This commit is contained in:
modmuss50 2016-04-01 19:35:27 +01:00
parent 7369288829
commit 04f0736568
4 changed files with 14 additions and 94 deletions

View file

@ -9,6 +9,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import techreborn.client.GuiHandler;
import techreborn.init.ModBlocks;
import techreborn.tiles.storage.TileBatBox;
import java.util.ArrayList;
@ -30,37 +31,11 @@ public class BlockBatBox extends BlockEnergyStorage
{
return new TileBatBox();
}
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
ArrayList<ItemStack> items = (ArrayList<ItemStack>) dropInventory(worldIn, pos, new ItemStack(this));
for(ItemStack itemStack : items){
Random rand = new Random();
float dX = rand.nextFloat() * 0.8F + 0.1F;
float dY = rand.nextFloat() * 0.8F + 0.1F;
float dZ = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(worldIn, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ,
itemStack.copy());
if (itemStack.hasTagCompound())
{
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
worldIn.spawnEntityInWorld(entityItem);
itemStack.stackSize = 0;
}
}
@Override public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
return new ArrayList<ItemStack>();
ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(this));
return list;
}
}

View file

@ -28,6 +28,7 @@ import techreborn.Core;
import techreborn.client.TechRebornCreativeTab;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
@ -131,14 +132,11 @@ public abstract class BlockEnergyStorage extends BaseTileBlock implements IRotat
if (tileEntity == null)
{
System.out.print("Null");
return null;
return Collections.emptyList();
}
if (!(tileEntity instanceof IInventory))
{
System.out.print("Not INstance");
return null;
return Collections.emptyList();
}
IInventory inventory = (IInventory) tileEntity;
@ -183,7 +181,6 @@ public abstract class BlockEnergyStorage extends BaseTileBlock implements IRotat
@Override
public IBlockState getStateFromMeta(int meta)
{
boolean active = false;
EnumFacing facing = getSideFromint(meta);
return this.getDefaultState().withProperty(FACING, facing);
}

View file

@ -12,6 +12,7 @@ import techreborn.client.GuiHandler;
import techreborn.init.ModBlocks;
import techreborn.tiles.storage.TileMFE;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@ -31,37 +32,11 @@ public class BlockMFE extends BlockEnergyStorage
{
return new TileMFE();
}
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
ArrayList<ItemStack> items = (ArrayList<ItemStack>) dropInventory(worldIn, pos, new ItemStack(ModBlocks.machineframe, 1 , 6));
for(ItemStack itemStack : items){
Random rand = new Random();
float dX = rand.nextFloat() * 0.8F + 0.1F;
float dY = rand.nextFloat() * 0.8F + 0.1F;
float dZ = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(worldIn, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ,
itemStack.copy());
if (itemStack.hasTagCompound())
{
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
worldIn.spawnEntityInWorld(entityItem);
itemStack.stackSize = 0;
}
}
@Override public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
return new ArrayList<ItemStack>();
ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(ModBlocks.machineframe, 1 , 6));
return list;
}
}

View file

@ -33,37 +33,10 @@ public class BlockMFSU extends BlockEnergyStorage
return new TileMFSU();
}
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
ArrayList<ItemStack> items = (ArrayList<ItemStack>) dropInventory(worldIn, pos, new ItemStack(ModBlocks.machineframe, 1 , 7));
for(ItemStack itemStack : items){
Random rand = new Random();
float dX = rand.nextFloat() * 0.8F + 0.1F;
float dY = rand.nextFloat() * 0.8F + 0.1F;
float dZ = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(worldIn, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ,
itemStack.copy());
if (itemStack.hasTagCompound())
{
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
worldIn.spawnEntityInWorld(entityItem);
itemStack.stackSize = 0;
}
}
@Override public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
return new ArrayList<ItemStack>();
ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(ModBlocks.machineframe, 1 , 7));
return list;
}
}