Skip to content

Commit

Permalink
more work on trident
Browse files Browse the repository at this point in the history
  • Loading branch information
RealYusufIsmail committed Jun 18, 2024
1 parent f2812e5 commit 28de1a4
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 304 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.realyusufismail.tutorialmod;

import io.github.realyusufismail.tutorialmod.client.TutorialModShieldItemRendererProvider;
import io.github.realyusufismail.tutorialmod.client.shield.TutorialModShieldItemRendererProvider;
import io.github.realyusufismail.tutorialmod.data.DataGenerators;
import io.github.realyusufismail.tutorialmod.events.Events;
import io.github.realyusufismail.tutorialmod.init.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package io.github.realyusufismail.tutorialmod.client.render;
package io.github.realyusufismail.tutorialmod.client.render.shield;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import io.github.realyusufismail.tutorialmod.TutorialMod;
import io.github.realyusufismail.tutorialmod.client.render.ModBlockEntityWithoutLevelRenderer;
import io.github.realyusufismail.tutorialmod.init.ItemInit;
import io.github.realyusufismail.tutorialmod.items.ModShieldItem;
import io.github.realyusufismail.tutorialmod.material.ShieldMaterial;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package io.github.realyusufismail.tutorialmod.client.render.trident;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis;
import io.github.realyusufismail.tutorialmod.TutorialMod;
import net.minecraft.client.model.TridentModel;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.projectile.ThrownTrident;
import org.jetbrains.annotations.NotNull;

public class TutorialModTridentItemRenderer extends EntityRenderer<ThrownTrident> {

private final TridentModel tridentModel;

public TutorialModTridentItemRenderer(EntityRendererProvider.Context context) {
super(context);
tridentModel = new TridentModel(context.bakeLayer(ModelLayers.TRIDENT));
}

@Override
public void render(ThrownTrident pEntity, float pEntityYaw, float pPartialTick, PoseStack pPoseStack, MultiBufferSource pBuffer, int pPackedLight) {
pPoseStack.pushPose();
pPoseStack.mulPose(
Axis.YP.rotationDegrees(Mth.lerp(pPartialTick, pEntity.yRotO, pEntity.getYRot()) - 90.0f));
pPoseStack.mulPose(
Axis.ZP.rotationDegrees(Mth.lerp(pPartialTick, pEntity.xRotO, pEntity.getYRot()) + 90.0f));
VertexConsumer vertexConsumer =
ItemRenderer.getFoilBufferDirect(
pBuffer,
tridentModel.renderType(getTextureLocation(pEntity)),
false,
pEntity.isFoil());
tridentModel.renderToBuffer(pPoseStack, vertexConsumer, pPackedLight, OverlayTexture.NO_OVERLAY);
pPoseStack.popPose();
super.render(pEntity, pEntityYaw, pPartialTick, pPoseStack, pBuffer, pPackedLight);
}

@Override
public @NotNull ResourceLocation getTextureLocation(ThrownTrident pEntity) {
return ResourceLocation.fromNamespaceAndPath(TutorialMod.MOD_ID, "entity/trident/example_trident");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.realyusufismail.tutorialmod.client;
package io.github.realyusufismail.tutorialmod.client.shield;

import io.github.realyusufismail.tutorialmod.client.render.TutorialModShieldItemRenderer;
import io.github.realyusufismail.tutorialmod.client.render.shield.TutorialModShieldItemRenderer;
import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent;
import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.github.realyusufismail.tutorialmod.client.trident;

import com.mojang.blaze3d.vertex.PoseStack;
import io.github.realyusufismail.tutorialmod.TutorialMod;
import io.github.realyusufismail.tutorialmod.client.render.ModBlockEntityWithoutLevelRenderer;
import io.github.realyusufismail.tutorialmod.init.ItemInit;
import net.minecraft.client.model.TridentModel;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;

public class TutorialModTridentRendererISTER extends ModBlockEntityWithoutLevelRenderer {

private TridentModel tridentModel;
private final ModelResourceLocation modelResourceLocation =
new ModelResourceLocation(ResourceLocation.fromNamespaceAndPath("tutorialmod", "example_trident"), "example_trident");
private final ResourceLocation textureLocation =
ResourceLocation.fromNamespaceAndPath(TutorialMod.MOD_ID, "entity/trident/example_trident");

@Override
public void onResourceManagerReload(ResourceManager pResourceManager) {
tridentModel = new TridentModel(this.entityModelSet.bakeLayer(ModelLayers.TRIDENT));
}

@Override
public void renderByItem(ItemStack pStack, ItemDisplayContext pDisplayContext, PoseStack pPoseStack, MultiBufferSource pBuffer, int pPackedLight, int pPackedOverlay) {

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.realyusufismail.tutorialmod.items;

import io.github.realyusufismail.tutorialmod.client.TutorialModShieldItemRendererProvider;
import io.github.realyusufismail.tutorialmod.client.shield.TutorialModShieldItemRendererProvider;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ShieldItem;
import net.minecraft.world.item.Tier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ public class ShieldMaterial {
public static final Material SHIELD_BASE_GRAPHITE_NO_PATTERN = new Material(
net.minecraft.client.renderer.Sheets.SHIELD_SHEET,
ResourceLocation.fromNamespaceAndPath("tutorialmod", "entity/shield/shield_base_nopattern"));

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading

0 comments on commit 28de1a4

Please sign in to comment.