mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-11 04:22:00 +01:00
Merge pull request #533 from Creators-of-Create/mc1.15/safe-nbt
Safe NBT tag
This commit is contained in:
commit
a26988db70
21 changed files with 224 additions and 66 deletions
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"replace": false,
|
||||||
|
"values": [
|
||||||
|
"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:rope_pulley",
|
||||||
|
"create:cart_assembler",
|
||||||
|
"create:linear_chassis",
|
||||||
|
"create:secondary_linear_chassis",
|
||||||
|
"create:radial_chassis",
|
||||||
|
"create:sequenced_gearshift",
|
||||||
|
"create:rotation_speed_controller",
|
||||||
|
"create:andesite_funnel",
|
||||||
|
"create:andesite_belt_funnel",
|
||||||
|
"create:brass_funnel",
|
||||||
|
"create:brass_belt_funnel",
|
||||||
|
"create:creative_crate",
|
||||||
|
"create:redstone_link",
|
||||||
|
"create:analog_lever",
|
||||||
|
"create:adjustable_repeater",
|
||||||
|
"create:adjustable_pulse_repeater"
|
||||||
|
]
|
||||||
|
}
|
|
@ -320,6 +320,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<CreativeMotorBlock> CREATIVE_MOTOR =
|
public static final BlockEntry<CreativeMotorBlock> CREATIVE_MOTOR =
|
||||||
REGISTRATE.block("creative_motor", CreativeMotorBlock::new)
|
REGISTRATE.block("creative_motor", CreativeMotorBlock::new)
|
||||||
.initialProperties(SharedProperties::stone)
|
.initialProperties(SharedProperties::stone)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.blockstate(new CreativeMotorGenerator()::generate)
|
.blockstate(new CreativeMotorGenerator()::generate)
|
||||||
.transform(StressConfigDefaults.setCapacity(16384.0))
|
.transform(StressConfigDefaults.setCapacity(16384.0))
|
||||||
.item()
|
.item()
|
||||||
|
@ -592,6 +593,7 @@ public class AllBlocks {
|
||||||
|
|
||||||
public static final BlockEntry<FluidTankBlock> FLUID_TANK = REGISTRATE.block("fluid_tank", FluidTankBlock::regular)
|
public static final BlockEntry<FluidTankBlock> FLUID_TANK = REGISTRATE.block("fluid_tank", FluidTankBlock::regular)
|
||||||
.initialProperties(SharedProperties::softMetal)
|
.initialProperties(SharedProperties::softMetal)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.properties(Block.Properties::nonOpaque)
|
.properties(Block.Properties::nonOpaque)
|
||||||
.blockstate(new FluidTankGenerator()::generate)
|
.blockstate(new FluidTankGenerator()::generate)
|
||||||
.onRegister(CreateRegistrate.blockModel(() -> FluidTankModel::standard))
|
.onRegister(CreateRegistrate.blockModel(() -> FluidTankModel::standard))
|
||||||
|
@ -604,6 +606,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<FluidTankBlock> CREATIVE_FLUID_TANK =
|
public static final BlockEntry<FluidTankBlock> CREATIVE_FLUID_TANK =
|
||||||
REGISTRATE.block("creative_fluid_tank", FluidTankBlock::creative)
|
REGISTRATE.block("creative_fluid_tank", FluidTankBlock::creative)
|
||||||
.initialProperties(SharedProperties::softMetal)
|
.initialProperties(SharedProperties::softMetal)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.properties(Block.Properties::nonOpaque)
|
.properties(Block.Properties::nonOpaque)
|
||||||
.blockstate(new FluidTankGenerator("creative_")::generate)
|
.blockstate(new FluidTankGenerator("creative_")::generate)
|
||||||
.onRegister(CreateRegistrate.blockModel(() -> FluidTankModel::creative))
|
.onRegister(CreateRegistrate.blockModel(() -> FluidTankModel::creative))
|
||||||
|
@ -653,11 +656,13 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<MechanicalPistonBlock> MECHANICAL_PISTON =
|
public static final BlockEntry<MechanicalPistonBlock> MECHANICAL_PISTON =
|
||||||
REGISTRATE.block("mechanical_piston", MechanicalPistonBlock::normal)
|
REGISTRATE.block("mechanical_piston", MechanicalPistonBlock::normal)
|
||||||
.transform(BuilderTransformers.mechanicalPiston(PistonType.DEFAULT))
|
.transform(BuilderTransformers.mechanicalPiston(PistonType.DEFAULT))
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final BlockEntry<MechanicalPistonBlock> STICKY_MECHANICAL_PISTON =
|
public static final BlockEntry<MechanicalPistonBlock> STICKY_MECHANICAL_PISTON =
|
||||||
REGISTRATE.block("sticky_mechanical_piston", MechanicalPistonBlock::sticky)
|
REGISTRATE.block("sticky_mechanical_piston", MechanicalPistonBlock::sticky)
|
||||||
.transform(BuilderTransformers.mechanicalPiston(PistonType.STICKY))
|
.transform(BuilderTransformers.mechanicalPiston(PistonType.STICKY))
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final BlockEntry<PistonExtensionPoleBlock> PISTON_EXTENSION_POLE =
|
public static final BlockEntry<PistonExtensionPoleBlock> PISTON_EXTENSION_POLE =
|
||||||
|
@ -670,6 +675,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<MechanicalPistonHeadBlock> MECHANICAL_PISTON_HEAD =
|
public static final BlockEntry<MechanicalPistonHeadBlock> MECHANICAL_PISTON_HEAD =
|
||||||
REGISTRATE.block("mechanical_piston_head", MechanicalPistonHeadBlock::new)
|
REGISTRATE.block("mechanical_piston_head", MechanicalPistonHeadBlock::new)
|
||||||
.initialProperties(() -> Blocks.PISTON_HEAD)
|
.initialProperties(() -> Blocks.PISTON_HEAD)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.loot((p, b) -> p.registerDropping(b, PISTON_EXTENSION_POLE.get()))
|
.loot((p, b) -> p.registerDropping(b, PISTON_EXTENSION_POLE.get()))
|
||||||
.blockstate((c, p) -> BlockStateGen.directionalBlockIgnoresWaterlogged(c, p, state -> p.models()
|
.blockstate((c, p) -> BlockStateGen.directionalBlockIgnoresWaterlogged(c, p, state -> p.models()
|
||||||
.getExistingFile(p.modLoc("block/mechanical_piston/" + state.get(MechanicalPistonHeadBlock.TYPE)
|
.getExistingFile(p.modLoc("block/mechanical_piston/" + state.get(MechanicalPistonHeadBlock.TYPE)
|
||||||
|
@ -680,12 +686,14 @@ public class AllBlocks {
|
||||||
REGISTRATE.block("windmill_bearing", WindmillBearingBlock::new)
|
REGISTRATE.block("windmill_bearing", WindmillBearingBlock::new)
|
||||||
.transform(BuilderTransformers.bearing("windmill", "gearbox", true))
|
.transform(BuilderTransformers.bearing("windmill", "gearbox", true))
|
||||||
.transform(StressConfigDefaults.setCapacity(512.0))
|
.transform(StressConfigDefaults.setCapacity(512.0))
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final BlockEntry<MechanicalBearingBlock> MECHANICAL_BEARING =
|
public static final BlockEntry<MechanicalBearingBlock> MECHANICAL_BEARING =
|
||||||
REGISTRATE.block("mechanical_bearing", MechanicalBearingBlock::new)
|
REGISTRATE.block("mechanical_bearing", MechanicalBearingBlock::new)
|
||||||
.transform(BuilderTransformers.bearing("mechanical", "gearbox", false))
|
.transform(BuilderTransformers.bearing("mechanical", "gearbox", false))
|
||||||
.transform(StressConfigDefaults.setImpact(4.0))
|
.transform(StressConfigDefaults.setImpact(4.0))
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.onRegister(addMovementBehaviour(new StabilizedBearingMovementBehaviour()))
|
.onRegister(addMovementBehaviour(new StabilizedBearingMovementBehaviour()))
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
|
@ -693,10 +701,12 @@ public class AllBlocks {
|
||||||
REGISTRATE.block("clockwork_bearing", ClockworkBearingBlock::new)
|
REGISTRATE.block("clockwork_bearing", ClockworkBearingBlock::new)
|
||||||
.transform(BuilderTransformers.bearing("clockwork", "brass_gearbox", false))
|
.transform(BuilderTransformers.bearing("clockwork", "brass_gearbox", false))
|
||||||
.transform(StressConfigDefaults.setImpact(4.0))
|
.transform(StressConfigDefaults.setImpact(4.0))
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final BlockEntry<PulleyBlock> ROPE_PULLEY = REGISTRATE.block("rope_pulley", PulleyBlock::new)
|
public static final BlockEntry<PulleyBlock> ROPE_PULLEY = REGISTRATE.block("rope_pulley", PulleyBlock::new)
|
||||||
.initialProperties(SharedProperties::stone)
|
.initialProperties(SharedProperties::stone)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.blockstate(BlockStateGen.horizontalAxisBlockProvider(true))
|
.blockstate(BlockStateGen.horizontalAxisBlockProvider(true))
|
||||||
.transform(StressConfigDefaults.setImpact(4.0))
|
.transform(StressConfigDefaults.setImpact(4.0))
|
||||||
.item()
|
.item()
|
||||||
|
@ -725,7 +735,7 @@ public class AllBlocks {
|
||||||
.properties(Block.Properties::nonOpaque)
|
.properties(Block.Properties::nonOpaque)
|
||||||
.blockstate(BlockStateGen.cartAssembler())
|
.blockstate(BlockStateGen.cartAssembler())
|
||||||
.addLayer(() -> RenderType::getCutoutMipped)
|
.addLayer(() -> RenderType::getCutoutMipped)
|
||||||
.tag(BlockTags.RAILS)
|
.tag(BlockTags.RAILS, AllBlockTags.SAFE_NBT.tag)
|
||||||
.item(CartAssemblerBlockItem::new)
|
.item(CartAssemblerBlockItem::new)
|
||||||
.transform(customItemModel())
|
.transform(customItemModel())
|
||||||
.register();
|
.register();
|
||||||
|
@ -765,6 +775,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<LinearChassisBlock> LINEAR_CHASSIS =
|
public static final BlockEntry<LinearChassisBlock> LINEAR_CHASSIS =
|
||||||
REGISTRATE.block("linear_chassis", LinearChassisBlock::new)
|
REGISTRATE.block("linear_chassis", LinearChassisBlock::new)
|
||||||
.initialProperties(SharedProperties::wooden)
|
.initialProperties(SharedProperties::wooden)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.blockstate(BlockStateGen.linearChassis())
|
.blockstate(BlockStateGen.linearChassis())
|
||||||
.onRegister(connectedTextures(new ChassisCTBehaviour()))
|
.onRegister(connectedTextures(new ChassisCTBehaviour()))
|
||||||
.lang("Linear Chassis")
|
.lang("Linear Chassis")
|
||||||
|
@ -774,6 +785,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<LinearChassisBlock> SECONDARY_LINEAR_CHASSIS =
|
public static final BlockEntry<LinearChassisBlock> SECONDARY_LINEAR_CHASSIS =
|
||||||
REGISTRATE.block("secondary_linear_chassis", LinearChassisBlock::new)
|
REGISTRATE.block("secondary_linear_chassis", LinearChassisBlock::new)
|
||||||
.initialProperties(SharedProperties::wooden)
|
.initialProperties(SharedProperties::wooden)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.blockstate(BlockStateGen.linearChassis())
|
.blockstate(BlockStateGen.linearChassis())
|
||||||
.onRegister(connectedTextures(new ChassisCTBehaviour()))
|
.onRegister(connectedTextures(new ChassisCTBehaviour()))
|
||||||
.simpleItem()
|
.simpleItem()
|
||||||
|
@ -782,6 +794,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<RadialChassisBlock> RADIAL_CHASSIS =
|
public static final BlockEntry<RadialChassisBlock> RADIAL_CHASSIS =
|
||||||
REGISTRATE.block("radial_chassis", RadialChassisBlock::new)
|
REGISTRATE.block("radial_chassis", RadialChassisBlock::new)
|
||||||
.initialProperties(SharedProperties::wooden)
|
.initialProperties(SharedProperties::wooden)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.blockstate(BlockStateGen.radialChassis())
|
.blockstate(BlockStateGen.radialChassis())
|
||||||
.item()
|
.item()
|
||||||
.model((c, p) -> {
|
.model((c, p) -> {
|
||||||
|
@ -968,6 +981,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<SequencedGearshiftBlock> SEQUENCED_GEARSHIFT =
|
public static final BlockEntry<SequencedGearshiftBlock> SEQUENCED_GEARSHIFT =
|
||||||
REGISTRATE.block("sequenced_gearshift", SequencedGearshiftBlock::new)
|
REGISTRATE.block("sequenced_gearshift", SequencedGearshiftBlock::new)
|
||||||
.initialProperties(SharedProperties::stone)
|
.initialProperties(SharedProperties::stone)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.properties(Block.Properties::nonOpaque)
|
.properties(Block.Properties::nonOpaque)
|
||||||
.transform(StressConfigDefaults.setNoImpact())
|
.transform(StressConfigDefaults.setNoImpact())
|
||||||
.blockstate(new SequencedGearshiftGenerator()::generate)
|
.blockstate(new SequencedGearshiftGenerator()::generate)
|
||||||
|
@ -997,6 +1011,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<SpeedControllerBlock> ROTATION_SPEED_CONTROLLER =
|
public static final BlockEntry<SpeedControllerBlock> ROTATION_SPEED_CONTROLLER =
|
||||||
REGISTRATE.block("rotation_speed_controller", SpeedControllerBlock::new)
|
REGISTRATE.block("rotation_speed_controller", SpeedControllerBlock::new)
|
||||||
.initialProperties(SharedProperties::softMetal)
|
.initialProperties(SharedProperties::softMetal)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.transform(StressConfigDefaults.setNoImpact())
|
.transform(StressConfigDefaults.setNoImpact())
|
||||||
.blockstate(BlockStateGen.horizontalAxisBlockProvider(true))
|
.blockstate(BlockStateGen.horizontalAxisBlockProvider(true))
|
||||||
.item()
|
.item()
|
||||||
|
@ -1024,6 +1039,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<AndesiteFunnelBlock> ANDESITE_FUNNEL =
|
public static final BlockEntry<AndesiteFunnelBlock> ANDESITE_FUNNEL =
|
||||||
REGISTRATE.block("andesite_funnel", AndesiteFunnelBlock::new)
|
REGISTRATE.block("andesite_funnel", AndesiteFunnelBlock::new)
|
||||||
.initialProperties(SharedProperties::stone)
|
.initialProperties(SharedProperties::stone)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.onRegister(addMovementBehaviour(FunnelMovementBehaviour.andesite()))
|
.onRegister(addMovementBehaviour(FunnelMovementBehaviour.andesite()))
|
||||||
.transform(BuilderTransformers.funnel("andesite", Create.asResource("block/andesite_casing")))
|
.transform(BuilderTransformers.funnel("andesite", Create.asResource("block/andesite_casing")))
|
||||||
.register();
|
.register();
|
||||||
|
@ -1031,6 +1047,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<AndesiteBeltFunnelBlock> ANDESITE_BELT_FUNNEL =
|
public static final BlockEntry<AndesiteBeltFunnelBlock> ANDESITE_BELT_FUNNEL =
|
||||||
REGISTRATE.block("andesite_belt_funnel", AndesiteBeltFunnelBlock::new)
|
REGISTRATE.block("andesite_belt_funnel", AndesiteBeltFunnelBlock::new)
|
||||||
.initialProperties(SharedProperties::stone)
|
.initialProperties(SharedProperties::stone)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.blockstate(new BeltFunnelGenerator("andesite", new ResourceLocation("block/polished_andesite"))::generate)
|
.blockstate(new BeltFunnelGenerator("andesite", new ResourceLocation("block/polished_andesite"))::generate)
|
||||||
.loot((p, b) -> p.registerDropping(b, ANDESITE_FUNNEL.get()))
|
.loot((p, b) -> p.registerDropping(b, ANDESITE_FUNNEL.get()))
|
||||||
.register();
|
.register();
|
||||||
|
@ -1038,6 +1055,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<BrassFunnelBlock> BRASS_FUNNEL =
|
public static final BlockEntry<BrassFunnelBlock> BRASS_FUNNEL =
|
||||||
REGISTRATE.block("brass_funnel", BrassFunnelBlock::new)
|
REGISTRATE.block("brass_funnel", BrassFunnelBlock::new)
|
||||||
.initialProperties(SharedProperties::softMetal)
|
.initialProperties(SharedProperties::softMetal)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.onRegister(addMovementBehaviour(FunnelMovementBehaviour.brass()))
|
.onRegister(addMovementBehaviour(FunnelMovementBehaviour.brass()))
|
||||||
.transform(BuilderTransformers.funnel("brass", Create.asResource("block/brass_casing")))
|
.transform(BuilderTransformers.funnel("brass", Create.asResource("block/brass_casing")))
|
||||||
.register();
|
.register();
|
||||||
|
@ -1045,6 +1063,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<BrassBeltFunnelBlock> BRASS_BELT_FUNNEL =
|
public static final BlockEntry<BrassBeltFunnelBlock> BRASS_BELT_FUNNEL =
|
||||||
REGISTRATE.block("brass_belt_funnel", BrassBeltFunnelBlock::new)
|
REGISTRATE.block("brass_belt_funnel", BrassBeltFunnelBlock::new)
|
||||||
.initialProperties(SharedProperties::softMetal)
|
.initialProperties(SharedProperties::softMetal)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.blockstate(new BeltFunnelGenerator("brass", Create.asResource("block/brass_block"))::generate)
|
.blockstate(new BeltFunnelGenerator("brass", Create.asResource("block/brass_block"))::generate)
|
||||||
.loot((p, b) -> p.registerDropping(b, BRASS_FUNNEL.get()))
|
.loot((p, b) -> p.registerDropping(b, BRASS_FUNNEL.get()))
|
||||||
.register();
|
.register();
|
||||||
|
@ -1093,6 +1112,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<CreativeCrateBlock> CREATIVE_CRATE =
|
public static final BlockEntry<CreativeCrateBlock> CREATIVE_CRATE =
|
||||||
REGISTRATE.block("creative_crate", CreativeCrateBlock::new)
|
REGISTRATE.block("creative_crate", CreativeCrateBlock::new)
|
||||||
.transform(BuilderTransformers.crate("creative"))
|
.transform(BuilderTransformers.crate("creative"))
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final BlockEntry<NixieTubeBlock> NIXIE_TUBE = REGISTRATE.block("nixie_tube", NixieTubeBlock::new)
|
public static final BlockEntry<NixieTubeBlock> NIXIE_TUBE = REGISTRATE.block("nixie_tube", NixieTubeBlock::new)
|
||||||
|
@ -1107,7 +1127,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<RedstoneLinkBlock> REDSTONE_LINK =
|
public static final BlockEntry<RedstoneLinkBlock> REDSTONE_LINK =
|
||||||
REGISTRATE.block("redstone_link", RedstoneLinkBlock::new)
|
REGISTRATE.block("redstone_link", RedstoneLinkBlock::new)
|
||||||
.initialProperties(SharedProperties::wooden)
|
.initialProperties(SharedProperties::wooden)
|
||||||
.tag(AllBlockTags.BRITTLE.tag)
|
.tag(AllBlockTags.BRITTLE.tag, AllBlockTags.SAFE_NBT.tag)
|
||||||
.blockstate(new RedstoneLinkGenerator()::generate)
|
.blockstate(new RedstoneLinkGenerator()::generate)
|
||||||
.addLayer(() -> RenderType::getCutoutMipped)
|
.addLayer(() -> RenderType::getCutoutMipped)
|
||||||
.item()
|
.item()
|
||||||
|
@ -1117,6 +1137,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<AnalogLeverBlock> ANALOG_LEVER =
|
public static final BlockEntry<AnalogLeverBlock> ANALOG_LEVER =
|
||||||
REGISTRATE.block("analog_lever", AnalogLeverBlock::new)
|
REGISTRATE.block("analog_lever", AnalogLeverBlock::new)
|
||||||
.initialProperties(() -> Blocks.LEVER)
|
.initialProperties(() -> Blocks.LEVER)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.blockstate((c, p) -> p.horizontalFaceBlock(c.get(), AssetLookup.partialBaseModel(c, p)))
|
.blockstate((c, p) -> p.horizontalFaceBlock(c.get(), AssetLookup.partialBaseModel(c, p)))
|
||||||
.item()
|
.item()
|
||||||
.transform(customItemModel())
|
.transform(customItemModel())
|
||||||
|
@ -1134,6 +1155,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<AdjustableRepeaterBlock> ADJUSTABLE_REPEATER =
|
public static final BlockEntry<AdjustableRepeaterBlock> ADJUSTABLE_REPEATER =
|
||||||
REGISTRATE.block("adjustable_repeater", AdjustableRepeaterBlock::new)
|
REGISTRATE.block("adjustable_repeater", AdjustableRepeaterBlock::new)
|
||||||
.initialProperties(() -> Blocks.REPEATER)
|
.initialProperties(() -> Blocks.REPEATER)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.blockstate(new AdjustableRepeaterGenerator()::generate)
|
.blockstate(new AdjustableRepeaterGenerator()::generate)
|
||||||
.item()
|
.item()
|
||||||
.model(AbstractDiodeGenerator.diodeItemModel(true))
|
.model(AbstractDiodeGenerator.diodeItemModel(true))
|
||||||
|
@ -1143,6 +1165,7 @@ public class AllBlocks {
|
||||||
public static final BlockEntry<AdjustableRepeaterBlock> ADJUSTABLE_PULSE_REPEATER =
|
public static final BlockEntry<AdjustableRepeaterBlock> ADJUSTABLE_PULSE_REPEATER =
|
||||||
REGISTRATE.block("adjustable_pulse_repeater", AdjustableRepeaterBlock::new)
|
REGISTRATE.block("adjustable_pulse_repeater", AdjustableRepeaterBlock::new)
|
||||||
.initialProperties(() -> Blocks.REPEATER)
|
.initialProperties(() -> Blocks.REPEATER)
|
||||||
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.blockstate(new AdjustableRepeaterGenerator()::generate)
|
.blockstate(new AdjustableRepeaterGenerator()::generate)
|
||||||
.addLayer(() -> RenderType::getCutoutMipped)
|
.addLayer(() -> RenderType::getCutoutMipped)
|
||||||
.item()
|
.item()
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class AllTags {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum AllBlockTags {
|
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
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,7 @@ import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.Constants.NBT;
|
import net.minecraftforge.common.util.Constants.NBT;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
|
||||||
|
|
||||||
public class DeployerTileEntity extends KineticTileEntity {
|
public class DeployerTileEntity extends KineticTileEntity {
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class BlockMovementTraits {
|
||||||
return true;
|
return true;
|
||||||
if (blockState.getBlockHardness(world, pos) == -1)
|
if (blockState.getBlockHardness(world, pos) == -1)
|
||||||
return false;
|
return false;
|
||||||
if (AllBlockTags.NON_MOVABLE.tag.contains(block))
|
if (AllBlockTags.NON_MOVABLE.matches(blockState))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Move controllers only when they aren't moving
|
// Move controllers only when they aren't moving
|
||||||
|
|
|
@ -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.AllContraptionTypes;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
|
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.FaceDirection;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
|
|
@ -3,8 +3,6 @@ package com.simibubi.create.content.contraptions.fluids.recipe;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.simibubi.create.content.contraptions.fluids.actors.FillingRecipe;
|
|
||||||
|
|
||||||
import net.minecraft.client.resources.ReloadListener;
|
import net.minecraft.client.resources.ReloadListener;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
|
@ -8,7 +8,6 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
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.BeltBlock;
|
||||||
import com.simibubi.create.content.contraptions.relays.belt.BeltHelper;
|
import com.simibubi.create.content.contraptions.relays.belt.BeltHelper;
|
||||||
import com.simibubi.create.content.contraptions.relays.belt.BeltSlope;
|
import com.simibubi.create.content.contraptions.relays.belt.BeltSlope;
|
||||||
|
|
|
@ -2,12 +2,8 @@ package com.simibubi.create.content.contraptions.relays.elementary;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.simibubi.create.AllBlocks;
|
|
||||||
import com.simibubi.create.AllShapes;
|
|
||||||
import com.simibubi.create.AllTileEntities;
|
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.base.RotatedPillarKineticBlock;
|
||||||
import com.simibubi.create.content.contraptions.relays.encased.EncasedShaftBlock;
|
|
||||||
import com.simibubi.create.content.contraptions.wrench.IWrenchableWithBracket;
|
import com.simibubi.create.content.contraptions.wrench.IWrenchableWithBracket;
|
||||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
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.Blocks;
|
||||||
import net.minecraft.block.IWaterLoggable;
|
import net.minecraft.block.IWaterLoggable;
|
||||||
import net.minecraft.block.material.PushReaction;
|
import net.minecraft.block.material.PushReaction;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.fluid.IFluidState;
|
import net.minecraft.fluid.IFluidState;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
import net.minecraft.item.ItemGroup;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.ItemUseContext;
|
import net.minecraft.item.ItemUseContext;
|
||||||
import net.minecraft.state.StateContainer.Builder;
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
|
@ -29,12 +23,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
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.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.IBlockReader;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.IWorldReader;
|
import net.minecraft.world.IWorldReader;
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package com.simibubi.create.content.curiosities.zapper;
|
package com.simibubi.create.content.curiosities.zapper;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import com.simibubi.create.AllSoundEvents;
|
import com.simibubi.create.AllSoundEvents;
|
||||||
import com.simibubi.create.foundation.networking.AllPackets;
|
import com.simibubi.create.AllTags.AllBlockTags;
|
||||||
import com.simibubi.create.foundation.networking.NbtPacket;
|
|
||||||
import com.simibubi.create.foundation.utility.BlockHelper;
|
import com.simibubi.create.foundation.utility.BlockHelper;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
@ -12,8 +13,8 @@ import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.state.properties.StairsShape;
|
import net.minecraft.state.properties.StairsShape;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.util.SoundCategory;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
@ -21,30 +22,21 @@ import net.minecraft.util.math.RayTraceContext;
|
||||||
import net.minecraft.util.math.RayTraceContext.BlockMode;
|
import net.minecraft.util.math.RayTraceContext.BlockMode;
|
||||||
import net.minecraft.util.math.RayTraceContext.FluidMode;
|
import net.minecraft.util.math.RayTraceContext.FluidMode;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
|
|
||||||
@EventBusSubscriber(value = Dist.CLIENT)
|
@EventBusSubscriber
|
||||||
public class ZapperInteractionHandler {
|
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
|
@SubscribeEvent
|
||||||
public static void leftClickingBlocksWithTheZapperSelectsTheBlock(PlayerInteractEvent.LeftClickBlock event) {
|
public static void leftClickingBlocksWithTheZapperSelectsTheBlock(PlayerInteractEvent.LeftClickBlock event) {
|
||||||
ItemStack heldItem = event.getPlayer()
|
if (event.getWorld().isRemote)
|
||||||
.getHeldItemMainhand();
|
return;
|
||||||
|
ItemStack heldItem = event.getPlayer().getHeldItemMainhand();
|
||||||
if (heldItem.getItem() instanceof ZapperItem && trySelect(heldItem, event.getPlayer())) {
|
if (heldItem.getItem() instanceof ZapperItem && trySelect(heldItem, event.getPlayer())) {
|
||||||
event.setCancellationResult(ActionResultType.FAIL);
|
event.setCancellationResult(ActionResultType.FAIL);
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
AllPackets.channel.sendToServer(new NbtPacket(heldItem, Hand.MAIN_HAND));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +60,7 @@ public class ZapperInteractionHandler {
|
||||||
if (BlockHelper.getRequiredItem(newState)
|
if (BlockHelper.getRequiredItem(newState)
|
||||||
.isEmpty())
|
.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
if (player.world.getTileEntity(pos) != null)
|
if (newState.hasTileEntity() && !AllBlockTags.SAFE_NBT.matches(newState))
|
||||||
return false;
|
return false;
|
||||||
if (newState.has(BlockStateProperties.DOUBLE_BLOCK_HALF))
|
if (newState.has(BlockStateProperties.DOUBLE_BLOCK_HALF))
|
||||||
return false;
|
return false;
|
||||||
|
@ -85,14 +77,31 @@ public class ZapperInteractionHandler {
|
||||||
if (newState.has(BlockStateProperties.WATERLOGGED))
|
if (newState.has(BlockStateProperties.WATERLOGGED))
|
||||||
newState = newState.with(BlockStateProperties.WATERLOGGED, false);
|
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();
|
CompoundNBT tag = stack.getOrCreateTag();
|
||||||
if (tag.contains("BlockUsed") && NBTUtil.readBlockState(stack.getTag()
|
if (tag.contains("BlockUsed")
|
||||||
.getCompound("BlockUsed")) == newState)
|
&& NBTUtil.readBlockState(
|
||||||
|
stack.getTag().getCompound("BlockUsed")) == newState
|
||||||
|
&& Objects.equals(data, tag.get("BlockData"))) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
tag.put("BlockUsed", NBTUtil.writeBlockState(newState));
|
tag.put("BlockUsed", NBTUtil.writeBlockState(newState));
|
||||||
player.world.playSound(player, player.getPosition(), AllSoundEvents.BLOCKZAPPER_CONFIRM.get(),
|
if (data == null)
|
||||||
|
tag.remove("BlockData");
|
||||||
|
else
|
||||||
|
tag.put("BlockData", data);
|
||||||
|
player.world.playSound(null, player.getPosition(), AllSoundEvents.BLOCKZAPPER_CONFIRM.get(),
|
||||||
SoundCategory.BLOCKS, 0.5f, 0.8f);
|
SoundCategory.BLOCKS, 0.5f, 0.8f);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import com.simibubi.create.AllSoundEvents;
|
import com.simibubi.create.AllSoundEvents;
|
||||||
|
import com.simibubi.create.AllTags.AllBlockTags;
|
||||||
import com.simibubi.create.foundation.item.ItemDescription;
|
import com.simibubi.create.foundation.item.ItemDescription;
|
||||||
import com.simibubi.create.foundation.networking.AllPackets;
|
import com.simibubi.create.foundation.networking.AllPackets;
|
||||||
import com.simibubi.create.foundation.utility.BlockHelper;
|
import com.simibubi.create.foundation.utility.BlockHelper;
|
||||||
|
@ -23,6 +24,7 @@ import net.minecraft.item.Rarity;
|
||||||
import net.minecraft.item.UseAction;
|
import net.minecraft.item.UseAction;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
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.RayTraceContext.FluidMode;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.common.util.Constants.NBT;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.fml.network.PacketDistributor;
|
import net.minecraftforge.fml.network.PacketDistributor;
|
||||||
|
|
||||||
|
@ -149,6 +151,10 @@ public abstract class ZapperItem extends Item {
|
||||||
if (nbt.contains("BlockUsed"))
|
if (nbt.contains("BlockUsed"))
|
||||||
stateToUse = NBTUtil.readBlockState(nbt.getCompound("BlockUsed"));
|
stateToUse = NBTUtil.readBlockState(nbt.getCompound("BlockUsed"));
|
||||||
stateToUse = BlockHelper.setZeroAge(stateToUse);
|
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
|
// Raytrace - Find the target
|
||||||
Vec3d start = player.getPositionVec()
|
Vec3d start = player.getPositionVec()
|
||||||
|
@ -181,7 +187,7 @@ public abstract class ZapperItem extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server side
|
// Server side
|
||||||
if (activate(world, player, item, stateToUse, raytrace)) {
|
if (activate(world, player, item, stateToUse, raytrace, data)) {
|
||||||
applyCooldown(player, item, gunInOtherHand);
|
applyCooldown(player, item, gunInOtherHand);
|
||||||
AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> player),
|
AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY.with(() -> player),
|
||||||
new ZapperBeamPacket(barrelPos, raytrace.getHitVec(), hand, false));
|
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,
|
protected abstract boolean activate(World world, PlayerEntity player, ItemStack item, BlockState stateToUse,
|
||||||
BlockRayTraceResult raytrace);
|
BlockRayTraceResult raytrace, CompoundNBT data);
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
protected abstract void openHandgunGUI(ItemStack item, boolean b);
|
protected abstract void openHandgunGUI(ItemStack item, boolean b);
|
||||||
|
@ -234,4 +240,16 @@ public abstract class ZapperItem extends Item {
|
||||||
return UseAction.NONE;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import com.simibubi.create.foundation.utility.NBTHelper;
|
||||||
import net.minecraft.advancements.CriteriaTriggers;
|
import net.minecraft.advancements.CriteriaTriggers;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.RedstoneLampBlock;
|
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -97,7 +96,7 @@ public class BlockzapperItem extends ZapperItem {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean activate(World world, PlayerEntity player, ItemStack stack, BlockState selectedState,
|
protected boolean activate(World world, PlayerEntity player, ItemStack stack, BlockState selectedState,
|
||||||
BlockRayTraceResult raytrace) {
|
BlockRayTraceResult raytrace, CompoundNBT data) {
|
||||||
CompoundNBT nbt = stack.getOrCreateTag();
|
CompoundNBT nbt = stack.getOrCreateTag();
|
||||||
boolean replace = nbt.contains("Replace") && nbt.getBoolean("Replace");
|
boolean replace = nbt.contains("Replace") && nbt.getBoolean("Replace");
|
||||||
|
|
||||||
|
@ -136,6 +135,7 @@ public class BlockzapperItem extends ZapperItem {
|
||||||
blocksnapshot.restore(true, false);
|
blocksnapshot.restore(true, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
setTileData(world, placed, data);
|
||||||
|
|
||||||
if (player instanceof ServerPlayerEntity && world instanceof ServerWorld) {
|
if (player instanceof ServerPlayerEntity && world instanceof ServerWorld) {
|
||||||
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player;
|
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player;
|
||||||
|
|
|
@ -4,11 +4,13 @@ import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.simibubi.create.content.curiosities.zapper.ZapperItem;
|
||||||
import com.simibubi.create.foundation.gui.AllIcons;
|
import com.simibubi.create.foundation.gui.AllIcons;
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -34,7 +36,7 @@ public enum TerrainTools {
|
||||||
return this != Clear && this != Flatten;
|
return this != Clear && this != Flatten;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(World world, List<BlockPos> targetPositions, Direction facing, @Nullable BlockState paintedState) {
|
public void run(World world, List<BlockPos> targetPositions, Direction facing, @Nullable BlockState paintedState, @Nullable CompoundNBT data) {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case Clear:
|
case Clear:
|
||||||
targetPositions.forEach(p -> world.setBlockState(p, Blocks.AIR.getDefaultState()));
|
targetPositions.forEach(p -> world.setBlockState(p, Blocks.AIR.getDefaultState()));
|
||||||
|
@ -45,6 +47,7 @@ public enum TerrainTools {
|
||||||
if (!isReplaceable(toReplace))
|
if (!isReplaceable(toReplace))
|
||||||
return;
|
return;
|
||||||
world.setBlockState(p, paintedState);
|
world.setBlockState(p, paintedState);
|
||||||
|
ZapperItem.setTileData(world, p, data);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case Flatten:
|
case Flatten:
|
||||||
|
@ -64,11 +67,13 @@ public enum TerrainTools {
|
||||||
if (!isReplaceable(toReplace))
|
if (!isReplaceable(toReplace))
|
||||||
return;
|
return;
|
||||||
world.setBlockState(p, paintedState);
|
world.setBlockState(p, paintedState);
|
||||||
|
ZapperItem.setTileData(world, p, data);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case Place:
|
case Place:
|
||||||
targetPositions.forEach(p -> {
|
targetPositions.forEach(p -> {
|
||||||
world.setBlockState(p, paintedState);
|
world.setBlockState(p, paintedState);
|
||||||
|
ZapperItem.setTileData(world, p, data);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case Replace:
|
case Replace:
|
||||||
|
@ -77,6 +82,7 @@ public enum TerrainTools {
|
||||||
if (isReplaceable(toReplace))
|
if (isReplaceable(toReplace))
|
||||||
return;
|
return;
|
||||||
world.setBlockState(p, paintedState);
|
world.setBlockState(p, paintedState);
|
||||||
|
ZapperItem.setTileData(world, p, data);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class WorldshaperItem extends ZapperItem {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean activate(World world, PlayerEntity player, ItemStack stack, BlockState stateToUse,
|
protected boolean activate(World world, PlayerEntity player, ItemStack stack, BlockState stateToUse,
|
||||||
BlockRayTraceResult raytrace) {
|
BlockRayTraceResult raytrace, CompoundNBT data) {
|
||||||
|
|
||||||
BlockPos targetPos = raytrace.getPos();
|
BlockPos targetPos = raytrace.getPos();
|
||||||
List<BlockPos> affectedPositions = new ArrayList<>();
|
List<BlockPos> affectedPositions = new ArrayList<>();
|
||||||
|
@ -77,7 +77,7 @@ public class WorldshaperItem extends ZapperItem {
|
||||||
for (BlockPos blockPos : brush.getIncludedPositions())
|
for (BlockPos blockPos : brush.getIncludedPositions())
|
||||||
affectedPositions.add(targetPos.add(blockPos));
|
affectedPositions.add(targetPos.add(blockPos));
|
||||||
PlacementPatterns.applyPattern(affectedPositions, stack);
|
PlacementPatterns.applyPattern(affectedPositions, stack);
|
||||||
tool.run(world, affectedPositions, raytrace.getFace(), stateToUse);
|
tool.run(world, affectedPositions, raytrace.getFace(), stateToUse, data);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.particles.ParticleTypes;
|
import net.minecraft.particles.ParticleTypes;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.tags.FluidTags;
|
import net.minecraft.tags.FluidTags;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.util.SoundCategory;
|
||||||
import net.minecraft.util.SoundEvents;
|
import net.minecraft.util.SoundEvents;
|
||||||
|
@ -26,6 +27,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.IPlantable;
|
import net.minecraftforge.common.IPlantable;
|
||||||
|
import net.minecraftforge.common.util.Constants;
|
||||||
|
|
||||||
public abstract class LaunchedItem {
|
public abstract class LaunchedItem {
|
||||||
|
|
||||||
|
@ -90,18 +92,27 @@ public abstract class LaunchedItem {
|
||||||
|
|
||||||
public static class ForBlockState extends LaunchedItem {
|
public static class ForBlockState extends LaunchedItem {
|
||||||
public BlockState state;
|
public BlockState state;
|
||||||
|
public CompoundNBT data;
|
||||||
|
|
||||||
ForBlockState() {}
|
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);
|
super(start, target, stack);
|
||||||
this.state = state;
|
this.state = state;
|
||||||
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundNBT serializeNBT() {
|
public CompoundNBT serializeNBT() {
|
||||||
CompoundNBT serializeNBT = super.serializeNBT();
|
CompoundNBT serializeNBT = super.serializeNBT();
|
||||||
serializeNBT.put("BlockState", NBTUtil.writeBlockState(state));
|
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;
|
return serializeNBT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +120,9 @@ public abstract class LaunchedItem {
|
||||||
void readNBT(CompoundNBT nbt) {
|
void readNBT(CompoundNBT nbt) {
|
||||||
super.readNBT(nbt);
|
super.readNBT(nbt);
|
||||||
state = NBTUtil.readBlockState(nbt.getCompound("BlockState"));
|
state = NBTUtil.readBlockState(nbt.getCompound("BlockState"));
|
||||||
|
if (nbt.contains("Data", Constants.NBT.TAG_COMPOUND)) {
|
||||||
|
data = nbt.getCompound("Data");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -141,6 +155,15 @@ public abstract class LaunchedItem {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
world.setBlockState(target, state, 18);
|
world.setBlockState(target, state, 18);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
state.getBlock().onBlockPlacedBy(world, target, state, null, stack);
|
state.getBlock().onBlockPlacedBy(world, target, state, null, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +188,7 @@ public abstract class LaunchedItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ForBelt(BlockPos start, BlockPos target, ItemStack stack, BlockState state, int length) {
|
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;
|
this.length = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,12 @@ package com.simibubi.create.content.schematics.block;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllItems;
|
import com.simibubi.create.AllItems;
|
||||||
import com.simibubi.create.AllSoundEvents;
|
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.BeltBlock;
|
||||||
import com.simibubi.create.content.contraptions.relays.belt.BeltPart;
|
import com.simibubi.create.content.contraptions.relays.belt.BeltPart;
|
||||||
import com.simibubi.create.content.contraptions.relays.belt.BeltSlope;
|
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))
|
if (te instanceof BeltTileEntity && AllBlocks.BELT.has(blockState))
|
||||||
launchBelt(target, blockState, ((BeltTileEntity) te).beltLength);
|
launchBelt(target, blockState, ((BeltTileEntity) te).beltLength);
|
||||||
else
|
else
|
||||||
launchBlock(target, icon, blockState);
|
launchBlock(target, icon, blockState, null);
|
||||||
} else
|
} else {
|
||||||
launchBlock(target, icon, blockState);
|
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();
|
printerCooldown = config().schematicannonDelay.get();
|
||||||
fuelLevel -= getFuelUsageRate();
|
fuelLevel -= getFuelUsageRate();
|
||||||
|
@ -692,7 +703,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
|
||||||
if (world == null)
|
if (world == null)
|
||||||
return false;
|
return false;
|
||||||
BlockState toReplace = world.getBlockState(pos);
|
BlockState toReplace = world.getBlockState(pos);
|
||||||
boolean placingAir = state.getBlock() == Blocks.AIR;
|
boolean placingAir = state.getBlock().isAir(state, world, pos);
|
||||||
|
|
||||||
BlockState toReplaceOther = null;
|
BlockState toReplaceOther = null;
|
||||||
if (state.has(BlockStateProperties.BED_PART) && state.has(BlockStateProperties.HORIZONTAL_FACING) && state.get(BlockStateProperties.BED_PART) == BedPart.FOOT)
|
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();
|
playFiringSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void launchBlock(BlockPos target, ItemStack stack, BlockState state) {
|
protected void launchBlock(BlockPos target, ItemStack stack, BlockState state, @Nullable CompoundNBT data) {
|
||||||
if (state.getBlock() != Blocks.AIR)
|
if (state.getBlock().isAir(state, world, target))
|
||||||
blocksPlaced++;
|
blocksPlaced++;
|
||||||
flyingBlocks.add(new LaunchedItem.ForBlockState(this.getPos(), target, stack, state));
|
flyingBlocks.add(new LaunchedItem.ForBlockState(this.getPos(), target, stack, state, data));
|
||||||
playFiringSound();
|
playFiringSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.components.turntable.TurntableHandler;
|
||||||
import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorHandler;
|
import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorHandler;
|
||||||
import com.simibubi.create.content.curiosities.tools.ExtendoGripRenderHandler;
|
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.ZapperRenderHandler;
|
||||||
import com.simibubi.create.content.curiosities.zapper.blockzapper.BlockzapperRenderHandler;
|
import com.simibubi.create.content.curiosities.zapper.blockzapper.BlockzapperRenderHandler;
|
||||||
import com.simibubi.create.content.curiosities.zapper.terrainzapper.WorldshaperRenderHandler;
|
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.config.AllConfigs;
|
||||||
import com.simibubi.create.foundation.gui.ScreenOpener;
|
import com.simibubi.create.foundation.gui.ScreenOpener;
|
||||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
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.renderState.SuperRenderTypeBuffer;
|
||||||
import com.simibubi.create.foundation.tileEntity.behaviour.edgeInteraction.EdgeInteractionRenderer;
|
import com.simibubi.create.foundation.tileEntity.behaviour.edgeInteraction.EdgeInteractionRenderer;
|
||||||
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer;
|
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.Phase;
|
||||||
import net.minecraftforge.event.TickEvent.RenderTickEvent;
|
import net.minecraftforge.event.TickEvent.RenderTickEvent;
|
||||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||||
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.minecraftforge.event.world.WorldEvent;
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.FluidTransferRecipes;
|
||||||
import com.simibubi.create.content.contraptions.fluids.recipe.PotionMixingRecipeManager;
|
import com.simibubi.create.content.contraptions.fluids.recipe.PotionMixingRecipeManager;
|
||||||
import com.simibubi.create.content.contraptions.wrench.WrenchItem;
|
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.content.schematics.ServerSchematicLoader;
|
||||||
import com.simibubi.create.foundation.command.AllCommands;
|
import com.simibubi.create.foundation.command.AllCommands;
|
||||||
import com.simibubi.create.foundation.fluid.FluidHelper;
|
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.block.BlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.fluid.IFluidState;
|
import net.minecraft.fluid.IFluidState;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.resources.IReloadableResourceManager;
|
import net.minecraft.resources.IReloadableResourceManager;
|
||||||
import net.minecraft.tags.FluidTags;
|
import net.minecraft.tags.FluidTags;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
@ -159,4 +163,11 @@ public class CommonEvents {
|
||||||
CapabilityMinecartController.startTracking(event);
|
CapabilityMinecartController.startTracking(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void leftClickEmpty(ServerPlayerEntity player) {
|
||||||
|
ItemStack stack = player.getHeldItemMainhand();
|
||||||
|
if (stack.getItem() instanceof ZapperItem) {
|
||||||
|
ZapperInteractionHandler.trySelect(stack, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ public enum AllPackets {
|
||||||
MINECART_COUPLING_CREATION(CouplingCreationPacket.class, CouplingCreationPacket::new),
|
MINECART_COUPLING_CREATION(CouplingCreationPacket.class, CouplingCreationPacket::new),
|
||||||
INSTANT_SCHEMATIC(InstantSchematicPacket.class, InstantSchematicPacket::new),
|
INSTANT_SCHEMATIC(InstantSchematicPacket.class, InstantSchematicPacket::new),
|
||||||
SYNC_SCHEMATIC(SchematicSyncPacket.class, SchematicSyncPacket::new),
|
SYNC_SCHEMATIC(SchematicSyncPacket.class, SchematicSyncPacket::new),
|
||||||
|
LEFT_CLICK(LeftClickPacket.class, LeftClickPacket::new),
|
||||||
|
|
||||||
// Server to Client
|
// Server to Client
|
||||||
SYMMETRY_EFFECT(SymmetryEffectPacket.class, SymmetryEffectPacket::new),
|
SYMMETRY_EFFECT(SymmetryEffectPacket.class, SymmetryEffectPacket::new),
|
||||||
|
|
|
@ -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) {
|
||||||
|
Context ctx = context.get();
|
||||||
|
if (ctx.getDirection() != NetworkDirection.PLAY_TO_SERVER)
|
||||||
|
return;
|
||||||
|
ctx.enqueueWork(() -> CommonEvents.leftClickEmpty(ctx.getSender()));
|
||||||
|
ctx.setPacketHandled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,9 +1,8 @@
|
||||||
package com.simibubi.create.foundation.tileEntity.behaviour.linked;
|
package com.simibubi.create.foundation.tileEntity.behaviour.linked;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
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 org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import com.simibubi.create.Create;
|
import com.simibubi.create.Create;
|
||||||
|
@ -35,8 +34,8 @@ public class LinkBehaviour extends TileEntityBehaviour {
|
||||||
|
|
||||||
public boolean newPosition;
|
public boolean newPosition;
|
||||||
private Mode mode;
|
private Mode mode;
|
||||||
private Supplier<Integer> transmission;
|
private IntSupplier transmission;
|
||||||
private Consumer<Integer> signalCallback;
|
private IntConsumer signalCallback;
|
||||||
|
|
||||||
protected LinkBehaviour(SmartTileEntity te, Pair<ValueBoxTransform, ValueBoxTransform> slots) {
|
protected LinkBehaviour(SmartTileEntity te, Pair<ValueBoxTransform, ValueBoxTransform> slots) {
|
||||||
super(te);
|
super(te);
|
||||||
|
@ -49,7 +48,7 @@ public class LinkBehaviour extends TileEntityBehaviour {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LinkBehaviour receiver(SmartTileEntity te, Pair<ValueBoxTransform, ValueBoxTransform> slots,
|
public static LinkBehaviour receiver(SmartTileEntity te, Pair<ValueBoxTransform, ValueBoxTransform> slots,
|
||||||
Consumer<Integer> signalCallback) {
|
IntConsumer signalCallback) {
|
||||||
LinkBehaviour behaviour = new LinkBehaviour(te, slots);
|
LinkBehaviour behaviour = new LinkBehaviour(te, slots);
|
||||||
behaviour.signalCallback = signalCallback;
|
behaviour.signalCallback = signalCallback;
|
||||||
behaviour.mode = Mode.RECEIVE;
|
behaviour.mode = Mode.RECEIVE;
|
||||||
|
@ -57,7 +56,7 @@ public class LinkBehaviour extends TileEntityBehaviour {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LinkBehaviour transmitter(SmartTileEntity te, Pair<ValueBoxTransform, ValueBoxTransform> slots,
|
public static LinkBehaviour transmitter(SmartTileEntity te, Pair<ValueBoxTransform, ValueBoxTransform> slots,
|
||||||
Supplier<Integer> transmission) {
|
IntSupplier transmission) {
|
||||||
LinkBehaviour behaviour = new LinkBehaviour(te, slots);
|
LinkBehaviour behaviour = new LinkBehaviour(te, slots);
|
||||||
behaviour.transmission = transmission;
|
behaviour.transmission = transmission;
|
||||||
behaviour.mode = Mode.TRANSMIT;
|
behaviour.mode = Mode.TRANSMIT;
|
||||||
|
@ -81,7 +80,7 @@ public class LinkBehaviour extends TileEntityBehaviour {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTransmittedStrength() {
|
public int getTransmittedStrength() {
|
||||||
return mode == Mode.TRANSMIT ? transmission.get() : 0;
|
return mode == Mode.TRANSMIT ? transmission.getAsInt() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateReceiver(int networkPower) {
|
public void updateReceiver(int networkPower) {
|
||||||
|
|
Loading…
Reference in a new issue