mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-25 20:24:30 +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) {}
|
||||
}
|
||||
Reference in new issue
Block a user