From b05ab4f6ab4ed529168f657eb61ffbdce5564286 Mon Sep 17 00:00:00 2001 From: Curle Date: Fri, 30 Jun 2023 05:50:13 +0100 Subject: [PATCH] Coolant system blocks + logic --- gradle.properties | 4 +- .../data/blockstate/BlockStateProvider.java | 6 +- .../engage/data/lang/EnglishProvider.java | 7 +- .../loot_tables/block/BlockLootTables.java | 2 +- .../data/tags/block/BlockTagProvider.java | 5 +- .../59eb3dbb5f86130e09b3c62d89b9525ee01cf52d | 4 +- .../8a3dba5a712aa838300c907fbeebb5313f8fde21 | 14 +- .../c622617f6fabf890a00b9275cd5f643584a8a2c8 | 4 +- .../resources/assets/engage/lang/en_us.json | 5 + .../loot_tables/blocks/beryllite_ore.json | 2 +- src/main/java/uk/gemwire/engage/Engage.java | 9 + .../block/coolant/CoolantBaseBlock.java | 164 ++++++++++++++++++ .../block/coolant/CoolantMeteringBlock.java | 32 ++++ .../uk/gemwire/engage/client/ClientStuff.java | 45 +++++ .../uk/gemwire/engage/registries/Blocks.java | 33 +++- .../uk/gemwire/engage/registries/Items.java | 4 - 16 files changed, 321 insertions(+), 19 deletions(-) create mode 100644 src/main/java/uk/gemwire/engage/block/coolant/CoolantBaseBlock.java create mode 100644 src/main/java/uk/gemwire/engage/block/coolant/CoolantMeteringBlock.java create mode 100644 src/main/java/uk/gemwire/engage/client/ClientStuff.java diff --git a/gradle.properties b/gradle.properties index fc72051..3dbc612 100644 --- a/gradle.properties +++ b/gradle.properties @@ -48,12 +48,12 @@ mod_name=Engage! # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=MIT # The mod version. See https://semver.org/ -mod_version=0.1.3 +mod_version=1.20-0.1.8 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html mod_group_id=uk.gemwire.engage # The authors of the mod. This is a simple text string that is used for display purposes in the mod list. -mod_authors=Curle, Matyrobbrt +mod_authors=Curle # The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list. mod_description=Placeholder \ No newline at end of file diff --git a/src/data/java/uk/gemwire/engage/data/blockstate/BlockStateProvider.java b/src/data/java/uk/gemwire/engage/data/blockstate/BlockStateProvider.java index bea5706..22f6640 100644 --- a/src/data/java/uk/gemwire/engage/data/blockstate/BlockStateProvider.java +++ b/src/data/java/uk/gemwire/engage/data/blockstate/BlockStateProvider.java @@ -28,6 +28,10 @@ public class BlockStateProvider extends BaseBlockStateProvider fluid, String name) { diff --git a/src/data/java/uk/gemwire/engage/data/loot_tables/block/BlockLootTables.java b/src/data/java/uk/gemwire/engage/data/loot_tables/block/BlockLootTables.java index b66c0b8..de9c776 100644 --- a/src/data/java/uk/gemwire/engage/data/loot_tables/block/BlockLootTables.java +++ b/src/data/java/uk/gemwire/engage/data/loot_tables/block/BlockLootTables.java @@ -7,6 +7,6 @@ public class BlockLootTables extends BaseBlockLootTables { @Override protected void generate() { - add(block -> createOreDrop(block, Items.RAW_BERYLLITE_ITEM.get()), Blocks.BERYLLITE_ORE_BLOCK.get()); + add(block -> createOreDrop(block, Blocks.BERYLLITE_ORE_BLOCK.item().get()), Blocks.BERYLLITE_ORE_BLOCK.block().get()); } } diff --git a/src/data/java/uk/gemwire/engage/data/tags/block/BlockTagProvider.java b/src/data/java/uk/gemwire/engage/data/tags/block/BlockTagProvider.java index 53d2ef5..d629f27 100644 --- a/src/data/java/uk/gemwire/engage/data/tags/block/BlockTagProvider.java +++ b/src/data/java/uk/gemwire/engage/data/tags/block/BlockTagProvider.java @@ -14,7 +14,6 @@ import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import uk.gemwire.engage.data.tags.BaseTagProvider; -import uk.gemwire.engage.data.tags.IntrinsicEngageTagBuilder; import uk.gemwire.engage.registries.Blocks; import javax.annotation.Nullable; @@ -39,7 +38,7 @@ public class BlockTagProvider extends BaseTagProvider { } private void addOres() { - List ores = List.of(Blocks.BERYLLITE_ORE_BLOCK.get()); + List ores = List.of(Blocks.BERYLLITE_ORE_BLOCK.block().get()); for (Block ore : ores) { TagKey itemTag = ItemTags.create(new ResourceLocation("forge:ores/" + ForgeRegistries.ITEMS.getKey(ore.asItem()).getPath())); TagKey blockTag = BlockTags.create(new ResourceLocation("forge:ores/" + ForgeRegistries.BLOCKS.getKey(ore).getPath())); @@ -57,7 +56,7 @@ public class BlockTagProvider extends BaseTagProvider { } private void addHarvests() { - addIronToolBlock(Blocks.BERYLLITE_ORE_BLOCK.get()); + addIronToolBlock(Blocks.BERYLLITE_ORE_BLOCK.block().get()); } private void addIronToolBlock(Block b) { diff --git a/src/data/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d b/src/data/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d index 4afdb83..5e8c8e4 100644 --- a/src/data/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d +++ b/src/data/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d @@ -1,2 +1,2 @@ -// 1.20.1 2023-06-30T03:04:16.2684959 Loot Tables -22933ac7663f965e6fe3c560231b4bcb76c43bfa data/engage/loot_tables/blocks/beryllite_ore.json +// 1.20.1 2023-06-30T04:23:53.8928559 Loot Tables +a0d5edde42a3b8244b925e55faccc1024cdc3f7f data/engage/loot_tables/blocks/beryllite_ore.json diff --git a/src/data/resources/.cache/8a3dba5a712aa838300c907fbeebb5313f8fde21 b/src/data/resources/.cache/8a3dba5a712aa838300c907fbeebb5313f8fde21 index 39757de..1f3943b 100644 --- a/src/data/resources/.cache/8a3dba5a712aa838300c907fbeebb5313f8fde21 +++ b/src/data/resources/.cache/8a3dba5a712aa838300c907fbeebb5313f8fde21 @@ -1,16 +1,28 @@ -// 1.20.1 2023-06-30T03:19:18.0203012 Block state provider: engage +// 1.20.1 2023-06-30T04:23:53.8880249 Block state provider: engage 4af9c861d7727e9ee266ca6e10d9c78c9e4104ba assets/engage/blockstates/antideuterium.json 163e87835e33814e2cad190c2265142f42e18ba9 assets/engage/blockstates/beryllite_ore.json +1bb5f9aee9050675d6749ef05c6308e655a6e4ff assets/engage/blockstates/compressor.json +05bff6a9b886ec537edd7ec3be8dab1b76aedd3a assets/engage/blockstates/coolant_meter.json +e8c835ceab42e3cc09b67e242199e682ab37b47d assets/engage/blockstates/copper_tube.json 38881f2039561be97bb6ea53d31ab9db54875fe5 assets/engage/blockstates/deuterium.json 620e8e678622f335115b86475f40e518de4f9cba assets/engage/blockstates/deuterium_slush.json +84d1165d093a917bb6ff2fed0ae7fc5b6b1e850d assets/engage/blockstates/heat_spreader.json 8c9558de31b0459d70da1d07b499138e6248e38c assets/engage/blockstates/heavy_water.json b58e421acd852f85bc9fee8f837609c8471b90b7 assets/engage/blockstates/propane.json 9b31876df3da1b32ac5639c48cab2ce60cc876ad assets/engage/blockstates/warp_plasma.json f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/antideuterium.json 9356d6cfcd705b3474cec35599e7709fb9f0954a assets/engage/models/block/beryllite_ore.json +cd4466ca9aff6e3cd44febc0ab2d2a5c4a3a45ed assets/engage/models/block/compressor.json +6164628d5c2a9ff67da9c172ffbffb82095851c0 assets/engage/models/block/coolant_meter.json +0021ec0a6a012353fc3294979a59e61e7c5c8f27 assets/engage/models/block/copper_tube.json f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/deuterium.json f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/deuterium_slush.json +d28b133024940edbbfa7aefa2c2f9e10df6bd271 assets/engage/models/block/heat_spreader.json f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/heavy_water.json f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/propane.json f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/warp_plasma.json 45314b766210255f87067ff2a93913e89b07f7ec assets/engage/models/item/beryllite_ore.json +604b3927d83cf0ec2f6df6426b2bc96de529aaa0 assets/engage/models/item/compressor.json +79d38cdc1bf52fa76e83ed1d3e1ba0143b139ba4 assets/engage/models/item/coolant_meter.json +2c86683db4b01a43068ed18c441d144e3f0e7ee1 assets/engage/models/item/copper_tube.json +f4c63d444041821c753f4a476c91a420d658131d assets/engage/models/item/heat_spreader.json diff --git a/src/data/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 b/src/data/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 index bdac8ec..c8f7bb4 100644 --- a/src/data/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 +++ b/src/data/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 @@ -1,2 +1,2 @@ -// 1.20.1 2023-06-30T03:04:16.2694935 Languages: en_us -50b8d51f4adf81848b9ed702904feddb9c747a09 assets/engage/lang/en_us.json +// 1.20.1 2023-06-30T04:23:53.8939811 Languages: en_us +bb27af69172d87ab45300a72da603a98b770a06e assets/engage/lang/en_us.json diff --git a/src/data/resources/assets/engage/lang/en_us.json b/src/data/resources/assets/engage/lang/en_us.json index 8733702..99adf7b 100644 --- a/src/data/resources/assets/engage/lang/en_us.json +++ b/src/data/resources/assets/engage/lang/en_us.json @@ -1,12 +1,17 @@ { "block.engage.antideuterium": "Antideuterium", "block.engage.beryllite_ore": "Beryllite Ore", + "block.engage.compressor": "Sterling Compressor", + "block.engage.coolant_meter": "Capillary Tube", + "block.engage.copper_tube": "Copper Tube", "block.engage.deuterium": "Deuterium", "block.engage.deuterium_slush": "Supercooled Deuterium", + "block.engage.heat_spreader": "Heat Spreader", "block.engage.heavy_water": "Heavy Water", "block.engage.propane": "Propane", "block.engage.warp_plasma": "Warp Plasma", "item.engage.antideuterium_bucket": "Antideuterium Bucket", + "item.engage.beryllite_raw": "Beryllite", "item.engage.deuterium_bucket": "Deuterium Bucket", "item.engage.deuterium_slush_bucket": "Supercooled Deuterium Bucket", "item.engage.heavy_water_bucket": "Heavy Water Bucket", diff --git a/src/data/resources/data/engage/loot_tables/blocks/beryllite_ore.json b/src/data/resources/data/engage/loot_tables/blocks/beryllite_ore.json index 172f0ad..3256fb8 100644 --- a/src/data/resources/data/engage/loot_tables/blocks/beryllite_ore.json +++ b/src/data/resources/data/engage/loot_tables/blocks/beryllite_ore.json @@ -38,7 +38,7 @@ "function": "minecraft:explosion_decay" } ], - "name": "engage:beryllite_raw" + "name": "engage:beryllite_ore" } ] } diff --git a/src/main/java/uk/gemwire/engage/Engage.java b/src/main/java/uk/gemwire/engage/Engage.java index 37ea8f1..fddcf68 100644 --- a/src/main/java/uk/gemwire/engage/Engage.java +++ b/src/main/java/uk/gemwire/engage/Engage.java @@ -41,6 +41,15 @@ import uk.gemwire.engage.registries.fluid.FluidDeferredRegister; * - Warp Gel * = Power port * + * The coolant loop needed to created Supercooled Deuterium consists of: + * - Copper tubes + * - Sterling Compressor + * - Multiple Vents + * - Constriction Valve + * + * The direction of the constriction valve will dictate which side will generate heat, and which side will consume heat. + * The Compressor must be loaded with Propane refrigerant before running, or it will destroy itself. + * */ @Mod("engage") public class Engage { diff --git a/src/main/java/uk/gemwire/engage/block/coolant/CoolantBaseBlock.java b/src/main/java/uk/gemwire/engage/block/coolant/CoolantBaseBlock.java new file mode 100644 index 0000000..045b1dd --- /dev/null +++ b/src/main/java/uk/gemwire/engage/block/coolant/CoolantBaseBlock.java @@ -0,0 +1,164 @@ +package uk.gemwire.engage.block.coolant; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import uk.gemwire.engage.registries.Blocks; + +import java.util.*; + +/** + * Contains a set of methods that allows all Coolant System blocks to check for a completed network on placement. + */ +public class CoolantBaseBlock extends Block { + static Logger LOGGER = LogManager.getLogger(); + + static List VALID_COOLANT_BLOCKS = List.of(Blocks.COMPRESSOR_BLOCK.block().get(), Blocks.COPPER_TUBE_BLOCK.block().get(), Blocks.COOLANT_HEAT_SPREADER_BLOCK.block().get(), Blocks.COOLANT_METERING_BLOCK.block().get()); + + public CoolantBaseBlock(Properties p_49795_) { + super(p_49795_); + } + + @Override + public void onPlace(BlockState prior, Level level, BlockPos pos, BlockState newState, boolean p_60570_) { + if (level.isClientSide) return; + + long startTime = System.currentTimeMillis(); + boolean encounteredMetering = false; + boolean encounteredCompressor = false; + boolean encounteredHeatSpreader = false; + List visitedBlocks = new ArrayList<>(); + // If we happened to choose the path that encounters the metering device before a heat spreader, we need to swap our detection system. + boolean prematureMetering = false; + Direction lastTransitionDirection; + + LOGGER.info("Beginning network discovery"); + + // Get the valid directions we can go. + var dirs = getValidTransitionsFrom(pos, null, level, visitedBlocks); + + LOGGER.info("First step: " + dirs.size() + " valid moves."); + // If we aren't connected to at least 2 other valid blocks, it is impossible to have a completed network. + if (dirs.size() < 2) { + long endTime = System.currentTimeMillis(); + LOGGER.info("Discovery took " + (endTime - startTime) + "ms"); + return; + }; + + // Check the block we're at, first. + if (this == Blocks.COMPRESSOR_BLOCK.block().get()) encounteredCompressor = true; + else if (this == Blocks.COOLANT_METERING_BLOCK.block().get()) { encounteredMetering = true; prematureMetering = true; } + else if (this == Blocks.COOLANT_HEAT_SPREADER_BLOCK.block().get()) encounteredHeatSpreader = true; + + visitedBlocks.add(pos); + BlockPos lastPos = pos; + while (dirs.size() > 1) { + // Traverse the new block + lastTransitionDirection = (Direction) dirs.keySet().toArray()[0]; + BlockPos traversedPos = dirs.get(lastTransitionDirection); + + Block reachedBlock = level.getBlockState(traversedPos).getBlock(); + + LOGGER.info("Traversing through " + lastTransitionDirection + " to " + traversedPos + ", which is a " + getBlockName(reachedBlock)); + visitedBlocks.add(traversedPos); + + // If we reached a metering block for the first time + if (reachedBlock == Blocks.COOLANT_METERING_BLOCK.block().get()) { + if (encounteredMetering) { + LOGGER.info("Two metering devices in the same network! Not valid."); + long endTime = System.currentTimeMillis(); + LOGGER.info("Discovery took " + (endTime - startTime) + "ms"); + return; + } + // And we have already reached a heat spreader: + if (encounteredHeatSpreader) { + // Tell the system to check for another + encounteredHeatSpreader = false; + // Set the metering flag true + encounteredMetering = true; + } else { + // We're searching prematurely! + // We'll search for it at the compressor instead. + prematureMetering = true; + encounteredMetering = true; + } + // The compressor has its own things to check.. + } else if (reachedBlock == Blocks.COMPRESSOR_BLOCK.block().get()) { + if (encounteredCompressor) { + LOGGER.info("Two compressors in the same network! Not valid."); + + long endTime = System.currentTimeMillis(); + LOGGER.info("Discovery took " + (endTime - startTime) + "ms"); + return; + } + + // Premature metering means we should check that a heat spreader is between the metering device and the compressor. + if (prematureMetering) { + if (!encounteredHeatSpreader) { + LOGGER.info("Metering Device and Compressor are too close together! Not valid."); + + long endTime = System.currentTimeMillis(); + LOGGER.info("Discovery took " + (endTime - startTime) + "ms"); + return; + } else { + encounteredCompressor = true; + } + } else { + encounteredCompressor = true; + } + // Heat spreaders may have many, so we just flip the flag to be true if we're just getting to one now. + } else if (reachedBlock == Blocks.COOLANT_HEAT_SPREADER_BLOCK.block().get()) { + if (!encounteredHeatSpreader) encounteredHeatSpreader = true; + } + + dirs = getValidTransitionsFrom(traversedPos, lastTransitionDirection, level, visitedBlocks); + } + + // Try to finalise stuff - we gotta have everything in our network. + // First, check that the last remaining direction takes us into a block we've already visited (the closed loop) + if (visitedBlocks.contains(dirs.values().toArray()[0])) { + // Check for premature mode + if (prematureMetering) { + if (!(encounteredCompressor && encounteredHeatSpreader)) { + LOGGER.info("Two heat spreaders not found in valid configuration!"); + + long endTime = System.currentTimeMillis(); + LOGGER.info("Discovery took " + (endTime - startTime) + "ms"); + return; + } + } else { + if (!(encounteredCompressor && encounteredMetering && encounteredHeatSpreader)) { + LOGGER.info("Not encountered all components of the coolant system!"); + + long endTime = System.currentTimeMillis(); + LOGGER.info("Discovery took " + (endTime - startTime) + "ms"); + return; + } + } + } + + LOGGER.info("Valid coolant loop!"); + long endTime = System.currentTimeMillis(); + LOGGER.info("Discovery took " + (endTime - startTime) + "ms"); + } + + private Map getValidTransitionsFrom(BlockPos pos, Direction incoming, Level level, List visited) { + Map dirs = new HashMap<>(); + for (Direction dir : Direction.values()) { + if (incoming != null && dir == incoming) continue; + BlockPos newPos = pos.relative(dir); + if (visited.contains(newPos)) continue; + if (VALID_COOLANT_BLOCKS.contains(level.getBlockState(newPos).getBlock())) dirs.put(dir, newPos); + } + + return dirs; + } + + private String getBlockName(Block block) { + return block.getName().getContents().toString(); + } +} diff --git a/src/main/java/uk/gemwire/engage/block/coolant/CoolantMeteringBlock.java b/src/main/java/uk/gemwire/engage/block/coolant/CoolantMeteringBlock.java new file mode 100644 index 0000000..f8cbe38 --- /dev/null +++ b/src/main/java/uk/gemwire/engage/block/coolant/CoolantMeteringBlock.java @@ -0,0 +1,32 @@ +package uk.gemwire.engage.block.coolant; + +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.DirectionProperty; + +/** + * A single block used in the Coolant multiblock. + * Is directional, meaning that its facing determines the behaviour of the multiblock. + * Both the front and back must be touching valid tubes in a completed coolant loop. + */ +public class CoolantMeteringBlock extends CoolantBaseBlock { + + public static final DirectionProperty FACING = BlockStateProperties.FACING; + + public CoolantMeteringBlock(Properties p_49795_) { + super(p_49795_); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder p_49915_) { + super.createBlockStateDefinition(p_49915_); + p_49915_.add(FACING); + } + + public BlockState getStateForPlacement(BlockPlaceContext p_55928_) { + return this.defaultBlockState().setValue(FACING, p_55928_.getClickedFace()); + } +} diff --git a/src/main/java/uk/gemwire/engage/client/ClientStuff.java b/src/main/java/uk/gemwire/engage/client/ClientStuff.java new file mode 100644 index 0000000..26a6054 --- /dev/null +++ b/src/main/java/uk/gemwire/engage/client/ClientStuff.java @@ -0,0 +1,45 @@ +package uk.gemwire.engage.client; + +import net.minecraft.client.color.item.ItemColor; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.renderer.RenderType; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.client.event.RegisterColorHandlersEvent; +import net.minecraftforge.client.model.DynamicFluidContainerModel; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; +import uk.gemwire.engage.registries.Fluids; +import uk.gemwire.engage.registries.fluid.FluidDeferredRegister; +import uk.gemwire.engage.registries.fluid.FluidRegistryObject; + +import java.util.List; + +@Mod.EventBusSubscriber(value= Dist.CLIENT, modid="engage", bus= Mod.EventBusSubscriber.Bus.MOD) +public class ClientStuff { + + private static final ItemColor BUCKET_ITEM_COLOR = new DynamicFluidContainerModel.Colors(); + + @SubscribeEvent + public static void registerBucketColorHandler(RegisterColorHandlersEvent.Item event) { + for (FluidRegistryObject fluidRO : Fluids.FLUIDS_REGISTRY.getAllFluids()) { + event.register(BUCKET_ITEM_COLOR, fluidRO.getBucket()); + } + } + + @SubscribeEvent + public static void clientSetup(FMLClientSetupEvent e) { + e.enqueueWork(() -> { + //Set fluids to a translucent render layer + for (FluidRegistryObject fluidRO : List.of(Fluids.HEAVY_WATER_FLUID, Fluids.DEUTERIUM_FLUID, Fluids.DEUTERIUM_SLUSH_FLUID, Fluids.ANTIDEUTERIUM_FLUID, Fluids.WARP_PLASMA_FLUID, Fluids.PROPANE_FLUID)) { + setRenderLayer(RenderType.translucent(), fluidRO); + } + }); + } + public static void setRenderLayer(RenderType type, FluidRegistryObject... fluidROs) { + for (FluidRegistryObject fluidRO : fluidROs) { + ItemBlockRenderTypes.setRenderLayer(fluidRO.getStillFluid(), type); + ItemBlockRenderTypes.setRenderLayer(fluidRO.getFlowingFluid(), type); + } + } +} diff --git a/src/main/java/uk/gemwire/engage/registries/Blocks.java b/src/main/java/uk/gemwire/engage/registries/Blocks.java index 977a122..3019972 100644 --- a/src/main/java/uk/gemwire/engage/registries/Blocks.java +++ b/src/main/java/uk/gemwire/engage/registries/Blocks.java @@ -1,6 +1,8 @@ package uk.gemwire.engage.registries; import net.minecraft.util.valueproviders.UniformInt; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.DropExperienceBlock; import net.minecraft.world.level.block.state.BlockBehaviour; @@ -9,6 +11,11 @@ import net.minecraft.world.level.material.MapColor; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; +import uk.gemwire.engage.block.coolant.CoolantBaseBlock; + +import javax.annotation.Nullable; +import java.rmi.registry.Registry; +import java.util.function.Supplier; /** * A utility class containing the registration and RegistryObjects of all the mods' blocks. @@ -18,6 +25,30 @@ public class Blocks { public static final DeferredRegister BLOCKS_REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCKS, "engage"); // Beryllite Ore, the raw form of Beryllite - the reaction control substance. - public static final RegistryObject BERYLLITE_ORE_BLOCK = BLOCKS_REGISTRY.register("beryllite_ore", () -> new DropExperienceBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE).instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops().strength(3.0F, 3.0F), UniformInt.of(0, 2))); + public static final BlockItemRegistryObject BERYLLITE_ORE_BLOCK = registerBlockItem("beryllite_ore", () -> new DropExperienceBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE).instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops().strength(3.0F, 3.0F), UniformInt.of(0, 2))); + // The Compressor, the source of pressure in a coolant system, and the Propane intake. + public static final BlockItemRegistryObject COMPRESSOR_BLOCK = registerBlockItem("compressor", () -> new CoolantBaseBlock(BlockBehaviour.Properties.of())); + // Copper Tubes, connecting the components of the Coolant System + public static final BlockItemRegistryObject COPPER_TUBE_BLOCK = registerBlockItem("copper_tube", () -> new CoolantBaseBlock(BlockBehaviour.Properties.of())); + // Heat Spreaders, the parts that get hot and cold. + public static final BlockItemRegistryObject COOLANT_HEAT_SPREADER_BLOCK = registerBlockItem("heat_spreader", () -> new CoolantBaseBlock(BlockBehaviour.Properties.of())); + // Metering Device, creates a pressure gradient after the evaporator so that the coolant can condense + public static final BlockItemRegistryObject COOLANT_METERING_BLOCK = registerBlockItem("coolant_meter", () -> new CoolantBaseBlock(BlockBehaviour.Properties.of())); + + static BlockItemRegistryObject registerBlockItem(String name, Supplier block, Item.Properties properties) { + RegistryObject b = BLOCKS_REGISTRY.register(name, block); + RegistryObject i = Items.ITEMS_REGISTRY.register(name, () -> new BlockItem(b.get(), properties)); + return new BlockItemRegistryObject(b, i); + } + + static BlockItemRegistryObject registerBlockItem(String name, Supplier block) { + RegistryObject b = BLOCKS_REGISTRY.register(name, block); + RegistryObject i = Items.ITEMS_REGISTRY.register(name, () -> new BlockItem(b.get(), new Item.Properties())); + return new BlockItemRegistryObject(b, i); + } + + public record BlockItemRegistryObject(RegistryObject block, RegistryObject item) { + + } } diff --git a/src/main/java/uk/gemwire/engage/registries/Items.java b/src/main/java/uk/gemwire/engage/registries/Items.java index 8c874e8..0a8e8fb 100644 --- a/src/main/java/uk/gemwire/engage/registries/Items.java +++ b/src/main/java/uk/gemwire/engage/registries/Items.java @@ -15,8 +15,4 @@ public class Items { // Raw (Unprocessed) Beryllite - the reaction control substance. public static final RegistryObject RAW_BERYLLITE_ITEM = ITEMS_REGISTRY.register("beryllite_raw", () -> new Item(new Item.Properties())); - - // Beryllite Ore BlockItem - public static final RegistryObject BERYLLITE_ORE_ITEM = ITEMS_REGISTRY.register("beryllite_ore", () -> new BlockItem(Blocks.BERYLLITE_ORE_BLOCK.get(), new Item.Properties())); - }