Kaynağa Gözat

为铁砧添加 material BlockState

LTCatt 6 yıl önce
ebeveyn
işleme
17003dab26

+ 9 - 0
src/main/java/com/hexdragon/enchrebirth/mixin/block/AnvilBlockMixin.java

@@ -1,10 +1,12 @@
 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 com.hexdragon.enchrebirth.registry.RegMain;
 import net.minecraft.block.*;
 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.state.DirectionProperty;
+import net.minecraft.state.StateContainer;
 import net.minecraft.tileentity.TileEntity;
 import net.minecraft.tileentity.TileEntity;
 import net.minecraft.util.Direction;
 import net.minecraft.util.Direction;
 import net.minecraft.util.math.BlockPos;
 import net.minecraft.util.math.BlockPos;
@@ -18,6 +20,7 @@ import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.Shadow;
 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.CallbackInfo;
 import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
 import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
 import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
 import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
 
 
@@ -73,4 +76,10 @@ public abstract class AnvilBlockMixin extends FallingBlock implements IForgeBloc
         cir.cancel();
         cir.cancel();
     }
     }
 
 
+    // 添加 MATERIAL BlockState
+    @Inject(method = "fillStateContainer", at = @At(value = "HEAD"), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
+    protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder, CallbackInfo cir) {
+        builder.add(RegMain.MATERIAL);
+    }
+
 }
 }

+ 2 - 4
src/main/java/com/hexdragon/enchrebirth/registry/RegClient.java

