Refactor all Gecko Internal support to CustomModel

This commit is contained in:
Kam committed 2023-11-16 17:46:12 -05:00
1 parent c67a8e43cb
commit ff49b1ffbd
11 files changed
+38 -111

No files matched your search

+1 -1
View File
@@ -156,7 +156,7 @@ public class CustomNpcs {
registerNpc(EntityNPCEnderman.class, "npcEnderman");
registerNpc(EntityNPCGolem.class, "npcGolem");
registerNpc(EntityCustomNpc.class, "CustomNpc");
registerCustomModel(EntityGeckoModel.class, "CustomModel");
registerCustomModel(EntityCustomModel.class, "CustomModel");
registerNewEntity(EntityChairMount.class, "CustomNpcChairMount", 64, 10, false);
registerNewEntity(EntityProjectile.class, "throwableitem", 64, 3, true);
@@ -87,7 +87,7 @@ public class ClientProxy extends CommonProxy {
new ScriptSoundController();
RenderingRegistry.registerEntityRenderingHandler(EntityNpcPony.class, new RenderNPCPony());
RenderingRegistry.registerEntityRenderingHandler(EntityGeckoModel.class, new RenderGeckolib());
RenderingRegistry.registerEntityRenderingHandler(EntityCustomModel.class, new RenderCustomModel());
RenderingRegistry.registerEntityRenderingHandler(EntityNpcCrystal.class, new RenderNpcCrystal(new ModelNpcCrystal(0.5F)));
RenderingRegistry.registerEntityRenderingHandler(EntityNpcDragon.class, new RenderNpcDragon(new ModelNpcDragon(0.0F), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityNpcSlime.class, new RenderNpcSlime(new ModelNpcSlime(16), new ModelNpcSlime(0), 0.25F));
@@ -5,7 +5,7 @@ import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.entity.EntityGeckoModel;
import noppes.npcs.entity.EntityCustomModel;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityUtil {
@@ -86,11 +86,11 @@ public class EntityUtil {
entity.setCurrentItemOrArmor(i, copied.getEquipmentInSlot(i));
}
if(entity instanceof EntityGeckoModel && copied instanceof EntityNPCInterface){
((EntityGeckoModel) entity).textureResLoc=new ResourceLocation(((EntityNPCInterface) copied).display.texture);
((EntityGeckoModel) entity).modelResLoc=new ResourceLocation(((EntityNPCInterface) copied).display.model);
((EntityGeckoModel) entity).animResLoc=new ResourceLocation(((EntityNPCInterface) copied).display.animFile);
((EntityGeckoModel) entity).idleAnim=((EntityNPCInterface) copied).display.idleAnim;
if(entity instanceof EntityCustomModel && copied instanceof EntityNPCInterface){
((EntityCustomModel) entity).textureResLoc=new ResourceLocation(((EntityNPCInterface) copied).display.texture);
((EntityCustomModel) entity).modelResLoc=new ResourceLocation(((EntityNPCInterface) copied).display.model);
((EntityCustomModel) entity).animResLoc=new ResourceLocation(((EntityNPCInterface) copied).display.animFile);
((EntityCustomModel) entity).idleAnim=((EntityNPCInterface) copied).display.idleAnim;
}
if(copied instanceof EntityNPCInterface && entity instanceof EntityNPCInterface){
@@ -15,6 +15,9 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.model.custom.GuiCustomAnimFileSelection;
import noppes.npcs.client.gui.model.custom.GuiCustomAnimationSelection;
import noppes.npcs.client.gui.model.custom.GuiCustomModelSelection;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.compat.PixelmonHelper;
@@ -325,15 +328,15 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol
}
if(button.id == 202){
NoppesUtil.openGUI(player, new GuiGeckoModelSelection(npc, this));
NoppesUtil.openGUI(player, new GuiCustomModelSelection(npc, this));
}
if(button.id == 203){
NoppesUtil.openGUI(player, new GuiGeckoAnimFileSelection(npc, this));
NoppesUtil.openGUI(player, new GuiCustomAnimFileSelection(npc, this));
}
if(button.id == 204){
NoppesUtil.openGUI(player, new GuiGeckoAnimationSelection(npc, this, (name)-> npc.display.idleAnim=name));
NoppesUtil.openGUI(player, new GuiCustomAnimationSelection(npc, this, (name)-> npc.display.idleAnim=name));
}
}
@@ -1,72 +0,0 @@
package noppes.npcs.client.gui.model;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.entity.EntityNPCInterface;
import software.bernie.geckolib3.resource.GeckoLibCache;
import java.util.Collections;
import java.util.HashSet;
import java.util.Vector;
public class GuiGeckoAnimFileSelection extends GuiNPCInterface {
public GuiNPCStringSlot slot;
public GuiScreen parent;
public GuiGeckoAnimFileSelection(EntityNPCInterface npc, GuiScreen parent){
super(npc);
drawDefaultBackground = false;
title = "";
this.parent = parent;
}
@Override
public void initGui(){
super.initGui();
String ss = "Selecting geckolib animation file:";
addLabel(new GuiNpcLabel(0,ss, width / 2 - (this.fontRendererObj.getStringWidth(ss)/2), 20, 0xffffff));
Vector<String> list = new Vector<String>();
for(ResourceLocation resLoc : GeckoLibCache.getInstance().getAnimations().keySet()){
list.add(resLoc.toString());
}
Collections.sort(list,String.CASE_INSENSITIVE_ORDER);
slot = new GuiNPCStringSlot(list,this,false,18);
slot.registerScrollButtons(4, 5);
this.addButton(new GuiNpcButton(2, width / 2 - 100, height - 44,98, 20, "gui.back"));
}
@Override
public void drawScreen(int i, int j, float f)
{
slot.drawScreen(i, j, f);
super.drawScreen(i, j, f);
}
@Override
public void elementClicked(){
}
@Override
public void doubleClicked(){
npc.display.animFile=slot.selected;
close();
NoppesUtil.openGUI(player, parent);
}
@Override
protected void actionPerformed(GuiButton guibutton){
int id = guibutton.id;
if(id == 2){
close();
NoppesUtil.openGUI(player, parent);
}
}
@Override
public void save() {
}
}
@@ -1,4 +1,4 @@
package noppes.npcs.client.model;
package noppes.npcs.client.gui.model.custom;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
@@ -9,14 +9,13 @@ import noppes.npcs.entity.EntityNPCInterface;
import software.bernie.geckolib3.resource.GeckoLibCache;
import java.util.Collections;
import java.util.HashSet;
import java.util.Vector;
public class GuiGeckoAnimFileSelection extends GuiNPCInterface {
public class GuiCustomAnimFileSelection extends GuiNPCInterface {
public GuiNPCStringSlot slot;
public GuiScreen parent;
public GuiGeckoAnimFileSelection(EntityNPCInterface npc, GuiScreen parent){
public GuiCustomAnimFileSelection(EntityNPCInterface npc, GuiScreen parent){
super(npc);
drawDefaultBackground = false;
title = "";
@@ -1,4 +1,4 @@
package noppes.npcs.client.gui.model;
package noppes.npcs.client.gui.model.custom;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
@@ -11,16 +11,15 @@ import software.bernie.geckolib3.file.AnimationFile;
import software.bernie.geckolib3.resource.GeckoLibCache;
import java.util.Collections;
import java.util.HashSet;
import java.util.Vector;
import java.util.function.Consumer;
public class GuiGeckoAnimationSelection extends GuiNPCInterface {
public class GuiCustomAnimationSelection extends GuiNPCInterface {
public GuiNPCStringSlot slot;
public GuiScreen parent;
public Consumer<String> action;
public GuiGeckoAnimationSelection(EntityNPCInterface npc, GuiScreen parent, Consumer<String> action){
public GuiCustomAnimationSelection(EntityNPCInterface npc, GuiScreen parent, Consumer<String> action){
super(npc);
drawDefaultBackground = false;
title = "";
@@ -1,4 +1,4 @@
package noppes.npcs.client.gui.model;
package noppes.npcs.client.gui.model.custom;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
@@ -9,14 +9,13 @@ import noppes.npcs.entity.EntityNPCInterface;
import software.bernie.geckolib3.resource.GeckoLibCache;
import java.util.Collections;
import java.util.HashSet;
import java.util.Vector;
public class GuiGeckoModelSelection extends GuiNPCInterface {
public class GuiCustomModelSelection extends GuiNPCInterface {
public GuiNPCStringSlot slot;
public GuiScreen parent;
public GuiGeckoModelSelection(EntityNPCInterface npc, GuiScreen parent){
public GuiCustomModelSelection(EntityNPCInterface npc, GuiScreen parent){
super(npc);
drawDefaultBackground = false;
title = "";
@@ -1,23 +1,22 @@
package noppes.npcs.client.model;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.entity.EntityGeckoModel;
import software.bernie.geckolib3.GeckoLib;
import noppes.npcs.entity.EntityCustomModel;
import software.bernie.geckolib3.model.AnimatedGeoModel;
public class ModelGeckolib extends AnimatedGeoModel<EntityGeckoModel> {
public class ModelCustom extends AnimatedGeoModel<EntityCustomModel> {
@Override
public ResourceLocation getAnimationFileLocation(EntityGeckoModel entity) {
public ResourceLocation getAnimationFileLocation(EntityCustomModel entity) {
return entity.animResLoc;//new ResourceLocation(GeckoLib.ModID, "animations/bike.animation.json");
}
@Override
public ResourceLocation getModelLocation(EntityGeckoModel entity) {
public ResourceLocation getModelLocation(EntityCustomModel entity) {
return entity.modelResLoc;//new ResourceLocation(GeckoLib.ModID, "geo/bike.geo.json");
}
@Override
public ResourceLocation getTextureLocation(EntityGeckoModel entity) {
public ResourceLocation getTextureLocation(EntityCustomModel entity) {
return entity.textureResLoc;//new ResourceLocation(GeckoLib.ModID, "textures/model/entity/bike.png");
}
}
@@ -3,8 +3,8 @@ 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.ModelGeckolib;
import noppes.npcs.entity.EntityGeckoModel;
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;
@@ -12,12 +12,12 @@ import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer;
import java.util.ArrayList;
public class RenderGeckolib extends GeoEntityRenderer<EntityGeckoModel> {
public class RenderCustomModel extends GeoEntityRenderer<EntityCustomModel> {
public RenderGeckolib() {
super(new ModelGeckolib());
public RenderCustomModel() {
super(new ModelCustom());
}
public void renderAfter(GeoModel model, EntityGeckoModel animatable, float ticks, float red, float green, float blue, float alpha) {
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();
@@ -34,7 +34,7 @@ public class RenderGeckolib extends GeoEntityRenderer<EntityGeckoModel> {
return (GeoBone[])bones.toArray(new GeoBone[0]);
}
public void renderItem(EntityGeckoModel animatable, GeoBone locator, float ticks) {
public void renderItem(EntityCustomModel animatable, GeoBone locator, float ticks) {
GL11.glPushMatrix();
float scale = 0.5F;
GL11.glScaled(scale, scale, scale);
@@ -59,7 +59,7 @@ public class RenderGeckolib extends GeoEntityRenderer<EntityGeckoModel> {
GL11.glPopMatrix();
}
public boolean isBoneRenderOverriden(EntityGeckoModel entity, GeoBone bone) {
public boolean isBoneRenderOverriden(EntityCustomModel entity, GeoBone bone) {
return bone.name.equals("held_item");
}
}
@@ -16,7 +16,7 @@ import software.bernie.geckolib3.core.manager.AnimationFactory;
import java.util.Objects;
public class EntityGeckoModel extends EntityCreature implements IAnimatable, IAnimationTickable {
public class EntityCustomModel extends EntityCreature implements IAnimatable, IAnimationTickable {
private AnimationFactory factory = new AnimationFactory(this);
public ResourceLocation modelResLoc=new ResourceLocation("geckolib3", "geo/npc.geo.json");
public ResourceLocation animResLoc=new ResourceLocation("custom", "geo_npc.animation.json");
@@ -46,7 +46,7 @@ public class EntityGeckoModel extends EntityCreature implements IAnimatable, IAn
return PlayState.CONTINUE;
}
public EntityGeckoModel(World worldIn) {
public EntityCustomModel(World worldIn) {
super(worldIn);
this.ignoreFrustumCheck = true;
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));