Fixed some GUIS and some Mass Fabs
This commit is contained in:
parent
9ea37a0799
commit
78e8acce7b
18 changed files with 655 additions and 720 deletions
|
@ -1,26 +1,15 @@
|
|||
package techreborn.blocks.storage;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.blocks.IRotationTexture;
|
||||
import techreborn.Core;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.tiles.TileAesu;
|
||||
|
||||
public class BlockAESU extends BlockMachineBase implements IRotationTexture
|
||||
public class BlockAESU extends BlockEnergyStorage
|
||||
{
|
||||
|
||||
private final String prefix = "techreborn:blocks/machine/storage/";
|
||||
|
||||
public BlockAESU(Material material)
|
||||
public BlockAESU()
|
||||
{
|
||||
super();
|
||||
setUnlocalizedName("techreborn.aesu");
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
super("AESU", GuiHandler.aesuID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,43 +18,4 @@ public class BlockAESU extends BlockMachineBase implements IRotationTexture
|
|||
return new TileAesu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX,
|
||||
float hitY, float hitZ)
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
player.openGui(Core.INSTANCE, GuiHandler.aesuID, world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFrontOff()
|
||||
{
|
||||
return prefix + "aesu_front";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFrontOn()
|
||||
{
|
||||
return prefix + "aesu_front";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSide()
|
||||
{
|
||||
return prefix + "aesu_side";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTop()
|
||||
{
|
||||
return prefix + "aesu_top";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBottom()
|
||||
{
|
||||
return prefix + "aesu_bottom";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,199 +1,18 @@
|
|||
package techreborn.blocks.storage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import me.modmuss50.jsonDestroyer.api.ITexturedBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDynamicLiquid;
|
||||
import net.minecraft.block.BlockStaticLiquid;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.BlockFluidBase;
|
||||
import reborncore.common.BaseTileBlock;
|
||||
import reborncore.common.blocks.IRotationTexture;
|
||||
import techreborn.Core;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.tiles.storage.TileBatBox;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterators;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 14/03/2016.
|
||||
*/
|
||||
public class BlockBatBox extends BaseTileBlock implements IRotationTexture, ITexturedBlock
|
||||
public class BlockBatBox extends BlockEnergyStorage
|
||||
{
|
||||
|
||||
public static PropertyDirection FACING = PropertyDirection.create("facing", Facings.ALL);
|
||||
protected final String prefix = "techreborn:blocks/machine/storage/";
|
||||
|
||||
public BlockBatBox()
|
||||
{
|
||||
super(Material.rock);
|
||||
setUnlocalizedName("techreborn.batBox");
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
|
||||
ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
player.openGui(Core.INSTANCE, GuiHandler.batboxID, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
return true;
|
||||
}
|
||||
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
FACING = PropertyDirection.create("facing", Facings.ALL);
|
||||
return new BlockStateContainer(this, FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
super.onBlockAdded(worldIn, pos, state);
|
||||
this.setDefaultFacing(worldIn, pos, state);
|
||||
}
|
||||
|
||||
private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!worldIn.isRemote)
|
||||
{
|
||||
IBlockState sate = worldIn.getBlockState(pos.north());
|
||||
Block block = sate.getBlock();
|
||||
IBlockState state1 = worldIn.getBlockState(pos.south());
|
||||
Block block1 = state1.getBlock();
|
||||
IBlockState state2 = worldIn.getBlockState(pos.west());
|
||||
Block block2 = state2.getBlock();
|
||||
IBlockState state3 = worldIn.getBlockState(pos.east());
|
||||
Block block3 = state3.getBlock();
|
||||
EnumFacing enumfacing = (EnumFacing) state.getValue(FACING);
|
||||
|
||||
if (enumfacing == EnumFacing.NORTH && block.isFullBlock(state) && !block1.isFullBlock(state1))
|
||||
{
|
||||
enumfacing = EnumFacing.SOUTH;
|
||||
} else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock(state1) && !block.isFullBlock(state))
|
||||
{
|
||||
enumfacing = EnumFacing.NORTH;
|
||||
} else if (enumfacing == EnumFacing.WEST && block2.isFullBlock(state2) && !block3.isFullBlock(state2))
|
||||
{
|
||||
enumfacing = EnumFacing.EAST;
|
||||
} else if (enumfacing == EnumFacing.EAST && block3.isFullBlock(state3) && !block2.isFullBlock(state2))
|
||||
{
|
||||
enumfacing = EnumFacing.WEST;
|
||||
}
|
||||
|
||||
worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer,
|
||||
ItemStack stack)
|
||||
{
|
||||
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
|
||||
EnumFacing facing = placer.getHorizontalFacing().getOpposite();
|
||||
if (placer.rotationPitch < -50)
|
||||
{
|
||||
facing = EnumFacing.DOWN;
|
||||
} else if (placer.rotationPitch > 50)
|
||||
{
|
||||
facing = EnumFacing.UP;
|
||||
}
|
||||
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)
|
||||
{
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
|
||||
if (tileEntity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!(tileEntity instanceof IInventory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IInventory inventory = (IInventory) tileEntity;
|
||||
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
||||
{
|
||||
ItemStack itemStack = inventory.getStackInSlot(i);
|
||||
|
||||
if (itemStack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (itemStack != null && itemStack.stackSize > 0)
|
||||
{
|
||||
if (itemStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
if (((ItemBlock) itemStack.getItem()).block instanceof BlockFluidBase
|
||||
|| ((ItemBlock) itemStack.getItem()).block instanceof BlockStaticLiquid
|
||||
|| ((ItemBlock) itemStack.getItem()).block instanceof BlockDynamicLiquid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
items.add(itemStack.copy());
|
||||
}
|
||||
|
||||
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(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("Batbox", GuiHandler.batboxID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -202,170 +21,4 @@ public class BlockBatBox extends BaseTileBlock implements IRotationTexture, ITex
|
|||
return new TileBatBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
int facingInt = getSideFromEnum(state.getValue(FACING));
|
||||
return facingInt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
boolean active = false;
|
||||
EnumFacing facing = getSideFromint(meta);
|
||||
return this.getDefaultState().withProperty(FACING, facing);
|
||||
}
|
||||
|
||||
public void setFacing(EnumFacing facing, World world, BlockPos pos)
|
||||
{
|
||||
world.setBlockState(pos, world.getBlockState(pos).withProperty(FACING, facing));
|
||||
}
|
||||
|
||||
public EnumFacing getSideFromint(int i)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
return EnumFacing.NORTH;
|
||||
} else if (i == 1)
|
||||
{
|
||||
return EnumFacing.SOUTH;
|
||||
} else if (i == 2)
|
||||
{
|
||||
return EnumFacing.EAST;
|
||||
} else if (i == 3)
|
||||
{
|
||||
return EnumFacing.WEST;
|
||||
} else if (i == 4)
|
||||
{
|
||||
return EnumFacing.UP;
|
||||
} else if (i == 5)
|
||||
{
|
||||
return EnumFacing.DOWN;
|
||||
}
|
||||
return EnumFacing.NORTH;
|
||||
}
|
||||
|
||||
public int getSideFromEnum(EnumFacing facing)
|
||||
{
|
||||
if (facing == EnumFacing.NORTH)
|
||||
{
|
||||
return 0;
|
||||
} else if (facing == EnumFacing.SOUTH)
|
||||
{
|
||||
return 1;
|
||||
} else if (facing == EnumFacing.EAST)
|
||||
{
|
||||
return 2;
|
||||
} else if (facing == EnumFacing.WEST)
|
||||
{
|
||||
return 3;
|
||||
} else if (facing == EnumFacing.UP)
|
||||
{
|
||||
return 4;
|
||||
} else if (facing == EnumFacing.DOWN)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
|
||||
{
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
items.add(new ItemStack(this));
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFrontOff()
|
||||
{
|
||||
return prefix + "batbox_front";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFrontOn()
|
||||
{
|
||||
return prefix + "batbox_front";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSide()
|
||||
{
|
||||
return prefix + "batbox_side";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTop()
|
||||
{
|
||||
return prefix + "batbox_top";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBottom()
|
||||
{
|
||||
return prefix + "batbox_bottom";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureNameFromState(IBlockState blockState, EnumFacing facing)
|
||||
{
|
||||
if (this instanceof IRotationTexture)
|
||||
{
|
||||
IRotationTexture rotationTexture = (IRotationTexture) this;
|
||||
if (getFacing(blockState) == facing)
|
||||
{
|
||||
return rotationTexture.getFrontOff();
|
||||
}
|
||||
if (facing == EnumFacing.UP)
|
||||
{
|
||||
return rotationTexture.getTop();
|
||||
}
|
||||
if (facing == EnumFacing.DOWN)
|
||||
{
|
||||
return rotationTexture.getBottom();
|
||||
}
|
||||
return rotationTexture.getSide();
|
||||
}
|
||||
return "techreborn:blocks/machine/machine_side";
|
||||
}
|
||||
|
||||
public EnumFacing getFacing(IBlockState state)
|
||||
{
|
||||
return state.getValue(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int amountOfStates()
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
|
||||
public enum Facings implements Predicate<EnumFacing>,Iterable<EnumFacing>
|
||||
{
|
||||
ALL;
|
||||
|
||||
public EnumFacing[] facings()
|
||||
{
|
||||
return new EnumFacing[] { EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.SOUTH, EnumFacing.WEST,
|
||||
EnumFacing.UP, EnumFacing.DOWN };
|
||||
}
|
||||
|
||||
public EnumFacing random(Random rand)
|
||||
{
|
||||
EnumFacing[] aenumfacing = this.facings();
|
||||
return aenumfacing[rand.nextInt(aenumfacing.length)];
|
||||
}
|
||||
|
||||
public boolean apply(EnumFacing p_apply_1_)
|
||||
{
|
||||
return p_apply_1_ != null;
|
||||
}
|
||||
|
||||
public Iterator<EnumFacing> iterator()
|
||||
{
|
||||
return Iterators.forArray(this.facings());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
368
src/main/java/techreborn/blocks/storage/BlockEnergyStorage.java
Normal file
368
src/main/java/techreborn/blocks/storage/BlockEnergyStorage.java
Normal file
|
@ -0,0 +1,368 @@
|
|||
package techreborn.blocks.storage;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterators;
|
||||
import me.modmuss50.jsonDestroyer.api.ITexturedBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDynamicLiquid;
|
||||
import net.minecraft.block.BlockStaticLiquid;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.BlockFluidBase;
|
||||
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;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by Rushmead
|
||||
*/
|
||||
public abstract class BlockEnergyStorage extends BaseTileBlock implements IRotationTexture, ITexturedBlock
|
||||
{
|
||||
public static PropertyDirection FACING = PropertyDirection.create("facing", Facings.ALL);
|
||||
protected final String prefix = "techreborn:blocks/machine/storage/";
|
||||
public String name;
|
||||
public int guiID;
|
||||
|
||||
public BlockEnergyStorage(String name, int guiID)
|
||||
{
|
||||
super(Material.rock);
|
||||
setUnlocalizedName("techreborn." + name.toLowerCase());
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
|
||||
this.name = name;
|
||||
this.guiID = guiID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
|
||||
ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
player.openGui(Core.INSTANCE, guiID, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
return true;
|
||||
}
|
||||
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
FACING = PropertyDirection.create("facing", Facings.ALL);
|
||||
return new BlockStateContainer(this, FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
super.onBlockAdded(worldIn, pos, state);
|
||||
this.setDefaultFacing(worldIn, pos, state);
|
||||
}
|
||||
|
||||
private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!worldIn.isRemote)
|
||||
{
|
||||
IBlockState sate = worldIn.getBlockState(pos.north());
|
||||
Block block = sate.getBlock();
|
||||
IBlockState state1 = worldIn.getBlockState(pos.south());
|
||||
Block block1 = state1.getBlock();
|
||||
IBlockState state2 = worldIn.getBlockState(pos.west());
|
||||
Block block2 = state2.getBlock();
|
||||
IBlockState state3 = worldIn.getBlockState(pos.east());
|
||||
Block block3 = state3.getBlock();
|
||||
EnumFacing enumfacing = (EnumFacing) state.getValue(FACING);
|
||||
|
||||
if (enumfacing == EnumFacing.NORTH && block.isFullBlock(state) && !block1.isFullBlock(state1))
|
||||
{
|
||||
enumfacing = EnumFacing.SOUTH;
|
||||
} else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock(state1) && !block.isFullBlock(state))
|
||||
{
|
||||
enumfacing = EnumFacing.NORTH;
|
||||
} else if (enumfacing == EnumFacing.WEST && block2.isFullBlock(state2) && !block3.isFullBlock(state2))
|
||||
{
|
||||
enumfacing = EnumFacing.EAST;
|
||||
} else if (enumfacing == EnumFacing.EAST && block3.isFullBlock(state3) && !block2.isFullBlock(state2))
|
||||
{
|
||||
enumfacing = EnumFacing.WEST;
|
||||
}
|
||||
|
||||
worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer,
|
||||
ItemStack stack)
|
||||
{
|
||||
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
|
||||
EnumFacing facing = placer.getHorizontalFacing().getOpposite();
|
||||
if (placer.rotationPitch < -50)
|
||||
{
|
||||
facing = EnumFacing.DOWN;
|
||||
} else if (placer.rotationPitch > 50)
|
||||
{
|
||||
facing = EnumFacing.UP;
|
||||
}
|
||||
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)
|
||||
{
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
|
||||
if (tileEntity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!(tileEntity instanceof IInventory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IInventory inventory = (IInventory) tileEntity;
|
||||
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
||||
{
|
||||
ItemStack itemStack = inventory.getStackInSlot(i);
|
||||
|
||||
if (itemStack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (itemStack != null && itemStack.stackSize > 0)
|
||||
{
|
||||
if (itemStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
if (((ItemBlock) itemStack.getItem()).block instanceof BlockFluidBase
|
||||
|| ((ItemBlock) itemStack.getItem()).block instanceof BlockStaticLiquid
|
||||
|| ((ItemBlock) itemStack.getItem()).block instanceof BlockDynamicLiquid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
items.add(itemStack.copy());
|
||||
}
|
||||
|
||||
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(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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
int facingInt = getSideFromEnum(state.getValue(FACING));
|
||||
return facingInt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
boolean active = false;
|
||||
EnumFacing facing = getSideFromint(meta);
|
||||
return this.getDefaultState().withProperty(FACING, facing);
|
||||
}
|
||||
|
||||
public void setFacing(EnumFacing facing, World world, BlockPos pos)
|
||||
{
|
||||
world.setBlockState(pos, world.getBlockState(pos).withProperty(FACING, facing));
|
||||
}
|
||||
|
||||
public EnumFacing getSideFromint(int i)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
return EnumFacing.NORTH;
|
||||
} else if (i == 1)
|
||||
{
|
||||
return EnumFacing.SOUTH;
|
||||
} else if (i == 2)
|
||||
{
|
||||
return EnumFacing.EAST;
|
||||
} else if (i == 3)
|
||||
{
|
||||
return EnumFacing.WEST;
|
||||
} else if (i == 4)
|
||||
{
|
||||
return EnumFacing.UP;
|
||||
} else if (i == 5)
|
||||
{
|
||||
return EnumFacing.DOWN;
|
||||
}
|
||||
return EnumFacing.NORTH;
|
||||
}
|
||||
|
||||
public int getSideFromEnum(EnumFacing facing)
|
||||
{
|
||||
if (facing == EnumFacing.NORTH)
|
||||
{
|
||||
return 0;
|
||||
} else if (facing == EnumFacing.SOUTH)
|
||||
{
|
||||
return 1;
|
||||
} else if (facing == EnumFacing.EAST)
|
||||
{
|
||||
return 2;
|
||||
} else if (facing == EnumFacing.WEST)
|
||||
{
|
||||
return 3;
|
||||
} else if (facing == EnumFacing.UP)
|
||||
{
|
||||
return 4;
|
||||
} else if (facing == EnumFacing.DOWN)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFrontOff()
|
||||
{
|
||||
return prefix + name.toLowerCase() + "_front";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFrontOn()
|
||||
{
|
||||
return prefix + name.toLowerCase() + "_front";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSide()
|
||||
{
|
||||
return prefix + name.toLowerCase() + "_side";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTop()
|
||||
{
|
||||
return prefix + name.toLowerCase() + "_top";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBottom()
|
||||
{
|
||||
return prefix + name.toLowerCase() + "_bottom";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureNameFromState(IBlockState blockState, EnumFacing facing)
|
||||
{
|
||||
if (this instanceof IRotationTexture)
|
||||
{
|
||||
IRotationTexture rotationTexture = (IRotationTexture) this;
|
||||
if (getFacing(blockState) == facing)
|
||||
{
|
||||
return rotationTexture.getFrontOff();
|
||||
}
|
||||
if (facing == EnumFacing.UP)
|
||||
{
|
||||
return rotationTexture.getTop();
|
||||
}
|
||||
if (facing == EnumFacing.DOWN)
|
||||
{
|
||||
return rotationTexture.getBottom();
|
||||
}
|
||||
return rotationTexture.getSide();
|
||||
}
|
||||
return "techreborn:blocks/machine/machine_side";
|
||||
}
|
||||
|
||||
public EnumFacing getFacing(IBlockState state)
|
||||
{
|
||||
return state.getValue(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int amountOfStates()
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
|
||||
public enum Facings implements Predicate<EnumFacing>,Iterable<EnumFacing>
|
||||
{
|
||||
ALL;
|
||||
|
||||
public EnumFacing[] facings()
|
||||
{
|
||||
return new EnumFacing[] { EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.SOUTH, EnumFacing.WEST,
|
||||
EnumFacing.UP, EnumFacing.DOWN };
|
||||
}
|
||||
|
||||
public EnumFacing random(Random rand)
|
||||
{
|
||||
EnumFacing[] aenumfacing = this.facings();
|
||||
return aenumfacing[rand.nextInt(aenumfacing.length)];
|
||||
}
|
||||
|
||||
public boolean apply(EnumFacing p_apply_1_)
|
||||
{
|
||||
return p_apply_1_ != null;
|
||||
}
|
||||
|
||||
public Iterator<EnumFacing> iterator()
|
||||
{
|
||||
return Iterators.forArray(this.facings());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,79 +1,36 @@
|
|||
package techreborn.blocks.storage;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.blocks.IAdvancedRotationTexture;
|
||||
import techreborn.Core;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.tiles.idsu.TileIDSU;
|
||||
|
||||
public class BlockIDSU extends BlockMachineBase implements IAdvancedRotationTexture
|
||||
public class BlockIDSU extends BlockEnergyStorage
|
||||
{
|
||||
|
||||
private final String prefix = "techreborn:blocks/machine/storage/";
|
||||
|
||||
public BlockIDSU(Material material)
|
||||
public BlockIDSU()
|
||||
{
|
||||
super();
|
||||
setUnlocalizedName("techreborn.idsu");
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
super("IDSU", GuiHandler.idsuID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
|
||||
public TileEntity createNewTileEntity(World world, int p_149915_2_)
|
||||
{
|
||||
return new TileIDSU(5, 2048, 100000000);
|
||||
return new TileIDSU();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX,
|
||||
float hitY, float hitZ)
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
player.openGui(Core.INSTANCE, GuiHandler.idsuID, world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack)
|
||||
@Override public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY,
|
||||
float hitZ, int meta, EntityLivingBase placer)
|
||||
{
|
||||
super.onBlockPlacedBy(world, x, y, z, player, itemstack);
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileIDSU)
|
||||
{
|
||||
((TileIDSU) tile).ownerUdid = player.getUniqueID().toString();
|
||||
((TileIDSU) tile).ownerUdid = placer.getUniqueID().toString();
|
||||
}
|
||||
return this.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFront(boolean isActive)
|
||||
{
|
||||
return prefix + "idsu_front";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSide(boolean isActive)
|
||||
{
|
||||
return prefix + "idsu_side";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTop(boolean isActive)
|
||||
{
|
||||
return prefix + "idsu_top";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBottom(boolean isActive)
|
||||
{
|
||||
return prefix + "idsu_bottom";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,65 +1,21 @@
|
|||
package techreborn.blocks.storage;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.blocks.IAdvancedRotationTexture;
|
||||
import techreborn.Core;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.tiles.lesu.TileLesu;
|
||||
|
||||
public class BlockLESU extends BlockMachineBase implements IAdvancedRotationTexture
|
||||
public class BlockLESU extends BlockEnergyStorage
|
||||
{
|
||||
|
||||
private final String prefix = "techreborn:blocks/machine/storage/";
|
||||
|
||||
public BlockLESU(Material material)
|
||||
public BlockLESU()
|
||||
{
|
||||
super();
|
||||
setUnlocalizedName("techreborn.lesu");
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
super("LESU", GuiHandler.lesuID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
|
||||
public TileEntity createNewTileEntity(World world, int p_149915_2_)
|
||||
{
|
||||
return new TileLesu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX,
|
||||
float hitY, float hitZ)
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
player.openGui(Core.INSTANCE, GuiHandler.lesuID, world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFront(boolean isActive)
|
||||
{
|
||||
return prefix + "lesu_front";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSide(boolean isActive)
|
||||
{
|
||||
return prefix + "lesu_side";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTop(boolean isActive)
|
||||
{
|
||||
return prefix + "lesu_top";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBottom(boolean isActive)
|
||||
{
|
||||
return prefix + "lesu_bottom";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,20 +2,17 @@ package techreborn.blocks.storage;
|
|||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.tiles.storage.TileMFE;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 14/03/2016.
|
||||
*/
|
||||
public class BlockMFE extends BlockBatBox
|
||||
public class BlockMFE extends BlockEnergyStorage
|
||||
{
|
||||
|
||||
public BlockMFE()
|
||||
{
|
||||
super();
|
||||
setUnlocalizedName("techreborn.mfe");
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
super("MFE", GuiHandler.mfeID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,33 +21,4 @@ public class BlockMFE extends BlockBatBox
|
|||
return new TileMFE();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFrontOff()
|
||||
{
|
||||
return prefix + "mfe_front";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFrontOn()
|
||||
{
|
||||
return prefix + "mfe_front";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSide()
|
||||
{
|
||||
return prefix + "mfe_side";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTop()
|
||||
{
|
||||
return prefix + "mfe_top";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBottom()
|
||||
{
|
||||
return prefix + "mfe_bottom";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,20 +2,17 @@ package techreborn.blocks.storage;
|
|||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.tiles.storage.TileMFSU;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 14/03/2016.
|
||||
*/
|
||||
public class BlockMFSU extends BlockBatBox
|
||||
public class BlockMFSU extends BlockEnergyStorage
|
||||
{
|
||||
|
||||
public BlockMFSU()
|
||||
{
|
||||
super();
|
||||
setUnlocalizedName("techreborn.mfsu");
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
super("MFSU", GuiHandler.mfsuID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,33 +21,4 @@ public class BlockMFSU extends BlockBatBox
|
|||
return new TileMFSU();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFrontOff()
|
||||
{
|
||||
return prefix + "mfsu_front";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFrontOn()
|
||||
{
|
||||
return prefix + "mfsu_front";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSide()
|
||||
{
|
||||
return prefix + "mfsu_side";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTop()
|
||||
{
|
||||
return prefix + "mfsu_top";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBottom()
|
||||
{
|
||||
return prefix + "mfsu_bottom";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,114 +4,17 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
import techreborn.client.container.ContainerAesu;
|
||||
import techreborn.client.container.ContainerAlloyFurnace;
|
||||
import techreborn.client.container.ContainerAlloySmelter;
|
||||
import techreborn.client.container.ContainerAssemblingMachine;
|
||||
import techreborn.client.container.ContainerBatbox;
|
||||
import techreborn.client.container.ContainerBlastFurnace;
|
||||
import techreborn.client.container.ContainerCentrifuge;
|
||||
import techreborn.client.container.ContainerChargeBench;
|
||||
import techreborn.client.container.ContainerChemicalReactor;
|
||||
import techreborn.client.container.ContainerChunkloader;
|
||||
import techreborn.client.container.ContainerCompressor;
|
||||
import techreborn.client.container.ContainerDestructoPack;
|
||||
import techreborn.client.container.ContainerDieselGenerator;
|
||||
import techreborn.client.container.ContainerDigitalChest;
|
||||
import techreborn.client.container.ContainerElectricFurnace;
|
||||
import techreborn.client.container.ContainerExtractor;
|
||||
import techreborn.client.container.ContainerFusionReactor;
|
||||
import techreborn.client.container.ContainerGasTurbine;
|
||||
import techreborn.client.container.ContainerGenerator;
|
||||
import techreborn.client.container.ContainerGrinder;
|
||||
import techreborn.client.container.ContainerIDSU;
|
||||
import techreborn.client.container.ContainerImplosionCompressor;
|
||||
import techreborn.client.container.ContainerIndustrialElectrolyzer;
|
||||
import techreborn.client.container.ContainerIndustrialGrinder;
|
||||
import techreborn.client.container.ContainerIndustrialSawmill;
|
||||
import techreborn.client.container.ContainerIronFurnace;
|
||||
import techreborn.client.container.ContainerLesu;
|
||||
import techreborn.client.container.ContainerMatterFabricator;
|
||||
import techreborn.client.container.ContainerQuantumChest;
|
||||
import techreborn.client.container.ContainerQuantumTank;
|
||||
import techreborn.client.container.ContainerRecycler;
|
||||
import techreborn.client.container.ContainerRollingMachine;
|
||||
import techreborn.client.container.ContainerScrapboxinator;
|
||||
import techreborn.client.container.ContainerSemifluidGenerator;
|
||||
import techreborn.client.container.ContainerThermalGenerator;
|
||||
import techreborn.client.container.ContainerVacuumFreezer;
|
||||
import techreborn.client.gui.GuiAesu;
|
||||
import techreborn.client.gui.GuiAlloyFurnace;
|
||||
import techreborn.client.gui.GuiAlloySmelter;
|
||||
import techreborn.client.gui.GuiAssemblingMachine;
|
||||
import techreborn.client.gui.GuiBatbox;
|
||||
import techreborn.client.gui.GuiBlastFurnace;
|
||||
import techreborn.client.gui.GuiCentrifuge;
|
||||
import techreborn.client.gui.GuiChargeBench;
|
||||
import techreborn.client.gui.GuiChemicalReactor;
|
||||
import techreborn.client.gui.GuiChunkLoader;
|
||||
import techreborn.client.gui.GuiCompressor;
|
||||
import techreborn.client.gui.GuiDestructoPack;
|
||||
import techreborn.client.gui.GuiDieselGenerator;
|
||||
import techreborn.client.gui.GuiDigitalChest;
|
||||
import techreborn.client.gui.GuiElectricFurnace;
|
||||
import techreborn.client.gui.GuiExtractor;
|
||||
import techreborn.client.gui.GuiFusionReactor;
|
||||
import techreborn.client.gui.GuiGasTurbine;
|
||||
import techreborn.client.gui.GuiGenerator;
|
||||
import techreborn.client.gui.GuiGrinder;
|
||||
import techreborn.client.gui.GuiIDSU;
|
||||
import techreborn.client.gui.GuiImplosionCompressor;
|
||||
import techreborn.client.gui.GuiIndustrialElectrolyzer;
|
||||
import techreborn.client.gui.GuiIndustrialGrinder;
|
||||
import techreborn.client.gui.GuiIndustrialSawmill;
|
||||
import techreborn.client.gui.GuiIronFurnace;
|
||||
import techreborn.client.gui.GuiLesu;
|
||||
import techreborn.client.gui.GuiMatterFabricator;
|
||||
import techreborn.client.gui.GuiQuantumChest;
|
||||
import techreborn.client.gui.GuiQuantumTank;
|
||||
import techreborn.client.gui.GuiRecycler;
|
||||
import techreborn.client.gui.GuiRollingMachine;
|
||||
import techreborn.client.gui.GuiScrapboxinator;
|
||||
import techreborn.client.gui.GuiSemifluidGenerator;
|
||||
import techreborn.client.gui.GuiThermalGenerator;
|
||||
import techreborn.client.gui.GuiVacuumFreezer;
|
||||
import techreborn.client.container.*;
|
||||
import techreborn.client.gui.*;
|
||||
import techreborn.manual.GuiManual;
|
||||
import techreborn.tiles.TileAesu;
|
||||
import techreborn.tiles.TileAlloyFurnace;
|
||||
import techreborn.tiles.TileAlloySmelter;
|
||||
import techreborn.tiles.TileAssemblingMachine;
|
||||
import techreborn.tiles.TileBlastFurnace;
|
||||
import techreborn.tiles.TileCentrifuge;
|
||||
import techreborn.tiles.TileChargeBench;
|
||||
import techreborn.tiles.TileChemicalReactor;
|
||||
import techreborn.tiles.TileChunkLoader;
|
||||
import techreborn.tiles.TileDigitalChest;
|
||||
import techreborn.tiles.TileImplosionCompressor;
|
||||
import techreborn.tiles.TileIndustrialElectrolyzer;
|
||||
import techreborn.tiles.TileIndustrialGrinder;
|
||||
import techreborn.tiles.TileIndustrialSawmill;
|
||||
import techreborn.tiles.TileIronFurnace;
|
||||
import techreborn.tiles.TileMatterFabricator;
|
||||
import techreborn.tiles.TileQuantumChest;
|
||||
import techreborn.tiles.TileQuantumTank;
|
||||
import techreborn.tiles.TileRollingMachine;
|
||||
import techreborn.tiles.TileScrapboxinator;
|
||||
import techreborn.tiles.TileVacuumFreezer;
|
||||
import techreborn.tiles.*;
|
||||
import techreborn.tiles.fusionReactor.TileEntityFusionController;
|
||||
import techreborn.tiles.generator.TileDieselGenerator;
|
||||
import techreborn.tiles.generator.TileGasTurbine;
|
||||
import techreborn.tiles.generator.TileGenerator;
|
||||
import techreborn.tiles.generator.TileSemifluidGenerator;
|
||||
import techreborn.tiles.generator.TileThermalGenerator;
|
||||
import techreborn.tiles.generator.*;
|
||||
import techreborn.tiles.idsu.TileIDSU;
|
||||
import techreborn.tiles.lesu.TileLesu;
|
||||
import techreborn.tiles.storage.TileBatBox;
|
||||
import techreborn.tiles.teir1.TileCompressor;
|
||||
import techreborn.tiles.teir1.TileElectricFurnace;
|
||||
import techreborn.tiles.teir1.TileExtractor;
|
||||
import techreborn.tiles.teir1.TileGrinder;
|
||||
import techreborn.tiles.teir1.TileRecycler;
|
||||
import techreborn.tiles.storage.TileMFSU;
|
||||
import techreborn.tiles.teir1.*;
|
||||
|
||||
public class GuiHandler implements IGuiHandler
|
||||
{
|
||||
|
@ -153,7 +56,8 @@ public class GuiHandler implements IGuiHandler
|
|||
public static final int recyclerID = 37;
|
||||
public static final int scrapboxinatorID = 38;
|
||||
public static final int batboxID = 39;
|
||||
|
||||
public static final int mfsuID = 40;
|
||||
public static final int mfeID = 41;
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
|
@ -280,6 +184,8 @@ public class GuiHandler implements IGuiHandler
|
|||
} else if (ID == batboxID)
|
||||
{
|
||||
return new ContainerBatbox((TileBatBox) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
}else if (ID == mfsuID){
|
||||
return new ContainerMFSU((TileMFSU) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -403,6 +309,10 @@ public class GuiHandler implements IGuiHandler
|
|||
{
|
||||
return new GuiBatbox(player, (TileBatBox) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
}
|
||||
else if (ID == mfsuID)
|
||||
{
|
||||
return new GuiMFSU(player, (TileMFSU) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.inventory.ICrafting;
|
|||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.client.gui.SlotCharge;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.storage.TileBatBox;
|
||||
|
||||
|
@ -38,6 +39,9 @@ public class ContainerBatbox extends RebornContainer
|
|||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
|
||||
this.addSlotToContainer(new SlotCharge(tile.inventory, 0, 80, 17));
|
||||
this.addSlotToContainer(new SlotCharge(tile.inventory, 1, 80, 53));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
110
src/main/java/techreborn/client/container/ContainerMFSU.java
Normal file
110
src/main/java/techreborn/client/container/ContainerMFSU.java
Normal file
|
@ -0,0 +1,110 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.client.gui.SlotCharge;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.storage.TileMFSU;
|
||||
|
||||
public class ContainerMFSU extends RebornContainer
|
||||
{
|
||||
|
||||
public int burnTime = 0;
|
||||
public int totalBurnTime = 0;
|
||||
public int energy;
|
||||
public int tickTime;
|
||||
EntityPlayer player;
|
||||
TileMFSU tile;
|
||||
private static final EntityEquipmentSlot[] equipmentSlots = new EntityEquipmentSlot[] {EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET};
|
||||
public ContainerMFSU(TileMFSU tile, EntityPlayer player)
|
||||
{
|
||||
super();
|
||||
this.tile = tile;
|
||||
this.player = player;
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
final EntityEquipmentSlot slot = equipmentSlots[k];
|
||||
addSlotToContainer(new Slot(player.inventory, player.inventory.getSizeInventory() - 2 - k, 44, 6 + k * 19)
|
||||
{
|
||||
@Override
|
||||
public int getSlotStackLimit() { return 1; }
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return stack != null && stack.getItem().isValidArmor(stack, slot, player);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.addSlotToContainer(new SlotCharge(tile.inventory, 0, 80, 17));
|
||||
this.addSlotToContainer(new SlotCharge(tile.inventory, 1, 80, 53));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < this.crafters.size(); i++)
|
||||
{
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get(i);
|
||||
if (this.energy != (int) tile.getEnergy())
|
||||
{
|
||||
icrafting.sendProgressBarUpdate(this, 2, (int) tile.getEnergy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftGuiOpened(ICrafting crafting)
|
||||
{
|
||||
super.onCraftGuiOpened(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 2, (int) tile.getEnergy());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int id, int value)
|
||||
{
|
||||
if (id == 0)
|
||||
{
|
||||
this.burnTime = value;
|
||||
} else if (id == 1)
|
||||
{
|
||||
this.totalBurnTime = value;
|
||||
} else if (id == 2)
|
||||
{
|
||||
this.energy = value;
|
||||
}
|
||||
this.tile.setEnergy(energy);
|
||||
}
|
||||
|
||||
public int getScaledBurnTime(int i)
|
||||
{
|
||||
return (int) (((float) burnTime / (float) totalBurnTime) * i);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
@ -15,6 +12,9 @@ import techreborn.client.container.ContainerAesu;
|
|||
import techreborn.packets.PacketAesu;
|
||||
import techreborn.tiles.TileAesu;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
public class GuiAesu extends GuiContainer
|
||||
{
|
||||
|
||||
|
@ -40,10 +40,10 @@ public class GuiAesu extends GuiContainer
|
|||
this.buttonList.clear();
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.buttonList.add(new GuiButton(0, k + 128, l + 5, 15, 15, "++"));
|
||||
this.buttonList.add(new GuiButton(1, k + 128, l + 5 + 20, 15, 15, "+"));
|
||||
this.buttonList.add(new GuiButton(2, k + 128, l + 5 + (20 * 2), 15, 15, "-"));
|
||||
this.buttonList.add(new GuiButton(3, k + 128, l + 5 + (20 * 3), 15, 15, "--"));
|
||||
this.buttonList.add(new GuiButton(0, k + 115, l + 5, 15, 20, "++"));
|
||||
this.buttonList.add(new GuiButton(1, k + 115, l + 5 + 20, 15, 20, "+"));
|
||||
this.buttonList.add(new GuiButton(2, k + 115, l + 5 + (20 * 2), 15, 20, "-"));
|
||||
this.buttonList.add(new GuiButton(3, k + 115, l + 5 + (20 * 3), 15, 20, "--"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,7 +44,7 @@ public class GuiBatbox extends GuiContainer
|
|||
|
||||
int j = 0;
|
||||
|
||||
j = generator.getEnergyScaled(24);
|
||||
j = generator.getEnergyScaled(12);
|
||||
if (j > 0)
|
||||
{
|
||||
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
|
||||
|
|
77
src/main/java/techreborn/client/gui/GuiMFSU.java
Normal file
77
src/main/java/techreborn/client/gui/GuiMFSU.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.client.container.ContainerMFSU;
|
||||
import techreborn.tiles.storage.TileMFSU;
|
||||
|
||||
/**
|
||||
* Created by Rushmead
|
||||
*/
|
||||
public class GuiMFSU extends GuiContainer
|
||||
{
|
||||
|
||||
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/mfsu.png");
|
||||
|
||||
TileMFSU generator;
|
||||
|
||||
ContainerMFSU containerGenerator;
|
||||
|
||||
public GuiMFSU(EntityPlayer player, TileMFSU generator)
|
||||
{
|
||||
super(new ContainerMFSU(generator, player));
|
||||
this.xSize = 176;
|
||||
this.ySize = 167;
|
||||
this.generator = generator;
|
||||
this.containerGenerator = (ContainerMFSU) this.inventorySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_)
|
||||
{
|
||||
this.mc.getTextureManager().bindTexture(texture);
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
int j = 0;
|
||||
|
||||
j = generator.getEnergyScaled(24);
|
||||
if (j > 0)
|
||||
{
|
||||
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
|
||||
}
|
||||
//
|
||||
// if (containerGenerator.burnTime != 0)
|
||||
// {
|
||||
// j = containerGenerator.getScaledBurnTime(13);
|
||||
// this.drawTexturedModalRect(k + 80, l + 38 + 12 - j, 176, 30 - j, 14,
|
||||
// j + 1);
|
||||
// }
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
|
||||
{
|
||||
String name = I18n.translateToLocal("tile.techreborn.mfsu.name");
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
|
||||
4210752);
|
||||
|
||||
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), this.xSize - 60,
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(generator.getMaxPower()), 110, this.ySize - 150,
|
||||
4210752);
|
||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerGenerator.energy), 110, this.ySize - 160,
|
||||
4210752);
|
||||
}
|
||||
}
|
|
@ -331,15 +331,15 @@ public class ModBlocks
|
|||
GameRegistry.registerBlock(ChemicalReactor, "chemicalreactor");
|
||||
GameRegistry.registerTileEntity(TileChemicalReactor.class, "TileChemicalReactorTR");
|
||||
|
||||
Idsu = new BlockIDSU(Material.rock);
|
||||
Idsu = new BlockIDSU();
|
||||
GameRegistry.registerBlock(Idsu, "idsu");
|
||||
GameRegistry.registerTileEntity(TileIDSU.class, "TileIDSUTR");
|
||||
|
||||
Aesu = new BlockAESU(Material.rock);
|
||||
Aesu = new BlockAESU();
|
||||
GameRegistry.registerBlock(Aesu, ItemBlockAesu.class, "aesu");
|
||||
GameRegistry.registerTileEntity(TileAesu.class, "TileAesuTR");
|
||||
|
||||
Lesu = new BlockLESU(Material.rock);
|
||||
Lesu = new BlockLESU();
|
||||
GameRegistry.registerBlock(Lesu, "lesu");
|
||||
GameRegistry.registerTileEntity(TileLesu.class, "TileLesuTR");
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package techreborn.items.tools;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import ic2.api.tile.IWrenchable;
|
||||
import me.modmuss50.jsonDestroyer.api.ITexturedItem;
|
||||
import net.minecraft.block.BlockDynamicLiquid;
|
||||
import net.minecraft.block.BlockStaticLiquid;
|
||||
|
@ -27,7 +24,10 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
import techreborn.client.TechRebornCreativeTabMisc;
|
||||
import techreborn.items.ItemTR;
|
||||
import techreborn.lib.ModInfo;
|
||||
import ic2.api.tile.IWrenchable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 26/02/2016.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import ic2.api.tile.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -13,9 +13,8 @@ import reborncore.common.util.Inventory;
|
|||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModItems;
|
||||
import ic2.api.tile.IWrenchable;
|
||||
|
||||
public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory
|
||||
public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchable, IInventory
|
||||
{
|
||||
|
||||
public static int fabricationRate = 2666656;
|
||||
|
@ -185,26 +184,26 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
|
|||
return inventory.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5, 6 } : new int[] { 0, 1, 2, 3, 4, 5, 6 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
if (slotIndex == 6)
|
||||
return false;
|
||||
return isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
{
|
||||
return slotIndex == 6;
|
||||
}
|
||||
// // ISidedInventory
|
||||
// @Override
|
||||
// public int[] getSlotsForFace(EnumFacing side)
|
||||
// {
|
||||
// return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5, 6 } : new int[] { 0, 1, 2, 3, 4, 5, 6 };
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
// {
|
||||
// if (slotIndex == 6)
|
||||
// return false;
|
||||
// return isItemValidForSlot(slotIndex, itemStack);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side)
|
||||
// {
|
||||
// return slotIndex == 6;
|
||||
// }
|
||||
|
||||
public int maxProgresstime()
|
||||
{
|
||||
|
|
|
@ -2,9 +2,11 @@ package techreborn.tiles.storage;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.init.ModBlocks;
|
||||
import ic2.api.tile.IWrenchable;
|
||||
|
||||
|
@ -14,6 +16,7 @@ import ic2.api.tile.IWrenchable;
|
|||
public class TileBatBox extends TilePowerAcceptor implements IWrenchable
|
||||
{
|
||||
|
||||
public Inventory inventory = new Inventory(2, "TileBatBox", 64, this);
|
||||
public TileBatBox()
|
||||
{
|
||||
super(1);
|
||||
|
@ -93,4 +96,16 @@ public class TileBatBox extends TilePowerAcceptor implements IWrenchable
|
|||
{
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -73,7 +73,7 @@ tile.techreborn.windmill.name=Wind Mill
|
|||
tile.techreborn.ironfurnace.name=Iron Furnace
|
||||
tile.techreborn.recycler.name=Recycler
|
||||
tile.techreborn.scrapboxinator.name=Scrapbox-inator
|
||||
tile.techreborn.batBox.name=Battery Box
|
||||
tile.techreborn.batbox.name=Battery Box
|
||||
tile.techreborn.mfe.name=MFE
|
||||
tile.techreborn.mfsu.name=MFSU
|
||||
tile.techreborn.reinforcedglass.name=Reinforced Glass
|
||||
|
|
Loading…
Add table
Reference in a new issue