From 98466017fed8bb5e9e7cfba00d3673e15dcd0661 Mon Sep 17 00:00:00 2001 From: izofar Date: Wed, 27 Sep 2023 10:12:43 -0500 Subject: [PATCH] v1.3.2 (v) - Fixed server crashing due to client-side class being loaded server-side --- .../bygonenether/client/BygoneNetherClient.java | 3 +-- .../client/renderer/ModShieldRenderer.java | 7 +++++++ .../com/izofar/bygonenether/item/ModShieldItem.java | 11 ----------- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/izofar/bygonenether/client/BygoneNetherClient.java b/src/main/java/com/izofar/bygonenether/client/BygoneNetherClient.java index 666539b..929bd20 100644 --- a/src/main/java/com/izofar/bygonenether/client/BygoneNetherClient.java +++ b/src/main/java/com/izofar/bygonenether/client/BygoneNetherClient.java @@ -7,7 +7,6 @@ import com.izofar.bygonenether.client.model.WitherSkeletonKnightModel; import com.izofar.bygonenether.client.renderer.*; import com.izofar.bygonenether.init.ModEntityTypes; -import com.izofar.bygonenether.item.ModShieldItem; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -46,7 +45,7 @@ public void onInitializeClient() { EntityModelLayerRegistry.registerModelLayer(CORPOR, CorporModel::createBodyLayer); EntityModelLayerRegistry.registerModelLayer(WITHER_SKELETON_KNIGHT, WitherSkeletonKnightModel::createBodyLayer); - ModShieldItem.addShieldPropertyOverrides(); + ModShieldRenderer.addShieldPropertyOverrides(); ModShieldRenderer.stitchTextureModelLayer(); } } diff --git a/src/main/java/com/izofar/bygonenether/client/renderer/ModShieldRenderer.java b/src/main/java/com/izofar/bygonenether/client/renderer/ModShieldRenderer.java index 86d1982..ab8a572 100644 --- a/src/main/java/com/izofar/bygonenether/client/renderer/ModShieldRenderer.java +++ b/src/main/java/com/izofar/bygonenether/client/renderer/ModShieldRenderer.java @@ -15,6 +15,8 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BannerRenderer; import net.minecraft.client.renderer.entity.ItemRenderer; +import net.minecraft.client.renderer.item.ClampedItemPropertyFunction; +import net.minecraft.client.renderer.item.ItemProperties; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.resources.model.Material; import net.minecraft.client.resources.model.ModelBakery; @@ -35,6 +37,8 @@ public class ModShieldRenderer { private static ShieldModel shieldModel; + private static final ClampedItemPropertyFunction isBlocking = (stack, world, entity, seed) -> entity != null && entity.isUsingItem() && entity.getUseItem() == stack ? 1.0F : 0.0F; + private static final ResourceLocation GILDED_NETHERITE_SHIELD_BASE_LOCATION = new ResourceLocation(BygoneNetherMod.MODID, "entity/shield/gilded_netherite_shield_base"); private static final ResourceLocation GILDED_NETHERITE_SHIELD_BASE_NOPATTERN_LOCATION = new ResourceLocation(BygoneNetherMod.MODID, "entity/shield/gilded_netherite_shield_base_nopattern"); @@ -74,4 +78,7 @@ public static void renderByItem(ItemStack stack, PoseStack poseStack, MultiBuffe poseStack.popPose(); } + public static void addShieldPropertyOverrides() { + ItemProperties.register(ModItems.GILDED_NETHERITE_SHIELD, new ResourceLocation(BygoneNetherMod.MODID, "blocking"), isBlocking); + } } diff --git a/src/main/java/com/izofar/bygonenether/item/ModShieldItem.java b/src/main/java/com/izofar/bygonenether/item/ModShieldItem.java index e6a25a8..513dece 100644 --- a/src/main/java/com/izofar/bygonenether/item/ModShieldItem.java +++ b/src/main/java/com/izofar/bygonenether/item/ModShieldItem.java @@ -1,25 +1,14 @@ package com.izofar.bygonenether.item; -import com.izofar.bygonenether.BygoneNetherMod; -import com.izofar.bygonenether.init.ModItems; -import net.minecraft.client.renderer.item.ClampedItemPropertyFunction; -import net.minecraft.client.renderer.item.ItemProperties; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ShieldItem; public class ModShieldItem extends ShieldItem { - private static final ClampedItemPropertyFunction isBlocking = (stack, world, entity, seed) -> entity != null && entity.isUsingItem() && entity.getUseItem() == stack ? 1.0F : 0.0F; - public ModShieldItem(Properties properties) { super(properties); } - public static void addShieldPropertyOverrides() { - ItemProperties.register(ModItems.GILDED_NETHERITE_SHIELD, new ResourceLocation(BygoneNetherMod.MODID, "blocking"), isBlocking); - } - @Override public boolean isValidRepairItem(ItemStack stack, ItemStack repairCandidate) { return false;