Basin checks use blockentity instanceof

- Implements #6172
This commit is contained in:
simibubi 2024-07-25 16:56:35 +02:00
parent 625a1f38e6
commit 8add39d24d
8 changed files with 27 additions and 18 deletions

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.fluids.particle;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Quaternion; import com.mojang.math.Quaternion;
import com.simibubi.create.AllBlocks; 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.content.processing.basin.BasinBlockEntity;
import com.simibubi.create.foundation.utility.VecHelper; 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)))); : 1 / 8f * (1 - ((Math.abs(age - (lifetime / 2)) / (1f * lifetime))));
if (age % 2 == 0) { if (age % 2 == 0) {
if (!AllBlocks.BASIN.has(level.getBlockState(basinPos))) { if (!AllBlocks.BASIN.has(level.getBlockState(basinPos)) && !BasinBlock.isBasin(level, basinPos)) {
remove(); remove();
return; return;
} }

View file

@ -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.FunnelBlock;
import com.simibubi.create.content.logistics.funnel.FunnelBlockEntity; import com.simibubi.create.content.logistics.funnel.FunnelBlockEntity;
import com.simibubi.create.content.logistics.tunnel.BeltTunnelBlock; 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.content.processing.burner.BlazeBurnerBlock;
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringBehaviour;
@ -96,7 +97,7 @@ public class AllArmInteractionPointTypes {
@Override @Override
public boolean canCreatePoint(Level level, BlockPos pos, BlockState state) { public boolean canCreatePoint(Level level, BlockPos pos, BlockState state) {
return AllBlocks.BASIN.has(state); return BasinBlock.isBasin(level, pos);
} }
@Override @Override

View file

@ -1,10 +1,10 @@
package com.simibubi.create.content.kinetics.mixer; package com.simibubi.create.content.kinetics.mixer;
import com.simibubi.create.AllBlockEntityTypes; import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllShapes; import com.simibubi.create.AllShapes;
import com.simibubi.create.content.kinetics.base.KineticBlock; import com.simibubi.create.content.kinetics.base.KineticBlock;
import com.simibubi.create.content.kinetics.simpleRelays.ICogWheel; import com.simibubi.create.content.kinetics.simpleRelays.ICogWheel;
import com.simibubi.create.content.processing.basin.BasinBlock;
import com.simibubi.create.foundation.block.IBE; import com.simibubi.create.foundation.block.IBE;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -28,7 +28,7 @@ public class MechanicalMixerBlock extends KineticBlock implements IBE<Mechanical
@Override @Override
public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) {
return !AllBlocks.BASIN.has(worldIn.getBlockState(pos.below())); return !BasinBlock.isBasin(worldIn, pos.below());
} }
@Override @Override

View file

@ -1,9 +1,9 @@
package com.simibubi.create.content.kinetics.press; package com.simibubi.create.content.kinetics.press;
import com.simibubi.create.AllBlockEntityTypes; import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllShapes; import com.simibubi.create.AllShapes;
import com.simibubi.create.content.kinetics.base.HorizontalKineticBlock; import com.simibubi.create.content.kinetics.base.HorizontalKineticBlock;
import com.simibubi.create.content.processing.basin.BasinBlock;
import com.simibubi.create.foundation.block.IBE; import com.simibubi.create.foundation.block.IBE;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -37,7 +37,7 @@ public class MechanicalPressBlock extends HorizontalKineticBlock implements IBE<
@Override @Override
public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) {
return !AllBlocks.BASIN.has(worldIn.getBlockState(pos.below())); return !BasinBlock.isBasin(worldIn, pos.below());
} }
@Override @Override

View file

