GeckoLib Addon is now an OPTIONAL Supported Addon [WIP]

This commit is contained in:
Kam committed 2024-01-22 20:32:03 -05:00
1 parent 5678029e30
commit 3c225f74db
20 files changed
+167 -476

No files matched your search

@@ -1,65 +0,0 @@
package noppes.npcs.client.renderer;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
import noppes.npcs.client.model.ModelCustom;
import noppes.npcs.entity.EntityCustomModel;
import org.lwjgl.opengl.GL11;
import software.bernie.geckolib3.geo.render.built.GeoBone;
import software.bernie.geckolib3.geo.render.built.GeoModel;
import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer;
import java.util.ArrayList;
public class RenderCustomModel extends GeoEntityRenderer<EntityCustomModel> {
public RenderCustomModel() {
super(new ModelCustom());
}
public void renderAfter(GeoModel model, EntityCustomModel animatable, float ticks, float red, float green, float blue, float alpha) {
super.renderAfter(model, animatable, ticks, red, green, blue, alpha);
if (model.getBone("held_item").isPresent() && animatable.getHeldItem() != null) {
GeoBone bone = model.getBone("held_item").get();
this.renderItem(animatable, bone, ticks);
}
}
public GeoBone[] getPathFromRoot(GeoBone bone) {
ArrayList bones;
for(bones = new ArrayList(); bone != null; bone = bone.parent) {
bones.add(0, bone);
}
return (GeoBone[])bones.toArray(new GeoBone[0]);
}
public void renderItem(EntityCustomModel animatable, GeoBone locator, float ticks) {
GL11.glPushMatrix();
float scale = 0.5F;
GL11.glScaled(scale, scale, scale);
GeoBone[] bonePath = this.getPathFromRoot(locator);
for(int i = 0; i < bonePath.length; ++i) {
GeoBone b = bonePath[i];
GL11.glTranslatef(b.getPositionX() / (16.0F * scale), b.getPositionY() / (16.0F * scale), b.getPositionZ() / (16.0F * scale));
GL11.glTranslatef(b.getPivotX() / (16.0F * scale), b.getPivotY() / (16.0F * scale), b.getPivotZ() / (16.0F * scale));
GL11.glRotated((double)b.getRotationZ() / Math.PI * 180.0, 0.0, 0.0, 1.0);
GL11.glRotated((double)b.getRotationY() / Math.PI * 180.0, 0.0, 1.0, 0.0);
GL11.glRotated((double)b.getRotationX() / Math.PI * 180.0, 1.0, 0.0, 0.0);
GL11.glScalef(b.getScaleX(), b.getScaleY(), b.getScaleZ());
GL11.glTranslatef(-b.getPivotX() / (16.0F * scale), -b.getPivotY() / (16.0F * scale), -b.getPivotZ() / (16.0F * scale));
}
GL11.glRotatef(250.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(40.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.4F, -0.55F, 1.7F);
ItemStack stack = animatable.getHeldItem();
RenderManager.instance.itemRenderer.renderItem(animatable, stack, 0, IItemRenderer.ItemRenderType.INVENTORY);
GL11.glPopMatrix();
}
public boolean isBoneRenderOverriden(EntityCustomModel entity, GeoBone bone) {
return bone.name.equals("held_item");
}
}
@@ -2,6 +2,7 @@ package noppes.npcs.client.renderer;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import kamkeel.addon.GeckoAddonSupport;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.gui.FontRenderer;
@@ -29,7 +30,6 @@ import noppes.npcs.controllers.data.SkinOverlay;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.opengl.GL11;
import software.bernie.geckolib3.core.IAnimatable;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
@@ -218,32 +218,9 @@ public class RenderNPCInterface extends RenderLiving{
super.doRender(entityliving, d, d1, d2, f, f1);
}
private void renderGeoModel(EntityNPCInterface npc, float rot, float partial)
{
((ModelMPM) mainModel).entity.renderYawOffset = ((ModelMPM) mainModel).entity.prevRenderYawOffset = 0;
if (!npc.isInvisible())
{
RenderManager.instance.renderEntityWithPosYaw(((ModelMPM) mainModel).entity, 0,0,0,rot,partial);
}
else if (!npc.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer))
{
GL11.glPushMatrix();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.15F);
GL11.glDepthMask(false);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
RenderManager.instance.renderEntityWithPosYaw(((ModelMPM) mainModel).entity, 0,0,0,rot,partial);
GL11.glDisable(GL11.GL_BLEND);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
GL11.glPopMatrix();
GL11.glDepthMask(true);
}
}
protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7) {
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
if(mainModel instanceof ModelMPM && ((ModelMPM) mainModel).entity instanceof IAnimatable){
if(GeckoAddonSupport.geckoModelRender(mainModel)){
GL11.glRotatef(180, 1,0,0);
GL11.glTranslated(0, -1.5,0);
renderGeoModel(npc, npc.rotationYaw, Minecraft.getMinecraft().timer.renderPartialTicks);
@@ -318,6 +295,31 @@ public class RenderNPCInterface extends RenderLiving{
npc.display.overlayRenderTicks++;
}
}
private void renderGeoModel(EntityNPCInterface npc, float rot, float partial)
{
((ModelMPM) mainModel).entity.renderYawOffset = ((ModelMPM) mainModel).entity.prevRenderYawOffset = 0;
if (!npc.isInvisible())
{
RenderManager.instance.renderEntityWithPosYaw(((ModelMPM) mainModel).entity, 0,0,0,rot,partial);
}
else if (!npc.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer))
{
GL11.glPushMatrix();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.15F);
GL11.glDepthMask(false);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
RenderManager.instance.renderEntityWithPosYaw(((ModelMPM) mainModel).entity, 0,0,0,rot,partial);
GL11.glDisable(GL11.GL_BLEND);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
GL11.glPopMatrix();
GL11.glDepthMask(true);
}
}
@Override
protected float handleRotationFloat(EntityLivingBase par1EntityLiving, float par2){
EntityNPCInterface npc = (EntityNPCInterface) par1EntityLiving;