Parcourir la source

将铁砧的高度降低了 1 像素

LTCatt il y a 6 ans
Parent
commit
f9cfdf133d

+ 2 - 2
src/main/java/com/hexdragon/enchrebirth/block/anvil/AnvilRenderer.java

@@ -24,7 +24,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
         ItemStack stackLeft = tileEntityIn.getStackInSlot(0);
         if (!stackLeft.isEmpty()) {
             matrixStackIn.push();
-            matrixStackIn.translate(0.7, 1.01, 0.52);
+            matrixStackIn.translate(0.7, 0.95, 0.53);
             matrixStackIn.rotate(Vector3f.XP.rotationDegrees(90.0F));
             matrixStackIn.rotate(Vector3f.ZN.rotationDegrees(5.0F));
             matrixStackIn.scale(0.375F, 0.375F, 0.375F);
@@ -37,7 +37,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
         ItemStack stackRight = tileEntityIn.getStackInSlot(1);
         if (!stackRight.isEmpty()) {
             matrixStackIn.push();
-            matrixStackIn.translate(0.27, 1.01, 0.45);
+            matrixStackIn.translate(0.27, 0.95, 0.44);
             matrixStackIn.rotate(Vector3f.XP.rotationDegrees(90.0F));
             matrixStackIn.rotate(Vector3f.ZP.rotationDegrees(15.0F));
             matrixStackIn.scale(0.375F, 0.375F, 0.375F);

+ 24 - 4
src/main/java/com/hexdragon/enchrebirth/mixin/block/AnvilBlockMixin.java

@@ -1,18 +1,21 @@
 package com.hexdragon.enchrebirth.mixin.block;
 
 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.container.INamedContainerProvider;
+import net.minecraft.state.DirectionProperty;
 import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.Direction;
 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.World;
 import net.minecraftforge.common.extensions.IForgeBlock;
 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.Inject;
 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();
+    }
+
 }

+ 1 - 1
src/main/resources/assets/enchrebirth/lang/zh_CN.json

@@ -1,4 +1,4 @@
 {
   "container.grindstone.title": "去除附魔",
-  "container.anvil.title": "修复工具"
+  "container.anvil.title": "修复物品"
 }

+ 291 - 0
src/main/resources/assets/minecraft/models/block/template_anvil.json

@@ -0,0 +1,291 @@
+{
+  "parent": "block/block",
+  "textures": {
+    "particle": "block/anvil",
+    "body": "block/anvil"
+  },
+  "display": {
+    "fixed": {
+      "rotation": [
+        0,
+        90,
+        0
+      ],
+      "translation": [
+        0,
+        0,
+        0
+      ],
+      "scale": [
+        0.5,
+        0.5,
+        0.5
+      ]
+    }
+  },
+  "elements": [
+    {
+      "__comment": "Anvil base",
+      "from": [
+        2,
+        0,
+        2
+      ],
+      "to": [
+        14,
+        4,
+        14
+      ],
+      "faces": {
+        "down": {
+          "uv": [
+            2,
+            2,
+            14,
+            14
+          ],
+          "texture": "#body",
+          "rotation": 180,
+          "cullface": "down"
+        },
+        "up": {
+          "uv": [
+            2,
+            2,
+            14,
+            14
+          ],
+          "texture": "#body",
+          "rotation": 180
+        },
+        "north": {
+          "uv": [
+            2,
+            12,
+            14,
+            16
+          ],
+          "texture": "#body"
+        },
+        "south": {
+          "uv": [
+            2,
+            12,
+            14,
+            16
+          ],
+          "texture": "#body"
+        },
+        "west": {
+          "uv": [
+            0,
+            2,
+            4,
+            14
+          ],
+          "texture": "#body",
+          "rotation": 90
+        },
+        "east": {
+          "uv": [
+            4,
+            2,
+            0,
+            14
+          ],
+          "texture": "#body",
+          "rotation": 270
+        }
+      }
+    },
+    {
+      "__comment": "Lower narrow portion",
+      "from": [
+        4,
+        4,
+        3
+      ],
+      "to": [
+        12,
+        5,
+        13
+      ],
+      "faces": {
+        "up": {
+          "uv": [
+            4,
+            3,
+            12,
+            13
+          ],
+          "texture": "#body",
+          "rotation": 180
+        },
+        "north": {
+          "uv": [
+            4,
+            11,
+            12,
+            12
+          ],
+          "texture": "#body"
+        },
+        "south": {
+          "uv": [
+            4,
+            11,
+            12,
+            12
+          ],
+          "texture": "#body"
+        },
+        "west": {
+          "uv": [
+            4,
+            3,
+            5,
+            13
+          ],
+          "texture": "#body",
+          "rotation": 90
+        },
+        "east": {
+          "uv": [
+            5,
+            3,
+            4,
+            13
+          ],
+          "texture": "#body",
+          "rotation": 270
+        }
+      }
+    },
+    {
+      "__comment": "Wider section beneath top portion",
+      "from": [
+        6,
+        5,
+        4
+      ],
+      "to": [
+        10,
+        10,
+        12
+      ],
+      "faces": {
+        "north": {
+          "uv": [
+            6,
+            6,
+            10,
+            11
+          ],
+          "texture": "#body"
+        },
+        "south": {
+          "uv": [
+            6,
+            6,
+            10,
+            11
+          ],
+          "texture": "#body"
+        },
+        "west": {
+          "uv": [
+            5,
+            4,
+            10,
+            12
+          ],
+          "texture": "#body",
+          "rotation": 90
+        },
+        "east": {
+          "uv": [
+            10,
+            4,
+            5,
+            12
+          ],
+          "texture": "#body",
+          "rotation": 270
+        }
+      }
+    },
+    {
+      "__comment": "Anvil top",
+      "from": [
+        3,
+        10,
+        0
+      ],
+      "to": [
+        13,
+        15,
+        16
+      ],
+      "faces": {
+        "down": {
+          "uv": [
+            3,
+            0,
+            13,
+            16
+          ],
+          "texture": "#body",
+          "rotation": 180
+        },
+        "up": {
+          "uv": [
+            3,
+            0,
+            13,
+            16
+          ],
+          "texture": "#top",
+          "rotation": 180
+        },
+        "north": {
+          "uv": [
+            3,
+            0,
+            13,
+            5
+          ],
+          "texture": "#body"
+        },
+        "south": {
+          "uv": [
+            3,
+            0,
+            13,
+            5
+          ],
+          "texture": "#body"
+        },
+        "west": {
+          "uv": [
+            10,
+            0,
+            16,
+            16
+          ],
+          "texture": "#body",
+          "rotation": 90
+        },
+        "east": {
+          "uv": [
+            16,
+            0,
+            10,
+            16
+          ],
+          "texture": "#body",
+          "rotation": 270
+        }
+      }
+    }
+  ]
+}