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 -1
View File
@@ -38,7 +38,7 @@ configurations {
apply plugin: 'forge'
version = "1.9-beta4"
version = "1.9-beta5"
group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "CustomNPC-Plus"
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,10 @@
package kamkeel.addon;
import net.minecraft.nbt.NBTTagCompound;
public interface DataDisplaySupport {
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound);
public void readToNBT(NBTTagCompound nbttagcompound);
}
@@ -0,0 +1,95 @@
package kamkeel.addon;
import net.minecraft.client.model.ModelBase;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.DataDisplay;
import noppes.npcs.DataGecko;
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.GuiModelInterface;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.model.ModelMPM;
import noppes.npcs.entity.EntityCustomModel;
import noppes.npcs.entity.EntityNPCInterface;
import software.bernie.geckolib3.core.IAnimatable;
import java.util.HashMap;
public class GeckoAddonSupport {
public static boolean supportEnabled = false;
public static boolean geckoModelRender(ModelBase modelBase) {
if(!supportEnabled)
return false;
return modelBase instanceof ModelMPM && ((ModelMPM) modelBase).entity instanceof IAnimatable;
}
public static void openGeckoGui(GuiModelInterface parent, GuiNpcButton button, EntityPlayer player, EntityNPCInterface npc){
if(!supportEnabled)
return;
if(button.id == 202){
NoppesUtil.openGUI(player, new GuiCustomModelSelection(npc, parent));
}
if(button.id == 203){
NoppesUtil.openGUI(player, new GuiCustomAnimFileSelection(npc, parent));
}
if(button.id == 204){
DataGecko geckoData = (DataGecko) getGeckoData(npc);
if(geckoData != null){
NoppesUtil.openGUI(player, new GuiCustomAnimationSelection(npc, parent, (name)-> geckoData.idleAnim=name));
}
}
}
public static void geckoModelCopy(EntityLivingBase copied, EntityLivingBase entity) {
if(!supportEnabled)
return;
if(entity instanceof EntityCustomModel && copied instanceof EntityNPCInterface){
DataGecko geckoData = (DataGecko) getGeckoData((EntityNPCInterface) copied);
if(geckoData != null){
((EntityCustomModel) entity).textureResLoc=new ResourceLocation(((EntityNPCInterface) copied).display.texture);
((EntityCustomModel) entity).modelResLoc=new ResourceLocation(geckoData.model);
((EntityCustomModel) entity).animResLoc=new ResourceLocation(geckoData.animFile);
((EntityCustomModel) entity).idleAnim=geckoData.idleAnim;
}
}
}
public static void initGeckoData(HashMap<String, DataDisplaySupport> dataDisplaySupportHashMap){
if(!supportEnabled)
return;
dataDisplaySupportHashMap.put("GECKO", new DataGecko());
}
public static void putGeckoData(EntityNPCInterface npc, DataDisplaySupport geckoData){
if(!supportEnabled)
return;
npc.display.dataDisplaySupport.put("GECKO", geckoData);
}
public static DataDisplaySupport getGeckoData(EntityNPCInterface npc){
if(!supportEnabled)
return null;
DataDisplaySupport dataDisplaySupport = npc.display.dataDisplaySupport.get("GECKO");
if(dataDisplaySupport instanceof DataGecko){
return dataDisplaySupport;
}
dataDisplaySupport = new DataGecko();
putGeckoData(npc, dataDisplaySupport);
return dataDisplaySupport;
}
}
+12 -11
View File
@@ -1,14 +1,13 @@
package noppes.npcs;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.*;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.network.FMLEventChannel;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import foxz.command.CommandNoppes;
import kamkeel.addon.GeckoAddonSupport;
import kamkeel.command.CommandKamkeel;
import kamkeel.developer.Developer;
import net.minecraft.block.Block;
@@ -33,9 +32,10 @@ import noppes.npcs.entity.old.*;
import noppes.npcs.scripted.NpcAPI;
import java.io.File;
import java.util.HashMap;
import java.util.Set;
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.9-beta4")
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.9-beta5")
public class CustomNpcs {
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
@@ -156,7 +156,6 @@ public class CustomNpcs {
registerNpc(EntityNPCEnderman.class, "npcEnderman");
registerNpc(EntityNPCGolem.class, "npcGolem");
registerNpc(EntityCustomNpc.class, "CustomNpc");
registerCustomModel(EntityCustomModel.class, "CustomModel");
registerNewEntity(EntityChairMount.class, "CustomNpcChairMount", 64, 10, false);
registerNewEntity(EntityProjectile.class, "throwableitem", 64, 3, true);
@@ -188,6 +187,14 @@ public class CustomNpcs {
}
@EventHandler
public void load(FMLPostInitializationEvent ev) {
if(Loader.isModLoaded("customnpcsgecko")){
System.out.println("Enabling CNPC+ Gecko Addon");
GeckoAddonSupport.supportEnabled = true;
}
}
@EventHandler
public void setAboutToStart(FMLServerAboutToStartEvent event) {
ChunkController.Instance.clear();
@@ -255,16 +262,10 @@ public class CustomNpcs {
EntityList.stringToClassMapping.put(name, cl);
}
private void registerCustomModel(Class<? extends Entity> cl, String name) {
EntityRegistry.registerModEntity(cl, name, NewEntityStartId++, this, 64, 10, false);
EntityList.stringToClassMapping.put(name, cl);
}
private void registerNewEntity(Class<? extends Entity> cl, String name, int range, int update, boolean velocity) {
EntityRegistry.registerModEntity(cl, name, NewEntityStartId++, this, range, update, velocity);
}
public static File getWorldSaveDirectory() {
MinecraftServer server = MinecraftServer.getServer();
File saves = new File(".");
+13 -25
View File
@@ -3,6 +3,8 @@ package noppes.npcs;
import com.google.common.collect.Iterables;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import kamkeel.addon.DataDisplaySupport;
import kamkeel.addon.GeckoAddonSupport;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
@@ -16,9 +18,7 @@ import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.entity.data.DataSkinOverlays;
import noppes.npcs.util.ValueUtil;
import java.util.ArrayList;
import java.util.Random;
import java.util.UUID;
import java.util.*;
public class DataDisplay {
public EntityNPCInterface npc;
@@ -37,12 +37,7 @@ public class DataDisplay {
public String texture = "customnpcs:textures/entity/humanmale/Steve.png";
public String cloakTexture = "";
public String model = "geckolib3:geo/npc.geo.json";
public String animFile = "custom:geo_npc.animation.json";
public String idleAnim = "";
public String walkAnim = "";
public String attackAnim = "";
public String hurtAnim = "";
public HashMap<String, DataDisplaySupport> dataDisplaySupport;
public DataSkinOverlays skinOverlayData;
public long overlayRenderTicks = 0;
@@ -74,6 +69,9 @@ public class DataDisplay {
skinOverlayData = new DataSkinOverlays(npc);
name = getRandomName();
animationData = new AnimationData(this);
dataDisplaySupport = new HashMap<>();
GeckoAddonSupport.initGeckoData(dataDisplaySupport);
}
public String getRandomName() {
@@ -88,13 +86,9 @@ public class DataDisplay {
nbttagcompound.setString("SkinUrl", url);
nbttagcompound.setString("Texture", texture);
// Custom Model
nbttagcompound.setString("Model", model);
nbttagcompound.setString("AnimFile", animFile);
nbttagcompound.setString("IdleAnim", idleAnim);
nbttagcompound.setString("WalkAnim", walkAnim);
nbttagcompound.setString("AttackAnim", attackAnim);
nbttagcompound.setString("HurtAnim", hurtAnim);
for(DataDisplaySupport dataDisplaySupport : dataDisplaySupport.values()){
nbttagcompound = dataDisplaySupport.writeToNBT(nbttagcompound);
}
nbttagcompound.setString("CloakTexture", cloakTexture);
nbttagcompound.setByte("UsingSkinUrl", skinType);
@@ -158,14 +152,9 @@ public class DataDisplay {
texture = nbttagcompound.getString("Texture");
// Custom Model
model = nbttagcompound.getString("Model");
animFile = nbttagcompound.getString("AnimFile");
idleAnim = nbttagcompound.getString("IdleAnim");
walkAnim = nbttagcompound.getString("WalkAnim");
hurtAnim = nbttagcompound.getString("HurtAnim");
attackAnim = nbttagcompound.getString("AttackAnim");
for(DataDisplaySupport dataDisplaySupport : dataDisplaySupport.values()){
dataDisplaySupport.readToNBT(nbttagcompound);
}
cloakTexture = nbttagcompound.getString("CloakTexture");
glowTexture = nbttagcompound.getString("GlowTexture");
@@ -291,5 +280,4 @@ public class DataDisplay {
return;
this.markovGeneratorId = ValueUtil.clamp(id, 0, CustomNpcs.MARKOV_GENERATOR.length-1);
}
}
@@ -87,7 +87,6 @@ public class ClientProxy extends CommonProxy {
new ScriptSoundController();
RenderingRegistry.registerEntityRenderingHandler(EntityNpcPony.class, new RenderNPCPony());
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));
@@ -1,11 +1,11 @@
package noppes.npcs.client;
import kamkeel.addon.GeckoAddonSupport;
import net.minecraft.entity.EntityLivingBase;
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.EntityCustomModel;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityUtil {
@@ -86,12 +86,7 @@ public class EntityUtil {
entity.setCurrentItemOrArmor(i, copied.getEquipmentInSlot(i));
}
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;
}
GeckoAddonSupport.geckoModelCopy(copied, entity);
if(copied instanceof EntityNPCInterface && entity instanceof EntityNPCInterface){
EntityNPCInterface npc = (EntityNPCInterface) copied;
@@ -1,8 +1,3 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.components;
import com.ibm.icu.text.ArabicShaping;
@@ -1,5 +1,6 @@
package noppes.npcs.client.gui.model;
import kamkeel.addon.GeckoAddonSupport;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
@@ -14,10 +15,6 @@ import net.minecraft.nbt.NBTTagByte;
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;
@@ -27,6 +24,8 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;
import static kamkeel.addon.GeckoAddonSupport.openGeckoGui;
public class GuiCreationScreen extends GuiModelInterface implements ICustomScrollListener{
public HashMap<String,Class<? extends EntityLivingBase>> data = new HashMap<String, Class<? extends EntityLivingBase>>();
@@ -170,7 +169,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol
addButton(new GuiNpcButton(201, guiLeft + 80, y + i * 22, 50, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"}, breed));
}
if(EntityList.getEntityString(entity).equals("customnpcs.CustomModel") || EntityList.getEntityString(entity).equals("CustomModel")){
if(EntityList.getEntityString(entity).equals("customnpcsgecko.CustomModel") || EntityList.getEntityString(entity).equals("CustomModel")){
this.addButton(new GuiNpcButton(202, guiLeft, y + i * 22, 120, 20, "Select model"));
this.addButton(new GuiNpcButton(203, guiLeft, y + i * 22+20, 120, 20, "Select animation file"));
this.addButton(new GuiNpcButton(204, guiLeft, y + i * 22+40, 120, 20, "Select idle animation"));
@@ -327,16 +326,8 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol
} catch (Exception ignored) {}
}
if(button.id == 202){
NoppesUtil.openGUI(player, new GuiCustomModelSelection(npc, this));
}
if(button.id == 203){
NoppesUtil.openGUI(player, new GuiCustomAnimFileSelection(npc, this));
}
if(button.id == 204){
NoppesUtil.openGUI(player, new GuiCustomAnimationSelection(npc, this, (name)-> npc.display.idleAnim=name));
if(GeckoAddonSupport.supportEnabled){
openGeckoGui(this, button, player, npc);
}
}
@@ -1,71 +0,0 @@
package noppes.npcs.client.gui.model.custom;
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.Vector;
public class GuiCustomAnimFileSelection extends GuiNPCInterface {
public GuiNPCStringSlot slot;
public GuiScreen parent;
public GuiCustomAnimFileSelection(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,80 +0,0 @@
package noppes.npcs.client.gui.model.custom;
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.core.builder.Animation;
import software.bernie.geckolib3.file.AnimationFile;
import software.bernie.geckolib3.resource.GeckoLibCache;
import java.util.Collections;
import java.util.Vector;
import java.util.function.Consumer;
public class GuiCustomAnimationSelection extends GuiNPCInterface {
public GuiNPCStringSlot slot;
public GuiScreen parent;
public Consumer<String> action;
public GuiCustomAnimationSelection(EntityNPCInterface npc, GuiScreen parent, Consumer<String> action){
super(npc);
drawDefaultBackground = false;
title = "";
this.parent = parent;
this.action=action;
}
@Override
public void initGui(){
super.initGui();
String ss = "Selecting geckolib animation:";
addLabel(new GuiNpcLabel(0,ss, width / 2 - (this.fontRendererObj.getStringWidth(ss)/2), 20, 0xffffff));
Vector<String> list = new Vector<String>();
AnimationFile file = GeckoLibCache.getInstance().getAnimations().get(new ResourceLocation(npc.display.animFile));
if(file!=null) {
for (Animation anim : file.getAllAnimations()) {
list.add(anim.animationName);
}
}
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;
action.accept(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,71 +0,0 @@
package noppes.npcs.client.gui.model.custom;
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.Vector;
public class GuiCustomModelSelection extends GuiNPCInterface {
public GuiNPCStringSlot slot;
public GuiScreen parent;
public GuiCustomModelSelection(EntityNPCInterface npc, GuiScreen parent){
super(npc);
drawDefaultBackground = false;
title = "";
this.parent = parent;
}
@Override
public void initGui(){
super.initGui();
String ss = "Selecting geckolib model:";
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().getGeoModels().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.model=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,22 +0,0 @@
package noppes.npcs.client.model;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.entity.EntityCustomModel;
import software.bernie.geckolib3.model.AnimatedGeoModel;
public class ModelCustom extends AnimatedGeoModel<EntityCustomModel> {
@Override
public ResourceLocation getAnimationFileLocation(EntityCustomModel entity) {
return entity.animResLoc;//new ResourceLocation(GeckoLib.ModID, "animations/bike.animation.json");
}
@Override
public ResourceLocation getModelLocation(EntityCustomModel entity) {
return entity.modelResLoc;//new ResourceLocation(GeckoLib.ModID, "geo/bike.geo.json");
}
@Override
public ResourceLocation getTextureLocation(EntityCustomModel entity) {
return entity.textureResLoc;//new ResourceLocation(GeckoLib.ModID, "textures/model/entity/bike.png");
}
}
@@ -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;
@@ -1,77 +0,0 @@
package noppes.npcs.entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import software.bernie.geckolib3.core.IAnimatable;
import software.bernie.geckolib3.core.IAnimationTickable;
import software.bernie.geckolib3.core.PlayState;
import software.bernie.geckolib3.core.builder.AnimationBuilder;
import software.bernie.geckolib3.core.controller.AnimationController;
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.manager.AnimationData;
import software.bernie.geckolib3.core.manager.AnimationFactory;
import java.util.Objects;
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");
public ResourceLocation textureResLoc = new ResourceLocation("geckolib3", "textures/model/entity/geo_npc.png");
public String idleAnim = "";
public String walkAnim = "";
public String hurtAnim = "";
public String attackAnim = "";
private <E extends IAnimatable> PlayState predicateMovement(AnimationEvent<E> event) {
if(!event.isMoving()){
if(!Objects.equals(idleAnim, "")) {
event.getController().setAnimation(new AnimationBuilder().addAnimation(idleAnim, true));
}
}else{
if(!Objects.equals(idleAnim, "")) {
event.getController().setAnimation(new AnimationBuilder().addAnimation(walkAnim, true));
}
}
//event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.bat.fly", true));
return PlayState.CONTINUE;
}
private <E extends IAnimatable> PlayState predicateAttack(AnimationEvent<E> event) {
//event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.bat.fly", true));
return PlayState.CONTINUE;
}
private <E extends IAnimatable> PlayState predicateManual(AnimationEvent<E> event) {
return PlayState.CONTINUE;
}
public EntityCustomModel(World worldIn) {
super(worldIn);
this.ignoreFrustumCheck = true;
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.setSize(0.7F, 2F);
}
@Override
public void registerControllers(AnimationData data) {
data.addAnimationController(new AnimationController<>(this, "movement", 10, this::predicateMovement));
data.addAnimationController(new AnimationController<>(this, "attack", 10, this::predicateAttack));
data.addAnimationController(new AnimationController<>(this, "manual", 10, this::predicateManual));
}
@Override
public AnimationFactory getFactory() {
return this.factory;
}
@Override
public int tickTimer() {
return ticksExisted;
}
@Override
public void tick() {
super.onUpdate();
}
}
@@ -2,6 +2,7 @@ package noppes.npcs.entity;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
import io.netty.buffer.ByteBuf;
import kamkeel.addon.GeckoAddonSupport;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.command.ICommandSender;