Sunday's bugs

- Fixed Girder Encased Shafts getting ignored by the Schematicannon
- Fixed Belts not offering a valid item handler until their first tick
- NPE Guard in Funnel-Arm interaction
This commit is contained in:
simibubi 2023-01-15 13:18:43 +01:00
parent f07574bff1
commit 405b7cbc36
3 changed files with 18 additions and 5 deletions

View file

@ -183,6 +183,8 @@ public class BeltTileEntity extends KineticTileEntity {
@Override
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {
if (!isRemoved() && !itemHandler.isPresent())
initializeItemHandler();
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
if (side == Direction.UP || BeltBlock.canAccessFromSide(side, getBlockState())) {
return itemHandler.cast();

View file

@ -8,6 +8,8 @@ import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.HorizontalAxisKineticBlock;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
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 net.minecraft.core.BlockPos;
@ -22,6 +24,7 @@ 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.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;
@ -34,7 +37,7 @@ import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
public class GirderEncasedShaftBlock extends HorizontalAxisKineticBlock
implements ITE<KineticTileEntity>, SimpleWaterloggedBlock, IWrenchable {
implements ITE<KineticTileEntity>, SimpleWaterloggedBlock, IWrenchable, ISpecialBlockItemRequirement {
public static final BooleanProperty TOP = GirderBlock.TOP;
public static final BooleanProperty BOTTOM = GirderBlock.BOTTOM;
@ -123,4 +126,10 @@ public class GirderEncasedShaftBlock extends HorizontalAxisKineticBlock
return state.setValue(WATERLOGGED, Boolean.valueOf(ifluidstate.getType() == Fluids.WATER));
}
@Override
public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) {
return ItemRequirement.of(AllBlocks.SHAFT.getDefaultState(), te)
.union(ItemRequirement.of(AllBlocks.METAL_GIRDER.getDefaultState(), te));
}
}

View file

@ -34,6 +34,7 @@ import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Containers;
import net.minecraft.world.InteractionResultHolder;
@ -501,16 +502,17 @@ public class AllArmInteractionPointTypes {
@Override
protected Vec3 getInteractionPositionVector() {
Direction funnelFacing = FunnelBlock.getFunnelFacing(cachedState);
Vec3i normal = funnelFacing != null ? funnelFacing.getNormal() : Vec3i.ZERO;
return VecHelper.getCenterOf(pos)
.add(Vec3.atLowerCornerOf(FunnelBlock.getFunnelFacing(cachedState)
.getNormal())
.add(Vec3.atLowerCornerOf(normal)
.scale(-.15f));
}
@Override
protected Direction getInteractionDirection() {
return FunnelBlock.getFunnelFacing(cachedState)
.getOpposite();
Direction funnelFacing = FunnelBlock.getFunnelFacing(cachedState);
return funnelFacing != null ? funnelFacing.getOpposite() : Direction.UP;
}
@Override