diff --git a/src/main/java/com/raoulvdberge/refinedstorage/ClientSetup.java b/src/main/java/com/raoulvdberge/refinedstorage/ClientSetup.java index 46f50f631..c652aea70 100644 --- a/src/main/java/com/raoulvdberge/refinedstorage/ClientSetup.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/ClientSetup.java @@ -47,6 +47,7 @@ public class ClientSetup { bakedModelOverrideRegistry.add(new ResourceLocation(RS.ID, "network_receiver"), (base, registry) -> new FullbrightBakedModel(base, new ResourceLocation(RS.ID, "block/network_receiver/cutouts/connected"))); bakedModelOverrideRegistry.add(new ResourceLocation(RS.ID, "network_transmitter"), (base, registry) -> new FullbrightBakedModel(base, new ResourceLocation(RS.ID, "block/network_transmitter/cutouts/connected"))); bakedModelOverrideRegistry.add(new ResourceLocation(RS.ID, "relay"), (base, registry) -> new FullbrightBakedModel(base, new ResourceLocation(RS.ID, "block/relay/cutouts/connected"))); + bakedModelOverrideRegistry.add(new ResourceLocation(RS.ID, "detector"), (base, registry) -> new FullbrightBakedModel(base, new ResourceLocation(RS.ID, "block/detector/cutouts/on"))); bakedModelOverrideRegistry.add(new ResourceLocation(RS.ID, "disk_drive"), (base, registry) -> new FullbrightBakedModel( new DiskDriveBakedModel( @@ -61,7 +62,6 @@ public class ClientSetup { bakedModelOverrideRegistry.add(new ResourceLocation(RS.ID, "pattern"), (base, registry) -> new PatternBakedModel(base)); - ModelLoader.addSpecialModel(new ResourceLocation(RS.ID + ":block/disks/disk")); ModelLoader.addSpecialModel(new ResourceLocation(RS.ID + ":block/disks/disk_near_capacity")); ModelLoader.addSpecialModel(new ResourceLocation(RS.ID + ":block/disks/disk_full")); @@ -112,6 +112,7 @@ public class ClientSetup { ScreenManager.registerFactory(RSContainers.EXPORTER, ExporterScreen::new); ScreenManager.registerFactory(RSContainers.NETWORK_TRANSMITTER, NetworkTransmitterScreen::new); ScreenManager.registerFactory(RSContainers.RELAY, RelayScreen::new); + ScreenManager.registerFactory(RSContainers.DETECTOR, DetectorScreen::new); ClientRegistry.registerKeyBinding(RSKeyBindings.FOCUS_SEARCH_BAR); ClientRegistry.registerKeyBinding(RSKeyBindings.CLEAR_GRID_CRAFTING_MATRIX); diff --git a/src/main/java/com/raoulvdberge/refinedstorage/RS.java b/src/main/java/com/raoulvdberge/refinedstorage/RS.java index 0d7ee80c4..0d9bce856 100755 --- a/src/main/java/com/raoulvdberge/refinedstorage/RS.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/RS.java @@ -121,6 +121,7 @@ public final class RS { API.instance().getNetworkNodeRegistry().add(NetworkReceiverNetworkNode.ID, (tag, world, pos) -> readAndReturn(tag, new NetworkReceiverNetworkNode(world, pos))); API.instance().getNetworkNodeRegistry().add(NetworkTransmitterNetworkNode.ID, (tag, world, pos) -> readAndReturn(tag, new NetworkTransmitterNetworkNode(world, pos))); API.instance().getNetworkNodeRegistry().add(RelayNetworkNode.ID, (tag, world, pos) -> readAndReturn(tag, new RelayNetworkNode(world, pos))); + API.instance().getNetworkNodeRegistry().add(DetectorNetworkNode.ID, (tag, world, pos) -> readAndReturn(tag, new DetectorNetworkNode(world, pos))); API.instance().getGridManager().add(GridBlockGridFactory.ID, new GridBlockGridFactory()); @@ -168,6 +169,7 @@ public final class RS { e.getRegistry().register(new NetworkReceiverBlock()); e.getRegistry().register(new NetworkTransmitterBlock()); e.getRegistry().register(new RelayBlock()); + e.getRegistry().register(new DetectorBlock()); } @SubscribeEvent @@ -199,6 +201,7 @@ public final class RS { e.getRegistry().register(registerTileDataParameters(TileEntityType.Builder.create(NetworkReceiverTile::new, RSBlocks.NETWORK_RECEIVER).build(null).setRegistryName(RS.ID, "network_receiver"))); e.getRegistry().register(registerTileDataParameters(TileEntityType.Builder.create(NetworkTransmitterTile::new, RSBlocks.NETWORK_TRANSMITTER).build(null).setRegistryName(RS.ID, "network_transmitter"))); e.getRegistry().register(registerTileDataParameters(TileEntityType.Builder.create(RelayTile::new, RSBlocks.RELAY).build(null).setRegistryName(RS.ID, "relay"))); + e.getRegistry().register(registerTileDataParameters(TileEntityType.Builder.create(DetectorTile::new, RSBlocks.DETECTOR).build(null).setRegistryName(RS.ID, "detector"))); } private TileEntityType registerTileDataParameters(TileEntityType t) { @@ -222,6 +225,7 @@ public final class RS { e.getRegistry().register(IForgeContainerType.create(new PositionalTileContainerFactory((windowId, inv, tile) -> new ExporterContainer(tile, inv.player, windowId))).setRegistryName(RS.ID, "exporter")); e.getRegistry().register(IForgeContainerType.create(new PositionalTileContainerFactory((windowId, inv, tile) -> new NetworkTransmitterContainer(tile, inv.player, windowId))).setRegistryName(RS.ID, "network_transmitter")); e.getRegistry().register(IForgeContainerType.create(new PositionalTileContainerFactory((windowId, inv, tile) -> new RelayContainer(tile, inv.player, windowId))).setRegistryName(RS.ID, "relay")); + e.getRegistry().register(IForgeContainerType.create(new PositionalTileContainerFactory((windowId, inv, tile) -> new DetectorContainer(tile, inv.player, windowId))).setRegistryName(RS.ID, "detector")); } @SubscribeEvent @@ -295,6 +299,7 @@ public final class RS { e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.NETWORK_RECEIVER)); e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.NETWORK_TRANSMITTER)); e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.RELAY)); + e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.DETECTOR)); } /* TODO diff --git a/src/main/java/com/raoulvdberge/refinedstorage/RSBlocks.java b/src/main/java/com/raoulvdberge/refinedstorage/RSBlocks.java index df5a19a2d..3750a146c 100755 --- a/src/main/java/com/raoulvdberge/refinedstorage/RSBlocks.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/RSBlocks.java @@ -6,48 +6,30 @@ import net.minecraftforge.registries.ObjectHolder; public final class RSBlocks { @ObjectHolder(RS.ID + ":importer") public static final ImporterBlock IMPORTER = null; - @ObjectHolder(RS.ID + ":exporter") public static final ExporterBlock EXPORTER = null; - - public static final BlockDetector DETECTOR = new BlockDetector(); - public static final BlockDestructor DESTRUCTOR = new BlockDestructor(); - public static final BlockConstructor CONSTRUCTOR = new BlockConstructor(); - + @ObjectHolder(RS.ID + ":detector") + public static final DetectorBlock DETECTOR = null; @ObjectHolder(RS.ID + ":relay") public static final RelayBlock RELAY = null; - - public static final BlockInterface INTERFACE = new BlockInterface(); - public static final BlockCraftingMonitor CRAFTING_MONITOR = new BlockCraftingMonitor(); - public static final BlockWirelessTransmitter WIRELESS_TRANSMITTER = new BlockWirelessTransmitter(); - public static final BlockCrafter CRAFTER = new BlockCrafter(); - @ObjectHolder(RS.ID + ":network_transmitter") public static final NetworkTransmitterBlock NETWORK_TRANSMITTER = null; @ObjectHolder(RS.ID + ":network_receiver") public static final NetworkReceiverBlock NETWORK_RECEIVER = null; - - public static final BlockFluidInterface FLUID_INTERFACE = new BlockFluidInterface(); - public static final BlockDiskManipulator DISK_MANIPULATOR = new BlockDiskManipulator(); - public static final BlockSecurityManager SECURITY_MANAGER = new BlockSecurityManager(); - @ObjectHolder(RS.ID + ":quartz_enriched_iron_block") public static final QuartzEnrichedIronBlock QUARTZ_ENRICHED_IRON = null; - @ObjectHolder(RS.ID + ":machine_casing") public static final MachineCasingBlock MACHINE_CASING = null; - @ObjectHolder(RS.ID + ":controller") public static final ControllerBlock CONTROLLER = null; @ObjectHolder(RS.ID + ":creative_controller") public static final ControllerBlock CREATIVE_CONTROLLER = null; - @ObjectHolder(RS.ID + ":cable") public static final CableBlock CABLE = null; - @ObjectHolder(RS.ID + ":disk_drive") public static final DiskDriveBlock DISK_DRIVE = null; - + @ObjectHolder(RS.ID + ":external_storage") + public static final ExternalStorageBlock EXTERNAL_STORAGE = null; @ObjectHolder(RS.ID + ":grid") public static final GridBlock GRID = null; @ObjectHolder(RS.ID + ":crafting_grid") @@ -56,7 +38,6 @@ public final class RSBlocks { public static final GridBlock PATTERN_GRID = null; @ObjectHolder(RS.ID + ":fluid_grid") public static final GridBlock FLUID_GRID = null; - @ObjectHolder(RS.ID + ":1k_storage_block") public static final StorageBlock ONE_K_STORAGE_BLOCK = null; @ObjectHolder(RS.ID + ":4k_storage_block") @@ -67,7 +48,6 @@ public final class RSBlocks { public static final StorageBlock SIXTY_FOUR_K_STORAGE_BLOCK = null; @ObjectHolder(RS.ID + ":creative_storage_block") public static final StorageBlock CREATIVE_STORAGE_BLOCK = null; - @ObjectHolder(RS.ID + ":64k_fluid_storage_block") public static final FluidStorageBlock SIXTY_FOUR_K_FLUID_STORAGE_BLOCK = null; @ObjectHolder(RS.ID + ":256k_fluid_storage_block") @@ -79,9 +59,15 @@ public final class RSBlocks { @ObjectHolder(RS.ID + ":creative_fluid_storage_block") public static final FluidStorageBlock CREATIVE_FLUID_STORAGE_BLOCK = null; - @ObjectHolder(RS.ID + ":external_storage") - public static final ExternalStorageBlock EXTERNAL_STORAGE = null; - + public static final BlockDestructor DESTRUCTOR = new BlockDestructor(); + public static final BlockConstructor CONSTRUCTOR = new BlockConstructor(); + public static final BlockInterface INTERFACE = new BlockInterface(); + public static final BlockCraftingMonitor CRAFTING_MONITOR = new BlockCraftingMonitor(); + public static final BlockWirelessTransmitter WIRELESS_TRANSMITTER = new BlockWirelessTransmitter(); + public static final BlockCrafter CRAFTER = new BlockCrafter(); + public static final BlockFluidInterface FLUID_INTERFACE = new BlockFluidInterface(); + public static final BlockDiskManipulator DISK_MANIPULATOR = new BlockDiskManipulator(); + public static final BlockSecurityManager SECURITY_MANAGER = new BlockSecurityManager(); public static final BlockStorageMonitor STORAGE_MONITOR = new BlockStorageMonitor(); public static final BlockPortableGrid PORTABLE_GRID = new BlockPortableGrid(); public static final BlockCrafterManager CRAFTER_MANAGER = new BlockCrafterManager(); diff --git a/src/main/java/com/raoulvdberge/refinedstorage/RSContainers.java b/src/main/java/com/raoulvdberge/refinedstorage/RSContainers.java index 246c85001..bcb6a1a41 100644 --- a/src/main/java/com/raoulvdberge/refinedstorage/RSContainers.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/RSContainers.java @@ -5,14 +5,30 @@ import net.minecraft.inventory.container.ContainerType; import net.minecraftforge.registries.ObjectHolder; public final class RSContainers { - //@ObjectHolder(RS.ID + ":constructor") - public static final ContainerType CONSTRUCTOR = null; - @ObjectHolder(RS.ID + ":controller") public static final ContainerType CONTROLLER = null; - @ObjectHolder(RS.ID + ":grid") public static final ContainerType GRID = null; + @ObjectHolder(RS.ID + ":detector") + public static final ContainerType DETECTOR = null; + @ObjectHolder(RS.ID + ":exporter") + public static final ContainerType EXPORTER = null; + @ObjectHolder(RS.ID + ":external_storage") + public static final ContainerType EXTERNAL_STORAGE = null; + @ObjectHolder(RS.ID + ":filter") + public static final ContainerType FILTER = null; + @ObjectHolder(RS.ID + ":importer") + public static final ContainerType IMPORTER = null; + @ObjectHolder(RS.ID + ":network_transmitter") + public static final ContainerType NETWORK_TRANSMITTER = null; + @ObjectHolder(RS.ID + ":relay") + public static final ContainerType RELAY = null; + @ObjectHolder(RS.ID + ":disk_drive") + public static final ContainerType DISK_DRIVE = null; + @ObjectHolder(RS.ID + ":storage_block") + public static final ContainerType STORAGE_BLOCK = null; + @ObjectHolder(RS.ID + ":fluid_storage_block") + public static final ContainerType FLUID_STORAGE_BLOCK = null; //@ObjectHolder(RS.ID + ":crafter") public static final ContainerType CRAFTER = null; @@ -22,47 +38,16 @@ public final class RSContainers { public static final ContainerType CRAFTING_MONITOR = null; //@ObjectHolder(RS.ID + ":destructor") public static final ContainerType DESTRUCTOR = null; - //@ObjectHolder(RS.ID + ":detector") - public static final ContainerType DETECTOR = null; - + //@ObjectHolder(RS.ID + ":constructor") + public static final ContainerType CONSTRUCTOR = null; //@ObjectHolder(RS.ID + ":disk_manipulator") public static final ContainerType DISK_MANIPULATOR = null; - - @ObjectHolder(RS.ID + ":exporter") - public static final ContainerType EXPORTER = null; - - @ObjectHolder(RS.ID + ":external_storage") - public static final ContainerType EXTERNAL_STORAGE = null; - - @ObjectHolder(RS.ID + ":filter") - public static final ContainerType FILTER = null; - //@ObjectHolder(RS.ID + ":fluid_interface") public static final ContainerType FLUID_INTERFACE = null; - - @ObjectHolder(RS.ID + ":importer") - public static final ContainerType IMPORTER = null; - //@ObjectHolder(RS.ID + ":interface") public static final ContainerType INTERFACE = null; - - @ObjectHolder(RS.ID + ":network_transmitter") - public static final ContainerType NETWORK_TRANSMITTER = null; - - @ObjectHolder(RS.ID + ":relay") - public static final ContainerType RELAY = null; - //@ObjectHolder(RS.ID + ":security_manager") public static final ContainerType SECURITY_MANAGER = null; - - @ObjectHolder(RS.ID + ":disk_drive") - public static final ContainerType DISK_DRIVE = null; - - @ObjectHolder(RS.ID + ":storage_block") - public static final ContainerType STORAGE_BLOCK = null; - @ObjectHolder(RS.ID + ":fluid_storage_block") - public static final ContainerType FLUID_STORAGE_BLOCK = null; - //@ObjectHolder(RS.ID + ":storage_monitor") public static final ContainerType STORAGE_MONITOR = null; //@ObjectHolder(RS.ID + ":wireless_transmitter") diff --git a/src/main/java/com/raoulvdberge/refinedstorage/RSOldConfig.java b/src/main/java/com/raoulvdberge/refinedstorage/RSOldConfig.java index b69d25267..d62f841a2 100644 --- a/src/main/java/com/raoulvdberge/refinedstorage/RSOldConfig.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/RSOldConfig.java @@ -8,7 +8,6 @@ public class RSOldConfig { public int craftingMonitorUsage; public int crafterManagerUsage; public int destructorUsage; - public int detectorUsage; public int interfaceUsage; public int fluidInterfaceUsage; public int wirelessTransmitterUsage; @@ -76,7 +75,6 @@ public class RSOldConfig { craftingMonitorUsage = config.getInt("craftingMonitor", ENERGY, 2, 0, Integer.MAX_VALUE, "The energy used by Crafting Monitors"); crafterManagerUsage = config.getInt("crafterManager", ENERGY, 4, 0, Integer.MAX_VALUE, "The energy used by Crafter Managers"); destructorUsage = config.getInt("destructor", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Destructors"); - detectorUsage = config.getInt("detector", ENERGY, 2, 0, Integer.MAX_VALUE, "The energy used by Detectors"); interfaceUsage = config.getInt("interface", ENERGY, 3, 0, Integer.MAX_VALUE, "The energy used by Interfaces"); fluidInterfaceUsage = config.getInt("fluidInterface", ENERGY, 3, 0, Integer.MAX_VALUE, "The energy used by Fluid Interfaces"); wirelessTransmitterUsage = config.getInt("wirelessTransmitter", ENERGY, 8, 0, Integer.MAX_VALUE, "The energy used by Wireless Transmitters"); diff --git a/src/main/java/com/raoulvdberge/refinedstorage/RSTiles.java b/src/main/java/com/raoulvdberge/refinedstorage/RSTiles.java index 513f988e3..d0b8295e2 100644 --- a/src/main/java/com/raoulvdberge/refinedstorage/RSTiles.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/RSTiles.java @@ -8,41 +8,18 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ObjectHolder; public class RSTiles { - //@ObjectHolder(RS.ID + ":constructor") - public static final TileEntityType CONSTRUCTOR = null; - @ObjectHolder(RS.ID + ":controller") public static final TileEntityType CONTROLLER = null; - @ObjectHolder(RS.ID + ":creative_controller") public static final TileEntityType CREATIVE_CONTROLLER = null; - - //@ObjectHolder(RS.ID + ":crafter") - public static final TileEntityType CRAFTER = null; - //@ObjectHolder(RS.ID + ":crafter_manager") - public static final TileEntityType CRAFTER_MANAGER = null; - //@ObjectHolder(RS.ID + ":crafting_monitor") - public static final TileEntityType CRAFTING_MONITOR = null; - //@ObjectHolder(RS.ID + ":destructor") - public static final TileEntityType DESTRUCTOR = null; - //@ObjectHolder(RS.ID + ":detector") - public static final TileEntityType DETECTOR = null; - + @ObjectHolder(RS.ID + ":detector") + public static final TileEntityType DETECTOR = null; @ObjectHolder(RS.ID + ":disk_drive") public static final TileEntityType DISK_DRIVE = null; - - //@ObjectHolder(RS.ID + ":disk_manipulator") - public static final TileEntityType DISK_MANIPULATOR = null; - @ObjectHolder(RS.ID + ":exporter") public static final TileEntityType EXPORTER = null; - @ObjectHolder(RS.ID + ":external_storage") public static final TileEntityType EXTERNAL_STORAGE = null; - - //@ObjectHolder(RS.ID + ":fluid_interface") - public static final TileEntityType FLUID_INTERFACE = null; - @ObjectHolder(RS.ID + ":grid") public static final TileEntityType GRID = null; @ObjectHolder(RS.ID + ":crafting_grid") @@ -51,31 +28,16 @@ public class RSTiles { public static final TileEntityType PATTERN_GRID = null; @ObjectHolder(RS.ID + ":fluid_grid") public static final TileEntityType FLUID_GRID = null; - @ObjectHolder(RS.ID + ":importer") public static final TileEntityType IMPORTER = null; - - //@ObjectHolder(RS.ID + ":interface") - public static final TileEntityType INTERFACE = null; - @ObjectHolder(RS.ID + ":network_transmitter") public static final TileEntityType NETWORK_TRANSMITTER = null; @ObjectHolder(RS.ID + ":network_receiver") public static final TileEntityType NETWORK_RECEIVER = null; - @ObjectHolder(RS.ID + ":relay") public static final TileEntityType RELAY = null; - - //@ObjectHolder(RS.ID + ":security_manager") - public static final TileEntityType SECURITY_MANAGER = null; - //@ObjectHolder(RS.ID + ":storage_monitor") - public static final TileEntityType STORAGE_MONITOR = null; - //@ObjectHolder(RS.ID + ":wireless_transmitter") - public static final TileEntityType WIRELESS_TRANSMITTER = null; - @ObjectHolder(RS.ID + ":cable") public static final TileEntityType CABLE = null; - @ObjectHolder(RS.ID + ":1k_storage_block") public static final TileEntityType ONE_K_STORAGE_BLOCK = null; @ObjectHolder(RS.ID + ":4k_storage_block") @@ -86,7 +48,6 @@ public class RSTiles { public static final TileEntityType SIXTY_FOUR_K_STORAGE_BLOCK = null; @ObjectHolder(RS.ID + ":creative_storage_block") public static final TileEntityType CREATIVE_STORAGE_BLOCK = null; - @ObjectHolder(RS.ID + ":64k_fluid_storage_block") public static final TileEntityType SIXTY_FOUR_K_FLUID_STORAGE_BLOCK = null; @ObjectHolder(RS.ID + ":256k_fluid_storage_block") @@ -100,4 +61,26 @@ public class RSTiles { //@ObjectHolder(RS.ID + ":portable_grid") public static final TileEntityType PORTABLE_GRID = null; + //@ObjectHolder(RS.ID + ":security_manager") + public static final TileEntityType SECURITY_MANAGER = null; + //@ObjectHolder(RS.ID + ":storage_monitor") + public static final TileEntityType STORAGE_MONITOR = null; + //@ObjectHolder(RS.ID + ":wireless_transmitter") + public static final TileEntityType WIRELESS_TRANSMITTER = null; + //@ObjectHolder(RS.ID + ":interface") + public static final TileEntityType INTERFACE = null; + //@ObjectHolder(RS.ID + ":fluid_interface") + public static final TileEntityType FLUID_INTERFACE = null; + //@ObjectHolder(RS.ID + ":disk_manipulator") + public static final TileEntityType DISK_MANIPULATOR = null; + //@ObjectHolder(RS.ID + ":crafter") + public static final TileEntityType CRAFTER = null; + //@ObjectHolder(RS.ID + ":crafter_manager") + public static final TileEntityType CRAFTER_MANAGER = null; + //@ObjectHolder(RS.ID + ":crafting_monitor") + public static final TileEntityType CRAFTING_MONITOR = null; + //@ObjectHolder(RS.ID + ":destructor") + public static final TileEntityType DESTRUCTOR = null; + //@ObjectHolder(RS.ID + ":constructor") + public static final TileEntityType CONSTRUCTOR = null; } diff --git a/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/node/NetworkNodeDetector.java b/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/node/DetectorNetworkNode.java old mode 100755 new mode 100644 similarity index 93% rename from src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/node/NetworkNodeDetector.java rename to src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/node/DetectorNetworkNode.java index 0ce387cf8..232c28e14 --- a/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/node/NetworkNodeDetector.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/network/node/DetectorNetworkNode.java @@ -4,16 +4,16 @@ import com.raoulvdberge.refinedstorage.RS; import com.raoulvdberge.refinedstorage.RSBlocks; import com.raoulvdberge.refinedstorage.api.network.INetwork; import com.raoulvdberge.refinedstorage.api.util.IComparer; +import com.raoulvdberge.refinedstorage.block.DetectorBlock; import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory; import com.raoulvdberge.refinedstorage.inventory.item.BaseItemHandler; import com.raoulvdberge.refinedstorage.inventory.listener.NetworkNodeFluidInventoryListener; import com.raoulvdberge.refinedstorage.inventory.listener.NetworkNodeInventoryListener; -import com.raoulvdberge.refinedstorage.tile.TileDetector; +import com.raoulvdberge.refinedstorage.tile.DetectorTile; import com.raoulvdberge.refinedstorage.tile.config.IComparable; import com.raoulvdberge.refinedstorage.tile.config.IType; import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode; import com.raoulvdberge.refinedstorage.util.StackUtils; -import com.raoulvdberge.refinedstorage.util.WorldUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ResourceLocation; @@ -23,7 +23,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; -public class NetworkNodeDetector extends NetworkNode implements IComparable, IType { +public class DetectorNetworkNode extends NetworkNode implements IComparable, IType { public static final ResourceLocation ID = new ResourceLocation(RS.ID, "detector"); private static final int SPEED = 5; @@ -49,13 +49,13 @@ public class NetworkNodeDetector extends NetworkNode implements IComparable, ITy private boolean powered = false; private boolean wasPowered; - public NetworkNodeDetector(World world, BlockPos pos) { + public DetectorNetworkNode(World world, BlockPos pos) { super(world, pos); } @Override public int getEnergyUsage() { - return RS.INSTANCE.config.detectorUsage; + return RS.SERVER_CONFIG.getDetector().getUsage(); } @Override @@ -65,9 +65,8 @@ public class NetworkNodeDetector extends NetworkNode implements IComparable, ITy if (powered != wasPowered) { wasPowered = powered; + world.setBlockState(pos, world.getBlockState(pos).with(DetectorBlock.POWERED, powered)); world.notifyNeighborsOfStateChange(pos, RSBlocks.DETECTOR); - - WorldUtils.updateBlock(world, pos); } if (canUpdate() && ticks % SPEED == 0) { @@ -222,7 +221,7 @@ public class NetworkNodeDetector extends NetworkNode implements IComparable, ITy @Override public int getType() { - return world.isRemote ? TileDetector.TYPE.getValue() : type; + return world.isRemote ? DetectorTile.TYPE.getValue() : type; } @Override diff --git a/src/main/java/com/raoulvdberge/refinedstorage/block/BlockDetector.java b/src/main/java/com/raoulvdberge/refinedstorage/block/BlockDetector.java deleted file mode 100755 index e37acd3b2..000000000 --- a/src/main/java/com/raoulvdberge/refinedstorage/block/BlockDetector.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.raoulvdberge.refinedstorage.block; - -import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder; -import com.raoulvdberge.refinedstorage.tile.TileDetector; -import net.minecraft.state.BooleanProperty; - -public class BlockDetector extends BlockNode { - private static final BooleanProperty POWERED = BooleanProperty.create("powered"); - - public BlockDetector() { - super(BlockInfoBuilder.forId("detector").tileEntity(TileDetector::new).create()); - } - - /* - @Override - @OnlyIn(Dist.CLIENT) - public void registerModels(IModelRegistration modelRegistration) { - modelRegistration.setModel(this, 0, new ModelResourceLocation(info.getId(), "inventory")); - - modelRegistration.addBakedModelOverride(info.getId(), base -> new BakedModelFullbright(base, RS.ID + ":blocks/detector/cutouts/on")); - } - - @Override - protected BlockStateContainer createBlockState() { - return createBlockStateBuilder() - .add(POWERED) - .build(); - } - - @Override - public BlockState getActualState(BlockState state, IBlockAccess world, BlockPos pos) { - return super.getActualState(state, world, pos) - .withProperty(POWERED, ((TileDetector) world.getTileEntity(pos)).getNode().isPowered()); - } - - @Override - public List getCollisions(TileEntity tile, BlockState state) { - return Collections.singletonList(ConstantsDetector.COLLISION); - } - - @Override - public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, EnumHand hand, Direction side, float hitX, float hitY, float hitZ) { - return openNetworkGui(RSGui.DETECTOR, player, world, pos, side); - } - - @Override - @SuppressWarnings("deprecation") - public int getWeakPower(BlockState state, IBlockAccess world, BlockPos pos, Direction side) { - TileEntity tile = world.getTileEntity(pos); - - return (tile instanceof TileDetector && ((TileDetector) tile).getNode().isPowered()) ? 15 : 0; - } - - @Override - @SuppressWarnings("deprecation") - public boolean canProvidePower(BlockState state) { - return true; - } - - @Override - @SuppressWarnings("deprecation") - public boolean isOpaqueCube(BlockState state) { - return false; - } - - @Override - @SuppressWarnings("deprecation") - public boolean isFullCube(BlockState state) { - return false; - } - - @Override - public BlockRenderLayer getRenderLayer() { - return BlockRenderLayer.CUTOUT; - } - - @Override - @SuppressWarnings("deprecation") - public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, BlockState state, BlockPos pos, Direction face) { - return BlockFaceShape.UNDEFINED; - }*/ -} diff --git a/src/main/java/com/raoulvdberge/refinedstorage/block/DetectorBlock.java b/src/main/java/com/raoulvdberge/refinedstorage/block/DetectorBlock.java new file mode 100644 index 000000000..8895cf540 --- /dev/null +++ b/src/main/java/com/raoulvdberge/refinedstorage/block/DetectorBlock.java @@ -0,0 +1,98 @@ +package com.raoulvdberge.refinedstorage.block; + +import com.raoulvdberge.refinedstorage.RS; +import com.raoulvdberge.refinedstorage.container.DetectorContainer; +import com.raoulvdberge.refinedstorage.container.factory.PositionalTileContainerProvider; +import com.raoulvdberge.refinedstorage.tile.DetectorTile; +import com.raoulvdberge.refinedstorage.util.BlockUtils; +import com.raoulvdberge.refinedstorage.util.NetworkUtils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.state.BooleanProperty; +import net.minecraft.state.StateContainer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.Direction; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; +import net.minecraftforge.fml.network.NetworkHooks; + +import javax.annotation.Nullable; + +public class DetectorBlock extends NodeBlock { + public static final BooleanProperty POWERED = BooleanProperty.create("powered"); + + private static final VoxelShape SHAPE = makeCuboidShape(0, 0, 0, 16, 5, 16); + + public DetectorBlock() { + super(BlockUtils.DEFAULT_ROCK_PROPERTIES); + + this.setRegistryName(RS.ID, "detector"); + this.setDefaultState(this.getStateContainer().getBaseState().with(POWERED, false)); + } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + + builder.add(POWERED); + } + + @Override + @SuppressWarnings("deprecation") + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + return SHAPE; + } + + @Override + public BlockRenderLayer getRenderLayer() { + return BlockRenderLayer.CUTOUT; + } + + + @Override + @SuppressWarnings("deprecation") + public boolean canProvidePower(BlockState state) { + return true; + } + + @Override + @SuppressWarnings("deprecation") + public int getWeakPower(BlockState state, IBlockReader world, BlockPos pos, Direction side) { + TileEntity tile = world.getTileEntity(pos); + + return (tile instanceof DetectorTile && ((DetectorTile) tile).getNode().isPowered()) ? 15 : 0; + } + + @Override + @SuppressWarnings("deprecation") + public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + if (!world.isRemote) { + return NetworkUtils.attemptModify(world, pos, hit.getFace(), player, () -> NetworkHooks.openGui( + (ServerPlayerEntity) player, + new PositionalTileContainerProvider( + new TranslationTextComponent("gui.refinedstorage.detector"), + (tile, windowId, inventory, p) -> new DetectorContainer(tile, player, windowId), + pos + ), + pos + )); + } + + return true; + } + + @Nullable + @Override + public TileEntity createTileEntity(BlockState state, IBlockReader world) { + return new DetectorTile(); + } +} diff --git a/src/main/java/com/raoulvdberge/refinedstorage/config/ServerConfig.java b/src/main/java/com/raoulvdberge/refinedstorage/config/ServerConfig.java index 1096e4355..6d6845da8 100644 --- a/src/main/java/com/raoulvdberge/refinedstorage/config/ServerConfig.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/config/ServerConfig.java @@ -18,6 +18,7 @@ public class ServerConfig { private NetworkReceiver networkReceiver; private NetworkTransmitter networkTransmitter; private Relay relay; + private Detector detector; private Upgrades upgrades; public ServerConfig() { @@ -33,6 +34,7 @@ public class ServerConfig { networkReceiver = new NetworkReceiver(); networkTransmitter = new NetworkTransmitter(); relay = new Relay(); + detector = new Detector(); upgrades = new Upgrades(); spec = builder.build(); @@ -90,6 +92,10 @@ public class ServerConfig { return relay; } + public Detector getDetector() { + return detector; + } + public ForgeConfigSpec getSpec() { return spec; } @@ -433,4 +439,20 @@ public class ServerConfig { return usage.get(); } } + + public class Detector { + private final ForgeConfigSpec.IntValue usage; + + public Detector() { + builder.push("detector"); + + usage = builder.comment("The energy used by the Detector").defineInRange("usage", 2, 0, Integer.MAX_VALUE); + + builder.pop(); + } + + public int getUsage() { + return usage.get(); + } + } } diff --git a/src/main/java/com/raoulvdberge/refinedstorage/container/DetectorContainer.java b/src/main/java/com/raoulvdberge/refinedstorage/container/DetectorContainer.java index 55742a190..c558f32dd 100644 --- a/src/main/java/com/raoulvdberge/refinedstorage/container/DetectorContainer.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/container/DetectorContainer.java @@ -3,12 +3,12 @@ package com.raoulvdberge.refinedstorage.container; import com.raoulvdberge.refinedstorage.RSContainers; import com.raoulvdberge.refinedstorage.container.slot.filter.FilterSlot; import com.raoulvdberge.refinedstorage.container.slot.filter.FluidFilterSlot; -import com.raoulvdberge.refinedstorage.tile.TileDetector; +import com.raoulvdberge.refinedstorage.tile.DetectorTile; import com.raoulvdberge.refinedstorage.tile.config.IType; import net.minecraft.entity.player.PlayerEntity; public class DetectorContainer extends BaseContainer { - public DetectorContainer(TileDetector detector, PlayerEntity player, int windowId) { + public DetectorContainer(DetectorTile detector, PlayerEntity player, int windowId) { super(RSContainers.DETECTOR, detector, player, windowId); addSlot(new FilterSlot(detector.getNode().getItemFilters(), 0, 107, 20).setEnableHandler(() -> detector.getNode().getType() == IType.ITEMS)); diff --git a/src/main/java/com/raoulvdberge/refinedstorage/render/constants/ConstantsDetector.java b/src/main/java/com/raoulvdberge/refinedstorage/render/constants/ConstantsDetector.java deleted file mode 100644 index 2c8bc9766..000000000 --- a/src/main/java/com/raoulvdberge/refinedstorage/render/constants/ConstantsDetector.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.raoulvdberge.refinedstorage.render.constants; - -import com.raoulvdberge.refinedstorage.render.collision.CollisionGroup; -import net.minecraft.util.math.AxisAlignedBB; - -public final class ConstantsDetector { - public static final CollisionGroup COLLISION = new CollisionGroup().addItem(new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 5D / 16D, 1.0D)); -} diff --git a/src/main/java/com/raoulvdberge/refinedstorage/screen/DetectorScreen.java b/src/main/java/com/raoulvdberge/refinedstorage/screen/DetectorScreen.java new file mode 100644 index 000000000..c67b6d424 --- /dev/null +++ b/src/main/java/com/raoulvdberge/refinedstorage/screen/DetectorScreen.java @@ -0,0 +1,82 @@ +package com.raoulvdberge.refinedstorage.screen; + +import com.raoulvdberge.refinedstorage.RS; +import com.raoulvdberge.refinedstorage.container.DetectorContainer; +import com.raoulvdberge.refinedstorage.screen.widget.sidebutton.DetectorModeSideButton; +import com.raoulvdberge.refinedstorage.screen.widget.sidebutton.ExactModeSideButton; +import com.raoulvdberge.refinedstorage.screen.widget.sidebutton.TypeSideButton; +import com.raoulvdberge.refinedstorage.tile.DetectorTile; +import com.raoulvdberge.refinedstorage.tile.data.TileDataManager; +import net.minecraft.client.gui.widget.TextFieldWidget; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; +import org.lwjgl.glfw.GLFW; + +public class DetectorScreen extends BaseScreen { + private TextFieldWidget amountField; + + public DetectorScreen(DetectorContainer container, PlayerInventory inventory, ITextComponent title) { + super(container, 176, 137, inventory, title); + } + + @Override + public void onPostInit(int x, int y) { + addSideButton(new TypeSideButton(this, DetectorTile.TYPE)); + + addSideButton(new DetectorModeSideButton(this)); + + addSideButton(new ExactModeSideButton(this, DetectorTile.COMPARE)); + + amountField = new TextFieldWidget(font, x + 41 + 1, y + 23 + 1, 50, font.FONT_HEIGHT, ""); + amountField.setText(String.valueOf(DetectorTile.AMOUNT.getValue())); + amountField.setEnableBackgroundDrawing(false); + amountField.setVisible(true); + amountField.setCanLoseFocus(true); + amountField.setFocused2(false); + amountField.setTextColor(16777215); + amountField.func_212954_a(value -> { + try { + int result = Integer.parseInt(value); + + TileDataManager.setParameter(DetectorTile.AMOUNT, result); + } catch (NumberFormatException e) { + // NO OP + } + }); + + addButton(amountField); + } + + @Override + public void tick(int x, int y) { + } + + @Override + public void renderBackground(int x, int y, int mouseX, int mouseY) { + bindTexture(RS.ID, "gui/detector.png"); + + blit(x, y, 0, 0, xSize, ySize); + } + + @Override + public void renderForeground(int mouseX, int mouseY) { + renderString(7, 7, title.getFormattedText()); + renderString(7, 43, I18n.format("container.inventory")); + } + + @Override + public boolean keyPressed(int key, int scanCode, int modifiers) { + if (key == GLFW.GLFW_KEY_ESCAPE) { + minecraft.player.closeScreen(); + + return true; + } + + if (amountField.keyPressed(key, scanCode, modifiers) || amountField.func_212955_f()) { + return true; + } + + return super.keyPressed(key, scanCode, modifiers); + } +} diff --git a/src/main/java/com/raoulvdberge/refinedstorage/screen/GuiDetector.java b/src/main/java/com/raoulvdberge/refinedstorage/screen/GuiDetector.java deleted file mode 100644 index 7ecb41ab0..000000000 --- a/src/main/java/com/raoulvdberge/refinedstorage/screen/GuiDetector.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.raoulvdberge.refinedstorage.screen; - -import com.raoulvdberge.refinedstorage.RS; -import com.raoulvdberge.refinedstorage.container.DetectorContainer; -import com.raoulvdberge.refinedstorage.screen.widget.sidebutton.DetectorModeSideButton; -import com.raoulvdberge.refinedstorage.screen.widget.sidebutton.ExactModeSideButton; -import com.raoulvdberge.refinedstorage.screen.widget.sidebutton.TypeSideButton; -import com.raoulvdberge.refinedstorage.tile.TileDetector; -import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.PlayerInventory; - -public class GuiDetector extends BaseScreen { - private TextFieldWidget amount; - - public GuiDetector(DetectorContainer container, PlayerInventory inventory) { - super(container, 176, 137, inventory, null); - } - - @Override - public void onPostInit(int x, int y) { - addSideButton(new TypeSideButton(this, TileDetector.TYPE)); - - addSideButton(new DetectorModeSideButton(this)); - - addSideButton(new ExactModeSideButton(this, TileDetector.COMPARE)); - - amount = new TextFieldWidget(font, x + 41 + 1, y + 23 + 1, 50, font.FONT_HEIGHT, ""); - amount.setText(String.valueOf(TileDetector.AMOUNT.getValue())); - amount.setEnableBackgroundDrawing(false); - amount.setVisible(true); - amount.setTextColor(16777215); - amount.setCanLoseFocus(true); - amount.setFocused2(false); - } - - @Override - public void tick(int x, int y) { - } - - @Override - public void renderBackground(int x, int y, int mouseX, int mouseY) { - bindTexture(RS.ID, "gui/detector.png"); - - blit(x, y, 0, 0, xSize, ySize); - - amount.renderButton(0, 0, 0); - } - - @Override - public void renderForeground(int mouseX, int mouseY) { - renderString(7, 7, I18n.format("gui.refinedstorage:detector")); - renderString(7, 43, I18n.format("container.inventory")); - } - - /* TODO - @Override - protected void keyTyped(char character, int keyCode) throws IOException { - if (!checkHotbarKeys(keyCode) && amount.textboxKeyTyped(character, keyCode)) { - Integer result = Ints.tryParse(amount.getText()); - - if (result != null) { - TileDataManager.setParameter(TileDetector.AMOUNT, result); - } - } else { - super.keyTyped(character, keyCode); - } - } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { - super.mouseClicked(mouseX, mouseY, mouseButton); - - amount.mouseClicked(mouseX, mouseY, mouseButton); - }*/ - - public TextFieldWidget getAmount() { - return amount; - } -} diff --git a/src/main/java/com/raoulvdberge/refinedstorage/screen/widget/sidebutton/DetectorModeSideButton.java b/src/main/java/com/raoulvdberge/refinedstorage/screen/widget/sidebutton/DetectorModeSideButton.java index 2e23c5178..613566227 100644 --- a/src/main/java/com/raoulvdberge/refinedstorage/screen/widget/sidebutton/DetectorModeSideButton.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/screen/widget/sidebutton/DetectorModeSideButton.java @@ -1,8 +1,8 @@ package com.raoulvdberge.refinedstorage.screen.widget.sidebutton; -import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDetector; +import com.raoulvdberge.refinedstorage.apiimpl.network.node.DetectorNetworkNode; import com.raoulvdberge.refinedstorage.screen.BaseScreen; -import com.raoulvdberge.refinedstorage.tile.TileDetector; +import com.raoulvdberge.refinedstorage.tile.DetectorTile; import com.raoulvdberge.refinedstorage.tile.data.TileDataManager; import net.minecraft.client.resources.I18n; import net.minecraft.util.text.TextFormatting; @@ -14,26 +14,26 @@ public class DetectorModeSideButton extends SideButton { @Override public String getTooltip() { - return I18n.format("sidebutton.refinedstorage.detector.mode") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage.detector.mode." + TileDetector.MODE.getValue()); + return I18n.format("sidebutton.refinedstorage.detector.mode") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage.detector.mode." + DetectorTile.MODE.getValue()); } @Override protected void renderButtonIcon(int x, int y) { - screen.blit(x, y, TileDetector.MODE.getValue() * 16, 176, 16, 16); + screen.blit(x, y, DetectorTile.MODE.getValue() * 16, 176, 16, 16); } @Override public void onPress() { - int mode = TileDetector.MODE.getValue(); + int mode = DetectorTile.MODE.getValue(); - if (mode == NetworkNodeDetector.MODE_EQUAL) { - mode = NetworkNodeDetector.MODE_ABOVE; - } else if (mode == NetworkNodeDetector.MODE_ABOVE) { - mode = NetworkNodeDetector.MODE_UNDER; - } else if (mode == NetworkNodeDetector.MODE_UNDER) { - mode = NetworkNodeDetector.MODE_EQUAL; + if (mode == DetectorNetworkNode.MODE_EQUAL) { + mode = DetectorNetworkNode.MODE_ABOVE; + } else if (mode == DetectorNetworkNode.MODE_ABOVE) { + mode = DetectorNetworkNode.MODE_UNDER; + } else if (mode == DetectorNetworkNode.MODE_UNDER) { + mode = DetectorNetworkNode.MODE_EQUAL; } - TileDataManager.setParameter(TileDetector.MODE, mode); + TileDataManager.setParameter(DetectorTile.MODE, mode); } } diff --git a/src/main/java/com/raoulvdberge/refinedstorage/tile/TileDetector.java b/src/main/java/com/raoulvdberge/refinedstorage/tile/DetectorTile.java old mode 100755 new mode 100644 similarity index 63% rename from src/main/java/com/raoulvdberge/refinedstorage/tile/TileDetector.java rename to src/main/java/com/raoulvdberge/refinedstorage/tile/DetectorTile.java index ab6026491..e7b7e95ee --- a/src/main/java/com/raoulvdberge/refinedstorage/tile/TileDetector.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/tile/DetectorTile.java @@ -1,9 +1,7 @@ package com.raoulvdberge.refinedstorage.tile; import com.raoulvdberge.refinedstorage.RSTiles; -import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDetector; -import com.raoulvdberge.refinedstorage.screen.BaseScreen; -import com.raoulvdberge.refinedstorage.screen.GuiDetector; +import com.raoulvdberge.refinedstorage.apiimpl.network.node.DetectorNetworkNode; import com.raoulvdberge.refinedstorage.tile.config.IComparable; import com.raoulvdberge.refinedstorage.tile.config.IType; import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter; @@ -14,25 +12,25 @@ import net.minecraft.world.World; import javax.annotation.Nonnull; -public class TileDetector extends NetworkNodeTile { - private static final String NBT_POWERED = "Powered"; - - public static final TileDataParameter COMPARE = IComparable.createParameter(); - public static final TileDataParameter TYPE = IType.createParameter(); - public static final TileDataParameter MODE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getMode(), (t, v) -> { - if (v == NetworkNodeDetector.MODE_UNDER || v == NetworkNodeDetector.MODE_EQUAL || v == NetworkNodeDetector.MODE_ABOVE) { +public class DetectorTile extends NetworkNodeTile { + public static final TileDataParameter COMPARE = IComparable.createParameter(); + public static final TileDataParameter TYPE = IType.createParameter(); + public static final TileDataParameter MODE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getMode(), (t, v) -> { + if (v == DetectorNetworkNode.MODE_UNDER || v == DetectorNetworkNode.MODE_EQUAL || v == DetectorNetworkNode.MODE_ABOVE) { t.getNode().setMode(v); t.getNode().markDirty(); } }); - public static final TileDataParameter AMOUNT = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getAmount(), (t, v) -> { + public static final TileDataParameter AMOUNT = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getAmount(), (t, v) -> { t.getNode().setAmount(v); t.getNode().markDirty(); - }, (initial, p) -> BaseScreen.executeLater(GuiDetector.class, detector -> detector.getAmount().setText(String.valueOf(p)))); + }); - public TileDetector() { + private static final String NBT_POWERED = "Powered"; + + public DetectorTile() { super(RSTiles.DETECTOR); - + dataManager.addWatchedParameter(COMPARE); dataManager.addWatchedParameter(TYPE); dataManager.addWatchedParameter(MODE); @@ -57,7 +55,7 @@ public class TileDetector extends NetworkNodeTile { @Override @Nonnull - public NetworkNodeDetector createNode(World world, BlockPos pos) { - return new NetworkNodeDetector(world, pos); + public DetectorNetworkNode createNode(World world, BlockPos pos) { + return new DetectorNetworkNode(world, pos); } } diff --git a/src/main/java/com/raoulvdberge/refinedstorage/tile/NetworkNodeTile.java b/src/main/java/com/raoulvdberge/refinedstorage/tile/NetworkNodeTile.java index 5efac2419..b1a68624f 100644 --- a/src/main/java/com/raoulvdberge/refinedstorage/tile/NetworkNodeTile.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/tile/NetworkNodeTile.java @@ -25,11 +25,10 @@ public abstract class NetworkNodeTile extends BaseTile im public static final TileDataParameter REDSTONE_MODE = RedstoneMode.createParameter(); private N clientNode; + private N removedNode; private LazyOptional> networkNodeProxy = LazyOptional.of(() -> this); - private N removedNode; - public NetworkNodeTile(TileEntityType tileType) { super(tileType); diff --git a/src/main/resources/assets/refinedstorage/blockstates/detector.json b/src/main/resources/assets/refinedstorage/blockstates/detector.json index bbd687ec5..f5b2a3644 100755 --- a/src/main/resources/assets/refinedstorage/blockstates/detector.json +++ b/src/main/resources/assets/refinedstorage/blockstates/detector.json @@ -1,29 +1,10 @@ { - "forge_marker": 1, - "defaults": { - "textures": { - "side": "refinedstorage:blocks/detector/side", - "bottom": "refinedstorage:blocks/detector/bottom", - "top": "refinedstorage:blocks/detector/top", - "torch": "refinedstorage:blocks/detector/cutouts/off", - "particle": "refinedstorage:blocks/detector/side" - }, - "model": "refinedstorage:detector" - }, "variants": { - "inventory": [ - { - "transform": "forge:default-block" - } - ], - "powered": { - "true": { - "textures": { - "torch": "refinedstorage:blocks/detector/cutouts/on" - } - }, - "false": { - } + "powered=true": { + "model": "refinedstorage:block/detector_on" + }, + "powered=false": { + "model": "refinedstorage:block/detector_off" } } } \ No newline at end of file diff --git a/src/main/resources/assets/refinedstorage/lang/en_us.json b/src/main/resources/assets/refinedstorage/lang/en_us.json index b6f45ef7e..e0c7a2941 100644 --- a/src/main/resources/assets/refinedstorage/lang/en_us.json +++ b/src/main/resources/assets/refinedstorage/lang/en_us.json @@ -23,7 +23,7 @@ "gui.refinedstorage.external_storage": "External Storage", "gui.refinedstorage.importer": "Importer", "gui.refinedstorage.exporter": "Exporter", - "gui.refinedstorage:detector": "Detector", + "gui.refinedstorage.detector": "Detector", "gui.refinedstorage:destructor": "Destructor", "gui.refinedstorage:constructor": "Constructor", "gui.refinedstorage.relay": "Relay", @@ -185,7 +185,7 @@ "block.refinedstorage.external_storage": "External Storage", "block.refinedstorage.importer": "Importer", "block.refinedstorage.exporter": "Exporter", - "block.refinedstorage:detector": "Detector", + "block.refinedstorage.detector": "Detector", "block.refinedstorage.machine_casing": "Machine Casing", "block.refinedstorage:destructor": "Destructor", "block.refinedstorage:constructor": "Constructor", diff --git a/src/main/resources/assets/refinedstorage/models/block/detector.json b/src/main/resources/assets/refinedstorage/models/block/detector.json index 339bc305a..1c1756c6b 100755 --- a/src/main/resources/assets/refinedstorage/models/block/detector.json +++ b/src/main/resources/assets/refinedstorage/models/block/detector.json @@ -1,5 +1,11 @@ { - "credit": "Made with Blockbench", + "parent": "block/cube", + "textures": { + "side": "refinedstorage:block/detector/side", + "bottom": "refinedstorage:block/detector/bottom", + "top": "refinedstorage:block/detector/top", + "particle": "refinedstorage:block/detector/side" + }, "elements": [ { "name": "Handle", diff --git a/src/main/resources/assets/refinedstorage/models/block/detector_off.json b/src/main/resources/assets/refinedstorage/models/block/detector_off.json new file mode 100644 index 000000000..3eb956b11 --- /dev/null +++ b/src/main/resources/assets/refinedstorage/models/block/detector_off.json @@ -0,0 +1,6 @@ +{ + "parent": "refinedstorage:block/detector", + "textures": { + "torch": "refinedstorage:block/detector/cutouts/off" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/refinedstorage/models/block/detector_on.json b/src/main/resources/assets/refinedstorage/models/block/detector_on.json new file mode 100644 index 000000000..3b23b0398 --- /dev/null +++ b/src/main/resources/assets/refinedstorage/models/block/detector_on.json @@ -0,0 +1,6 @@ +{ + "parent": "refinedstorage:block/detector", + "textures": { + "torch": "refinedstorage:block/detector/cutouts/on" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/refinedstorage/models/item/detector.json b/src/main/resources/assets/refinedstorage/models/item/detector.json new file mode 100644 index 000000000..cc4fac834 --- /dev/null +++ b/src/main/resources/assets/refinedstorage/models/item/detector.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/detector_off" +} diff --git a/src/main/resources/data/refinedstorage/loot_tables/blocks/detector.json b/src/main/resources/data/refinedstorage/loot_tables/blocks/detector.json new file mode 100644 index 000000000..3eb6a9d4b --- /dev/null +++ b/src/main/resources/data/refinedstorage/loot_tables/blocks/detector.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:detector" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/refinedstorage/recipes/detector.json b/src/main/resources/data/refinedstorage/recipes/detector.json similarity index 89% rename from src/main/resources/assets/refinedstorage/recipes/detector.json rename to src/main/resources/data/refinedstorage/recipes/detector.json index 08228f35c..505f5df6b 100644 --- a/src/main/resources/assets/refinedstorage/recipes/detector.json +++ b/src/main/resources/data/refinedstorage/recipes/detector.json @@ -19,7 +19,7 @@ "item": "refinedstorage:machine_casing" }, "P": { - "item": "#improved_processor" + "item": "refinedstorage:improved_processor" } }, "result": {