mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-29 22:35:06 +01:00
Tick and Tag
- assign harvest tool tags to block entries - repurpose ITE as EntityBlock and apply change to all affected blocks
This commit is contained in:
parent
00b6a32e77
commit
cb987307c0
127 changed files with 1171 additions and 1357 deletions
|
@ -1,6 +1,9 @@
|
|||
package com.simibubi.create;
|
||||
|
||||
import static com.simibubi.create.AllMovementBehaviours.addMovementBehaviour;
|
||||
import static com.simibubi.create.AllTags.axeOnly;
|
||||
import static com.simibubi.create.AllTags.axeOrPickaxe;
|
||||
import static com.simibubi.create.AllTags.pickaxeOnly;
|
||||
import static com.simibubi.create.AllTags.tagBlockAndItem;
|
||||
import static com.simibubi.create.content.AllSections.SCHEMATICS;
|
||||
import static com.simibubi.create.foundation.data.BlockStateGen.axisBlock;
|
||||
|
@ -66,7 +69,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.pis
|
|||
import com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyBlock;
|
||||
import com.simibubi.create.content.contraptions.components.tracks.ControllerRailBlock;
|
||||
import com.simibubi.create.content.contraptions.components.tracks.ControllerRailGenerator;
|
||||
import com.simibubi.create.content.contraptions.components.tracks.ReinforcedRailBlock;
|
||||
import com.simibubi.create.content.contraptions.components.turntable.TurntableBlock;
|
||||
import com.simibubi.create.content.contraptions.components.waterwheel.WaterWheelBlock;
|
||||
import com.simibubi.create.content.contraptions.fluids.PipeAttachmentModel;
|
||||
|
@ -220,6 +222,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<SchematicannonBlock> SCHEMATICANNON =
|
||||
REGISTRATE.block("schematicannon", SchematicannonBlock::new)
|
||||
.initialProperties(() -> Blocks.DISPENSER)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate((ctx, prov) -> prov.simpleBlock(ctx.getEntry(), AssetLookup.partialBaseModel(ctx, prov)))
|
||||
.loot((lt, block) -> {
|
||||
Builder builder = LootTable.lootTable();
|
||||
|
@ -239,6 +242,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<SchematicTableBlock> SCHEMATIC_TABLE =
|
||||
REGISTRATE.block("schematic_table", SchematicTableBlock::new)
|
||||
.initialProperties(() -> Blocks.LECTERN)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate((ctx, prov) -> prov.horizontalBlock(ctx.getEntry(), prov.models()
|
||||
.getExistingFile(ctx.getId()), 0))
|
||||
.simpleItem()
|
||||
|
@ -253,6 +257,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<ShaftBlock> SHAFT = REGISTRATE.block("shaft", ShaftBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate(BlockStateGen.axisBlockProvider(false))
|
||||
.onRegister(CreateRegistrate.blockModel(() -> BracketedKineticBlockModel::new))
|
||||
.simpleItem()
|
||||
|
@ -260,8 +265,9 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<CogWheelBlock> COGWHEEL = REGISTRATE.block("cogwheel", CogWheelBlock::small)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.properties(p -> p.sound(SoundType.WOOD))
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(BlockStateGen.axisBlockProvider(false))
|
||||
.onRegister(CreateRegistrate.blockModel(() -> BracketedKineticBlockModel::new))
|
||||
.item(CogwheelBlockItem::new)
|
||||
|
@ -272,6 +278,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("large_cogwheel", CogWheelBlock::large)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(p -> p.sound(SoundType.WOOD))
|
||||
.transform(axeOrPickaxe())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate(BlockStateGen.axisBlockProvider(false))
|
||||
.onRegister(CreateRegistrate.blockModel(() -> BracketedKineticBlockModel::new))
|
||||
|
@ -282,17 +289,20 @@ public class AllBlocks {
|
|||
public static final BlockEntry<EncasedShaftBlock> ANDESITE_ENCASED_SHAFT =
|
||||
REGISTRATE.block("andesite_encased_shaft", EncasedShaftBlock::andesite)
|
||||
.transform(BuilderTransformers.encasedShaft("andesite", AllSpriteShifts.ANDESITE_CASING))
|
||||
.transform(axeOrPickaxe())
|
||||
.register();
|
||||
|
||||
public static final BlockEntry<EncasedShaftBlock> BRASS_ENCASED_SHAFT =
|
||||
REGISTRATE.block("brass_encased_shaft", EncasedShaftBlock::brass)
|
||||
.transform(BuilderTransformers.encasedShaft("brass", AllSpriteShifts.BRASS_CASING))
|
||||
.transform(axeOrPickaxe())
|
||||
.register();
|
||||
|
||||
public static final BlockEntry<GearboxBlock> GEARBOX = REGISTRATE.block("gearbox", GearboxBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.transform(axeOrPickaxe())
|
||||
.onRegister(CreateRegistrate.connectedTextures(new EncasedCTBehaviour(AllSpriteShifts.ANDESITE_CASING)))
|
||||
.onRegister(CreateRegistrate.casingConnectivity((block, cc) -> cc.make(block, AllSpriteShifts.ANDESITE_CASING,
|
||||
(s, f) -> f.getAxis() == s.getValue(GearboxBlock.AXIS))))
|
||||
|
@ -305,6 +315,7 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties::stone)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p)))
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
|
@ -314,6 +325,7 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties::stone)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p)))
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
|
@ -324,6 +336,7 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties::stone)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate((c, p) -> new EncasedBeltGenerator((state, suffix) -> p.models()
|
||||
.getExistingFile(p.modLoc("block/" + c.getName() + "/" + suffix))).generate(c, p))
|
||||
.item()
|
||||
|
@ -335,6 +348,7 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties::stone)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate((c, p) -> new EncasedBeltGenerator((state, suffix) -> {
|
||||
String powered = state.getValue(AdjustablePulleyBlock.POWERED) ? "_powered" : "";
|
||||
return p.models()
|
||||
|
@ -352,6 +366,7 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties.beltMaterial, MaterialColor.COLOR_GRAY)
|
||||
.properties(p -> p.sound(SoundType.WOOL))
|
||||
.properties(p -> p.strength(0.8F))
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(new BeltGenerator()::generate)
|
||||
.transform(BlockStressDefaults.setImpact(1.0))
|
||||
.onRegister(CreateRegistrate.blockModel(() -> BeltModel::new))
|
||||
|
@ -361,6 +376,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("creative_motor", CreativeMotorBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate(new CreativeMotorGenerator()::generate)
|
||||
.transform(BlockStressDefaults.setCapacity(16384.0))
|
||||
.item()
|
||||
|
@ -371,6 +387,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<WaterWheelBlock> WATER_WHEEL = REGISTRATE.block("water_wheel", WaterWheelBlock::new)
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(BlockStateGen.directionalBlockProviderIgnoresWaterlogged(false))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.transform(BlockStressDefaults.setCapacity(16.0))
|
||||
|
@ -381,6 +398,7 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties::stone)
|
||||
.blockstate(BlockStateGen.directionalBlockProvider(true))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.transform(axeOrPickaxe())
|
||||
.transform(BlockStressDefaults.setCapacity(16.0))
|
||||
.transform(BlockStressDefaults.setImpact(2.0))
|
||||
.item()
|
||||
|
@ -390,6 +408,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<NozzleBlock> NOZZLE = REGISTRATE.block("nozzle", NozzleBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.tag(AllBlockTags.BRITTLE.tag)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(BlockStateGen.directionalBlockProvider(true))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.item()
|
||||
|
@ -398,6 +417,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<TurntableBlock> TURNTABLE = REGISTRATE.block("turntable", TurntableBlock::new)
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate((c, p) -> p.simpleBlock(c.getEntry(), AssetLookup.standardModel(c, p)))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.simpleItem()
|
||||
|
@ -405,6 +425,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<HandCrankBlock> HAND_CRANK = REGISTRATE.block("hand_crank", HandCrankBlock::new)
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(BlockStateGen.directionalBlockProvider(true))
|
||||
.transform(BlockStressDefaults.setCapacity(8.0))
|
||||
.tag(AllBlockTags.BRITTLE.tag)
|
||||
|
@ -415,11 +436,13 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<CuckooClockBlock> CUCKOO_CLOCK =
|
||||
REGISTRATE.block("cuckoo_clock", CuckooClockBlock::regular)
|
||||
.transform(axeOrPickaxe())
|
||||
.transform(BuilderTransformers.cuckooClock())
|
||||
.register();
|
||||
|
||||
public static final BlockEntry<CuckooClockBlock> MYSTERIOUS_CUCKOO_CLOCK =
|
||||
REGISTRATE.block("mysterious_cuckoo_clock", CuckooClockBlock::mysterious)
|
||||
.transform(axeOrPickaxe())
|
||||
.transform(BuilderTransformers.cuckooClock())
|
||||
.lang("Cuckoo Clock")
|
||||
.onRegisterAfter(Item.class, c -> TooltipHelper.referTo(c, CUCKOO_CLOCK))
|
||||
|
@ -427,6 +450,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<MillstoneBlock> MILLSTONE = REGISTRATE.block("millstone", MillstoneBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate((c, p) -> p.simpleBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p)))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.item()
|
||||
|
@ -437,6 +461,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("crushing_wheel", CrushingWheelBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate(BlockStateGen.axisBlockProvider(false))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.transform(BlockStressDefaults.setImpact(8.0))
|
||||
|
@ -457,6 +482,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("mechanical_press", MechanicalPressBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(BlockStateGen.horizontalBlockProvider(true))
|
||||
.transform(BlockStressDefaults.setImpact(8.0))
|
||||
.item(AssemblyOperatorBlockItem::new)
|
||||
|
@ -467,6 +493,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("mechanical_mixer", MechanicalMixerBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate((c, p) -> p.simpleBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p)))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
|
@ -477,6 +504,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<BasinBlock> BASIN = REGISTRATE.block("basin", BasinBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(p -> p.sound(SoundType.NETHERITE_BLOCK))
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate(new BasinGenerator()::generate)
|
||||
.onRegister(addMovementBehaviour(new BasinMovementBehaviour()))
|
||||
.item()
|
||||
|
@ -487,6 +515,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("blaze_burner", BlazeBurnerBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(p -> p.lightLevel(BlazeBurnerBlock::getLight))
|
||||
.transform(pickaxeOnly())
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.tag(AllBlockTags.FAN_TRANSPARENT.tag, AllBlockTags.FAN_HEATERS.tag)
|
||||
.loot((lt, block) -> lt.add(block, BlazeBurnerBlock.buildLootTable()))
|
||||
|
@ -500,6 +529,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("lit_blaze_burner", LitBlazeBurnerBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(p -> p.lightLevel(LitBlazeBurnerBlock::getLight))
|
||||
.transform(pickaxeOnly())
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.tag(AllBlockTags.FAN_TRANSPARENT.tag, AllBlockTags.FAN_HEATERS.tag)
|
||||
.loot((lt, block) -> lt.dropOther(block, AllItems.EMPTY_BLAZE_BURNER.get()))
|
||||
|
@ -515,6 +545,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<DepotBlock> DEPOT = REGISTRATE.block("depot", DepotBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate((c, p) -> p.simpleBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p)))
|
||||
.item()
|
||||
.transform(customItemModel("_", "block"))
|
||||
|
@ -524,6 +555,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("weighted_ejector", EjectorBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate((c, p) -> p.horizontalBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p), 180))
|
||||
.transform(BlockStressDefaults.setImpact(2.0))
|
||||
.item(EjectorItem::new)
|
||||
|
@ -533,6 +565,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<ChuteBlock> CHUTE = REGISTRATE.block("chute", ChuteBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(p -> p.sound(SoundType.NETHERITE_BLOCK))
|
||||
.transform(pickaxeOnly())
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.blockstate(new ChuteGenerator()::generate)
|
||||
.item(ChuteItem::new)
|
||||
|
@ -542,6 +575,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<SmartChuteBlock> SMART_CHUTE = REGISTRATE.block("smart_chute", SmartChuteBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(p -> p.sound(SoundType.NETHERITE_BLOCK))
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate((c, p) -> BlockStateGen.simpleBlock(c, p, AssetLookup.forPowered(c, p)))
|
||||
.item()
|
||||
.transform(customItemModel("_", "block"))
|
||||
|
@ -549,6 +583,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<GaugeBlock> SPEEDOMETER = REGISTRATE.block("speedometer", GaugeBlock::speed)
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.transform(axeOrPickaxe())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate(new GaugeGenerator()::generate)
|
||||
.item()
|
||||
|
@ -557,6 +592,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<GaugeBlock> STRESSOMETER = REGISTRATE.block("stressometer", GaugeBlock::stress)
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.transform(axeOrPickaxe())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate(new GaugeGenerator()::generate)
|
||||
.item()
|
||||
|
@ -565,12 +601,14 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<BracketBlock> WOODEN_BRACKET = REGISTRATE.block("wooden_bracket", BracketBlock::new)
|
||||
.blockstate(new BracketGenerator("wooden")::generate)
|
||||
.transform(axeOrPickaxe())
|
||||
.item(BracketBlockItem::new)
|
||||
.transform(BracketGenerator.itemModel("wooden"))
|
||||
.register();
|
||||
|
||||
public static final BlockEntry<BracketBlock> METAL_BRACKET = REGISTRATE.block("metal_bracket", BracketBlock::new)
|
||||
.blockstate(new BracketGenerator("metal")::generate)
|
||||
.transform(pickaxeOnly())
|
||||
.item(BracketBlockItem::new)
|
||||
.transform(BracketGenerator.itemModel("metal"))
|
||||
.register();
|
||||
|
@ -579,6 +617,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<FluidPipeBlock> FLUID_PIPE = REGISTRATE.block("fluid_pipe", FluidPipeBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate(BlockStateGen.pipe())
|
||||
.onRegister(CreateRegistrate.blockModel(() -> PipeAttachmentModel::new))
|
||||
.item()
|
||||
|
@ -589,6 +628,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("encased_fluid_pipe", EncasedPipeBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(BlockStateGen.encasedPipe())
|
||||
.onRegister(CreateRegistrate.connectedTextures(new EncasedCTBehaviour(AllSpriteShifts.COPPER_CASING)))
|
||||
.onRegister(CreateRegistrate.casingConnectivity((block, cc) -> cc.make(block, AllSpriteShifts.COPPER_CASING,
|
||||
|
@ -601,6 +641,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("glass_fluid_pipe", GlassFluidPipeBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate((c, p) -> BlockStateGen.axisBlock(c, p, s -> p.models()
|
||||
.getExistingFile(
|
||||
p.modLoc("block/fluid_pipe/window" + (s.getValue(GlassFluidPipeBlock.ALT) ? "_alt" : "")))))
|
||||
|
@ -610,6 +651,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<PumpBlock> MECHANICAL_PUMP = REGISTRATE.block("mechanical_pump", PumpBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate(BlockStateGen.directionalBlockProviderIgnoresWaterlogged(true))
|
||||
.onRegister(CreateRegistrate.blockModel(() -> PipeAttachmentModel::new))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
|
@ -620,6 +662,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<SmartFluidPipeBlock> SMART_FLUID_PIPE =
|
||||
REGISTRATE.block("smart_fluid_pipe", SmartFluidPipeBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate(new SmartFluidPipeGenerator()::generate)
|
||||
.onRegister(CreateRegistrate.blockModel(() -> PipeAttachmentModel::new))
|
||||
.item()
|
||||
|
@ -628,6 +671,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<FluidValveBlock> FLUID_VALVE = REGISTRATE.block("fluid_valve", FluidValveBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate((c, p) -> BlockStateGen.directionalAxisBlock(c, p,
|
||||
(state, vertical) -> AssetLookup.partialBaseModel(c, p, vertical ? "vertical" : "horizontal",
|
||||
state.getValue(FluidValveBlock.ENABLED) ? "open" : "closed")))
|
||||
|
@ -638,12 +682,14 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<ValveHandleBlock> COPPER_VALVE_HANDLE =
|
||||
REGISTRATE.block("copper_valve_handle", ValveHandleBlock::copper)
|
||||
.transform(pickaxeOnly())
|
||||
.transform(BuilderTransformers.valveHandle(null))
|
||||
.register();
|
||||
|
||||
public static final DyedBlockList<ValveHandleBlock> DYED_VALVE_HANDLES = new DyedBlockList<>(colour -> {
|
||||
String colourName = colour.getSerializedName();
|
||||
return REGISTRATE.block(colourName + "_valve_handle", p -> ValveHandleBlock.dyed(p, colour))
|
||||
.transform(pickaxeOnly())
|
||||
.transform(BuilderTransformers.valveHandle(colour))
|
||||
.recipe((c, p) -> ShapedRecipeBuilder.shaped(c.get())
|
||||
.pattern("#")
|
||||
|
@ -658,6 +704,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<FluidTankBlock> FLUID_TANK = REGISTRATE.block("fluid_tank", FluidTankBlock::regular)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate(new FluidTankGenerator()::generate)
|
||||
.onRegister(CreateRegistrate.blockModel(() -> FluidTankModel::standard))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
|
@ -669,8 +716,9 @@ public class AllBlocks {
|
|||
public static final BlockEntry<FluidTankBlock> CREATIVE_FLUID_TANK =
|
||||
REGISTRATE.block("creative_fluid_tank", FluidTankBlock::creative)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(pickaxeOnly())
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.blockstate(new FluidTankGenerator("creative_")::generate)
|
||||
.onRegister(CreateRegistrate.blockModel(() -> FluidTankModel::creative))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
|
@ -685,6 +733,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<HosePulleyBlock> HOSE_PULLEY = REGISTRATE.block("hose_pulley", HosePulleyBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate(BlockStateGen.horizontalBlockProvider(true))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.item()
|
||||
|
@ -693,6 +742,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<ItemDrainBlock> ITEM_DRAIN = REGISTRATE.block("item_drain", ItemDrainBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.transform(pickaxeOnly())
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.blockstate((c, p) -> p.simpleBlock(c.get(), AssetLookup.standardModel(c, p)))
|
||||
.simpleItem()
|
||||
|
@ -700,6 +750,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<SpoutBlock> SPOUT = REGISTRATE.block("spout", SpoutBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate((ctx, prov) -> prov.simpleBlock(ctx.getEntry(), AssetLookup.partialBaseModel(ctx, prov)))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.item(AssemblyOperatorBlockItem::new)
|
||||
|
@ -709,6 +760,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<PortableStorageInterfaceBlock> PORTABLE_FLUID_INTERFACE =
|
||||
REGISTRATE.block("portable_fluid_interface", PortableStorageInterfaceBlock::forFluids)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate((c, p) -> p.directionalBlock(c.get(), AssetLookup.partialBaseModel(c, p)))
|
||||
.onRegister(addMovementBehaviour(new PortableStorageInterfaceMovement()))
|
||||
.item()
|
||||
|
@ -719,12 +771,14 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<MechanicalPistonBlock> MECHANICAL_PISTON =
|
||||
REGISTRATE.block("mechanical_piston", MechanicalPistonBlock::normal)
|
||||
.transform(axeOrPickaxe())
|
||||
.transform(BuilderTransformers.mechanicalPiston(PistonType.DEFAULT))
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.register();
|
||||
|
||||
public static final BlockEntry<MechanicalPistonBlock> STICKY_MECHANICAL_PISTON =
|
||||
REGISTRATE.block("sticky_mechanical_piston", MechanicalPistonBlock::sticky)
|
||||
.transform(axeOrPickaxe())
|
||||
.transform(BuilderTransformers.mechanicalPiston(PistonType.STICKY))
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.register();
|
||||
|
@ -732,6 +786,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<PistonExtensionPoleBlock> PISTON_EXTENSION_POLE =
|
||||
REGISTRATE.block("piston_extension_pole", PistonExtensionPoleBlock::new)
|
||||
.initialProperties(() -> Blocks.PISTON_HEAD)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(BlockStateGen.directionalBlockProviderIgnoresWaterlogged(false))
|
||||
.simpleItem()
|
||||
.register();
|
||||
|
@ -739,6 +794,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<MechanicalPistonHeadBlock> MECHANICAL_PISTON_HEAD =
|
||||
REGISTRATE.block("mechanical_piston_head", MechanicalPistonHeadBlock::new)
|
||||
.initialProperties(() -> Blocks.PISTON_HEAD)
|
||||
.transform(axeOrPickaxe())
|
||||
.loot((p, b) -> p.dropOther(b, PISTON_EXTENSION_POLE.get()))
|
||||
.blockstate((c, p) -> BlockStateGen.directionalBlockIgnoresWaterlogged(c, p, state -> p.models()
|
||||
.getExistingFile(p.modLoc("block/mechanical_piston/" + state.getValue(MechanicalPistonHeadBlock.TYPE)
|
||||
|
@ -749,6 +805,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("gantry_carriage", GantryCarriageBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(BlockStateGen.directionalAxisBlockProvider())
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
|
@ -757,6 +814,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<GantryShaftBlock> GANTRY_SHAFT =
|
||||
REGISTRATE.block("gantry_shaft", GantryShaftBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate((c, p) -> p.directionalBlock(c.get(), s -> {
|
||||
boolean isPowered = s.getValue(GantryShaftBlock.POWERED);
|
||||
boolean isFlipped = s.getValue(GantryShaftBlock.FACING)
|
||||
|
@ -779,6 +837,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<WindmillBearingBlock> WINDMILL_BEARING =
|
||||
REGISTRATE.block("windmill_bearing", WindmillBearingBlock::new)
|
||||
.transform(axeOrPickaxe())
|
||||
.transform(BuilderTransformers.bearing("windmill", "gearbox", true))
|
||||
.transform(BlockStressDefaults.setCapacity(512.0))
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
|
@ -786,6 +845,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<MechanicalBearingBlock> MECHANICAL_BEARING =
|
||||
REGISTRATE.block("mechanical_bearing", MechanicalBearingBlock::new)
|
||||
.transform(axeOrPickaxe())
|
||||
.transform(BuilderTransformers.bearing("mechanical", "gearbox", false))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
|
@ -794,6 +854,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<ClockworkBearingBlock> CLOCKWORK_BEARING =
|
||||
REGISTRATE.block("clockwork_bearing", ClockworkBearingBlock::new)
|
||||
.transform(axeOrPickaxe())
|
||||
.transform(BuilderTransformers.bearing("clockwork", "brass_gearbox", false))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
|
@ -801,6 +862,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<PulleyBlock> ROPE_PULLEY = REGISTRATE.block("rope_pulley", PulleyBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(axeOrPickaxe())
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.blockstate(BlockStateGen.horizontalAxisBlockProvider(true))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
|
@ -828,6 +890,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("cart_assembler", CartAssemblerBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(BlockStateGen.cartAssembler())
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.tag(BlockTags.RAILS, AllBlockTags.SAFE_NBT.tag)
|
||||
|
@ -835,22 +898,10 @@ public class AllBlocks {
|
|||
.transform(customItemModel())
|
||||
.register();
|
||||
|
||||
public static final BlockEntry<ReinforcedRailBlock> REINFORCED_RAIL =
|
||||
REGISTRATE.block("reinforced_rail", ReinforcedRailBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.blockstate(BlockStateGen.reinforcedRail())
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.tag(BlockTags.RAILS)
|
||||
.item()
|
||||
.model((c, p) -> p.blockItem(() -> c.getEntry()
|
||||
.getBlock(), "/block"))
|
||||
.build()
|
||||
.register();
|
||||
|
||||
public static final BlockEntry<ControllerRailBlock> CONTROLLER_RAIL =
|
||||
REGISTRATE.block("controller_rail", ControllerRailBlock::new)
|
||||
.initialProperties(() -> Blocks.POWERED_RAIL)
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate(new ControllerRailGenerator()::generate)
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.color(() -> ColorHandlers::getRedstonePower)
|
||||
|
@ -870,6 +921,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<LinearChassisBlock> LINEAR_CHASSIS =
|
||||
REGISTRATE.block("linear_chassis", LinearChassisBlock::new)
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.transform(axeOrPickaxe())
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.blockstate(BlockStateGen.linearChassis())
|
||||
.onRegister(connectedTextures(new ChassisCTBehaviour()))
|
||||
|
@ -880,6 +932,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<LinearChassisBlock> SECONDARY_LINEAR_CHASSIS =
|
||||
REGISTRATE.block("secondary_linear_chassis", LinearChassisBlock::new)
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.transform(axeOrPickaxe())
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.blockstate(BlockStateGen.linearChassis())
|
||||
.onRegister(connectedTextures(new ChassisCTBehaviour()))
|
||||
|
@ -889,6 +942,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<RadialChassisBlock> RADIAL_CHASSIS =
|
||||
REGISTRATE.block("radial_chassis", RadialChassisBlock::new)
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.transform(axeOrPickaxe())
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.blockstate(BlockStateGen.radialChassis())
|
||||
.item()
|
||||
|
@ -901,6 +955,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<StickerBlock> STICKER = REGISTRATE.block("sticker", StickerBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(pickaxeOnly())
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.blockstate((c, p) -> p.directionalBlock(c.get(), AssetLookup.forPowered(c, p)))
|
||||
|
@ -910,6 +965,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<DrillBlock> MECHANICAL_DRILL = REGISTRATE.block("mechanical_drill", DrillBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(BlockStateGen.directionalBlockProvider(true))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.onRegister(addMovementBehaviour(new DrillMovementBehaviour()))
|
||||
|
@ -919,6 +975,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<SawBlock> MECHANICAL_SAW = REGISTRATE.block("mechanical_saw", SawBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(new SawGenerator()::generate)
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.onRegister(addMovementBehaviour(new SawMovementBehaviour()))
|
||||
|
@ -929,6 +986,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<DeployerBlock> DEPLOYER = REGISTRATE.block("deployer", DeployerBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(BlockStateGen.directionalAxisBlockProvider())
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.onRegister(addMovementBehaviour(new DeployerMovementBehaviour()))
|
||||
|
@ -939,6 +997,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<PortableStorageInterfaceBlock> PORTABLE_STORAGE_INTERFACE =
|
||||
REGISTRATE.block("portable_storage_interface", PortableStorageInterfaceBlock::forItems)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate((c, p) -> p.directionalBlock(c.get(), AssetLookup.partialBaseModel(c, p)))
|
||||
.onRegister(addMovementBehaviour(new PortableStorageInterfaceMovement()))
|
||||
.item()
|
||||
|
@ -948,6 +1007,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<RedstoneContactBlock> REDSTONE_CONTACT =
|
||||
REGISTRATE.block("redstone_contact", RedstoneContactBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(axeOrPickaxe())
|
||||
.onRegister(addMovementBehaviour(new ContactMovementBehaviour()))
|
||||
.blockstate((c, p) -> p.directionalBlock(c.get(), AssetLookup.forPowered(c, p)))
|
||||
.item()
|
||||
|
@ -957,6 +1017,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<HarvesterBlock> MECHANICAL_HARVESTER =
|
||||
REGISTRATE.block("mechanical_harvester", HarvesterBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(axeOrPickaxe())
|
||||
.onRegister(addMovementBehaviour(new HarvesterMovementBehaviour()))
|
||||
.blockstate(BlockStateGen.horizontalBlockProvider(true))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
|
@ -967,6 +1028,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<PloughBlock> MECHANICAL_PLOUGH =
|
||||
REGISTRATE.block("mechanical_plough", PloughBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(axeOrPickaxe())
|
||||
.onRegister(addMovementBehaviour(new PloughMovementBehaviour()))
|
||||
.blockstate(BlockStateGen.horizontalBlockProvider(false))
|
||||
.simpleItem()
|
||||
|
@ -977,6 +1039,7 @@ public class AllBlocks {
|
|||
SeatMovementBehaviour movementBehaviour = new SeatMovementBehaviour();
|
||||
return REGISTRATE.block(colourName + "_seat", p -> new SeatBlock(p, colour, colour == DyeColor.RED))
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.transform(axeOnly())
|
||||
.onRegister(addMovementBehaviour(movementBehaviour))
|
||||
.blockstate((c, p) -> {
|
||||
p.simpleBlock(c.get(), p.models()
|
||||
|
@ -1011,6 +1074,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<SailBlock> SAIL_FRAME = REGISTRATE.block("sail_frame", p -> SailBlock.frame(p))
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(axeOnly())
|
||||
.blockstate(BlockStateGen.directionalBlockProvider(false))
|
||||
.tag(AllBlockTags.WINDMILL_SAILS.tag)
|
||||
.tag(AllBlockTags.FAN_TRANSPARENT.tag)
|
||||
|
@ -1021,6 +1085,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("white_sail", p -> SailBlock.withCanvas(p, DyeColor.WHITE))
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(axeOnly())
|
||||
.blockstate(BlockStateGen.directionalBlockProvider(false))
|
||||
.tag(AllBlockTags.WINDMILL_SAILS.tag)
|
||||
.simpleItem()
|
||||
|
@ -1032,8 +1097,9 @@ public class AllBlocks {
|
|||
}
|
||||
String colourName = colour.getSerializedName();
|
||||
return REGISTRATE.block(colourName + "_sail", p -> SailBlock.withCanvas(p, colour))
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(axeOnly())
|
||||
.blockstate((c, p) -> p.directionalBlock(c.get(), p.models()
|
||||
.withExistingParent(colourName + "_sail", p.modLoc("block/white_sail"))
|
||||
.texture("0", p.modLoc("block/sail/canvas_" + colourName))))
|
||||
|
@ -1072,6 +1138,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("mechanical_crafter", MechanicalCrafterBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(BlockStateGen.horizontalBlockProvider(true))
|
||||
.transform(BlockStressDefaults.setImpact(2.0))
|
||||
.onRegister(CreateRegistrate.connectedTextures(new CrafterCTBehaviour()))
|
||||
|
@ -1083,6 +1150,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<SequencedGearshiftBlock> SEQUENCED_GEARSHIFT =
|
||||
REGISTRATE.block("sequenced_gearshift", SequencedGearshiftBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(axeOrPickaxe())
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
|
@ -1094,6 +1162,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<FlywheelBlock> FLYWHEEL = REGISTRATE.block("flywheel", FlywheelBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(BlockBehaviour.Properties::noOcclusion)
|
||||
.transform(axeOrPickaxe())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate(new FlywheelGenerator()::generate)
|
||||
.item()
|
||||
|
@ -1103,6 +1172,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<FurnaceEngineBlock> FURNACE_ENGINE =
|
||||
REGISTRATE.block("furnace_engine", FurnaceEngineBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.transform(pickaxeOnly())
|
||||
.tag(AllBlockTags.BRITTLE.tag)
|
||||
.blockstate(BlockStateGen.horizontalBlockProvider(true))
|
||||
.transform(BlockStressDefaults.setCapacity(1024.0))
|
||||
|
@ -1113,6 +1183,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<SpeedControllerBlock> ROTATION_SPEED_CONTROLLER =
|
||||
REGISTRATE.block("rotation_speed_controller", SpeedControllerBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.transform(axeOrPickaxe())
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate(BlockStateGen.horizontalAxisBlockProvider(true))
|
||||
|
@ -1128,6 +1199,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<ArmBlock> MECHANICAL_ARM = REGISTRATE.block("mechanical_arm", ArmBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate((c, p) -> p.getVariantBuilder(c.get())
|
||||
.forAllStates(s -> ConfiguredModel.builder()
|
||||
.modelFile(AssetLookup.partialBaseModel(c, p))
|
||||
|
@ -1141,6 +1213,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<AndesiteFunnelBlock> ANDESITE_FUNNEL =
|
||||
REGISTRATE.block("andesite_funnel", AndesiteFunnelBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(pickaxeOnly())
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.onRegister(addMovementBehaviour(FunnelMovementBehaviour.andesite()))
|
||||
.blockstate(new FunnelGenerator("andesite", false)::generate)
|
||||
|
@ -1152,6 +1225,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<BeltFunnelBlock> ANDESITE_BELT_FUNNEL =
|
||||
REGISTRATE.block("andesite_belt_funnel", p -> new BeltFunnelBlock(AllBlocks.ANDESITE_FUNNEL, p))
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(pickaxeOnly())
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.blockstate(new BeltFunnelGenerator("andesite", new ResourceLocation("block/polished_andesite"))::generate)
|
||||
.loot((p, b) -> p.dropOther(b, ANDESITE_FUNNEL.get()))
|
||||
|
@ -1160,6 +1234,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<BrassFunnelBlock> BRASS_FUNNEL =
|
||||
REGISTRATE.block("brass_funnel", BrassFunnelBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.transform(pickaxeOnly())
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.onRegister(addMovementBehaviour(FunnelMovementBehaviour.brass()))
|
||||
.blockstate(new FunnelGenerator("brass", true)::generate)
|
||||
|
@ -1171,6 +1246,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<BeltFunnelBlock> BRASS_BELT_FUNNEL =
|
||||
REGISTRATE.block("brass_belt_funnel", p -> new BeltFunnelBlock(AllBlocks.BRASS_FUNNEL, p))
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.transform(pickaxeOnly())
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.blockstate(new BeltFunnelGenerator("brass", Create.asResource("block/brass_block"))::generate)
|
||||
.loot((p, b) -> p.dropOther(b, BRASS_FUNNEL.get()))
|
||||
|
@ -1190,6 +1266,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<ContentObserverBlock> CONTENT_OBSERVER =
|
||||
REGISTRATE.block("content_observer", ContentObserverBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate((c, p) -> p.horizontalBlock(c.get(), AssetLookup.forPowered(c, p)))
|
||||
.item()
|
||||
.transform(customItemModel("_", "block"))
|
||||
|
@ -1198,6 +1275,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<StockpileSwitchBlock> STOCKPILE_SWITCH =
|
||||
REGISTRATE.block("stockpile_switch", StockpileSwitchBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate((c, p) -> p.horizontalBlock(c.get(),
|
||||
AssetLookup.withIndicator(c, p, $ -> AssetLookup.standardModel(c, p), StockpileSwitchBlock.INDICATOR)))
|
||||
.simpleItem()
|
||||
|
@ -1218,6 +1296,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("nixie_tube", p -> new NixieTubeBlock(p, DyeColor.ORANGE))
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(p -> p.lightLevel($ -> 5))
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(new NixieTubeGenerator()::generate)
|
||||
.addLayer(() -> RenderType::translucent)
|
||||
.item()
|
||||
|
@ -1231,6 +1310,7 @@ public class AllBlocks {
|
|||
return REGISTRATE.block(colourName + "_nixie_tube", p -> new NixieTubeBlock(p, colour))
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(p -> p.lightLevel($ -> 5))
|
||||
.transform(axeOrPickaxe())
|
||||
.blockstate(new NixieTubeGenerator()::generate)
|
||||
.loot((p, b) -> p.dropOther(b, ORANGE_NIXIE_TUBE.get()))
|
||||
.addLayer(() -> RenderType::translucent)
|
||||
|
@ -1240,6 +1320,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<RedstoneLinkBlock> REDSTONE_LINK =
|
||||
REGISTRATE.block("redstone_link", RedstoneLinkBlock::new)
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.transform(axeOrPickaxe())
|
||||
.tag(AllBlockTags.BRITTLE.tag, AllBlockTags.SAFE_NBT.tag)
|
||||
.blockstate(new RedstoneLinkGenerator()::generate)
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
|
@ -1250,6 +1331,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<AnalogLeverBlock> ANALOG_LEVER =
|
||||
REGISTRATE.block("analog_lever", AnalogLeverBlock::new)
|
||||
.initialProperties(() -> Blocks.LEVER)
|
||||
.transform(axeOrPickaxe())
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.blockstate((c, p) -> p.horizontalFaceBlock(c.get(), AssetLookup.partialBaseModel(c, p)))
|
||||
.onRegister(ItemUseOverrides::addBlock)
|
||||
|
@ -1307,6 +1389,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<LecternControllerBlock> LECTERN_CONTROLLER =
|
||||
REGISTRATE.block("lectern_controller", LecternControllerBlock::new)
|
||||
.initialProperties(() -> Blocks.LECTERN)
|
||||
.transform(axeOnly())
|
||||
.blockstate((c, p) -> p.horizontalBlock(c.get(), p.models()
|
||||
.getExistingFile(p.mcLoc("block/lectern"))))
|
||||
.loot((lt, block) -> lt.dropOther(block, Blocks.LECTERN))
|
||||
|
@ -1322,6 +1405,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("copper_backtank", CopperBacktankBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.blockstate((c, p) -> p.horizontalBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p)))
|
||||
.transform(pickaxeOnly())
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.loot((lt, block) -> {
|
||||
|
@ -1392,6 +1476,8 @@ public class AllBlocks {
|
|||
public static final BlockEntry<OxidizingBlock> COPPER_ORE =
|
||||
REGISTRATE.block("copper_ore", p -> new OxidizingBlock(p, 1))
|
||||
.initialProperties(() -> Blocks.IRON_ORE)
|
||||
.properties(p -> p.requiresCorrectToolForDrops())
|
||||
.transform(pickaxeOnly())
|
||||
.transform(oxidizedBlockstate())
|
||||
.tag(Tags.Blocks.ORES)
|
||||
.transform(tagBlockAndItem("ores/copper"))
|
||||
|
@ -1403,6 +1489,8 @@ public class AllBlocks {
|
|||
.initialProperties(() -> Blocks.GOLD_BLOCK)
|
||||
.properties(p -> p.requiresCorrectToolForDrops()
|
||||
.sound(SoundType.STONE))
|
||||
.transform(pickaxeOnly())
|
||||
.tag(BlockTags.NEEDS_IRON_TOOL)
|
||||
.tag(Tags.Blocks.ORES)
|
||||
.transform(tagBlockAndItem("ores/zinc"))
|
||||
.tag(Tags.Items.ORES)
|
||||
|
@ -1412,6 +1500,8 @@ public class AllBlocks {
|
|||
public static final BlockEntry<OxidizingBlock> COPPER_BLOCK =
|
||||
REGISTRATE.block("copper_block", p -> new OxidizingBlock(p, 1 / 32f))
|
||||
.initialProperties(() -> Blocks.IRON_BLOCK)
|
||||
.properties(p -> p.requiresCorrectToolForDrops())
|
||||
.transform(pickaxeOnly())
|
||||
.tag(Tags.Blocks.STORAGE_BLOCKS)
|
||||
.tag(BlockTags.BEACON_BASE_BLOCKS)
|
||||
.transform(tagBlockAndItem("storage_blocks/copper"))
|
||||
|
@ -1424,6 +1514,8 @@ public class AllBlocks {
|
|||
public static final BlockEntry<OxidizingBlock> COPPER_SHINGLES =
|
||||
REGISTRATE.block("copper_shingles", p -> new OxidizingBlock(p, 1 / 32f))
|
||||
.initialProperties(() -> Blocks.IRON_BLOCK)
|
||||
.properties(p -> p.requiresCorrectToolForDrops())
|
||||
.transform(pickaxeOnly())
|
||||
.item()
|
||||
.transform(oxidizedItemModel())
|
||||
.transform(oxidizedBlockstate())
|
||||
|
@ -1432,6 +1524,8 @@ public class AllBlocks {
|
|||
public static final BlockEntry<OxidizingBlock> COPPER_TILES =
|
||||
REGISTRATE.block("copper_tiles", p -> new OxidizingBlock(p, 1 / 32f))
|
||||
.initialProperties(() -> Blocks.IRON_BLOCK)
|
||||
.properties(p -> p.requiresCorrectToolForDrops())
|
||||
.transform(pickaxeOnly())
|
||||
.item()
|
||||
.transform(oxidizedItemModel())
|
||||
.transform(oxidizedBlockstate())
|
||||
|
@ -1439,6 +1533,9 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<Block> ZINC_BLOCK = REGISTRATE.block("zinc_block", p -> new Block(p))
|
||||
.initialProperties(() -> Blocks.IRON_BLOCK)
|
||||
.properties(p -> p.requiresCorrectToolForDrops())
|
||||
.transform(pickaxeOnly())
|
||||
.tag(BlockTags.NEEDS_IRON_TOOL)
|
||||
.tag(Tags.Blocks.STORAGE_BLOCKS)
|
||||
.tag(BlockTags.BEACON_BASE_BLOCKS)
|
||||
.transform(tagBlockAndItem("storage_blocks/zinc"))
|
||||
|
@ -1449,8 +1546,11 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<Block> BRASS_BLOCK = REGISTRATE.block("brass_block", p -> new Block(p))
|
||||
.initialProperties(() -> Blocks.IRON_BLOCK)
|
||||
.properties(p -> p.requiresCorrectToolForDrops())
|
||||
.transform(pickaxeOnly())
|
||||
.blockstate((c, p) -> p.simpleBlock(c.get(), p.models()
|
||||
.cubeAll(c.getName(), p.modLoc("block/brass_storage_block"))))
|
||||
.tag(BlockTags.NEEDS_IRON_TOOL)
|
||||
.tag(Tags.Blocks.STORAGE_BLOCKS)
|
||||
.tag(BlockTags.BEACON_BASE_BLOCKS)
|
||||
.transform(tagBlockAndItem("storage_blocks/brass"))
|
||||
|
|
|
@ -54,6 +54,19 @@ public class AllTags {
|
|||
return forgeTag(FluidTags::createOptional, path);
|
||||
}
|
||||
|
||||
public static <T extends Block, P> NonNullFunction<BlockBuilder<T, P>, BlockBuilder<T, P>> axeOrPickaxe() {
|
||||
return b -> b.tag(BlockTags.MINEABLE_WITH_AXE)
|
||||
.tag(BlockTags.MINEABLE_WITH_PICKAXE);
|
||||
}
|
||||
|
||||
public static <T extends Block, P> NonNullFunction<BlockBuilder<T, P>, BlockBuilder<T, P>> axeOnly() {
|
||||
return b -> b.tag(BlockTags.MINEABLE_WITH_AXE);
|
||||
}
|
||||
|
||||
public static <T extends Block, P> NonNullFunction<BlockBuilder<T, P>, BlockBuilder<T, P>> pickaxeOnly() {
|
||||
return b -> b.tag(BlockTags.MINEABLE_WITH_PICKAXE);
|
||||
}
|
||||
|
||||
public static <T extends Block, P> NonNullFunction<BlockBuilder<T, P>, ItemBuilder<BlockItem, BlockBuilder<T, P>>> tagBlockAndItem(
|
||||
String path) {
|
||||
return b -> b.tag(forgeBlockTag(path))
|
||||
|
@ -63,9 +76,7 @@ public class AllTags {
|
|||
|
||||
public enum NameSpace {
|
||||
|
||||
MOD(Create.ID, false, true),
|
||||
FORGE("forge"),
|
||||
TIC("tconstruct")
|
||||
MOD(Create.ID, false, true), FORGE("forge"), TIC("tconstruct")
|
||||
|
||||
;
|
||||
|
||||
|
@ -325,8 +336,8 @@ public class AllTags {
|
|||
AllBlockTags.WRENCH_PICKUP.includeAll(BlockTags.BUTTONS);
|
||||
AllBlockTags.WRENCH_PICKUP.includeAll(BlockTags.PRESSURE_PLATES);
|
||||
AllBlockTags.WRENCH_PICKUP.add(Blocks.REDSTONE_WIRE, Blocks.REDSTONE_TORCH, Blocks.REPEATER, Blocks.LEVER,
|
||||
Blocks.COMPARATOR, Blocks.OBSERVER, Blocks.REDSTONE_WALL_TORCH, Blocks.PISTON, Blocks.STICKY_PISTON,
|
||||
Blocks.TRIPWIRE, Blocks.TRIPWIRE_HOOK, Blocks.DAYLIGHT_DETECTOR, Blocks.TARGET);
|
||||
Blocks.COMPARATOR, Blocks.OBSERVER, Blocks.REDSTONE_WALL_TORCH, Blocks.PISTON, Blocks.STICKY_PISTON,
|
||||
Blocks.TRIPWIRE, Blocks.TRIPWIRE_HOOK, Blocks.DAYLIGHT_DETECTOR, Blocks.TARGET);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -386,7 +386,7 @@ public class RotationPropagator {
|
|||
.getBlockState(neighbourPos);
|
||||
if (!(neighbourState.getBlock() instanceof IRotate))
|
||||
return null;
|
||||
if (!neighbourState.hasTileEntity())
|
||||
if (!neighbourState.hasBlockEntity())
|
||||
return null;
|
||||
BlockEntity neighbourTE = currentTE.getLevel()
|
||||
.getBlockEntity(neighbourPos);
|
||||
|
|
|
@ -2,14 +2,10 @@ package com.simibubi.create.content.contraptions.base;
|
|||
|
||||
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
public class CasingBlock extends Block implements IWrenchable {
|
||||
|
||||
|
@ -22,23 +18,4 @@ public class CasingBlock extends Block implements IWrenchable {
|
|||
return InteractionResult.FAIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToolType getHarvestTool(BlockState state) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(BlockState state, BlockGetter world, BlockPos pos, Player player) {
|
||||
for (ToolType toolType : player.getMainHandItem().getToolTypes()) {
|
||||
if (isToolEffective(state, toolType))
|
||||
return true;
|
||||
}
|
||||
return super.canHarvestBlock(state, world, pos, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isToolEffective(BlockState state, ToolType tool) {
|
||||
return tool == ToolType.AXE || tool == ToolType.PICKAXE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,16 +5,13 @@ import com.simibubi.create.foundation.item.ItemDescription.Palette;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
public abstract class KineticBlock extends Block implements IRotate {
|
||||
|
||||
|
@ -24,26 +21,6 @@ public abstract class KineticBlock extends Block implements IRotate {
|
|||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToolType getHarvestTool(BlockState state) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(BlockState state, BlockGetter world, BlockPos pos, Player player) {
|
||||
for (ToolType toolType : player.getMainHandItem()
|
||||
.getToolTypes()) {
|
||||
if (isToolEffective(state, toolType))
|
||||
return true;
|
||||
}
|
||||
return super.canHarvestBlock(state, world, pos, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isToolEffective(BlockState state, ToolType tool) {
|
||||
return tool == ToolType.AXE || tool == ToolType.PICKAXE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlace(BlockState state, Level worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
|
||||
// onBlockAdded is useless for init, as sometimes the TE gets re-instantiated
|
||||
|
@ -58,7 +35,7 @@ public abstract class KineticBlock extends Block implements IRotate {
|
|||
|
||||
if (oldState.getBlock() != state.getBlock())
|
||||
return;
|
||||
if (state.hasTileEntity() != oldState.hasTileEntity())
|
||||
if (state.hasBlockEntity() != oldState.hasBlockEntity())
|
||||
return;
|
||||
if (!areStatesKineticallyEquivalent(oldState, state))
|
||||
return;
|
||||
|
@ -72,20 +49,12 @@ public abstract class KineticBlock extends Block implements IRotate {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean areStatesKineticallyEquivalent(BlockState oldState, BlockState newState) {
|
||||
if (oldState.getBlock() != newState.getBlock())
|
||||
return false;
|
||||
return getRotationAxis(newState) == getRotationAxis(oldState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract BlockEntity createTileEntity(BlockState state, BlockGetter world);
|
||||
|
||||
@Override
|
||||
public void updateIndirectNeighbourShapes(BlockState stateIn, LevelAccessor worldIn, BlockPos pos, int flags, int count) {
|
||||
if (worldIn.isClientSide())
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.world.level.BlockGetter;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
|
@ -35,17 +35,13 @@ public class DrillBlock extends DirectionalKineticBlock implements ITE<DrillTile
|
|||
public DrillBlock(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level worldIn, BlockPos pos, Entity entityIn) {
|
||||
if (entityIn instanceof ItemEntity)
|
||||
return;
|
||||
if (!new AABB(pos).deflate(.1f).intersects(entityIn.getBoundingBox()))
|
||||
if (!new AABB(pos).deflate(.1f)
|
||||
.intersects(entityIn.getBoundingBox()))
|
||||
return;
|
||||
withTileEntityDo(worldIn, pos, te -> {
|
||||
if (te.getSpeed() == 0)
|
||||
|
@ -54,11 +50,6 @@ public class DrillBlock extends DirectionalKineticBlock implements ITE<DrillTile
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.DRILL.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
return AllShapes.CASING_12PX.get(state.getValue(FACING));
|
||||
|
@ -66,18 +57,20 @@ public class DrillBlock extends DirectionalKineticBlock implements ITE<DrillTile
|
|||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
boolean isMoving) {
|
||||
withTileEntityDo(worldIn, pos, DrillTileEntity::destroyNextTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Axis getRotationAxis(BlockState state) {
|
||||
return state.getValue(FACING).getAxis();
|
||||
return state.getValue(FACING)
|
||||
.getAxis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) {
|
||||
return face == state.getValue(FACING).getOpposite();
|
||||
return face == state.getValue(FACING)
|
||||
.getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -85,11 +78,6 @@ public class DrillBlock extends DirectionalKineticBlock implements ITE<DrillTile
|
|||
return PushReaction.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<DrillTileEntity> getTileEntityClass() {
|
||||
return DrillTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
return false;
|
||||
|
@ -102,4 +90,14 @@ public class DrillBlock extends DirectionalKineticBlock implements ITE<DrillTile
|
|||
double sub3 = Math.min(speedAbs / 64, 4);
|
||||
return Mth.clamp(sub1 + sub2 + sub3, 1, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<DrillTileEntity> getTileEntityClass() {
|
||||
return DrillTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends DrillTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.DRILL.get();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
package com.simibubi.create.content.contraptions.components.actors;
|
||||
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
||||
public class HarvesterBlock extends AttachedActorBlock {
|
||||
public class HarvesterBlock extends AttachedActorBlock implements ITE<HarvesterTileEntity> {
|
||||
|
||||
public HarvesterBlock(Properties p_i48377_1_) {
|
||||
super(p_i48377_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
public Class<HarvesterTileEntity> getTileEntityClass() {
|
||||
return HarvesterTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return new HarvesterTileEntity(AllTileEntities.HARVESTER.get());
|
||||
public BlockEntityType<? extends HarvesterTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.HARVESTER.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.simibubi.create.content.contraptions.components.actors;
|
|||
|
||||
import com.simibubi.create.foundation.tileEntity.SyncedTileEntity;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
@ -14,8 +16,8 @@ public class HarvesterTileEntity extends SyncedTileEntity {
|
|||
// For simulations such as Ponder
|
||||
private float manuallyAnimatedSpeed;
|
||||
|
||||
public HarvesterTileEntity(BlockEntityType<? extends HarvesterTileEntity> type) {
|
||||
super(type);
|
||||
public HarvesterTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,7 +13,7 @@ import net.minecraft.world.item.context.BlockPlaceContext;
|
|||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
@ -38,17 +38,6 @@ public class PortableStorageInterfaceBlock extends WrenchableDirectionalBlock
|
|||
this.fluids = fluids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return (fluids ? AllTileEntities.PORTABLE_FLUID_INTERFACE : AllTileEntities.PORTABLE_STORAGE_INTERFACE)
|
||||
.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block p_220069_4_, BlockPos p_220069_5_,
|
||||
boolean p_220069_6_) {
|
||||
|
@ -82,4 +71,10 @@ public class PortableStorageInterfaceBlock extends WrenchableDirectionalBlock
|
|||
return PortableStorageInterfaceTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends PortableStorageInterfaceTileEntity> getTileEntityType() {
|
||||
return fluids ? AllTileEntities.PORTABLE_FLUID_INTERFACE.get()
|
||||
: AllTileEntities.PORTABLE_STORAGE_INTERFACE.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ public class SeatBlock extends Block {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fallOn(Level p_180658_1_, BlockPos p_180658_2_, Entity p_180658_3_, float p_180658_4_) {
|
||||
super.fallOn(p_180658_1_, p_180658_2_, p_180658_3_, p_180658_4_ * 0.5F);
|
||||
public void fallOn(Level p_152426_, BlockState p_152427_, BlockPos p_152428_, Entity p_152429_, float p_152430_) {
|
||||
super.fallOn(p_152426_, p_152427_, p_152428_, p_152429_, p_152430_ * 0.5F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,11 +35,6 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData {
|
|||
EntityType.Builder<SeatEntity> entityBuilder = (EntityType.Builder<SeatEntity>) builder;
|
||||
return entityBuilder.sized(0.25f, 0.35f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AABB getBoundingBox() {
|
||||
return super.getBoundingBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosRaw(double x, double y, double z) {
|
||||
|
@ -60,7 +55,7 @@ public class SeatEntity extends Entity implements IEntityAdditionalSpawnData {
|
|||
.getBlock() instanceof SeatBlock;
|
||||
if (isVehicle() && blockPresent)
|
||||
return;
|
||||
this.remove();
|
||||
this.discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -158,7 +158,7 @@ public interface IMovedDispenseItemBehaviour {
|
|||
BlockState state = context.world.getBlockState(interactAt);
|
||||
Block block = state.getBlock();
|
||||
|
||||
if (block.is(BlockTags.BEEHIVES) && state.getValue(BeehiveBlock.HONEY_LEVEL) >= 5) {
|
||||
if (state.is(BlockTags.BEEHIVES) && state.getValue(BeehiveBlock.HONEY_LEVEL) >= 5) {
|
||||
((BeehiveBlock) block).releaseBeesAndResetHoneyLevel(context.world, state, interactAt, null,
|
||||
BeehiveBlockEntity.BeeReleaseStatus.BEE_RELEASED);
|
||||
this.successful = true;
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.clock;
|
|||
import com.simibubi.create.AllShapes;
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -14,13 +15,13 @@ import net.minecraft.world.item.context.BlockPlaceContext;
|
|||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class CuckooClockBlock extends HorizontalKineticBlock {
|
||||
public class CuckooClockBlock extends HorizontalKineticBlock implements ITE<CuckooClockTileEntity> {
|
||||
|
||||
private boolean mysterious;
|
||||
|
||||
|
@ -36,11 +37,6 @@ public class CuckooClockBlock extends HorizontalKineticBlock {
|
|||
super(properties);
|
||||
this.mysterious = mysterious;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.CUCKOO_CLOCK.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState p_220053_1_, BlockGetter p_220053_2_, BlockPos p_220053_3_,
|
||||
|
@ -82,4 +78,14 @@ public class CuckooClockBlock extends HorizontalKineticBlock {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<CuckooClockTileEntity> getTileEntityClass() {
|
||||
return CuckooClockTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends CuckooClockTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.CUCKOO_CLOCK.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
|
@ -41,7 +41,8 @@ import net.minecraftforge.items.IItemHandler;
|
|||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
public class MechanicalCrafterBlock extends HorizontalKineticBlock implements ITE<MechanicalCrafterTileEntity>, ICogWheel {
|
||||
public class MechanicalCrafterBlock extends HorizontalKineticBlock
|
||||
implements ITE<MechanicalCrafterTileEntity>, ICogWheel {
|
||||
|
||||
public static final EnumProperty<Pointing> POINTING = EnumProperty.create("pointing", Pointing.class);
|
||||
|
||||
|
@ -55,11 +56,6 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
|
|||
super.createBlockStateDefinition(builder.add(POINTING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.MECHANICAL_CRAFTER.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Axis getRotationAxis(BlockState state) {
|
||||
return state.getValue(HORIZONTAL_FACING)
|
||||
|
@ -99,7 +95,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
|
|||
}
|
||||
}
|
||||
|
||||
if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) {
|
||||
if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) {
|
||||
MechanicalCrafterTileEntity crafter = CrafterHelper.getCrafter(worldIn, pos);
|
||||
if (crafter != null) {
|
||||
if (crafter.covered)
|
||||
|
@ -148,7 +144,8 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
|
|||
public InteractionResult onWrenched(BlockState state, UseOnContext context) {
|
||||
if (context.getClickedFace() == state.getValue(HORIZONTAL_FACING)) {
|
||||
if (!context.getLevel().isClientSide)
|
||||
KineticTileEntity.switchToBlockState(context.getLevel(), context.getClickedPos(), state.cycle(POINTING));
|
||||
KineticTileEntity.switchToBlockState(context.getLevel(), context.getClickedPos(),
|
||||
state.cycle(POINTING));
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -169,7 +166,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
|
|||
|
||||
if (AllBlocks.MECHANICAL_ARM.isIn(heldItem))
|
||||
return InteractionResult.PASS;
|
||||
|
||||
|
||||
if (hit.getDirection() == state.getValue(HORIZONTAL_FACING)) {
|
||||
|
||||
if (crafter.phase != Phase.IDLE && !wrenched) {
|
||||
|
@ -205,7 +202,8 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
|
|||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
ItemStack inSlot = crafter.getInventory().getItem(0);
|
||||
ItemStack inSlot = crafter.getInventory()
|
||||
.getItem(0);
|
||||
if (inSlot.isEmpty()) {
|
||||
if (crafter.covered && !wrenched) {
|
||||
if (worldIn.isClientSide)
|
||||
|
@ -214,7 +212,8 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
|
|||
crafter.setChanged();
|
||||
crafter.sendData();
|
||||
if (!player.isCreative())
|
||||
player.getInventory().placeItemBackInInventory(worldIn, AllItems.CRAFTER_SLOT_COVER.asStack());
|
||||
player.getInventory()
|
||||
.placeItemBackInInventory(AllItems.CRAFTER_SLOT_COVER.asStack());
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
return InteractionResult.PASS;
|
||||
|
@ -223,8 +222,10 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
|
|||
return InteractionResult.PASS;
|
||||
if (worldIn.isClientSide)
|
||||
return InteractionResult.SUCCESS;
|
||||
player.getInventory().placeItemBackInInventory(worldIn, inSlot);
|
||||
crafter.getInventory().setStackInSlot(0, ItemStack.EMPTY);
|
||||
player.getInventory()
|
||||
.placeItemBackInInventory(inSlot);
|
||||
crafter.getInventory()
|
||||
.setStackInSlot(0, ItemStack.EMPTY);
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -233,7 +234,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
|
|||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
boolean isMoving) {
|
||||
InvManipulationBehaviour behaviour = TileEntityBehaviour.get(worldIn, pos, InvManipulationBehaviour.TYPE);
|
||||
if (behaviour != null)
|
||||
behaviour.onNeighborChanged(fromPos);
|
||||
|
@ -281,4 +282,9 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
|
|||
return MechanicalCrafterTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends MechanicalCrafterTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.MECHANICAL_CRAFTER.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
@ -97,11 +97,6 @@ public class HandCrankBlock extends DirectionalKineticBlock implements ITE<HandC
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.HAND_CRANK.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasShaftTowards(LevelReader world, BlockPos pos, BlockState state, Direction face) {
|
||||
return face == state.getValue(FACING)
|
||||
|
@ -118,6 +113,11 @@ public class HandCrankBlock extends DirectionalKineticBlock implements ITE<HandC
|
|||
public Class<HandCrankTileEntity> getTileEntityClass() {
|
||||
return HandCrankTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends HandCrankTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.HAND_CRANK.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
|
|
|
@ -18,7 +18,7 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
|
@ -30,11 +30,6 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE
|
|||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.CRUSHING_WHEEL.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Axis getRotationAxis(BlockState state) {
|
||||
return state.getValue(AXIS);
|
||||
|
@ -194,5 +189,10 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock implements ITE
|
|||
public Class<CrushingWheelTileEntity> getTileEntityClass() {
|
||||
return CrushingWheelTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends CrushingWheelTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.CRUSHING_WHEEL.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import net.minecraft.world.level.LevelAccessor;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.DirectionalBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -34,11 +35,11 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
|||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.EntityCollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class CrushingWheelControllerBlock extends DirectionalBlock
|
||||
implements ITE<CrushingWheelControllerTileEntity> {
|
||||
public class CrushingWheelControllerBlock extends DirectionalBlock implements ITE<CrushingWheelControllerTileEntity> {
|
||||
|
||||
public CrushingWheelControllerBlock(Properties p_i48440_1_) {
|
||||
super(p_i48440_1_);
|
||||
|
@ -46,11 +47,6 @@ public class CrushingWheelControllerBlock extends DirectionalBlock
|
|||
|
||||
public static final BooleanProperty VALID = BooleanProperty.create("valid");
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeReplaced(BlockState state, BlockPlaceContext useContext) {
|
||||
return false;
|
||||
|
@ -61,11 +57,6 @@ public class CrushingWheelControllerBlock extends DirectionalBlock
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.CRUSHING_WHEEL_CONTROLLER.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) {
|
||||
builder.add(VALID);
|
||||
|
@ -85,9 +76,8 @@ public class CrushingWheelControllerBlock extends DirectionalBlock
|
|||
withTileEntityDo(worldIn, pos, te -> {
|
||||
if (te.processingEntity == entityIn)
|
||||
|
||||
entityIn.makeStuckInBlock(state, new Vec3(axis == Axis.X ? (double) 0.05F : 0.25D
|
||||
, axis == Axis.Y ? (double) 0.05F : 0.25D
|
||||
, axis == Axis.Z ? (double) 0.05F : 0.25D));
|
||||
entityIn.makeStuckInBlock(state, new Vec3(axis == Axis.X ? (double) 0.05F : 0.25D,
|
||||
axis == Axis.Y ? (double) 0.05F : 0.25D, axis == Axis.Z ? (double) 0.05F : 0.25D));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -118,7 +108,7 @@ public class CrushingWheelControllerBlock extends DirectionalBlock
|
|||
@Override
|
||||
public void updateEntityAfterFallOn(BlockGetter worldIn, Entity entityIn) {
|
||||
super.updateEntityAfterFallOn(worldIn, entityIn);
|
||||
//Moved to onEntityCollision to allow for omnidirectional input
|
||||
// Moved to onEntityCollision to allow for omnidirectional input
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -135,7 +125,7 @@ public class CrushingWheelControllerBlock extends DirectionalBlock
|
|||
|
||||
@Override
|
||||
public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor worldIn,
|
||||
BlockPos currentPos, BlockPos facingPos) {
|
||||
BlockPos currentPos, BlockPos facingPos) {
|
||||
updateSpeed(stateIn, worldIn, currentPos);
|
||||
return stateIn;
|
||||
}
|
||||
|
@ -167,21 +157,23 @@ public class CrushingWheelControllerBlock extends DirectionalBlock
|
|||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter worldIn, BlockPos pos,
|
||||
CollisionContext context) {
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
VoxelShape standardShape = AllShapes.CRUSHING_WHEEL_CONTROLLER_COLLISION.get(state.getValue(FACING));
|
||||
|
||||
if (!state.getValue(VALID))
|
||||
return standardShape;
|
||||
|
||||
Entity entity = context.getEntity();
|
||||
if (!(context instanceof EntityCollisionContext))
|
||||
return standardShape;
|
||||
Entity entity = ((EntityCollisionContext) context).getEntity()
|
||||
.orElse(null);
|
||||
if (entity == null)
|
||||
return standardShape;
|
||||
|
||||
CompoundTag data = entity.getPersistentData();
|
||||
if (data.contains("BypassCrushingWheel"))
|
||||
if (pos.equals(NbtUtils.readBlockPos(data.getCompound("BypassCrushingWheel"))))
|
||||
if (state.getValue(FACING) != Direction.UP) // Allow output items to land on top of the block rather than falling back through.
|
||||
if (state.getValue(FACING) != Direction.UP) // Allow output items to land on top of the block rather
|
||||
// than falling back through.
|
||||
return Shapes.empty();
|
||||
|
||||
CrushingWheelControllerTileEntity te = getTileEntity(worldIn, pos);
|
||||
|
@ -193,7 +185,7 @@ public class CrushingWheelControllerBlock extends DirectionalBlock
|
|||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (!state.hasTileEntity() || state.getBlock() == newState.getBlock())
|
||||
if (!state.hasBlockEntity() || state.getBlock() == newState.getBlock())
|
||||
return;
|
||||
|
||||
withTileEntityDo(worldIn, pos, te -> ItemHelper.dropContents(worldIn, pos, te.inventory));
|
||||
|
@ -205,6 +197,11 @@ public class CrushingWheelControllerBlock extends DirectionalBlock
|
|||
return CrushingWheelControllerTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends CrushingWheelControllerTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.CRUSHING_WHEEL_CONTROLLER.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
return false;
|
||||
|
|
|
@ -23,7 +23,7 @@ import net.minecraft.world.item.context.UseOnContext;
|
|||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
|
@ -39,11 +39,6 @@ public class DeployerBlock extends DirectionalAxisKineticBlock implements ITE<De
|
|||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.DEPLOYER.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PushReaction getPistonPushReaction(BlockState state) {
|
||||
return PushReaction.NORMAL;
|
||||
|
@ -66,12 +61,12 @@ public class DeployerBlock extends DirectionalAxisKineticBlock implements ITE<De
|
|||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) {
|
||||
if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) {
|
||||
withTileEntityDo(worldIn, pos, te -> {
|
||||
if (te.player != null && !isMoving) {
|
||||
te.player.getInventory().dropAll();
|
||||
te.overflowItems.forEach(itemstack -> te.player.drop(itemstack, true, false));
|
||||
te.player.remove();
|
||||
te.player.discard();
|
||||
te.player = null;
|
||||
}
|
||||
});
|
||||
|
@ -112,6 +107,11 @@ public class DeployerBlock extends DirectionalAxisKineticBlock implements ITE<De
|
|||
public Class<DeployerTileEntity> getTileEntityClass() {
|
||||
return DeployerTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends DeployerTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.DEPLOYER.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean isMoving) {
|
||||
|
|
|
@ -108,19 +108,20 @@ public class DeployerFakePlayer extends FakePlayer {
|
|||
if (trueSource != null && trueSource instanceof DeployerFakePlayer) {
|
||||
DeployerFakePlayer fakePlayer = (DeployerFakePlayer) trueSource;
|
||||
event.getDrops()
|
||||
.forEach(stack -> fakeplayer.getInventory().placeItemBackInInventory(trueSource.level, stack.getItem()));
|
||||
.forEach(stack -> fakePlayer.getInventory()
|
||||
.placeItemBackInInventory(stack.getItem()));
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void playEquipSound(ItemStack p_184606_1_) {}
|
||||
protected void equipEventAndSound(ItemStack p_147219_) {}
|
||||
|
||||
@Override
|
||||
public void remove(boolean keepData) {
|
||||
public void remove(RemovalReason p_150097_) {
|
||||
if (blockBreakingProgress != null && !level.isClientSide)
|
||||
level.destroyBlockProgress(getId(), blockBreakingProgress.getKey(), -1);
|
||||
super.remove(keepData);
|
||||
super.remove(p_150097_);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -162,8 +163,7 @@ public class DeployerFakePlayer extends FakePlayer {
|
|||
public void send(Packet<?> packetIn) {}
|
||||
|
||||
@Override
|
||||
public void send(Packet<?> packetIn,
|
||||
GenericFutureListener<? extends Future<? super Void>> futureListeners) {}
|
||||
public void send(Packet<?> packetIn, GenericFutureListener<? extends Future<? super Void>> futureListeners) {}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,7 +55,8 @@ public class DeployerMovingInteraction extends MovingInteractionBehaviour {
|
|||
|
||||
if (!(ctx.temporaryData instanceof DeployerFakePlayer) && ctx.world instanceof ServerLevel) {
|
||||
DeployerFakePlayer deployerFakePlayer = new DeployerFakePlayer((ServerLevel) ctx.world);
|
||||
deployerFakeplayer.getInventory().load(ctx.tileData.getList("Inventory", Constants.NBT.TAG_COMPOUND));
|
||||
deployerFakePlayer.getInventory()
|
||||
.load(ctx.tileData.getList("Inventory", Constants.NBT.TAG_COMPOUND));
|
||||
ctx.temporaryData = fake = deployerFakePlayer;
|
||||
ctx.tileData.remove("Inventory");
|
||||
} else
|
||||
|
|
|
@ -11,12 +11,11 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class EncasedFanBlock extends DirectionalKineticBlock implements ITE<EncasedFanTileEntity> {
|
||||
|
@ -25,11 +24,6 @@ public class EncasedFanBlock extends DirectionalKineticBlock implements ITE<Enca
|
|||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.ENCASED_FAN.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlace(BlockState state, Level worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
|
||||
super.onPlace(state, worldIn, pos, oldState, isMoving);
|
||||
|
@ -44,7 +38,7 @@ public class EncasedFanBlock extends DirectionalKineticBlock implements ITE<Enca
|
|||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState p_196243_4_, boolean p_196243_5_) {
|
||||
if (state.hasTileEntity() && (state.getBlock() != p_196243_4_.getBlock() || !p_196243_4_.hasTileEntity())) {
|
||||
if (state.hasBlockEntity() && (state.getBlock() != p_196243_4_.getBlock() || !p_196243_4_.hasBlockEntity())) {
|
||||
withTileEntityDo(world, pos, EncasedFanTileEntity::updateChute);
|
||||
world.removeBlockEntity(pos);
|
||||
}
|
||||
|
@ -116,5 +110,10 @@ public class EncasedFanBlock extends DirectionalKineticBlock implements ITE<Enca
|
|||
public Class<EncasedFanTileEntity> getTileEntityClass() {
|
||||
return EncasedFanTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends EncasedFanTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.ENCASED_FAN.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
|||
|
||||
import com.simibubi.create.AllShapes;
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.block.WrenchableDirectionalBlock;
|
||||
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
|
@ -17,6 +18,7 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
|
@ -24,27 +26,17 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
|||
|
||||
@MethodsReturnNonnullByDefault
|
||||
@ParametersAreNonnullByDefault
|
||||
public class NozzleBlock extends WrenchableDirectionalBlock {
|
||||
public class NozzleBlock extends WrenchableDirectionalBlock implements ITE<NozzleTileEntity> {
|
||||
|
||||
public NozzleBlock(Properties p_i48415_1_) {
|
||||
super(p_i48415_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult onWrenched(BlockState state, UseOnContext context) {
|
||||
return InteractionResult.FAIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.NOZZLE.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
return defaultBlockState().setValue(FACING, context.getClickedFace());
|
||||
|
@ -81,4 +73,14 @@ public class NozzleBlock extends WrenchableDirectionalBlock {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<NozzleTileEntity> getTileEntityClass() {
|
||||
return NozzleTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends NozzleTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.NOZZLE.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock;
|
|||
import com.simibubi.create.content.contraptions.components.flywheel.engine.EngineTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.engine.FurnaceEngineBlock;
|
||||
import com.simibubi.create.foundation.advancement.AllTriggers;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -14,16 +15,15 @@ import net.minecraft.util.StringRepresentable;
|
|||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
|
||||
public class FlywheelBlock extends HorizontalKineticBlock {
|
||||
public class FlywheelBlock extends HorizontalKineticBlock implements ITE<FlywheelTileEntity> {
|
||||
|
||||
public static EnumProperty<ConnectionState> CONNECTION = EnumProperty.create("connection", ConnectionState.class);
|
||||
|
||||
|
@ -37,11 +37,6 @@ public class FlywheelBlock extends HorizontalKineticBlock {
|
|||
super.createBlockStateDefinition(builder.add(CONNECTION));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.FLYWHEEL.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
Direction preferred = getPreferredHorizontalFacing(context);
|
||||
|
@ -115,4 +110,14 @@ public class FlywheelBlock extends HorizontalKineticBlock {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<FlywheelTileEntity> getTileEntityClass() {
|
||||
return FlywheelTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends FlywheelTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.FLYWHEEL.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
@ -33,19 +32,11 @@ public abstract class EngineBlock extends HorizontalDirectionalBlock implements
|
|||
return isValidPosition(state, worldIn, pos, state.getValue(FACING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult onWrenched(BlockState state, UseOnContext context) {
|
||||
return InteractionResult.FAIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract BlockEntity createTileEntity(BlockState state, BlockGetter world);
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
Direction facing = context.getClickedFace();
|
||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.world.level.BlockGetter;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.AbstractFurnaceBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
@ -46,11 +46,6 @@ public class FurnaceEngineBlock extends EngineBlock implements ITE<FurnaceEngine
|
|||
return AllBlockPartials.FURNACE_GENERATOR_FRAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.FURNACE_ENGINE.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
|
@ -85,4 +80,10 @@ public class FurnaceEngineBlock extends EngineBlock implements ITE<FurnaceEngine
|
|||
return FurnaceEngineTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends FurnaceEngineTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.FURNACE_ENGINE.get();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
@ -38,11 +38,6 @@ public class MillstoneBlock extends KineticBlock implements ITE<MillstoneTileEnt
|
|||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.MILLSTONE.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
return AllShapes.MILLSTONE;
|
||||
|
@ -55,8 +50,9 @@ public class MillstoneBlock extends KineticBlock implements ITE<MillstoneTileEnt
|
|||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn,
|
||||
BlockHitResult hit) {
|
||||
if (!player.getItemInHand(handIn).isEmpty())
|
||||
BlockHitResult hit) {
|
||||
if (!player.getItemInHand(handIn)
|
||||
.isEmpty())
|
||||
return InteractionResult.PASS;
|
||||
if (worldIn.isClientSide)
|
||||
return InteractionResult.SUCCESS;
|
||||
|
@ -68,14 +64,16 @@ public class MillstoneBlock extends KineticBlock implements ITE<MillstoneTileEnt
|
|||
ItemStack stackInSlot = inv.getStackInSlot(slot);
|
||||
if (!stackInSlot.isEmpty())
|
||||
emptyOutput = false;
|
||||
player.getInventory().placeItemBackInInventory(worldIn, stackInSlot);
|
||||
player.getInventory()
|
||||
.placeItemBackInInventory(stackInSlot);
|
||||
inv.setStackInSlot(slot, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
if (emptyOutput) {
|
||||
inv = millstone.inputInv;
|
||||
for (int slot = 0; slot < inv.getSlots(); slot++) {
|
||||
player.getInventory().placeItemBackInInventory(worldIn, inv.getStackInSlot(slot));
|
||||
player.getInventory()
|
||||
.placeItemBackInInventory(inv.getStackInSlot(slot));
|
||||
inv.setStackInSlot(slot, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
@ -111,16 +109,18 @@ public class MillstoneBlock extends KineticBlock implements ITE<MillstoneTileEnt
|
|||
if (!capability.isPresent())
|
||||
return;
|
||||
|
||||
ItemStack remainder = capability.orElse(new ItemStackHandler()).insertItem(0, itemEntity.getItem(), false);
|
||||
ItemStack remainder = capability.orElse(new ItemStackHandler())
|
||||
.insertItem(0, itemEntity.getItem(), false);
|
||||
if (remainder.isEmpty())
|
||||
itemEntity.discard();
|
||||
if (remainder.getCount() < itemEntity.getItem().getCount())
|
||||
if (remainder.getCount() < itemEntity.getItem()
|
||||
.getCount())
|
||||
itemEntity.setItem(remainder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) {
|
||||
if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) {
|
||||
withTileEntityDo(worldIn, pos, te -> {
|
||||
ItemHelper.dropContents(worldIn, pos, te.inputInv);
|
||||
ItemHelper.dropContents(worldIn, pos, te.outputInv);
|
||||
|
@ -140,6 +140,11 @@ public class MillstoneBlock extends KineticBlock implements ITE<MillstoneTileEnt
|
|||
return MillstoneTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends MillstoneTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.MILLSTONE.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
return false;
|
||||
|
|
|
@ -13,10 +13,11 @@ import net.minecraft.core.Direction.Axis;
|
|||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.EntityCollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class MechanicalMixerBlock extends KineticBlock implements ITE<MechanicalMixerTileEntity>, ICogWheel {
|
||||
|
@ -25,11 +26,6 @@ public class MechanicalMixerBlock extends KineticBlock implements ITE<Mechanical
|
|||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.MECHANICAL_MIXER.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) {
|
||||
return !AllBlocks.BASIN.has(worldIn.getBlockState(pos.below()));
|
||||
|
@ -37,7 +33,8 @@ public class MechanicalMixerBlock extends KineticBlock implements ITE<Mechanical
|
|||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
if (context.getEntity() instanceof Player)
|
||||
if (context instanceof EntityCollisionContext && ((EntityCollisionContext) context).getEntity()
|
||||
.orElse(null) instanceof Player)
|
||||
return AllShapes.CASING_14PX.get(Direction.DOWN);
|
||||
|
||||
return AllShapes.MECHANICAL_PROCESSOR_SHAPE;
|
||||
|
@ -72,7 +69,12 @@ public class MechanicalMixerBlock extends KineticBlock implements ITE<Mechanical
|
|||
public Class<MechanicalMixerTileEntity> getTileEntityClass() {
|
||||
return MechanicalMixerTileEntity.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends MechanicalMixerTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.MECHANICAL_MIXER.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
return false;
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.motor;
|
|||
import com.simibubi.create.AllShapes;
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -10,13 +11,13 @@ import net.minecraft.core.Direction.Axis;
|
|||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class CreativeMotorBlock extends DirectionalKineticBlock {
|
||||
public class CreativeMotorBlock extends DirectionalKineticBlock implements ITE<CreativeMotorTileEntity> {
|
||||
|
||||
public CreativeMotorBlock(Properties properties) {
|
||||
super(properties);
|
||||
|
@ -27,11 +28,6 @@ public class CreativeMotorBlock extends DirectionalKineticBlock {
|
|||
return AllShapes.MOTOR_BLOCK.get(state.getValue(FACING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.MOTOR.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
Direction preferred = getPreferredFacing(context);
|
||||
|
@ -63,5 +59,15 @@ public class CreativeMotorBlock extends DirectionalKineticBlock {
|
|||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<CreativeMotorTileEntity> getTileEntityClass() {
|
||||
return CreativeMotorTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends CreativeMotorTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.MOTOR.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,10 +13,11 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.EntityCollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class MechanicalPressBlock extends HorizontalKineticBlock implements ITE<MechanicalPressTileEntity> {
|
||||
|
@ -27,8 +28,10 @@ public class MechanicalPressBlock extends HorizontalKineticBlock implements ITE<
|
|||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
if (context.getEntity() instanceof Player)
|
||||
if (context instanceof EntityCollisionContext && ((EntityCollisionContext) context).getEntity()
|
||||
.orElse(null) instanceof Player)
|
||||
return AllShapes.CASING_14PX.get(Direction.DOWN);
|
||||
|
||||
return AllShapes.MECHANICAL_PROCESSOR_SHAPE;
|
||||
}
|
||||
|
||||
|
@ -37,11 +40,6 @@ public class MechanicalPressBlock extends HorizontalKineticBlock implements ITE<
|
|||
return !AllBlocks.BASIN.has(worldIn.getBlockState(pos.below()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.MECHANICAL_PRESS.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
Direction prefferedSide = getPreferredHorizontalFacing(context);
|
||||
|
@ -66,7 +64,12 @@ public class MechanicalPressBlock extends HorizontalKineticBlock implements ITE<
|
|||
public Class<MechanicalPressTileEntity> getTileEntityClass() {
|
||||
return MechanicalPressTileEntity.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends MechanicalPressTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.MECHANICAL_PRESS.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
return false;
|
||||
|
|
|
@ -22,7 +22,7 @@ import net.minecraft.world.item.context.BlockPlaceContext;
|
|||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
|
@ -48,11 +48,6 @@ public class SawBlock extends DirectionalAxisKineticBlock implements ITE<SawTile
|
|||
return stateForPlacement.setValue(AXIS_ALONG_FIRST_COORDINATE, facing.getAxis() == Axis.X);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.SAW.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
return AllShapes.CASING_12PX.get(state.getValue(FACING));
|
||||
|
@ -109,7 +104,7 @@ public class SawBlock extends DirectionalAxisKineticBlock implements ITE<SawTile
|
|||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (!state.hasTileEntity() || state.getBlock() == newState.getBlock())
|
||||
if (!state.hasBlockEntity() || state.getBlock() == newState.getBlock())
|
||||
return;
|
||||
|
||||
withTileEntityDo(worldIn, pos, te -> ItemHelper.dropContents(worldIn, pos, te.inventory));
|
||||
|
@ -122,6 +117,11 @@ public class SawBlock extends DirectionalAxisKineticBlock implements ITE<SawTile
|
|||
return SawTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends SawTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.SAW.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
return false;
|
||||
|
|
|
@ -8,9 +8,8 @@ import net.minecraft.world.InteractionHand;
|
|||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
||||
|
@ -20,11 +19,6 @@ public class ClockworkBearingBlock extends BearingBlock implements ITE<Clockwork
|
|||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.CLOCKWORK_BEARING.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos,
|
||||
Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
|
@ -60,4 +54,9 @@ public class ClockworkBearingBlock extends BearingBlock implements ITE<Clockwork
|
|||
return resultType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends ClockworkBearingTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.CLOCKWORK_BEARING.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,9 +7,8 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
||||
|
@ -19,11 +18,6 @@ public class MechanicalBearingBlock extends BearingBlock implements ITE<Mechanic
|
|||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.MECHANICAL_BEARING.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn,
|
||||
BlockHitResult hit) {
|
||||
|
@ -52,4 +46,9 @@ public class MechanicalBearingBlock extends BearingBlock implements ITE<Mechanic
|
|||
return MechanicalBearingTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends MechanicalBearingTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.MECHANICAL_BEARING.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,16 +65,19 @@ public class SailBlock extends WrenchableDirectionalBlock {
|
|||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
BlockState state = super.getStateForPlacement(context);
|
||||
return state.setValue(FACING, state.getValue(FACING).getOpposite());
|
||||
return state.setValue(FACING, state.getValue(FACING)
|
||||
.getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult ray) {
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||
BlockHitResult ray) {
|
||||
ItemStack heldItem = player.getItemInHand(hand);
|
||||
|
||||
IPlacementHelper placementHelper = PlacementHelpers.get(placementHelperId);
|
||||
if (placementHelper.matchesItem(heldItem))
|
||||
return placementHelper.getOffset(player, world, state, pos, ray).placeInWorld(world, (BlockItem) heldItem.getItem(), player, hand, ray);
|
||||
return placementHelper.getOffset(player, world, state, pos, ray)
|
||||
.placeInWorld(world, (BlockItem) heldItem.getItem(), player, hand, ray);
|
||||
|
||||
if (heldItem.getItem() instanceof ShearsItem) {
|
||||
if (!world.isClientSide)
|
||||
|
@ -97,7 +100,7 @@ public class SailBlock extends WrenchableDirectionalBlock {
|
|||
|
||||
protected void applyDye(BlockState state, Level world, BlockPos pos, @Nullable DyeColor color) {
|
||||
BlockState newState =
|
||||
(color == null ? AllBlocks.SAIL_FRAME : AllBlocks.DYED_SAILS.get(color)).getDefaultState();
|
||||
(color == null ? AllBlocks.SAIL_FRAME : AllBlocks.DYED_SAILS.get(color)).getDefaultState();
|
||||
newState = BlockHelper.copyProperties(state, newState);
|
||||
|
||||
// Dye the block itself
|
||||
|
@ -109,7 +112,7 @@ public class SailBlock extends WrenchableDirectionalBlock {
|
|||
// Dye all adjacent
|
||||
for (Direction d : Iterate.directions) {
|
||||
if (d.getAxis() == state.getValue(FACING)
|
||||
.getAxis())
|
||||
.getAxis())
|
||||
continue;
|
||||
BlockPos offset = pos.relative(d);
|
||||
BlockState adjacentState = world.getBlockState(offset);
|
||||
|
@ -136,7 +139,7 @@ public class SailBlock extends WrenchableDirectionalBlock {
|
|||
|
||||
for (Direction d : Iterate.directions) {
|
||||
if (d.getAxis() == state.getValue(FACING)
|
||||
.getAxis())
|
||||
.getAxis())
|
||||
continue;
|
||||
BlockPos offset = currentPos.relative(d);
|
||||
if (visited.contains(offset))
|
||||
|
@ -154,12 +157,14 @@ public class SailBlock extends WrenchableDirectionalBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_, CollisionContext p_220053_4_) {
|
||||
public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_,
|
||||
CollisionContext p_220053_4_) {
|
||||
return (frame ? AllShapes.SAIL_FRAME : AllShapes.SAIL).get(state.getValue(FACING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter p_220071_2_, BlockPos p_220071_3_, CollisionContext p_220071_4_) {
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter p_220071_2_, BlockPos p_220071_3_,
|
||||
CollisionContext p_220071_4_) {
|
||||
if (frame)
|
||||
return AllShapes.SAIL_FRAME_COLLISION.get(state.getValue(FACING));
|
||||
return getShape(state, p_220071_2_, p_220071_3_, p_220071_4_);
|
||||
|
@ -170,14 +175,15 @@ public class SailBlock extends WrenchableDirectionalBlock {
|
|||
ItemStack pickBlock = super.getPickBlock(state, target, world, pos, player);
|
||||
if (pickBlock.isEmpty())
|
||||
return AllBlocks.SAIL.get()
|
||||
.getPickBlock(state, target, world, pos, player);
|
||||
.getPickBlock(state, target, world, pos, player);
|
||||
return pickBlock;
|
||||
}
|
||||
|
||||
public void fallOn(Level p_180658_1_, BlockPos p_180658_2_, Entity p_180658_3_, float p_180658_4_) {
|
||||
@Override
|
||||
public void fallOn(Level p_152426_, BlockState p_152427_, BlockPos p_152428_, Entity p_152429_, float p_152430_) {
|
||||
if (frame)
|
||||
super.fallOn(p_180658_1_, p_180658_2_, p_180658_3_, p_180658_4_);
|
||||
super.fallOn(p_180658_1_, p_180658_2_, p_180658_3_, 0);
|
||||
super.fallOn(p_152426_, p_152427_, p_152428_, p_152429_, p_152430_);
|
||||
super.fallOn(p_152426_, p_152427_, p_152428_, p_152429_, 0);
|
||||
}
|
||||
|
||||
public void updateEntityAfterFallOn(BlockGetter p_176216_1_, Entity p_176216_2_) {
|
||||
|
@ -196,7 +202,7 @@ public class SailBlock extends WrenchableDirectionalBlock {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
return false;
|
||||
|
@ -223,13 +229,20 @@ public class SailBlock extends WrenchableDirectionalBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos, BlockHitResult ray) {
|
||||
List<Direction> directions = IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getLocation(), state.getValue(SailBlock.FACING).getAxis(), dir -> world.getBlockState(pos.relative(dir)).getMaterial().isReplaceable());
|
||||
public PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos,
|
||||
BlockHitResult ray) {
|
||||
List<Direction> directions = IPlacementHelper.orderedByDistanceExceptAxis(pos, ray.getLocation(),
|
||||
state.getValue(SailBlock.FACING)
|
||||
.getAxis(),
|
||||
dir -> world.getBlockState(pos.relative(dir))
|
||||
.getMaterial()
|
||||
.isReplaceable());
|
||||
|
||||
if (directions.isEmpty())
|
||||
return PlacementOffset.fail();
|
||||
else {
|
||||
return PlacementOffset.success(pos.relative(directions.get(0)), s -> s.setValue(FACING, state.getValue(FACING)));
|
||||
return PlacementOffset.success(pos.relative(directions.get(0)),
|
||||
s -> s.setValue(FACING, state.getValue(FACING)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,8 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
||||
|
@ -19,11 +18,6 @@ public class WindmillBearingBlock extends BearingBlock implements ITE<WindmillBe
|
|||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.WINDMILL_BEARING.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn,
|
||||
BlockHitResult hit) {
|
||||
|
@ -51,5 +45,10 @@ public class WindmillBearingBlock extends BearingBlock implements ITE<WindmillBe
|
|||
public Class<WindmillBearingTileEntity> getTileEntityClass() {
|
||||
return WindmillBearingTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends WindmillBearingTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.WINDMILL_BEARING.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.simibubi.create.AllItems;
|
|||
import com.simibubi.create.AllSoundEvents;
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -18,29 +19,19 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.block.Mirror;
|
||||
import net.minecraft.world.level.block.RotatedPillarBlock;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.Tags;
|
||||
|
||||
public abstract class AbstractChassisBlock extends RotatedPillarBlock implements IWrenchable {
|
||||
public abstract class AbstractChassisBlock extends RotatedPillarBlock implements IWrenchable, ITE<ChassisTileEntity> {
|
||||
|
||||
public AbstractChassisBlock(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.CHASSIS.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn,
|
||||
BlockHitResult hit) {
|
||||
|
@ -48,8 +39,7 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements
|
|||
return InteractionResult.PASS;
|
||||
|
||||
ItemStack heldItem = player.getItemInHand(handIn);
|
||||
boolean isSlimeBall = heldItem.getItem()
|
||||
.is(Tags.Items.SLIMEBALLS) || AllItems.SUPER_GLUE.isIn(heldItem);
|
||||
boolean isSlimeBall = heldItem.is(Tags.Items.SLIMEBALLS) || AllItems.SUPER_GLUE.isIn(heldItem);
|
||||
|
||||
BooleanProperty affectedSide = getGlueableSide(state, hit.getDirection());
|
||||
if (affectedSide == null)
|
||||
|
@ -58,7 +48,8 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements
|
|||
if (isSlimeBall && state.getValue(affectedSide)) {
|
||||
for (Direction face : Iterate.directions) {
|
||||
BooleanProperty glueableSide = getGlueableSide(state, face);
|
||||
if (glueableSide != null && !state.getValue(glueableSide) && glueAllowedOnSide(worldIn, pos, state, face)) {
|
||||
if (glueableSide != null && !state.getValue(glueableSide)
|
||||
&& glueAllowedOnSide(worldIn, pos, state, face)) {
|
||||
if (worldIn.isClientSide) {
|
||||
Vec3 vec = hit.getLocation();
|
||||
worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0);
|
||||
|
@ -95,7 +86,6 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements
|
|||
if (rotation == Rotation.NONE)
|
||||
return state;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
BlockState rotated = super.rotate(state, rotation);
|
||||
for (Direction face : Iterate.directions) {
|
||||
BooleanProperty glueableSide = getGlueableSide(rotated, face);
|
||||
|
@ -147,4 +137,14 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ChassisTileEntity> getTileEntityClass() {
|
||||
return ChassisTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends ChassisTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.CHASSIS.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.core.particles.BlockParticleOption;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
|
@ -18,7 +19,7 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -68,24 +69,19 @@ public class StickerBlock extends WrenchableDirectionalBlock implements ITE<Stic
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCheckWeakPower(BlockState state, LevelReader world, BlockPos pos, Direction side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.STICKER.create();
|
||||
public Class<StickerTileEntity> getTileEntityClass() {
|
||||
return StickerTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<StickerTileEntity> getTileEntityClass() {
|
||||
return StickerTileEntity.class;
|
||||
public BlockEntityType<? extends StickerTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.STICKER.get();
|
||||
}
|
||||
|
||||
// Slime block stuff
|
||||
|
@ -96,12 +92,10 @@ public class StickerBlock extends WrenchableDirectionalBlock implements ITE<Stic
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fallOn(Level p_180658_1_, BlockPos p_180658_2_, Entity p_180658_3_, float p_180658_4_) {
|
||||
if (!isUprightSticker(p_180658_1_, p_180658_2_) || p_180658_3_.isSuppressingBounce()) {
|
||||
super.fallOn(p_180658_1_, p_180658_2_, p_180658_3_, p_180658_4_);
|
||||
} else {
|
||||
p_180658_3_.causeFallDamage(p_180658_4_, 0.0F);
|
||||
}
|
||||
public void fallOn(Level p_152426_, BlockState p_152427_, BlockPos p_152428_, Entity p_152429_, float p_152430_) {
|
||||
if (!isUprightSticker(p_152426_, p_152428_) || p_152429_.isSuppressingBounce())
|
||||
super.fallOn(p_152426_, p_152427_, p_152428_, p_152429_, p_152430_);
|
||||
p_152429_.causeFallDamage(p_152430_, 1.0F, DamageSource.FALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -123,22 +117,23 @@ public class StickerBlock extends WrenchableDirectionalBlock implements ITE<Stic
|
|||
}
|
||||
|
||||
@Override
|
||||
public void stepOn(Level p_176199_1_, BlockPos p_176199_2_, Entity p_176199_3_) {
|
||||
double d0 = Math.abs(p_176199_3_.getDeltaMovement().y);
|
||||
if (d0 < 0.1D && !p_176199_3_.isSteppingCarefully() && isUprightSticker(p_176199_1_, p_176199_2_)) {
|
||||
public void stepOn(Level p_152431_, BlockPos p_152432_, BlockState p_152433_, Entity p_152434_) {
|
||||
double d0 = Math.abs(p_152434_.getDeltaMovement().y);
|
||||
if (d0 < 0.1D && !p_152434_.isSteppingCarefully() && isUprightSticker(p_152431_, p_152432_)) {
|
||||
double d1 = 0.4D + d0 * 0.2D;
|
||||
p_176199_3_.setDeltaMovement(p_176199_3_.getDeltaMovement()
|
||||
p_152434_.setDeltaMovement(p_152434_.getDeltaMovement()
|
||||
.multiply(d1, 1.0D, d1));
|
||||
}
|
||||
super.stepOn(p_176199_1_, p_176199_2_, p_176199_3_);
|
||||
super.stepOn(p_152431_, p_152432_, p_152433_, p_152434_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addLandingEffects(BlockState state1, ServerLevel worldserver, BlockPos pos, BlockState state2,
|
||||
LivingEntity entity, int numberOfParticles) {
|
||||
if (isUprightSticker(worldserver, pos)) {
|
||||
worldserver.sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, Blocks.SLIME_BLOCK.defaultBlockState()),
|
||||
entity.getX(), entity.getY(), entity.getZ(), numberOfParticles, 0.0D, 0.0D, 0.0D, (double) 0.15F);
|
||||
worldserver.sendParticles(
|
||||
new BlockParticleOption(ParticleTypes.BLOCK, Blocks.SLIME_BLOCK.defaultBlockState()), entity.getX(),
|
||||
entity.getY(), entity.getZ(), numberOfParticles, 0.0D, 0.0D, 0.0D, (double) 0.15F);
|
||||
return true;
|
||||
}
|
||||
return super.addLandingEffects(state1, worldserver, pos, state2, entity, numberOfParticles);
|
||||
|
@ -152,8 +147,8 @@ public class StickerBlock extends WrenchableDirectionalBlock implements ITE<Stic
|
|||
new BlockParticleOption(ParticleTypes.BLOCK, Blocks.SLIME_BLOCK.defaultBlockState()).setPos(pos),
|
||||
entity.getX() + ((double) world.random.nextFloat() - 0.5D) * (double) entity.getBbWidth(),
|
||||
entity.getY() + 0.1D,
|
||||
entity.getZ() + ((double) world.random.nextFloat() - 0.5D) * (double) entity.getBbWidth(), Vector3d.x * -4.0D,
|
||||
1.5D, Vector3d.z * -4.0D);
|
||||
entity.getZ() + ((double) world.random.nextFloat() - 0.5D) * (double) entity.getBbWidth(),
|
||||
Vector3d.x * -4.0D, 1.5D, Vector3d.z * -4.0D);
|
||||
return true;
|
||||
}
|
||||
return super.addRunningEffects(state, world, pos, entity);
|
||||
|
|
|
@ -15,12 +15,11 @@ import net.minecraft.world.InteractionHand;
|
|||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
||||
|
@ -49,11 +48,6 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements
|
|||
super.onPlace(state, worldIn, pos, oldState, isMoving);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.GANTRY_PINION.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Direction getFacingForPlacement(BlockPlaceContext context) {
|
||||
return context.getClickedFace();
|
||||
|
@ -140,4 +134,9 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements
|
|||
return GantryCarriageTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends GantryCarriageTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.GANTRY_PINION.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class SuperGlueItem extends Item {
|
|||
}
|
||||
|
||||
protected boolean canPlace(Player entity, Direction facing, ItemStack stack, BlockPos pos) {
|
||||
return !Level.isOutsideBuildHeight(pos) && entity.mayUseItemAt(pos, facing, stack);
|
||||
return !entity.level.isOutsideBuildHeight(pos) && entity.mayUseItemAt(pos, facing, stack);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
|
|
@ -40,6 +40,7 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.Mirror;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -54,6 +55,7 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
|||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.EntityCollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
|
@ -88,8 +90,11 @@ public class CartAssemblerBlock extends BaseRailBlock
|
|||
public static BlockState getRailBlock(BlockState state) {
|
||||
BaseRailBlock railBlock = (BaseRailBlock) state.getValue(RAIL_TYPE)
|
||||
.getBlock();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
BlockState railState = railBlock.defaultBlockState()
|
||||
.setValue(railBlock.getShapeProperty(), state.getValue(RAIL_SHAPE));
|
||||
|
||||
if (railState.hasProperty(ControllerRailBlock.BACKWARDS))
|
||||
railState = railState.setValue(ControllerRailBlock.BACKWARDS, state.getValue(BACKWARDS));
|
||||
return railState;
|
||||
|
@ -101,16 +106,6 @@ public class CartAssemblerBlock extends BaseRailBlock
|
|||
super.createBlockStateDefinition(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.CART_ASSEMBLER.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMakeSlopes(@Nonnull BlockState state, @Nonnull BlockGetter world, @Nonnull BlockPos pos) {
|
||||
return false;
|
||||
|
@ -166,8 +161,8 @@ public class CartAssemblerBlock extends BaseRailBlock
|
|||
|
||||
@Override
|
||||
@Nonnull
|
||||
public InteractionResult use(@Nonnull BlockState state, @Nonnull Level world, @Nonnull BlockPos pos,
|
||||
Player player, @Nonnull InteractionHand hand, @Nonnull BlockHitResult blockRayTraceResult) {
|
||||
public InteractionResult use(@Nonnull BlockState state, @Nonnull Level world, @Nonnull BlockPos pos, Player player,
|
||||
@Nonnull InteractionHand hand, @Nonnull BlockHitResult blockRayTraceResult) {
|
||||
|
||||
ItemStack itemStack = player.getItemInHand(hand);
|
||||
Item previousItem = getRailItem(state);
|
||||
|
@ -185,7 +180,8 @@ public class CartAssemblerBlock extends BaseRailBlock
|
|||
|
||||
if (!player.isCreative()) {
|
||||
itemStack.shrink(1);
|
||||
player.getInventory().placeItemBackInInventory(new ItemStack(previousItem));
|
||||
player.getInventory()
|
||||
.placeItemBackInInventory(new ItemStack(previousItem));
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
@ -225,11 +221,14 @@ public class CartAssemblerBlock extends BaseRailBlock
|
|||
@Nonnull
|
||||
public VoxelShape getCollisionShape(@Nonnull BlockState state, @Nonnull BlockGetter worldIn, @Nonnull BlockPos pos,
|
||||
CollisionContext context) {
|
||||
Entity entity = context.getEntity();
|
||||
if (entity instanceof AbstractMinecart)
|
||||
return Shapes.empty();
|
||||
if (entity instanceof Player)
|
||||
return AllShapes.CART_ASSEMBLER_PLAYER_COLLISION.get(getRailAxis(state));
|
||||
if (context instanceof EntityCollisionContext) {
|
||||
Entity entity = ((EntityCollisionContext) context).getEntity()
|
||||
.orElse(null);
|
||||
if (entity instanceof AbstractMinecart)
|
||||
return Shapes.empty();
|
||||
if (entity instanceof Player)
|
||||
return AllShapes.CART_ASSEMBLER_PLAYER_COLLISION.get(getRailAxis(state));
|
||||
}
|
||||
return Shapes.block();
|
||||
}
|
||||
|
||||
|
@ -244,6 +243,11 @@ public class CartAssemblerBlock extends BaseRailBlock
|
|||
return CartAssemblerTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends CartAssemblerTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.CART_ASSEMBLER.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSurvive(@Nonnull BlockState state, @Nonnull LevelReader world, @Nonnull BlockPos pos) {
|
||||
return false;
|
||||
|
@ -286,7 +290,8 @@ public class CartAssemblerBlock extends BaseRailBlock
|
|||
return InteractionResult.SUCCESS;
|
||||
if (player != null && !player.isCreative())
|
||||
getDropsNoRail(state, (ServerLevel) world, pos, world.getBlockEntity(pos), player, context.getItemInHand())
|
||||
.forEach(itemStack -> player.getInventory().placeItemBackInInventory(itemStack));
|
||||
.forEach(itemStack -> player.getInventory()
|
||||
.placeItemBackInInventory(itemStack));
|
||||
if (world instanceof ServerLevel)
|
||||
state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY);
|
||||
world.setBlockAndUpdate(pos, getRailBlock(state));
|
||||
|
|
|
@ -52,7 +52,7 @@ public class CartAssemblerBlockItem extends BlockItem {
|
|||
return false;
|
||||
}
|
||||
|
||||
RailShape shape = state.getValue(((BaseRailBlock) block).getShapeProperty());
|
||||
RailShape shape = ((BaseRailBlock) block).getRailDirection(state, world, pos, null);
|
||||
if (shape != RailShape.EAST_WEST && shape != RailShape.NORTH_SOUTH)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -245,9 +245,9 @@ public class MinecartContraptionItem extends Item {
|
|||
return;
|
||||
}
|
||||
|
||||
player.getInventory().placeItemBackInInventory(event.getWorld(), generatedStack);
|
||||
contraption.remove();
|
||||
entity.remove();
|
||||
player.getInventory().placeItemBackInInventory(generatedStack);
|
||||
contraption.discard();
|
||||
entity.discard();
|
||||
event.setCancellationResult(InteractionResult.SUCCESS);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import net.minecraft.world.item.context.UseOnContext;
|
|||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -69,7 +69,6 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement
|
|||
if (player.isShiftKeyDown())
|
||||
return InteractionResult.PASS;
|
||||
if (!player.getItemInHand(handIn)
|
||||
.getItem()
|
||||
.is(Tags.Items.SLIMEBALLS)) {
|
||||
if (player.getItemInHand(handIn)
|
||||
.isEmpty()) {
|
||||
|
@ -129,11 +128,6 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.MECHANICAL_PISTON.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult onWrenched(BlockState state, UseOnContext context) {
|
||||
if (state.getValue(STATE) != PistonState.RETRACTED)
|
||||
|
@ -215,6 +209,11 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock implement
|
|||
public Class<MechanicalPistonTileEntity> getTileEntityClass() {
|
||||
return MechanicalPistonTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends MechanicalPistonTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.MECHANICAL_PISTON.get();
|
||||
}
|
||||
|
||||
public static boolean isPiston(BlockState state) {
|
||||
return AllBlocks.MECHANICAL_PISTON.has(state) || isStickyPiston(state);
|
||||
|
|
|
@ -42,7 +42,6 @@ import net.minecraft.world.level.pathfinder.PathComputationType;
|
|||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock implements IWrenchable, SimpleWaterloggedBlock {
|
||||
|
||||
|
@ -53,26 +52,6 @@ public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock impleme
|
|||
registerDefaultState(defaultBlockState().setValue(FACING, Direction.UP).setValue(BlockStateProperties.WATERLOGGED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToolType getHarvestTool(BlockState state) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(BlockState state, BlockGetter world, BlockPos pos, Player player) {
|
||||
for (ToolType toolType : player.getMainHandItem()
|
||||
.getToolTypes()) {
|
||||
if (isToolEffective(state, toolType))
|
||||
return true;
|
||||
}
|
||||
return super.canHarvestBlock(state, world, pos, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isToolEffective(BlockState state, ToolType tool) {
|
||||
return tool == ToolType.AXE || tool == ToolType.PICKAXE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PushReaction getPistonPushReaction(BlockState state) {
|
||||
return PushReaction.NORMAL;
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraft.world.level.LevelAccessor;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -50,11 +51,6 @@ public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE<Pulle
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.ROPE_PULLEY.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
|
@ -63,7 +59,7 @@ public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE<Pulle
|
|||
if (below.getBlock() instanceof RopeBlockBase)
|
||||
worldIn.destroyBlock(pos.below(), true);
|
||||
}
|
||||
if (state.hasTileEntity())
|
||||
if (state.hasBlockEntity())
|
||||
worldIn.removeBlockEntity(pos);
|
||||
}
|
||||
}
|
||||
|
@ -91,6 +87,11 @@ public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE<Pulle
|
|||
public Class<PulleyTileEntity> getTileEntityClass() {
|
||||
return PulleyTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends PulleyTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.ROPE_PULLEY.get();
|
||||
}
|
||||
|
||||
private static class RopeBlockBase extends Block implements SimpleWaterloggedBlock {
|
||||
|
||||
|
@ -128,7 +129,7 @@ public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE<Pulle
|
|||
worldIn.destroyBlock(pos.below(), true);
|
||||
}
|
||||
}
|
||||
if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) {
|
||||
if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) {
|
||||
worldIn.removeBlockEntity(pos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import net.minecraft.world.entity.Entity;
|
|||
|
||||
/**
|
||||
* <p>
|
||||
* ContraptionMatrices must be cleared and setup per-contraption per-frame
|
||||
* ContraptionMatrices must be cleared and setup per-contraption per-frame
|
||||
* </p>
|
||||
*/
|
||||
public class ContraptionMatrices {
|
||||
|
@ -42,9 +42,9 @@ public class ContraptionMatrices {
|
|||
|
||||
translateToEntity(world, entity, partialTicks);
|
||||
|
||||
light.set(world);
|
||||
light.multiply(model
|
||||
.last().pose());
|
||||
light.load(world);
|
||||
light.multiply(model.last()
|
||||
.pose());
|
||||
|
||||
ready = true;
|
||||
}
|
||||
|
@ -83,12 +83,14 @@ public class ContraptionMatrices {
|
|||
}
|
||||
|
||||
public static void transform(PoseStack ms, PoseStack transform) {
|
||||
ms.last().pose()
|
||||
ms.last()
|
||||
.pose()
|
||||
.multiply(transform.last()
|
||||
.pose());
|
||||
ms.last().normal()
|
||||
.pose());
|
||||
ms.last()
|
||||
.normal()
|
||||
.mul(transform.last()
|
||||
.normal());
|
||||
.normal());
|
||||
}
|
||||
|
||||
public static void translateToEntity(Matrix4f matrix, Entity entity, float partialTicks) {
|
||||
|
|
|
@ -16,7 +16,6 @@ import com.jozufozu.flywheel.core.model.WorldModel;
|
|||
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3d;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;
|
||||
|
@ -25,11 +24,11 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
|||
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class RenderedContraption extends ContraptionRenderInfo {
|
||||
|
||||
|
@ -82,7 +81,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
|
|||
|
||||
kinetics.beginFrame(event.getInfo());
|
||||
|
||||
Vector3d cameraPos = event.getCameraPos();
|
||||
Vec3 cameraPos = event.getCameraPos();
|
||||
|
||||
lightBox = lighter.lightVolume.toAABB()
|
||||
.move(-cameraPos.x, -cameraPos.y, -cameraPos.z);
|
||||
|
|
|
@ -1,135 +0,0 @@
|
|||
package com.simibubi.create.content.contraptions.components.tracks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.entity.vehicle.AbstractMinecart;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.BaseRailBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraft.world.level.block.state.properties.RailShape;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class ReinforcedRailBlock extends BaseRailBlock {
|
||||
|
||||
public static Property<RailShape> RAIL_SHAPE =
|
||||
EnumProperty.create("shape", RailShape.class, RailShape.EAST_WEST, RailShape.NORTH_SOUTH);
|
||||
|
||||
public static Property<Boolean> CONNECTS_N = BooleanProperty.create("connects_n");
|
||||
public static Property<Boolean> CONNECTS_S = BooleanProperty.create("connects_s");
|
||||
|
||||
public ReinforcedRailBlock(Properties properties) {
|
||||
super(true, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemCategory(CreativeModeTab p_149666_1_, NonNullList<ItemStack> p_149666_2_) {
|
||||
// TODO re-add when finished
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Property<RailShape> getShapeProperty() {
|
||||
return RAIL_SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) {
|
||||
builder.add(RAIL_SHAPE, CONNECTS_N, CONNECTS_S);
|
||||
super.createBlockStateDefinition(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
boolean alongX = context.getHorizontalDirection().getAxis() == Axis.X;
|
||||
return super.getStateForPlacement(context).setValue(RAIL_SHAPE, alongX ? RailShape.EAST_WEST : RailShape.NORTH_SOUTH).setValue(CONNECTS_N, false).setValue(CONNECTS_S, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMakeSlopes(@Nonnull BlockState state, @Nonnull BlockGetter world, @Nonnull BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateState(@Nonnull BlockState state, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Block block) {
|
||||
super.updateState(state, world, pos, block);
|
||||
world.setBlockAndUpdate(pos, updateDir(world, pos, state, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
protected BlockState updateDir(@Nonnull Level world, BlockPos pos, BlockState state,
|
||||
boolean p_208489_4_) {
|
||||
|
||||
boolean alongX = state.getValue(RAIL_SHAPE) == RailShape.EAST_WEST;
|
||||
BlockPos sPos = pos.offset(alongX ? -1 : 0, 0, alongX ? 0 : 1);
|
||||
BlockPos nPos = pos.offset(alongX ? 1 : 0, 0, alongX ? 0 : -1);
|
||||
|
||||
return super.updateDir(world, pos, state, p_208489_4_).setValue(CONNECTS_S, world.getBlockState(sPos).getBlock() instanceof ReinforcedRailBlock &&
|
||||
(world.getBlockState(sPos).getValue(RAIL_SHAPE) == state.getValue(RAIL_SHAPE)))
|
||||
.setValue(CONNECTS_N, world.getBlockState(nPos).getBlock() instanceof ReinforcedRailBlock &&
|
||||
(world.getBlockState(nPos).getValue(RAIL_SHAPE) == state.getValue(RAIL_SHAPE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public VoxelShape getCollisionShape(@Nonnull BlockState state, @Nonnull BlockGetter worldIn, @Nonnull BlockPos pos,
|
||||
CollisionContext context) { //FIXME
|
||||
if (context.getEntity() instanceof AbstractMinecart)
|
||||
return Shapes.empty();
|
||||
return getShape(state, worldIn, pos, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public VoxelShape getShape(BlockState state, @Nonnull BlockGetter reader, @Nonnull BlockPos pos, CollisionContext context) {
|
||||
boolean alongX = state.getValue(RAIL_SHAPE) == RailShape.EAST_WEST;
|
||||
return Shapes.or(box(0, -2, 0, 16, 2, 16), Shapes.or(box(0, -2, 0, alongX ? 16 : -1, 12, alongX ? -1 : 16), box(alongX ? 0 : 17, -2, alongX ? 17 : 0, 16, 12, 16)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public PushReaction getPistonPushReaction(BlockState state) {
|
||||
return PushReaction.BLOCK;
|
||||
}
|
||||
|
||||
/* FIXME: Same thing as before, does this still matter? If so, what is the new way of doing it?
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return false;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||
return !(world.getBlockState(pos.below()).getBlock() instanceof BaseRailBlock || world.getBlockState(pos.above()).getBlock() instanceof BaseRailBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(@Nonnull BlockState state, Level world, @Nonnull BlockPos pos, @Nonnull Block block, @Nonnull BlockPos pos2, boolean p_220069_6_) {
|
||||
if (!world.isClientSide) {
|
||||
if ((world.getBlockState(pos.below()).getBlock() instanceof BaseRailBlock)) {
|
||||
if (!p_220069_6_) {
|
||||
dropResources(state, world, pos);
|
||||
}
|
||||
world.removeBlock(pos, false);
|
||||
} else {
|
||||
this.updateState(state, world, pos, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ import net.minecraft.world.level.BlockGetter;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -31,11 +31,6 @@ public class TurntableBlock extends KineticBlock implements ITE<TurntableTileEnt
|
|||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.TURNTABLE.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState state) {
|
||||
return RenderShape.ENTITYBLOCK_ANIMATED;
|
||||
|
@ -108,6 +103,11 @@ public class TurntableBlock extends KineticBlock implements ITE<TurntableTileEnt
|
|||
return TurntableTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends TurntableTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.TURNTABLE.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
return false;
|
||||
|
|
|
@ -20,14 +20,13 @@ import net.minecraft.core.Direction.Axis;
|
|||
import net.minecraft.core.Direction.AxisDirection;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.BubbleColumnBlock;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -40,11 +39,6 @@ public class WaterWheelBlock extends DirectionalKineticBlock implements ITE<Wate
|
|||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.WATER_WHEEL.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState state) {
|
||||
return RenderShape.ENTITYBLOCK_ANIMATED;
|
||||
|
@ -104,7 +98,7 @@ public class WaterWheelBlock extends DirectionalKineticBlock implements ITE<Wate
|
|||
if (side.getAxis()
|
||||
.isHorizontal()) {
|
||||
BlockState adjacentBlock = world.getBlockState(pos.relative(side));
|
||||
if (adjacentBlock.getBlock() == Blocks.BUBBLE_COLUMN.getBlock())
|
||||
if (adjacentBlock.getBlock() == Blocks.BUBBLE_COLUMN)
|
||||
vec = new Vec3(0, adjacentBlock.getValue(BubbleColumnBlock.DRAG_DOWN) ? -1 : 1, 0);
|
||||
}
|
||||
|
||||
|
@ -184,7 +178,7 @@ public class WaterWheelBlock extends DirectionalKineticBlock implements ITE<Wate
|
|||
facing = Direction.UP;
|
||||
else
|
||||
facing = horizontalFacing;
|
||||
|
||||
|
||||
}
|
||||
|
||||
return defaultBlockState().setValue(FACING, sneaking ? facing.getOpposite() : facing);
|
||||
|
@ -222,4 +216,9 @@ public class WaterWheelBlock extends DirectionalKineticBlock implements ITE<Wate
|
|||
return WaterWheelTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends WaterWheelTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.WATER_WHEEL.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.simibubi.create.AllShapes;
|
|||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock;
|
||||
import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -21,6 +22,7 @@ import net.minecraft.world.level.TickPriority;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -30,23 +32,13 @@ import net.minecraft.world.level.pathfinder.PathComputationType;
|
|||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class PumpBlock extends DirectionalKineticBlock implements SimpleWaterloggedBlock, ICogWheel {
|
||||
public class PumpBlock extends DirectionalKineticBlock implements SimpleWaterloggedBlock, ICogWheel, ITE<PumpTileEntity> {
|
||||
|
||||
public PumpBlock(Properties p_i48415_1_) {
|
||||
super(p_i48415_1_);
|
||||
registerDefaultState(super.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.MECHANICAL_PUMP.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getRotatedBlockState(BlockState originalState, Direction targetedFace) {
|
||||
return originalState.setValue(FACING, originalState.getValue(FACING)
|
||||
|
@ -151,7 +143,7 @@ public class PumpBlock extends DirectionalKineticBlock implements SimpleWaterlog
|
|||
boolean blockTypeChanged = state.getBlock() != newState.getBlock();
|
||||
if (blockTypeChanged && !world.isClientSide)
|
||||
FluidPropagator.propagateChangedPipe(world, pos, state);
|
||||
if (state.hasTileEntity() && (blockTypeChanged || !newState.hasTileEntity()))
|
||||
if (state.hasBlockEntity() && (blockTypeChanged || !newState.hasBlockEntity()))
|
||||
world.removeBlockEntity(pos);
|
||||
}
|
||||
|
||||
|
@ -160,4 +152,14 @@ public class PumpBlock extends DirectionalKineticBlock implements SimpleWaterlog
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<PumpTileEntity> getTileEntityClass() {
|
||||
return PumpTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends PumpTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.MECHANICAL_PUMP.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -274,15 +274,14 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour {
|
|||
}
|
||||
|
||||
protected void replaceBlock(Level world, BlockPos pos, BlockState state) {
|
||||
BlockEntity tileentity = state.getBlock()
|
||||
.hasTileEntity(state) ? world.getBlockEntity(pos) : null;
|
||||
BlockEntity tileentity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null;
|
||||
Block.dropResources(state, world, pos, tileentity);
|
||||
}
|
||||
|
||||
// From FlowingFluidBlock#isBlocked
|
||||
protected boolean canBeReplacedByFluid(BlockGetter world, BlockPos pos, BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (!(block instanceof DoorBlock) && !block.is(BlockTags.SIGNS) && block != Blocks.LADDER
|
||||
if (!(block instanceof DoorBlock) && !state.is(BlockTags.SIGNS) && block != Blocks.LADDER
|
||||
&& block != Blocks.SUGAR_CANE && block != Blocks.BUBBLE_COLUMN) {
|
||||
Material material = state.getMaterial();
|
||||
if (material != Material.PORTAL && material != Material.STRUCTURAL_AIR && material != Material.WATER_PLANT
|
||||
|
|
|
@ -114,8 +114,9 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour {
|
|||
protected void scheduleUpdatesInAffectedArea() {
|
||||
Level world = getWorld();
|
||||
BlockPos
|
||||
.betweenClosedStream(new BlockPos(affectedArea.x0 - 1, affectedArea.y0 - 1, affectedArea.z0 - 1),
|
||||
new BlockPos(affectedArea.x1 + 1, affectedArea.y1 + 1, affectedArea.z1 + 1))
|
||||
.betweenClosedStream(
|
||||
new BlockPos(affectedArea.minX() - 1, affectedArea.minY() - 1, affectedArea.minZ() - 1),
|
||||
new BlockPos(affectedArea.maxX() + 1, affectedArea.maxY() + 1, affectedArea.maxZ() + 1))
|
||||
.forEach(pos -> {
|
||||
FluidState nextFluidState = world.getFluidState(pos);
|
||||
if (nextFluidState.isEmpty())
|
||||
|
@ -221,9 +222,9 @@ public abstract class FluidManipulationBehaviour extends TileEntityBehaviour {
|
|||
nbt.put("LastPos", NbtUtils.writeBlockPos(rootPos));
|
||||
if (affectedArea != null) {
|
||||
nbt.put("AffectedAreaFrom",
|
||||
NbtUtils.writeBlockPos(new BlockPos(affectedArea.x0, affectedArea.y0, affectedArea.z0)));
|
||||
NbtUtils.writeBlockPos(new BlockPos(affectedArea.minX(), affectedArea.minY(), affectedArea.minZ())));
|
||||
nbt.put("AffectedAreaTo",
|
||||
NbtUtils.writeBlockPos(new BlockPos(affectedArea.x1, affectedArea.y1, affectedArea.z1)));
|
||||
NbtUtils.writeBlockPos(new BlockPos(affectedArea.maxX(), affectedArea.maxY(), affectedArea.maxZ())));
|
||||
}
|
||||
super.write(nbt, clientPacket);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.world.item.context.BlockPlaceContext;
|
|||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
@ -54,11 +54,6 @@ public class HosePulleyBlock extends HorizontalKineticBlock implements ITE<HoseP
|
|||
.getCounterClockWise() == face;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.HOSE_PULLEY.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getPreferredHorizontalFacing(BlockPlaceContext context) {
|
||||
Direction fromParent = super.getPreferredHorizontalFacing(context);
|
||||
|
@ -84,8 +79,8 @@ public class HosePulleyBlock extends HorizontalKineticBlock implements ITE<HoseP
|
|||
@Override
|
||||
public void onRemove(BlockState p_196243_1_, Level world, BlockPos pos, BlockState p_196243_4_,
|
||||
boolean p_196243_5_) {
|
||||
if (p_196243_1_.hasTileEntity()
|
||||
&& (p_196243_1_.getBlock() != p_196243_4_.getBlock() || !p_196243_4_.hasTileEntity())) {
|
||||
if (p_196243_1_.hasBlockEntity()
|
||||
&& (p_196243_1_.getBlock() != p_196243_4_.getBlock() || !p_196243_4_.hasBlockEntity())) {
|
||||
TileEntityBehaviour.destroy(world, pos, FluidDrainingBehaviour.TYPE);
|
||||
TileEntityBehaviour.destroy(world, pos, FluidFillingBehaviour.TYPE);
|
||||
world.removeBlockEntity(pos);
|
||||
|
@ -103,5 +98,10 @@ public class HosePulleyBlock extends HorizontalKineticBlock implements ITE<HoseP
|
|||
public Class<HosePulleyTileEntity> getTileEntityClass() {
|
||||
return HosePulleyTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends HosePulleyTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.HOSE_PULLEY.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
@ -54,7 +54,7 @@ public class ItemDrainBlock extends Block implements IWrenchable, ITE<ItemDrainT
|
|||
|
||||
ItemStack heldItemStack = te.getHeldItemStack();
|
||||
if (!worldIn.isClientSide && !heldItemStack.isEmpty()) {
|
||||
player.getInventory().placeItemBackInInventory(worldIn, heldItemStack);
|
||||
player.getInventory().placeItemBackInInventory(heldItemStack);
|
||||
te.heldItem = null;
|
||||
te.notifyUpdate();
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public class ItemDrainBlock extends Block implements IWrenchable, ITE<ItemDrainT
|
|||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (!state.hasTileEntity() || state.getBlock() == newState.getBlock())
|
||||
if (!state.hasBlockEntity() || state.getBlock() == newState.getBlock())
|
||||
return;
|
||||
withTileEntityDo(worldIn, pos, te -> {
|
||||
ItemStack heldItemStack = te.getHeldItemStack();
|
||||
|
@ -89,20 +89,15 @@ public class ItemDrainBlock extends Block implements IWrenchable, ITE<ItemDrainT
|
|||
worldIn.removeBlockEntity(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.ITEM_DRAIN.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ItemDrainTileEntity> getTileEntityClass() {
|
||||
return ItemDrainTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends ItemDrainTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.ITEM_DRAIN.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAnalogOutputSignal(BlockState state) {
|
||||
|
|
|
@ -3,40 +3,31 @@ package com.simibubi.create.content.contraptions.fluids.actors;
|
|||
import com.simibubi.create.AllShapes;
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.tileEntity.ComparatorUtil;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class SpoutBlock extends Block implements IWrenchable {
|
||||
public class SpoutBlock extends Block implements IWrenchable, ITE<SpoutTileEntity> {
|
||||
|
||||
public SpoutBlock(Properties p_i48440_1_) {
|
||||
super(p_i48440_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState p_220053_1_, BlockGetter p_220053_2_, BlockPos p_220053_3_,
|
||||
CollisionContext p_220053_4_) {
|
||||
return AllShapes.SPOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.SPOUT.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAnalogOutputSignal(BlockState state) {
|
||||
return true;
|
||||
|
@ -52,4 +43,14 @@ public class SpoutBlock extends Block implements IWrenchable {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<SpoutTileEntity> getTileEntityClass() {
|
||||
return SpoutTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends SpoutTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.SPOUT.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWith
|
|||
FluidPropagator.propagateChangedPipe(world, pos, state);
|
||||
if (state != newState && !isMoving)
|
||||
removeBracket(world, pos, true).ifPresent(stack -> Block.popResource(world, pos, stack));
|
||||
if (state.hasTileEntity() && (blockTypeChanged || !newState.hasTileEntity()))
|
||||
if (state.hasBlockEntity() && (blockTypeChanged || !newState.hasBlockEntity()))
|
||||
world.removeBlockEntity(pos);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour;
|
|||
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
||||
import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement;
|
||||
import com.simibubi.create.content.schematics.ItemRequirement;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -33,12 +34,13 @@ import net.minecraft.world.level.TickPriority;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.PipeBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
|
||||
public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBlockItemRequirement {
|
||||
public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBlockItemRequirement, ITE<FluidPipeTileEntity> {
|
||||
|
||||
public static final Map<Direction, BooleanProperty> FACING_TO_PROPERTY_MAP = PipeBlock.PROPERTY_BY_DIRECTION;
|
||||
|
||||
|
@ -58,17 +60,12 @@ public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBloc
|
|||
super.createBlockStateDefinition(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBlockEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
boolean blockTypeChanged = state.getBlock() != newState.getBlock();
|
||||
if (blockTypeChanged && !world.isClientSide)
|
||||
FluidPropagator.propagateChangedPipe(world, pos, state);
|
||||
if (state.hasBlockEntity() && (blockTypeChanged || !newState.hasTileEntity()))
|
||||
if (state.hasBlockEntity() && (blockTypeChanged || !newState.hasBlockEntity()))
|
||||
world.removeBlockEntity(pos);
|
||||
}
|
||||
|
||||
|
@ -102,11 +99,6 @@ public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBloc
|
|||
FluidPropagator.propagateChangedPipe(world, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.ENCASED_FLUID_PIPE.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult onWrenched(BlockState state, UseOnContext context) {
|
||||
Level world = context.getLevel();
|
||||
|
@ -146,4 +138,14 @@ public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBloc
|
|||
return ItemRequirement.of(AllBlocks.FLUID_PIPE.getDefaultState(), te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<FluidPipeTileEntity> getTileEntityClass() {
|
||||
return FluidPipeTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends FluidPipeTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.ENCASED_FLUID_PIPE.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour;
|
|||
import com.simibubi.create.content.contraptions.relays.elementary.BracketedTileEntityBehaviour;
|
||||
import com.simibubi.create.content.contraptions.wrench.IWrenchableWithBracket;
|
||||
import com.simibubi.create.foundation.advancement.AllTriggers;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
||||
|
@ -37,7 +38,7 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.PipeBlock;
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -47,7 +48,7 @@ import net.minecraft.world.level.pathfinder.PathComputationType;
|
|||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class FluidPipeBlock extends PipeBlock implements SimpleWaterloggedBlock, IWrenchableWithBracket {
|
||||
public class FluidPipeBlock extends PipeBlock implements SimpleWaterloggedBlock, IWrenchableWithBracket, ITE<FluidPipeTileEntity> {
|
||||
|
||||
public FluidPipeBlock(Properties properties) {
|
||||
super(4 / 16f, properties);
|
||||
|
@ -121,16 +122,6 @@ public class FluidPipeBlock extends PipeBlock implements SimpleWaterloggedBlock,
|
|||
return FluidPropagator.getStraightPipeAxis(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.FLUID_PIPE.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
boolean blockTypeChanged = state.getBlock() != newState.getBlock();
|
||||
|
@ -138,7 +129,7 @@ public class FluidPipeBlock extends PipeBlock implements SimpleWaterloggedBlock,
|
|||
FluidPropagator.propagateChangedPipe(world, pos, state);
|
||||
if (state != newState && !isMoving)
|
||||
removeBracket(world, pos, true).ifPresent(stack -> Block.popResource(world, pos, stack));
|
||||
if (state.hasTileEntity() && (blockTypeChanged || !newState.hasTileEntity()))
|
||||
if (state.hasBlockEntity() && (blockTypeChanged || !newState.hasBlockEntity()))
|
||||
world.removeBlockEntity(pos);
|
||||
}
|
||||
|
||||
|
@ -326,4 +317,14 @@ public class FluidPipeBlock extends PipeBlock implements SimpleWaterloggedBlock,
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<FluidPipeTileEntity> getTileEntityClass() {
|
||||
return FluidPipeTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends FluidPipeTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.FLUID_PIPE.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.simibubi.create.AllShapes;
|
|||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock;
|
||||
import com.simibubi.create.content.contraptions.fluids.FluidPropagator;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -20,7 +21,7 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.TickPriority;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
|
@ -28,7 +29,7 @@ import net.minecraft.world.level.pathfinder.PathComputationType;
|
|||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxisPipe {
|
||||
public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxisPipe, ITE<FluidValveTileEntity> {
|
||||
|
||||
public static final BooleanProperty ENABLED = BooleanProperty.create("enabled");
|
||||
|
||||
|
@ -58,11 +59,6 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi
|
|||
return super.prefersConnectionTo(reader, pos, facing, shaftAxis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.FLUID_VALVE.create();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static Axis getPipeAxis(BlockState state) {
|
||||
if (!(state.getBlock() instanceof FluidValveBlock))
|
||||
|
@ -91,7 +87,7 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi
|
|||
boolean blockTypeChanged = state.getBlock() != newState.getBlock();
|
||||
if (blockTypeChanged && !world.isClientSide)
|
||||
FluidPropagator.propagateChangedPipe(world, pos, state);
|
||||
if (state.hasTileEntity() && (blockTypeChanged || !newState.hasTileEntity()))
|
||||
if (state.hasBlockEntity() && (blockTypeChanged || !newState.hasBlockEntity()))
|
||||
world.removeBlockEntity(pos);
|
||||
}
|
||||
|
||||
|
@ -137,4 +133,14 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<FluidValveTileEntity> getTileEntityClass() {
|
||||
return FluidValveTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends FluidValveTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.FLUID_VALVE.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.simibubi.create.AllTileEntities;
|
|||
import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour;
|
||||
import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement;
|
||||
import com.simibubi.create.content.schematics.ItemRequirement;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -18,6 +19,7 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -28,7 +30,7 @@ import net.minecraft.world.level.pathfinder.PathComputationType;
|
|||
|
||||
@MethodsReturnNonnullByDefault
|
||||
@ParametersAreNonnullByDefault
|
||||
public class GlassFluidPipeBlock extends AxisPipeBlock implements SimpleWaterloggedBlock, ISpecialBlockItemRequirement {
|
||||
public class GlassFluidPipeBlock extends AxisPipeBlock implements ITE<StraightPipeTileEntity>, SimpleWaterloggedBlock, ISpecialBlockItemRequirement {
|
||||
|
||||
public static final BooleanProperty ALT = BooleanProperty.create("alt");
|
||||
|
||||
|
@ -42,16 +44,6 @@ public class GlassFluidPipeBlock extends AxisPipeBlock implements SimpleWaterlog
|
|||
super.createBlockStateDefinition(p_206840_1_.add(ALT, BlockStateProperties.WATERLOGGED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.GLASS_FLUID_PIPE.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult onWrenched(BlockState state, UseOnContext context) {
|
||||
if (tryRemoveBracket(context))
|
||||
|
@ -91,4 +83,14 @@ public class GlassFluidPipeBlock extends AxisPipeBlock implements SimpleWaterlog
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<StraightPipeTileEntity> getTileEntityClass() {
|
||||
return StraightPipeTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends StraightPipeTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.GLASS_FLUID_PIPE.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.simibubi.create.AllShapes;
|
|||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.contraptions.fluids.FluidPropagator;
|
||||
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.VoxelShaper;
|
||||
|
||||
|
@ -21,7 +22,7 @@ import net.minecraft.world.level.LevelReader;
|
|||
import net.minecraft.world.level.TickPriority;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.AttachFace;
|
||||
|
@ -29,7 +30,8 @@ import net.minecraft.world.level.pathfinder.PathComputationType;
|
|||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class SmartFluidPipeBlock extends FaceAttachedHorizontalDirectionalBlock implements IAxisPipe, IWrenchable {
|
||||
public class SmartFluidPipeBlock extends FaceAttachedHorizontalDirectionalBlock
|
||||
implements ITE<SmartFluidPipeTileEntity>, IAxisPipe, IWrenchable {
|
||||
|
||||
public SmartFluidPipeBlock(Properties p_i48339_1_) {
|
||||
super(p_i48339_1_);
|
||||
|
@ -85,7 +87,7 @@ public class SmartFluidPipeBlock extends FaceAttachedHorizontalDirectionalBlock
|
|||
boolean blockTypeChanged = state.getBlock() != newState.getBlock();
|
||||
if (blockTypeChanged && !world.isClientSide)
|
||||
FluidPropagator.propagateChangedPipe(world, pos, state);
|
||||
if (state.hasTileEntity() && (blockTypeChanged || !newState.hasTileEntity()))
|
||||
if (state.hasBlockEntity() && (blockTypeChanged || !newState.hasBlockEntity()))
|
||||
world.removeBlockEntity(pos);
|
||||
}
|
||||
|
||||
|
@ -119,7 +121,7 @@ public class SmartFluidPipeBlock extends FaceAttachedHorizontalDirectionalBlock
|
|||
public static boolean isOpenAt(BlockState state, Direction d) {
|
||||
return d.getAxis() == getPipeAxis(state);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random r) {
|
||||
FluidPropagator.propagateChangedPipe(world, pos, state);
|
||||
|
@ -131,16 +133,6 @@ public class SmartFluidPipeBlock extends FaceAttachedHorizontalDirectionalBlock
|
|||
.getAxis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.SMART_FLUID_PIPE.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter p_220053_2_, BlockPos p_220053_3_,
|
||||
CollisionContext p_220053_4_) {
|
||||
|
@ -154,10 +146,20 @@ public class SmartFluidPipeBlock extends FaceAttachedHorizontalDirectionalBlock
|
|||
public Axis getAxis(BlockState state) {
|
||||
return getPipeAxis(state);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<SmartFluidPipeTileEntity> getTileEntityClass() {
|
||||
return SmartFluidPipeTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends SmartFluidPipeTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.SMART_FLUID_PIPE.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import net.minecraft.world.level.block.Mirror;
|
|||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
|
@ -41,6 +42,7 @@ import net.minecraft.world.level.block.state.properties.EnumProperty;
|
|||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeSoundType;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
@ -88,9 +90,9 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE<FluidTankT
|
|||
protected void createBlockStateDefinition(Builder<Block, BlockState> p_206840_1_) {
|
||||
p_206840_1_.add(TOP, BOTTOM, SHAPE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLightValue(BlockState state, BlockGetter world, BlockPos pos) {
|
||||
public int getLightEmission(BlockState state, BlockGetter world, BlockPos pos) {
|
||||
FluidTankTileEntity tankAt = FluidTankConnectivityHandler.anyTankAt(world, pos);
|
||||
if (tankAt == null)
|
||||
return 0;
|
||||
|
@ -221,14 +223,9 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE<FluidTankT
|
|||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.hasTileEntity() && (state.getBlock() != newState.getBlock() || !newState.hasTileEntity())) {
|
||||
if (state.hasBlockEntity() && (state.getBlock() != newState.getBlock() || !newState.hasBlockEntity())) {
|
||||
BlockEntity te = world.getBlockEntity(pos);
|
||||
if (!(te instanceof FluidTankTileEntity))
|
||||
return;
|
||||
|
@ -238,15 +235,15 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE<FluidTankT
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return creative ? AllTileEntities.CREATIVE_FLUID_TANK.create() : AllTileEntities.FLUID_TANK.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<FluidTankTileEntity> getTileEntityClass() {
|
||||
return FluidTankTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends FluidTankTileEntity> getTileEntityType() {
|
||||
return creative ? AllTileEntities.CREATIVE_FLUID_TANK.get() : AllTileEntities.FLUID_TANK.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState mirror(BlockState state, Mirror mirror) {
|
||||
|
@ -300,8 +297,8 @@ public class FluidTankBlock extends Block implements IWrenchable, ITE<FluidTankT
|
|||
|
||||
// Tanks are less noisy when placed in batch
|
||||
public static final SoundType SILENCED_METAL =
|
||||
new SoundType(0.1F, 1.5F, SoundEvents.METAL_BREAK, SoundEvents.METAL_STEP,
|
||||
SoundEvents.METAL_PLACE, SoundEvents.METAL_HIT, SoundEvents.METAL_FALL);
|
||||
new ForgeSoundType(0.1F, 1.5F, () -> SoundEvents.METAL_BREAK, () -> SoundEvents.METAL_STEP,
|
||||
() -> SoundEvents.METAL_PLACE, () -> SoundEvents.METAL_HIT, () -> SoundEvents.METAL_FALL);
|
||||
|
||||
@Override
|
||||
public SoundType getSoundType(BlockState state, LevelReader world, BlockPos pos, Entity entity) {
|
||||
|
|
|
@ -33,6 +33,7 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -40,6 +41,7 @@ import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
|||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.EntityCollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
@ -57,11 +59,6 @@ public class BasinBlock extends Block implements ITE<BasinTileEntity>, IWrenchab
|
|||
registerDefaultState(defaultBlockState().setValue(FACING, Direction.DOWN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(Builder<Block, BlockState> p_206840_1_) {
|
||||
super.createBlockStateDefinition(p_206840_1_.add(FACING));
|
||||
|
@ -75,15 +72,11 @@ public class BasinBlock extends Block implements ITE<BasinTileEntity>, IWrenchab
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.BASIN.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult onWrenched(BlockState state, UseOnContext context) {
|
||||
if (!context.getLevel().isClientSide)
|
||||
withTileEntityDo(context.getLevel(), context.getClickedPos(), bte -> bte.onWrenched(context.getClickedFace()));
|
||||
withTileEntityDo(context.getLevel(), context.getClickedPos(),
|
||||
bte -> bte.onWrenched(context.getClickedFace()));
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -100,7 +93,7 @@ public class BasinBlock extends Block implements ITE<BasinTileEntity>, IWrenchab
|
|||
return InteractionResult.SUCCESS;
|
||||
|
||||
if (EmptyingByBasin.canItemBeEmptied(worldIn, heldItem)
|
||||
|| GenericItemFilling.canItemBeFilled(worldIn, heldItem))
|
||||
|| GenericItemFilling.canItemBeFilled(worldIn, heldItem))
|
||||
return InteractionResult.SUCCESS;
|
||||
if (heldItem.getItem()
|
||||
.equals(Items.SPONGE)
|
||||
|
@ -119,13 +112,14 @@ public class BasinBlock extends Block implements ITE<BasinTileEntity>, IWrenchab
|
|||
ItemStack stackInSlot = inv.getStackInSlot(slot);
|
||||
if (stackInSlot.isEmpty())
|
||||
continue;
|
||||
player.getInventory().placeItemBackInInventory(worldIn, stackInSlot);
|
||||
player.getInventory()
|
||||
.placeItemBackInInventory(stackInSlot);
|
||||
inv.setStackInSlot(slot, ItemStack.EMPTY);
|
||||
success = true;
|
||||
}
|
||||
if (success)
|
||||
worldIn.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundSource.PLAYERS, .2f,
|
||||
1f + Create.RANDOM.nextFloat());
|
||||
1f + Create.RANDOM.nextFloat());
|
||||
te.onEmptied();
|
||||
return InteractionResult.SUCCESS;
|
||||
});
|
||||
|
@ -173,14 +167,15 @@ public class BasinBlock extends Block implements ITE<BasinTileEntity>, IWrenchab
|
|||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter reader, BlockPos pos, CollisionContext ctx) {
|
||||
if (ctx.getEntity() instanceof ItemEntity)
|
||||
if (ctx instanceof EntityCollisionContext && ((EntityCollisionContext) ctx).getEntity()
|
||||
.orElse(null) instanceof ItemEntity)
|
||||
return AllShapes.BASIN_COLLISION_SHAPE;
|
||||
return getShape(state, reader, pos, ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (!state.hasTileEntity() || state.getBlock() == newState.getBlock())
|
||||
if (!state.hasBlockEntity() || state.getBlock() == newState.getBlock())
|
||||
return;
|
||||
TileEntityBehaviour.destroy(worldIn, pos, FilteringBehaviour.TYPE);
|
||||
withTileEntityDo(worldIn, pos, te -> {
|
||||
|
@ -208,6 +203,11 @@ public class BasinBlock extends Block implements ITE<BasinTileEntity>, IWrenchab
|
|||
return BasinTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends BasinTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.BASIN.get();
|
||||
}
|
||||
|
||||
public static boolean canOutputTo(BlockGetter world, BlockPos basinPos, Direction direction) {
|
||||
BlockPos neighbour = basinPos.relative(direction);
|
||||
BlockPos output = neighbour.below();
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Optional;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllRecipeTypes;
|
||||
import com.simibubi.create.content.contraptions.components.fan.SplashingRecipe;
|
||||
|
@ -61,7 +62,8 @@ public class InWorldProcessing {
|
|||
return Type.SPLASHING;
|
||||
Block block = blockState.getBlock();
|
||||
if (block == Blocks.FIRE || AllBlocks.LIT_BLAZE_BURNER.has(blockState)
|
||||
|| (BlockTags.CAMPFIRES.contains(block) && blockState.getOptionalValue(CampfireBlock.LIT).orElse(false))
|
||||
|| (BlockTags.CAMPFIRES.contains(block) && blockState.getOptionalValue(CampfireBlock.LIT)
|
||||
.orElse(false))
|
||||
|| getHeatLevelOf(blockState) == BlazeBurnerBlock.HeatLevel.SMOULDERING)
|
||||
return Type.SMOKING;
|
||||
if (block == Blocks.LAVA || getHeatLevelOf(blockState).isAtLeast(BlazeBurnerBlock.HeatLevel.FADING))
|
||||
|
@ -109,7 +111,8 @@ public class InWorldProcessing {
|
|||
if (blastingRecipe.isPresent())
|
||||
return true;
|
||||
|
||||
return !stack.getItem().isFireResistant();
|
||||
return !stack.getItem()
|
||||
.isFireResistant();
|
||||
}
|
||||
|
||||
if (type == Type.SMOKING) {
|
||||
|
@ -138,7 +141,7 @@ public class InWorldProcessing {
|
|||
if (stacks == null)
|
||||
return;
|
||||
if (stacks.isEmpty()) {
|
||||
entity.remove();
|
||||
entity.discard();
|
||||
return;
|
||||
}
|
||||
entity.setItem(stacks.remove(0));
|
||||
|
@ -248,7 +251,7 @@ public class InWorldProcessing {
|
|||
if (stacks == null)
|
||||
return;
|
||||
if (stacks.isEmpty()) {
|
||||
entity.remove();
|
||||
entity.discard();
|
||||
return;
|
||||
}
|
||||
entity.setItem(stacks.remove(0));
|
||||
|
@ -307,10 +310,9 @@ public class InWorldProcessing {
|
|||
world.addParticle(ParticleTypes.POOF, vec.x, vec.y + .25f, vec.z, 0, 1 / 16f, 0);
|
||||
break;
|
||||
case SPLASHING:
|
||||
Vec3 color = Color.vectorFromRGB(0x0055FF);
|
||||
world.addParticle(new DustParticleOptions((float) color.x, (float) color.y, (float) color.z, 1),
|
||||
vec.x + (world.random.nextFloat() - .5f) * .5f, vec.y + .5f, vec.z + (world.random.nextFloat() - .5f) * .5f,
|
||||
0, 1 / 8f, 0);
|
||||
Vector3f color = new Vector3f(Color.vectorFromRGB(0x0055FF));
|
||||
world.addParticle(new DustParticleOptions(color, 1), vec.x + (world.random.nextFloat() - .5f) * .5f,
|
||||
vec.y + .5f, vec.z + (world.random.nextFloat() - .5f) * .5f, 0, 1 / 8f, 0);
|
||||
world.addParticle(ParticleTypes.SPIT, vec.x + (world.random.nextFloat() - .5f) * .5f, vec.y + .5f,
|
||||
vec.z + (world.random.nextFloat() - .5f) * .5f, 0, 1 / 8f, 0);
|
||||
break;
|
||||
|
|
|
@ -35,7 +35,9 @@ import net.minecraft.world.level.ItemLike;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.level.storage.loot.LootPool;
|
||||
|
@ -43,7 +45,7 @@ import net.minecraft.world.level.storage.loot.LootTable;
|
|||
import net.minecraft.world.level.storage.loot.entries.LootItem;
|
||||
import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition.Builder;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
|
||||
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
|
@ -80,35 +82,36 @@ public class BlazeBurnerBlock extends Block implements ITE<BlazeBurnerTileEntity
|
|||
basin.notifyChangeOfContents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return state.getValue(HEAT_LEVEL)
|
||||
.isAtLeast(HeatLevel.SMOULDERING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemCategory(CreativeModeTab group, NonNullList<ItemStack> list) {
|
||||
list.add(AllItems.EMPTY_BLAZE_BURNER.asStack());
|
||||
super.fillItemCategory(group, list);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.HEATER.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<BlazeBurnerTileEntity> getTileEntityClass() {
|
||||
return BlazeBurnerTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends BlazeBurnerTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.HEATER.get();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos p_153215_, BlockState p_153216_) {
|
||||
if (p_153216_.getValue(HEAT_LEVEL) == HeatLevel.NONE)
|
||||
return null;
|
||||
return ITE.super.newBlockEntity(p_153215_, p_153216_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||
BlockHitResult blockRayTraceResult) {
|
||||
ItemStack heldItem = player.getItemInHand(hand);
|
||||
|
||||
if (!state.hasTileEntity()) {
|
||||
if (!state.hasBlockEntity()) {
|
||||
if (heldItem.getItem() instanceof FlintAndSteelItem) {
|
||||
world.playSound(player, pos, SoundEvents.FLINTANDSTEEL_USE, SoundSource.BLOCKS, 1.0F,
|
||||
world.random.nextFloat() * 0.4F + 0.8F);
|
||||
|
@ -124,12 +127,14 @@ public class BlazeBurnerBlock extends Block implements ITE<BlazeBurnerTileEntity
|
|||
boolean doNotConsume = player.isCreative();
|
||||
boolean forceOverflow = !(player instanceof FakePlayer);
|
||||
|
||||
InteractionResultHolder<ItemStack> res = tryInsert(state, world, pos, heldItem, doNotConsume, forceOverflow, false);
|
||||
InteractionResultHolder<ItemStack> res =
|
||||
tryInsert(state, world, pos, heldItem, doNotConsume, forceOverflow, false);
|
||||
ItemStack leftover = res.getObject();
|
||||
if (!world.isClientSide && !doNotConsume && !leftover.isEmpty()) {
|
||||
if (heldItem.isEmpty()) {
|
||||
player.setItemInHand(hand, leftover);
|
||||
} else if (!player.getInventory().add(leftover)) {
|
||||
} else if (!player.getInventory()
|
||||
.add(leftover)) {
|
||||
player.drop(leftover, false);
|
||||
}
|
||||
}
|
||||
|
@ -137,9 +142,9 @@ public class BlazeBurnerBlock extends Block implements ITE<BlazeBurnerTileEntity
|
|||
return res.getResult() == InteractionResult.SUCCESS ? InteractionResult.SUCCESS : InteractionResult.PASS;
|
||||
}
|
||||
|
||||
public static InteractionResultHolder<ItemStack> tryInsert(BlockState state, Level world, BlockPos pos, ItemStack stack, boolean doNotConsume,
|
||||
boolean forceOverflow, boolean simulate) {
|
||||
if (!state.hasTileEntity())
|
||||
public static InteractionResultHolder<ItemStack> tryInsert(BlockState state, Level world, BlockPos pos,
|
||||
ItemStack stack, boolean doNotConsume, boolean forceOverflow, boolean simulate) {
|
||||
if (!state.hasBlockEntity())
|
||||
return InteractionResultHolder.fail(ItemStack.EMPTY);
|
||||
|
||||
BlockEntity te = world.getBlockEntity(pos);
|
||||
|
@ -199,7 +204,8 @@ public class BlazeBurnerBlock extends Block implements ITE<BlazeBurnerTileEntity
|
|||
|
||||
@Override
|
||||
public int getAnalogOutputSignal(BlockState state, Level p_180641_2_, BlockPos p_180641_3_) {
|
||||
return Math.max(0, state.getValue(HEAT_LEVEL).ordinal() - 1);
|
||||
return Math.max(0, state.getValue(HEAT_LEVEL)
|
||||
.ordinal() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -230,14 +236,12 @@ public class BlazeBurnerBlock extends Block implements ITE<BlazeBurnerTileEntity
|
|||
}
|
||||
|
||||
public static LootTable.Builder buildLootTable() {
|
||||
Builder survivesExplosion = ExplosionCondition.survivesExplosion();
|
||||
LootItemCondition.Builder survivesExplosion = ExplosionCondition.survivesExplosion();
|
||||
BlazeBurnerBlock block = AllBlocks.BLAZE_BURNER.get();
|
||||
|
||||
LootTable.Builder builder = LootTable.lootTable();
|
||||
LootPool.Builder poolBuilder = LootPool.lootPool();
|
||||
for (HeatLevel level : HeatLevel.values()) {
|
||||
ItemLike drop =
|
||||
level == HeatLevel.NONE ? AllItems.EMPTY_BLAZE_BURNER.get() : AllBlocks.BLAZE_BURNER.get();
|
||||
ItemLike drop = level == HeatLevel.NONE ? AllItems.EMPTY_BLAZE_BURNER.get() : AllBlocks.BLAZE_BURNER.get();
|
||||
poolBuilder.add(LootItem.lootTableItem(drop)
|
||||
.when(survivesExplosion)
|
||||
.when(LootItemBlockStatePropertyCondition.hasBlockStateProperties(block)
|
||||
|
@ -249,7 +253,7 @@ public class BlazeBurnerBlock extends Block implements ITE<BlazeBurnerTileEntity
|
|||
}
|
||||
|
||||
public enum HeatLevel implements StringRepresentable {
|
||||
NONE, SMOULDERING, FADING, KINDLED, SEETHING, ;
|
||||
NONE, SMOULDERING, FADING, KINDLED, SEETHING,;
|
||||
|
||||
public static HeatLevel byIndex(int index) {
|
||||
return values()[index];
|
||||
|
|
|
@ -127,7 +127,7 @@ public class BlazeBurnerBlockItem extends BlockItem {
|
|||
return InteractionResult.FAIL;
|
||||
|
||||
giveBurnerItemTo(player, heldItem, hand);
|
||||
entity.remove();
|
||||
entity.discard();
|
||||
return InteractionResult.FAIL;
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ public class BlazeBurnerBlockItem extends BlockItem {
|
|||
player.setItemInHand(hand, filled);
|
||||
return;
|
||||
}
|
||||
player.getInventory().placeItemBackInInventory(player.level, filled);
|
||||
player.getInventory().placeItemBackInInventory(filled);
|
||||
}
|
||||
|
||||
private void spawnCaptureEffects(Level world, Vec3 vec) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import net.minecraft.world.entity.projectile.ThrownEgg;
|
||||
import net.minecraft.world.entity.projectile.ThrownPotion;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -29,32 +30,31 @@ import net.minecraftforge.fml.common.Mod;
|
|||
public class BlazeBurnerHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onThrowableImpact(ProjectileImpactEvent.Throwable event) {
|
||||
public static void onThrowableImpact(ProjectileImpactEvent event) {
|
||||
thrownEggsGetEatenByBurner(event);
|
||||
splashExtinguishesBurner(event);
|
||||
}
|
||||
|
||||
public static void thrownEggsGetEatenByBurner(ProjectileImpactEvent.Throwable event) {
|
||||
if (!(event.getThrowable() instanceof ThrownEgg))
|
||||
public static void thrownEggsGetEatenByBurner(ProjectileImpactEvent event) {
|
||||
Projectile projectile = event.getProjectile();
|
||||
if (!(projectile instanceof ThrownEgg))
|
||||
return;
|
||||
|
||||
if (event.getRayTraceResult()
|
||||
.getType() != HitResult.Type.BLOCK)
|
||||
return;
|
||||
|
||||
BlockEntity tile = event.getThrowable().level.getBlockEntity(new BlockPos(event.getRayTraceResult()
|
||||
BlockEntity tile = projectile.level.getBlockEntity(new BlockPos(event.getRayTraceResult()
|
||||
.getLocation()));
|
||||
if (!(tile instanceof BlazeBurnerTileEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCanceled(true);
|
||||
event.getThrowable()
|
||||
.setDeltaMovement(Vec3.ZERO);
|
||||
event.getThrowable()
|
||||
.remove();
|
||||
projectile.setDeltaMovement(Vec3.ZERO);
|
||||
projectile.discard();
|
||||
|
||||
Level world = event.getThrowable().level;
|
||||
Level world = projectile.level;
|
||||
if (world.isClientSide)
|
||||
return;
|
||||
|
||||
|
@ -72,13 +72,13 @@ public class BlazeBurnerHandler {
|
|||
AllSoundEvents.BLAZE_MUNCH.playOnServer(world, heater.getBlockPos());
|
||||
}
|
||||
|
||||
public static void splashExtinguishesBurner(ProjectileImpactEvent.Throwable event) {
|
||||
if (event.getThrowable().level.isClientSide)
|
||||
public static void splashExtinguishesBurner(ProjectileImpactEvent event) {
|
||||
Projectile projectile = event.getProjectile();
|
||||
if (projectile.level.isClientSide)
|
||||
return;
|
||||
|
||||
if (!(event.getThrowable() instanceof ThrownPotion))
|
||||
if (!(projectile instanceof ThrownPotion))
|
||||
return;
|
||||
ThrownPotion entity = (ThrownPotion) event.getThrowable();
|
||||
ThrownPotion entity = (ThrownPotion) projectile;
|
||||
|
||||
if (event.getRayTraceResult()
|
||||
.getType() != HitResult.Type.BLOCK)
|
||||
|
@ -86,11 +86,13 @@ public class BlazeBurnerHandler {
|
|||
|
||||
ItemStack stack = entity.getItem();
|
||||
Potion potion = PotionUtils.getPotion(stack);
|
||||
if (potion == Potions.WATER && PotionUtils.getMobEffects(stack).isEmpty()) {
|
||||
if (potion == Potions.WATER && PotionUtils.getMobEffects(stack)
|
||||
.isEmpty()) {
|
||||
BlockHitResult result = (BlockHitResult) event.getRayTraceResult();
|
||||
Level world = entity.level;
|
||||
Direction face = result.getDirection();
|
||||
BlockPos pos = result.getBlockPos().relative(face);
|
||||
BlockPos pos = result.getBlockPos()
|
||||
.relative(face);
|
||||
|
||||
extinguishLitBurners(world, pos, face);
|
||||
extinguishLitBurners(world, pos.relative(face.getOpposite()), face);
|
||||
|
@ -104,7 +106,8 @@ public class BlazeBurnerHandler {
|
|||
private static void extinguishLitBurners(Level world, BlockPos pos, Direction direction) {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
if (AllBlocks.LIT_BLAZE_BURNER.has(state)) {
|
||||
world.playSound(null, pos, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
|
||||
world.playSound(null, pos, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 0.5F,
|
||||
2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
|
||||
world.setBlockAndUpdate(pos, AllBlocks.BLAZE_BURNER.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import net.minecraft.world.phys.shapes.CollisionContext;
|
|||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
public class LitBlazeBurnerBlock extends Block {
|
||||
|
||||
|
@ -51,17 +50,8 @@ public class LitBlazeBurnerBlock extends Block {
|
|||
BlockHitResult blockRayTraceResult) {
|
||||
ItemStack heldItem = player.getItemInHand(hand);
|
||||
|
||||
if (heldItem.getToolTypes().contains(ToolType.SHOVEL)) {
|
||||
world.playSound(player, pos, SoundEvents.GENERIC_EXTINGUISH_FIRE, SoundSource.BLOCKS, 0.5f, 2);
|
||||
if (world.isClientSide)
|
||||
return InteractionResult.SUCCESS;
|
||||
heldItem.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(hand));
|
||||
world.setBlockAndUpdate(pos, AllBlocks.BLAZE_BURNER.getDefaultState());
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
if (state.getValue(FLAME_TYPE) == FlameType.REGULAR) {
|
||||
if (heldItem.getItem().is(ItemTags.SOUL_FIRE_BASE_BLOCKS)) {
|
||||
if (heldItem.is(ItemTags.SOUL_FIRE_BASE_BLOCKS)) {
|
||||
world.playSound(player, pos, SoundEvents.SOUL_SAND_PLACE, SoundSource.BLOCKS, 1.0f, world.random.nextFloat() * 0.4F + 0.8F);
|
||||
if (world.isClientSide)
|
||||
return InteractionResult.SUCCESS;
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.simibubi.create.AllShapes;
|
|||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.placement.IPlacementHelper;
|
||||
|
@ -34,6 +35,7 @@ import net.minecraft.world.level.LevelReader;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -45,7 +47,7 @@ import net.minecraft.world.phys.BlockHitResult;
|
|||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class GantryShaftBlock extends DirectionalKineticBlock {
|
||||
public class GantryShaftBlock extends DirectionalKineticBlock implements ITE<GantryShaftTileEntity> {
|
||||
|
||||
public static final Property<Part> PART = EnumProperty.create("part", Part.class);
|
||||
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
|
||||
|
@ -67,14 +69,16 @@ public class GantryShaftBlock extends DirectionalKineticBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult ray) {
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||
BlockHitResult ray) {
|
||||
ItemStack heldItem = player.getItemInHand(hand);
|
||||
|
||||
IPlacementHelper placementHelper = PlacementHelpers.get(placementHelperId);
|
||||
if (!placementHelper.matchesItem(heldItem))
|
||||
return InteractionResult.PASS;
|
||||
|
||||
return placementHelper.getOffset(player, world, state, pos, ray).placeInWorld(world, ((BlockItem) heldItem.getItem()), player, hand, ray);
|
||||
return placementHelper.getOffset(player, world, state, pos, ray)
|
||||
.placeInWorld(world, ((BlockItem) heldItem.getItem()), player, hand, ray);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -173,7 +177,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock {
|
|||
public void onPlace(BlockState state, Level worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
|
||||
super.onPlace(state, worldIn, pos, oldState, isMoving);
|
||||
|
||||
if (!worldIn.isClientSide() && oldState.getBlock().is(AllBlocks.GANTRY_SHAFT.get())) {
|
||||
if (!worldIn.isClientSide() && oldState.is(AllBlocks.GANTRY_SHAFT.get())) {
|
||||
Part oldPart = oldState.getValue(PART), part = state.getValue(PART);
|
||||
if ((oldPart != Part.MIDDLE && part == Part.MIDDLE) || (oldPart == Part.SINGLE && part != Part.SINGLE)) {
|
||||
BlockEntity te = worldIn.getBlockEntity(pos);
|
||||
|
@ -264,11 +268,6 @@ public class GantryShaftBlock extends DirectionalKineticBlock {
|
|||
.getAxis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.GANTRY_SHAFT.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean areStatesKineticallyEquivalent(BlockState oldState, BlockState newState) {
|
||||
return super.areStatesKineticallyEquivalent(oldState, newState)
|
||||
|
@ -303,11 +302,23 @@ public class GantryShaftBlock extends DirectionalKineticBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos, BlockHitResult ray) {
|
||||
public PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos,
|
||||
BlockHitResult ray) {
|
||||
PlacementOffset offset = super.getOffset(player, world, state, pos, ray);
|
||||
offset.withTransform(offset.getTransform().andThen(s -> s.setValue(POWERED, state.getValue(POWERED))));
|
||||
offset.withTransform(offset.getTransform()
|
||||
.andThen(s -> s.setValue(POWERED, state.getValue(POWERED))));
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<GantryShaftTileEntity> getTileEntityClass() {
|
||||
return GantryShaftTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends GantryShaftTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.GANTRY_SHAFT.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import net.minecraft.world.item.context.BlockPlaceContext;
|
|||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
|
@ -43,11 +43,6 @@ public class SpeedControllerBlock extends HorizontalAxisKineticBlock implements
|
|||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.ROTATION_SPEED_CONTROLLER.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
BlockState above = context.getLevel()
|
||||
|
@ -116,4 +111,9 @@ public class SpeedControllerBlock extends HorizontalAxisKineticBlock implements
|
|||
public Class<SpeedControllerTileEntity> getTileEntityClass() {
|
||||
return SpeedControllerTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends SpeedControllerTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.ROTATION_SPEED_CONTROLLER.get();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,11 +22,10 @@ import net.minecraft.world.item.BlockItem;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
|
@ -50,11 +49,6 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen
|
|||
super.createBlockStateDefinition(builder.add(STATE, VERTICAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.SEQUENCED_GEARSHIFT.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCheckWeakPower(BlockState state, LevelReader world, BlockPos pos, Direction side) {
|
||||
return false;
|
||||
|
@ -156,6 +150,11 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen
|
|||
public Class<SequencedGearshiftTileEntity> getTileEntityClass() {
|
||||
return SequencedGearshiftTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends SequencedGearshiftTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.SEQUENCED_GEARSHIFT.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAnalogOutputSignal(BlockState p_149740_1_) {
|
||||
|
|
|
@ -55,6 +55,7 @@ import net.minecraft.world.level.block.Blocks;
|
|||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -69,6 +70,7 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
|||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.EntityCollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
@ -119,14 +121,14 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
|
||||
Player player) {
|
||||
public ItemStack getPickBlock(BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player) {
|
||||
return AllItems.BELT_CONNECTOR.asStack();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, net.minecraft.world.level.storage.loot.LootContext.Builder builder) {
|
||||
public List<ItemStack> getDrops(BlockState state,
|
||||
net.minecraft.world.level.storage.loot.LootContext.Builder builder) {
|
||||
List<ItemStack> drops = super.getDrops(state, builder);
|
||||
BlockEntity tileEntity = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY);
|
||||
if (tileEntity instanceof BeltTileEntity && ((BeltTileEntity) tileEntity).hasPulley())
|
||||
|
@ -269,7 +271,8 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
|||
MutableBoolean success = new MutableBoolean(false);
|
||||
controllerBelt.getInventory()
|
||||
.applyToEachWithin(belt.index + .5f, .55f, (transportedItemStack) -> {
|
||||
player.getInventory().placeItemBackInInventory(transportedItemStack.stack);
|
||||
player.getInventory()
|
||||
.placeItemBackInInventory(transportedItemStack.stack);
|
||||
success.setTrue();
|
||||
return TransportedResult.removeItem();
|
||||
});
|
||||
|
@ -326,7 +329,8 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
|||
return InteractionResult.SUCCESS;
|
||||
KineticTileEntity.switchToBlockState(world, pos, state.setValue(PART, BeltPart.MIDDLE));
|
||||
if (player != null && !player.isCreative())
|
||||
player.getInventory().placeItemBackInInventory(AllBlocks.SHAFT.asStack());
|
||||
player.getInventory()
|
||||
.placeItemBackInInventory(AllBlocks.SHAFT.asStack());
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -339,11 +343,6 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
|||
super.createBlockStateDefinition(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPathTypes getAiPathNodeType(BlockState state, BlockGetter world, BlockPos pos, Mob entity) {
|
||||
return BlockPathTypes.RAIL;
|
||||
|
@ -362,20 +361,25 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
|||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter worldIn, BlockPos pos,
|
||||
CollisionContext context) {
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
if (state.getBlock() != this)
|
||||
return Shapes.empty();
|
||||
|
||||
VoxelShape shape = getShape(state, worldIn, pos, context);
|
||||
if (!(context instanceof EntityCollisionContext))
|
||||
return shape;
|
||||
|
||||
return getTileEntityOptional(worldIn, pos).map(te -> {
|
||||
if (context.getEntity() == null)
|
||||
if (!((EntityCollisionContext) context).getEntity()
|
||||
.isPresent())
|
||||
return shape;
|
||||
|
||||
BeltTileEntity controller = te.getControllerTE();
|
||||
if (controller == null)
|
||||
return shape;
|
||||
if (controller.passengers == null || !controller.passengers.containsKey(context.getEntity()))
|
||||
if (controller.passengers == null || !controller.passengers.containsKey(
|
||||
((EntityCollisionContext) context).getEntity()
|
||||
.get()))
|
||||
return BeltShapes.getCollisionShape(state);
|
||||
return shape;
|
||||
|
||||
|
@ -383,11 +387,6 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
|||
.orElse(shape);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.BELT.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState state) {
|
||||
return state.getValue(CASING) ? RenderShape.MODEL : RenderShape.ENTITYBLOCK_ANIMATED;
|
||||
|
@ -501,8 +500,8 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
|||
}
|
||||
|
||||
@Override
|
||||
public BlockState updateShape(BlockState state, Direction side, BlockState p_196271_3_, LevelAccessor world, BlockPos pos,
|
||||
BlockPos p_196271_6_) {
|
||||
public BlockState updateShape(BlockState state, Direction side, BlockState p_196271_3_, LevelAccessor world,
|
||||
BlockPos pos, BlockPos p_196271_6_) {
|
||||
if (side.getAxis()
|
||||
.isHorizontal())
|
||||
updateTunnelConnections(world, pos.above());
|
||||
|
@ -561,6 +560,11 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
|||
public Class<BeltTileEntity> getTileEntityClass() {
|
||||
return BeltTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends BeltTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.BELT.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) {
|
||||
|
|
|
@ -17,9 +17,7 @@ public class BeltHelper {
|
|||
|
||||
public static boolean isItemUpright(ItemStack stack) {
|
||||
return stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY)
|
||||
.isPresent()
|
||||
|| stack.getItem()
|
||||
.is(AllItemTags.UPRIGHT_ON_BELT.tag);
|
||||
.isPresent() || stack.is(AllItemTags.UPRIGHT_ON_BELT.tag);
|
||||
}
|
||||
|
||||
public static BeltTileEntity getSegmentTE(LevelAccessor world, BlockPos pos) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
|
@ -50,7 +51,8 @@ public class BeltConnectorHandler {
|
|||
|
||||
BlockPos first = NbtUtils.readBlockPos(tag.getCompound("FirstPulley"));
|
||||
|
||||
if (!world.getBlockState(first).hasProperty(BlockStateProperties.AXIS))
|
||||
if (!world.getBlockState(first)
|
||||
.hasProperty(BlockStateProperties.AXIS))
|
||||
continue;
|
||||
Axis axis = world.getBlockState(first)
|
||||
.getValue(BlockStateProperties.AXIS);
|
||||
|
@ -58,7 +60,7 @@ public class BeltConnectorHandler {
|
|||
HitResult rayTrace = Minecraft.getInstance().hitResult;
|
||||
if (rayTrace == null || !(rayTrace instanceof BlockHitResult)) {
|
||||
if (r.nextInt(50) == 0) {
|
||||
world.addParticle(new DustParticleOptions(.3f, .9f, .5f, 1),
|
||||
world.addParticle(new DustParticleOptions(new Vector3f(.3f, .9f, .5f), 1),
|
||||
first.getX() + .5f + randomOffset(.25f), first.getY() + .5f + randomOffset(.25f),
|
||||
first.getZ() + .5f + randomOffset(.25f), 0, 0, 0);
|
||||
}
|
||||
|
@ -125,7 +127,8 @@ public class BeltConnectorHandler {
|
|||
for (float f = 0; f < length; f += .0625f) {
|
||||
Vec3 position = start.add(step.scale(f));
|
||||
if (r.nextInt(10) == 0) {
|
||||
world.addParticle(new DustParticleOptions(canConnect ? .3f : .9f, canConnect ? .9f : .3f, .5f, 1),
|
||||
world.addParticle(
|
||||
new DustParticleOptions(new Vector3f(canConnect ? .3f : .9f, canConnect ? .9f : .3f, .5f), 1),
|
||||
position.x + .5f, position.y + .5f, position.z + .5f, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Optional;
|
|||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock;
|
||||
import com.simibubi.create.content.contraptions.wrench.IWrenchableWithBracket;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -21,7 +22,7 @@ import net.minecraft.world.level.LevelReader;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -31,7 +32,7 @@ import net.minecraft.world.level.material.PushReaction;
|
|||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
|
||||
public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock
|
||||
implements SimpleWaterloggedBlock, IWrenchableWithBracket {
|
||||
implements ITE<SimpleKineticTileEntity>, SimpleWaterloggedBlock, IWrenchableWithBracket {
|
||||
|
||||
public AbstractShaftBlock(Properties properties) {
|
||||
super(properties);
|
||||
|
@ -48,11 +49,6 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock
|
|||
return PushReaction.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.SIMPLE_KINETIC.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
|
@ -86,8 +82,8 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock
|
|||
}
|
||||
|
||||
@Override
|
||||
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState,
|
||||
LevelAccessor world, BlockPos pos, BlockPos neighbourPos) {
|
||||
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, LevelAccessor world,
|
||||
BlockPos pos, BlockPos neighbourPos) {
|
||||
if (state.getValue(BlockStateProperties.WATERLOGGED)) {
|
||||
world.getLiquidTicks()
|
||||
.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
||||
|
@ -120,4 +116,14 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<SimpleKineticTileEntity> getTileEntityClass() {
|
||||
return SimpleKineticTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends SimpleKineticTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.SIMPLE_KINETIC.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
|||
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@SuppressWarnings("deprecation")
|
||||
public class CogWheelBlock extends AbstractShaftBlock implements ICogWheel {
|
||||
boolean isLarge;
|
||||
|
||||
|
@ -79,16 +78,21 @@ public class CogWheelBlock extends AbstractShaftBlock implements ICogWheel {
|
|||
}
|
||||
|
||||
protected Axis getAxisForPlacement(BlockPlaceContext context) {
|
||||
if (context.getPlayer() != null && context.getPlayer().isShiftKeyDown())
|
||||
return context.getClickedFace().getAxis();
|
||||
if (context.getPlayer() != null && context.getPlayer()
|
||||
.isShiftKeyDown())
|
||||
return context.getClickedFace()
|
||||
.getAxis();
|
||||
|
||||
Level world = context.getLevel();
|
||||
BlockState stateBelow = world.getBlockState(context.getClickedPos().below());
|
||||
BlockState stateBelow = world.getBlockState(context.getClickedPos()
|
||||
.below());
|
||||
|
||||
if (AllBlocks.ROTATION_SPEED_CONTROLLER.has(stateBelow) && isLargeCog())
|
||||
return stateBelow.getValue(SpeedControllerBlock.HORIZONTAL_AXIS) == Axis.X ? Axis.Z : Axis.X;
|
||||
|
||||
BlockPos placedOnPos = context.getClickedPos().relative(context.getClickedFace().getOpposite());
|
||||
BlockPos placedOnPos = context.getClickedPos()
|
||||
.relative(context.getClickedFace()
|
||||
.getOpposite());
|
||||
BlockState placedAgainst = world.getBlockState(placedOnPos);
|
||||
|
||||
Block block = placedAgainst.getBlock();
|
||||
|
@ -96,12 +100,16 @@ public class CogWheelBlock extends AbstractShaftBlock implements ICogWheel {
|
|||
return ((IRotate) block).getRotationAxis(placedAgainst);
|
||||
|
||||
Axis preferredAxis = getPreferredAxis(context);
|
||||
return preferredAxis != null ? preferredAxis : context.getClickedFace().getAxis();
|
||||
return preferredAxis != null ? preferredAxis
|
||||
: context.getClickedFace()
|
||||
.getAxis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
boolean shouldWaterlog = context.getLevel().getFluidState(context.getClickedPos()).getType() == Fluids.WATER;
|
||||
boolean shouldWaterlog = context.getLevel()
|
||||
.getFluidState(context.getClickedPos())
|
||||
.getType() == Fluids.WATER;
|
||||
return this.defaultBlockState()
|
||||
.setValue(AXIS, getAxisForPlacement(context))
|
||||
.setValue(BlockStateProperties.WATERLOGGED, shouldWaterlog);
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
package com.simibubi.create.content.contraptions.relays.encased;
|
||||
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
|
||||
public class AdjustablePulleyBlock extends EncasedBeltBlock implements ITE<AdjustablePulleyTileEntity> {
|
||||
public class AdjustablePulleyBlock extends EncasedBeltBlock {
|
||||
|
||||
public static BooleanProperty POWERED = BlockStateProperties.POWERED;
|
||||
|
||||
|
@ -28,17 +27,12 @@ public class AdjustablePulleyBlock extends EncasedBeltBlock implements ITE<Adjus
|
|||
super.createBlockStateDefinition(builder.add(POWERED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.ADJUSTABLE_PULLEY.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlace(BlockState state, Level worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
|
||||
super.onPlace(state, worldIn, pos, oldState, isMoving);
|
||||
if (oldState.getBlock() == state.getBlock())
|
||||
return;
|
||||
withTileEntityDo(worldIn, pos, AdjustablePulleyTileEntity::neighborChanged);
|
||||
withTileEntityDo(worldIn, pos, kte -> ((AdjustablePulleyTileEntity) kte).neighbourChanged());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,7 +53,7 @@ public class AdjustablePulleyBlock extends EncasedBeltBlock implements ITE<Adjus
|
|||
if (worldIn.isClientSide)
|
||||
return;
|
||||
|
||||
withTileEntityDo(worldIn, pos, AdjustablePulleyTileEntity::neighborChanged);
|
||||
withTileEntityDo(worldIn, pos, kte -> ((AdjustablePulleyTileEntity) kte).neighbourChanged());
|
||||
|
||||
boolean previouslyPowered = state.getValue(POWERED);
|
||||
if (previouslyPowered != worldIn.hasNeighborSignal(pos))
|
||||
|
@ -67,8 +61,8 @@ public class AdjustablePulleyBlock extends EncasedBeltBlock implements ITE<Adjus
|
|||
}
|
||||
|
||||
@Override
|
||||
public Class<AdjustablePulleyTileEntity> getTileEntityClass() {
|
||||
return AdjustablePulleyTileEntity.class;
|
||||
public BlockEntityType<? extends KineticTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.ADJUSTABLE_PULLEY.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class AdjustablePulleyTileEntity extends KineticTileEntity {
|
|||
return getModifierForSignal(signal);
|
||||
}
|
||||
|
||||
public void neighborChanged() {
|
||||
public void neighbourChanged() {
|
||||
if (!hasLevel())
|
||||
return;
|
||||
int power = level.getBestNeighborSignal(worldPosition);
|
||||
|
@ -45,7 +45,7 @@ public class AdjustablePulleyTileEntity extends KineticTileEntity {
|
|||
@Override
|
||||
public void lazyTick() {
|
||||
super.lazyTick();
|
||||
neighborChanged();
|
||||
neighbourChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,10 +3,9 @@ package com.simibubi.create.content.contraptions.relays.encased;
|
|||
import com.simibubi.create.AllTileEntities;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class ClutchBlock extends GearshiftBlock {
|
||||
|
@ -15,11 +14,6 @@ public class ClutchBlock extends GearshiftBlock {
|
|||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.CLUTCH.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
|
@ -32,5 +26,10 @@ public class ClutchBlock extends GearshiftBlock {
|
|||
detachKinetics(worldIn, pos, previouslyPowered);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends SplitShaftTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.CLUTCH.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.simibubi.create.AllTileEntities;
|
|||
import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
|
@ -14,11 +15,10 @@ import net.minecraft.core.Direction.AxisDirection;
|
|||
import net.minecraft.util.StringRepresentable;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -27,7 +27,7 @@ import net.minecraft.world.level.block.state.properties.EnumProperty;
|
|||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
|
||||
public class EncasedBeltBlock extends RotatedPillarKineticBlock {
|
||||
public class EncasedBeltBlock extends RotatedPillarKineticBlock implements ITE<KineticTileEntity> {
|
||||
|
||||
public static final Property<Part> PART = EnumProperty.create("part", Part.class);
|
||||
public static final BooleanProperty CONNECTED_ALONG_FIRST_COORDINATE =
|
||||
|
@ -199,11 +199,6 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock {
|
|||
return fromMod / toMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.ENCASED_SHAFT.create();
|
||||
}
|
||||
|
||||
public enum Part implements StringRepresentable {
|
||||
START, MIDDLE, END, NONE;
|
||||
|
||||
|
@ -213,4 +208,14 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<KineticTileEntity> getTileEntityClass() {
|
||||
return KineticTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends KineticTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.ENCASED_SHAFT.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,16 +6,17 @@ import com.simibubi.create.content.contraptions.base.CasingBlock;
|
|||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement;
|
||||
import com.simibubi.create.content.schematics.ItemRequirement;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.tterrag.registrate.util.entry.BlockEntry;
|
||||
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class EncasedShaftBlock extends AbstractEncasedShaftBlock implements ISpecialBlockItemRequirement {
|
||||
public class EncasedShaftBlock extends AbstractEncasedShaftBlock implements ITE<EncasedShaftTileEntity>, ISpecialBlockItemRequirement {
|
||||
|
||||
private BlockEntry<CasingBlock> casing;
|
||||
|
||||
|
@ -32,11 +33,6 @@ public class EncasedShaftBlock extends AbstractEncasedShaftBlock implements ISpe
|
|||
this.casing = casing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.ENCASED_SHAFT.create();
|
||||
}
|
||||
|
||||
public BlockEntry<CasingBlock> getCasing() {
|
||||
return casing;
|
||||
}
|
||||
|
@ -54,5 +50,15 @@ public class EncasedShaftBlock extends AbstractEncasedShaftBlock implements ISpe
|
|||
public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) {
|
||||
return ItemRequirement.of(AllBlocks.SHAFT.getDefaultState(), te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<EncasedShaftTileEntity> getTileEntityClass() {
|
||||
return EncasedShaftTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends EncasedShaftTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.ENCASED_SHAFT.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,23 +5,22 @@ import java.util.Random;
|
|||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.contraptions.RotationPropagator;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.gearbox.GearshiftTileEntity;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.TickPriority;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
|
||||
public class GearshiftBlock extends AbstractEncasedShaftBlock implements ITE<GearshiftTileEntity> {
|
||||
public class GearshiftBlock extends AbstractEncasedShaftBlock implements ITE<SplitShaftTileEntity> {
|
||||
|
||||
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
|
||||
|
||||
|
@ -30,11 +29,6 @@ public class GearshiftBlock extends AbstractEncasedShaftBlock implements ITE<Gea
|
|||
registerDefaultState(defaultBlockState().setValue(POWERED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.GEARSHIFT.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) {
|
||||
builder.add(POWERED);
|
||||
|
@ -61,8 +55,13 @@ public class GearshiftBlock extends AbstractEncasedShaftBlock implements ITE<Gea
|
|||
}
|
||||
|
||||
@Override
|
||||
public Class<GearshiftTileEntity> getTileEntityClass() {
|
||||
return GearshiftTileEntity.class;
|
||||
public Class<SplitShaftTileEntity> getTileEntityClass() {
|
||||
return SplitShaftTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends SplitShaftTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.GEARSHIFT.get();
|
||||
}
|
||||
|
||||
public void detachKinetics(Level worldIn, BlockPos pos, boolean reAttachNextTick) {
|
||||
|
|
|
@ -36,8 +36,8 @@ public interface IWrenchable {
|
|||
|
||||
BlockEntity te = context.getLevel()
|
||||
.getBlockEntity(context.getClickedPos());
|
||||
if (te != null)
|
||||
te.clearCache();
|
||||
// if (te != null)
|
||||
// te.clearCache();
|
||||
if (te instanceof GeneratingKineticTileEntity) {
|
||||
((GeneratingKineticTileEntity) te).reActivateSource = true;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import net.minecraft.world.level.LevelAccessor;
|
|||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -175,15 +175,15 @@ public class CopperBacktankBlock extends HorizontalKineticBlock
|
|||
return AllShapes.BACKTANK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.COPPER_BACKTANK.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<CopperBacktankTileEntity> getTileEntityClass() {
|
||||
return CopperBacktankTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends CopperBacktankTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.COPPER_BACKTANK.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
|
|
|
@ -13,6 +13,8 @@ import net.minecraft.world.level.BlockGetter;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BellBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BellAttachType;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
@ -26,12 +28,6 @@ public abstract class AbstractBellBlock<TE extends AbstractBellTileEntity> exten
|
|||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BlockEntity newBlockEntity(BlockGetter block) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter reader, BlockPos pos, CollisionContext selection) {
|
||||
Direction facing = state.getValue(FACING);
|
||||
|
@ -50,8 +46,7 @@ public abstract class AbstractBellBlock<TE extends AbstractBellTileEntity> exten
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onHit(Level world, BlockState state, BlockHitResult hit, @Nullable Player player,
|
||||
boolean flag) {
|
||||
public boolean onHit(Level world, BlockState state, BlockHitResult hit, @Nullable Player player, boolean flag) {
|
||||
BlockPos pos = hit.getBlockPos();
|
||||
Direction direction = hit.getDirection();
|
||||
if (direction == null)
|
||||
|
@ -94,6 +89,17 @@ public abstract class AbstractBellBlock<TE extends AbstractBellTileEntity> exten
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockEntity newBlockEntity(BlockPos p_152198_, BlockState p_152199_) {
|
||||
return ITE.super.newBlockEntity(p_152198_, p_152199_);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level p_152194_, BlockState p_152195_,
|
||||
BlockEntityType<T> p_152196_) {
|
||||
return ITE.super.getTicker(p_152194_, p_152195_, p_152196_);
|
||||
}
|
||||
|
||||
public abstract void playSound(Level world, BlockPos pos);
|
||||
|
||||
}
|
||||
|
|
|
@ -4,9 +4,8 @@ import com.simibubi.create.AllSoundEvents;
|
|||
import com.simibubi.create.AllTileEntities;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class HauntedBellBlock extends AbstractBellBlock<HauntedBellTileEntity> {
|
||||
|
@ -16,10 +15,10 @@ public class HauntedBellBlock extends AbstractBellBlock<HauntedBellTileEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.HAUNTED_BELL.create();
|
||||
public BlockEntityType<? extends HauntedBellTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.HAUNTED_BELL.get();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<HauntedBellTileEntity> getTileEntityClass() {
|
||||
return HauntedBellTileEntity.class;
|
||||
|
|
|
@ -39,7 +39,7 @@ public class HauntedBellPulser {
|
|||
return;
|
||||
if (event.player.isSpectator())
|
||||
return;
|
||||
if (!event.player.isHolding(AllBlocks.HAUNTED_BELL::is))
|
||||
if (!event.player.isHolding(AllBlocks.HAUNTED_BELL::isIn))
|
||||
return;
|
||||
|
||||
Entity player = event.player;
|
||||
|
|
|
@ -10,12 +10,11 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
|
@ -26,8 +25,8 @@ public class PeculiarBellBlock extends AbstractBellBlock<PeculiarBellTileEntity>
|
|||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.PECULIAR_BELL.create();
|
||||
public BlockEntityType<? extends PeculiarBellTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.PECULIAR_BELL.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,7 +65,7 @@ public class PeculiarBellBlock extends AbstractBellBlock<PeculiarBellTileEntity>
|
|||
return state;
|
||||
|
||||
Block underBlock = underState.getBlock();
|
||||
if (!(Blocks.SOUL_FIRE.is(underBlock) || Blocks.SOUL_CAMPFIRE.is(underBlock)))
|
||||
if (!(Blocks.SOUL_FIRE.equals(underBlock) || Blocks.SOUL_CAMPFIRE.equals(underBlock)))
|
||||
return state;
|
||||
|
||||
if (world.isClientSide()) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Random;
|
|||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.content.curiosities.symmetry.mirror.EmptyMirror;
|
||||
import com.simibubi.create.content.curiosities.symmetry.mirror.SymmetryMirror;
|
||||
|
@ -58,8 +59,7 @@ public class SymmetryHandler {
|
|||
.isEmpty()
|
||||
&& inv.getItem(i)
|
||||
.getItem() == AllItems.WAND_OF_SYMMETRY.get()) {
|
||||
SymmetryWandItem.apply(player.level, inv.getItem(i), player, event.getPos(),
|
||||
event.getPlacedBlock());
|
||||
SymmetryWandItem.apply(player.level, inv.getItem(i), player, event.getPos(), event.getPlacedBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,8 @@ public class SymmetryHandler {
|
|||
LocalPlayer player = mc.player;
|
||||
|
||||
for (int i = 0; i < Inventory.getSelectionSize(); i++) {
|
||||
ItemStack stackInSlot = player.getInventory().getItem(i);
|
||||
ItemStack stackInSlot = player.getInventory()
|
||||
.getItem(i);
|
||||
if (!AllItems.WAND_OF_SYMMETRY.isIn(stackInSlot))
|
||||
continue;
|
||||
if (!SymmetryWandItem.isEnabled(stackInSlot))
|
||||
|
@ -120,9 +121,8 @@ public class SymmetryHandler {
|
|||
|
||||
mc.getBlockRenderer()
|
||||
.getModelRenderer()
|
||||
.renderModel(player.level, model, Blocks.AIR.defaultBlockState(), pos, ms, builder, true,
|
||||
player.level.getRandom(), Mth.getSeed(pos), OverlayTexture.NO_OVERLAY,
|
||||
EmptyModelData.INSTANCE);
|
||||
.tesselateBlock(player.level, model, Blocks.AIR.defaultBlockState(), pos, ms, builder, true,
|
||||
player.level.getRandom(), Mth.getSeed(pos), OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE);
|
||||
|
||||
buffer.endBatch();
|
||||
ms.popPose();
|
||||
|
@ -146,7 +146,8 @@ public class SymmetryHandler {
|
|||
|
||||
if (tickCounter % 10 == 0) {
|
||||
for (int i = 0; i < Inventory.getSelectionSize(); i++) {
|
||||
ItemStack stackInSlot = player.getInventory().getItem(i);
|
||||
ItemStack stackInSlot = player.getInventory()
|
||||
.getItem(i);
|
||||
|
||||
if (stackInSlot != null && AllItems.WAND_OF_SYMMETRY.isIn(stackInSlot)
|
||||
&& SymmetryWandItem.isEnabled(stackInSlot)) {
|
||||
|
@ -171,8 +172,10 @@ public class SymmetryHandler {
|
|||
|
||||
public static void drawEffect(BlockPos from, BlockPos to) {
|
||||
double density = 0.8f;
|
||||
Vec3 start = Vec3.atLowerCornerOf(from).add(0.5, 0.5, 0.5);
|
||||
Vec3 end = Vec3.atLowerCornerOf(to).add(0.5, 0.5, 0.5);
|
||||
Vec3 start = Vec3.atLowerCornerOf(from)
|
||||
.add(0.5, 0.5, 0.5);
|
||||
Vec3 end = Vec3.atLowerCornerOf(to)
|
||||
.add(0.5, 0.5, 0.5);
|
||||
Vec3 diff = end.subtract(start);
|
||||
|
||||
Vec3 step = diff.normalize()
|
||||
|
@ -184,8 +187,8 @@ public class SymmetryHandler {
|
|||
Vec3 pos = start.add(step.scale(i));
|
||||
Vec3 speed = new Vec3(0, r.nextDouble() * -40f, 0);
|
||||
|
||||
Minecraft.getInstance().level.addParticle(new DustParticleOptions(1, 1, 1, 1), pos.x, pos.y, pos.z,
|
||||
speed.x, speed.y, speed.z);
|
||||
Minecraft.getInstance().level.addParticle(new DustParticleOptions(new Vector3f(1, 1, 1), 1), pos.x, pos.y,
|
||||
pos.z, speed.x, speed.y, speed.z);
|
||||
}
|
||||
|
||||
Vec3 speed = new Vec3(0, r.nextDouble() * 1 / 32f, 0);
|
||||
|
|
|
@ -318,7 +318,7 @@ public class SymmetryWandItem extends Item {
|
|||
.isEmpty())
|
||||
player.getMainHandItem()
|
||||
.mineBlock(world, blockstate, position, player);
|
||||
BlockEntity tileentity = blockstate.hasTileEntity() ? world.getBlockEntity(position) : null;
|
||||
BlockEntity tileentity = blockstate.hasBlockEntity() ? world.getBlockEntity(position) : null;
|
||||
Block.dropResources(blockstate, world, pos, tileentity, player, player.getMainHandItem()); // Add fortune, silk touch and other loot modifiers
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import net.minecraft.world.level.LevelAccessor;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -89,7 +89,7 @@ public class ToolboxBlock extends HorizontalDirectionalBlock implements SimpleWa
|
|||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean moving) {
|
||||
if (state.hasTileEntity() && (!newState.hasTileEntity() || !(newState.getBlock() instanceof ToolboxBlock)))
|
||||
if (state.hasBlockEntity() && (!newState.hasBlockEntity() || !(newState.getBlock() instanceof ToolboxBlock)))
|
||||
world.removeBlockEntity(pos);
|
||||
}
|
||||
|
||||
|
@ -140,11 +140,6 @@ public class ToolboxBlock extends HorizontalDirectionalBlock implements SimpleWa
|
|||
return AllShapes.TOOLBOX.get(state.getValue(FACING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||
BlockHitResult ray) {
|
||||
|
@ -172,11 +167,6 @@ public class ToolboxBlock extends HorizontalDirectionalBlock implements SimpleWa
|
|||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.TOOLBOX.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
FluidState ifluidstate = context.getLevel()
|
||||
|
@ -190,6 +180,11 @@ public class ToolboxBlock extends HorizontalDirectionalBlock implements SimpleWa
|
|||
public Class<ToolboxTileEntity> getTileEntityClass() {
|
||||
return ToolboxTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends ToolboxTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.TOOLBOX.get();
|
||||
}
|
||||
|
||||
public DyeColor getColor() {
|
||||
return color;
|
||||
|
|
|
@ -390,11 +390,11 @@ public class ToolboxTileEntity extends SmartTileEntity implements MenuProvider,
|
|||
return customName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCache() {
|
||||
super.clearCache();
|
||||
colorProvider.reset();
|
||||
}
|
||||
// @Override
|
||||
// public void clearCache() {
|
||||
// super.clearCache();
|
||||
// colorProvider.reset();
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void setChanged() {
|
||||
|
|
|
@ -60,7 +60,7 @@ public class ZapperInteractionHandler {
|
|||
if (BlockHelper.getRequiredItem(newState)
|
||||
.isEmpty())
|
||||
return false;
|
||||
if (newState.hasTileEntity() && !AllBlockTags.SAFE_NBT.matches(newState))
|
||||
if (newState.hasBlockEntity() && !AllBlockTags.SAFE_NBT.matches(newState))
|
||||
return false;
|
||||
if (newState.hasProperty(BlockStateProperties.DOUBLE_BLOCK_HALF))
|
||||
return false;
|
||||
|
|
|
@ -27,6 +27,7 @@ import net.minecraft.world.level.LevelReader;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -54,21 +55,11 @@ public class BeltTunnelBlock extends Block implements ITE<BeltTunnelTileEntity>,
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||
return BeltTunnelShapes.getShape(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.ANDESITE_TUNNEL.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) {
|
||||
BlockState blockState = worldIn.getBlockState(pos.below());
|
||||
|
@ -95,7 +86,7 @@ public class BeltTunnelBlock extends Block implements ITE<BeltTunnelTileEntity>,
|
|||
public static boolean isStraight(BlockState state) {
|
||||
return hasWindow(state) || state.getValue(SHAPE) == Shape.STRAIGHT;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isJunction(BlockState state) {
|
||||
Shape shape = state.getValue(SHAPE);
|
||||
return shape == Shape.CROSS || shape == Shape.T_LEFT || shape == Shape.T_RIGHT;
|
||||
|
@ -174,14 +165,14 @@ public class BeltTunnelBlock extends Block implements ITE<BeltTunnelTileEntity>,
|
|||
Direction fw = Direction.get(AxisDirection.POSITIVE, axis);
|
||||
BlockState blockState1 = reader.getBlockState(pos.relative(fw));
|
||||
BlockState blockState2 = reader.getBlockState(pos.relative(fw.getOpposite()));
|
||||
|
||||
|
||||
boolean funnel1 = blockState1.getBlock() instanceof BeltFunnelBlock
|
||||
&& blockState1.getValue(BeltFunnelBlock.SHAPE) == BeltFunnelBlock.Shape.EXTENDED
|
||||
&& blockState1.getValue(BeltFunnelBlock.HORIZONTAL_FACING) == fw.getOpposite();
|
||||
boolean funnel2 = blockState2.getBlock() instanceof BeltFunnelBlock
|
||||
&& blockState2.getValue(BeltFunnelBlock.SHAPE) == BeltFunnelBlock.Shape.EXTENDED
|
||||
&& blockState2.getValue(BeltFunnelBlock.HORIZONTAL_FACING) == fw;
|
||||
|
||||
|
||||
boolean valid1 = blockState1.getBlock() instanceof BeltTunnelBlock || funnel1;
|
||||
boolean valid2 = blockState2.getBlock() instanceof BeltTunnelBlock || funnel2;
|
||||
boolean canHaveWindow = valid1 && valid2 && !(funnel1 && funnel2);
|
||||
|
@ -245,4 +236,9 @@ public class BeltTunnelBlock extends Block implements ITE<BeltTunnelTileEntity>,
|
|||
return BeltTunnelTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends BeltTunnelTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.ANDESITE_TUNNEL.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,11 +15,10 @@ import net.minecraft.world.InteractionHand;
|
|||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
@ -51,8 +50,8 @@ public class BrassTunnelBlock extends BeltTunnelBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.BRASS_TUNNEL.create();
|
||||
public BlockEntityType<? extends BeltTunnelTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.BRASS_TUNNEL.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,8 +63,8 @@ public class BrassTunnelBlock extends BeltTunnelBlock {
|
|||
@Override
|
||||
public void onRemove(BlockState p_196243_1_, Level p_196243_2_, BlockPos p_196243_3_, BlockState p_196243_4_,
|
||||
boolean p_196243_5_) {
|
||||
if (p_196243_1_.hasTileEntity()
|
||||
&& (p_196243_1_.getBlock() != p_196243_4_.getBlock() || !p_196243_4_.hasTileEntity())) {
|
||||
if (p_196243_1_.hasBlockEntity()
|
||||
&& (p_196243_1_.getBlock() != p_196243_4_.getBlock() || !p_196243_4_.hasBlockEntity())) {
|
||||
TileEntityBehaviour.destroy(p_196243_2_, p_196243_3_, FilteringBehaviour.TYPE);
|
||||
withTileEntityDo(p_196243_2_, p_196243_3_, te -> {
|
||||
if (te instanceof BrassTunnelTileEntity)
|
||||
|
|
|
@ -38,11 +38,6 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I
|
|||
super(p_i48440_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isChute(BlockState state) {
|
||||
return state.getBlock() instanceof AbstractChuteBlock;
|
||||
}
|
||||
|
@ -72,9 +67,6 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract BlockEntity createTileEntity(BlockState state, BlockGetter world);
|
||||
|
||||
@Override
|
||||
public void updateEntityAfterFallOn(BlockGetter worldIn, Entity entityIn) {
|
||||
super.updateEntityAfterFallOn(worldIn, entityIn);
|
||||
|
@ -128,7 +120,7 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I
|
|||
@Override
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState p_196243_4_, boolean p_196243_5_) {
|
||||
boolean differentBlock = state.getBlock() != p_196243_4_.getBlock();
|
||||
if (state.hasTileEntity() && (differentBlock || !p_196243_4_.hasTileEntity())) {
|
||||
if (state.hasBlockEntity() && (differentBlock || !p_196243_4_.hasBlockEntity())) {
|
||||
TileEntityBehaviour.destroy(world, pos, FilteringBehaviour.TYPE);
|
||||
withTileEntityDo(world, pos, c -> c.onRemoved(state));
|
||||
world.removeBlockEntity(pos);
|
||||
|
|
|
@ -18,7 +18,7 @@ import net.minecraft.world.level.BlockGetter;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -47,11 +47,6 @@ public class ChuteBlock extends AbstractChuteBlock {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.CHUTE.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getFacing(BlockState state) {
|
||||
return state.getValue(FACING);
|
||||
|
@ -151,5 +146,10 @@ public class ChuteBlock extends AbstractChuteBlock {
|
|||
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends ChuteTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.CHUTE.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -565,7 +565,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
|||
}
|
||||
|
||||
public void onAdded() {
|
||||
clearCache();
|
||||
// clearCache();
|
||||
updatePull();
|
||||
ChuteTileEntity targetChute = getTargetChute(getBlockState());
|
||||
if (targetChute != null)
|
||||
|
|
|
@ -11,7 +11,7 @@ import net.minecraft.world.level.BlockGetter;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -55,10 +55,10 @@ public class SmartChuteBlock extends AbstractChuteBlock {
|
|||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.SMART_CHUTE.create();
|
||||
public BlockEntityType<? extends ChuteTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.SMART_CHUTE.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
@ -37,20 +37,15 @@ public class DepotBlock extends Block implements ITE<DepotTileEntity>, IWrenchab
|
|||
return AllShapes.DEPOT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createTileEntity(BlockState state, BlockGetter world) {
|
||||
return AllTileEntities.DEPOT.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<DepotTileEntity> getTileEntityClass() {
|
||||
return DepotTileEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<? extends DepotTileEntity> getTileEntityType() {
|
||||
return AllTileEntities.DEPOT.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue