mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 15:27:29 +00:00
Update CNPC+ to Support GeckoLib Mixin with Addon Classes
This commit is contained in:
1 parent
3c225f74db
commit
fc34e0a40d
14 files changed
+96
-154
No files matched your search
@@ -0,0 +1,21 @@
|
||||
package kamkeel.addon;
|
||||
|
||||
import kamkeel.addon.client.GeckoAddonClient;
|
||||
|
||||
public class AddonManager {
|
||||
public static AddonManager Instance;
|
||||
|
||||
// Manager class to easily disable mixin manipulated
|
||||
// addons for debugging and testing
|
||||
|
||||
public AddonManager(){
|
||||
Instance = this;
|
||||
load();
|
||||
}
|
||||
|
||||
public void load(){
|
||||
// Gecko Addon Initialization
|
||||
new GeckoAddon();
|
||||
new GeckoAddonClient();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package kamkeel.addon;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface DataDisplaySupport {
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound);
|
||||
public void readToNBT(NBTTagCompound nbttagcompound);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package kamkeel.addon;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
public class GeckoAddon {
|
||||
public static GeckoAddon instance;
|
||||
public boolean supportEnabled = true;
|
||||
|
||||
/**
|
||||
* This class is a shell class to be changed via mixins
|
||||
* The Addon Mod will replace all blank functions within
|
||||
* this class to change the ongoing code.
|
||||
*/
|
||||
public GeckoAddon(){
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void geckoCopyData(EntityLivingBase copied, EntityLivingBase entity){}
|
||||
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package kamkeel.addon.client;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import noppes.npcs.client.gui.model.GuiCreationScreen;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface2;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.model.ModelMPM;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class GeckoAddonClient {
|
||||
public static GeckoAddonClient Instance;
|
||||
public boolean supportEnabled = true;
|
||||
|
||||
/**
|
||||
* This class is a shell class to be changed via mixins
|
||||
* The Addon Mod will replace all blank functions within
|
||||
* this class to change the ongoing code.
|
||||
* The fewer classes modified by mixins the safer.
|
||||
* These are for mixins affecting only client-side classes.
|
||||
*/
|
||||
public GeckoAddonClient(){
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
// Creation Screen Mixins
|
||||
public void showGeckoButtons(GuiCreationScreen creationScreen, EntityLivingBase entity){}
|
||||
public void geckoGuiCreationScreenActionPerformed(GuiCreationScreen creationScreen, GuiNpcButton btn){}
|
||||
|
||||
// Npc Display Mixins
|
||||
public void geckoNpcDisplayInitGui(GuiNPCInterface2 guiNPCInterface){}
|
||||
public void geckoNpcDisplayActionPerformed(GuiNPCInterface2 guiNPCInterface, GuiNpcButton btn){}
|
||||
|
||||
// Render Npc Mixins
|
||||
public boolean isGeckoModel(ModelBase mainModel){ return false;}
|
||||
public void geckoRenderModel(ModelMPM mainModel, EntityNPCInterface npc, float rotationYaw, float renderPartialTicks) {}
|
||||
}
|
||||
@@ -7,7 +7,8 @@ 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.addon.AddonManager;
|
||||
import kamkeel.addon.GeckoAddon;
|
||||
import kamkeel.command.CommandKamkeel;
|
||||
import kamkeel.developer.Developer;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -32,7 +33,6 @@ 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-beta5")
|
||||
@@ -168,7 +168,9 @@ public class CustomNpcs {
|
||||
new CustomNpcsPermissions();
|
||||
new Developer();
|
||||
|
||||
// Load Mod Support
|
||||
PixelmonHelper.load();
|
||||
new AddonManager();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -187,14 +189,6 @@ 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();
|
||||
|
||||
@@ -3,8 +3,6 @@ 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;
|
||||
@@ -37,8 +35,6 @@ public class DataDisplay {
|
||||
public String texture = "customnpcs:textures/entity/humanmale/Steve.png";
|
||||
public String cloakTexture = "";
|
||||
|
||||
public HashMap<String, DataDisplaySupport> dataDisplaySupport;
|
||||
|
||||
public DataSkinOverlays skinOverlayData;
|
||||
public long overlayRenderTicks = 0;
|
||||
|
||||
@@ -69,9 +65,6 @@ public class DataDisplay {
|
||||
skinOverlayData = new DataSkinOverlays(npc);
|
||||
name = getRandomName();
|
||||
animationData = new AnimationData(this);
|
||||
dataDisplaySupport = new HashMap<>();
|
||||
|
||||
GeckoAddonSupport.initGeckoData(dataDisplaySupport);
|
||||
}
|
||||
|
||||
public String getRandomName() {
|
||||
@@ -86,10 +79,6 @@ public class DataDisplay {
|
||||
nbttagcompound.setString("SkinUrl", url);
|
||||
nbttagcompound.setString("Texture", texture);
|
||||
|
||||
for(DataDisplaySupport dataDisplaySupport : dataDisplaySupport.values()){
|
||||
nbttagcompound = dataDisplaySupport.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
nbttagcompound.setString("CloakTexture", cloakTexture);
|
||||
nbttagcompound.setByte("UsingSkinUrl", skinType);
|
||||
nbttagcompound.setString("GlowTexture", glowTexture);
|
||||
@@ -152,10 +141,6 @@ public class DataDisplay {
|
||||
|
||||
texture = nbttagcompound.getString("Texture");
|
||||
|
||||
for(DataDisplaySupport dataDisplaySupport : dataDisplaySupport.values()){
|
||||
dataDisplaySupport.readToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
cloakTexture = nbttagcompound.getString("CloakTexture");
|
||||
glowTexture = nbttagcompound.getString("GlowTexture");
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package noppes.npcs.client;
|
||||
|
||||
import kamkeel.addon.GeckoAddonSupport;
|
||||
import kamkeel.addon.GeckoAddon;
|
||||
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.EntityNPCInterface;
|
||||
|
||||
public class EntityUtil {
|
||||
@@ -86,7 +85,7 @@ public class EntityUtil {
|
||||
entity.setCurrentItemOrArmor(i, copied.getEquipmentInSlot(i));
|
||||
}
|
||||
|
||||
GeckoAddonSupport.geckoModelCopy(copied, entity);
|
||||
GeckoAddon.instance.geckoCopyData(copied, entity);
|
||||
|
||||
if(copied instanceof EntityNPCInterface && entity instanceof EntityNPCInterface){
|
||||
EntityNPCInterface npc = (EntityNPCInterface) copied;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs.client.gui.mainmenu;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import kamkeel.addon.client.GeckoAddonClient;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.DataDisplay;
|
||||
@@ -95,6 +96,7 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
|
||||
addLabel(new GuiNpcLabel(10,"display.bossbar", guiLeft + 5, y + 5));
|
||||
this.addButton(new GuiNpcButton(10, guiLeft + 120, y, 110, 20, new String[]{"display.hide","display.show","display.showAttacking"}, display.showBossBar));
|
||||
|
||||
GeckoAddonClient.Instance.geckoNpcDisplayInitGui(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,6 +194,8 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
|
||||
else if(button.id == 15){
|
||||
setSubGui(new SubGuiNpcName(display));
|
||||
}
|
||||
|
||||
GeckoAddonClient.Instance.geckoNpcDisplayActionPerformed(this, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs.client.gui.model;
|
||||
|
||||
import kamkeel.addon.GeckoAddonSupport;
|
||||
import kamkeel.addon.GeckoAddon;
|
||||
import kamkeel.addon.client.GeckoAddonClient;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -24,8 +25,6 @@ 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>>();
|
||||
@@ -169,12 +168,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("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"));
|
||||
//this.addButton(new GuiNpcButton(203, guiLeft, y + i * 22+60, 120, 20, "Select animation file"));
|
||||
}
|
||||
GeckoAddonClient.Instance.showGeckoButtons(this, entity);
|
||||
}
|
||||
private boolean isIgnored(String tag){
|
||||
for(String s : ignoredTags)
|
||||
@@ -326,9 +320,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
if(GeckoAddonSupport.supportEnabled){
|
||||
openGeckoGui(this, button, player, npc);
|
||||
}
|
||||
GeckoAddonClient.Instance.geckoGuiCreationScreenActionPerformed(this, button);
|
||||
}
|
||||
|
||||
private void updateTexture(){
|
||||
|
||||
@@ -2,7 +2,8 @@ package noppes.npcs.client.renderer;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
import kamkeel.addon.GeckoAddonSupport;
|
||||
import kamkeel.addon.GeckoAddon;
|
||||
import kamkeel.addon.client.GeckoAddonClient;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
@@ -11,7 +12,6 @@ import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
@@ -33,7 +33,6 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.MessageDigest;
|
||||
@@ -220,10 +219,8 @@ public class RenderNPCInterface extends RenderLiving{
|
||||
|
||||
protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7) {
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
|
||||
if(GeckoAddonSupport.geckoModelRender(mainModel)){
|
||||
GL11.glRotatef(180, 1,0,0);
|
||||
GL11.glTranslated(0, -1.5,0);
|
||||
renderGeoModel(npc, npc.rotationYaw, Minecraft.getMinecraft().timer.renderPartialTicks);
|
||||
if(GeckoAddonClient.Instance.isGeckoModel(mainModel)){
|
||||
GeckoAddonClient.Instance.geckoRenderModel((ModelMPM) mainModel, npc, npc.rotationYaw, Minecraft.getMinecraft().timer.renderPartialTicks);
|
||||
} else if (this.getEntityTexture(entityliving) != null) {
|
||||
super.renderModel(entityliving, par2, par3, par4, par5, par6, par7);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ 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;
|
||||
@@ -24,7 +23,6 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBow;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.play.server.S04PacketEntityEquipment;
|
||||
import net.minecraft.pathfinding.PathNavigate;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
|
||||
Reference in new issue
Block a user