Update the Tiles for Storage. Also work on Drops. Not Finished.

This commit is contained in:
Stuart Pomeroy 2016-03-28 11:45:21 +01:00
parent e6b1f4f07a
commit c25ab8227a
11 changed files with 290 additions and 199 deletions

View file

@ -1,6 +1,9 @@
package techreborn.blocks.storage;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import techreborn.client.GuiHandler;
import techreborn.tiles.storage.TileBatBox;
@ -20,5 +23,9 @@ public class BlockBatBox extends BlockEnergyStorage
{
return new TileBatBox();
}
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
dropInventory(worldIn, pos, new ItemStack(this));
}
}

View file

@ -28,7 +28,6 @@ import reborncore.common.BaseTileBlock;
import reborncore.common.blocks.IRotationTexture;
import techreborn.Core;
import techreborn.client.TechRebornCreativeTab;
import techreborn.init.ModBlocks;
import java.util.ArrayList;
import java.util.Iterator;
@ -48,6 +47,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock implements IRotat
public BlockEnergyStorage(String name, int guiID)
{
super(Material.rock);
setHardness(2f);
setUnlocalizedName("techreborn." + name.toLowerCase());
setCreativeTab(TechRebornCreativeTab.instance);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
@ -125,23 +125,20 @@ public abstract class BlockEnergyStorage extends BaseTileBlock implements IRotat
setFacing(facing, worldIn, pos);
}
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
dropInventory(worldIn, pos);
super.breakBlock(worldIn, pos, state);
}
protected void dropInventory(World world, BlockPos pos)
protected void dropInventory(World world, BlockPos pos, ItemStack itemToDrop)
{
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity == null)
{
System.out.print("Null");
return;
}
if (!(tileEntity instanceof IInventory))
{
return;
}
@ -171,7 +168,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock implements IRotat
}
items.add(itemStack.copy());
}
items.add(itemToDrop);
for (ItemStack itemStack : items)
{
Random rand = new Random();
@ -195,6 +192,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock implements IRotat
world.spawnEntityInWorld(entityItem);
itemStack.stackSize = 0;
}
}
@ -270,7 +268,6 @@ public abstract class BlockEnergyStorage extends BaseTileBlock implements IRotat
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
List<ItemStack> items = new ArrayList<ItemStack>();
items.add(new ItemStack(ModBlocks.machineframe));
return items;
}

View file

@ -1,8 +1,12 @@
package techreborn.blocks.storage;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import techreborn.client.GuiHandler;
import techreborn.init.ModBlocks;
import techreborn.tiles.storage.TileMFE;
/**
@ -20,5 +24,10 @@ public class BlockMFE extends BlockEnergyStorage
{
return new TileMFE();
}
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
dropInventory(worldIn, pos, new ItemStack(ModBlocks.machineframe));
super.breakBlock(worldIn, pos, state);
}
}

View file

@ -1,8 +1,12 @@
package techreborn.blocks.storage;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import techreborn.client.GuiHandler;
import techreborn.init.ModBlocks;
import techreborn.tiles.storage.TileMFSU;
/**
@ -13,6 +17,7 @@ public class BlockMFSU extends BlockEnergyStorage
public BlockMFSU()
{
super("MFSU", GuiHandler.mfsuID);
setHardness(2f);
}
@Override
@ -21,4 +26,11 @@ public class BlockMFSU extends BlockEnergyStorage
return new TileMFSU();
}
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
dropInventory(worldIn, pos, new ItemStack(ModBlocks.machineframe, 1 ,7));
super.breakBlock(worldIn, pos, state);
}
}

View file

@ -1,10 +1,18 @@
package techreborn.blocks.transformers;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import techreborn.client.TechRebornCreativeTab;
import techreborn.init.ModBlocks;
import techreborn.tiles.transformers.TileHVTransformer;
import java.util.Random;
/**
* Created by modmuss50 on 16/03/2016.
*/
@ -53,5 +61,31 @@ public class BlockHVTransformer extends BlockLVTransformer
{
return prefix + "hv_transformer_bottom";
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
ItemStack itemStack = new ItemStack(ModBlocks.machineframe, 1 ,7);
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(world, 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;
world.spawnEntityInWorld(entityItem);
itemStack.stackSize = 0;
}
}

View file

@ -1,11 +1,18 @@
package techreborn.blocks.transformers;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import techreborn.blocks.storage.BlockBatBox;
import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.transformers.TileLVTransformer;
import java.util.Random;
/**
* Created by modmuss50 on 16/03/2016.
*/
@ -54,4 +61,30 @@ public class BlockLVTransformer extends BlockBatBox
{
return prefix + "lv_transformer_side";
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
ItemStack itemStack = new ItemStack(this);
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(world, 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;
world.spawnEntityInWorld(entityItem);
itemStack.stackSize = 0;
}
}

View file

@ -1,10 +1,18 @@
package techreborn.blocks.transformers;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import techreborn.client.TechRebornCreativeTab;
import techreborn.init.ModBlocks;
import techreborn.tiles.transformers.TileMVTransformer;
import java.util.Random;
/**
* Created by modmuss50 on 16/03/2016.
*/
@ -53,4 +61,31 @@ public class BlockMVTransformer extends BlockLVTransformer
{
return prefix + "mv_transformer_side";
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
ItemStack itemStack = new ItemStack(ModBlocks.machineframe);
itemStack.setItemDamage(6);
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(world, 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;
world.spawnEntityInWorld(entityItem);
itemStack.stackSize = 0;
super.breakBlock(world, pos, state);
}
}