Skip to content

Commit

Permalink
v1.3.2 (v)
Browse files Browse the repository at this point in the history
- Fixed server crashing due to client-side class being loaded server-side
  • Loading branch information
izofar committed Sep 27, 2023
1 parent 844f57a commit 9846601
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");

Expand Down Expand Up @@ -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);
}
}
11 changes: 0 additions & 11 deletions src/main/java/com/izofar/bygonenether/item/ModShieldItem.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 9846601

Please sign in to comment.