Coolant system blocks + logic
This commit is contained in:
parent
8e1b671c13
commit
b05ab4f6ab
|
@ -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.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=MIT
|
mod_license=MIT
|
||||||
# The mod version. See https://semver.org/
|
# 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.
|
# 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.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
mod_group_id=uk.gemwire.engage
|
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.
|
# 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.
|
# 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
|
mod_description=Placeholder
|
|
@ -28,6 +28,10 @@ public class BlockStateProvider extends BaseBlockStateProvider<BlockModelProvide
|
||||||
@Override
|
@Override
|
||||||
protected void registerStatesAndModels() {
|
protected void registerStatesAndModels() {
|
||||||
registerFluidBlockStates(List.of(Fluids.HEAVY_WATER_FLUID, Fluids.DEUTERIUM_FLUID, Fluids.DEUTERIUM_SLUSH_FLUID, Fluids.ANTIDEUTERIUM_FLUID, Fluids.WARP_PLASMA_FLUID, Fluids.PROPANE_FLUID));
|
registerFluidBlockStates(List.of(Fluids.HEAVY_WATER_FLUID, Fluids.DEUTERIUM_FLUID, Fluids.DEUTERIUM_SLUSH_FLUID, Fluids.ANTIDEUTERIUM_FLUID, Fluids.WARP_PLASMA_FLUID, Fluids.PROPANE_FLUID));
|
||||||
simpleBlockWithItem(Blocks.BERYLLITE_ORE_BLOCK.get(), models().cubeAll(name(Blocks.BERYLLITE_ORE_BLOCK.get()), new ResourceLocation("minecraft:block/coal_ore")));
|
simpleBlockWithItem(Blocks.BERYLLITE_ORE_BLOCK.block().get(), models().cubeAll(name(Blocks.BERYLLITE_ORE_BLOCK.block().get()), new ResourceLocation("minecraft:block/coal_ore")));
|
||||||
|
simpleBlockWithItem(Blocks.COMPRESSOR_BLOCK.block().get(), models().cubeAll(name(Blocks.COMPRESSOR_BLOCK.block().get()), new ResourceLocation("minecraft:block/black_wool")));
|
||||||
|
simpleBlockWithItem(Blocks.COPPER_TUBE_BLOCK.block().get(), models().cubeAll(name(Blocks.COPPER_TUBE_BLOCK.block().get()), new ResourceLocation("minecraft:block/white_wool")));
|
||||||
|
simpleBlockWithItem(Blocks.COOLANT_METERING_BLOCK.block().get(), models().cubeAll(name(Blocks.COOLANT_METERING_BLOCK.block().get()), new ResourceLocation("minecraft:block/yellow_wool")));
|
||||||
|
simpleBlockWithItem(Blocks.COOLANT_HEAT_SPREADER_BLOCK.block().get(), models().cubeAll(name(Blocks.COOLANT_HEAT_SPREADER_BLOCK.block().get()), new ResourceLocation("minecraft:block/blue_wool")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package uk.gemwire.engage.data.lang;
|
||||||
|
|
||||||
import net.minecraft.data.PackOutput;
|
import net.minecraft.data.PackOutput;
|
||||||
import net.minecraftforge.common.data.LanguageProvider;
|
import net.minecraftforge.common.data.LanguageProvider;
|
||||||
|
import uk.gemwire.engage.registries.Blocks;
|
||||||
import uk.gemwire.engage.registries.Fluids;
|
import uk.gemwire.engage.registries.Fluids;
|
||||||
import uk.gemwire.engage.registries.Items;
|
import uk.gemwire.engage.registries.Items;
|
||||||
import uk.gemwire.engage.registries.fluid.FluidRegistryObject;
|
import uk.gemwire.engage.registries.fluid.FluidRegistryObject;
|
||||||
|
@ -14,7 +15,7 @@ public class EnglishProvider extends LanguageProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addTranslations() {
|
protected void addTranslations() {
|
||||||
add(Items.BERYLLITE_ORE_ITEM.get(), "Beryllite Ore");
|
add(Blocks.BERYLLITE_ORE_BLOCK.item().get(), "Beryllite Ore");
|
||||||
add(Items.RAW_BERYLLITE_ITEM.get(), "Beryllite");
|
add(Items.RAW_BERYLLITE_ITEM.get(), "Beryllite");
|
||||||
add(Fluids.HEAVY_WATER_FLUID, "Heavy Water");
|
add(Fluids.HEAVY_WATER_FLUID, "Heavy Water");
|
||||||
add(Fluids.PROPANE_FLUID, "Propane");
|
add(Fluids.PROPANE_FLUID, "Propane");
|
||||||
|
@ -23,6 +24,10 @@ public class EnglishProvider extends LanguageProvider {
|
||||||
add(Fluids.ANTIDEUTERIUM_FLUID, "Antideuterium");
|
add(Fluids.ANTIDEUTERIUM_FLUID, "Antideuterium");
|
||||||
add(Fluids.WARP_PLASMA_FLUID, "Warp Plasma");
|
add(Fluids.WARP_PLASMA_FLUID, "Warp Plasma");
|
||||||
|
|
||||||
|
add(Blocks.COMPRESSOR_BLOCK.item().get(), "Sterling Compressor");
|
||||||
|
add(Blocks.COPPER_TUBE_BLOCK.item().get(), "Copper Tube");
|
||||||
|
add(Blocks.COOLANT_HEAT_SPREADER_BLOCK.item().get(), "Heat Spreader");
|
||||||
|
add(Blocks.COOLANT_METERING_BLOCK.item().get(), "Capillary Tube");
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(FluidRegistryObject<?, ?, ?, ?, ?> fluid, String name) {
|
void add(FluidRegistryObject<?, ?, ?, ?, ?> fluid, String name) {
|
||||||
|
|
|
@ -7,6 +7,6 @@ public class BlockLootTables extends BaseBlockLootTables {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void generate() {
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import net.minecraftforge.common.data.ExistingFileHelper;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
import uk.gemwire.engage.data.tags.BaseTagProvider;
|
import uk.gemwire.engage.data.tags.BaseTagProvider;
|
||||||
import uk.gemwire.engage.data.tags.IntrinsicEngageTagBuilder;
|
|
||||||
import uk.gemwire.engage.registries.Blocks;
|
import uk.gemwire.engage.registries.Blocks;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -39,7 +38,7 @@ public class BlockTagProvider extends BaseTagProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addOres() {
|
private void addOres() {
|
||||||
List<Block> ores = List.of(Blocks.BERYLLITE_ORE_BLOCK.get());
|
List<Block> ores = List.of(Blocks.BERYLLITE_ORE_BLOCK.block().get());
|
||||||
for (Block ore : ores) {
|
for (Block ore : ores) {
|
||||||
TagKey<Item> itemTag = ItemTags.create(new ResourceLocation("forge:ores/" + ForgeRegistries.ITEMS.getKey(ore.asItem()).getPath()));
|
TagKey<Item> itemTag = ItemTags.create(new ResourceLocation("forge:ores/" + ForgeRegistries.ITEMS.getKey(ore.asItem()).getPath()));
|
||||||
TagKey<Block> blockTag = BlockTags.create(new ResourceLocation("forge:ores/" + ForgeRegistries.BLOCKS.getKey(ore).getPath()));
|
TagKey<Block> blockTag = BlockTags.create(new ResourceLocation("forge:ores/" + ForgeRegistries.BLOCKS.getKey(ore).getPath()));
|
||||||
|
@ -57,7 +56,7 @@ public class BlockTagProvider extends BaseTagProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addHarvests() {
|
private void addHarvests() {
|
||||||
addIronToolBlock(Blocks.BERYLLITE_ORE_BLOCK.get());
|
addIronToolBlock(Blocks.BERYLLITE_ORE_BLOCK.block().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIronToolBlock(Block b) {
|
private void addIronToolBlock(Block b) {
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
// 1.20.1 2023-06-30T03:04:16.2684959 Loot Tables
|
// 1.20.1 2023-06-30T04:23:53.8928559 Loot Tables
|
||||||
22933ac7663f965e6fe3c560231b4bcb76c43bfa data/engage/loot_tables/blocks/beryllite_ore.json
|
a0d5edde42a3b8244b925e55faccc1024cdc3f7f data/engage/loot_tables/blocks/beryllite_ore.json
|
||||||
|
|
|
@ -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
|
4af9c861d7727e9ee266ca6e10d9c78c9e4104ba assets/engage/blockstates/antideuterium.json
|
||||||
163e87835e33814e2cad190c2265142f42e18ba9 assets/engage/blockstates/beryllite_ore.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
|
38881f2039561be97bb6ea53d31ab9db54875fe5 assets/engage/blockstates/deuterium.json
|
||||||
620e8e678622f335115b86475f40e518de4f9cba assets/engage/blockstates/deuterium_slush.json
|
620e8e678622f335115b86475f40e518de4f9cba assets/engage/blockstates/deuterium_slush.json
|
||||||
|
84d1165d093a917bb6ff2fed0ae7fc5b6b1e850d assets/engage/blockstates/heat_spreader.json
|
||||||
8c9558de31b0459d70da1d07b499138e6248e38c assets/engage/blockstates/heavy_water.json
|
8c9558de31b0459d70da1d07b499138e6248e38c assets/engage/blockstates/heavy_water.json
|
||||||
b58e421acd852f85bc9fee8f837609c8471b90b7 assets/engage/blockstates/propane.json
|
b58e421acd852f85bc9fee8f837609c8471b90b7 assets/engage/blockstates/propane.json
|
||||||
9b31876df3da1b32ac5639c48cab2ce60cc876ad assets/engage/blockstates/warp_plasma.json
|
9b31876df3da1b32ac5639c48cab2ce60cc876ad assets/engage/blockstates/warp_plasma.json
|
||||||
f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/antideuterium.json
|
f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/antideuterium.json
|
||||||
9356d6cfcd705b3474cec35599e7709fb9f0954a assets/engage/models/block/beryllite_ore.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.json
|
||||||
f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/deuterium_slush.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/heavy_water.json
|
||||||
f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/propane.json
|
f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/propane.json
|
||||||
f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/warp_plasma.json
|
f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/warp_plasma.json
|
||||||
45314b766210255f87067ff2a93913e89b07f7ec assets/engage/models/item/beryllite_ore.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
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
// 1.20.1 2023-06-30T03:04:16.2694935 Languages: en_us
|
// 1.20.1 2023-06-30T04:23:53.8939811 Languages: en_us
|
||||||
50b8d51f4adf81848b9ed702904feddb9c747a09 assets/engage/lang/en_us.json
|
bb27af69172d87ab45300a72da603a98b770a06e assets/engage/lang/en_us.json
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
{
|
{
|
||||||
"block.engage.antideuterium": "Antideuterium",
|
"block.engage.antideuterium": "Antideuterium",
|
||||||
"block.engage.beryllite_ore": "Beryllite Ore",
|
"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": "Deuterium",
|
||||||
"block.engage.deuterium_slush": "Supercooled Deuterium",
|
"block.engage.deuterium_slush": "Supercooled Deuterium",
|
||||||
|
"block.engage.heat_spreader": "Heat Spreader",
|
||||||
"block.engage.heavy_water": "Heavy Water",
|
"block.engage.heavy_water": "Heavy Water",
|
||||||
"block.engage.propane": "Propane",
|
"block.engage.propane": "Propane",
|
||||||
"block.engage.warp_plasma": "Warp Plasma",
|
"block.engage.warp_plasma": "Warp Plasma",
|
||||||
"item.engage.antideuterium_bucket": "Antideuterium Bucket",
|
"item.engage.antideuterium_bucket": "Antideuterium Bucket",
|
||||||
|
"item.engage.beryllite_raw": "Beryllite",
|
||||||
"item.engage.deuterium_bucket": "Deuterium Bucket",
|
"item.engage.deuterium_bucket": "Deuterium Bucket",
|
||||||
"item.engage.deuterium_slush_bucket": "Supercooled Deuterium Bucket",
|
"item.engage.deuterium_slush_bucket": "Supercooled Deuterium Bucket",
|
||||||
"item.engage.heavy_water_bucket": "Heavy Water Bucket",
|
"item.engage.heavy_water_bucket": "Heavy Water Bucket",
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
"function": "minecraft:explosion_decay"
|
"function": "minecraft:explosion_decay"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "engage:beryllite_raw"
|
"name": "engage:beryllite_ore"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,15 @@ import uk.gemwire.engage.registries.fluid.FluidDeferredRegister;
|
||||||
* - Warp Gel
|
* - Warp Gel
|
||||||
* = Power port
|
* = 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")
|
@Mod("engage")
|
||||||
public class Engage {
|
public class Engage {
|
||||||
|
|
|
@ -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<Block> 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<BlockPos> 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<Direction, BlockPos> getValidTransitionsFrom(BlockPos pos, Direction incoming, Level level, List<BlockPos> visited) {
|
||||||
|
Map<Direction, BlockPos> 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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<Block, BlockState> p_49915_) {
|
||||||
|
super.createBlockStateDefinition(p_49915_);
|
||||||
|
p_49915_.add(FACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getStateForPlacement(BlockPlaceContext p_55928_) {
|
||||||
|
return this.defaultBlockState().setValue(FACING, p_55928_.getClickedFace());
|
||||||
|
}
|
||||||
|
}
|
45
src/main/java/uk/gemwire/engage/client/ClientStuff.java
Normal file
45
src/main/java/uk/gemwire/engage/client/ClientStuff.java
Normal file
|
@ -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<? extends FluidDeferredRegister.MekanismFluidType, ?, ?, ?, ?> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
package uk.gemwire.engage.registries;
|
package uk.gemwire.engage.registries;
|
||||||
|
|
||||||
import net.minecraft.util.valueproviders.UniformInt;
|
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.Block;
|
||||||
import net.minecraft.world.level.block.DropExperienceBlock;
|
import net.minecraft.world.level.block.DropExperienceBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
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.DeferredRegister;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
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.
|
* A utility class containing the registration and RegistryObjects of all the mods' blocks.
|
||||||
|
@ -18,6 +25,30 @@ public class Blocks {
|
||||||
public static final DeferredRegister<Block> BLOCKS_REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCKS, "engage");
|
public static final DeferredRegister<Block> BLOCKS_REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCKS, "engage");
|
||||||
|
|
||||||
// Beryllite Ore, the raw form of Beryllite - the reaction control substance.
|
// Beryllite Ore, the raw form of Beryllite - the reaction control substance.
|
||||||
public static final RegistryObject<Block> 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> block, Item.Properties properties) {
|
||||||
|
RegistryObject<Block> b = BLOCKS_REGISTRY.register(name, block);
|
||||||
|
RegistryObject<Item> i = Items.ITEMS_REGISTRY.register(name, () -> new BlockItem(b.get(), properties));
|
||||||
|
return new BlockItemRegistryObject(b, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
static BlockItemRegistryObject registerBlockItem(String name, Supplier<Block> block) {
|
||||||
|
RegistryObject<Block> b = BLOCKS_REGISTRY.register(name, block);
|
||||||
|
RegistryObject<Item> i = Items.ITEMS_REGISTRY.register(name, () -> new BlockItem(b.get(), new Item.Properties()));
|
||||||
|
return new BlockItemRegistryObject(b, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public record BlockItemRegistryObject(RegistryObject<Block> block, RegistryObject<Item> item) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,4 @@ public class Items {
|
||||||
|
|
||||||
// Raw (Unprocessed) Beryllite - the reaction control substance.
|
// Raw (Unprocessed) Beryllite - the reaction control substance.
|
||||||
public static final RegistryObject<Item> RAW_BERYLLITE_ITEM = ITEMS_REGISTRY.register("beryllite_raw", () -> new Item(new Item.Properties()));
|
public static final RegistryObject<Item> RAW_BERYLLITE_ITEM = ITEMS_REGISTRY.register("beryllite_raw", () -> new Item(new Item.Properties()));
|
||||||
|
|
||||||
// Beryllite Ore BlockItem
|
|
||||||
public static final RegistryObject<Item> BERYLLITE_ORE_ITEM = ITEMS_REGISTRY.register("beryllite_ore", () -> new BlockItem(Blocks.BERYLLITE_ORE_BLOCK.get(), new Item.Properties()));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user