@@ -15,15 +15,13 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
 @Mod.EventBusSubscriber(modid = Main.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) @OnlyIn(Dist.CLIENT)
 @Mod.EventBusSubscriber(modid = Main.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) @OnlyIn(Dist.CLIENT)
 public class RegClient {
 public class RegClient {
 
 
-    @SubscribeEvent
-    public static void clientSetup(final FMLClientSetupEvent e) {
+    @SubscribeEvent public static void clientSetup(final FMLClientSetupEvent e) {
         // 注册 Screen
         // 注册 Screen
         ScreenManager.registerFactory(RegMain.containerGrindstone.get(), GrindstoneScreenRe::new);
         ScreenManager.registerFactory(RegMain.containerGrindstone.get(), GrindstoneScreenRe::new);
         ScreenManager.registerFactory(RegMain.containerAnvil.get(), AnvilScreenRe::new);
         ScreenManager.registerFactory(RegMain.containerAnvil.get(), AnvilScreenRe::new);
     }
     }
 
 
-    @SubscribeEvent
-    public static void onClientEvent(FMLClientSetupEvent event) {
+    @SubscribeEvent public static void onClientEvent(FMLClientSetupEvent event) {
         // 注册 Renderer
         // 注册 Renderer
         ClientRegistry.bindTileEntityRenderer(RegMain.tileEntityPerfectAnvil.get(), (AnvilRenderer::new));
         ClientRegistry.bindTileEntityRenderer(RegMain.tileEntityPerfectAnvil.get(), (AnvilRenderer::new));
         ClientRegistry.bindTileEntityRenderer(RegMain.tileEntityChippedAnvil.get(), (AnvilRenderer::new));
         ClientRegistry.bindTileEntityRenderer(RegMain.tileEntityChippedAnvil.get(), (AnvilRenderer::new));

+ 5 - 1
src/main/java/com/hexdragon/enchrebirth/registry/RegMain.java

@@ -8,6 +8,7 @@ import net.minecraft.block.Blocks;
 import net.minecraft.entity.player.PlayerInventory;
 import net.minecraft.entity.player.PlayerInventory;
 import net.minecraft.inventory.container.ContainerType;
 import net.minecraft.inventory.container.ContainerType;
 import net.minecraft.network.PacketBuffer;
 import net.minecraft.network.PacketBuffer;
+import net.minecraft.state.IntegerProperty;
 import net.minecraft.tileentity.TileEntityType;
 import net.minecraft.tileentity.TileEntityType;
 import net.minecraftforge.common.extensions.IForgeContainerType;
 import net.minecraftforge.common.extensions.IForgeContainerType;
 import net.minecraftforge.fml.RegistryObject;
 import net.minecraftforge.fml.RegistryObject;
@@ -16,7 +17,7 @@ import net.minecraftforge.registries.ForgeRegistries;
 
 
 public class RegMain {
 public class RegMain {
 
 
-    // 容器
+    // Container
     public static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, Main.MODID);
     public static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, Main.MODID);
     public static final RegistryObject<ContainerType<GrindstoneContainerRe>> containerGrindstone = CONTAINERS.register("grindstone", () -> IForgeContainerType.create((int windowId, PlayerInventory inv, PacketBuffer data) -> new GrindstoneContainerRe(windowId, inv)));
     public static final RegistryObject<ContainerType<GrindstoneContainerRe>> containerGrindstone = CONTAINERS.register("grindstone", () -> IForgeContainerType.create((int windowId, PlayerInventory inv, PacketBuffer data) -> new GrindstoneContainerRe(windowId, inv)));
     public static final RegistryObject<ContainerType<AnvilContainerRe>> containerAnvil = CONTAINERS.register("anvil", () -> IForgeContainerType.create((int windowId, PlayerInventory inv, PacketBuffer data) -> new AnvilContainerRe(windowId, inv)));
     public static final RegistryObject<ContainerType<AnvilContainerRe>> containerAnvil = CONTAINERS.register("anvil", () -> IForgeContainerType.create((int windowId, PlayerInventory inv, PacketBuffer data) -> new AnvilContainerRe(windowId, inv)));
@@ -27,4 +28,7 @@ public class RegMain {
     public static RegistryObject<TileEntityType<AnvilTileEntity.ChippedAnvilTileEntity>> tileEntityChippedAnvil = TILE_ENTITIES.register("chipped_anvil_tileentity", () -> TileEntityType.Builder.create(AnvilTileEntity.ChippedAnvilTileEntity::new, Blocks.CHIPPED_ANVIL).build(null));
     public static RegistryObject<TileEntityType<AnvilTileEntity.ChippedAnvilTileEntity>> tileEntityChippedAnvil = TILE_ENTITIES.register("chipped_anvil_tileentity", () -> TileEntityType.Builder.create(AnvilTileEntity.ChippedAnvilTileEntity::new, Blocks.CHIPPED_ANVIL).build(null));
     public static RegistryObject<TileEntityType<AnvilTileEntity.DamagedAnvilTileEntity>> tileEntityDamagedAnvil = TILE_ENTITIES.register("damaged_anvil_tileentity", () -> TileEntityType.Builder.create(AnvilTileEntity.DamagedAnvilTileEntity::new, Blocks.DAMAGED_ANVIL).build(null));
     public static RegistryObject<TileEntityType<AnvilTileEntity.DamagedAnvilTileEntity>> tileEntityDamagedAnvil = TILE_ENTITIES.register("damaged_anvil_tileentity", () -> TileEntityType.Builder.create(AnvilTileEntity.DamagedAnvilTileEntity::new, Blocks.DAMAGED_ANVIL).build(null));
 
 
+    // BlockState
+    public static final IntegerProperty MATERIAL = IntegerProperty.create("material", 0, 1);
+
 }
 }

+ 6 - 0
src/main/resources/assets/enchrebirth/models/block/netherite_anvil.json

@@ -0,0 +1,6 @@
+{
+  "parent": "enchrebirth:block/template_netherite_anvil",
+  "textures": {
+    "top": "enchrebirth:block/netherite_anvil_top"
+  }
+}

+ 6 - 0
src/main/resources/assets/enchrebirth/models/block/netherite_chipped_anvil.json

@@ -0,0 +1,6 @@
+{
+  "parent": "enchrebirth:block/template_netherite_anvil",
+  "textures": {
+    "top": "enchrebirth:block/netherite_chipped_anvil_top"
+  }
+}

+ 6 - 0
src/main/resources/assets/enchrebirth/models/block/netherite_damaged_anvil.json

@@ -0,0 +1,6 @@
+{
+  "parent": "enchrebirth:block/template_netherite_anvil",
+  "textures": {
+    "top": "enchrebirth:block/netherite_damaged_anvil_top"
+  }
+}

+ 291 - 0
src/main/resources/assets/enchrebirth/models/block/template_netherite_anvil.json

@@ -0,0 +1,291 @@
+{
+  "parent": "block/block",
+  "textures": {
+    "particle": "enchrebirth:block/netherite_anvil",
+    "body": "enchrebirth:block/netherite_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
+        }
+      }
+    }
+  ]
+}

