From 517a4f08243c641168b3fa5eb02cf37186e125fa Mon Sep 17 00:00:00 2001 From: Snownee Date: Fri, 11 Dec 2020 20:03:16 +0800 Subject: [PATCH 1/7] Allow schematicannon to persist some safe block data --- .../java/com/simibubi/create/AllTags.java | 2 +- .../schematics/block/LaunchedItem.java | 20 +++++++++++-- .../block/SchematicannonTileEntity.java | 25 +++++++++++----- .../data/create/tags/blocks/safe_nbt.json | 30 +++++++++++++++++++ 4 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 src/main/resources/data/create/tags/blocks/safe_nbt.json diff --git a/src/main/java/com/simibubi/create/AllTags.java b/src/main/java/com/simibubi/create/AllTags.java index b486accd5..039c576ad 100644 --- a/src/main/java/com/simibubi/create/AllTags.java +++ b/src/main/java/com/simibubi/create/AllTags.java @@ -109,7 +109,7 @@ public class AllTags { } public static enum AllBlockTags { - WINDMILL_SAILS, FAN_HEATERS, WINDOWABLE, NON_MOVABLE, BRITTLE, SEATS, SAILS, VALVE_HANDLES, FAN_TRANSPARENT + WINDMILL_SAILS, FAN_HEATERS, WINDOWABLE, NON_MOVABLE, BRITTLE, SEATS, SAILS, VALVE_HANDLES, FAN_TRANSPARENT, SAFE_NBT ; diff --git a/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java b/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java index efebcdcd7..075a01513 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java @@ -19,6 +19,7 @@ import net.minecraft.nbt.NBTUtil; import net.minecraft.particles.ParticleTypes; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tags.FluidTags; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction.Axis; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; @@ -26,6 +27,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.IPlantable; +import net.minecraftforge.common.util.Constants; public abstract class LaunchedItem { @@ -90,18 +92,23 @@ public abstract class LaunchedItem { public static class ForBlockState extends LaunchedItem { public BlockState state; + public CompoundNBT data; ForBlockState() {} - public ForBlockState(BlockPos start, BlockPos target, ItemStack stack, BlockState state) { + public ForBlockState(BlockPos start, BlockPos target, ItemStack stack, BlockState state, CompoundNBT data) { super(start, target, stack); this.state = state; + this.data = data; } @Override public CompoundNBT serializeNBT() { CompoundNBT serializeNBT = super.serializeNBT(); serializeNBT.put("BlockState", NBTUtil.writeBlockState(state)); + if (data != null) { + serializeNBT.put("Data", data); + } return serializeNBT; } @@ -109,6 +116,9 @@ public abstract class LaunchedItem { void readNBT(CompoundNBT nbt) { super.readNBT(nbt); state = NBTUtil.readBlockState(nbt.getCompound("BlockState")); + if (nbt.contains("Data", Constants.NBT.TAG_COMPOUND)) { + data = nbt.getCompound("Data"); + } } @Override @@ -141,6 +151,12 @@ public abstract class LaunchedItem { return; } world.setBlockState(target, state, 18); + if (data != null) { + TileEntity tile = world.getTileEntity(target); + if (tile != null) { + tile.read(data); + } + } state.getBlock().onBlockPlacedBy(world, target, state, null, stack); } @@ -165,7 +181,7 @@ public abstract class LaunchedItem { } public ForBelt(BlockPos start, BlockPos target, ItemStack stack, BlockState state, int length) { - super(start, target, stack, state); + super(start, target, stack, state, null); this.length = length; } diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index e6a4eb1a9..872b36696 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -3,9 +3,12 @@ package com.simibubi.create.content.schematics.block; import java.util.LinkedList; import java.util.List; +import javax.annotation.Nullable; + import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.AllSoundEvents; +import com.simibubi.create.AllTags.AllBlockTags; import com.simibubi.create.content.contraptions.relays.belt.BeltBlock; import com.simibubi.create.content.contraptions.relays.belt.BeltPart; import com.simibubi.create.content.contraptions.relays.belt.BeltSlope; @@ -458,9 +461,17 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC if (te instanceof BeltTileEntity && AllBlocks.BELT.has(blockState)) launchBelt(target, blockState, ((BeltTileEntity) te).beltLength); else - launchBlock(target, icon, blockState); - } else - launchBlock(target, icon, blockState); + launchBlock(target, icon, blockState, null); + } else { + CompoundNBT data = null; + if (AllBlockTags.SAFE_NBT.matches(blockState)) { + TileEntity tile = blockReader.getTileEntity(target); + if (tile != null && !tile.onlyOpsCanSetNbt()) { + data = tile.write(new CompoundNBT()); + } + } + launchBlock(target, icon, blockState, data); + } printerCooldown = config().schematicannonDelay.get(); fuelLevel -= getFuelUsageRate(); @@ -692,7 +703,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC if (world == null) return false; BlockState toReplace = world.getBlockState(pos); - boolean placingAir = state.getBlock() == Blocks.AIR; + boolean placingAir = state.getBlock().isAir(state, world, pos); BlockState toReplaceOther = null; if (state.has(BlockStateProperties.BED_PART) && state.has(BlockStateProperties.HORIZONTAL_FACING) && state.get(BlockStateProperties.BED_PART) == BedPart.FOOT) @@ -828,10 +839,10 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC playFiringSound(); } - protected void launchBlock(BlockPos target, ItemStack stack, BlockState state) { - if (state.getBlock() != Blocks.AIR) + protected void launchBlock(BlockPos target, ItemStack stack, BlockState state, @Nullable CompoundNBT data) { + if (state.getBlock().isAir(state, world, target)) blocksPlaced++; - flyingBlocks.add(new LaunchedItem.ForBlockState(this.getPos(), target, stack, state)); + flyingBlocks.add(new LaunchedItem.ForBlockState(this.getPos(), target, stack, state, data)); playFiringSound(); } diff --git a/src/main/resources/data/create/tags/blocks/safe_nbt.json b/src/main/resources/data/create/tags/blocks/safe_nbt.json new file mode 100644 index 000000000..d00a30821 --- /dev/null +++ b/src/main/resources/data/create/tags/blocks/safe_nbt.json @@ -0,0 +1,30 @@ +{ + "replace": false, + "values": [ + "#signs", + "create:linear_chassis", + "create:secondary_linear_chassis", + "create:radial_chassis", + "create:redstone_link", + "create:windmill_bearing", + "create:mechanical_bearing", + "create:clockwork_bearing", + "create:mechanical_piston", + "create:sticky_mechanical_piston", + "create:rope_pulley", + "create:cart_assembler", + "create:sequenced_gearshift", + "create:creative_motor", + "create:creative_fluid_tank", + "create:creative_crate", + "create:adjustable_repeater", + "create:adjustable_pulse_repeater", + "create:analog_lever", + "create:brass_funnel", + "create:brass_belt_funnel", + "create:andesite_funnel", + "create:andesite_belt_funnel" + ], + "optional": [ + ] +} \ No newline at end of file From 1a052d1ec10786df998634c83b34ab3c341a6912 Mon Sep 17 00:00:00 2001 From: Snownee Date: Sat, 12 Dec 2020 05:00:25 +0800 Subject: [PATCH 2/7] 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 From 0941d9403fbe871c7069005f78cf115f00cd48eb Mon Sep 17 00:00:00 2001 From: Snownee Date: Sat, 12 Dec 2020 19:09:10 +0800 Subject: [PATCH 3/7] Zappers Safe-NBT support --- .../zapper/ZapperInteractionHandler.java | 27 ++++++++++++++++--- .../curiosities/zapper/ZapperItem.java | 24 ++++++++++++++--- .../zapper/blockzapper/BlockzapperItem.java | 4 +-- .../zapper/terrainzapper/TerrainTools.java | 8 +++++- .../zapper/terrainzapper/WorldshaperItem.java | 4 +-- .../schematics/block/LaunchedItem.java | 7 +++++ .../behaviour/linked/LinkBehaviour.java | 15 +++++------ 7 files changed, 70 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperInteractionHandler.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperInteractionHandler.java index ccc010a83..edd0e003f 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperInteractionHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperInteractionHandler.java @@ -1,6 +1,9 @@ package com.simibubi.create.content.curiosities.zapper; +import java.util.Objects; + import com.simibubi.create.AllSoundEvents; +import com.simibubi.create.AllTags.AllBlockTags; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.NbtPacket; import com.simibubi.create.foundation.utility.BlockHelper; @@ -12,6 +15,7 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.NBTUtil; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.StairsShape; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; @@ -68,7 +72,7 @@ public class ZapperInteractionHandler { if (BlockHelper.getRequiredItem(newState) .isEmpty()) return false; - if (player.world.getTileEntity(pos) != null) + if (newState.hasTileEntity() && !AllBlockTags.SAFE_NBT.matches(newState)) return false; if (newState.has(BlockStateProperties.DOUBLE_BLOCK_HALF)) return false; @@ -85,14 +89,31 @@ public class ZapperInteractionHandler { if (newState.has(BlockStateProperties.WATERLOGGED)) newState = newState.with(BlockStateProperties.WATERLOGGED, false); + CompoundNBT data = null; + TileEntity tile = player.world.getTileEntity(pos); + if (tile != null) { + data = tile.write(new CompoundNBT()); + data.remove("x"); + data.remove("y"); + data.remove("z"); + data.remove("id"); + } CompoundNBT tag = stack.getOrCreateTag(); - if (tag.contains("BlockUsed") && NBTUtil.readBlockState(stack.getTag() - .getCompound("BlockUsed")) == newState) + if (tag.contains("BlockUsed") + && NBTUtil.readBlockState( + stack.getTag().getCompound("BlockUsed")) == newState + && Objects.equals(data, tag.get("BlockData"))) { return false; + } tag.put("BlockUsed", NBTUtil.writeBlockState(newState)); + if (data == null) + tag.remove("BlockData"); + else + tag.put("BlockData", data); player.world.playSound(player, player.getPosition(), AllSoundEvents.BLOCKZAPPER_CONFIRM.get(), SoundCategory.BLOCKS, 0.5f, 0.8f); + return true; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java index 37253ceea..7dfb7dc06 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java @@ -5,6 +5,7 @@ import java.util.List; import javax.annotation.Nonnull; import com.simibubi.create.AllSoundEvents; +import com.simibubi.create.AllTags.AllBlockTags; import com.simibubi.create.foundation.item.ItemDescription; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.BlockHelper; @@ -23,6 +24,7 @@ import net.minecraft.item.Rarity; import net.minecraft.item.UseAction; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.NBTUtil; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; @@ -35,12 +37,12 @@ import net.minecraft.util.math.RayTraceContext.BlockMode; import net.minecraft.util.math.RayTraceContext.FluidMode; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.network.PacketDistributor; @@ -149,6 +151,10 @@ public abstract class ZapperItem extends Item { if (nbt.contains("BlockUsed")) stateToUse = NBTUtil.readBlockState(nbt.getCompound("BlockUsed")); stateToUse = BlockHelper.setZeroAge(stateToUse); + CompoundNBT data = null; + if (AllBlockTags.SAFE_NBT.matches(stateToUse) && nbt.contains("BlockData", NBT.TAG_COMPOUND)) { + data = nbt.getCompound("BlockData"); + } // Raytrace - Find the target Vec3d start = player.getPositionVec() @@ -181,7 +187,7 @@ public abstract class ZapperItem extends Item { } // Server side - if (activate(world, player, item, stateToUse, raytrace)) { + if (activate(world, player, item, stateToUse, raytrace, data)) { applyCooldown(player, item, gunInOtherHand); AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> player), new ZapperBeamPacket(barrelPos, raytrace.getHitVec(), hand, false)); @@ -200,7 +206,7 @@ public abstract class ZapperItem extends Item { } protected abstract boolean activate(World world, PlayerEntity player, ItemStack item, BlockState stateToUse, - BlockRayTraceResult raytrace); + BlockRayTraceResult raytrace, CompoundNBT data); @OnlyIn(Dist.CLIENT) protected abstract void openHandgunGUI(ItemStack item, boolean b); @@ -234,4 +240,16 @@ public abstract class ZapperItem extends Item { return UseAction.NONE; } + public static void setTileData(World world, BlockPos pos, CompoundNBT data) { + if (data != null) { + TileEntity tile = world.getTileEntity(pos); + if (tile != null && !tile.onlyOpsCanSetNbt()) { + data.putInt("x", pos.getX()); + data.putInt("y", pos.getY()); + data.putInt("z", pos.getZ()); + tile.read(data); + } + } + } + } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/blockzapper/BlockzapperItem.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/blockzapper/BlockzapperItem.java index e6051d6de..5e27ad20c 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/blockzapper/BlockzapperItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/blockzapper/BlockzapperItem.java @@ -22,7 +22,6 @@ import com.simibubi.create.foundation.utility.NBTHelper; import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.block.RedstoneLampBlock; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.Entity; @@ -97,7 +96,7 @@ public class BlockzapperItem extends ZapperItem { @Override protected boolean activate(World world, PlayerEntity player, ItemStack stack, BlockState selectedState, - BlockRayTraceResult raytrace) { + BlockRayTraceResult raytrace, CompoundNBT data) { CompoundNBT nbt = stack.getOrCreateTag(); boolean replace = nbt.contains("Replace") && nbt.getBoolean("Replace"); @@ -136,6 +135,7 @@ public class BlockzapperItem extends ZapperItem { blocksnapshot.restore(true, false); return false; } + setTileData(world, placed, data); if (player instanceof ServerPlayerEntity && world instanceof ServerWorld) { ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player; diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/TerrainTools.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/TerrainTools.java index ad9602f1e..51401b113 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/TerrainTools.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/TerrainTools.java @@ -4,11 +4,13 @@ import java.util.List; import javax.annotation.Nullable; +import com.simibubi.create.content.curiosities.zapper.ZapperItem; import com.simibubi.create.foundation.gui.AllIcons; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -34,7 +36,7 @@ public enum TerrainTools { return this != Clear && this != Flatten; } - public void run(World world, List targetPositions, Direction facing, @Nullable BlockState paintedState) { + public void run(World world, List targetPositions, Direction facing, @Nullable BlockState paintedState, @Nullable CompoundNBT data) { switch (this) { case Clear: targetPositions.forEach(p -> world.setBlockState(p, Blocks.AIR.getDefaultState())); @@ -45,6 +47,7 @@ public enum TerrainTools { if (!isReplaceable(toReplace)) return; world.setBlockState(p, paintedState); + ZapperItem.setTileData(world, p, data); }); break; case Flatten: @@ -64,11 +67,13 @@ public enum TerrainTools { if (!isReplaceable(toReplace)) return; world.setBlockState(p, paintedState); + ZapperItem.setTileData(world, p, data); }); break; case Place: targetPositions.forEach(p -> { world.setBlockState(p, paintedState); + ZapperItem.setTileData(world, p, data); }); break; case Replace: @@ -77,6 +82,7 @@ public enum TerrainTools { if (isReplaceable(toReplace)) return; world.setBlockState(p, paintedState); + ZapperItem.setTileData(world, p, data); }); break; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItem.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItem.java index 7c7b91e72..9f2e4d019 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItem.java @@ -60,7 +60,7 @@ public class WorldshaperItem extends ZapperItem { @Override protected boolean activate(World world, PlayerEntity player, ItemStack stack, BlockState stateToUse, - BlockRayTraceResult raytrace) { + BlockRayTraceResult raytrace, CompoundNBT data) { BlockPos targetPos = raytrace.getPos(); List affectedPositions = new ArrayList<>(); @@ -77,7 +77,7 @@ public class WorldshaperItem extends ZapperItem { for (BlockPos blockPos : brush.getIncludedPositions()) affectedPositions.add(targetPos.add(blockPos)); PlacementPatterns.applyPattern(affectedPositions, stack); - tool.run(world, affectedPositions, raytrace.getFace(), stateToUse); + tool.run(world, affectedPositions, raytrace.getFace(), stateToUse, data); return true; } diff --git a/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java b/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java index 075a01513..5502356af 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java @@ -107,6 +107,10 @@ public abstract class LaunchedItem { CompoundNBT serializeNBT = super.serializeNBT(); serializeNBT.put("BlockState", NBTUtil.writeBlockState(state)); if (data != null) { + data.remove("x"); + data.remove("y"); + data.remove("z"); + data.remove("id"); serializeNBT.put("Data", data); } return serializeNBT; @@ -154,6 +158,9 @@ public abstract class LaunchedItem { if (data != null) { TileEntity tile = world.getTileEntity(target); if (tile != null) { + data.putInt("x", target.getX()); + data.putInt("y", target.getY()); + data.putInt("z", target.getZ()); tile.read(data); } } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java index 651fd7828..871c126ce 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java @@ -1,9 +1,8 @@ package com.simibubi.create.foundation.tileEntity.behaviour.linked; -import java.util.function.Consumer; import java.util.function.Function; -import java.util.function.Supplier; - +import java.util.function.IntConsumer; +import java.util.function.IntSupplier; import org.apache.commons.lang3.tuple.Pair; import com.simibubi.create.Create; @@ -35,8 +34,8 @@ public class LinkBehaviour extends TileEntityBehaviour { public boolean newPosition; private Mode mode; - private Supplier transmission; - private Consumer signalCallback; + private IntSupplier transmission; + private IntConsumer signalCallback; protected LinkBehaviour(SmartTileEntity te, Pair slots) { super(te); @@ -49,7 +48,7 @@ public class LinkBehaviour extends TileEntityBehaviour { } public static LinkBehaviour receiver(SmartTileEntity te, Pair slots, - Consumer signalCallback) { + IntConsumer signalCallback) { LinkBehaviour behaviour = new LinkBehaviour(te, slots); behaviour.signalCallback = signalCallback; behaviour.mode = Mode.RECEIVE; @@ -57,7 +56,7 @@ public class LinkBehaviour extends TileEntityBehaviour { } public static LinkBehaviour transmitter(SmartTileEntity te, Pair slots, - Supplier transmission) { + IntSupplier transmission) { LinkBehaviour behaviour = new LinkBehaviour(te, slots); behaviour.transmission = transmission; behaviour.mode = Mode.TRANSMIT; @@ -81,7 +80,7 @@ public class LinkBehaviour extends TileEntityBehaviour { } public int getTransmittedStrength() { - return mode == Mode.TRANSMIT ? transmission.get() : 0; + return mode == Mode.TRANSMIT ? transmission.getAsInt() : 0; } public void updateReceiver(int networkPower) { From f64dc8c43f609c4667682ec943228a1f0ef91e65 Mon Sep 17 00:00:00 2001 From: Snownee Date: Sat, 12 Dec 2020 19:10:59 +0800 Subject: [PATCH 4/7] Signs are not nbt-safe, due to the ability to execute command --- src/generated/resources/data/create/tags/blocks/safe_nbt.json | 3 +-- src/main/java/com/simibubi/create/AllTags.java | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/generated/resources/data/create/tags/blocks/safe_nbt.json b/src/generated/resources/data/create/tags/blocks/safe_nbt.json index b0a118a65..e0049a6df 100644 --- a/src/generated/resources/data/create/tags/blocks/safe_nbt.json +++ b/src/generated/resources/data/create/tags/blocks/safe_nbt.json @@ -25,7 +25,6 @@ "create:redstone_link", "create:analog_lever", "create:adjustable_repeater", - "create:adjustable_pulse_repeater", - "#minecraft:signs" + "create:adjustable_pulse_repeater" ] } \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/AllTags.java b/src/main/java/com/simibubi/create/AllTags.java index d5e378760..039c576ad 100644 --- a/src/main/java/com/simibubi/create/AllTags.java +++ b/src/main/java/com/simibubi/create/AllTags.java @@ -163,7 +163,5 @@ 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); } } From 24dcb5383a295d58ae870791e8fe34bea64bfad5 Mon Sep 17 00:00:00 2001 From: Snownee Date: Sat, 12 Dec 2020 19:32:32 +0800 Subject: [PATCH 5/7] Make the zapper selection logic server-side (#515) --- .../zapper/ZapperInteractionHandler.java | 22 +++---------- .../simibubi/create/events/ClientEvents.java | 12 +++++++ .../simibubi/create/events/CommonEvents.java | 11 +++++++ .../foundation/networking/AllPackets.java | 1 + .../networking/LeftClickPacket.java | 32 +++++++++++++++++++ 5 files changed, 61 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/simibubi/create/foundation/networking/LeftClickPacket.java diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperInteractionHandler.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperInteractionHandler.java index edd0e003f..030f9ee44 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperInteractionHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperInteractionHandler.java @@ -4,8 +4,6 @@ import java.util.Objects; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllTags.AllBlockTags; -import com.simibubi.create.foundation.networking.AllPackets; -import com.simibubi.create.foundation.networking.NbtPacket; import com.simibubi.create.foundation.utility.BlockHelper; import net.minecraft.block.BlockState; @@ -17,7 +15,6 @@ import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.StairsShape; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; @@ -25,30 +22,21 @@ import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceContext.BlockMode; import net.minecraft.util.math.RayTraceContext.FluidMode; import net.minecraft.util.math.Vec3d; -import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -@EventBusSubscriber(value = Dist.CLIENT) +@EventBusSubscriber public class ZapperInteractionHandler { - @SubscribeEvent - public static void leftClickingTheZapperSelectsANewBlock(PlayerInteractEvent.LeftClickEmpty event) { - ItemStack heldItem = event.getPlayer() - .getHeldItemMainhand(); - if (heldItem.getItem() instanceof ZapperItem && trySelect(heldItem, event.getPlayer())) - AllPackets.channel.sendToServer(new NbtPacket(heldItem, Hand.MAIN_HAND)); - } - @SubscribeEvent public static void leftClickingBlocksWithTheZapperSelectsTheBlock(PlayerInteractEvent.LeftClickBlock event) { - ItemStack heldItem = event.getPlayer() - .getHeldItemMainhand(); + if (event.getWorld().isRemote) + return; + ItemStack heldItem = event.getPlayer().getHeldItemMainhand(); if (heldItem.getItem() instanceof ZapperItem && trySelect(heldItem, event.getPlayer())) { event.setCancellationResult(ActionResultType.FAIL); event.setCanceled(true); - AllPackets.channel.sendToServer(new NbtPacket(heldItem, Hand.MAIN_HAND)); } } @@ -111,7 +99,7 @@ public class ZapperInteractionHandler { tag.remove("BlockData"); else tag.put("BlockData", data); - player.world.playSound(player, player.getPosition(), AllSoundEvents.BLOCKZAPPER_CONFIRM.get(), + player.world.playSound(null, player.getPosition(), AllSoundEvents.BLOCKZAPPER_CONFIRM.get(), SoundCategory.BLOCKS, 0.5f, 0.8f); return true; diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index 5f5e8c978..a609e7955 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -19,6 +19,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.tra import com.simibubi.create.content.contraptions.components.turntable.TurntableHandler; import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorHandler; import com.simibubi.create.content.curiosities.tools.ExtendoGripRenderHandler; +import com.simibubi.create.content.curiosities.zapper.ZapperItem; import com.simibubi.create.content.curiosities.zapper.ZapperRenderHandler; import com.simibubi.create.content.curiosities.zapper.blockzapper.BlockzapperRenderHandler; import com.simibubi.create.content.curiosities.zapper.terrainzapper.WorldshaperRenderHandler; @@ -26,6 +27,8 @@ import com.simibubi.create.content.logistics.block.mechanicalArm.ArmInteractionP import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.item.TooltipHelper; +import com.simibubi.create.foundation.networking.AllPackets; +import com.simibubi.create.foundation.networking.LeftClickPacket; import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; import com.simibubi.create.foundation.tileEntity.behaviour.edgeInteraction.EdgeInteractionRenderer; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer; @@ -53,6 +56,7 @@ import net.minecraftforge.event.TickEvent.ClientTickEvent; import net.minecraftforge.event.TickEvent.Phase; import net.minecraftforge.event.TickEvent.RenderTickEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @@ -216,4 +220,12 @@ public class ClientEvents { } } + @SubscribeEvent + public static void leftClickEmpty(PlayerInteractEvent.LeftClickEmpty event) { + ItemStack stack = event.getItemStack(); + if (stack.getItem() instanceof ZapperItem) { + AllPackets.channel.sendToServer(new LeftClickPacket()); + } + } + } diff --git a/src/main/java/com/simibubi/create/events/CommonEvents.java b/src/main/java/com/simibubi/create/events/CommonEvents.java index e3dd7bf80..e8422f75f 100644 --- a/src/main/java/com/simibubi/create/events/CommonEvents.java +++ b/src/main/java/com/simibubi/create/events/CommonEvents.java @@ -8,6 +8,8 @@ import com.simibubi.create.content.contraptions.components.structureMovement.tra import com.simibubi.create.content.contraptions.fluids.recipe.FluidTransferRecipes; import com.simibubi.create.content.contraptions.fluids.recipe.PotionMixingRecipeManager; import com.simibubi.create.content.contraptions.wrench.WrenchItem; +import com.simibubi.create.content.curiosities.zapper.ZapperInteractionHandler; +import com.simibubi.create.content.curiosities.zapper.ZapperItem; import com.simibubi.create.content.schematics.ServerSchematicLoader; import com.simibubi.create.foundation.command.AllCommands; import com.simibubi.create.foundation.fluid.FluidHelper; @@ -19,7 +21,9 @@ import com.simibubi.create.foundation.utility.recipe.RecipeFinder; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.fluid.IFluidState; +import net.minecraft.item.ItemStack; import net.minecraft.resources.IReloadableResourceManager; import net.minecraft.tags.FluidTags; import net.minecraft.util.Direction; @@ -159,4 +163,11 @@ public class CommonEvents { CapabilityMinecartController.startTracking(event); } + public static void leftClickEmpty(ServerPlayerEntity player) { + ItemStack stack = player.getHeldItemMainhand(); + if (stack.getItem() instanceof ZapperItem) { + ZapperInteractionHandler.trySelect(stack, player); + } + } + } diff --git a/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java b/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java index 0d4dbf5fa..94222fb36 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java +++ b/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java @@ -64,6 +64,7 @@ public enum AllPackets { MINECART_COUPLING_CREATION(CouplingCreationPacket.class, CouplingCreationPacket::new), INSTANT_SCHEMATIC(InstantSchematicPacket.class, InstantSchematicPacket::new), SYNC_SCHEMATIC(SchematicSyncPacket.class, SchematicSyncPacket::new), + LEFT_CLICK(LeftClickPacket.class, LeftClickPacket::new), // Server to Client SYMMETRY_EFFECT(SymmetryEffectPacket.class, SymmetryEffectPacket::new), diff --git a/src/main/java/com/simibubi/create/foundation/networking/LeftClickPacket.java b/src/main/java/com/simibubi/create/foundation/networking/LeftClickPacket.java new file mode 100644 index 000000000..8ce69099b --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/networking/LeftClickPacket.java @@ -0,0 +1,32 @@ +package com.simibubi.create.foundation.networking; + +import java.util.function.Supplier; + +import com.simibubi.create.events.CommonEvents; + +import net.minecraft.network.PacketBuffer; +import net.minecraftforge.fml.network.NetworkDirection; +import net.minecraftforge.fml.network.NetworkEvent.Context; + +public class LeftClickPacket extends SimplePacketBase { + + public LeftClickPacket() { + } + + LeftClickPacket(PacketBuffer buffer) { + } + + @Override + public void write(PacketBuffer buffer) { + } + + @Override + public void handle(Supplier context) { + Context ctx = context.get(); + if (ctx.getDirection() != NetworkDirection.PLAY_TO_SERVER) + return; + ctx.enqueueWork(() -> CommonEvents.leftClickEmpty(ctx.getSender())); + ctx.setPacketHandled(true); + } + +} From f3053d7e45dcf6423703beaa7ec2071d843ecd3b Mon Sep 17 00:00:00 2001 From: Snownee Date: Sat, 12 Dec 2020 19:39:02 +0800 Subject: [PATCH 6/7] Remove unused imports --- .../components/deployer/DeployerTileEntity.java | 2 -- .../structureMovement/bearing/BearingContraption.java | 1 - .../fluids/recipe/FluidTransferRecipes.java | 2 -- .../relays/belt/transport/BeltInventory.java | 1 - .../relays/elementary/AbstractShaftBlock.java | 11 ----------- 5 files changed, 17 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java index 2f043502d..65beab8e3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java @@ -36,9 +36,7 @@ import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; -import net.minecraftforge.items.wrapper.InvWrapper; public class DeployerTileEntity extends KineticTileEntity { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingContraption.java index 63f141114..76db5bd8b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingContraption.java @@ -6,7 +6,6 @@ import com.simibubi.create.AllTags.AllBlockTags; import com.simibubi.create.content.contraptions.components.structureMovement.AllContraptionTypes; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; -import net.minecraft.client.renderer.FaceDirection; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/FluidTransferRecipes.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/FluidTransferRecipes.java index 975989cdb..9102302d9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/FluidTransferRecipes.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/FluidTransferRecipes.java @@ -3,8 +3,6 @@ package com.simibubi.create.content.contraptions.fluids.recipe; import java.util.ArrayList; import java.util.List; -import com.simibubi.create.content.contraptions.fluids.actors.FillingRecipe; - import net.minecraft.client.resources.ReloadListener; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltInventory.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltInventory.java index cd070dcbb..654528425 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltInventory.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltInventory.java @@ -8,7 +8,6 @@ import java.util.LinkedList; import java.util.List; import java.util.function.Function; -import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.relays.belt.BeltBlock; import com.simibubi.create.content.contraptions.relays.belt.BeltHelper; import com.simibubi.create.content.contraptions.relays.belt.BeltSlope; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/AbstractShaftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/AbstractShaftBlock.java index 9883870d4..210ba1029 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/AbstractShaftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/AbstractShaftBlock.java @@ -2,12 +2,8 @@ package com.simibubi.create.content.contraptions.relays.elementary; import java.util.Optional; -import com.simibubi.create.AllBlocks; -import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; -import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; -import com.simibubi.create.content.contraptions.relays.encased.EncasedShaftBlock; import com.simibubi.create.content.contraptions.wrench.IWrenchableWithBracket; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; @@ -16,11 +12,9 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.IWaterLoggable; import net.minecraft.block.material.PushReaction; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.Fluids; import net.minecraft.fluid.IFluidState; import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.state.StateContainer.Builder; @@ -29,12 +23,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; -import net.minecraft.util.Hand; -import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; From 45465fb69b67ca3837c273b5412897d36e6bfb66 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Sat, 12 Dec 2020 17:33:16 +0100 Subject: [PATCH 7/7] Minor adjustments - Fluid tanks are not nbt safe - Mekanism uses reversed ids --- src/generated/resources/.cache/cache | 21 ++++++------ ...json => ingot_osmium_compat_mekanism.json} | 4 +-- ...sm.json => ingot_tin_compat_mekanism.json} | 4 +-- ...json => ingot_osmium_compat_mekanism.json} | 4 +-- ...sm.json => ingot_tin_compat_mekanism.json} | 4 +-- ...json => ingot_osmium_compat_mekanism.json} | 2 +- ...sm.json => ingot_tin_compat_mekanism.json} | 2 +- ...json => ingot_osmium_compat_mekanism.json} | 2 +- ...sm.json => ingot_tin_compat_mekanism.json} | 2 +- .../mekanism/crushed_osmium_ore.json | 4 +-- .../splashing/mekanism/crushed_tin_ore.json | 4 +-- .../data/create/tags/blocks/safe_nbt.json | 1 - .../java/com/simibubi/create/AllBlocks.java | 1 - .../processing/ProcessingRecipeBuilder.java | 4 +-- .../data/recipe/CreateRecipeProvider.java | 2 -- .../create/foundation/data/recipe/Mods.java | 34 +++++++++++++++++++ .../data/recipe/StandardRecipeGen.java | 15 +++++--- .../data/recipe/WashingRecipeGen.java | 21 ++++++++---- 18 files changed, 88 insertions(+), 43 deletions(-) rename src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/{osmium_ingot_compat_mekanism.json => ingot_osmium_compat_mekanism.json} (80%) rename src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/{tin_ingot_compat_mekanism.json => ingot_tin_compat_mekanism.json} (81%) rename src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/{osmium_ingot_compat_mekanism.json => ingot_osmium_compat_mekanism.json} (80%) rename src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/{tin_ingot_compat_mekanism.json => ingot_tin_compat_mekanism.json} (81%) rename src/generated/resources/data/create/recipes/blasting/{osmium_ingot_compat_mekanism.json => ingot_osmium_compat_mekanism.json} (86%) rename src/generated/resources/data/create/recipes/blasting/{tin_ingot_compat_mekanism.json => ingot_tin_compat_mekanism.json} (87%) rename src/generated/resources/data/create/recipes/smelting/{osmium_ingot_compat_mekanism.json => ingot_osmium_compat_mekanism.json} (86%) rename src/generated/resources/data/create/recipes/smelting/{tin_ingot_compat_mekanism.json => ingot_tin_compat_mekanism.json} (87%) create mode 100644 src/main/java/com/simibubi/create/foundation/data/recipe/Mods.java diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 9182811c0..6427baf4f 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -1577,20 +1577,20 @@ a135eec618e448f440d9f42cc7a3e6c63fc45a71 data/create/advancements/overstressed.j 2e253226c408dffb9dfb828b846f70ebd1cfb16e data/create/advancements/recipes/building_blocks/blasting/ingot_aluminum_compat_immersiveengineering.json 3f022f89aeb5034f2292ca71daa9f311e8af40ff data/create/advancements/recipes/building_blocks/blasting/ingot_lead_compat_immersiveengineering.json b7232d0e659de3f227289a5275f76a5a2ec578bb data/create/advancements/recipes/building_blocks/blasting/ingot_nickel_compat_immersiveengineering.json +1f527bbe24e79f3f149c06dd8be7016eea42b4e9 data/create/advancements/recipes/building_blocks/blasting/ingot_osmium_compat_mekanism.json bf68b12cf828b64f5bb407bba6cf6ced8578327c data/create/advancements/recipes/building_blocks/blasting/ingot_silver_compat_immersiveengineering.json +fc07b75f81782fa06990c7eb7febc635621df91a data/create/advancements/recipes/building_blocks/blasting/ingot_tin_compat_mekanism.json 84963b1e8eb81dd20df6a9680028f8b76fef2bae data/create/advancements/recipes/building_blocks/blasting/ingot_uranium_compat_immersiveengineering.json 744d8831fde05ee2598ccde10f9289512c45d55b data/create/advancements/recipes/building_blocks/blasting/lead_ingot_compat_mysticalworld.json 4ef0ac97acddee1c49a0deb402b43feb40af1dc6 data/create/advancements/recipes/building_blocks/blasting/lead_ingot_compat_silents_mechanisms.json 25c6e6736da3a529c4cfb384a2dba707f946ce22 data/create/advancements/recipes/building_blocks/blasting/lead_ingot_compat_thermal.json 6a7c767957b8c1827ad58210b37321a2a6bb4018 data/create/advancements/recipes/building_blocks/blasting/nickel_ingot_compat_silents_mechanisms.json e2475d1fad9aaa82e99415a2a5d07a2343ce84a6 data/create/advancements/recipes/building_blocks/blasting/nickel_ingot_compat_thermal.json -075d793d172da2500e591af050176b1d3a0d26aa data/create/advancements/recipes/building_blocks/blasting/osmium_ingot_compat_mekanism.json f994f545e3a1990448e852c556d94f7eaf9954a0 data/create/advancements/recipes/building_blocks/blasting/platinum_ingot_compat_silents_mechanisms.json 85b1a8c173ca7e5421f9d2bd0f3f997c8431d15c data/create/advancements/recipes/building_blocks/blasting/quicksilver_ingot_compat_mysticalworld.json 9b48187d487ddabcad4f4e4f75b67813f26a746d data/create/advancements/recipes/building_blocks/blasting/silver_ingot_compat_mysticalworld.json 96bf046af4d23dddcca5915cfbfc04a46b0d2912 data/create/advancements/recipes/building_blocks/blasting/silver_ingot_compat_silents_mechanisms.json 96a3efecf663433123861136467d9fa28ea26a1e data/create/advancements/recipes/building_blocks/blasting/silver_ingot_compat_thermal.json -0c12fee4021c8095385f3df008bd187dd0baea0e data/create/advancements/recipes/building_blocks/blasting/tin_ingot_compat_mekanism.json 506ade70e5bcc111323823f195c3abe4869d4c69 data/create/advancements/recipes/building_blocks/blasting/tin_ingot_compat_mysticalworld.json a75f1162ac89cd50a1ca8e525dd059fb359a6550 data/create/advancements/recipes/building_blocks/blasting/tin_ingot_compat_silents_mechanisms.json 230c3da350aa45524712d5dd28b84aa59b2883e9 data/create/advancements/recipes/building_blocks/blasting/tin_ingot_compat_thermal.json @@ -1603,20 +1603,20 @@ d192e3f2185ad3cd8cd64f639dd6395aaec89563 data/create/advancements/recipes/buildi 43d3d2c952f54fdf73e4df422554451ceff899d3 data/create/advancements/recipes/building_blocks/smelting/ingot_aluminum_compat_immersiveengineering.json 48439dd60a0a79f0ab6accc3773a3a8b64b7396e data/create/advancements/recipes/building_blocks/smelting/ingot_lead_compat_immersiveengineering.json 7d8325768f249a1ac5d79d60eb58b6eb32c51234 data/create/advancements/recipes/building_blocks/smelting/ingot_nickel_compat_immersiveengineering.json +c2a565459bc3a2b6aa1770e36295373f886b27b3 data/create/advancements/recipes/building_blocks/smelting/ingot_osmium_compat_mekanism.json d192714def52e54a58ae96f7592055e925d88bb8 data/create/advancements/recipes/building_blocks/smelting/ingot_silver_compat_immersiveengineering.json +e922be59fa4cb031020041f54d06d361f090e6a8 data/create/advancements/recipes/building_blocks/smelting/ingot_tin_compat_mekanism.json 6f0b67b3f49da5c3102a48e68e6c4f834d08b0e2 data/create/advancements/recipes/building_blocks/smelting/ingot_uranium_compat_immersiveengineering.json 847dc1a0bd2275a11ff02624b98cf7fdf0d8f47b data/create/advancements/recipes/building_blocks/smelting/lead_ingot_compat_mysticalworld.json 79d5f852e9e48e9e8ff5cd42890fbc9ad29e9712 data/create/advancements/recipes/building_blocks/smelting/lead_ingot_compat_silents_mechanisms.json cdf4697b74e4a6add2ea41825733f4d9ff2b83e6 data/create/advancements/recipes/building_blocks/smelting/lead_ingot_compat_thermal.json 2be47fb3a33a7e92705767eb255d7586de56f4a5 data/create/advancements/recipes/building_blocks/smelting/nickel_ingot_compat_silents_mechanisms.json 6dff1a0b51d7a81d6a4e8f4fd8fa558f9befea1b data/create/advancements/recipes/building_blocks/smelting/nickel_ingot_compat_thermal.json -1cebfdc52bfa34515144e651ba5a6d65e97a57a9 data/create/advancements/recipes/building_blocks/smelting/osmium_ingot_compat_mekanism.json 70d98f34671f09331f6765447b95cd00c3b8d4e5 data/create/advancements/recipes/building_blocks/smelting/platinum_ingot_compat_silents_mechanisms.json 8e5beb04ea241145f4e34320cba1745fd9d386e6 data/create/advancements/recipes/building_blocks/smelting/quicksilver_ingot_compat_mysticalworld.json 60fd25d05bfe101d83e3a13678cca9940665771c data/create/advancements/recipes/building_blocks/smelting/silver_ingot_compat_mysticalworld.json 29685c6f05455faa657cb51433352d005b798cf4 data/create/advancements/recipes/building_blocks/smelting/silver_ingot_compat_silents_mechanisms.json 05b68914ac2fb0da7609a32369bf739e28256e41 data/create/advancements/recipes/building_blocks/smelting/silver_ingot_compat_thermal.json -787158553e0eac72dffffed787d2a2529754e8b0 data/create/advancements/recipes/building_blocks/smelting/tin_ingot_compat_mekanism.json 7677ff00e70a92e9c4b9035b0d706e0c255b7e26 data/create/advancements/recipes/building_blocks/smelting/tin_ingot_compat_mysticalworld.json e98e6372bb065a0d82f44bea7169e8f40bd40920 data/create/advancements/recipes/building_blocks/smelting/tin_ingot_compat_silents_mechanisms.json c33e122c534a7a134f69faa36446ce7564d8a705 data/create/advancements/recipes/building_blocks/smelting/tin_ingot_compat_thermal.json @@ -2634,7 +2634,9 @@ d9021504be855cd2d4d91503a82b84233052adb0 data/create/recipes/blasting/gold_ingot f2307aa01ddf7accb3fe19c4d3f9b46dec1acf97 data/create/recipes/blasting/ingot_aluminum_compat_immersiveengineering.json 8315c188802bd64f7226a9e942be45173112c7ac data/create/recipes/blasting/ingot_lead_compat_immersiveengineering.json 368fd45a8e9d5d2fc0e1f8af1ffb48984b85601c data/create/recipes/blasting/ingot_nickel_compat_immersiveengineering.json +d167828a4fe3a20d765831c1df433fc3c8efeab8 data/create/recipes/blasting/ingot_osmium_compat_mekanism.json 9b5a388f0f8a3a8fae9e6bbf6460913b7c1f6fe7 data/create/recipes/blasting/ingot_silver_compat_immersiveengineering.json +7997e66e5e7aebe2c6da764902d78e3bf5f4c530 data/create/recipes/blasting/ingot_tin_compat_mekanism.json ba7498521a1e07b9bd46ec230d952fb232eaaba0 data/create/recipes/blasting/ingot_uranium_compat_immersiveengineering.json 69cda0f54c47cd44c296608cc379db855602410f data/create/recipes/blasting/iron_ingot_from_crushed.json 65a44735ffa0c3e471a1df30b987d8c3cf1764fc data/create/recipes/blasting/lead_ingot_compat_mysticalworld.json @@ -2642,13 +2644,11 @@ aeb345e5b4c266ac9e2ef6929b153cb535468d01 data/create/recipes/blasting/lead_ingot 606b46f5af59d7bd71462807ceb95edebb09a07e data/create/recipes/blasting/lead_ingot_compat_thermal.json 91691cb14043e8222c38a18bb103f874b39d30b1 data/create/recipes/blasting/nickel_ingot_compat_silents_mechanisms.json bd26be2cc7044537628e10ff057a7ce78b720025 data/create/recipes/blasting/nickel_ingot_compat_thermal.json -453a6602d70bbd30e13033565eb6ce6fa8fde194 data/create/recipes/blasting/osmium_ingot_compat_mekanism.json a99be7aae1706cce96a3b6fadd38295bb53d10b7 data/create/recipes/blasting/platinum_ingot_compat_silents_mechanisms.json 3419a88787e331d59e0da8b9084d8c8a72a84ec0 data/create/recipes/blasting/quicksilver_ingot_compat_mysticalworld.json 84b73c8ef561ab0ecc2954cd86160595975811d6 data/create/recipes/blasting/silver_ingot_compat_mysticalworld.json 3ce20049c90fc3ce446efac1d166b5e1b2855980 data/create/recipes/blasting/silver_ingot_compat_silents_mechanisms.json c49e88f38ad624a56865bb293e2b81da09ebdf37 data/create/recipes/blasting/silver_ingot_compat_thermal.json -3d0c3e23be0d237a37a1c9945a7d0021248ffc50 data/create/recipes/blasting/tin_ingot_compat_mekanism.json 44a31af2877854f1b22691eb9b0dd831f80628f0 data/create/recipes/blasting/tin_ingot_compat_mysticalworld.json dd44cf0e09b1b34b4d2c254ab3d10d05a02717aa data/create/recipes/blasting/tin_ingot_compat_silents_mechanisms.json 539c30c3c06489815b0a356735a0dd42ac432b26 data/create/recipes/blasting/tin_ingot_compat_thermal.json @@ -3327,7 +3327,9 @@ b032c79090adad2262ae94609e0b3747327d51a2 data/create/recipes/smelting/gold_ingot 5cd79470a32c77fc7347a04ad2096df08769a59f data/create/recipes/smelting/ingot_aluminum_compat_immersiveengineering.json ce34f496dca15378b5e4b21c70505e9d1184848d data/create/recipes/smelting/ingot_lead_compat_immersiveengineering.json 428b3981a13c63381115384496d89375e3d20837 data/create/recipes/smelting/ingot_nickel_compat_immersiveengineering.json +36a8f88fe3a9b09674bbba99a8f41c8ac5542cdb data/create/recipes/smelting/ingot_osmium_compat_mekanism.json 456ec25989f6d882fc931764341d8217386cf9ab data/create/recipes/smelting/ingot_silver_compat_immersiveengineering.json +d2ab440819e4534f717315b7a737bcc2883072ed data/create/recipes/smelting/ingot_tin_compat_mekanism.json 7ca0d75c667e171f2abc5faeb96ef17282b130ac data/create/recipes/smelting/ingot_uranium_compat_immersiveengineering.json fe3e4c244c34aa6948243fabd6b42f04f80d4992 data/create/recipes/smelting/iron_ingot_from_crushed.json 4a1e8041f44bb36d29ec624fc78bdfd0ac875953 data/create/recipes/smelting/lead_ingot_compat_mysticalworld.json @@ -3336,7 +3338,6 @@ fe3e4c244c34aa6948243fabd6b42f04f80d4992 data/create/recipes/smelting/iron_ingot bf0e5df5a88e583e39a4e14b006cbf33b99611e1 data/create/recipes/smelting/limestone.json 6a9ef35f3e5fc37602d887687924547ea77bffcd data/create/recipes/smelting/nickel_ingot_compat_silents_mechanisms.json 76b02e4111687e1013a2ae0d171fb01f5787626f data/create/recipes/smelting/nickel_ingot_compat_thermal.json -18d0f016d3dfa08789438e074626258932404898 data/create/recipes/smelting/osmium_ingot_compat_mekanism.json 86725fc9711c6e7971a4b396aa089ad191089bb3 data/create/recipes/smelting/platinum_ingot_compat_silents_mechanisms.json 92c308baf81fe2c8a63c90b0dfc7cf8cc2183c4b data/create/recipes/smelting/quicksilver_ingot_compat_mysticalworld.json 2c230522bb0946bde6a51442cb15c5efeea99b15 data/create/recipes/smelting/scoria.json @@ -3344,7 +3345,6 @@ f5317c85a9e10a5f9346e13aef8bb364a5203346 data/create/recipes/smelting/scoria_fro 96c2b799b812e469bb1785200d68c1e8f8cfacf7 data/create/recipes/smelting/silver_ingot_compat_mysticalworld.json 21c5fbce648ca8812d4c75e3c71934bc269e2216 data/create/recipes/smelting/silver_ingot_compat_silents_mechanisms.json c01f5fdef7419a2da5e0f24d61637ec35a006fd1 data/create/recipes/smelting/silver_ingot_compat_thermal.json -85116bc01ff8513f9e3122af0dcd32fbcd645828 data/create/recipes/smelting/tin_ingot_compat_mekanism.json 3e977195d8c825365753eb609e3bccca3302a0a3 data/create/recipes/smelting/tin_ingot_compat_mysticalworld.json 07bc2816c79de888e8f8f5954c6f917f6ab37176 data/create/recipes/smelting/tin_ingot_compat_silents_mechanisms.json 8d6139a5463119f2930476c429c175e14c7c7a58 data/create/recipes/smelting/tin_ingot_compat_thermal.json @@ -3376,8 +3376,8 @@ a43d7c9a6369a48ef7d1396f2c11dc1f3704a61e data/create/recipes/splashing/lime_conc 67d97de29a9075a7ba8edb6e47c997b02600557e data/create/recipes/splashing/limestone.json 862f7b68bb107d7c4ecc82ddd10c788eb0a07b03 data/create/recipes/splashing/magenta_concrete_powder.json 004e05fed3684de8603905d9c9381cbbd789a882 data/create/recipes/splashing/magma_block.json -11e61710da12d73aa86660c1ea208f9533a7882c data/create/recipes/splashing/mekanism/crushed_osmium_ore.json -370c28fb8f2da4fbbb498ee3de11d1d21252957b data/create/recipes/splashing/mekanism/crushed_tin_ore.json +f627573eefe0353b32d7c48abd7dcbcf13613004 data/create/recipes/splashing/mekanism/crushed_osmium_ore.json +a1828cb3c934c4146008d1d10d04adb80a80ac94 data/create/recipes/splashing/mekanism/crushed_tin_ore.json ea4a295149091e3b4b8388cb9d4dd2ab509d666e data/create/recipes/splashing/mysticalworld/crushed_lead_ore.json 1ecac82da1ccc381e303dc64e8033c13cf66fb59 data/create/recipes/splashing/mysticalworld/crushed_quicksilver_ore.json fd1751c804bfc156c7bd97955fabb19f9a4b94ec data/create/recipes/splashing/mysticalworld/crushed_silver_ore.json @@ -3431,6 +3431,7 @@ d3fdb8ece6cb072a93ddb64a0baad5ac952117a4 data/create/recipes/weathered_limestone eedf31af7134d03656c5fa57229982f9c5bed07c data/create/tags/blocks/brittle.json 13b55d6e905a02403d2e95e9ba2357f99c5f2241 data/create/tags/blocks/fan_heaters.json 3bc64e3a1e7980237435b1770a9ba2102d57fcd4 data/create/tags/blocks/fan_transparent.json +c5439249176a869a6d1537da46922d6f6c0c2186 data/create/tags/blocks/safe_nbt.json c9ac7e3e5ec18554e7184168d65e9b8e44ef5610 data/create/tags/blocks/sails.json 6cdeeac1689f7b5bfd9bc40b462143d8eaf3ad0b data/create/tags/blocks/seats.json 50936b211d94167a35ec78c89954082a336b6269 data/create/tags/blocks/valve_handles.json diff --git a/src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/osmium_ingot_compat_mekanism.json b/src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/ingot_osmium_compat_mekanism.json similarity index 80% rename from src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/osmium_ingot_compat_mekanism.json rename to src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/ingot_osmium_compat_mekanism.json index 1aa1197f7..c2a16b13e 100644 --- a/src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/osmium_ingot_compat_mekanism.json +++ b/src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/ingot_osmium_compat_mekanism.json @@ -2,7 +2,7 @@ "parent": "minecraft:recipes/root", "rewards": { "recipes": [ - "create:blasting/osmium_ingot_compat_mekanism" + "create:blasting/ingot_osmium_compat_mekanism" ] }, "criteria": { @@ -19,7 +19,7 @@ "has_the_recipe": { "trigger": "minecraft:recipe_unlocked", "conditions": { - "recipe": "create:blasting/osmium_ingot_compat_mekanism" + "recipe": "create:blasting/ingot_osmium_compat_mekanism" } } }, diff --git a/src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/tin_ingot_compat_mekanism.json b/src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/ingot_tin_compat_mekanism.json similarity index 81% rename from src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/tin_ingot_compat_mekanism.json rename to src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/ingot_tin_compat_mekanism.json index 1c1029415..a3b8566b0 100644 --- a/src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/tin_ingot_compat_mekanism.json +++ b/src/generated/resources/data/create/advancements/recipes/building_blocks/blasting/ingot_tin_compat_mekanism.json @@ -2,7 +2,7 @@ "parent": "minecraft:recipes/root", "rewards": { "recipes": [ - "create:blasting/tin_ingot_compat_mekanism" + "create:blasting/ingot_tin_compat_mekanism" ] }, "criteria": { @@ -19,7 +19,7 @@ "has_the_recipe": { "trigger": "minecraft:recipe_unlocked", "conditions": { - "recipe": "create:blasting/tin_ingot_compat_mekanism" + "recipe": "create:blasting/ingot_tin_compat_mekanism" } } }, diff --git a/src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/osmium_ingot_compat_mekanism.json b/src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/ingot_osmium_compat_mekanism.json similarity index 80% rename from src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/osmium_ingot_compat_mekanism.json rename to src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/ingot_osmium_compat_mekanism.json index 8ef5a05d5..4719c363d 100644 --- a/src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/osmium_ingot_compat_mekanism.json +++ b/src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/ingot_osmium_compat_mekanism.json @@ -2,7 +2,7 @@ "parent": "minecraft:recipes/root", "rewards": { "recipes": [ - "create:smelting/osmium_ingot_compat_mekanism" + "create:smelting/ingot_osmium_compat_mekanism" ] }, "criteria": { @@ -19,7 +19,7 @@ "has_the_recipe": { "trigger": "minecraft:recipe_unlocked", "conditions": { - "recipe": "create:smelting/osmium_ingot_compat_mekanism" + "recipe": "create:smelting/ingot_osmium_compat_mekanism" } } }, diff --git a/src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/tin_ingot_compat_mekanism.json b/src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/ingot_tin_compat_mekanism.json similarity index 81% rename from src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/tin_ingot_compat_mekanism.json rename to src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/ingot_tin_compat_mekanism.json index be2f789a2..2b25cbd3e 100644 --- a/src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/tin_ingot_compat_mekanism.json +++ b/src/generated/resources/data/create/advancements/recipes/building_blocks/smelting/ingot_tin_compat_mekanism.json @@ -2,7 +2,7 @@ "parent": "minecraft:recipes/root", "rewards": { "recipes": [ - "create:smelting/tin_ingot_compat_mekanism" + "create:smelting/ingot_tin_compat_mekanism" ] }, "criteria": { @@ -19,7 +19,7 @@ "has_the_recipe": { "trigger": "minecraft:recipe_unlocked", "conditions": { - "recipe": "create:smelting/tin_ingot_compat_mekanism" + "recipe": "create:smelting/ingot_tin_compat_mekanism" } } }, diff --git a/src/generated/resources/data/create/recipes/blasting/osmium_ingot_compat_mekanism.json b/src/generated/resources/data/create/recipes/blasting/ingot_osmium_compat_mekanism.json similarity index 86% rename from src/generated/resources/data/create/recipes/blasting/osmium_ingot_compat_mekanism.json rename to src/generated/resources/data/create/recipes/blasting/ingot_osmium_compat_mekanism.json index 65bbfe190..f191d5906 100644 --- a/src/generated/resources/data/create/recipes/blasting/osmium_ingot_compat_mekanism.json +++ b/src/generated/resources/data/create/recipes/blasting/ingot_osmium_compat_mekanism.json @@ -3,7 +3,7 @@ "ingredient": { "item": "create:crushed_osmium_ore" }, - "result": "mekanism:osmium_ingot", + "result": "mekanism:ingot_osmium", "experience": 0.1, "cookingtime": 100, "conditions": [ diff --git a/src/generated/resources/data/create/recipes/blasting/tin_ingot_compat_mekanism.json b/src/generated/resources/data/create/recipes/blasting/ingot_tin_compat_mekanism.json similarity index 87% rename from src/generated/resources/data/create/recipes/blasting/tin_ingot_compat_mekanism.json rename to src/generated/resources/data/create/recipes/blasting/ingot_tin_compat_mekanism.json index 182dec6ef..0bc4fe4f7 100644 --- a/src/generated/resources/data/create/recipes/blasting/tin_ingot_compat_mekanism.json +++ b/src/generated/resources/data/create/recipes/blasting/ingot_tin_compat_mekanism.json @@ -3,7 +3,7 @@ "ingredient": { "item": "create:crushed_tin_ore" }, - "result": "mekanism:tin_ingot", + "result": "mekanism:ingot_tin", "experience": 0.1, "cookingtime": 100, "conditions": [ diff --git a/src/generated/resources/data/create/recipes/smelting/osmium_ingot_compat_mekanism.json b/src/generated/resources/data/create/recipes/smelting/ingot_osmium_compat_mekanism.json similarity index 86% rename from src/generated/resources/data/create/recipes/smelting/osmium_ingot_compat_mekanism.json rename to src/generated/resources/data/create/recipes/smelting/ingot_osmium_compat_mekanism.json index b522da67c..56f95d5f3 100644 --- a/src/generated/resources/data/create/recipes/smelting/osmium_ingot_compat_mekanism.json +++ b/src/generated/resources/data/create/recipes/smelting/ingot_osmium_compat_mekanism.json @@ -3,7 +3,7 @@ "ingredient": { "item": "create:crushed_osmium_ore" }, - "result": "mekanism:osmium_ingot", + "result": "mekanism:ingot_osmium", "experience": 0.1, "cookingtime": 200, "conditions": [ diff --git a/src/generated/resources/data/create/recipes/smelting/tin_ingot_compat_mekanism.json b/src/generated/resources/data/create/recipes/smelting/ingot_tin_compat_mekanism.json similarity index 87% rename from src/generated/resources/data/create/recipes/smelting/tin_ingot_compat_mekanism.json rename to src/generated/resources/data/create/recipes/smelting/ingot_tin_compat_mekanism.json index c5f7205c7..476cd4942 100644 --- a/src/generated/resources/data/create/recipes/smelting/tin_ingot_compat_mekanism.json +++ b/src/generated/resources/data/create/recipes/smelting/ingot_tin_compat_mekanism.json @@ -3,7 +3,7 @@ "ingredient": { "item": "create:crushed_tin_ore" }, - "result": "mekanism:tin_ingot", + "result": "mekanism:ingot_tin", "experience": 0.1, "cookingtime": 200, "conditions": [ diff --git a/src/generated/resources/data/create/recipes/splashing/mekanism/crushed_osmium_ore.json b/src/generated/resources/data/create/recipes/splashing/mekanism/crushed_osmium_ore.json index a01ea54c9..b05c11800 100644 --- a/src/generated/resources/data/create/recipes/splashing/mekanism/crushed_osmium_ore.json +++ b/src/generated/resources/data/create/recipes/splashing/mekanism/crushed_osmium_ore.json @@ -7,11 +7,11 @@ ], "results": [ { - "item": "mekanism:osmium_nugget", + "item": "mekanism:nugget_osmium", "count": 10 }, { - "item": "mekanism:osmium_nugget", + "item": "mekanism:nugget_osmium", "count": 5, "chance": 0.5 } diff --git a/src/generated/resources/data/create/recipes/splashing/mekanism/crushed_tin_ore.json b/src/generated/resources/data/create/recipes/splashing/mekanism/crushed_tin_ore.json index 4f04dbf57..21f9b3556 100644 --- a/src/generated/resources/data/create/recipes/splashing/mekanism/crushed_tin_ore.json +++ b/src/generated/resources/data/create/recipes/splashing/mekanism/crushed_tin_ore.json @@ -7,11 +7,11 @@ ], "results": [ { - "item": "mekanism:tin_nugget", + "item": "mekanism:nugget_tin", "count": 10 }, { - "item": "mekanism:tin_nugget", + "item": "mekanism:nugget_tin", "count": 5, "chance": 0.5 } diff --git a/src/generated/resources/data/create/tags/blocks/safe_nbt.json b/src/generated/resources/data/create/tags/blocks/safe_nbt.json index e0049a6df..cd67c1292 100644 --- a/src/generated/resources/data/create/tags/blocks/safe_nbt.json +++ b/src/generated/resources/data/create/tags/blocks/safe_nbt.json @@ -2,7 +2,6 @@ "replace": false, "values": [ "create:creative_motor", - "create:fluid_tank", "create:creative_fluid_tank", "create:mechanical_piston", "create:sticky_mechanical_piston", diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 91864933b..1b9fcc141 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -593,7 +593,6 @@ 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)) diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeBuilder.java b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeBuilder.java index cd30fdcd8..386e6ecad 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeBuilder.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeBuilder.java @@ -156,8 +156,8 @@ public class ProcessingRecipeBuilder> { return this; } - public ProcessingRecipeBuilder output(float chance, String modId, String registryName, int amount) { - params.results.add(new ProcessingOutput(Pair.of(new ResourceLocation(modId, registryName), amount), chance)); + public ProcessingRecipeBuilder output(float chance, ResourceLocation registryName, int amount) { + params.results.add(new ProcessingOutput(Pair.of(registryName, amount), chance)); return this; } diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/CreateRecipeProvider.java b/src/main/java/com/simibubi/create/foundation/data/recipe/CreateRecipeProvider.java index 299c6ff17..035fcc2f8 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/CreateRecipeProvider.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/CreateRecipeProvider.java @@ -20,8 +20,6 @@ import net.minecraftforge.common.Tags; public abstract class CreateRecipeProvider extends RecipeProvider { - public final String MEK = "mekanism", TH = "thermal", MW = "mysticalworld", SM = "silents_mechanisms", IE = "immersiveengineering"; - final List all = new ArrayList<>(); public CreateRecipeProvider(DataGenerator p_i48262_1_) { diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/Mods.java b/src/main/java/com/simibubi/create/foundation/data/recipe/Mods.java new file mode 100644 index 000000000..500f7ae98 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/Mods.java @@ -0,0 +1,34 @@ +package com.simibubi.create.foundation.data.recipe; + +import net.minecraft.util.ResourceLocation; + +public enum Mods { + + MEK("mekanism", true), + TH("thermal", false), + MW("mysticalworld", false), + SM("silents_mechanisms", false), + IE("immersiveengineering", true) + + ; + + private String id; + private boolean reversedPrefix; + + private Mods(String id, boolean reversedPrefix) { + this.id = id; + this.reversedPrefix = reversedPrefix;} + + public ResourceLocation ingotOf(String type) { + return new ResourceLocation(id, reversedPrefix ? "ingot_" + type : type + "_ingot"); + } + + public ResourceLocation nuggetOf(String type) { + return new ResourceLocation(id, reversedPrefix ? "nugget_" + type : type + "_nugget"); + } + + public String getId() { + return id; + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java index aae5fb32d..856f55c34 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java @@ -1,5 +1,11 @@ package com.simibubi.create.foundation.data.recipe; +import static com.simibubi.create.foundation.data.recipe.Mods.IE; +import static com.simibubi.create.foundation.data.recipe.Mods.MEK; +import static com.simibubi.create.foundation.data.recipe.Mods.MW; +import static com.simibubi.create.foundation.data.recipe.Mods.SM; +import static com.simibubi.create.foundation.data.recipe.Mods.TH; + import java.util.ArrayList; import java.util.List; import java.util.function.UnaryOperator; @@ -994,10 +1000,11 @@ public class StandardRecipeGen extends CreateRecipeProvider { .inBlastFurnace(); } - GeneratedRecipe blastModdedCrushedMetal(ItemEntry ingredient, String metalName, String... mods) { - for (String modId : mods) { - String ingot = modId.equals(IE) ? "ingot_" + metalName : metalName + "_ingot"; - create(new ResourceLocation(modId, ingot)).withSuffix("_compat_" + modId) + GeneratedRecipe blastModdedCrushedMetal(ItemEntry ingredient, String metalName, Mods... mods) { + for (Mods mod : mods) { + ResourceLocation ingot = mod.ingotOf(metalName); + String modId = mod.getId(); + create(ingot).withSuffix("_compat_" + modId) .whenModLoaded(modId) .viaCooking(ingredient::get) .rewardXP(.1f) diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/WashingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/WashingRecipeGen.java index d4fbc0a4d..6c726e541 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/WashingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/WashingRecipeGen.java @@ -1,5 +1,11 @@ package com.simibubi.create.foundation.data.recipe; +import static com.simibubi.create.foundation.data.recipe.Mods.IE; +import static com.simibubi.create.foundation.data.recipe.Mods.MEK; +import static com.simibubi.create.foundation.data.recipe.Mods.MW; +import static com.simibubi.create.foundation.data.recipe.Mods.SM; +import static com.simibubi.create.foundation.data.recipe.Mods.TH; + import java.util.function.Supplier; import com.simibubi.create.AllItems; @@ -15,6 +21,7 @@ import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; import net.minecraft.tags.ItemTags; import net.minecraft.util.IItemProvider; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.Tags; public class WashingRecipeGen extends ProcessingRecipeGen { @@ -86,15 +93,15 @@ public class WashingRecipeGen extends ProcessingRecipeGen { .output(.5f, nugget.get(), 5)); } - public GeneratedRecipe moddedCrushedOre(ItemEntry crushed, String metalName, String... mods) { - for (String modId : mods) { - String nugget = modId.equals(IE) ? "nugget_" + metalName : metalName + "_nugget"; - create(modId + "/" + crushed.getId() + public GeneratedRecipe moddedCrushedOre(ItemEntry crushed, String metalName, Mods... mods) { + for (Mods mod : mods) { + ResourceLocation nugget = mod.nuggetOf(metalName); + create(mod.getId() + "/" + crushed.getId() .getPath(), b -> b.withItemIngredients(Ingredient.fromItems(crushed::get)) - .output(1, modId, nugget, 10) - .output(.5f, modId, nugget, 5) - .whenModLoaded(modId)); + .output(1, nugget, 10) + .output(.5f, nugget, 5) + .whenModLoaded(mod.getId())); } return null; }