|
@@ -1,18 +1,21 @@
|
|
|
package com.hexdragon.enchrebirth.mixin.block;
|
|
package com.hexdragon.enchrebirth.mixin.block;
|
|
|
|
|
|
|
|
import com.hexdragon.enchrebirth.block.anvil.AnvilTileEntity;
|
|
import com.hexdragon.enchrebirth.block.anvil.AnvilTileEntity;
|
|
|
-import net.minecraft.block.AnvilBlock;
|
|
|
|
|
-import net.minecraft.block.BlockState;
|
|
|
|
|
-import net.minecraft.block.Blocks;
|
|
|
|
|
-import net.minecraft.block.FallingBlock;
|
|
|
|
|
|
|
+import net.minecraft.block.*;
|
|
|
import net.minecraft.inventory.InventoryHelper;
|
|
import net.minecraft.inventory.InventoryHelper;
|
|
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
|
|
|
|
+import net.minecraft.state.DirectionProperty;
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
|
+import net.minecraft.util.Direction;
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
|
+import net.minecraft.util.math.shapes.ISelectionContext;
|
|
|
|
|
+import net.minecraft.util.math.shapes.VoxelShape;
|
|
|
|
|
+import net.minecraft.util.math.shapes.VoxelShapes;
|
|
|
import net.minecraft.world.IBlockReader;
|
|
import net.minecraft.world.IBlockReader;
|
|
|
import net.minecraft.world.World;
|
|
import net.minecraft.world.World;
|
|
|
import net.minecraftforge.common.extensions.IForgeBlock;
|
|
import net.minecraftforge.common.extensions.IForgeBlock;
|
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
|
|
|
+import org.spongepowered.asm.mixin.Shadow;
|
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
|
import org.spongepowered.asm.mixin.injection.Inject;
|
|
import org.spongepowered.asm.mixin.injection.Inject;
|
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
@@ -53,4 +56,21 @@ public abstract class AnvilBlockMixin extends FallingBlock implements IForgeBloc
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 将铁砧的碰撞箱降低 1 像素
|
|
|
|
|
+ @Shadow public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
|
|
|
|
|
+ private static final VoxelShape PART_BASE = Block.makeCuboidShape(2.0D, 0.0D, 2.0D, 14.0D, 4.0D, 14.0D);
|
|
|
|
|
+ private static final VoxelShape PART_LOWER_X = Block.makeCuboidShape(3.0D, 4.0D, 4.0D, 13.0D, 5.0D, 12.0D);
|
|
|
|
|
+ private static final VoxelShape PART_MID_X = Block.makeCuboidShape(4.0D, 5.0D, 6.0D, 12.0D, 10.0D, 10.0D);
|
|
|
|
|
+ private static final VoxelShape PART_UPPER_X = Block.makeCuboidShape(0.0D, 10.0D, 3.0D, 16.0D, 15.0D, 13.0D);
|
|
|
|
|
+ private static final VoxelShape PART_LOWER_Z = Block.makeCuboidShape(4.0D, 4.0D, 3.0D, 12.0D, 5.0D, 13.0D);
|
|
|
|
|
+ private static final VoxelShape PART_MID_Z = Block.makeCuboidShape(6.0D, 5.0D, 4.0D, 10.0D, 10.0D, 12.0D);
|
|
|
|
|
+ private static final VoxelShape PART_UPPER_Z = Block.makeCuboidShape(3.0D, 10.0D, 0.0D, 13.0D, 15.0D, 16.0D);
|
|
|
|
|
+ private static final VoxelShape X_AXIS_AABB = VoxelShapes.or(PART_BASE, PART_LOWER_X, PART_MID_X, PART_UPPER_X);
|
|
|
|
|
+ private static final VoxelShape Z_AXIS_AABB = VoxelShapes.or(PART_BASE, PART_LOWER_Z, PART_MID_Z, PART_UPPER_Z);
|
|
|
|
|
+ @Inject(method = "getShape", at = @At(value = "HEAD"), cancellable = true, locals = LocalCapture.CAPTURE_FAILEXCEPTION)
|
|
|
|
|
+ private void getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
|
|
|
|
+ cir.setReturnValue(state.get(FACING).getAxis() == Direction.Axis.X ? X_AXIS_AABB : Z_AXIS_AABB);
|
|
|
|
|
+ cir.cancel();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|