Add better block info system.
This commit is contained in:
		| @@ -15,7 +15,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode; | |||||||
| import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheFluid; | import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheFluid; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper; | import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper; | ||||||
| import com.raoulvdberge.refinedstorage.block.BlockFluidStorage; | import com.raoulvdberge.refinedstorage.block.BlockFluidStorage; | ||||||
| import com.raoulvdberge.refinedstorage.block.FluidStorageType; | import com.raoulvdberge.refinedstorage.block.enums.FluidStorageType; | ||||||
| import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid; | import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid; | ||||||
| import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode; | import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileFluidStorage; | import com.raoulvdberge.refinedstorage.tile.TileFluidStorage; | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode; | |||||||
| import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheItem; | import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheItem; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper; | import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper; | ||||||
| import com.raoulvdberge.refinedstorage.block.BlockStorage; | import com.raoulvdberge.refinedstorage.block.BlockStorage; | ||||||
| import com.raoulvdberge.refinedstorage.block.ItemStorageType; | import com.raoulvdberge.refinedstorage.block.enums.ItemStorageType; | ||||||
| import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase; | import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase; | ||||||
| import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode; | import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileStorage; | import com.raoulvdberge.refinedstorage.tile.TileStorage; | ||||||
|   | |||||||
| @@ -8,8 +8,8 @@ import com.raoulvdberge.refinedstorage.api.util.IOneSixMigrationHelper; | |||||||
| import com.raoulvdberge.refinedstorage.apiimpl.API; | import com.raoulvdberge.refinedstorage.apiimpl.API; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeFluidStorage; | import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeFluidStorage; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeStorage; | import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeStorage; | ||||||
| import com.raoulvdberge.refinedstorage.block.FluidStorageType; | import com.raoulvdberge.refinedstorage.block.enums.FluidStorageType; | ||||||
| import com.raoulvdberge.refinedstorage.block.ItemStorageType; | import com.raoulvdberge.refinedstorage.block.enums.ItemStorageType; | ||||||
| import com.raoulvdberge.refinedstorage.item.ItemPattern; | import com.raoulvdberge.refinedstorage.item.ItemPattern; | ||||||
| import com.raoulvdberge.refinedstorage.tile.config.IFilterable; | import com.raoulvdberge.refinedstorage.tile.config.IFilterable; | ||||||
| import net.minecraft.item.Item; | import net.minecraft.item.Item; | ||||||
|   | |||||||
| @@ -1,21 +1,14 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block; | ||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RS; | import com.raoulvdberge.refinedstorage.RS; | ||||||
| import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode; | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
| import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy; | import com.raoulvdberge.refinedstorage.block.info.IBlockInfo; | ||||||
| import com.raoulvdberge.refinedstorage.api.network.security.Permission; |  | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable; |  | ||||||
| import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy; |  | ||||||
| import com.raoulvdberge.refinedstorage.container.ContainerBase; |  | ||||||
| import com.raoulvdberge.refinedstorage.item.ItemBlockBase; | import com.raoulvdberge.refinedstorage.item.ItemBlockBase; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileBase; | import com.raoulvdberge.refinedstorage.tile.TileBase; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileNode; |  | ||||||
| import com.raoulvdberge.refinedstorage.util.WorldUtils; | import com.raoulvdberge.refinedstorage.util.WorldUtils; | ||||||
| import net.minecraft.block.Block; | import net.minecraft.block.Block; | ||||||
| import net.minecraft.block.material.Material; |  | ||||||
| import net.minecraft.block.state.BlockStateContainer; | import net.minecraft.block.state.BlockStateContainer; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| import net.minecraft.entity.Entity; |  | ||||||
| import net.minecraft.entity.player.EntityPlayer; | import net.minecraft.entity.player.EntityPlayer; | ||||||
| import net.minecraft.inventory.InventoryHelper; | import net.minecraft.inventory.InventoryHelper; | ||||||
| import net.minecraft.item.Item; | import net.minecraft.item.Item; | ||||||
| @@ -30,32 +23,25 @@ import net.minecraftforge.items.IItemHandler; | |||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
|  |  | ||||||
| public abstract class BlockBase extends Block { | public abstract class BlockBase extends Block { | ||||||
|     private final String name; |     protected final IBlockInfo info; | ||||||
|  |  | ||||||
|     public BlockBase(String name) { |     public BlockBase(IBlockInfo info) { | ||||||
|         super(Material.ROCK); |         super(info.getMaterial()); | ||||||
|  |  | ||||||
|         this.name = name; |         this.info = info; | ||||||
|  |  | ||||||
|         setHardness(1.9F); |         setHardness(info.getHardness()); | ||||||
|         setRegistryName(getDomain(), name); |         setRegistryName(info.getModId(), info.getId()); | ||||||
|         setCreativeTab(RS.INSTANCE.tab); |         setCreativeTab(RS.INSTANCE.tab); | ||||||
|     } |         setSoundType(info.getSoundType()); | ||||||
|  |  | ||||||
|     protected String getDomain() { |  | ||||||
|         return RS.ID; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     protected Object getModObject() { |  | ||||||
|         return RS.INSTANCE; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public String getUnlocalizedName() { |     public String getUnlocalizedName() { | ||||||
|         return "block." + getDomain() + ":" + name; |         return "block." + info.getModId() + ":" + info.getId(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected BlockStateContainer.Builder createBlockStateBuilder() { |     protected BlockStateContainer.Builder createStateBuilder() { | ||||||
|         BlockStateContainer.Builder builder = new BlockStateContainer.Builder(this); |         BlockStateContainer.Builder builder = new BlockStateContainer.Builder(this); | ||||||
|  |  | ||||||
|         if (getDirection() != null) { |         if (getDirection() != null) { | ||||||
| @@ -67,7 +53,7 @@ public abstract class BlockBase extends Block { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected BlockStateContainer createBlockState() { |     protected BlockStateContainer createBlockState() { | ||||||
|         return createBlockStateBuilder().build(); |         return createStateBuilder().build(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public Item createItem() { |     public Item createItem() { | ||||||
| @@ -111,10 +97,6 @@ public abstract class BlockBase extends Block { | |||||||
|  |  | ||||||
|             EnumFacing newDirection = getDirection().cycle(tile.getDirection()); |             EnumFacing newDirection = getDirection().cycle(tile.getDirection()); | ||||||
|  |  | ||||||
|             if (tile instanceof TileNode && ((TileNode) tile).getNode() instanceof ICoverable && ((ICoverable) ((TileNode) tile).getNode()).getCoverManager().hasCover(newDirection)) { |  | ||||||
|                 return false; |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             tile.setDirection(newDirection); |             tile.setDirection(newDirection); | ||||||
|  |  | ||||||
|             WorldUtils.updateBlock(world, pos); |             WorldUtils.updateBlock(world, pos); | ||||||
| @@ -129,21 +111,15 @@ public abstract class BlockBase extends Block { | |||||||
|     public void breakBlock(World world, BlockPos pos, IBlockState state) { |     public void breakBlock(World world, BlockPos pos, IBlockState state) { | ||||||
|         dropContents(world, pos); |         dropContents(world, pos); | ||||||
|         removeTile(world, pos, state); |         removeTile(world, pos, state); | ||||||
|  |  | ||||||
|         for (EntityPlayer player : world.playerEntities) { |  | ||||||
|             if (player.openContainer instanceof ContainerBase && ((ContainerBase) player.openContainer).getTile() != null && ((ContainerBase) player.openContainer).getTile().getPos().equals(pos)) { |  | ||||||
|                 player.closeScreen(); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected void removeTile(World world, BlockPos pos, IBlockState state) { |     void removeTile(World world, BlockPos pos, IBlockState state) { | ||||||
|         if (hasTileEntity(state)) { |         if (hasTileEntity(state)) { | ||||||
|             world.removeTileEntity(pos); |             world.removeTileEntity(pos); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected void dropContents(World world, BlockPos pos) { |     void dropContents(World world, BlockPos pos) { | ||||||
|         TileEntity tile = world.getTileEntity(pos); |         TileEntity tile = world.getTileEntity(pos); | ||||||
|  |  | ||||||
|         if (tile instanceof TileBase && ((TileBase) tile).getDrops() != null) { |         if (tile instanceof TileBase && ((TileBase) tile).getDrops() != null) { | ||||||
| @@ -169,51 +145,22 @@ public abstract class BlockBase extends Block { | |||||||
|         world.setBlockToAir(pos); |         world.setBlockToAir(pos); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected boolean tryOpenNetworkGui(int guiId, EntityPlayer player, World world, BlockPos pos, EnumFacing facing) { |     @Override | ||||||
|         return tryOpenNetworkGui(guiId, player, world, pos, facing, Permission.MODIFY); |     public final boolean hasTileEntity(IBlockState state) { | ||||||
|     } |         return info.hasTileEntity(); | ||||||
|  |  | ||||||
|     protected boolean tryOpenNetworkGui(int guiId, EntityPlayer player, World world, BlockPos pos, EnumFacing facing, Permission... permissions) { |  | ||||||
|         TileEntity tile = world.getTileEntity(pos); |  | ||||||
|  |  | ||||||
|         if (tile != null && tile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing)) { |  | ||||||
|             INetworkNodeProxy nodeProxy = CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY.cast(tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing)); |  | ||||||
|             INetworkNode node = nodeProxy.getNode(); |  | ||||||
|  |  | ||||||
|             if (node.getNetwork() != null) { |  | ||||||
|                 for (Permission permission : permissions) { |  | ||||||
|                     if (!node.getNetwork().getSecurityManager().hasPermission(permission, player)) { |  | ||||||
|                         WorldUtils.sendNoPermissionMessage(player); |  | ||||||
|  |  | ||||||
|                         return false; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         player.openGui(getModObject(), guiId, world, pos.getX(), pos.getY(), pos.getZ()); |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) { |     public final TileEntity createTileEntity(World world, IBlockState state) { | ||||||
|         TileEntity tile = world.getTileEntity(pos); |         return info.createTileEntity(); | ||||||
|  |  | ||||||
|         if (tile != null && tile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, null)) { |  | ||||||
|             INetworkNodeProxy nodeProxy = tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, null); |  | ||||||
|             INetworkNode node = nodeProxy.getNode(); |  | ||||||
|  |  | ||||||
|             if (node.getNetwork() != null) { |  | ||||||
|                 return entity instanceof EntityPlayer && node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, (EntityPlayer) entity); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return super.canEntityDestroy(state, world, pos, entity); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nullable |     @Nullable | ||||||
|     public Direction getDirection() { |     public BlockDirection getDirection() { | ||||||
|         return Direction.HORIZONTAL; |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public final IBlockInfo getInfo() { | ||||||
|  |         return info; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -4,6 +4,9 @@ import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode; | |||||||
| import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable; | import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.Cover; | import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.Cover; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager; | import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.IBlockInfo; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.property.PropertyObject; | ||||||
| import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy; | import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.AdvancedRayTraceResult; | import com.raoulvdberge.refinedstorage.render.collision.AdvancedRayTraceResult; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.AdvancedRayTracer; | import com.raoulvdberge.refinedstorage.render.collision.AdvancedRayTracer; | ||||||
| @@ -13,6 +16,8 @@ import com.raoulvdberge.refinedstorage.tile.TileBase; | |||||||
| import com.raoulvdberge.refinedstorage.tile.TileCable; | import com.raoulvdberge.refinedstorage.tile.TileCable; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileNode; | import com.raoulvdberge.refinedstorage.tile.TileNode; | ||||||
| import com.raoulvdberge.refinedstorage.util.RenderUtils; | import com.raoulvdberge.refinedstorage.util.RenderUtils; | ||||||
|  | import net.minecraft.block.SoundType; | ||||||
|  | import net.minecraft.block.material.Material; | ||||||
| import net.minecraft.block.properties.PropertyBool; | import net.minecraft.block.properties.PropertyBool; | ||||||
| import net.minecraft.block.state.BlockFaceShape; | import net.minecraft.block.state.BlockFaceShape; | ||||||
| import net.minecraft.block.state.BlockStateContainer; | import net.minecraft.block.state.BlockStateContainer; | ||||||
| @@ -30,7 +35,6 @@ import net.minecraft.world.IBlockAccess; | |||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
| import net.minecraftforge.common.property.IExtendedBlockState; | import net.minecraftforge.common.property.IExtendedBlockState; | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; |  | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| @@ -49,17 +53,16 @@ public class BlockCable extends BlockNode { | |||||||
|     private static final PropertyBool UP = PropertyBool.create("up"); |     private static final PropertyBool UP = PropertyBool.create("up"); | ||||||
|     private static final PropertyBool DOWN = PropertyBool.create("down"); |     private static final PropertyBool DOWN = PropertyBool.create("down"); | ||||||
|  |  | ||||||
|     public BlockCable(String name) { |     public BlockCable(IBlockInfo info) { | ||||||
|         super(name); |         super(info); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public BlockCable() { |     public BlockCable() { | ||||||
|         this("cable"); |         super(createBuilder("cable").tileEntity(TileCable::new).create()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     static BlockInfoBuilder createBuilder(String id) { | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |         return BlockInfoBuilder.forId(id).material(Material.GLASS).soundType(SoundType.GLASS).hardness(0.35F); | ||||||
|         return new TileCable(); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public boolean hasConnectivityState() { |     public boolean hasConnectivityState() { | ||||||
| @@ -68,7 +71,7 @@ public class BlockCable extends BlockNode { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected BlockStateContainer createBlockState() { |     protected BlockStateContainer createBlockState() { | ||||||
|         return super.createBlockStateBuilder() |         return super.createStateBuilder() | ||||||
|             .add(NORTH) |             .add(NORTH) | ||||||
|             .add(EAST) |             .add(EAST) | ||||||
|             .add(SOUTH) |             .add(SOUTH) | ||||||
| @@ -339,10 +342,4 @@ public class BlockCable extends BlockNode { | |||||||
|     public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) { |     public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) { | ||||||
|         return BlockFaceShape.UNDEFINED; |         return BlockFaceShape.UNDEFINED; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return null; |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block; | ||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup; | import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsCable; | import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsCable; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsConstructor; | import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsConstructor; | ||||||
| @@ -18,7 +19,13 @@ import java.util.List; | |||||||
|  |  | ||||||
| public class BlockConstructor extends BlockCable { | public class BlockConstructor extends BlockCable { | ||||||
|     public BlockConstructor() { |     public BlockConstructor() { | ||||||
|         super("constructor"); |         super(createBuilder("constructor").tileEntity(TileConstructor::new).create()); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     @Nullable | ||||||
|  |     public BlockDirection getDirection() { | ||||||
|  |         return BlockDirection.ANY; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -55,32 +62,17 @@ public class BlockConstructor extends BlockCable { | |||||||
|         return groups; |         return groups; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileConstructor(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!canAccessGui(state, world, pos, hitX, hitY, hitZ)) { |         if (!canAccessGui(state, world, pos, hitX, hitY, hitZ)) { | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.CONSTRUCTOR, player, world, pos, side); | ||||||
|             tryOpenNetworkGui(RSGui.CONSTRUCTOR, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean hasConnectivityState() { |     public boolean hasConnectivityState() { | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return Direction.ANY; |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -2,6 +2,9 @@ package com.raoulvdberge.refinedstorage.block; | |||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSBlocks; | import com.raoulvdberge.refinedstorage.RSBlocks; | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.enums.ControllerEnergyType; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.enums.ControllerType; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.item.ItemBlockController; | import com.raoulvdberge.refinedstorage.item.ItemBlockController; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileController; | import com.raoulvdberge.refinedstorage.tile.TileController; | ||||||
| import net.minecraft.block.properties.PropertyEnum; | import net.minecraft.block.properties.PropertyEnum; | ||||||
| @@ -13,7 +16,6 @@ import net.minecraft.entity.player.EntityPlayer; | |||||||
| import net.minecraft.item.Item; | import net.minecraft.item.Item; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.item.ItemStack; | ||||||
| import net.minecraft.nbt.NBTTagCompound; | import net.minecraft.nbt.NBTTagCompound; | ||||||
| import net.minecraft.tileentity.TileEntity; |  | ||||||
| import net.minecraft.util.EnumFacing; | import net.minecraft.util.EnumFacing; | ||||||
| import net.minecraft.util.EnumHand; | import net.minecraft.util.EnumHand; | ||||||
| import net.minecraft.util.NonNullList; | import net.minecraft.util.NonNullList; | ||||||
| @@ -21,14 +23,12 @@ import net.minecraft.util.math.BlockPos; | |||||||
| import net.minecraft.world.IBlockAccess; | import net.minecraft.world.IBlockAccess; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; | public class BlockController extends BlockNodeProxy { | ||||||
|  |  | ||||||
| public class BlockController extends BlockBase { |  | ||||||
|     public static final PropertyEnum TYPE = PropertyEnum.create("type", ControllerType.class); |     public static final PropertyEnum TYPE = PropertyEnum.create("type", ControllerType.class); | ||||||
|     public static final PropertyEnum ENERGY_TYPE = PropertyEnum.create("energy_type", ControllerEnergyType.class); |     public static final PropertyEnum ENERGY_TYPE = PropertyEnum.create("energy_type", ControllerEnergyType.class); | ||||||
|  |  | ||||||
|     public BlockController() { |     public BlockController() { | ||||||
|         super("controller"); |         super(BlockInfoBuilder.forId("controller").tileEntity(TileController::new).create()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -40,7 +40,7 @@ public class BlockController extends BlockBase { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected BlockStateContainer createBlockState() { |     protected BlockStateContainer createBlockState() { | ||||||
|         return createBlockStateBuilder() |         return createStateBuilder() | ||||||
|             .add(TYPE) |             .add(TYPE) | ||||||
|             .add(ENERGY_TYPE) |             .add(ENERGY_TYPE) | ||||||
|             .build(); |             .build(); | ||||||
| @@ -62,23 +62,9 @@ public class BlockController extends BlockBase { | |||||||
|             .withProperty(ENERGY_TYPE, ((TileController) world.getTileEntity(pos)).getEnergyType()); |             .withProperty(ENERGY_TYPE, ((TileController) world.getTileEntity(pos)).getEnergyType()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public boolean hasTileEntity(IBlockState state) { |  | ||||||
|         return true; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileController(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.CONTROLLER, player, world, pos, side); | ||||||
|             tryOpenNetworkGui(RSGui.CONTROLLER, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -108,12 +94,6 @@ public class BlockController extends BlockBase { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public Item createItem() { |     public Item createItem() { | ||||||
|         return new ItemBlockController(); |         return new ItemBlockController(this, getDirection()); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Nullable |  | ||||||
|     @Override |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return null; |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -2,6 +2,8 @@ package com.raoulvdberge.refinedstorage.block; | |||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSBlocks; | import com.raoulvdberge.refinedstorage.RSBlocks; | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileCrafter; | import com.raoulvdberge.refinedstorage.tile.TileCrafter; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| import net.minecraft.entity.EntityLivingBase; | import net.minecraft.entity.EntityLivingBase; | ||||||
| @@ -20,12 +22,13 @@ import javax.annotation.Nullable; | |||||||
|  |  | ||||||
| public class BlockCrafter extends BlockNode { | public class BlockCrafter extends BlockNode { | ||||||
|     public BlockCrafter() { |     public BlockCrafter() { | ||||||
|         super("crafter"); |         super(BlockInfoBuilder.forId("crafter").tileEntity(TileCrafter::new).create()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |     @Nullable | ||||||
|         return new TileCrafter(); |     public BlockDirection getDirection() { | ||||||
|  |         return BlockDirection.ANY_FACE_PLAYER; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -44,21 +47,7 @@ public class BlockCrafter extends BlockNode { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.CRAFTER, player, world, pos, side); | ||||||
|             tryOpenNetworkGui(RSGui.CRAFTER, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return Direction.ANY_FACE_PLAYER; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public boolean hasConnectivityState() { |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -75,4 +64,9 @@ public class BlockCrafter extends BlockNode { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public boolean hasConnectivityState() { | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -2,29 +2,33 @@ package com.raoulvdberge.refinedstorage.block; | |||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
| import com.raoulvdberge.refinedstorage.api.network.security.Permission; | import com.raoulvdberge.refinedstorage.api.network.security.Permission; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileCrafterManager; | import com.raoulvdberge.refinedstorage.tile.TileCrafterManager; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| import net.minecraft.entity.player.EntityPlayer; | import net.minecraft.entity.player.EntityPlayer; | ||||||
| import net.minecraft.entity.player.EntityPlayerMP; | import net.minecraft.entity.player.EntityPlayerMP; | ||||||
| import net.minecraft.tileentity.TileEntity; |  | ||||||
| import net.minecraft.util.EnumFacing; | import net.minecraft.util.EnumFacing; | ||||||
| import net.minecraft.util.EnumHand; | import net.minecraft.util.EnumHand; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.util.math.BlockPos; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
|  |  | ||||||
|  | import javax.annotation.Nullable; | ||||||
|  |  | ||||||
| public class BlockCrafterManager extends BlockNode { | public class BlockCrafterManager extends BlockNode { | ||||||
|     public BlockCrafterManager() { |     public BlockCrafterManager() { | ||||||
|         super("crafter_manager"); |         super(BlockInfoBuilder.forId("crafter_manager").tileEntity(TileCrafterManager::new).create()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |     @Nullable | ||||||
|         return new TileCrafterManager(); |     public BlockDirection getDirection() { | ||||||
|  |         return BlockDirection.HORIZONTAL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!world.isRemote && tryOpenNetworkGui(RSGui.CRAFTER_MANAGER, player, world, pos, side, Permission.MODIFY, Permission.AUTOCRAFTING)) { |         if (!world.isRemote && openNetworkGui(RSGui.CRAFTER_MANAGER, player, world, pos, side, Permission.MODIFY, Permission.AUTOCRAFTING)) { | ||||||
|             ((TileCrafterManager) world.getTileEntity(pos)).getNode().sendTo((EntityPlayerMP) player); |             ((TileCrafterManager) world.getTileEntity(pos)).getNode().sendTo((EntityPlayerMP) player); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -2,32 +2,32 @@ package com.raoulvdberge.refinedstorage.block; | |||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
| import com.raoulvdberge.refinedstorage.api.network.security.Permission; | import com.raoulvdberge.refinedstorage.api.network.security.Permission; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor; | import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| import net.minecraft.entity.player.EntityPlayer; | import net.minecraft.entity.player.EntityPlayer; | ||||||
| import net.minecraft.tileentity.TileEntity; |  | ||||||
| import net.minecraft.util.EnumFacing; | import net.minecraft.util.EnumFacing; | ||||||
| import net.minecraft.util.EnumHand; | import net.minecraft.util.EnumHand; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.util.math.BlockPos; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
|  |  | ||||||
|  | import javax.annotation.Nullable; | ||||||
|  |  | ||||||
| public class BlockCraftingMonitor extends BlockNode { | public class BlockCraftingMonitor extends BlockNode { | ||||||
|     public BlockCraftingMonitor() { |     public BlockCraftingMonitor() { | ||||||
|         super("crafting_monitor"); |         super(BlockInfoBuilder.forId("crafting_monitor").tileEntity(TileCraftingMonitor::new).create()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |     @Nullable | ||||||
|         return new TileCraftingMonitor(); |     public BlockDirection getDirection() { | ||||||
|  |         return BlockDirection.HORIZONTAL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.CRAFTING_MONITOR, player, world, pos, side, Permission.MODIFY, Permission.AUTOCRAFTING); | ||||||
|             tryOpenNetworkGui(RSGui.CRAFTING_MONITOR, player, world, pos, side, Permission.MODIFY, Permission.AUTOCRAFTING); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.block; | |||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSBlocks; | import com.raoulvdberge.refinedstorage.RSBlocks; | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup; | import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileDestructor; | import com.raoulvdberge.refinedstorage.tile.TileDestructor; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| @@ -17,12 +18,13 @@ import java.util.List; | |||||||
|  |  | ||||||
| public class BlockDestructor extends BlockCable { | public class BlockDestructor extends BlockCable { | ||||||
|     public BlockDestructor() { |     public BlockDestructor() { | ||||||
|         super("destructor"); |         super(createBuilder("destructor").tileEntity(TileDestructor::new).create()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |     @Nullable | ||||||
|         return new TileDestructor(); |     public BlockDirection getDirection() { | ||||||
|  |         return BlockDirection.ANY; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -36,21 +38,11 @@ public class BlockDestructor extends BlockCable { | |||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.DESTRUCTOR, player, world, pos, side); | ||||||
|             tryOpenNetworkGui(RSGui.DESTRUCTOR, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean hasConnectivityState() { |     public boolean hasConnectivityState() { | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return Direction.ANY; |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block; | ||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsDetector; | import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsDetector; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileDetector; | import com.raoulvdberge.refinedstorage.tile.TileDetector; | ||||||
| import net.minecraft.block.properties.PropertyBool; | import net.minecraft.block.properties.PropertyBool; | ||||||
| @@ -17,18 +18,16 @@ import net.minecraft.util.math.BlockPos; | |||||||
| import net.minecraft.world.IBlockAccess; | import net.minecraft.world.IBlockAccess; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; |  | ||||||
|  |  | ||||||
| public class BlockDetector extends BlockNode { | public class BlockDetector extends BlockNode { | ||||||
|     private static final PropertyBool POWERED = PropertyBool.create("powered"); |     private static final PropertyBool POWERED = PropertyBool.create("powered"); | ||||||
|  |  | ||||||
|     public BlockDetector() { |     public BlockDetector() { | ||||||
|         super("detector"); |         super(BlockInfoBuilder.forId("detector").tileEntity(TileDetector::new).create()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected BlockStateContainer createBlockState() { |     protected BlockStateContainer createBlockState() { | ||||||
|         return createBlockStateBuilder() |         return createStateBuilder() | ||||||
|             .add(POWERED) |             .add(POWERED) | ||||||
|             .build(); |             .build(); | ||||||
|     } |     } | ||||||
| @@ -46,8 +45,8 @@ public class BlockDetector extends BlockNode { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         return new TileDetector(); |         return openNetworkGui(RSGui.DETECTOR, player, world, pos, side); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -64,15 +63,6 @@ public class BlockDetector extends BlockNode { | |||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |  | ||||||
|         if (!world.isRemote) { |  | ||||||
|             tryOpenNetworkGui(RSGui.DETECTOR, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     @SuppressWarnings("deprecation") |     @SuppressWarnings("deprecation") | ||||||
|     public boolean isOpaqueCube(IBlockState state) { |     public boolean isOpaqueCube(IBlockState state) { | ||||||
| @@ -90,12 +80,6 @@ public class BlockDetector extends BlockNode { | |||||||
|         return BlockRenderLayer.CUTOUT; |         return BlockRenderLayer.CUTOUT; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return null; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     @SuppressWarnings("deprecation") |     @SuppressWarnings("deprecation") | ||||||
|     public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) { |     public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) { | ||||||
|   | |||||||
| @@ -1,6 +1,9 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block; | ||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.property.PropertyObject; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileDiskDrive; | import com.raoulvdberge.refinedstorage.tile.TileDiskDrive; | ||||||
| import net.minecraft.block.state.BlockStateContainer; | import net.minecraft.block.state.BlockStateContainer; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| @@ -13,30 +16,29 @@ import net.minecraft.world.IBlockAccess; | |||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
| import net.minecraftforge.common.property.IExtendedBlockState; | import net.minecraftforge.common.property.IExtendedBlockState; | ||||||
|  |  | ||||||
|  | import javax.annotation.Nullable; | ||||||
|  |  | ||||||
| public class BlockDiskDrive extends BlockNode { | public class BlockDiskDrive extends BlockNode { | ||||||
|     public static final PropertyObject<Integer[]> DISK_STATE = new PropertyObject<>("disk_state", Integer[].class); |     public static final PropertyObject<Integer[]> DISK_STATE = new PropertyObject<>("disk_state", Integer[].class); | ||||||
|  |  | ||||||
|     public BlockDiskDrive() { |     public BlockDiskDrive() { | ||||||
|         super("disk_drive"); |         super(BlockInfoBuilder.forId("disk_drive").tileEntity(TileDiskDrive::new).create()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |     @Nullable | ||||||
|         return new TileDiskDrive(); |     public BlockDirection getDirection() { | ||||||
|  |         return BlockDirection.HORIZONTAL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.DISK_DRIVE, player, world, pos, side); | ||||||
|             tryOpenNetworkGui(RSGui.DISK_DRIVE, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected BlockStateContainer.Builder createBlockStateBuilder() { |     protected BlockStateContainer.Builder createStateBuilder() { | ||||||
|         return super.createBlockStateBuilder().add(DISK_STATE); |         return super.createStateBuilder().add(DISK_STATE); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -1,6 +1,9 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block; | ||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.property.PropertyObject; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileDiskManipulator; | import com.raoulvdberge.refinedstorage.tile.TileDiskManipulator; | ||||||
| import net.minecraft.block.state.BlockStateContainer; | import net.minecraft.block.state.BlockStateContainer; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| @@ -13,30 +16,29 @@ import net.minecraft.world.IBlockAccess; | |||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
| import net.minecraftforge.common.property.IExtendedBlockState; | import net.minecraftforge.common.property.IExtendedBlockState; | ||||||
|  |  | ||||||
|  | import javax.annotation.Nullable; | ||||||
|  |  | ||||||
| public class BlockDiskManipulator extends BlockNode { | public class BlockDiskManipulator extends BlockNode { | ||||||
|     public static final PropertyObject<Integer[]> DISK_STATE = new PropertyObject<>("disk_state", Integer[].class); |     public static final PropertyObject<Integer[]> DISK_STATE = new PropertyObject<>("disk_state", Integer[].class); | ||||||
|  |  | ||||||
|     public BlockDiskManipulator() { |     public BlockDiskManipulator() { | ||||||
|         super("disk_manipulator"); |         super(BlockInfoBuilder.forId("disk_manipulator").tileEntity(TileDiskManipulator::new).create()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |     @Nullable | ||||||
|         return new TileDiskManipulator(); |     public BlockDirection getDirection() { | ||||||
|  |         return BlockDirection.HORIZONTAL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.DISK_MANIPULATOR, player, world, pos, side); | ||||||
|             tryOpenNetworkGui(RSGui.DISK_MANIPULATOR, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected BlockStateContainer.Builder createBlockStateBuilder() { |     protected BlockStateContainer.Builder createStateBuilder() { | ||||||
|         return super.createBlockStateBuilder().add(DISK_STATE); |         return super.createStateBuilder().add(DISK_STATE); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block; | ||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup; | import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsExporter; | import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsExporter; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileExporter; | import com.raoulvdberge.refinedstorage.tile.TileExporter; | ||||||
| @@ -17,7 +18,13 @@ import java.util.List; | |||||||
|  |  | ||||||
| public class BlockExporter extends BlockCable { | public class BlockExporter extends BlockCable { | ||||||
|     public BlockExporter() { |     public BlockExporter() { | ||||||
|         super("exporter"); |         super(createBuilder("exporter").tileEntity(TileExporter::new).create()); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     @Nullable | ||||||
|  |     public BlockDirection getDirection() { | ||||||
|  |         return BlockDirection.ANY; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -48,27 +55,12 @@ public class BlockExporter extends BlockCable { | |||||||
|         return groups; |         return groups; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileExporter(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!canAccessGui(state, world, pos, hitX, hitY, hitZ)) { |         if (!canAccessGui(state, world, pos, hitX, hitY, hitZ)) { | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.EXPORTER, player, world, pos, side); | ||||||
|             tryOpenNetworkGui(RSGui.EXPORTER, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return Direction.ANY; |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.block; | |||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeExternalStorage; | import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeExternalStorage; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup; | import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsCable; | import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsCable; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsExternalStorage; | import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsExternalStorage; | ||||||
| @@ -20,7 +21,13 @@ import java.util.List; | |||||||
|  |  | ||||||
| public class BlockExternalStorage extends BlockCable { | public class BlockExternalStorage extends BlockCable { | ||||||
|     public BlockExternalStorage() { |     public BlockExternalStorage() { | ||||||
|         super("external_storage"); |         super(createBuilder("external_storage").tileEntity(TileExternalStorage::new).create()); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     @Nullable | ||||||
|  |     public BlockDirection getDirection() { | ||||||
|  |         return BlockDirection.ANY; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -57,22 +64,13 @@ public class BlockExternalStorage extends BlockCable { | |||||||
|         return groups; |         return groups; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileExternalStorage(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!canAccessGui(state, world, pos, hitX, hitY, hitZ)) { |         if (!canAccessGui(state, world, pos, hitX, hitY, hitZ)) { | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.EXTERNAL_STORAGE, player, world, pos, side); | ||||||
|             tryOpenNetworkGui(RSGui.EXTERNAL_STORAGE, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -92,10 +90,4 @@ public class BlockExternalStorage extends BlockCable { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return Direction.ANY; |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -2,44 +2,27 @@ package com.raoulvdberge.refinedstorage.block; | |||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
| import com.raoulvdberge.refinedstorage.api.network.security.Permission; | import com.raoulvdberge.refinedstorage.api.network.security.Permission; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileFluidInterface; | import com.raoulvdberge.refinedstorage.tile.TileFluidInterface; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| import net.minecraft.entity.player.EntityPlayer; | import net.minecraft.entity.player.EntityPlayer; | ||||||
| import net.minecraft.tileentity.TileEntity; |  | ||||||
| import net.minecraft.util.EnumFacing; | import net.minecraft.util.EnumFacing; | ||||||
| import net.minecraft.util.EnumHand; | import net.minecraft.util.EnumHand; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.util.math.BlockPos; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; |  | ||||||
|  |  | ||||||
| public class BlockFluidInterface extends BlockNode { | public class BlockFluidInterface extends BlockNode { | ||||||
|     public BlockFluidInterface() { |     public BlockFluidInterface() { | ||||||
|         super("fluid_interface"); |         super(BlockInfoBuilder.forId("fluid_interface").tileEntity(TileFluidInterface::new).create()); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileFluidInterface(); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.FLUID_INTERFACE, player, world, pos, side, Permission.MODIFY, Permission.INSERT, Permission.EXTRACT); | ||||||
|             tryOpenNetworkGui(RSGui.FLUID_INTERFACE, player, world, pos, side, Permission.MODIFY, Permission.INSERT, Permission.EXTRACT); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean hasConnectivityState() { |     public boolean hasConnectivityState() { | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return null; |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,6 +3,8 @@ package com.raoulvdberge.refinedstorage.block; | |||||||
| import com.raoulvdberge.refinedstorage.RSBlocks; | import com.raoulvdberge.refinedstorage.RSBlocks; | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeFluidStorage; | import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeFluidStorage; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.enums.FluidStorageType; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.item.ItemBlockFluidStorage; | import com.raoulvdberge.refinedstorage.item.ItemBlockFluidStorage; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileFluidStorage; | import com.raoulvdberge.refinedstorage.tile.TileFluidStorage; | ||||||
| import net.minecraft.block.properties.PropertyEnum; | import net.minecraft.block.properties.PropertyEnum; | ||||||
| @@ -14,7 +16,6 @@ import net.minecraft.entity.player.EntityPlayer; | |||||||
| import net.minecraft.item.Item; | import net.minecraft.item.Item; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.item.ItemStack; | ||||||
| import net.minecraft.nbt.NBTTagCompound; | import net.minecraft.nbt.NBTTagCompound; | ||||||
| import net.minecraft.tileentity.TileEntity; |  | ||||||
| import net.minecraft.util.EnumFacing; | import net.minecraft.util.EnumFacing; | ||||||
| import net.minecraft.util.EnumHand; | import net.minecraft.util.EnumHand; | ||||||
| import net.minecraft.util.NonNullList; | import net.minecraft.util.NonNullList; | ||||||
| @@ -22,15 +23,11 @@ import net.minecraft.util.math.BlockPos; | |||||||
| import net.minecraft.world.IBlockAccess; | import net.minecraft.world.IBlockAccess; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; |  | ||||||
|  |  | ||||||
| public class BlockFluidStorage extends BlockNode { | public class BlockFluidStorage extends BlockNode { | ||||||
|     public static final PropertyEnum TYPE = PropertyEnum.create("type", FluidStorageType.class); |     public static final PropertyEnum TYPE = PropertyEnum.create("type", FluidStorageType.class); | ||||||
|  |  | ||||||
|     public BlockFluidStorage() { |     public BlockFluidStorage() { | ||||||
|         super("fluid_storage"); |         super(BlockInfoBuilder.forId("fluid_storage").hardness(5.8F).tileEntity(TileFluidStorage::new).create()); | ||||||
|  |  | ||||||
|         setHardness(5.8F); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -42,7 +39,7 @@ public class BlockFluidStorage extends BlockNode { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected BlockStateContainer createBlockState() { |     protected BlockStateContainer createBlockState() { | ||||||
|         return createBlockStateBuilder() |         return createStateBuilder() | ||||||
|             .add(TYPE) |             .add(TYPE) | ||||||
|             .build(); |             .build(); | ||||||
|     } |     } | ||||||
| @@ -57,29 +54,14 @@ public class BlockFluidStorage extends BlockNode { | |||||||
|         return ((FluidStorageType) state.getValue(TYPE)).getId(); |         return ((FluidStorageType) state.getValue(TYPE)).getId(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileFluidStorage(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.FLUID_STORAGE, player, world, pos, side); | ||||||
|             tryOpenNetworkGui(RSGui.FLUID_STORAGE, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public Item createItem() { |     public Item createItem() { | ||||||
|         return new ItemBlockFluidStorage(); |         return new ItemBlockFluidStorage(this, getDirection()); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return null; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -2,6 +2,8 @@ package com.raoulvdberge.refinedstorage.block; | |||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
| import com.raoulvdberge.refinedstorage.api.network.grid.GridType; | import com.raoulvdberge.refinedstorage.api.network.grid.GridType; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.item.ItemBlockBase; | import com.raoulvdberge.refinedstorage.item.ItemBlockBase; | ||||||
| import com.raoulvdberge.refinedstorage.tile.grid.TileGrid; | import com.raoulvdberge.refinedstorage.tile.grid.TileGrid; | ||||||
| import net.minecraft.block.properties.PropertyEnum; | import net.minecraft.block.properties.PropertyEnum; | ||||||
| @@ -11,23 +13,25 @@ import net.minecraft.creativetab.CreativeTabs; | |||||||
| import net.minecraft.entity.player.EntityPlayer; | import net.minecraft.entity.player.EntityPlayer; | ||||||
| import net.minecraft.item.Item; | import net.minecraft.item.Item; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.item.ItemStack; | ||||||
| import net.minecraft.tileentity.TileEntity; |  | ||||||
| import net.minecraft.util.EnumFacing; | import net.minecraft.util.EnumFacing; | ||||||
| import net.minecraft.util.EnumHand; | import net.minecraft.util.EnumHand; | ||||||
| import net.minecraft.util.NonNullList; | import net.minecraft.util.NonNullList; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.util.math.BlockPos; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
|  |  | ||||||
|  | import javax.annotation.Nullable; | ||||||
|  |  | ||||||
| public class BlockGrid extends BlockNode { | public class BlockGrid extends BlockNode { | ||||||
|     public static final PropertyEnum TYPE = PropertyEnum.create("type", GridType.class); |     public static final PropertyEnum TYPE = PropertyEnum.create("type", GridType.class); | ||||||
|  |  | ||||||
|     public BlockGrid() { |     public BlockGrid() { | ||||||
|         super("grid"); |         super(BlockInfoBuilder.forId("grid").tileEntity(TileGrid::new).create()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |     @Nullable | ||||||
|         return new TileGrid(); |     public BlockDirection getDirection() { | ||||||
|  |         return BlockDirection.HORIZONTAL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -39,7 +43,7 @@ public class BlockGrid extends BlockNode { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected BlockStateContainer createBlockState() { |     protected BlockStateContainer createBlockState() { | ||||||
|         return createBlockStateBuilder() |         return createStateBuilder() | ||||||
|             .add(TYPE) |             .add(TYPE) | ||||||
|             .build(); |             .build(); | ||||||
|     } |     } | ||||||
| @@ -56,11 +60,7 @@ public class BlockGrid extends BlockNode { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.GRID, player, world, pos, side); | ||||||
|             tryOpenNetworkGui(RSGui.GRID, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block; | ||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup; | import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsImporter; | import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsImporter; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileImporter; | import com.raoulvdberge.refinedstorage.tile.TileImporter; | ||||||
| @@ -17,7 +18,13 @@ import java.util.List; | |||||||
|  |  | ||||||
| public class BlockImporter extends BlockCable { | public class BlockImporter extends BlockCable { | ||||||
|     public BlockImporter() { |     public BlockImporter() { | ||||||
|         super("importer"); |         super(createBuilder("importer").tileEntity(TileImporter::new).create()); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     @Nullable | ||||||
|  |     public BlockDirection getDirection() { | ||||||
|  |         return BlockDirection.ANY; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -48,27 +55,12 @@ public class BlockImporter extends BlockCable { | |||||||
|         return groups; |         return groups; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileImporter(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!canAccessGui(state, world, pos, hitX, hitY, hitZ)) { |         if (!canAccessGui(state, world, pos, hitX, hitY, hitZ)) { | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.IMPORTER, player, world, pos, side); | ||||||
|             tryOpenNetworkGui(RSGui.IMPORTER, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return Direction.ANY; |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -2,44 +2,27 @@ package com.raoulvdberge.refinedstorage.block; | |||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
| import com.raoulvdberge.refinedstorage.api.network.security.Permission; | import com.raoulvdberge.refinedstorage.api.network.security.Permission; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileInterface; | import com.raoulvdberge.refinedstorage.tile.TileInterface; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| import net.minecraft.entity.player.EntityPlayer; | import net.minecraft.entity.player.EntityPlayer; | ||||||
| import net.minecraft.tileentity.TileEntity; |  | ||||||
| import net.minecraft.util.EnumFacing; | import net.minecraft.util.EnumFacing; | ||||||
| import net.minecraft.util.EnumHand; | import net.minecraft.util.EnumHand; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.util.math.BlockPos; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; |  | ||||||
|  |  | ||||||
| public class BlockInterface extends BlockNode { | public class BlockInterface extends BlockNode { | ||||||
|     public BlockInterface() { |     public BlockInterface() { | ||||||
|         super("interface"); |         super(BlockInfoBuilder.forId("interface").tileEntity(TileInterface::new).create()); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileInterface(); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.INTERFACE, player, world, pos, side, Permission.MODIFY, Permission.INSERT, Permission.EXTRACT); | ||||||
|             tryOpenNetworkGui(RSGui.INTERFACE, player, world, pos, side, Permission.MODIFY, Permission.INSERT, Permission.EXTRACT); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean hasConnectivityState() { |     public boolean hasConnectivityState() { | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return null; |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,15 +1,9 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block; | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
|  |  | ||||||
| public class BlockMachineCasing extends BlockBase { | public class BlockMachineCasing extends BlockBase { | ||||||
|     public BlockMachineCasing() { |     public BlockMachineCasing() { | ||||||
|         super("machine_casing"); |         super(BlockInfoBuilder.forId("machine_casing").create()); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return null; |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,26 +1,11 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block; | ||||||
|  |  | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileNetworkReceiver; | import com.raoulvdberge.refinedstorage.tile.TileNetworkReceiver; | ||||||
| import net.minecraft.block.state.IBlockState; |  | ||||||
| import net.minecraft.tileentity.TileEntity; |  | ||||||
| import net.minecraft.world.World; |  | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; |  | ||||||
|  |  | ||||||
| public class BlockNetworkReceiver extends BlockNode { | public class BlockNetworkReceiver extends BlockNode { | ||||||
|     public BlockNetworkReceiver() { |     public BlockNetworkReceiver() { | ||||||
|         super("network_receiver"); |         super(BlockInfoBuilder.forId("network_receiver").tileEntity(TileNetworkReceiver::new).create()); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileNetworkReceiver(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return null; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -1,40 +1,23 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block; | ||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileNetworkTransmitter; | import com.raoulvdberge.refinedstorage.tile.TileNetworkTransmitter; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| import net.minecraft.entity.player.EntityPlayer; | import net.minecraft.entity.player.EntityPlayer; | ||||||
| import net.minecraft.tileentity.TileEntity; |  | ||||||
| import net.minecraft.util.EnumFacing; | import net.minecraft.util.EnumFacing; | ||||||
| import net.minecraft.util.EnumHand; | import net.minecraft.util.EnumHand; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.util.math.BlockPos; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; |  | ||||||
|  |  | ||||||
| public class BlockNetworkTransmitter extends BlockNode { | public class BlockNetworkTransmitter extends BlockNode { | ||||||
|     public BlockNetworkTransmitter() { |     public BlockNetworkTransmitter() { | ||||||
|         super("network_transmitter"); |         super(BlockInfoBuilder.forId("network_transmitter").tileEntity(TileNetworkTransmitter::new).create()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.NETWORK_TRANSMITTER, player, world, pos, side); | ||||||
|             tryOpenNetworkGui(RSGui.NETWORK_TRANSMITTER, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileNetworkTransmitter(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return null; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.block; | |||||||
| import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode; | import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode; | ||||||
| import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager; | import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.API; | import com.raoulvdberge.refinedstorage.apiimpl.API; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.IBlockInfo; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileNode; | import com.raoulvdberge.refinedstorage.tile.TileNode; | ||||||
| import net.minecraft.block.properties.PropertyBool; | import net.minecraft.block.properties.PropertyBool; | ||||||
| import net.minecraft.block.state.BlockStateContainer; | import net.minecraft.block.state.BlockStateContainer; | ||||||
| @@ -15,16 +16,11 @@ import net.minecraft.util.math.BlockPos; | |||||||
| import net.minecraft.world.IBlockAccess; | import net.minecraft.world.IBlockAccess; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
|  |  | ||||||
| public abstract class BlockNode extends BlockBase { | public abstract class BlockNode extends BlockNodeProxy { | ||||||
|     public static final PropertyBool CONNECTED = PropertyBool.create("connected"); |     public static final PropertyBool CONNECTED = PropertyBool.create("connected"); | ||||||
|  |  | ||||||
|     public BlockNode(String name) { |     public BlockNode(IBlockInfo info) { | ||||||
|         super(name); |         super(info); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public boolean hasTileEntity(IBlockState state) { |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -61,8 +57,8 @@ public abstract class BlockNode extends BlockBase { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected BlockStateContainer.Builder createBlockStateBuilder() { |     protected BlockStateContainer.Builder createStateBuilder() { | ||||||
|         BlockStateContainer.Builder builder = super.createBlockStateBuilder(); |         BlockStateContainer.Builder builder = super.createStateBuilder(); | ||||||
|  |  | ||||||
|         if (hasConnectivityState()) { |         if (hasConnectivityState()) { | ||||||
|             builder.add(CONNECTED); |             builder.add(CONNECTED); | ||||||
| @@ -73,7 +69,7 @@ public abstract class BlockNode extends BlockBase { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected BlockStateContainer createBlockState() { |     protected BlockStateContainer createBlockState() { | ||||||
|         return createBlockStateBuilder().build(); |         return createStateBuilder().build(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -0,0 +1,86 @@ | |||||||
|  | package com.raoulvdberge.refinedstorage.block; | ||||||
|  |  | ||||||
|  | import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode; | ||||||
|  | import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy; | ||||||
|  | import com.raoulvdberge.refinedstorage.api.network.security.Permission; | ||||||
|  | import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.IBlockInfo; | ||||||
|  | import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy; | ||||||
|  | import com.raoulvdberge.refinedstorage.tile.TileBase; | ||||||
|  | import com.raoulvdberge.refinedstorage.tile.TileNode; | ||||||
|  | import com.raoulvdberge.refinedstorage.util.WorldUtils; | ||||||
|  | import net.minecraft.block.state.IBlockState; | ||||||
|  | import net.minecraft.entity.Entity; | ||||||
|  | import net.minecraft.entity.player.EntityPlayer; | ||||||
|  | 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; | ||||||
|  |  | ||||||
|  | public abstract class BlockNodeProxy extends BlockBase { | ||||||
|  |     public BlockNodeProxy(IBlockInfo info) { | ||||||
|  |         super(info); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) { | ||||||
|  |         TileEntity tile = world.getTileEntity(pos); | ||||||
|  |  | ||||||
|  |         if (tile != null && tile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, null)) { | ||||||
|  |             INetworkNode node = tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, null).getNode(); | ||||||
|  |  | ||||||
|  |             if (node.getNetwork() != null) { | ||||||
|  |                 return entity instanceof EntityPlayer && node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, (EntityPlayer) entity); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return super.canEntityDestroy(state, world, pos, entity); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) { | ||||||
|  |         if (!world.isRemote && getDirection() != null) { | ||||||
|  |             TileBase tile = (TileBase) world.getTileEntity(pos); | ||||||
|  |  | ||||||
|  |             EnumFacing newDirection = getDirection().cycle(tile.getDirection()); | ||||||
|  |  | ||||||
|  |             if (tile instanceof TileNode && ((TileNode) tile).getNode() instanceof ICoverable && ((ICoverable) ((TileNode) tile).getNode()).getCoverManager().hasCover(newDirection)) { | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return super.rotateBlock(world, pos, axis); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     protected boolean openNetworkGui(int guiId, EntityPlayer player, World world, BlockPos pos, EnumFacing facing) { | ||||||
|  |         return openNetworkGui(guiId, player, world, pos, facing, Permission.MODIFY); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     protected boolean openNetworkGui(int guiId, EntityPlayer player, World world, BlockPos pos, EnumFacing facing, Permission... permissions) { | ||||||
|  |         if (world.isRemote) { | ||||||
|  |             return true; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         TileEntity tile = world.getTileEntity(pos); | ||||||
|  |  | ||||||
|  |         if (tile != null && tile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing)) { | ||||||
|  |             INetworkNodeProxy nodeProxy = CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY.cast(tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing)); | ||||||
|  |             INetworkNode node = nodeProxy.getNode(); | ||||||
|  |  | ||||||
|  |             if (node.getNetwork() != null) { | ||||||
|  |                 for (Permission permission : permissions) { | ||||||
|  |                     if (!node.getNetwork().getSecurityManager().hasPermission(permission, player)) { | ||||||
|  |                         WorldUtils.sendNoPermissionMessage(player); | ||||||
|  |  | ||||||
|  |                         return false; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         player.openGui(info.getModObject(), guiId, world, pos.getX(), pos.getY(), pos.getZ()); | ||||||
|  |  | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -2,6 +2,10 @@ package com.raoulvdberge.refinedstorage.block; | |||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RS; | import com.raoulvdberge.refinedstorage.RS; | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.enums.PortableGridDiskState; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.enums.PortableGridType; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.item.ItemBlockPortableGrid; | import com.raoulvdberge.refinedstorage.item.ItemBlockPortableGrid; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsPortableGrid; | import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsPortableGrid; | ||||||
| import com.raoulvdberge.refinedstorage.tile.grid.portable.TilePortableGrid; | import com.raoulvdberge.refinedstorage.tile.grid.portable.TilePortableGrid; | ||||||
| @@ -14,7 +18,6 @@ import net.minecraft.entity.EntityLivingBase; | |||||||
| import net.minecraft.entity.player.EntityPlayer; | import net.minecraft.entity.player.EntityPlayer; | ||||||
| import net.minecraft.item.Item; | import net.minecraft.item.Item; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.item.ItemStack; | ||||||
| import net.minecraft.tileentity.TileEntity; |  | ||||||
| import net.minecraft.util.EnumFacing; | import net.minecraft.util.EnumFacing; | ||||||
| import net.minecraft.util.EnumHand; | import net.minecraft.util.EnumHand; | ||||||
| import net.minecraft.util.NonNullList; | import net.minecraft.util.NonNullList; | ||||||
| @@ -31,28 +34,18 @@ public class BlockPortableGrid extends BlockBase { | |||||||
|     public static final PropertyBool CONNECTED = PropertyBool.create("connected"); |     public static final PropertyBool CONNECTED = PropertyBool.create("connected"); | ||||||
|  |  | ||||||
|     public BlockPortableGrid() { |     public BlockPortableGrid() { | ||||||
|         super("portable_grid"); |         super(BlockInfoBuilder.forId("portable_grid").tileEntity(TilePortableGrid::new).create()); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public boolean hasTileEntity(IBlockState state) { |  | ||||||
|         return true; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TilePortableGrid(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public Item createItem() { |  | ||||||
|         return new ItemBlockPortableGrid(); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     @Nullable |     @Nullable | ||||||
|     public Direction getDirection() { |     public BlockDirection getDirection() { | ||||||
|         return Direction.HORIZONTAL; |         return BlockDirection.HORIZONTAL; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public Item createItem() { | ||||||
|  |         return new ItemBlockPortableGrid(this, getDirection()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -98,7 +91,7 @@ public class BlockPortableGrid extends BlockBase { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected BlockStateContainer createBlockState() { |     protected BlockStateContainer createBlockState() { | ||||||
|         return createBlockStateBuilder() |         return createStateBuilder() | ||||||
|             .add(TYPE) |             .add(TYPE) | ||||||
|             .add(DISK_STATE) |             .add(DISK_STATE) | ||||||
|             .add(CONNECTED) |             .add(CONNECTED) | ||||||
|   | |||||||
| @@ -1,15 +1,9 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block; | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
|  |  | ||||||
| public class BlockQuartzEnrichedIron extends BlockBase { | public class BlockQuartzEnrichedIron extends BlockBase { | ||||||
|     public BlockQuartzEnrichedIron() { |     public BlockQuartzEnrichedIron() { | ||||||
|         super("quartz_enriched_iron_block"); |         super(BlockInfoBuilder.forId("quartz_enriched_iron_block").create()); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return null; |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ import com.raoulvdberge.refinedstorage.RSBlocks; | |||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
| import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel; | import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeReader; | import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeReader; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup; | import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileReader; | import com.raoulvdberge.refinedstorage.tile.TileReader; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| @@ -20,7 +21,13 @@ import java.util.List; | |||||||
|  |  | ||||||
| public class BlockReader extends BlockCable { | public class BlockReader extends BlockCable { | ||||||
|     public BlockReader() { |     public BlockReader() { | ||||||
|         super("reader"); |         super(createBuilder("reader").tileEntity(TileReader::new).create()); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     @Nullable | ||||||
|  |     public BlockDirection getDirection() { | ||||||
|  |         return BlockDirection.ANY; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -46,7 +53,7 @@ public class BlockReader extends BlockCable { | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 tryOpenNetworkGui(RSGui.READER_WRITER, player, world, pos, side); |                 openNetworkGui(RSGui.READER_WRITER, player, world, pos, side); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -60,19 +67,8 @@ public class BlockReader extends BlockCable { | |||||||
|         return tile instanceof TileReader && side == ((TileReader) tile).getDirection().getOpposite(); |         return tile instanceof TileReader && side == ((TileReader) tile).getDirection().getOpposite(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileReader(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean hasConnectivityState() { |     public boolean hasConnectivityState() { | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return Direction.ANY; |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,40 +1,23 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block; | ||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileRelay; | import com.raoulvdberge.refinedstorage.tile.TileRelay; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| import net.minecraft.entity.player.EntityPlayer; | import net.minecraft.entity.player.EntityPlayer; | ||||||
| import net.minecraft.tileentity.TileEntity; |  | ||||||
| import net.minecraft.util.EnumFacing; | import net.minecraft.util.EnumFacing; | ||||||
| import net.minecraft.util.EnumHand; | import net.minecraft.util.EnumHand; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.util.math.BlockPos; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; |  | ||||||
|  |  | ||||||
| public class BlockRelay extends BlockNode { | public class BlockRelay extends BlockNode { | ||||||
|     public BlockRelay() { |     public BlockRelay() { | ||||||
|         super("relay"); |         super(BlockInfoBuilder.forId("relay").tileEntity(TileRelay::new).create()); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileRelay(); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.RELAY, player, world, pos, side); | ||||||
|             tryOpenNetworkGui(RSGui.RELAY, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return null; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public boolean hasConnectivityState() { |     public boolean hasConnectivityState() { | ||||||
|   | |||||||
| @@ -3,23 +3,27 @@ package com.raoulvdberge.refinedstorage.block; | |||||||
| import com.raoulvdberge.refinedstorage.RS; | import com.raoulvdberge.refinedstorage.RS; | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
| import com.raoulvdberge.refinedstorage.api.network.security.Permission; | import com.raoulvdberge.refinedstorage.api.network.security.Permission; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileSecurityManager; | import com.raoulvdberge.refinedstorage.tile.TileSecurityManager; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| import net.minecraft.entity.player.EntityPlayer; | import net.minecraft.entity.player.EntityPlayer; | ||||||
| import net.minecraft.tileentity.TileEntity; |  | ||||||
| import net.minecraft.util.EnumFacing; | import net.minecraft.util.EnumFacing; | ||||||
| import net.minecraft.util.EnumHand; | import net.minecraft.util.EnumHand; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.util.math.BlockPos; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
|  |  | ||||||
|  | import javax.annotation.Nullable; | ||||||
|  |  | ||||||
| public class BlockSecurityManager extends BlockNode { | public class BlockSecurityManager extends BlockNode { | ||||||
|     public BlockSecurityManager() { |     public BlockSecurityManager() { | ||||||
|         super("security_manager"); |         super(BlockInfoBuilder.forId("security_manager").tileEntity(TileSecurityManager::new).create()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |     @Nullable | ||||||
|         return new TileSecurityManager(); |     public BlockDirection getDirection() { | ||||||
|  |         return BlockDirection.HORIZONTAL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -28,7 +32,7 @@ public class BlockSecurityManager extends BlockNode { | |||||||
|             if (player.getGameProfile().getId().equals(((TileSecurityManager) world.getTileEntity(pos)).getNode().getOwner())) { |             if (player.getGameProfile().getId().equals(((TileSecurityManager) world.getTileEntity(pos)).getNode().getOwner())) { | ||||||
|                 player.openGui(RS.INSTANCE, RSGui.SECURITY_MANAGER, world, pos.getX(), pos.getY(), pos.getZ()); |                 player.openGui(RS.INSTANCE, RSGui.SECURITY_MANAGER, world, pos.getX(), pos.getY(), pos.getZ()); | ||||||
|             } else { |             } else { | ||||||
|                 tryOpenNetworkGui(RSGui.SECURITY_MANAGER, player, world, pos, side, Permission.MODIFY, Permission.SECURITY); |                 openNetworkGui(RSGui.SECURITY_MANAGER, player, world, pos, side, Permission.MODIFY, Permission.SECURITY); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -3,6 +3,8 @@ package com.raoulvdberge.refinedstorage.block; | |||||||
| import com.raoulvdberge.refinedstorage.RSBlocks; | import com.raoulvdberge.refinedstorage.RSBlocks; | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeStorage; | import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeStorage; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.enums.ItemStorageType; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.item.ItemBlockStorage; | import com.raoulvdberge.refinedstorage.item.ItemBlockStorage; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileStorage; | import com.raoulvdberge.refinedstorage.tile.TileStorage; | ||||||
| import net.minecraft.block.properties.PropertyEnum; | import net.minecraft.block.properties.PropertyEnum; | ||||||
| @@ -14,7 +16,6 @@ import net.minecraft.entity.player.EntityPlayer; | |||||||
| import net.minecraft.item.Item; | import net.minecraft.item.Item; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.item.ItemStack; | ||||||
| import net.minecraft.nbt.NBTTagCompound; | import net.minecraft.nbt.NBTTagCompound; | ||||||
| import net.minecraft.tileentity.TileEntity; |  | ||||||
| import net.minecraft.util.EnumFacing; | import net.minecraft.util.EnumFacing; | ||||||
| import net.minecraft.util.EnumHand; | import net.minecraft.util.EnumHand; | ||||||
| import net.minecraft.util.NonNullList; | import net.minecraft.util.NonNullList; | ||||||
| @@ -22,15 +23,11 @@ import net.minecraft.util.math.BlockPos; | |||||||
| import net.minecraft.world.IBlockAccess; | import net.minecraft.world.IBlockAccess; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; |  | ||||||
|  |  | ||||||
| public class BlockStorage extends BlockNode { | public class BlockStorage extends BlockNode { | ||||||
|     public static final PropertyEnum TYPE = PropertyEnum.create("type", ItemStorageType.class); |     public static final PropertyEnum TYPE = PropertyEnum.create("type", ItemStorageType.class); | ||||||
|  |  | ||||||
|     public BlockStorage() { |     public BlockStorage() { | ||||||
|         super("storage"); |         super(BlockInfoBuilder.forId("storage").tileEntity(TileStorage::new).hardness(5.8F).create()); | ||||||
|  |  | ||||||
|         setHardness(5.8F); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -42,7 +39,7 @@ public class BlockStorage extends BlockNode { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected BlockStateContainer createBlockState() { |     protected BlockStateContainer createBlockState() { | ||||||
|         return createBlockStateBuilder() |         return createStateBuilder() | ||||||
|             .add(TYPE) |             .add(TYPE) | ||||||
|             .build(); |             .build(); | ||||||
|     } |     } | ||||||
| @@ -57,29 +54,14 @@ public class BlockStorage extends BlockNode { | |||||||
|         return ((ItemStorageType) state.getValue(TYPE)).getId(); |         return ((ItemStorageType) state.getValue(TYPE)).getId(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileStorage(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.STORAGE, player, world, pos, side); | ||||||
|             tryOpenNetworkGui(RSGui.STORAGE, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public Item createItem() { |     public Item createItem() { | ||||||
|         return new ItemBlockStorage(); |         return new ItemBlockStorage(this, getDirection()); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return null; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -2,11 +2,12 @@ package com.raoulvdberge.refinedstorage.block; | |||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeStorageMonitor; | import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeStorageMonitor; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileStorageMonitor; | import com.raoulvdberge.refinedstorage.tile.TileStorageMonitor; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| import net.minecraft.entity.player.EntityPlayer; | import net.minecraft.entity.player.EntityPlayer; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.item.ItemStack; | ||||||
| import net.minecraft.tileentity.TileEntity; |  | ||||||
| import net.minecraft.util.EnumFacing; | import net.minecraft.util.EnumFacing; | ||||||
| import net.minecraft.util.EnumHand; | import net.minecraft.util.EnumHand; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.util.math.BlockPos; | ||||||
| @@ -18,7 +19,13 @@ import javax.annotation.Nullable; | |||||||
|  |  | ||||||
| public class BlockStorageMonitor extends BlockNode { | public class BlockStorageMonitor extends BlockNode { | ||||||
|     public BlockStorageMonitor() { |     public BlockStorageMonitor() { | ||||||
|         super("storage_monitor"); |         super(BlockInfoBuilder.forId("storage_monitor").tileEntity(TileStorageMonitor::new).create()); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     @Nullable | ||||||
|  |     public BlockDirection getDirection() { | ||||||
|  |         return BlockDirection.HORIZONTAL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -27,7 +34,7 @@ public class BlockStorageMonitor extends BlockNode { | |||||||
|             ItemStack held = player.inventory.getCurrentItem(); |             ItemStack held = player.inventory.getCurrentItem(); | ||||||
|  |  | ||||||
|             if (player.isSneaking()) { |             if (player.isSneaking()) { | ||||||
|                 tryOpenNetworkGui(RSGui.STORAGE_MONITOR, player, world, pos, side); |                 openNetworkGui(RSGui.STORAGE_MONITOR, player, world, pos, side); | ||||||
|             } else { |             } else { | ||||||
|                 NetworkNodeStorageMonitor storageMonitor = ((TileStorageMonitor) world.getTileEntity(pos)).getNode(); |                 NetworkNodeStorageMonitor storageMonitor = ((TileStorageMonitor) world.getTileEntity(pos)).getNode(); | ||||||
|  |  | ||||||
| @@ -57,12 +64,6 @@ public class BlockStorageMonitor extends BlockNode { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nullable |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileStorageMonitor(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean hasConnectivityState() { |     public boolean hasConnectivityState() { | ||||||
|         return true; |         return true; | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block; | ||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RSGui; | import com.raoulvdberge.refinedstorage.RSGui; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsWirelessTransmitter; | import com.raoulvdberge.refinedstorage.render.collision.constants.ConstantsWirelessTransmitter; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileWirelessTransmitter; | import com.raoulvdberge.refinedstorage.tile.TileWirelessTransmitter; | ||||||
| import net.minecraft.block.Block; | import net.minecraft.block.Block; | ||||||
| @@ -10,7 +11,6 @@ import net.minecraft.client.resources.I18n; | |||||||
| import net.minecraft.client.util.ITooltipFlag; | import net.minecraft.client.util.ITooltipFlag; | ||||||
| import net.minecraft.entity.player.EntityPlayer; | import net.minecraft.entity.player.EntityPlayer; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.item.ItemStack; | ||||||
| import net.minecraft.tileentity.TileEntity; |  | ||||||
| import net.minecraft.util.BlockRenderLayer; | import net.minecraft.util.BlockRenderLayer; | ||||||
| import net.minecraft.util.EnumFacing; | import net.minecraft.util.EnumFacing; | ||||||
| import net.minecraft.util.EnumHand; | import net.minecraft.util.EnumHand; | ||||||
| @@ -25,21 +25,12 @@ import java.util.List; | |||||||
|  |  | ||||||
| public class BlockWirelessTransmitter extends BlockNode { | public class BlockWirelessTransmitter extends BlockNode { | ||||||
|     public BlockWirelessTransmitter() { |     public BlockWirelessTransmitter() { | ||||||
|         super("wireless_transmitter"); |         super(BlockInfoBuilder.forId("wireless_transmitter").tileEntity(TileWirelessTransmitter::new).create()); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileWirelessTransmitter(); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { |     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { | ||||||
|         if (!world.isRemote) { |         return openNetworkGui(RSGui.WIRELESS_TRANSMITTER, player, world, pos, side); | ||||||
|             tryOpenNetworkGui(RSGui.WIRELESS_TRANSMITTER, player, world, pos, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -85,12 +76,6 @@ public class BlockWirelessTransmitter extends BlockNode { | |||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return null; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag) { |     public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag) { | ||||||
|         super.addInformation(stack, world, tooltip, flag); |         super.addInformation(stack, world, tooltip, flag); | ||||||
|   | |||||||
| @@ -5,6 +5,7 @@ import com.raoulvdberge.refinedstorage.RSGui; | |||||||
| import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel; | import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel; | ||||||
| import com.raoulvdberge.refinedstorage.api.network.readerwriter.IWriter; | import com.raoulvdberge.refinedstorage.api.network.readerwriter.IWriter; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeWriter; | import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeWriter; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup; | import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileWriter; | import com.raoulvdberge.refinedstorage.tile.TileWriter; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| @@ -21,7 +22,13 @@ import java.util.List; | |||||||
|  |  | ||||||
| public class BlockWriter extends BlockCable { | public class BlockWriter extends BlockCable { | ||||||
|     public BlockWriter() { |     public BlockWriter() { | ||||||
|         super("writer"); |         super(createBuilder("writer").tileEntity(TileWriter::new).create()); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     @Nullable | ||||||
|  |     public BlockDirection getDirection() { | ||||||
|  |         return BlockDirection.ANY; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -47,18 +54,13 @@ public class BlockWriter extends BlockCable { | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 tryOpenNetworkGui(RSGui.READER_WRITER, player, world, pos, side); |                 openNetworkGui(RSGui.READER_WRITER, player, world, pos, side); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public TileEntity createTileEntity(World world, IBlockState state) { |  | ||||||
|         return new TileWriter(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     @SuppressWarnings("deprecation") |     @SuppressWarnings("deprecation") | ||||||
|     public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { |     public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { | ||||||
| @@ -90,10 +92,4 @@ public class BlockWriter extends BlockCable { | |||||||
|     public boolean hasConnectivityState() { |     public boolean hasConnectivityState() { | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     @Nullable |  | ||||||
|     public Direction getDirection() { |  | ||||||
|         return Direction.ANY; |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block.enums; | ||||||
| 
 | 
 | ||||||
| import net.minecraft.util.IStringSerializable; | import net.minecraft.util.IStringSerializable; | ||||||
| 
 | 
 | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block.enums; | ||||||
| 
 | 
 | ||||||
| import net.minecraft.util.IStringSerializable; | import net.minecraft.util.IStringSerializable; | ||||||
| 
 | 
 | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block.enums; | ||||||
| 
 | 
 | ||||||
| import net.minecraft.util.IStringSerializable; | import net.minecraft.util.IStringSerializable; | ||||||
| 
 | 
 | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block.enums; | ||||||
| 
 | 
 | ||||||
| import net.minecraft.util.IStringSerializable; | import net.minecraft.util.IStringSerializable; | ||||||
| 
 | 
 | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block.enums; | ||||||
| 
 | 
 | ||||||
| import net.minecraft.util.IStringSerializable; | import net.minecraft.util.IStringSerializable; | ||||||
| 
 | 
 | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block.enums; | ||||||
| 
 | 
 | ||||||
| import net.minecraft.util.IStringSerializable; | import net.minecraft.util.IStringSerializable; | ||||||
| 
 | 
 | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block.info; | ||||||
| 
 | 
 | ||||||
| import net.minecraft.block.properties.PropertyDirection; | import net.minecraft.block.properties.PropertyDirection; | ||||||
| import net.minecraft.entity.EntityLivingBase; | import net.minecraft.entity.EntityLivingBase; | ||||||
| @@ -7,14 +7,14 @@ import net.minecraft.util.math.BlockPos; | |||||||
| 
 | 
 | ||||||
| import java.util.Arrays; | import java.util.Arrays; | ||||||
| 
 | 
 | ||||||
| public enum Direction { | public enum BlockDirection { | ||||||
|     ANY(EnumFacing.VALUES), |     ANY(EnumFacing.VALUES), | ||||||
|     ANY_FACE_PLAYER(EnumFacing.VALUES), |     ANY_FACE_PLAYER(EnumFacing.VALUES), | ||||||
|     HORIZONTAL(EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.SOUTH, EnumFacing.WEST); |     HORIZONTAL(EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.SOUTH, EnumFacing.WEST); | ||||||
| 
 | 
 | ||||||
|     private final PropertyDirection property; |     private final PropertyDirection property; | ||||||
| 
 | 
 | ||||||
|     Direction(EnumFacing... allowed) { |     BlockDirection(EnumFacing... allowed) { | ||||||
|         this.property = PropertyDirection.create("direction", Arrays.asList(allowed)); |         this.property = PropertyDirection.create("direction", Arrays.asList(allowed)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @@ -0,0 +1,70 @@ | |||||||
|  | package com.raoulvdberge.refinedstorage.block.info; | ||||||
|  |  | ||||||
|  | import com.raoulvdberge.refinedstorage.tile.TileBase; | ||||||
|  | import net.minecraft.block.SoundType; | ||||||
|  | import net.minecraft.block.material.Material; | ||||||
|  |  | ||||||
|  | import javax.annotation.Nullable; | ||||||
|  | import java.util.function.Supplier; | ||||||
|  |  | ||||||
|  | public class BlockInfo implements IBlockInfo { | ||||||
|  |     private final Material material; | ||||||
|  |     private final SoundType soundType; | ||||||
|  |     private final float hardness; | ||||||
|  |     private final String id; | ||||||
|  |     private final String modId; | ||||||
|  |     private final Object modObject; | ||||||
|  |     @Nullable | ||||||
|  |     private final Supplier<TileBase> tileSupplier; | ||||||
|  |  | ||||||
|  |     public BlockInfo(Material material, SoundType soundType, float hardness, String id, String modId, Object modObject, Supplier<TileBase> tileSupplier) { | ||||||
|  |         this.material = material; | ||||||
|  |         this.soundType = soundType; | ||||||
|  |         this.hardness = hardness; | ||||||
|  |         this.id = id; | ||||||
|  |         this.modId = modId; | ||||||
|  |         this.modObject = modObject; | ||||||
|  |         this.tileSupplier = tileSupplier; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public Material getMaterial() { | ||||||
|  |         return material; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public SoundType getSoundType() { | ||||||
|  |         return soundType; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public String getId() { | ||||||
|  |         return id; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public String getModId() { | ||||||
|  |         return modId; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public Object getModObject() { | ||||||
|  |         return modObject; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public float getHardness() { | ||||||
|  |         return hardness; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Nullable | ||||||
|  |     @Override | ||||||
|  |     public TileBase createTileEntity() { | ||||||
|  |         return tileSupplier.get(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public boolean hasTileEntity() { | ||||||
|  |         return tileSupplier != null; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,63 @@ | |||||||
|  | package com.raoulvdberge.refinedstorage.block.info; | ||||||
|  |  | ||||||
|  | import com.raoulvdberge.refinedstorage.RS; | ||||||
|  | import com.raoulvdberge.refinedstorage.tile.TileBase; | ||||||
|  | import net.minecraft.block.SoundType; | ||||||
|  | import net.minecraft.block.material.Material; | ||||||
|  |  | ||||||
|  | import java.util.function.Supplier; | ||||||
|  |  | ||||||
|  | public final class BlockInfoBuilder { | ||||||
|  |     private Material material = Material.ROCK; | ||||||
|  |     private String id; | ||||||
|  |     private String modId; | ||||||
|  |     private Object modObject; | ||||||
|  |     private float hardness = 1.9F; | ||||||
|  |     private SoundType soundType = SoundType.STONE; | ||||||
|  |     private Supplier<TileBase> tileSupplier; | ||||||
|  |  | ||||||
|  |     private BlockInfoBuilder() { | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static BlockInfoBuilder forMod(Object modObject, String modId, String id) { | ||||||
|  |         BlockInfoBuilder builder = new BlockInfoBuilder(); | ||||||
|  |  | ||||||
|  |         builder.modObject = modObject; | ||||||
|  |         builder.modId = modId; | ||||||
|  |         builder.id = id; | ||||||
|  |  | ||||||
|  |         return builder; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static BlockInfoBuilder forId(String id) { | ||||||
|  |         return forMod(RS.INSTANCE, RS.ID, id); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public BlockInfoBuilder material(Material material) { | ||||||
|  |         this.material = material; | ||||||
|  |  | ||||||
|  |         return this; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public BlockInfoBuilder soundType(SoundType soundType) { | ||||||
|  |         this.soundType = soundType; | ||||||
|  |  | ||||||
|  |         return this; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public BlockInfoBuilder hardness(float hardness) { | ||||||
|  |         this.hardness = hardness; | ||||||
|  |  | ||||||
|  |         return this; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public BlockInfoBuilder tileEntity(Supplier<TileBase> tileSupplier) { | ||||||
|  |         this.tileSupplier = tileSupplier; | ||||||
|  |  | ||||||
|  |         return this; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public BlockInfo create() { | ||||||
|  |         return new BlockInfo(material, soundType, hardness, id, modId, modObject, tileSupplier); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,26 @@ | |||||||
|  | package com.raoulvdberge.refinedstorage.block.info; | ||||||
|  |  | ||||||
|  | import com.raoulvdberge.refinedstorage.tile.TileBase; | ||||||
|  | import net.minecraft.block.SoundType; | ||||||
|  | import net.minecraft.block.material.Material; | ||||||
|  |  | ||||||
|  | import javax.annotation.Nullable; | ||||||
|  |  | ||||||
|  | public interface IBlockInfo { | ||||||
|  |     Material getMaterial(); | ||||||
|  |  | ||||||
|  |     SoundType getSoundType(); | ||||||
|  |  | ||||||
|  |     String getId(); | ||||||
|  |  | ||||||
|  |     String getModId(); | ||||||
|  |  | ||||||
|  |     Object getModObject(); | ||||||
|  |  | ||||||
|  |     float getHardness(); | ||||||
|  |  | ||||||
|  |     @Nullable | ||||||
|  |     TileBase createTileEntity(); | ||||||
|  |  | ||||||
|  |     boolean hasTileEntity(); | ||||||
|  | } | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| package com.raoulvdberge.refinedstorage.block; | package com.raoulvdberge.refinedstorage.block.property; | ||||||
| 
 | 
 | ||||||
| import net.minecraftforge.common.property.IUnlistedProperty; | import net.minecraftforge.common.property.IUnlistedProperty; | ||||||
| 
 | 
 | ||||||
| @@ -1,6 +1,6 @@ | |||||||
| package com.raoulvdberge.refinedstorage.item; | package com.raoulvdberge.refinedstorage.item; | ||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.block.Direction; | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileBase; | import com.raoulvdberge.refinedstorage.tile.TileBase; | ||||||
| import net.minecraft.block.Block; | import net.minecraft.block.Block; | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| @@ -13,9 +13,9 @@ import net.minecraft.util.math.BlockPos; | |||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
|  |  | ||||||
| public class ItemBlockBase extends ItemBlock { | public class ItemBlockBase extends ItemBlock { | ||||||
|     private Direction direction; |     private BlockDirection direction; | ||||||
|  |  | ||||||
|     public ItemBlockBase(Block block, Direction direction, boolean subtypes) { |     public ItemBlockBase(Block block, BlockDirection direction, boolean subtypes) { | ||||||
|         super(block); |         super(block); | ||||||
|  |  | ||||||
|         setRegistryName(block.getRegistryName()); |         setRegistryName(block.getRegistryName()); | ||||||
|   | |||||||
| @@ -1,9 +1,10 @@ | |||||||
| package com.raoulvdberge.refinedstorage.item; | package com.raoulvdberge.refinedstorage.item; | ||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RS; | import com.raoulvdberge.refinedstorage.RS; | ||||||
| import com.raoulvdberge.refinedstorage.RSBlocks; | import com.raoulvdberge.refinedstorage.block.enums.ControllerType; | ||||||
| import com.raoulvdberge.refinedstorage.block.ControllerType; | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileController; | import com.raoulvdberge.refinedstorage.tile.TileController; | ||||||
|  | import net.minecraft.block.Block; | ||||||
| import net.minecraft.client.resources.I18n; | import net.minecraft.client.resources.I18n; | ||||||
| import net.minecraft.client.util.ITooltipFlag; | import net.minecraft.client.util.ITooltipFlag; | ||||||
| import net.minecraft.entity.player.EntityPlayer; | import net.minecraft.entity.player.EntityPlayer; | ||||||
| @@ -15,8 +16,8 @@ import javax.annotation.Nullable; | |||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public class ItemBlockController extends ItemBlockBase { | public class ItemBlockController extends ItemBlockBase { | ||||||
|     public ItemBlockController() { |     public ItemBlockController(Block block, BlockDirection direction) { | ||||||
|         super(RSBlocks.CONTROLLER, RSBlocks.CONTROLLER.getDirection(), true); |         super(block, direction, true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| package com.raoulvdberge.refinedstorage.item; | package com.raoulvdberge.refinedstorage.item; | ||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.block.Direction; | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
| import net.minecraft.block.Block; | import net.minecraft.block.Block; | ||||||
| import net.minecraft.client.resources.I18n; | import net.minecraft.client.resources.I18n; | ||||||
| import net.minecraft.client.util.ITooltipFlag; | import net.minecraft.client.util.ITooltipFlag; | ||||||
| @@ -23,7 +23,7 @@ public abstract class ItemBlockEnergyItem extends ItemBlockBase { | |||||||
|  |  | ||||||
|     private int energyCapacity; |     private int energyCapacity; | ||||||
|  |  | ||||||
|     public ItemBlockEnergyItem(Block block, Direction direction, int energyCapacity) { |     public ItemBlockEnergyItem(Block block, BlockDirection direction, int energyCapacity) { | ||||||
|         super(block, direction, true); |         super(block, direction, true); | ||||||
|  |  | ||||||
|         this.energyCapacity = energyCapacity; |         this.energyCapacity = energyCapacity; | ||||||
|   | |||||||
| @@ -7,6 +7,8 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData; | |||||||
| import com.raoulvdberge.refinedstorage.apiimpl.API; | import com.raoulvdberge.refinedstorage.apiimpl.API; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeFluidStorage; | import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeFluidStorage; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper; | import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
|  | import net.minecraft.block.Block; | ||||||
| import net.minecraft.client.resources.I18n; | import net.minecraft.client.resources.I18n; | ||||||
| import net.minecraft.client.util.ITooltipFlag; | import net.minecraft.client.util.ITooltipFlag; | ||||||
| import net.minecraft.entity.Entity; | import net.minecraft.entity.Entity; | ||||||
| @@ -23,8 +25,8 @@ import java.util.List; | |||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
|  |  | ||||||
| public class ItemBlockFluidStorage extends ItemBlockBase { | public class ItemBlockFluidStorage extends ItemBlockBase { | ||||||
|     public ItemBlockFluidStorage() { |     public ItemBlockFluidStorage(Block block, BlockDirection direction) { | ||||||
|         super(RSBlocks.FLUID_STORAGE, RSBlocks.FLUID_STORAGE.getDirection(), true); |         super(block, direction, true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -1,9 +1,10 @@ | |||||||
| package com.raoulvdberge.refinedstorage.item; | package com.raoulvdberge.refinedstorage.item; | ||||||
|  |  | ||||||
| import com.raoulvdberge.refinedstorage.RS; | import com.raoulvdberge.refinedstorage.RS; | ||||||
| import com.raoulvdberge.refinedstorage.RSBlocks; |  | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.API; | import com.raoulvdberge.refinedstorage.apiimpl.API; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
| import com.raoulvdberge.refinedstorage.tile.grid.portable.PortableGrid; | import com.raoulvdberge.refinedstorage.tile.grid.portable.PortableGrid; | ||||||
|  | import net.minecraft.block.Block; | ||||||
| import net.minecraft.client.resources.I18n; | import net.minecraft.client.resources.I18n; | ||||||
| import net.minecraft.client.util.ITooltipFlag; | import net.minecraft.client.util.ITooltipFlag; | ||||||
| import net.minecraft.entity.player.EntityPlayer; | import net.minecraft.entity.player.EntityPlayer; | ||||||
| @@ -19,8 +20,8 @@ import javax.annotation.Nullable; | |||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public class ItemBlockPortableGrid extends ItemBlockEnergyItem { | public class ItemBlockPortableGrid extends ItemBlockEnergyItem { | ||||||
|     public ItemBlockPortableGrid() { |     public ItemBlockPortableGrid(Block block, BlockDirection direction) { | ||||||
|         super(RSBlocks.PORTABLE_GRID, RSBlocks.PORTABLE_GRID.getDirection(), RS.INSTANCE.config.portableGridCapacity); |         super(block, direction, RS.INSTANCE.config.portableGridCapacity); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -7,6 +7,8 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData; | |||||||
| import com.raoulvdberge.refinedstorage.apiimpl.API; | import com.raoulvdberge.refinedstorage.apiimpl.API; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeStorage; | import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeStorage; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper; | import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.BlockDirection; | ||||||
|  | import net.minecraft.block.Block; | ||||||
| import net.minecraft.client.resources.I18n; | import net.minecraft.client.resources.I18n; | ||||||
| import net.minecraft.client.util.ITooltipFlag; | import net.minecraft.client.util.ITooltipFlag; | ||||||
| import net.minecraft.entity.Entity; | import net.minecraft.entity.Entity; | ||||||
| @@ -23,8 +25,8 @@ import java.util.List; | |||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
|  |  | ||||||
| public class ItemBlockStorage extends ItemBlockBase { | public class ItemBlockStorage extends ItemBlockBase { | ||||||
|     public ItemBlockStorage() { |     public ItemBlockStorage(Block block, BlockDirection direction) { | ||||||
|         super(RSBlocks.STORAGE, RSBlocks.STORAGE.getDirection(), true); |         super(block, direction, true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk; | |||||||
| import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider; | import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider; | ||||||
| import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData; | import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.API; | import com.raoulvdberge.refinedstorage.apiimpl.API; | ||||||
| import com.raoulvdberge.refinedstorage.block.FluidStorageType; | import com.raoulvdberge.refinedstorage.block.enums.FluidStorageType; | ||||||
| import net.minecraft.client.resources.I18n; | import net.minecraft.client.resources.I18n; | ||||||
| import net.minecraft.client.util.ITooltipFlag; | import net.minecraft.client.util.ITooltipFlag; | ||||||
| import net.minecraft.creativetab.CreativeTabs; | import net.minecraft.creativetab.CreativeTabs; | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk; | |||||||
| import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider; | import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider; | ||||||
| import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData; | import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.API; | import com.raoulvdberge.refinedstorage.apiimpl.API; | ||||||
| import com.raoulvdberge.refinedstorage.block.ItemStorageType; | import com.raoulvdberge.refinedstorage.block.enums.ItemStorageType; | ||||||
| import net.minecraft.client.resources.I18n; | import net.minecraft.client.resources.I18n; | ||||||
| import net.minecraft.client.util.ITooltipFlag; | import net.minecraft.client.util.ITooltipFlag; | ||||||
| import net.minecraft.creativetab.CreativeTabs; | import net.minecraft.creativetab.CreativeTabs; | ||||||
|   | |||||||
| @@ -5,17 +5,19 @@ import com.raoulvdberge.refinedstorage.RSBlocks; | |||||||
| import com.raoulvdberge.refinedstorage.RSItems; | import com.raoulvdberge.refinedstorage.RSItems; | ||||||
| import com.raoulvdberge.refinedstorage.RSKeyBindings; | import com.raoulvdberge.refinedstorage.RSKeyBindings; | ||||||
| import com.raoulvdberge.refinedstorage.api.network.grid.GridType; | import com.raoulvdberge.refinedstorage.api.network.grid.GridType; | ||||||
| import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider; |  | ||||||
| import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData; |  | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.API; |  | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.CraftingPattern; | import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.CraftingPattern; | ||||||
| import com.raoulvdberge.refinedstorage.block.*; | import com.raoulvdberge.refinedstorage.block.BlockController; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.BlockPortableGrid; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.enums.ControllerEnergyType; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.enums.ControllerType; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.enums.FluidStorageType; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.enums.ItemStorageType; | ||||||
| import com.raoulvdberge.refinedstorage.gui.GuiCraftingPreview; | import com.raoulvdberge.refinedstorage.gui.GuiCraftingPreview; | ||||||
| import com.raoulvdberge.refinedstorage.gui.grid.GuiCraftingStart; | import com.raoulvdberge.refinedstorage.gui.grid.GuiCraftingStart; | ||||||
| import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase; |  | ||||||
| import com.raoulvdberge.refinedstorage.item.*; | import com.raoulvdberge.refinedstorage.item.*; | ||||||
| import com.raoulvdberge.refinedstorage.network.MessageGridCraftingPreviewResponse; | import com.raoulvdberge.refinedstorage.network.MessageGridCraftingPreviewResponse; | ||||||
| import com.raoulvdberge.refinedstorage.render.collision.BlockHighlightListener; | import com.raoulvdberge.refinedstorage.render.collision.BlockHighlightListener; | ||||||
|  | import com.raoulvdberge.refinedstorage.render.meshdefinition.ItemMeshDefinitionPortableGrid; | ||||||
| import com.raoulvdberge.refinedstorage.render.model.ModelDiskDrive; | import com.raoulvdberge.refinedstorage.render.model.ModelDiskDrive; | ||||||
| import com.raoulvdberge.refinedstorage.render.model.ModelDiskManipulator; | import com.raoulvdberge.refinedstorage.render.model.ModelDiskManipulator; | ||||||
| import com.raoulvdberge.refinedstorage.render.model.baked.BakedModelCableCover; | import com.raoulvdberge.refinedstorage.render.model.baked.BakedModelCableCover; | ||||||
| @@ -26,9 +28,6 @@ import com.raoulvdberge.refinedstorage.render.statemapper.StateMapperCTM; | |||||||
| import com.raoulvdberge.refinedstorage.render.tesr.TileEntitySpecialRendererStorageMonitor; | import com.raoulvdberge.refinedstorage.render.tesr.TileEntitySpecialRendererStorageMonitor; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileController; | import com.raoulvdberge.refinedstorage.tile.TileController; | ||||||
| import com.raoulvdberge.refinedstorage.tile.TileStorageMonitor; | import com.raoulvdberge.refinedstorage.tile.TileStorageMonitor; | ||||||
| import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid; |  | ||||||
| import com.raoulvdberge.refinedstorage.tile.grid.portable.TilePortableGrid; |  | ||||||
| import com.raoulvdberge.refinedstorage.util.StackUtils; |  | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| import net.minecraft.client.Minecraft; | import net.minecraft.client.Minecraft; | ||||||
| import net.minecraft.client.gui.GuiScreen; | import net.minecraft.client.gui.GuiScreen; | ||||||
| @@ -44,7 +43,6 @@ import net.minecraftforge.client.event.ModelRegistryEvent; | |||||||
| import net.minecraftforge.client.model.ModelLoader; | import net.minecraftforge.client.model.ModelLoader; | ||||||
| import net.minecraftforge.client.model.ModelLoaderRegistry; | import net.minecraftforge.client.model.ModelLoaderRegistry; | ||||||
| import net.minecraftforge.common.MinecraftForge; | import net.minecraftforge.common.MinecraftForge; | ||||||
| import net.minecraftforge.energy.CapabilityEnergy; |  | ||||||
| import net.minecraftforge.fml.client.registry.ClientRegistry; | import net.minecraftforge.fml.client.registry.ClientRegistry; | ||||||
| import net.minecraftforge.fml.common.FMLCommonHandler; | import net.minecraftforge.fml.common.FMLCommonHandler; | ||||||
| import net.minecraftforge.fml.common.Loader; | import net.minecraftforge.fml.common.Loader; | ||||||
| @@ -52,8 +50,6 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent; | |||||||
| import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | ||||||
| import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||||||
|  |  | ||||||
| import java.util.UUID; |  | ||||||
|  |  | ||||||
| public class ProxyClient extends ProxyCommon { | public class ProxyClient extends ProxyCommon { | ||||||
|     @Override |     @Override | ||||||
|     public void preInit(FMLPreInitializationEvent e) { |     public void preInit(FMLPreInitializationEvent e) { | ||||||
| @@ -289,55 +285,7 @@ public class ProxyClient extends ProxyCommon { | |||||||
|         ModelLoaderRegistry.registerLoader(new CustomModelLoaderCover()); |         ModelLoaderRegistry.registerLoader(new CustomModelLoaderCover()); | ||||||
|  |  | ||||||
|         ModelLoader.setCustomStateMapper(RSBlocks.PORTABLE_GRID, new StateMap.Builder().ignore(BlockPortableGrid.TYPE).build()); |         ModelLoader.setCustomStateMapper(RSBlocks.PORTABLE_GRID, new StateMap.Builder().ignore(BlockPortableGrid.TYPE).build()); | ||||||
|         ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(RSBlocks.PORTABLE_GRID), stack -> { |         ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(RSBlocks.PORTABLE_GRID), new ItemMeshDefinitionPortableGrid()); | ||||||
|             ItemHandlerBase disk = new ItemHandlerBase(1); |  | ||||||
|  |  | ||||||
|             if (stack.hasTagCompound()) { |  | ||||||
|                 StackUtils.readItems(disk, 4, stack.getTagCompound()); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             UUID diskId = disk.getStackInSlot(0).isEmpty() ? null : ((IStorageDiskProvider) disk.getStackInSlot(0).getItem()).getId(disk.getStackInSlot(0)); |  | ||||||
|  |  | ||||||
|             IPortableGrid.IPortableGridRenderInfo renderInfo = new IPortableGrid.IPortableGridRenderInfo() { |  | ||||||
|                 @Override |  | ||||||
|                 public int getStored() { |  | ||||||
|                     if (diskId == null) { |  | ||||||
|                         return 0; |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     API.instance().getStorageDiskSync().sendRequest(diskId); |  | ||||||
|  |  | ||||||
|                     IStorageDiskSyncData data = API.instance().getStorageDiskSync().getData(diskId); |  | ||||||
|  |  | ||||||
|                     return data == null ? 0 : data.getStored(); |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 @Override |  | ||||||
|                 public int getCapacity() { |  | ||||||
|                     if (diskId == null) { |  | ||||||
|                         return 0; |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     API.instance().getStorageDiskSync().sendRequest(diskId); |  | ||||||
|  |  | ||||||
|                     IStorageDiskSyncData data = API.instance().getStorageDiskSync().getData(diskId); |  | ||||||
|  |  | ||||||
|                     return data == null ? 0 : data.getCapacity(); |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 @Override |  | ||||||
|                 public boolean hasStorage() { |  | ||||||
|                     return diskId != null; |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 @Override |  | ||||||
|                 public boolean isActive() { |  | ||||||
|                     return (stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored() > 0 || stack.getMetadata() == ItemBlockPortableGrid.TYPE_CREATIVE) && hasStorage(); |  | ||||||
|                 } |  | ||||||
|             }; |  | ||||||
|  |  | ||||||
|             return new ModelResourceLocation("refinedstorage:portable_grid", "connected=" + Boolean.toString(renderInfo.isActive()) + ",direction=north,disk_state=" + TilePortableGrid.getDiskState(renderInfo)); |  | ||||||
|         }); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void onReceiveCraftingPreviewResponse(MessageGridCraftingPreviewResponse message) { |     public static void onReceiveCraftingPreviewResponse(MessageGridCraftingPreviewResponse message) { | ||||||
|   | |||||||
| @@ -27,6 +27,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage.ExternalS | |||||||
| import com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage.ExternalStorageProviderItem; | import com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage.ExternalStorageProviderItem; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper; | import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper; | ||||||
| import com.raoulvdberge.refinedstorage.block.BlockBase; | import com.raoulvdberge.refinedstorage.block.BlockBase; | ||||||
|  | import com.raoulvdberge.refinedstorage.block.info.IBlockInfo; | ||||||
| import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy; | import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy; | ||||||
| import com.raoulvdberge.refinedstorage.container.ContainerCrafter; | import com.raoulvdberge.refinedstorage.container.ContainerCrafter; | ||||||
| import com.raoulvdberge.refinedstorage.container.ContainerCrafterManager; | import com.raoulvdberge.refinedstorage.container.ContainerCrafterManager; | ||||||
| @@ -45,14 +46,12 @@ import com.raoulvdberge.refinedstorage.network.*; | |||||||
| import com.raoulvdberge.refinedstorage.recipe.RecipeCover; | import com.raoulvdberge.refinedstorage.recipe.RecipeCover; | ||||||
| import com.raoulvdberge.refinedstorage.recipe.RecipeHollowCover; | import com.raoulvdberge.refinedstorage.recipe.RecipeHollowCover; | ||||||
| import com.raoulvdberge.refinedstorage.recipe.RecipeHollowWideCover; | import com.raoulvdberge.refinedstorage.recipe.RecipeHollowWideCover; | ||||||
| import com.raoulvdberge.refinedstorage.tile.*; | import com.raoulvdberge.refinedstorage.tile.TileBase; | ||||||
| import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor; | import com.raoulvdberge.refinedstorage.tile.TileNode; | ||||||
| import com.raoulvdberge.refinedstorage.tile.data.TileDataManager; | import com.raoulvdberge.refinedstorage.tile.data.TileDataManager; | ||||||
| import com.raoulvdberge.refinedstorage.tile.grid.TileGrid; |  | ||||||
| import com.raoulvdberge.refinedstorage.tile.grid.WirelessFluidGrid; | import com.raoulvdberge.refinedstorage.tile.grid.WirelessFluidGrid; | ||||||
| import com.raoulvdberge.refinedstorage.tile.grid.WirelessGrid; | import com.raoulvdberge.refinedstorage.tile.grid.WirelessGrid; | ||||||
| import com.raoulvdberge.refinedstorage.tile.grid.portable.PortableGrid; | import com.raoulvdberge.refinedstorage.tile.grid.portable.PortableGrid; | ||||||
| import com.raoulvdberge.refinedstorage.tile.grid.portable.TilePortableGrid; |  | ||||||
| import com.raoulvdberge.refinedstorage.util.StackUtils; | import com.raoulvdberge.refinedstorage.util.StackUtils; | ||||||
| import net.minecraft.block.Block; | import net.minecraft.block.Block; | ||||||
| import net.minecraft.client.Minecraft; | import net.minecraft.client.Minecraft; | ||||||
| @@ -188,34 +187,6 @@ public class ProxyCommon { | |||||||
|  |  | ||||||
|         MinecraftForge.EVENT_BUS.register(new NetworkNodeListener()); |         MinecraftForge.EVENT_BUS.register(new NetworkNodeListener()); | ||||||
|  |  | ||||||
|         registerTile(TileController.class, "controller"); |  | ||||||
|         registerTile(TileGrid.class, "grid"); |  | ||||||
|         registerTile(TileDiskDrive.class, "disk_drive"); |  | ||||||
|         registerTile(TileExternalStorage.class, "external_storage"); |  | ||||||
|         registerTile(TileImporter.class, "importer"); |  | ||||||
|         registerTile(TileExporter.class, "exporter"); |  | ||||||
|         registerTile(TileDetector.class, "detector"); |  | ||||||
|         registerTile(TileDestructor.class, "destructor"); |  | ||||||
|         registerTile(TileConstructor.class, "constructor"); |  | ||||||
|         registerTile(TileStorage.class, "storage"); |  | ||||||
|         registerTile(TileRelay.class, "relay"); |  | ||||||
|         registerTile(TileInterface.class, "interface"); |  | ||||||
|         registerTile(TileCraftingMonitor.class, "crafting_monitor"); |  | ||||||
|         registerTile(TileWirelessTransmitter.class, "wireless_transmitter"); |  | ||||||
|         registerTile(TileCrafter.class, "crafter"); |  | ||||||
|         registerTile(TileCable.class, "cable"); |  | ||||||
|         registerTile(TileNetworkReceiver.class, "network_receiver"); |  | ||||||
|         registerTile(TileNetworkTransmitter.class, "network_transmitter"); |  | ||||||
|         registerTile(TileFluidInterface.class, "fluid_interface"); |  | ||||||
|         registerTile(TileFluidStorage.class, "fluid_storage"); |  | ||||||
|         registerTile(TileDiskManipulator.class, "disk_manipulator"); |  | ||||||
|         registerTile(TileSecurityManager.class, "security_manager"); |  | ||||||
|         registerTile(TileReader.class, "reader"); |  | ||||||
|         registerTile(TileWriter.class, "writer"); |  | ||||||
|         registerTile(TileStorageMonitor.class, "storage_monitor"); |  | ||||||
|         registerTile(TilePortableGrid.class, "portable_grid"); |  | ||||||
|         registerTile(TileCrafterManager.class, "crafter_manager"); |  | ||||||
|  |  | ||||||
|         registerBlock(RSBlocks.CONTROLLER); |         registerBlock(RSBlocks.CONTROLLER); | ||||||
|         registerBlock(RSBlocks.GRID); |         registerBlock(RSBlocks.GRID); | ||||||
|         registerBlock(RSBlocks.PORTABLE_GRID); |         registerBlock(RSBlocks.PORTABLE_GRID); | ||||||
| @@ -365,17 +336,23 @@ public class ProxyCommon { | |||||||
|         blocksToRegister.add(block); |         blocksToRegister.add(block); | ||||||
|  |  | ||||||
|         registerItem(block.createItem()); |         registerItem(block.createItem()); | ||||||
|  |  | ||||||
|  |         if (block.getInfo().hasTileEntity()) { | ||||||
|  |             registerTile(block.getInfo()); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void registerItem(Item item) { |     private void registerItem(Item item) { | ||||||
|         itemsToRegister.add(item); |         itemsToRegister.add(item); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void registerTile(Class<? extends TileBase> tile, String id) { |     private void registerTile(IBlockInfo info) { | ||||||
|         GameRegistry.registerTileEntity(tile, new ResourceLocation(RS.ID, id)); |         Class<? extends TileBase> clazz = info.createTileEntity().getClass(); | ||||||
|  |  | ||||||
|  |         GameRegistry.registerTileEntity(clazz, new ResourceLocation(RS.ID, info.getId())); | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             TileBase tileInstance = tile.newInstance(); |             TileBase tileInstance = clazz.newInstance(); | ||||||
|  |  | ||||||
|             if (tileInstance instanceof TileNode) { |             if (tileInstance instanceof TileNode) { | ||||||
|                 API.instance().getNetworkNodeRegistry().add(((TileNode) tileInstance).getNodeId(), (tag, world, pos) -> { |                 API.instance().getNetworkNodeRegistry().add(((TileNode) tileInstance).getNodeId(), (tag, world, pos) -> { | ||||||
|   | |||||||
| @@ -0,0 +1,71 @@ | |||||||
|  | package com.raoulvdberge.refinedstorage.render.meshdefinition; | ||||||
|  |  | ||||||
|  | import com.raoulvdberge.refinedstorage.RS; | ||||||
|  | import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider; | ||||||
|  | import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSyncData; | ||||||
|  | import com.raoulvdberge.refinedstorage.apiimpl.API; | ||||||
|  | import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase; | ||||||
|  | import com.raoulvdberge.refinedstorage.item.ItemBlockPortableGrid; | ||||||
|  | import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid; | ||||||
|  | import com.raoulvdberge.refinedstorage.tile.grid.portable.TilePortableGrid; | ||||||
|  | import com.raoulvdberge.refinedstorage.util.StackUtils; | ||||||
|  | import net.minecraft.client.renderer.ItemMeshDefinition; | ||||||
|  | import net.minecraft.client.renderer.block.model.ModelResourceLocation; | ||||||
|  | import net.minecraft.item.ItemStack; | ||||||
|  | import net.minecraftforge.energy.CapabilityEnergy; | ||||||
|  |  | ||||||
|  | import java.util.UUID; | ||||||
|  |  | ||||||
|  | public class ItemMeshDefinitionPortableGrid implements ItemMeshDefinition { | ||||||
|  |     // TODO: Optimize | ||||||
|  |     @Override | ||||||
|  |     public ModelResourceLocation getModelLocation(ItemStack stack) { | ||||||
|  |         ItemHandlerBase disk = new ItemHandlerBase(1); | ||||||
|  |  | ||||||
|  |         if (stack.hasTagCompound()) { | ||||||
|  |             StackUtils.readItems(disk, 4, stack.getTagCompound()); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         UUID diskId = disk.getStackInSlot(0).isEmpty() ? null : ((IStorageDiskProvider) disk.getStackInSlot(0).getItem()).getId(disk.getStackInSlot(0)); | ||||||
|  |  | ||||||
|  |         IPortableGrid.IPortableGridRenderInfo renderInfo = new IPortableGrid.IPortableGridRenderInfo() { | ||||||
|  |             @Override | ||||||
|  |             public int getStored() { | ||||||
|  |                 if (diskId == null) { | ||||||
|  |                     return 0; | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 API.instance().getStorageDiskSync().sendRequest(diskId); | ||||||
|  |  | ||||||
|  |                 IStorageDiskSyncData data = API.instance().getStorageDiskSync().getData(diskId); | ||||||
|  |  | ||||||
|  |                 return data == null ? 0 : data.getStored(); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             @Override | ||||||
|  |             public int getCapacity() { | ||||||
|  |                 if (diskId == null) { | ||||||
|  |                     return 0; | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 API.instance().getStorageDiskSync().sendRequest(diskId); | ||||||
|  |  | ||||||
|  |                 IStorageDiskSyncData data = API.instance().getStorageDiskSync().getData(diskId); | ||||||
|  |  | ||||||
|  |                 return data == null ? 0 : data.getCapacity(); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             @Override | ||||||
|  |             public boolean hasStorage() { | ||||||
|  |                 return diskId != null; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             @Override | ||||||
|  |             public boolean isActive() { | ||||||
|  |                 return (stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored() > 0 || stack.getMetadata() == ItemBlockPortableGrid.TYPE_CREATIVE) && hasStorage(); | ||||||
|  |             } | ||||||
|  |         }; | ||||||
|  |  | ||||||
|  |         return new ModelResourceLocation(RS.ID + ":portable_grid", "connected=" + Boolean.toString(renderInfo.isActive()) + ",direction=north,disk_state=" + TilePortableGrid.getDiskState(renderInfo)); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -34,8 +34,8 @@ import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheItem; | |||||||
| import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageTrackerFluid; | import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageTrackerFluid; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageTrackerItem; | import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageTrackerItem; | ||||||
| import com.raoulvdberge.refinedstorage.block.BlockController; | import com.raoulvdberge.refinedstorage.block.BlockController; | ||||||
| import com.raoulvdberge.refinedstorage.block.ControllerEnergyType; | import com.raoulvdberge.refinedstorage.block.enums.ControllerEnergyType; | ||||||
| import com.raoulvdberge.refinedstorage.block.ControllerType; | import com.raoulvdberge.refinedstorage.block.enums.ControllerType; | ||||||
| import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy; | import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy; | ||||||
| import com.raoulvdberge.refinedstorage.integration.forgeenergy.EnergyProxy; | import com.raoulvdberge.refinedstorage.integration.forgeenergy.EnergyProxy; | ||||||
| import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable; | import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable; | ||||||
|   | |||||||
| @@ -24,8 +24,8 @@ import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheListenerGridP | |||||||
| import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageTrackerItem; | import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageTrackerItem; | ||||||
| import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskItemPortable; | import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskItemPortable; | ||||||
| import com.raoulvdberge.refinedstorage.block.BlockPortableGrid; | import com.raoulvdberge.refinedstorage.block.BlockPortableGrid; | ||||||
| import com.raoulvdberge.refinedstorage.block.PortableGridDiskState; | import com.raoulvdberge.refinedstorage.block.enums.PortableGridDiskState; | ||||||
| import com.raoulvdberge.refinedstorage.block.PortableGridType; | import com.raoulvdberge.refinedstorage.block.enums.PortableGridType; | ||||||
| import com.raoulvdberge.refinedstorage.gui.GuiBase; | import com.raoulvdberge.refinedstorage.gui.GuiBase; | ||||||
| import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid; | import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid; | ||||||
| import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase; | import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 raoulvdberge
					raoulvdberge