From 5bfaa0e20b854cfe8bb703911faacfc8d9dfa449 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Tue, 21 Jul 2020 21:23:33 -0400 Subject: [PATCH] Structure Actually Work! --- .../energonrelics/EnergonRelics.java | 23 +--- .../block/DefensiveLaserBlock.java | 2 +- .../block/EnergonLightBlock.java | 2 +- .../energonrelics/block/SolarPanelBlock.java | 2 +- .../energonrelics/block/SwitchBlock.java | 2 +- .../PassiveBatteryControllerBlock.java | 2 +- .../entity/DefensiveLaserBlockEntity.java | 13 +- .../ResearchComplexGeneratorBlockEntity.java | 52 -------- .../StructureGeneratorBlockEntity.java | 59 +++++++++ .../ResearchComplexGeneratorBlock.java | 41 ------ .../structure/StructureGeneratorBlock.java | 119 ++++++++++++++++++ .../structure/StructureGeneratorFeature.java} | 23 ++-- .../structure/StructureGeneratorPiece.java | 57 +++++++++ .../{ => energy}/EnergyProviderBlock.java | 3 +- .../client/EnergonRelicsClient.java | 2 +- .../client/config/UserConfig.java | 2 + .../energonrelics/item/MultimeterItem.java | 3 - .../mixin/MixinDefaultBiomeFeatures.java | 6 + .../mixin/RenderPhaseAccessor.java | 5 - .../structure/StructurePart.java | 39 ++++-- .../feature/ResearchComplexGenerator.java | 82 ------------ .../AbstractResearchComplexRoomPart.java | 7 +- .../ResearchComplexHallwayPart.java | 36 +++--- .../researchcomplex/ResearchComplexState.java | 6 +- .../research_complex_generator.json | 7 ++ .../assets/energonrelics/lang/en_us.json | 3 +- .../loot_tables/chests/research_complex.json | 4 +- 27 files changed, 336 insertions(+), 266 deletions(-) delete mode 100644 src/main/java/com/thebrokenrail/energonrelics/block/entity/structure/ResearchComplexGeneratorBlockEntity.java create mode 100644 src/main/java/com/thebrokenrail/energonrelics/block/entity/structure/StructureGeneratorBlockEntity.java delete mode 100644 src/main/java/com/thebrokenrail/energonrelics/block/structure/ResearchComplexGeneratorBlock.java create mode 100644 src/main/java/com/thebrokenrail/energonrelics/block/structure/StructureGeneratorBlock.java rename src/main/java/com/thebrokenrail/energonrelics/{structure/feature/ResearchComplexFeature.java => block/structure/StructureGeneratorFeature.java} (58%) create mode 100644 src/main/java/com/thebrokenrail/energonrelics/block/structure/StructureGeneratorPiece.java rename src/main/java/com/thebrokenrail/energonrelics/block/util/{ => energy}/EnergyProviderBlock.java (96%) delete mode 100644 src/main/java/com/thebrokenrail/energonrelics/structure/feature/ResearchComplexGenerator.java create mode 100644 src/main/resources/assets/energonrelics/blockstates/research_complex_generator.json diff --git a/src/main/java/com/thebrokenrail/energonrelics/EnergonRelics.java b/src/main/java/com/thebrokenrail/energonrelics/EnergonRelics.java index cbaf9f9..34bf237 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/EnergonRelics.java +++ b/src/main/java/com/thebrokenrail/energonrelics/EnergonRelics.java @@ -1,7 +1,7 @@ package com.thebrokenrail.energonrelics; import com.thebrokenrail.energonrelics.block.DefensiveLaserBlock; -import com.thebrokenrail.energonrelics.block.structure.ResearchComplexGeneratorBlock; +import com.thebrokenrail.energonrelics.block.structure.StructureGeneratorBlock; import com.thebrokenrail.energonrelics.block.ThermalGlassBlock; import com.thebrokenrail.energonrelics.block.battery.ActiveBatteryControllerBlock; import com.thebrokenrail.energonrelics.block.reactor.ReactorControllerBlock; @@ -16,9 +16,6 @@ import com.thebrokenrail.energonrelics.block.SwitchBlock; import com.thebrokenrail.energonrelics.block.util.SimpleBlock; import com.thebrokenrail.energonrelics.item.MultimeterItem; import com.thebrokenrail.energonrelics.item.NetworkChipItem; -import com.thebrokenrail.energonrelics.structure.feature.ResearchComplexFeature; -import com.thebrokenrail.energonrelics.structure.feature.ResearchComplexGenerator; -import net.earthcomputer.libstructure.LibStructure; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; @@ -28,19 +25,12 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.structure.StructurePieceType; import net.minecraft.util.Identifier; import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.Registry; -import net.minecraft.world.biome.Biomes; -import net.minecraft.world.gen.GenerationStep; -import net.minecraft.world.gen.chunk.StructureConfig; import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.DefaultFeatureConfig; import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.FeatureConfig; import net.minecraft.world.gen.feature.OreFeatureConfig; -import net.minecraft.world.gen.feature.StructureFeature; public class EnergonRelics implements ModInitializer { public static final String NAMESPACE = "energonrelics"; @@ -75,11 +65,6 @@ public class EnergonRelics implements ModInitializer { public static final Item DEFENSIVE_LASER_CORE_ITEM = new Item(new Item.Settings().group(ITEM_GROUP)); public static final DefensiveLaserBlock DEFENSIVE_LASER_BLOCK = new DefensiveLaserBlock(); - public static final ResearchComplexGeneratorBlock RESEARCH_COMPLEX_GENERATOR_BLOCK = new ResearchComplexGeneratorBlock(); - - public static StructureFeature RESEARCH_COMPLEX_STRUCTURE_FEATURE = new ResearchComplexFeature(DefaultFeatureConfig.CODEC); - public static StructurePieceType RESEARCH_COMPLEX_STRUCTURE_PIECE = (structureManager, tag) -> new ResearchComplexGenerator.Piece(tag); - @Override public void onInitialize() { NETWORK_CHIP_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "network_chip"), new NetworkChipItem()); @@ -109,10 +94,6 @@ public class EnergonRelics implements ModInitializer { Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "defensive_laser_core"), DEFENSIVE_LASER_CORE_ITEM); DEFENSIVE_LASER_BLOCK.register("defensive_laser"); - RESEARCH_COMPLEX_GENERATOR_BLOCK.register("research_complex_generator"); - - Registry.register(Registry.STRUCTURE_PIECE, new Identifier(NAMESPACE, "research_complex_piece"), RESEARCH_COMPLEX_STRUCTURE_PIECE); - Biomes.PLAINS.addStructureFeature(RESEARCH_COMPLEX_STRUCTURE_FEATURE.configure(FeatureConfig.DEFAULT)); - LibStructure.registerStructure(new Identifier(NAMESPACE, "research_complex"), RESEARCH_COMPLEX_STRUCTURE_FEATURE, GenerationStep.Feature.UNDERGROUND_STRUCTURES, new StructureConfig(32, 8, 14357618), RESEARCH_COMPLEX_STRUCTURE_FEATURE.configure(FeatureConfig.DEFAULT)); + StructureGeneratorBlock.register(); } } diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/DefensiveLaserBlock.java b/src/main/java/com/thebrokenrail/energonrelics/block/DefensiveLaserBlock.java index 1410601..3d15b69 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/block/DefensiveLaserBlock.java +++ b/src/main/java/com/thebrokenrail/energonrelics/block/DefensiveLaserBlock.java @@ -1,7 +1,7 @@ package com.thebrokenrail.energonrelics.block; import com.thebrokenrail.energonrelics.block.entity.DefensiveLaserBlockEntity; -import com.thebrokenrail.energonrelics.block.util.EnergyProviderBlock; +import com.thebrokenrail.energonrelics.block.util.energy.EnergyProviderBlock; import com.thebrokenrail.energonrelics.client.block.entity.render.DefensiveLaserBlockEntityRenderer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/EnergonLightBlock.java b/src/main/java/com/thebrokenrail/energonrelics/block/EnergonLightBlock.java index fc5ff0e..a21e64a 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/block/EnergonLightBlock.java +++ b/src/main/java/com/thebrokenrail/energonrelics/block/EnergonLightBlock.java @@ -1,7 +1,7 @@ package com.thebrokenrail.energonrelics.block; import com.thebrokenrail.energonrelics.block.entity.EnergonLightBlockEntity; -import com.thebrokenrail.energonrelics.block.util.EnergyProviderBlock; +import com.thebrokenrail.energonrelics.block.util.energy.EnergyProviderBlock; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.Block; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/SolarPanelBlock.java b/src/main/java/com/thebrokenrail/energonrelics/block/SolarPanelBlock.java index 362407b..dac00bf 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/block/SolarPanelBlock.java +++ b/src/main/java/com/thebrokenrail/energonrelics/block/SolarPanelBlock.java @@ -1,7 +1,7 @@ package com.thebrokenrail.energonrelics.block; import com.thebrokenrail.energonrelics.block.entity.SolarPanelBlockEntity; -import com.thebrokenrail.energonrelics.block.util.EnergyProviderBlock; +import com.thebrokenrail.energonrelics.block.util.energy.EnergyProviderBlock; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.Material; import net.minecraft.block.entity.BlockEntity; diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/SwitchBlock.java b/src/main/java/com/thebrokenrail/energonrelics/block/SwitchBlock.java index b29b33e..144b58c 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/block/SwitchBlock.java +++ b/src/main/java/com/thebrokenrail/energonrelics/block/SwitchBlock.java @@ -1,7 +1,7 @@ package com.thebrokenrail.energonrelics.block; import com.thebrokenrail.energonrelics.block.entity.SwitchBlockEntity; -import com.thebrokenrail.energonrelics.block.util.EnergyProviderBlock; +import com.thebrokenrail.energonrelics.block.util.energy.EnergyProviderBlock; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.Block; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/battery/PassiveBatteryControllerBlock.java b/src/main/java/com/thebrokenrail/energonrelics/block/battery/PassiveBatteryControllerBlock.java index 9187ca9..3f3ba41 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/block/battery/PassiveBatteryControllerBlock.java +++ b/src/main/java/com/thebrokenrail/energonrelics/block/battery/PassiveBatteryControllerBlock.java @@ -1,7 +1,7 @@ package com.thebrokenrail.energonrelics.block.battery; import com.thebrokenrail.energonrelics.block.entity.battery.PassiveBatteryControllerBlockEntity; -import com.thebrokenrail.energonrelics.block.util.EnergyProviderBlock; +import com.thebrokenrail.energonrelics.block.util.energy.EnergyProviderBlock; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.Block; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/entity/DefensiveLaserBlockEntity.java b/src/main/java/com/thebrokenrail/energonrelics/block/entity/DefensiveLaserBlockEntity.java index d67f5e0..98ad57c 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/block/entity/DefensiveLaserBlockEntity.java +++ b/src/main/java/com/thebrokenrail/energonrelics/block/entity/DefensiveLaserBlockEntity.java @@ -35,7 +35,7 @@ import java.util.function.Predicate; public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity { private static final float ROTATION_INCREMENT = 4; - public final Rotation rotation = new Rotation(0, 0, "Rotation"); + public final Rotation rotation = new Rotation(); private static Vec3d getPosVec(BlockPos pos) { return new Vec3d(pos.getX() + 0.5d, pos.getY() + 0.5d, pos.getZ() + 0.5d); @@ -57,15 +57,14 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity { public class Rotation { private float yaw = 0; private float pitch = 0; - private final String key; + private static final String KEY = "Rotation"; - private Rotation(float yaw, float pitch, String key) { - setRaw(yaw, pitch); - this.key = key; + private Rotation() { + setRaw(0f, 0f); } private void fromTag(CompoundTag tag) { - CompoundTag rotation = tag.getCompound(key); + CompoundTag rotation = tag.getCompound(KEY); setRaw(rotation.getInt("Yaw"), rotation.getInt("Pitch")); } @@ -73,7 +72,7 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity { CompoundTag rotation = new CompoundTag(); rotation.putFloat("Yaw", yaw); rotation.putFloat("Pitch", pitch); - tag.put(key, rotation); + tag.put(KEY, rotation); } private void setRaw(float yaw, float pitch) { diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/entity/structure/ResearchComplexGeneratorBlockEntity.java b/src/main/java/com/thebrokenrail/energonrelics/block/entity/structure/ResearchComplexGeneratorBlockEntity.java deleted file mode 100644 index 642728b..0000000 --- a/src/main/java/com/thebrokenrail/energonrelics/block/entity/structure/ResearchComplexGeneratorBlockEntity.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.thebrokenrail.energonrelics.block.entity.structure; - -import com.thebrokenrail.energonrelics.block.structure.ResearchComplexGeneratorBlock; -import com.thebrokenrail.energonrelics.structure.StructurePart; -import com.thebrokenrail.energonrelics.structure.StructurePlacer; -import com.thebrokenrail.energonrelics.structure.researchcomplex.ResearchComplexStartPart; -import com.thebrokenrail.energonrelics.structure.researchcomplex.ResearchComplexState; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.BlockEntityType; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.util.Tickable; -import net.minecraft.util.math.Direction; - -import java.util.Collections; -import java.util.Objects; -import java.util.Random; - -public class ResearchComplexGeneratorBlockEntity extends BlockEntity implements Tickable { - private long seed = 0; - - public ResearchComplexGeneratorBlockEntity(BlockEntityType type) { - super(type); - } - - public void setSeed(long seed) { - this.seed = seed; - } - - @Override - public CompoundTag toTag(CompoundTag tag) { - super.toTag(tag); - tag.putLong("Seed", seed); - return tag; - } - - @Override - public void fromTag(BlockState state, CompoundTag tag) { - super.fromTag(state, tag); - seed = tag.getLong("Seed"); - } - - @Override - public void tick() { - if (hasWorld() && !Objects.requireNonNull(getWorld()).isClient()) { - Direction facing = getCachedState().get(ResearchComplexGeneratorBlock.HORIZONTAL_FACING); - getWorld().setBlockState(getPos(), Blocks.STONE.getDefaultState()); - new StructurePlacer(new ResearchComplexStartPart(new ResearchComplexState(getWorld(), new Random(seed)), Collections.singletonList(StructurePart.getTransformationFromDirection(facing)))).place(getWorld(), getPos()); - } - } -} diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/entity/structure/StructureGeneratorBlockEntity.java b/src/main/java/com/thebrokenrail/energonrelics/block/entity/structure/StructureGeneratorBlockEntity.java new file mode 100644 index 0000000..5bf40eb --- /dev/null +++ b/src/main/java/com/thebrokenrail/energonrelics/block/entity/structure/StructureGeneratorBlockEntity.java @@ -0,0 +1,59 @@ +package com.thebrokenrail.energonrelics.block.entity.structure; + +import com.thebrokenrail.energonrelics.block.structure.StructureGeneratorBlock; +import com.thebrokenrail.energonrelics.structure.StructurePart; +import com.thebrokenrail.energonrelics.structure.StructurePlacer; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.math.Direction; +import net.minecraft.world.World; + +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Random; + +public class StructureGeneratorBlockEntity extends BlockEntity { + public interface StructurePartFactory { + StructurePart create(World world, Random random, List transformations); + } + + private long seed = 0; + private boolean generated = false; + + private final StructurePartFactory factory; + + public StructureGeneratorBlockEntity(BlockEntityType type, StructurePartFactory factory) { + super(type); + this.factory = factory; + } + + public void setSeed(long seed) { + this.seed = seed; + } + + @Override + public CompoundTag toTag(CompoundTag tag) { + super.toTag(tag); + tag.putLong("Seed", seed); + tag.putBoolean("Generated", generated); + return tag; + } + + @Override + public void fromTag(BlockState state, CompoundTag tag) { + super.fromTag(state, tag); + seed = tag.getLong("Seed"); + generated = tag.getBoolean("Generated"); + } + + public void generate() { + if (hasWorld() && !Objects.requireNonNull(getWorld()).isClient() && !generated) { + Direction facing = getCachedState().get(StructureGeneratorBlock.HORIZONTAL_FACING); + generated = true; + new StructurePlacer(factory.create(getWorld(), new Random(seed), Collections.singletonList(StructurePart.directionToTransformation(facing)))).place(getWorld(), getPos()); + } + } +} diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/structure/ResearchComplexGeneratorBlock.java b/src/main/java/com/thebrokenrail/energonrelics/block/structure/ResearchComplexGeneratorBlock.java deleted file mode 100644 index 4e15a13..0000000 --- a/src/main/java/com/thebrokenrail/energonrelics/block/structure/ResearchComplexGeneratorBlock.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.thebrokenrail.energonrelics.block.structure; - -import com.thebrokenrail.energonrelics.block.entity.structure.ResearchComplexGeneratorBlockEntity; -import com.thebrokenrail.energonrelics.block.util.SimpleBlockWithEntity; -import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.BlockEntityType; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.DirectionProperty; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.Direction; - -import java.util.function.Function; - -public class ResearchComplexGeneratorBlock extends SimpleBlockWithEntity { - public static DirectionProperty HORIZONTAL_FACING = Properties.HORIZONTAL_FACING; - - public ResearchComplexGeneratorBlock() { - super(FabricBlockSettings.of(Material.STONE).strength(-1.0F, 3600000.0F).dropsNothing()); - setDefaultState(getDefaultState().with(HORIZONTAL_FACING, Direction.NORTH)); - } - - @Override - protected boolean registerItem() { - return false; - } - - @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); - builder.add(HORIZONTAL_FACING); - } - - @Override - protected Function, BlockEntity> getFactory() { - return ResearchComplexGeneratorBlockEntity::new; - } -} diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/structure/StructureGeneratorBlock.java b/src/main/java/com/thebrokenrail/energonrelics/block/structure/StructureGeneratorBlock.java new file mode 100644 index 0000000..4b3c154 --- /dev/null +++ b/src/main/java/com/thebrokenrail/energonrelics/block/structure/StructureGeneratorBlock.java @@ -0,0 +1,119 @@ +package com.thebrokenrail.energonrelics.block.structure; + +import com.thebrokenrail.energonrelics.EnergonRelics; +import com.thebrokenrail.energonrelics.block.entity.structure.StructureGeneratorBlockEntity; +import com.thebrokenrail.energonrelics.block.util.SimpleBlockWithEntity; +import com.thebrokenrail.energonrelics.structure.researchcomplex.ResearchComplexStartPart; +import com.thebrokenrail.energonrelics.structure.researchcomplex.ResearchComplexState; +import net.earthcomputer.libstructure.LibStructure; +import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Material; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.DirectionProperty; +import net.minecraft.state.property.Properties; +import net.minecraft.structure.StructurePieceType; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.registry.Registry; +import net.minecraft.world.World; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.gen.GenerationStep; +import net.minecraft.world.gen.chunk.StructureConfig; +import net.minecraft.world.gen.feature.DefaultFeatureConfig; +import net.minecraft.world.gen.feature.FeatureConfig; +import net.minecraft.world.gen.feature.StructureFeature; + +import java.util.HashMap; +import java.util.Map; +import java.util.Random; +import java.util.function.Function; + +public class StructureGeneratorBlock extends SimpleBlockWithEntity { + public static final DirectionProperty HORIZONTAL_FACING = Properties.HORIZONTAL_FACING; + + private static final Map blocks = new HashMap<>(); + + private final StructureGeneratorBlockEntity.StructurePartFactory structureFactory; + private final StructureConfig structureConfig; + + private final StructureFeature feature = new StructureGeneratorFeature(this); + final StructurePieceType piece = (structureManager, tag) -> new StructureGeneratorPiece(this, tag); + + private StructureGeneratorBlock(StructureGeneratorBlockEntity.StructurePartFactory structureFactory, StructureConfig structureConfig) { + super(FabricBlockSettings.of(Material.STONE).strength(-1f, 3600000f).dropsNothing()); + setDefaultState(getDefaultState().with(HORIZONTAL_FACING, Direction.NORTH)); + this.structureFactory = structureFactory; + this.structureConfig = structureConfig; + } + + @Override + protected boolean registerItem() { + return false; + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(HORIZONTAL_FACING); + } + + @Override + protected Function, BlockEntity> getFactory() { + return type -> new StructureGeneratorBlockEntity(type, structureFactory); + } + + @SuppressWarnings("deprecation") + @Override + public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + super.scheduledTick(state, world, pos, random); + BlockEntity entity = world.getBlockEntity(pos); + if (entity instanceof StructureGeneratorBlockEntity) { + ((StructureGeneratorBlockEntity) entity).generate(); + } + } + + @SuppressWarnings("deprecation") + @Override + public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) { + super.onBlockAdded(state, world, pos, oldState, notify); + schedule(world, pos); + } + + public void schedule(World world, BlockPos pos) { + world.getBlockTickScheduler().schedule(pos, this, 0); + } + + @Override + public void register(String name) { + super.register(name + "_generator"); + Registry.register(Registry.STRUCTURE_PIECE, new Identifier(EnergonRelics.NAMESPACE, name + "_piece"), piece); + LibStructure.registerStructure(new Identifier(EnergonRelics.NAMESPACE, name), feature, GenerationStep.Feature.UNDERGROUND_STRUCTURES, structureConfig, feature.configure(FeatureConfig.DEFAULT)); + } + + @SuppressWarnings("SameParameterValue") + private static void create(String name, StructureGeneratorBlockEntity.StructurePartFactory factory, StructureConfig config) { + blocks.put(name, new StructureGeneratorBlock(factory, config)); + } + + public static void register() { + for (Map.Entry entry : blocks.entrySet()) { + entry.getValue().register(entry.getKey()); + } + } + + public static void addToBiome(Biome biome) { + for (Map.Entry entry : blocks.entrySet()) { + biome.addStructureFeature(entry.getValue().feature.configure(DefaultFeatureConfig.INSTANCE)); + } + } + + static { + create("research_complex", (world, random, transformations) -> new ResearchComplexStartPart(new ResearchComplexState(world, random), transformations), new StructureConfig(32, 8, 14357618)); + } +} diff --git a/src/main/java/com/thebrokenrail/energonrelics/structure/feature/ResearchComplexFeature.java b/src/main/java/com/thebrokenrail/energonrelics/block/structure/StructureGeneratorFeature.java similarity index 58% rename from src/main/java/com/thebrokenrail/energonrelics/structure/feature/ResearchComplexFeature.java rename to src/main/java/com/thebrokenrail/energonrelics/block/structure/StructureGeneratorFeature.java index 618ce04..0d6bae0 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/structure/feature/ResearchComplexFeature.java +++ b/src/main/java/com/thebrokenrail/energonrelics/block/structure/StructureGeneratorFeature.java @@ -1,6 +1,5 @@ -package com.thebrokenrail.energonrelics.structure.feature; +package com.thebrokenrail.energonrelics.block.structure; -import com.mojang.serialization.Codec; import net.minecraft.structure.StructureManager; import net.minecraft.structure.StructureStart; import net.minecraft.util.BlockRotation; @@ -13,26 +12,32 @@ import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; import net.minecraft.world.gen.feature.StructureFeature; -public class ResearchComplexFeature extends StructureFeature { - public ResearchComplexFeature(Codec codec) { - super(codec); +class StructureGeneratorFeature extends StructureFeature { + private final StructureGeneratorBlock block; + + StructureGeneratorFeature(StructureGeneratorBlock block) { + super(DefaultFeatureConfig.CODEC); + this.block = block; } @Override public StructureStartFactory getStructureStartFactory() { - return Start::new; + return (structureFeature, i, j, blockBox, k, l) -> new Start(block, structureFeature, i, j, blockBox, k, l); } - public static class Start extends StructureStart { - public Start(StructureFeature structureFeature, int i, int j, BlockBox blockBox, int k, long l) { + private static class Start extends StructureStart { + private final StructureGeneratorBlock block; + + private Start(StructureGeneratorBlock block, StructureFeature structureFeature, int i, int j, BlockBox blockBox, int k, long l) { super(structureFeature, i, j, blockBox, k, l); + this.block = block; } @Override public void init(DynamicRegistryManager dynamicRegistryManager, ChunkGenerator chunkGenerator, StructureManager structureManager, int x, int z, Biome biome, DefaultFeatureConfig defaultFeatureConfig) { BlockPos blockPos = new BlockPos(x * 16, chunkGenerator.getHeight(x, z, Heightmap.Type.WORLD_SURFACE) / 2, z * 16); BlockRotation blockRotation = BlockRotation.random(random); - ResearchComplexGenerator.addPieces(blockPos, blockRotation, children); + children.add(new StructureGeneratorPiece(block, blockRotation, blockPos)); setBoundingBoxFromChildren(); } } diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/structure/StructureGeneratorPiece.java b/src/main/java/com/thebrokenrail/energonrelics/block/structure/StructureGeneratorPiece.java new file mode 100644 index 0000000..3080401 --- /dev/null +++ b/src/main/java/com/thebrokenrail/energonrelics/block/structure/StructureGeneratorPiece.java @@ -0,0 +1,57 @@ +package com.thebrokenrail.energonrelics.block.structure; + +import com.thebrokenrail.energonrelics.block.entity.structure.StructureGeneratorBlockEntity; +import com.thebrokenrail.energonrelics.structure.StructurePart; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.structure.StructurePiece; +import net.minecraft.util.BlockRotation; +import net.minecraft.util.math.BlockBox; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.ServerWorldAccess; +import net.minecraft.world.gen.StructureAccessor; +import net.minecraft.world.gen.chunk.ChunkGenerator; + +import java.util.Random; + +class StructureGeneratorPiece extends StructurePiece { + private final StructureGeneratorBlock block; + private final BlockRotation rotation; + private final BlockPos pos; + + StructureGeneratorPiece(StructureGeneratorBlock block, BlockRotation rotation, BlockPos pos) { + super(block.piece, 0); + this.block = block; + this.rotation = rotation; + this.pos = pos; + boundingBox = BlockBox.create(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1); + } + + StructureGeneratorPiece(StructureGeneratorBlock block, CompoundTag tag) { + this(block, BlockRotation.valueOf(tag.getString("Rot")), new BlockPos(tag.getInt("X"), tag.getInt("Y"), tag.getInt("Z"))); + } + + @Override + protected void toNbt(CompoundTag tag) { + tag.putString("Rot", rotation.name()); + tag.putInt("X", pos.getX()); + tag.putInt("Y", pos.getY()); + tag.putInt("Z", pos.getZ()); + } + + @Override + public boolean generate(ServerWorldAccess world, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockBox boundingBox, ChunkPos chunkPos, BlockPos blockPos) { + BlockState state = block.getDefaultState().with(StructureGeneratorBlock.HORIZONTAL_FACING, StructurePart.blockRotationToDirection(rotation)); + + world.setBlockState(pos, state, 3); + BlockEntity entity = world.getBlockEntity(pos); + if (entity instanceof StructureGeneratorBlockEntity) { + ((StructureGeneratorBlockEntity) entity).setSeed(random.nextLong()); + } + + block.schedule(world.getWorld(), pos); + return true; + } +} diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/util/EnergyProviderBlock.java b/src/main/java/com/thebrokenrail/energonrelics/block/util/energy/EnergyProviderBlock.java similarity index 96% rename from src/main/java/com/thebrokenrail/energonrelics/block/util/EnergyProviderBlock.java rename to src/main/java/com/thebrokenrail/energonrelics/block/util/energy/EnergyProviderBlock.java index d1b7d9b..9056ea8 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/block/util/EnergyProviderBlock.java +++ b/src/main/java/com/thebrokenrail/energonrelics/block/util/energy/EnergyProviderBlock.java @@ -1,6 +1,7 @@ -package com.thebrokenrail.energonrelics.block.util; +package com.thebrokenrail.energonrelics.block.util.energy; import com.thebrokenrail.energonrelics.EnergonRelics; +import com.thebrokenrail.energonrelics.block.util.SimpleBlockWithEntity; import com.thebrokenrail.energonrelics.client.block.entity.render.HighlightBlockEntityRenderer; import com.thebrokenrail.energonrelics.energy.core.EnergyProviderBlockEntity; import net.fabricmc.api.EnvType; diff --git a/src/main/java/com/thebrokenrail/energonrelics/client/EnergonRelicsClient.java b/src/main/java/com/thebrokenrail/energonrelics/client/EnergonRelicsClient.java index 46f6879..032462e 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/client/EnergonRelicsClient.java +++ b/src/main/java/com/thebrokenrail/energonrelics/client/EnergonRelicsClient.java @@ -1,7 +1,7 @@ package com.thebrokenrail.energonrelics.client; import com.thebrokenrail.energonrelics.EnergonRelics; -import com.thebrokenrail.energonrelics.block.util.EnergyProviderBlock; +import com.thebrokenrail.energonrelics.block.util.energy.EnergyProviderBlock; import com.thebrokenrail.energonrelics.client.config.UserConfig; import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; import me.sargunvohra.mcmods.autoconfig1u.ConfigData; diff --git a/src/main/java/com/thebrokenrail/energonrelics/client/config/UserConfig.java b/src/main/java/com/thebrokenrail/energonrelics/client/config/UserConfig.java index 17ec604..4a4e515 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/client/config/UserConfig.java +++ b/src/main/java/com/thebrokenrail/energonrelics/client/config/UserConfig.java @@ -11,6 +11,7 @@ import java.util.Locale; @Environment(EnvType.CLIENT) @Config(name = EnergonRelics.NAMESPACE) public class UserConfig implements ConfigData { + @SuppressWarnings("unused") public enum TextureSet { TheBrokenRail, PoeticRainbow; @@ -20,5 +21,6 @@ public class UserConfig implements ConfigData { } } + @SuppressWarnings("CanBeFinal") public TextureSet textureSet = TextureSet.TheBrokenRail; } diff --git a/src/main/java/com/thebrokenrail/energonrelics/item/MultimeterItem.java b/src/main/java/com/thebrokenrail/energonrelics/item/MultimeterItem.java index aee7364..a96aa32 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/item/MultimeterItem.java +++ b/src/main/java/com/thebrokenrail/energonrelics/item/MultimeterItem.java @@ -4,9 +4,7 @@ import com.thebrokenrail.energonrelics.EnergonRelics; import com.thebrokenrail.energonrelics.energy.core.EnergyReceiverBlockEntity; import com.thebrokenrail.energonrelics.energy.helper.EnergyGenerator; import net.minecraft.block.entity.BlockEntity; -import net.minecraft.entity.Entity; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUsageContext; import net.minecraft.text.LiteralText; import net.minecraft.text.MutableText; @@ -14,7 +12,6 @@ import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; import net.minecraft.util.ActionResult; import net.minecraft.util.Formatting; -import net.minecraft.world.RayTraceContext; import net.minecraft.world.World; import java.util.Objects; diff --git a/src/main/java/com/thebrokenrail/energonrelics/mixin/MixinDefaultBiomeFeatures.java b/src/main/java/com/thebrokenrail/energonrelics/mixin/MixinDefaultBiomeFeatures.java index 1b518d1..641ec8c 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/mixin/MixinDefaultBiomeFeatures.java +++ b/src/main/java/com/thebrokenrail/energonrelics/mixin/MixinDefaultBiomeFeatures.java @@ -1,6 +1,7 @@ package com.thebrokenrail.energonrelics.mixin; import com.thebrokenrail.energonrelics.EnergonRelics; +import com.thebrokenrail.energonrelics.block.structure.StructureGeneratorBlock; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.feature.DefaultBiomeFeatures; @@ -15,4 +16,9 @@ public class MixinDefaultBiomeFeatures { private static void addDefaultOres(Biome biome, CallbackInfo info) { biome.addFeature(GenerationStep.Feature.UNDERGROUND_ORES, EnergonRelics.VERIDIUM_ORE_FEATURE); } + + @Inject(at = @At("RETURN"), method = "addDefaultUndergroundStructures") + private static void addDefaultUndergroundStructures(Biome biome, CallbackInfo info) { + StructureGeneratorBlock.addToBiome(biome); + } } diff --git a/src/main/java/com/thebrokenrail/energonrelics/mixin/RenderPhaseAccessor.java b/src/main/java/com/thebrokenrail/energonrelics/mixin/RenderPhaseAccessor.java index 3d94268..b39a4bb 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/mixin/RenderPhaseAccessor.java +++ b/src/main/java/com/thebrokenrail/energonrelics/mixin/RenderPhaseAccessor.java @@ -11,11 +11,6 @@ public interface RenderPhaseAccessor { throw new UnsupportedOperationException(); } - @Accessor - static RenderPhase.Target getTRANSLUCENT_TARGET() { - throw new UnsupportedOperationException(); - } - @Accessor static RenderPhase.Layering getVIEW_OFFSET_Z_LAYERING() { throw new UnsupportedOperationException(); diff --git a/src/main/java/com/thebrokenrail/energonrelics/structure/StructurePart.java b/src/main/java/com/thebrokenrail/energonrelics/structure/StructurePart.java index ce78571..e83579e 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/structure/StructurePart.java +++ b/src/main/java/com/thebrokenrail/energonrelics/structure/StructurePart.java @@ -2,7 +2,6 @@ package com.thebrokenrail.energonrelics.structure; import com.thebrokenrail.energonrelics.util.MissingCaseException; import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; import net.minecraft.state.property.Properties; import net.minecraft.util.BlockMirror; import net.minecraft.util.BlockRotation; @@ -16,7 +15,7 @@ import java.util.List; import java.util.Map; public abstract class StructurePart { - protected interface Transformation { + public interface Transformation { BlockPos transform(BlockPos pos); BlockState transform(BlockState state); } @@ -80,7 +79,7 @@ public abstract class StructurePart { return state.rotate(BlockRotation.COUNTERCLOCKWISE_90); } }; - protected static final Transformation MIRROR = new Transformation() { + protected static final Transformation MIRROR_DEPTH = new Transformation() { @Override public BlockPos transform(BlockPos pos) { return new BlockPos(pos.getX(), pos.getY(), -pos.getZ()); @@ -142,18 +141,18 @@ public abstract class StructurePart { public void place(World world, BlockPos pos) { for (Map.Entry entry : blocks.entrySet()) { BlockState state = entry.getValue(); - if (state.getBlock() != Blocks.VOID_AIR) { - BlockPos newPos = pos.add(BlockPos.fromLong(entry.getKey())); - world.removeBlockEntity(newPos); - world.setBlockState(newPos, state); - handleBlockPlace(world, newPos, state); - } + BlockPos newPos = pos.add(BlockPos.fromLong(entry.getKey())); + + world.removeBlockEntity(newPos); + world.setBlockState(newPos, state); + + handleBlockPlace(world, newPos, state); } } protected abstract void handleBlockPlace(World world, BlockPos pos, BlockState state); - public static Transformation getTransformationFromDirection(Direction direction) { + public static Transformation directionToTransformation(Direction direction) { switch (direction) { case NORTH: { return NONE; @@ -173,6 +172,26 @@ public abstract class StructurePart { } } + public static Direction blockRotationToDirection(BlockRotation rotation) { + switch (rotation) { + case NONE: { + return Direction.NORTH; + } + case CLOCKWISE_90: { + return Direction.EAST; + } + case CLOCKWISE_180: { + return Direction.SOUTH; + } + case COUNTERCLOCKWISE_90: { + return Direction.WEST; + } + default: { + throw new MissingCaseException(rotation); + } + } + } + protected void part(StructureContext context, BlockPos originalPos, StructurePart part) { BlockPos pos = transform(originalPos); context.addPart(pos.getX(), pos.getY(), pos.getZ(), part); diff --git a/src/main/java/com/thebrokenrail/energonrelics/structure/feature/ResearchComplexGenerator.java b/src/main/java/com/thebrokenrail/energonrelics/structure/feature/ResearchComplexGenerator.java deleted file mode 100644 index 9baea27..0000000 --- a/src/main/java/com/thebrokenrail/energonrelics/structure/feature/ResearchComplexGenerator.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.thebrokenrail.energonrelics.structure.feature; - -import com.thebrokenrail.energonrelics.EnergonRelics; -import com.thebrokenrail.energonrelics.block.entity.structure.ResearchComplexGeneratorBlockEntity; -import com.thebrokenrail.energonrelics.block.structure.ResearchComplexGeneratorBlock; -import com.thebrokenrail.energonrelics.util.MissingCaseException; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.structure.StructurePiece; -import net.minecraft.util.BlockRotation; -import net.minecraft.util.math.BlockBox; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.ServerWorldAccess; -import net.minecraft.world.gen.StructureAccessor; -import net.minecraft.world.gen.chunk.ChunkGenerator; - -import java.util.List; -import java.util.Random; - -public class ResearchComplexGenerator { - static void addPieces(BlockPos pos, BlockRotation rotation, List pieces) { - pieces.add(new Piece(rotation, pos)); - } - - public static class Piece extends StructurePiece { - private final BlockRotation rotation; - private final BlockPos pos; - - private Piece(BlockRotation rotation, BlockPos pos) { - super(EnergonRelics.RESEARCH_COMPLEX_STRUCTURE_PIECE, 0); - this.rotation = rotation; - this.pos = pos; - boundingBox = BlockBox.create(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1); - } - - public Piece(CompoundTag tag) { - super(EnergonRelics.RESEARCH_COMPLEX_STRUCTURE_PIECE, tag); - rotation = BlockRotation.valueOf(tag.getString("Rot")); - pos = new BlockPos(tag.getInt("X"), tag.getInt("Y"), tag.getInt("Z")); - } - - @Override - protected void toNbt(CompoundTag tag) { - tag.putString("Rot", rotation.name()); - tag.putInt("X", pos.getX()); - tag.putInt("Y", pos.getY()); - tag.putInt("Z", pos.getZ()); - } - - @Override - public boolean generate(ServerWorldAccess world, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockBox boundingBox, ChunkPos chunkPos, BlockPos blockPos) { - world.setBlockState(pos, EnergonRelics.RESEARCH_COMPLEX_GENERATOR_BLOCK.getDefaultState().with(ResearchComplexGeneratorBlock.HORIZONTAL_FACING, blockRotationToDirection(rotation)), 4); - BlockEntity entity = world.getBlockEntity(pos); - if (entity instanceof ResearchComplexGeneratorBlockEntity) { - ((ResearchComplexGeneratorBlockEntity) entity).setSeed(random.nextLong()); - } - return true; - } - - private static Direction blockRotationToDirection(BlockRotation rotation) { - switch (rotation) { - case NONE: { - return Direction.NORTH; - } - case CLOCKWISE_90: { - return Direction.EAST; - } - case CLOCKWISE_180: { - return Direction.SOUTH; - } - case COUNTERCLOCKWISE_90: { - return Direction.WEST; - } - default: { - throw new MissingCaseException(rotation); - } - } - } - } -} diff --git a/src/main/java/com/thebrokenrail/energonrelics/structure/researchcomplex/AbstractResearchComplexRoomPart.java b/src/main/java/com/thebrokenrail/energonrelics/structure/researchcomplex/AbstractResearchComplexRoomPart.java index 6d88e56..fb83b78 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/structure/researchcomplex/AbstractResearchComplexRoomPart.java +++ b/src/main/java/com/thebrokenrail/energonrelics/structure/researchcomplex/AbstractResearchComplexRoomPart.java @@ -4,6 +4,7 @@ import com.thebrokenrail.energonrelics.EnergonRelics; import com.thebrokenrail.energonrelics.config.HardcodedConfig; import com.thebrokenrail.energonrelics.structure.StructureContext; import com.thebrokenrail.energonrelics.util.WeightedList; +import net.minecraft.block.BarrelBlock; import net.minecraft.block.BedBlock; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -157,7 +158,7 @@ public abstract class AbstractResearchComplexRoomPart extends BaseResearchComple @Override protected void buildInterior() { - BlockState barrel = Blocks.BARREL.getDefaultState(); + BlockState barrel = Blocks.BARREL.getDefaultState().with(BarrelBlock.FACING, Direction.WEST); rect(new BlockPos(3, 0, 2), 2, 2, 3, barrel); rect(new BlockPos(2, 0, 3), 1, 1, 2, barrel); rect(new BlockPos(4, 2, 3), 1, 1, 2, barrel); @@ -172,8 +173,8 @@ public abstract class AbstractResearchComplexRoomPart extends BaseResearchComple private static WeightedList createWeightedList() { WeightedList weightedList = new WeightedList<>(); weightedList.add(1, StorageRoom::new); - weightedList.add(4, CraftingRoom::new); - weightedList.add(4, BedRoom::new); + weightedList.add(2, CraftingRoom::new); + weightedList.add(2, BedRoom::new); return weightedList; } diff --git a/src/main/java/com/thebrokenrail/energonrelics/structure/researchcomplex/ResearchComplexHallwayPart.java b/src/main/java/com/thebrokenrail/energonrelics/structure/researchcomplex/ResearchComplexHallwayPart.java index 3febd9e..00e8173 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/structure/researchcomplex/ResearchComplexHallwayPart.java +++ b/src/main/java/com/thebrokenrail/energonrelics/structure/researchcomplex/ResearchComplexHallwayPart.java @@ -19,7 +19,7 @@ public class ResearchComplexHallwayPart extends BaseResearchComplexPart { private int rightRoomPadding; private int leftRoomPadding; - private static final float ROOM_CHANCE = 0.4f; + private static final float ROOM_CHANCE = 0.45f; public ResearchComplexHallwayPart(ResearchComplexState state, List list, boolean hasLight, int rightRoomPadding, int leftRoomPadding) { super(state, list); @@ -28,13 +28,9 @@ public class ResearchComplexHallwayPart extends BaseResearchComplexPart { this.leftRoomPadding = leftRoomPadding; } - private int getHeight() { - return 6; - } + private static final int HEIGHT = 6; - private int getDepth() { - return 3; - } + private static final int DEPTH = 3; @Override protected void build(StructureContext context) { @@ -46,22 +42,22 @@ public class ResearchComplexHallwayPart extends BaseResearchComplexPart { BlockState westStairs = stairs.with(StairsBlock.FACING, Direction.WEST); BlockState eastStairs = stairs.with(StairsBlock.FACING, Direction.EAST); - for (int y = 0; y < getHeight(); y++) { - BlockState state = y == 0 || y == getHeight() - 1 ? bricks : air; - if (y > 1 && y < getHeight() - 2) { - rect(new BlockPos(1, y, 0), 5, 1, getDepth(), air); - rect(new BlockPos(0, y, 0), 1, 1, getDepth(), bricks); - rect(new BlockPos(6, y, 0), 1, 1, getDepth(), bricks); + for (int y = 0; y < HEIGHT; y++) { + BlockState state = y == 0 || y == HEIGHT - 1 ? bricks : air; + if (y > 1 && y < HEIGHT - 2) { + rect(new BlockPos(1, y, 0), 5, 1, DEPTH, air); + rect(new BlockPos(0, y, 0), 1, 1, DEPTH, bricks); + rect(new BlockPos(6, y, 0), 1, 1, DEPTH, bricks); } else { - rect(new BlockPos(2, y, 0), 3, 1, getDepth(), state); + rect(new BlockPos(2, y, 0), 3, 1, DEPTH, state); } - if (y == 1 || y == getHeight() - 2) { - if (y == getHeight() - 2) { + if (y == 1 || y == HEIGHT - 2) { + if (y == HEIGHT - 2) { eastStairs = eastStairs.with(StairsBlock.HALF, BlockHalf.TOP); westStairs = westStairs.with(StairsBlock.HALF, BlockHalf.TOP); } - rect(new BlockPos(1, y, 0), 1, 1, getDepth(), westStairs); - rect(new BlockPos(5, y, 0), 1, 1, getDepth(), eastStairs); + rect(new BlockPos(1, y, 0), 1, 1, DEPTH, westStairs); + rect(new BlockPos(5, y, 0), 1, 1, DEPTH, eastStairs); } } @@ -88,7 +84,7 @@ public class ResearchComplexHallwayPart extends BaseResearchComplexPart { rightRoomPadding = rightRoomPadding - 1; } - part(context, new BlockPos(0, 0, getDepth()), new ResearchComplexHallwayPart(getState(), getTransformations(), !hasLight, rightRoomPadding, leftRoomPadding)); + part(context, new BlockPos(0, 0, DEPTH), new ResearchComplexHallwayPart(getState(), getTransformations(), !hasLight, rightRoomPadding, leftRoomPadding)); } else { rect(new BlockPos(1, 1, 0), 5, 4, 1, bricks); } @@ -97,7 +93,7 @@ public class ResearchComplexHallwayPart extends BaseResearchComplexPart { private List getRoomTransformation(boolean mirror) { List list = new ArrayList<>(); if (mirror) { - list.add(MIRROR); + list.add(MIRROR_DEPTH); } list.addAll(getTransformations()); list.add(com.thebrokenrail.energonrelics.structure.StructurePart.CLOCKWISE_90); diff --git a/src/main/java/com/thebrokenrail/energonrelics/structure/researchcomplex/ResearchComplexState.java b/src/main/java/com/thebrokenrail/energonrelics/structure/researchcomplex/ResearchComplexState.java index 47d398e..237e3d9 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/structure/researchcomplex/ResearchComplexState.java +++ b/src/main/java/com/thebrokenrail/energonrelics/structure/researchcomplex/ResearchComplexState.java @@ -21,12 +21,12 @@ public class ResearchComplexState { this.random = random; } - private int getID(int id) { - return baseID + id; + private int getID() { + return baseID; } int getMainNetwork() { - return getID(0); + return getID(); } boolean hasEnergy(long amount, BlockPos pos) { diff --git a/src/main/resources/assets/energonrelics/blockstates/research_complex_generator.json b/src/main/resources/assets/energonrelics/blockstates/research_complex_generator.json new file mode 100644 index 0000000..ac411f7 --- /dev/null +++ b/src/main/resources/assets/energonrelics/blockstates/research_complex_generator.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "minecraft:block/structure_block_load" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/energonrelics/lang/en_us.json b/src/main/resources/assets/energonrelics/lang/en_us.json index 0ce8f34..2d7ee26 100644 --- a/src/main/resources/assets/energonrelics/lang/en_us.json +++ b/src/main/resources/assets/energonrelics/lang/en_us.json @@ -25,5 +25,6 @@ "text.autoconfig.energonrelics.title": "EnergonRelics", "text.autoconfig.energonrelics.option.textureSet": "Texture Set", "death.attack.energonrelics.defensive_laser": "%s was evaporated by a laser", - "death.attack.energonrelics.defensive_laser.player": "%s was evaporated by a laser whilst fighting %s" + "death.attack.energonrelics.defensive_laser.player": "%s was evaporated by a laser whilst fighting %s", + "block.energonrelics.research_complex_generator": "Research Complex Generator" } \ No newline at end of file diff --git a/src/main/resources/data/energonrelics/loot_tables/chests/research_complex.json b/src/main/resources/data/energonrelics/loot_tables/chests/research_complex.json index 9f7695f..06d022e 100644 --- a/src/main/resources/data/energonrelics/loot_tables/chests/research_complex.json +++ b/src/main/resources/data/energonrelics/loot_tables/chests/research_complex.json @@ -37,7 +37,7 @@ { "type": "minecraft:item", "name": "minecraft:iron_ingot", - "weight": 5, + "weight": 4, "functions": [ { "function": "minecraft:set_count", @@ -79,7 +79,7 @@ "count": { "type": "minecraft:uniform", "min": 1, - "max": 6 + "max": 7 } } ]