Update the Tiles for Storage. Also work on Drops. Not Finished.
This commit is contained in:
parent
e6b1f4f07a
commit
c25ab8227a
11 changed files with 290 additions and 199 deletions
|
@ -1,6 +1,9 @@
|
||||||
package techreborn.blocks.storage;
|
package techreborn.blocks.storage;
|
||||||
|
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import techreborn.client.GuiHandler;
|
import techreborn.client.GuiHandler;
|
||||||
import techreborn.tiles.storage.TileBatBox;
|
import techreborn.tiles.storage.TileBatBox;
|
||||||
|
@ -20,5 +23,9 @@ public class BlockBatBox extends BlockEnergyStorage
|
||||||
{
|
{
|
||||||
return new TileBatBox();
|
return new TileBatBox();
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
dropInventory(worldIn, pos, new ItemStack(this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ import reborncore.common.BaseTileBlock;
|
||||||
import reborncore.common.blocks.IRotationTexture;
|
import reborncore.common.blocks.IRotationTexture;
|
||||||
import techreborn.Core;
|
import techreborn.Core;
|
||||||
import techreborn.client.TechRebornCreativeTab;
|
import techreborn.client.TechRebornCreativeTab;
|
||||||
import techreborn.init.ModBlocks;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -48,6 +47,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock implements IRotat
|
||||||
public BlockEnergyStorage(String name, int guiID)
|
public BlockEnergyStorage(String name, int guiID)
|
||||||
{
|
{
|
||||||
super(Material.rock);
|
super(Material.rock);
|
||||||
|
setHardness(2f);
|
||||||
setUnlocalizedName("techreborn." + name.toLowerCase());
|
setUnlocalizedName("techreborn." + name.toLowerCase());
|
||||||
setCreativeTab(TechRebornCreativeTab.instance);
|
setCreativeTab(TechRebornCreativeTab.instance);
|
||||||
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
|
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);
|
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);
|
TileEntity tileEntity = world.getTileEntity(pos);
|
||||||
|
|
||||||
if (tileEntity == null)
|
if (tileEntity == null)
|
||||||
{
|
{
|
||||||
|
System.out.print("Null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(tileEntity instanceof IInventory))
|
if (!(tileEntity instanceof IInventory))
|
||||||
{
|
{
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +168,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock implements IRotat
|
||||||
}
|
}
|
||||||
items.add(itemStack.copy());
|
items.add(itemStack.copy());
|
||||||
}
|
}
|
||||||
|
items.add(itemToDrop);
|
||||||
for (ItemStack itemStack : items)
|
for (ItemStack itemStack : items)
|
||||||
{
|
{
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
|
@ -195,6 +192,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock implements IRotat
|
||||||
world.spawnEntityInWorld(entityItem);
|
world.spawnEntityInWorld(entityItem);
|
||||||
itemStack.stackSize = 0;
|
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)
|
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
|
||||||
{
|
{
|
||||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||||
items.add(new ItemStack(ModBlocks.machineframe));
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
package techreborn.blocks.storage;
|
package techreborn.blocks.storage;
|
||||||
|
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import techreborn.client.GuiHandler;
|
import techreborn.client.GuiHandler;
|
||||||
|
import techreborn.init.ModBlocks;
|
||||||
import techreborn.tiles.storage.TileMFE;
|
import techreborn.tiles.storage.TileMFE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,5 +24,10 @@ public class BlockMFE extends BlockEnergyStorage
|
||||||
{
|
{
|
||||||
return new TileMFE();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
package techreborn.blocks.storage;
|
package techreborn.blocks.storage;
|
||||||
|
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import techreborn.client.GuiHandler;
|
import techreborn.client.GuiHandler;
|
||||||
|
import techreborn.init.ModBlocks;
|
||||||
import techreborn.tiles.storage.TileMFSU;
|
import techreborn.tiles.storage.TileMFSU;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,6 +17,7 @@ public class BlockMFSU extends BlockEnergyStorage
|
||||||
public BlockMFSU()
|
public BlockMFSU()
|
||||||
{
|
{
|
||||||
super("MFSU", GuiHandler.mfsuID);
|
super("MFSU", GuiHandler.mfsuID);
|
||||||
|
setHardness(2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,4 +26,11 @@ public class BlockMFSU extends BlockEnergyStorage
|
||||||
return new TileMFSU();
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
package techreborn.blocks.transformers;
|
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.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import techreborn.client.TechRebornCreativeTab;
|
import techreborn.client.TechRebornCreativeTab;
|
||||||
|
import techreborn.init.ModBlocks;
|
||||||
import techreborn.tiles.transformers.TileHVTransformer;
|
import techreborn.tiles.transformers.TileHVTransformer;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 16/03/2016.
|
* Created by modmuss50 on 16/03/2016.
|
||||||
*/
|
*/
|
||||||
|
@ -53,5 +61,31 @@ public class BlockHVTransformer extends BlockLVTransformer
|
||||||
{
|
{
|
||||||
return prefix + "hv_transformer_bottom";
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
package techreborn.blocks.transformers;
|
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.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import techreborn.blocks.storage.BlockBatBox;
|
import techreborn.blocks.storage.BlockBatBox;
|
||||||
import techreborn.client.TechRebornCreativeTab;
|
import techreborn.client.TechRebornCreativeTab;
|
||||||
import techreborn.tiles.transformers.TileLVTransformer;
|
import techreborn.tiles.transformers.TileLVTransformer;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 16/03/2016.
|
* Created by modmuss50 on 16/03/2016.
|
||||||
*/
|
*/
|
||||||
|
@ -54,4 +61,30 @@ public class BlockLVTransformer extends BlockBatBox
|
||||||
{
|
{
|
||||||
return prefix + "lv_transformer_side";
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
package techreborn.blocks.transformers;
|
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.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import techreborn.client.TechRebornCreativeTab;
|
import techreborn.client.TechRebornCreativeTab;
|
||||||
|
import techreborn.init.ModBlocks;
|
||||||
import techreborn.tiles.transformers.TileMVTransformer;
|
import techreborn.tiles.transformers.TileMVTransformer;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 16/03/2016.
|
* Created by modmuss50 on 16/03/2016.
|
||||||
*/
|
*/
|
||||||
|
@ -53,4 +61,31 @@ public class BlockMVTransformer extends BlockLVTransformer
|
||||||
{
|
{
|
||||||
return prefix + "mv_transformer_side";
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,139 +1,16 @@
|
||||||
package techreborn.tiles.storage;
|
package techreborn.tiles.storage;
|
||||||
|
|
||||||
import ic2.api.tile.IWrenchable;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import reborncore.api.power.EnumPowerTier;
|
import reborncore.api.power.EnumPowerTier;
|
||||||
import reborncore.api.power.IEnergyItemInfo;
|
|
||||||
import reborncore.common.powerSystem.PoweredItem;
|
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
|
||||||
import reborncore.common.util.Inventory;
|
|
||||||
import techreborn.init.ModBlocks;
|
import techreborn.init.ModBlocks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 14/03/2016.
|
* Created by modmuss50 on 14/03/2016.
|
||||||
*/
|
*/
|
||||||
public class TileBatBox extends TilePowerAcceptor implements IWrenchable, ITickable
|
public class TileBatBox extends TileEnergyStorage
|
||||||
{
|
{
|
||||||
|
|
||||||
public Inventory inventory = new Inventory(2, "TileBatBox", 64, this);
|
|
||||||
public TileBatBox()
|
public TileBatBox()
|
||||||
{
|
{
|
||||||
super(1);
|
super("BatBox", 2, ModBlocks.batBox, EnumPowerTier.LOW, 32, 32, 4000);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumFacing getFacing()
|
|
||||||
{
|
|
||||||
return getFacingEnum();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
|
||||||
{
|
|
||||||
if (entityPlayer.isSneaking())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void updateEntity()
|
|
||||||
{
|
|
||||||
if(inventory.getStackInSlot(0) != null){
|
|
||||||
ItemStack stack = inventory.getStackInSlot(0);
|
|
||||||
IEnergyItemInfo item = (IEnergyItemInfo) inventory.getStackInSlot(0).getItem();
|
|
||||||
if(PoweredItem.getEnergy(stack) != PoweredItem.getMaxPower(stack)){
|
|
||||||
if(canUseEnergy(item.getMaxTransfer(stack)))
|
|
||||||
{
|
|
||||||
useEnergy(item.getMaxTransfer(stack));
|
|
||||||
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) + item.getMaxTransfer(stack), stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}if(inventory.getStackInSlot(1) != null){
|
|
||||||
ItemStack stack = inventory.getStackInSlot(1);
|
|
||||||
IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem();
|
|
||||||
if(item.canProvideEnergy(stack)){
|
|
||||||
if(getEnergy() != getMaxPower())
|
|
||||||
{
|
|
||||||
addEnergy(item.getMaxTransfer(stack));
|
|
||||||
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) - item.getMaxTransfer(stack), stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getWrenchDropRate()
|
|
||||||
{
|
|
||||||
return 1.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
|
||||||
{
|
|
||||||
return new ItemStack(ModBlocks.batBox);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isComplete()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getMaxPower()
|
|
||||||
{
|
|
||||||
return 40000;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canAcceptEnergy(EnumFacing direction)
|
|
||||||
{
|
|
||||||
return getFacingEnum() != direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(EnumFacing direction)
|
|
||||||
{
|
|
||||||
return getFacingEnum() == direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getMaxOutput()
|
|
||||||
{
|
|
||||||
return 32;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getMaxInput()
|
|
||||||
{
|
|
||||||
return 32;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumPowerTier getTier()
|
|
||||||
{
|
|
||||||
return EnumPowerTier.LOW;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void writeToNBT(NBTTagCompound tagCompound)
|
|
||||||
{
|
|
||||||
super.writeToNBT(tagCompound);
|
|
||||||
inventory.writeToNBT(tagCompound);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void readFromNBT(NBTTagCompound nbttagcompound)
|
|
||||||
{
|
|
||||||
super.readFromNBT(nbttagcompound);
|
|
||||||
inventory.readFromNBT(nbttagcompound);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
141
src/main/java/techreborn/tiles/storage/TileEnergyStorage.java
Normal file
141
src/main/java/techreborn/tiles/storage/TileEnergyStorage.java
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
package techreborn.tiles.storage;
|
||||||
|
|
||||||
|
import ic2.api.tile.IWrenchable;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.ITickable;
|
||||||
|
import reborncore.api.power.EnumPowerTier;
|
||||||
|
import reborncore.api.power.IEnergyItemInfo;
|
||||||
|
import reborncore.common.powerSystem.PoweredItem;
|
||||||
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
|
import reborncore.common.util.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Rushmead
|
||||||
|
*/
|
||||||
|
public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable, ITickable
|
||||||
|
{
|
||||||
|
|
||||||
|
public Inventory inventory;
|
||||||
|
public String name;
|
||||||
|
public Block wrenchDrop;
|
||||||
|
public EnumPowerTier tier;
|
||||||
|
public int maxInput;
|
||||||
|
public int maxOutput;
|
||||||
|
public int maxStorage;
|
||||||
|
public TileEnergyStorage(String name, int invSize, Block wrenchDrop, EnumPowerTier tier, int maxInput, int maxOuput, int maxStorage)
|
||||||
|
{
|
||||||
|
super(1);
|
||||||
|
inventory = new Inventory(invSize, "Tile" + name, 64, this);
|
||||||
|
this.wrenchDrop = wrenchDrop;
|
||||||
|
this.tier = tier;
|
||||||
|
this.name = name;
|
||||||
|
this.maxInput = maxInput;
|
||||||
|
this.maxOutput = maxOuput;
|
||||||
|
this.maxStorage = maxStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public EnumFacing getFacing()
|
||||||
|
{
|
||||||
|
return getFacingEnum();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||||
|
{
|
||||||
|
if (entityPlayer.isSneaking())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void updateEntity()
|
||||||
|
{
|
||||||
|
if (inventory.getStackInSlot(0) != null)
|
||||||
|
{
|
||||||
|
ItemStack stack = inventory.getStackInSlot(0);
|
||||||
|
IEnergyItemInfo item = (IEnergyItemInfo) inventory.getStackInSlot(0).getItem();
|
||||||
|
if (PoweredItem.getEnergy(stack) != PoweredItem.getMaxPower(stack))
|
||||||
|
{
|
||||||
|
if (canUseEnergy(item.getMaxTransfer(stack)))
|
||||||
|
{
|
||||||
|
useEnergy(item.getMaxTransfer(stack));
|
||||||
|
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) + item.getMaxTransfer(stack), stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (inventory.getStackInSlot(1) != null)
|
||||||
|
{
|
||||||
|
ItemStack stack = inventory.getStackInSlot(1);
|
||||||
|
IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem();
|
||||||
|
if (item.canProvideEnergy(stack))
|
||||||
|
{
|
||||||
|
if (getEnergy() != getMaxPower())
|
||||||
|
{
|
||||||
|
addEnergy(item.getMaxTransfer(stack));
|
||||||
|
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) - item.getMaxTransfer(stack), stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public float getWrenchDropRate()
|
||||||
|
{
|
||||||
|
return 1.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||||
|
{
|
||||||
|
return new ItemStack(wrenchDrop);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public double getMaxPower()
|
||||||
|
{
|
||||||
|
return maxStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean canAcceptEnergy(EnumFacing direction)
|
||||||
|
{
|
||||||
|
return getFacingEnum() != direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean canProvideEnergy(EnumFacing direction)
|
||||||
|
{
|
||||||
|
return getFacingEnum() == direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public double getMaxOutput()
|
||||||
|
{
|
||||||
|
return maxOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public double getMaxInput()
|
||||||
|
{
|
||||||
|
return maxInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public EnumPowerTier getTier()
|
||||||
|
{
|
||||||
|
return tier;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void writeToNBT(NBTTagCompound tagCompound)
|
||||||
|
{
|
||||||
|
super.writeToNBT(tagCompound);
|
||||||
|
inventory.writeToNBT(tagCompound);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void readFromNBT(NBTTagCompound nbttagcompound)
|
||||||
|
{
|
||||||
|
super.readFromNBT(nbttagcompound);
|
||||||
|
inventory.readFromNBT(nbttagcompound);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,43 +1,16 @@
|
||||||
package techreborn.tiles.storage;
|
package techreborn.tiles.storage;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import reborncore.api.power.EnumPowerTier;
|
import reborncore.api.power.EnumPowerTier;
|
||||||
import techreborn.init.ModBlocks;
|
import techreborn.init.ModBlocks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 14/03/2016.
|
* Created by modmuss50 on 14/03/2016.
|
||||||
*/
|
*/
|
||||||
public class TileMFE extends TileBatBox
|
public class TileMFE extends TileEnergyStorage
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
public TileMFE()
|
||||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
|
||||||
{
|
{
|
||||||
return new ItemStack(ModBlocks.mfe);
|
super("MFE", 2, ModBlocks.mfe, EnumPowerTier.MEDIUM, 512, 512, 4000000);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getMaxPower()
|
|
||||||
{
|
|
||||||
return 4000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getMaxOutput()
|
|
||||||
{
|
|
||||||
return 512;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getMaxInput()
|
|
||||||
{
|
|
||||||
return 512;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumPowerTier getTier()
|
|
||||||
{
|
|
||||||
return EnumPowerTier.MEDIUM;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,43 +1,16 @@
|
||||||
package techreborn.tiles.storage;
|
package techreborn.tiles.storage;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import reborncore.api.power.EnumPowerTier;
|
import reborncore.api.power.EnumPowerTier;
|
||||||
import techreborn.init.ModBlocks;
|
import techreborn.init.ModBlocks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 14/03/2016.
|
* Created by modmuss50 on 14/03/2016.
|
||||||
*/
|
*/
|
||||||
public class TileMFSU extends TileBatBox
|
public class TileMFSU extends TileEnergyStorage
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
public TileMFSU()
|
||||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
|
||||||
{
|
{
|
||||||
return new ItemStack(ModBlocks.mfsu);
|
super("MFSU", 2, ModBlocks.mfsu, EnumPowerTier.HIGH, 2048, 2048, 40000000);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getMaxPower()
|
|
||||||
{
|
|
||||||
return 40000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getMaxOutput()
|
|
||||||
{
|
|
||||||
return 2048;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getMaxInput()
|
|
||||||
{
|
|
||||||
return 2048;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumPowerTier getTier()
|
|
||||||
{
|
|
||||||
return EnumPowerTier.HIGH;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue