-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started work on the inventory panel mass storage block
- Loading branch information
1 parent
8ea39f8
commit b987736
Showing
6 changed files
with
417 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
172 changes: 172 additions & 0 deletions
172
src/main/java/crazypants/enderio/machine/invpanel/chest/BlockInventoryChest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| package crazypants.enderio.machine.invpanel.chest; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import javax.annotation.Nonnull; | ||
|
|
||
| import com.enderio.core.api.client.gui.IResourceTooltipProvider; | ||
|
|
||
| import crazypants.enderio.GuiID; | ||
| import crazypants.enderio.ModObject; | ||
| import crazypants.enderio.machine.AbstractMachineBlock; | ||
| import crazypants.enderio.paint.IPaintable; | ||
| import crazypants.enderio.render.IBlockStateWrapper; | ||
| import crazypants.enderio.render.IRenderMapper; | ||
| import crazypants.enderio.render.IRenderMapper.IItemRenderMapper; | ||
| import crazypants.enderio.render.ISmartRenderAwareBlock; | ||
| import crazypants.enderio.render.property.EnumRenderMode; | ||
| import crazypants.enderio.teleport.telepad.render.TelePadRenderMapper; | ||
| import net.minecraft.block.properties.IProperty; | ||
| import net.minecraft.block.state.BlockStateContainer; | ||
| import net.minecraft.block.state.IBlockState; | ||
| import net.minecraft.creativetab.CreativeTabs; | ||
| import net.minecraft.entity.player.EntityPlayer; | ||
| import net.minecraft.item.Item; | ||
| import net.minecraft.item.ItemBlock; | ||
| 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.IBlockAccess; | ||
| import net.minecraft.world.World; | ||
| import net.minecraftforge.fml.relauncher.Side; | ||
| import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
|
||
| public class BlockInventoryChest extends AbstractMachineBlock<TileInventoryChest> | ||
| implements IResourceTooltipProvider, ISmartRenderAwareBlock, IPaintable.IBlockPaintableBlock, IPaintable.IWrenchHideablePaint { | ||
|
|
||
| public static BlockInventoryChest create() { | ||
| TileInventoryChest.create(); | ||
| BlockInventoryChest res = new BlockInventoryChest(); | ||
| res.init(); | ||
| return res; | ||
| } | ||
|
|
||
| protected BlockInventoryChest() { | ||
| super(ModObject.blockInventoryChest, TileInventoryChest.class); | ||
| initDefaultState(); | ||
| } | ||
|
|
||
| protected void initDefaultState() { | ||
| setDefaultState( | ||
| this.blockState.getBaseState().withProperty(EnumRenderMode.RENDER, EnumRenderMode.AUTO).withProperty(EnumChestSize.SIZE, EnumChestSize.TINY)); | ||
| } | ||
|
|
||
| @Override | ||
| protected @Nonnull BlockStateContainer createBlockState() { | ||
| return new BlockStateContainer(this, new IProperty[] { EnumRenderMode.RENDER, EnumChestSize.SIZE }); | ||
| } | ||
|
|
||
| @Override | ||
| public IBlockState getStateFromMeta(int meta) { | ||
| return getDefaultState().withProperty(EnumChestSize.SIZE, EnumChestSize.getTypeFromMeta(meta)); | ||
| } | ||
|
|
||
| @Override | ||
| public int getMetaFromState(IBlockState state) { | ||
| return EnumChestSize.getMetaFromType(state.getValue(EnumChestSize.SIZE)); | ||
| } | ||
|
|
||
| @Override | ||
| public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { | ||
| return state.withProperty(EnumRenderMode.RENDER, EnumRenderMode.AUTO); | ||
| } | ||
|
|
||
| @Override | ||
| protected void setBlockStateWrapperCache(@Nonnull IBlockStateWrapper blockStateWrapper, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, | ||
| @Nonnull TileInventoryChest tileEntity) { | ||
| blockStateWrapper.addCacheKey(0); | ||
| } | ||
|
|
||
| @Override | ||
| @SideOnly(Side.CLIENT) | ||
| public IItemRenderMapper getItemRenderMapper() { | ||
| return TelePadRenderMapper.instance; | ||
| } | ||
|
|
||
| @SideOnly(Side.CLIENT) | ||
| public IRenderMapper.IBlockRenderMapper getBlockRenderMapper() { | ||
| return TelePadRenderMapper.instance; | ||
| } | ||
|
|
||
| // NO GUI | ||
|
|
||
| @Override | ||
| public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| protected GuiID getGuiId() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean openGui(World world, BlockPos pos, EntityPlayer entityPlayer, EnumFacing side) { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean hasComparatorInputOverride(IBlockState state) { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos) { | ||
| TileInventoryChest te = getTileEntitySafe(worldIn, pos); | ||
| if (te != null) { | ||
| return te.getComparatorInputOverride(); | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| @Override | ||
| public @Nonnull TileEntity createTileEntity(World world, IBlockState state) { | ||
| TileInventoryChest te = TileInventoryChest.create(state.getValue(EnumChestSize.SIZE)); | ||
| te.init(); | ||
| return te; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean hasTileEntity(IBlockState state) { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected ItemBlock createItemBlock() { | ||
| ItemBlock ib = new ItemBlock(this) { | ||
| @Override | ||
| public String getUnlocalizedName(ItemStack stack) { | ||
| return EnumChestSize.getTypeFromMeta(stack.getMetadata()).getUnlocalizedName(this); | ||
| } | ||
|
|
||
| @Override | ||
| public int getMetadata(int damage) { | ||
| return damage; | ||
| } | ||
| }; | ||
| ib.setRegistryName(getName()); | ||
| ib.setHasSubtypes(true); | ||
| return ib; | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| @SideOnly(Side.CLIENT) | ||
| public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list) { | ||
| for (EnumChestSize size : EnumChestSize.values()) { | ||
| list.add(new ItemStack(itemIn, 1, EnumChestSize.getMetaFromType(size))); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public int damageDropped(IBlockState state) { | ||
| return getMetaFromState(state); | ||
| } | ||
|
|
||
| } |
58 changes: 58 additions & 0 deletions
58
src/main/java/crazypants/enderio/machine/invpanel/chest/EnumChestSize.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package crazypants.enderio.machine.invpanel.chest; | ||
|
|
||
| import java.util.Locale; | ||
|
|
||
| import javax.annotation.Nonnull; | ||
|
|
||
| import crazypants.util.NullHelper; | ||
| import net.minecraft.block.properties.PropertyEnum; | ||
| import net.minecraft.item.Item; | ||
| import net.minecraft.util.IStringSerializable; | ||
|
|
||
| public enum EnumChestSize implements IStringSerializable { | ||
| TINY(9), | ||
| SMALL(12), | ||
| MEDIUM(15), | ||
| BIG(18), | ||
| LARGE(21), | ||
| HUGE(24), | ||
| ENORMOUS(27), | ||
| WAREHOUSE(30), | ||
| WAREHOUSE13(60), | ||
|
|
||
| // Be honest, you expected a bra size joke here, didn't you? | ||
|
|
||
| ; | ||
|
|
||
| private final int slots; | ||
|
|
||
| private EnumChestSize(int rows) { | ||
| this.slots = rows * 9; | ||
| } | ||
|
|
||
| public int getSlots() { | ||
| return slots; | ||
| } | ||
|
|
||
| @SuppressWarnings("null") | ||
| public static final @Nonnull PropertyEnum<EnumChestSize> SIZE = PropertyEnum.<EnumChestSize> create("size", EnumChestSize.class); | ||
|
|
||
| @Override | ||
| public @Nonnull String getName() { | ||
| return NullHelper.notnullJ(name().toLowerCase(Locale.ENGLISH), "String.toLowerCase()"); | ||
| } | ||
|
|
||
| public String getUnlocalizedName(Item me) { | ||
| return me.getUnlocalizedName() + "_" + getName(); | ||
| } | ||
|
|
||
| public static EnumChestSize getTypeFromMeta(int meta) { | ||
| return values()[meta >= 0 && meta < values().length ? meta : 0]; | ||
| } | ||
|
|
||
| public static int getMetaFromType(EnumChestSize value) { | ||
| return value.ordinal(); | ||
| } | ||
|
|
||
|
|
||
| } |
Oops, something went wrong.