From 8add39d24d7452bacd85ddb57a2f841d21e0d661 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:56:35 +0200 Subject: [PATCH] Basin checks use blockentity instanceof - Implements #6172 --- .../fluids/particle/BasinFluidParticle.java | 3 ++- .../AllArmInteractionPointTypes.java | 3 ++- .../kinetics/mixer/MechanicalMixerBlock.java | 4 ++-- .../kinetics/press/MechanicalPressBlock.java | 4 ++-- .../content/kinetics/press/PressingBehaviour.java | 4 ++-- .../processing/AssemblyOperatorBlockItem.java | 15 +++++++++------ .../content/processing/basin/BasinBlock.java | 8 ++++++-- .../processing/burner/BlazeBurnerBlockEntity.java | 4 ++-- 8 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/fluids/particle/BasinFluidParticle.java b/src/main/java/com/simibubi/create/content/fluids/particle/BasinFluidParticle.java index 4b1fdb456..ee6af63f8 100644 --- a/src/main/java/com/simibubi/create/content/fluids/particle/BasinFluidParticle.java +++ b/src/main/java/com/simibubi/create/content/fluids/particle/BasinFluidParticle.java @@ -3,6 +3,7 @@ package com.simibubi.create.content.fluids.particle; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Quaternion; import com.simibubi.create.AllBlocks; +import com.simibubi.create.content.processing.basin.BasinBlock; import com.simibubi.create.content.processing.basin.BasinBlockEntity; import com.simibubi.create.foundation.utility.VecHelper; @@ -56,7 +57,7 @@ public class BasinFluidParticle extends FluidStackParticle { : 1 / 8f * (1 - ((Math.abs(age - (lifetime / 2)) / (1f * lifetime)))); if (age % 2 == 0) { - if (!AllBlocks.BASIN.has(level.getBlockState(basinPos))) { + if (!AllBlocks.BASIN.has(level.getBlockState(basinPos)) && !BasinBlock.isBasin(level, basinPos)) { remove(); return; } diff --git a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/AllArmInteractionPointTypes.java b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/AllArmInteractionPointTypes.java index 12b95efcb..4fab5eb32 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/AllArmInteractionPointTypes.java +++ b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/AllArmInteractionPointTypes.java @@ -25,6 +25,7 @@ import com.simibubi.create.content.logistics.funnel.BeltFunnelBlock.Shape; import com.simibubi.create.content.logistics.funnel.FunnelBlock; import com.simibubi.create.content.logistics.funnel.FunnelBlockEntity; import com.simibubi.create.content.logistics.tunnel.BeltTunnelBlock; +import com.simibubi.create.content.processing.basin.BasinBlock; import com.simibubi.create.content.processing.burner.BlazeBurnerBlock; import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringBehaviour; @@ -96,7 +97,7 @@ public class AllArmInteractionPointTypes { @Override public boolean canCreatePoint(Level level, BlockPos pos, BlockState state) { - return AllBlocks.BASIN.has(state); + return BasinBlock.isBasin(level, pos); } @Override diff --git a/src/main/java/com/simibubi/create/content/kinetics/mixer/MechanicalMixerBlock.java b/src/main/java/com/simibubi/create/content/kinetics/mixer/MechanicalMixerBlock.java index 62d987084..c57147dba 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/mixer/MechanicalMixerBlock.java +++ b/src/main/java/com/simibubi/create/content/kinetics/mixer/MechanicalMixerBlock.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.kinetics.mixer; import com.simibubi.create.AllBlockEntityTypes; -import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; import com.simibubi.create.content.kinetics.base.KineticBlock; import com.simibubi.create.content.kinetics.simpleRelays.ICogWheel; +import com.simibubi.create.content.processing.basin.BasinBlock; import com.simibubi.create.foundation.block.IBE; import net.minecraft.core.BlockPos; @@ -28,7 +28,7 @@ public class MechanicalMixerBlock extends KineticBlock implements IBE, IWrencha protected void createBlockStateDefinition(Builder p_206840_1_) { super.createBlockStateDefinition(p_206840_1_.add(FACING)); } + + public static boolean isBasin(LevelReader world, BlockPos pos) { + return world.getBlockEntity(pos) instanceof BasinBlockEntity; + } @Override public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { @@ -127,7 +130,8 @@ public class BasinBlock extends Block implements IBE, IWrencha @Override public void updateEntityAfterFallOn(BlockGetter worldIn, Entity entityIn) { super.updateEntityAfterFallOn(worldIn, entityIn); - if (!AllBlocks.BASIN.has(worldIn.getBlockState(entityIn.blockPosition()))) + if (!worldIn.getBlockState(entityIn.blockPosition()) + .is(this)) return; if (!(entityIn instanceof ItemEntity)) return; diff --git a/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerBlockEntity.java b/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerBlockEntity.java index cf1a6f8a8..d10b8edbd 100644 --- a/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/processing/burner/BlazeBurnerBlockEntity.java @@ -3,10 +3,10 @@ package com.simibubi.create.content.processing.burner; import java.util.List; import java.util.Random; -import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.AllTags.AllItemTags; import com.simibubi.create.content.fluids.tank.FluidTankBlock; +import com.simibubi.create.content.processing.basin.BasinBlock; import com.simibubi.create.content.processing.burner.BlazeBurnerBlock.HeatLevel; import com.simibubi.create.foundation.blockEntity.SmartBlockEntity; import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; @@ -269,7 +269,7 @@ public class BlazeBurnerBlockEntity extends SmartBlockEntity { if (isVirtual()) return false; BlockState blockState = level.getBlockState(worldPosition.above()); - return AllBlocks.BASIN.has(blockState) || blockState.getBlock() instanceof FluidTankBlock; + return BasinBlock.isBasin(level, worldPosition.above()) || blockState.getBlock() instanceof FluidTankBlock; } protected void playSound() {