diff --git a/gradle.properties b/gradle.properties index 0b56e83..5a3b550 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx2G loader_version=0.9.1+build.205 # Mod Properties - mod_version = beta-1.9 + mod_version = beta-1.9.1 maven_group = com.oroarmor archives_base_name = netherite-plus-mod diff --git a/src/main/java/com/oroarmor/netherite_plus/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/com/oroarmor/netherite_plus/mixin/ClientPlayNetworkHandlerMixin.java index c258ec8..9caf9a3 100644 --- a/src/main/java/com/oroarmor/netherite_plus/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/com/oroarmor/netherite_plus/mixin/ClientPlayNetworkHandlerMixin.java @@ -1,5 +1,7 @@ package com.oroarmor.netherite_plus.mixin; +import java.util.Iterator; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -17,6 +19,7 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.projectile.PersistentProjectileEntity; import net.minecraft.entity.projectile.TridentEntity; +import net.minecraft.item.ItemStack; import net.minecraft.network.NetworkThreadUtils; import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket; import net.minecraft.util.thread.ThreadExecutor; @@ -46,8 +49,13 @@ public void onEntitySpawnMixin(EntitySpawnS2CPacket packet, CallbackInfo info) { entity16 = world.getEntityById(packet.getEntityData()); if (entity16 instanceof ClientPlayerEntity) { - if (((ClientPlayerEntity) entity16).getItemsHand().iterator().next() - .getItem() == NetheritePlusItems.NETHERITE_TRIDENT) { + + boolean hasNetheriteTrident = false; + Iterator items = ((ClientPlayerEntity) entity16).getItemsHand().iterator(); + while (items.hasNext()) { + hasNetheriteTrident |= items.next().getItem() == NetheritePlusItems.NETHERITE_TRIDENT; + } + if (hasNetheriteTrident) { entity15 = new NetheriteTridentEntity(world, d, e, f); } } diff --git a/src/main/java/com/oroarmor/netherite_plus/mixin/render/ItemRendererMixin.java b/src/main/java/com/oroarmor/netherite_plus/mixin/render/ItemRendererMixin.java index 40bb11c..efc34bd 100644 --- a/src/main/java/com/oroarmor/netherite_plus/mixin/render/ItemRendererMixin.java +++ b/src/main/java/com/oroarmor/netherite_plus/mixin/render/ItemRendererMixin.java @@ -1,23 +1,71 @@ package com.oroarmor.netherite_plus.mixin.render; 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.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import com.oroarmor.netherite_plus.item.NetheritePlusItems; import com.oroarmor.util.item.UniqueItemRegistry; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.RenderLayers; +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.item.BuiltinModelItemRenderer; +import net.minecraft.client.render.item.ItemModels; import net.minecraft.client.render.item.ItemRenderer; +import net.minecraft.client.render.model.BakedModel; +import net.minecraft.client.render.model.json.ModelTransformation; +import net.minecraft.client.util.ModelIdentifier; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @Mixin(ItemRenderer.class) -public class ItemRendererMixin { +public abstract class ItemRendererMixin { + + @Shadow + private ItemModels models; + + @Inject(method = "renderItem", at = @At(value = "HEAD"), cancellable = true) + public void renderItem(ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, + MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, + CallbackInfo info) { + if (!stack.isEmpty() && stack.getItem() == NetheritePlusItems.NETHERITE_TRIDENT) { + matrices.push(); + boolean bl = renderMode == ModelTransformation.Mode.GUI || renderMode == ModelTransformation.Mode.GROUND + || renderMode == ModelTransformation.Mode.FIXED; + if (stack.getItem() == NetheritePlusItems.NETHERITE_TRIDENT && bl) { + model = this.models.getModelManager() + .getModel(new ModelIdentifier("netherite_plus:netherite_trident#inventory")); + } + + model.getTransformation().getTransformation(renderMode).apply(leftHanded, matrices); + matrices.translate(-0.5D, -0.5D, -0.5D); + if (model.isBuiltin() || stack.getItem() == NetheritePlusItems.NETHERITE_TRIDENT && !bl) { + BuiltinModelItemRenderer.INSTANCE.render(stack, renderMode, matrices, vertexConsumers, light, overlay); + } else { + RenderLayer renderLayer = RenderLayers.getItemLayer(stack, true); + VertexConsumer vertexConsumer4; + vertexConsumer4 = ItemRenderer.getDirectGlintVertexConsumer(vertexConsumers, renderLayer, true, + stack.hasGlint()); + + this.renderBakedItemModel(model, stack, light, overlay, matrices, vertexConsumer4); + } + + matrices.pop(); + info.cancel(); + } - @Redirect(method = "renderItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getItem()Lnet/minecraft/item/Item;")) - public Item renderItem(ItemStack stack) { - return UniqueItemRegistry.TRIDENT.getDefaultItem(stack.getItem()); } + @Shadow + protected abstract void renderBakedItemModel(BakedModel model, ItemStack stack, int light, int overlay, + MatrixStack matrices, VertexConsumer vertexConsumer4); + @Redirect(method = "getHeldItemModel", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getItem()Lnet/minecraft/item/Item;")) public Item getHeldItemModel(ItemStack stack) { return UniqueItemRegistry.TRIDENT.getDefaultItem(stack.getItem()); diff --git a/src/main/resources/assets/netherite_plus/textures/item/netherite_trident.png b/src/main/resources/assets/netherite_plus/textures/item/netherite_trident.png index 4d4e064..a4c22d4 100644 Binary files a/src/main/resources/assets/netherite_plus/textures/item/netherite_trident.png and b/src/main/resources/assets/netherite_plus/textures/item/netherite_trident.png differ diff --git a/src/main/resources/assets/netherite_plus/textures/models/armor/copy/netherite_elytra_layer_1.png b/src/main/resources/assets/netherite_plus/textures/models/armor/copy/netherite_elytra_layer_1.png deleted file mode 100644 index 5a67fec..0000000 Binary files a/src/main/resources/assets/netherite_plus/textures/models/armor/copy/netherite_elytra_layer_1.png and /dev/null differ diff --git a/src/main/resources/assets/netherite_plus/textures/models/armor/copy/netherite_elytra_layer_2.png b/src/main/resources/assets/netherite_plus/textures/models/armor/copy/netherite_elytra_layer_2.png deleted file mode 100644 index 7dcdee0..0000000 Binary files a/src/main/resources/assets/netherite_plus/textures/models/armor/copy/netherite_elytra_layer_2.png and /dev/null differ