BIN
src/main/resources/assets/enchrebirth/textures/block/netherite_anvil.png


BIN
src/main/resources/assets/enchrebirth/textures/block/netherite_anvil_top.png


BIN
src/main/resources/assets/enchrebirth/textures/block/netherite_chipped_anvil_top.png


BIN
src/main/resources/assets/enchrebirth/textures/block/netherite_damaged_anvil_top.png


+ 34 - 0
src/main/resources/assets/minecraft/blockstates/anvil.json

@@ -0,0 +1,34 @@
+{
+  "variants": {
+    "facing=east,material=0": {
+      "model": "minecraft:block/anvil",
+      "y": 270
+    },
+    "facing=north,material=0": {
+      "model": "minecraft:block/anvil",
+      "y": 180
+    },
+    "facing=south,material=0": {
+      "model": "minecraft:block/anvil"
+    },
+    "facing=west,material=0": {
+      "model": "minecraft:block/anvil",
+      "y": 90
+    },
+    "facing=east,material=1": {
+      "model": "enchrebirth:block/netherite_anvil",
+      "y": 270
+    },
+    "facing=north,material=1": {
+      "model": "enchrebirth:block/netherite_anvil",
+      "y": 180
+    },
+    "facing=south,material=1": {
+      "model": "enchrebirth:block/netherite_anvil"
+    },
+    "facing=west,material=1": {
+      "model": "enchrebirth:block/netherite_anvil",
+      "y": 90
+    }
+  }
+}

+ 34 - 0
src/main/resources/assets/minecraft/blockstates/chipped_anvil.json

@@ -0,0 +1,34 @@
+{
+  "variants": {
+    "facing=east,material=0": {
+      "model": "minecraft:block/chipped_anvil",
+      "y": 270
+    },
+    "facing=north,material=0": {
+      "model": "minecraft:block/chipped_anvil",
+      "y": 180
+    },
+    "facing=south,material=0": {
+      "model": "minecraft:block/chipped_anvil"
+    },
+    "facing=west,material=0": {
+      "model": "minecraft:block/chipped_anvil",
+      "y": 90
+    },
+    "facing=east,material=1": {
+      "model": "enchrebirth:block/netherite_chipped_anvil",
+      "y": 270
+    },
+    "facing=north,material=1": {
+      "model": "enchrebirth:block/netherite_chipped_anvil",
+      "y": 180
+    },
+    "facing=south,material=1": {
+      "model": "enchrebirth:block/netherite_chipped_anvil"
+    },
+    "facing=west,material=1": {
+      "model": "enchrebirth:block/netherite_chipped_anvil",
+      "y": 90
+    }
+  }
+}

+ 34 - 0
src/main/resources/assets/minecraft/blockstates/damaged_anvil.json

@@ -0,0 +1,34 @@
+{
+  "variants": {
+    "facing=east,material=0": {
+      "model": "minecraft:block/damaged_anvil",
+      "y": 270
+    },
+    "facing=north,material=0": {
+      "model": "minecraft:block/damaged_anvil",
+      "y": 180
+    },
+    "facing=south,material=0": {
+      "model": "minecraft:block/damaged_anvil"
+    },
+    "facing=west,material=0": {
+      "model": "minecraft:block/damaged_anvil",
+      "y": 90
+    },
+    "facing=east,material=1": {
+      "model": "enchrebirth:block/netherite_damaged_anvil",
+      "y": 270
+    },
+    "facing=north,material=1": {
+      "model": "enchrebirth:block/netherite_damaged_anvil",
+      "y": 180
+    },
+    "facing=south,material=1": {
+      "model": "enchrebirth:block/netherite_damaged_anvil"
+    },
+    "facing=west,material=1": {
+      "model": "enchrebirth:block/netherite_damaged_anvil",
+      "y": 90
+    }
+  }
+}