@ -3,11 +3,11 @@ package com.simibubi.create.content.kinetics.press;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.content.kinetics.belt.behaviour.BeltProcessingBehaviour; import com.simibubi.create.content.kinetics.belt.behaviour.BeltProcessingBehaviour;
import com.simibubi.create.content.kinetics.belt.behaviour.TransportedItemStackHandlerBehaviour; import com.simibubi.create.content.kinetics.belt.behaviour.TransportedItemStackHandlerBehaviour;
import com.simibubi.create.content.kinetics.belt.transport.TransportedItemStack; import com.simibubi.create.content.kinetics.belt.transport.TransportedItemStack;
import com.simibubi.create.content.processing.basin.BasinBlock;
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity; import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
@ -144,7 +144,7 @@ public class PressingBehaviour extends BeltProcessingBehaviour {
if (BlockEntityBehaviour.get(level, worldPosition.below(2), if (BlockEntityBehaviour.get(level, worldPosition.below(2),
TransportedItemStackHandlerBehaviour.TYPE) != null) TransportedItemStackHandlerBehaviour.TYPE) != null)
return; return;
if (AllBlocks.BASIN.has(level.getBlockState(worldPosition.below(2)))) if (BasinBlock.isBasin(level, worldPosition.below(2)))
return; return;
for (ItemEntity itemEntity : level.getEntitiesOfClass(ItemEntity.class, for (ItemEntity itemEntity : level.getEntitiesOfClass(ItemEntity.class,

View file

@ -3,12 +3,15 @@ package com.simibubi.create.content.processing;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.kinetics.belt.BeltBlock; import com.simibubi.create.content.kinetics.belt.BeltBlock;
import com.simibubi.create.content.kinetics.belt.BeltSlope; import com.simibubi.create.content.kinetics.belt.BeltSlope;
import com.simibubi.create.content.processing.basin.BasinBlock;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.item.context.BlockPlaceContext;
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.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
@ -25,11 +28,11 @@ public class AssemblyOperatorBlockItem extends BlockItem {
BlockPos placedOnPos = context.getClickedPos() BlockPos placedOnPos = context.getClickedPos()
.relative(context.getClickedFace() .relative(context.getClickedFace()
.getOpposite()); .getOpposite());
BlockState placedOnState = context.getLevel() Level level = context.getLevel();
BlockState placedOnState = level
.getBlockState(placedOnPos); .getBlockState(placedOnPos);
if (operatesOn(placedOnState) && context.getClickedFace() == Direction.UP) { if (operatesOn(level, placedOnPos, placedOnState) && context.getClickedFace() == Direction.UP) {
if (context.getLevel() if (level.getBlockState(placedOnPos.above(2))
.getBlockState(placedOnPos.above(2))
.getMaterial() .getMaterial()
.isReplaceable()) .isReplaceable())
context = adjustContext(context, placedOnPos); context = adjustContext(context, placedOnPos);
@ -45,10 +48,10 @@ public class AssemblyOperatorBlockItem extends BlockItem {
return new AssemblyOperatorUseContext(context.getLevel(), context.getPlayer(), context.getHand(), context.getItemInHand(), new BlockHitResult(new Vec3((double)up.getX() + 0.5D + (double) Direction.UP.getStepX() * 0.5D, (double)up.getY() + 0.5D + (double) Direction.UP.getStepY() * 0.5D, (double)up.getZ() + 0.5D + (double) Direction.UP.getStepZ() * 0.5D), Direction.UP, up, false)); return new AssemblyOperatorUseContext(context.getLevel(), context.getPlayer(), context.getHand(), context.getItemInHand(), new BlockHitResult(new Vec3((double)up.getX() + 0.5D + (double) Direction.UP.getStepX() * 0.5D, (double)up.getY() + 0.5D + (double) Direction.UP.getStepY() * 0.5D, (double)up.getZ() + 0.5D + (double) Direction.UP.getStepZ() * 0.5D), Direction.UP, up, false));
} }
protected boolean operatesOn(BlockState placedOnState) { protected boolean operatesOn(LevelReader world, BlockPos pos, BlockState placedOnState) {
if (AllBlocks.BELT.has(placedOnState)) if (AllBlocks.BELT.has(placedOnState))
return placedOnState.getValue(BeltBlock.SLOPE) == BeltSlope.HORIZONTAL; return placedOnState.getValue(BeltBlock.SLOPE) == BeltSlope.HORIZONTAL;
return AllBlocks.BASIN.has(placedOnState) || AllBlocks.DEPOT.has(placedOnState) || AllBlocks.WEIGHTED_EJECTOR.has(placedOnState); return BasinBlock.isBasin(world, pos) || AllBlocks.DEPOT.has(placedOnState) || AllBlocks.WEIGHTED_EJECTOR.has(placedOnState);
} }
} }

View file

@ -1,7 +1,6 @@
package com.simibubi.create.content.processing.basin; package com.simibubi.create.content.processing.basin;
import com.simibubi.create.AllBlockEntityTypes; import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllShapes; import com.simibubi.create.AllShapes;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.content.equipment.wrench.IWrenchable; import com.simibubi.create.content.equipment.wrench.IWrenchable;
@ -62,6 +61,10 @@ public class BasinBlock extends Block implements IBE<BasinBlockEntity>, IWrencha
protected void createBlockStateDefinition(Builder<Block, BlockState> p_206840_1_) { protected void createBlockStateDefinition(Builder<Block, BlockState> p_206840_1_) {
super.createBlockStateDefinition(p_206840_1_.add(FACING)); super.createBlockStateDefinition(p_206840_1_.add(FACING));
} }
public static boolean isBasin(LevelReader world, BlockPos pos) {
return world.getBlockEntity(pos) instanceof BasinBlockEntity;
}
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
@ -127,7 +130,8 @@ public class BasinBlock extends Block implements IBE<BasinBlockEntity>, IWrencha
@Override @Override
public void updateEntityAfterFallOn(BlockGetter worldIn, Entity entityIn) { public void updateEntityAfterFallOn(BlockGetter worldIn, Entity entityIn) {
super.updateEntityAfterFallOn(worldIn, entityIn); super.updateEntityAfterFallOn(worldIn, entityIn);
if (!AllBlocks.BASIN.has(worldIn.getBlockState(entityIn.blockPosition()))) if (!worldIn.getBlockState(entityIn.blockPosition())
.is(this))
return; return;
if (!(entityIn instanceof ItemEntity)) if (!(entityIn instanceof ItemEntity))
return; return;

View file

@ -3,10 +3,10 @@ package com.simibubi.create.content.processing.burner;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.AllTags.AllItemTags; import com.simibubi.create.AllTags.AllItemTags;
import com.simibubi.create.content.fluids.tank.FluidTankBlock; 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.content.processing.burner.BlazeBurnerBlock.HeatLevel;
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity; import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
@ -269,7 +269,7 @@ public class BlazeBurnerBlockEntity extends SmartBlockEntity {
if (isVirtual()) if (isVirtual())
return false; return false;
BlockState blockState = level.getBlockState(worldPosition.above()); 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() { protected void playSound() {