From 1a052d1ec10786df998634c83b34ab3c341a6912 Mon Sep 17 00:00:00 2001 From: Snownee Date: Sat, 12 Dec 2020 05:00:25 +0800 Subject: [PATCH] Tag data-gen --- .../data/create/tags/blocks/safe_nbt.json | 35 ++++++++++--------- .../java/com/simibubi/create/AllBlocks.java | 27 ++++++++++++-- .../java/com/simibubi/create/AllTags.java | 2 ++ .../BlockMovementTraits.java | 2 +- 4 files changed, 46 insertions(+), 20 deletions(-) rename src/{main => generated}/resources/data/create/tags/blocks/safe_nbt.json (81%) diff --git a/src/main/resources/data/create/tags/blocks/safe_nbt.json b/src/generated/resources/data/create/tags/blocks/safe_nbt.json similarity index 81% rename from src/main/resources/data/create/tags/blocks/safe_nbt.json rename to src/generated/resources/data/create/tags/blocks/safe_nbt.json index d00a30821..b0a118a65 100644 --- a/src/main/resources/data/create/tags/blocks/safe_nbt.json +++ b/src/generated/resources/data/create/tags/blocks/safe_nbt.json @@ -1,30 +1,31 @@ { "replace": false, "values": [ - "#signs", - "create:linear_chassis", - "create:secondary_linear_chassis", - "create:radial_chassis", - "create:redstone_link", + "create:creative_motor", + "create:fluid_tank", + "create:creative_fluid_tank", + "create:mechanical_piston", + "create:sticky_mechanical_piston", + "create:mechanical_piston_head", "create:windmill_bearing", "create:mechanical_bearing", "create:clockwork_bearing", - "create:mechanical_piston", - "create:sticky_mechanical_piston", "create:rope_pulley", "create:cart_assembler", + "create:linear_chassis", + "create:secondary_linear_chassis", + "create:radial_chassis", "create:sequenced_gearshift", - "create:creative_motor", - "create:creative_fluid_tank", - "create:creative_crate", - "create:adjustable_repeater", - "create:adjustable_pulse_repeater", - "create:analog_lever", + "create:rotation_speed_controller", + "create:andesite_funnel", + "create:andesite_belt_funnel", "create:brass_funnel", "create:brass_belt_funnel", - "create:andesite_funnel", - "create:andesite_belt_funnel" - ], - "optional": [ + "create:creative_crate", + "create:redstone_link", + "create:analog_lever", + "create:adjustable_repeater", + "create:adjustable_pulse_repeater", + "#minecraft:signs" ] } \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index d53d27bcc..fa13dc040 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -320,6 +320,7 @@ public class AllBlocks { public static final BlockEntry CREATIVE_MOTOR = REGISTRATE.block("creative_motor", CreativeMotorBlock::new) .initialProperties(SharedProperties::stone) + .tag(AllBlockTags.SAFE_NBT.tag) .blockstate(new CreativeMotorGenerator()::generate) .transform(StressConfigDefaults.setCapacity(16384.0)) .item() @@ -592,6 +593,7 @@ public class AllBlocks { public static final BlockEntry FLUID_TANK = REGISTRATE.block("fluid_tank", FluidTankBlock::regular) .initialProperties(SharedProperties::softMetal) + .tag(AllBlockTags.SAFE_NBT.tag) .properties(Block.Properties::nonOpaque) .blockstate(new FluidTankGenerator()::generate) .onRegister(CreateRegistrate.blockModel(() -> FluidTankModel::standard)) @@ -604,6 +606,7 @@ public class AllBlocks { public static final BlockEntry CREATIVE_FLUID_TANK = REGISTRATE.block("creative_fluid_tank", FluidTankBlock::creative) .initialProperties(SharedProperties::softMetal) + .tag(AllBlockTags.SAFE_NBT.tag) .properties(Block.Properties::nonOpaque) .blockstate(new FluidTankGenerator("creative_")::generate) .onRegister(CreateRegistrate.blockModel(() -> FluidTankModel::creative)) @@ -653,11 +656,13 @@ public class AllBlocks { public static final BlockEntry MECHANICAL_PISTON = REGISTRATE.block("mechanical_piston", MechanicalPistonBlock::normal) .transform(BuilderTransformers.mechanicalPiston(PistonType.DEFAULT)) + .tag(AllBlockTags.SAFE_NBT.tag) .register(); public static final BlockEntry STICKY_MECHANICAL_PISTON = REGISTRATE.block("sticky_mechanical_piston", MechanicalPistonBlock::sticky) .transform(BuilderTransformers.mechanicalPiston(PistonType.STICKY)) + .tag(AllBlockTags.SAFE_NBT.tag) .register(); public static final BlockEntry PISTON_EXTENSION_POLE = @@ -670,6 +675,7 @@ public class AllBlocks { public static final BlockEntry MECHANICAL_PISTON_HEAD = REGISTRATE.block("mechanical_piston_head", MechanicalPistonHeadBlock::new) .initialProperties(() -> Blocks.PISTON_HEAD) + .tag(AllBlockTags.SAFE_NBT.tag) .loot((p, b) -> p.registerDropping(b, PISTON_EXTENSION_POLE.get())) .blockstate((c, p) -> BlockStateGen.directionalBlockIgnoresWaterlogged(c, p, state -> p.models() .getExistingFile(p.modLoc("block/mechanical_piston/" + state.get(MechanicalPistonHeadBlock.TYPE) @@ -680,12 +686,14 @@ public class AllBlocks { REGISTRATE.block("windmill_bearing", WindmillBearingBlock::new) .transform(BuilderTransformers.bearing("windmill", "gearbox", true)) .transform(StressConfigDefaults.setCapacity(512.0)) + .tag(AllBlockTags.SAFE_NBT.tag) .register(); public static final BlockEntry MECHANICAL_BEARING = REGISTRATE.block("mechanical_bearing", MechanicalBearingBlock::new) .transform(BuilderTransformers.bearing("mechanical", "gearbox", false)) .transform(StressConfigDefaults.setImpact(4.0)) + .tag(AllBlockTags.SAFE_NBT.tag) .onRegister(addMovementBehaviour(new StabilizedBearingMovementBehaviour())) .register(); @@ -693,10 +701,12 @@ public class AllBlocks { REGISTRATE.block("clockwork_bearing", ClockworkBearingBlock::new) .transform(BuilderTransformers.bearing("clockwork", "brass_gearbox", false)) .transform(StressConfigDefaults.setImpact(4.0)) + .tag(AllBlockTags.SAFE_NBT.tag) .register(); public static final BlockEntry ROPE_PULLEY = REGISTRATE.block("rope_pulley", PulleyBlock::new) .initialProperties(SharedProperties::stone) + .tag(AllBlockTags.SAFE_NBT.tag) .blockstate(BlockStateGen.horizontalAxisBlockProvider(true)) .transform(StressConfigDefaults.setImpact(4.0)) .item() @@ -725,7 +735,7 @@ public class AllBlocks { .properties(Block.Properties::nonOpaque) .blockstate(BlockStateGen.cartAssembler()) .addLayer(() -> RenderType::getCutoutMipped) - .tag(BlockTags.RAILS) + .tag(BlockTags.RAILS, AllBlockTags.SAFE_NBT.tag) .item(CartAssemblerBlockItem::new) .transform(customItemModel()) .register(); @@ -765,6 +775,7 @@ public class AllBlocks { public static final BlockEntry LINEAR_CHASSIS = REGISTRATE.block("linear_chassis", LinearChassisBlock::new) .initialProperties(SharedProperties::wooden) + .tag(AllBlockTags.SAFE_NBT.tag) .blockstate(BlockStateGen.linearChassis()) .onRegister(connectedTextures(new ChassisCTBehaviour())) .lang("Linear Chassis") @@ -774,6 +785,7 @@ public class AllBlocks { public static final BlockEntry SECONDARY_LINEAR_CHASSIS = REGISTRATE.block("secondary_linear_chassis", LinearChassisBlock::new) .initialProperties(SharedProperties::wooden) + .tag(AllBlockTags.SAFE_NBT.tag) .blockstate(BlockStateGen.linearChassis()) .onRegister(connectedTextures(new ChassisCTBehaviour())) .simpleItem() @@ -782,6 +794,7 @@ public class AllBlocks { public static final BlockEntry RADIAL_CHASSIS = REGISTRATE.block("radial_chassis", RadialChassisBlock::new) .initialProperties(SharedProperties::wooden) + .tag(AllBlockTags.SAFE_NBT.tag) .blockstate(BlockStateGen.radialChassis()) .item() .model((c, p) -> { @@ -968,6 +981,7 @@ public class AllBlocks { public static final BlockEntry SEQUENCED_GEARSHIFT = REGISTRATE.block("sequenced_gearshift", SequencedGearshiftBlock::new) .initialProperties(SharedProperties::stone) + .tag(AllBlockTags.SAFE_NBT.tag) .properties(Block.Properties::nonOpaque) .transform(StressConfigDefaults.setNoImpact()) .blockstate(new SequencedGearshiftGenerator()::generate) @@ -997,6 +1011,7 @@ public class AllBlocks { public static final BlockEntry ROTATION_SPEED_CONTROLLER = REGISTRATE.block("rotation_speed_controller", SpeedControllerBlock::new) .initialProperties(SharedProperties::softMetal) + .tag(AllBlockTags.SAFE_NBT.tag) .transform(StressConfigDefaults.setNoImpact()) .blockstate(BlockStateGen.horizontalAxisBlockProvider(true)) .item() @@ -1024,6 +1039,7 @@ public class AllBlocks { public static final BlockEntry ANDESITE_FUNNEL = REGISTRATE.block("andesite_funnel", AndesiteFunnelBlock::new) .initialProperties(SharedProperties::stone) + .tag(AllBlockTags.SAFE_NBT.tag) .onRegister(addMovementBehaviour(FunnelMovementBehaviour.andesite())) .transform(BuilderTransformers.funnel("andesite", Create.asResource("block/andesite_casing"))) .register(); @@ -1031,6 +1047,7 @@ public class AllBlocks { public static final BlockEntry ANDESITE_BELT_FUNNEL = REGISTRATE.block("andesite_belt_funnel", AndesiteBeltFunnelBlock::new) .initialProperties(SharedProperties::stone) + .tag(AllBlockTags.SAFE_NBT.tag) .blockstate(new BeltFunnelGenerator("andesite", new ResourceLocation("block/polished_andesite"))::generate) .loot((p, b) -> p.registerDropping(b, ANDESITE_FUNNEL.get())) .register(); @@ -1038,6 +1055,7 @@ public class AllBlocks { public static final BlockEntry BRASS_FUNNEL = REGISTRATE.block("brass_funnel", BrassFunnelBlock::new) .initialProperties(SharedProperties::softMetal) + .tag(AllBlockTags.SAFE_NBT.tag) .onRegister(addMovementBehaviour(FunnelMovementBehaviour.brass())) .transform(BuilderTransformers.funnel("brass", Create.asResource("block/brass_casing"))) .register(); @@ -1045,6 +1063,7 @@ public class AllBlocks { public static final BlockEntry BRASS_BELT_FUNNEL = REGISTRATE.block("brass_belt_funnel", BrassBeltFunnelBlock::new) .initialProperties(SharedProperties::softMetal) + .tag(AllBlockTags.SAFE_NBT.tag) .blockstate(new BeltFunnelGenerator("brass", Create.asResource("block/brass_block"))::generate) .loot((p, b) -> p.registerDropping(b, BRASS_FUNNEL.get())) .register(); @@ -1093,6 +1112,7 @@ public class AllBlocks { public static final BlockEntry CREATIVE_CRATE = REGISTRATE.block("creative_crate", CreativeCrateBlock::new) .transform(BuilderTransformers.crate("creative")) + .tag(AllBlockTags.SAFE_NBT.tag) .register(); public static final BlockEntry NIXIE_TUBE = REGISTRATE.block("nixie_tube", NixieTubeBlock::new) @@ -1107,7 +1127,7 @@ public class AllBlocks { public static final BlockEntry REDSTONE_LINK = REGISTRATE.block("redstone_link", RedstoneLinkBlock::new) .initialProperties(SharedProperties::wooden) - .tag(AllBlockTags.BRITTLE.tag) + .tag(AllBlockTags.BRITTLE.tag, AllBlockTags.SAFE_NBT.tag) .blockstate(new RedstoneLinkGenerator()::generate) .addLayer(() -> RenderType::getCutoutMipped) .item() @@ -1117,6 +1137,7 @@ public class AllBlocks { public static final BlockEntry ANALOG_LEVER = REGISTRATE.block("analog_lever", AnalogLeverBlock::new) .initialProperties(() -> Blocks.LEVER) + .tag(AllBlockTags.SAFE_NBT.tag) .blockstate((c, p) -> p.horizontalFaceBlock(c.get(), AssetLookup.partialBaseModel(c, p))) .item() .transform(customItemModel()) @@ -1134,6 +1155,7 @@ public class AllBlocks { public static final BlockEntry ADJUSTABLE_REPEATER = REGISTRATE.block("adjustable_repeater", AdjustableRepeaterBlock::new) .initialProperties(() -> Blocks.REPEATER) + .tag(AllBlockTags.SAFE_NBT.tag) .blockstate(new AdjustableRepeaterGenerator()::generate) .item() .model(AbstractDiodeGenerator.diodeItemModel(true)) @@ -1143,6 +1165,7 @@ public class AllBlocks { public static final BlockEntry ADJUSTABLE_PULSE_REPEATER = REGISTRATE.block("adjustable_pulse_repeater", AdjustableRepeaterBlock::new) .initialProperties(() -> Blocks.REPEATER) + .tag(AllBlockTags.SAFE_NBT.tag) .blockstate(new AdjustableRepeaterGenerator()::generate) .addLayer(() -> RenderType::getCutoutMipped) .item() diff --git a/src/main/java/com/simibubi/create/AllTags.java b/src/main/java/com/simibubi/create/AllTags.java index 039c576ad..d5e378760 100644 --- a/src/main/java/com/simibubi/create/AllTags.java +++ b/src/main/java/com/simibubi/create/AllTags.java @@ -163,5 +163,7 @@ public class AllTags { AllBlockTags.FAN_TRANSPARENT.add(Blocks.IRON_BARS); AllBlockTags.FAN_HEATERS.add(Blocks.MAGMA_BLOCK, Blocks.CAMPFIRE, Blocks.LAVA, Blocks.FIRE); + + AllBlockTags.SAFE_NBT.includeAll(BlockTags.SIGNS); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementTraits.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementTraits.java index 941c91731..1589e2768 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementTraits.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementTraits.java @@ -74,7 +74,7 @@ public class BlockMovementTraits { return true; if (blockState.getBlockHardness(world, pos) == -1) return false; - if (AllBlockTags.NON_MOVABLE.tag.contains(block)) + if (AllBlockTags.NON_MOVABLE.matches(blockState)) return false; // Move controllers only when they aren't moving