Item Display Support Gecko Lib + Item Stack Wrapper

This commit is contained in:
Kam committed 2026-03-12 05:50:51 -04:00
1 parent 6fa5f1c366
commit 9642c9f909
17 files changed
+949 -236

No files matched your search

@@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.api.block.IBlockScripted;
import noppes.npcs.api.entity.ICustomNpc;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.item.IItemCustomizable;
import noppes.npcs.entity.EntityNPCInterface;
public abstract class AbstractGeckoAPI {
@@ -227,10 +228,100 @@ public abstract class AbstractGeckoAPI {
*/
public abstract void syncAnimForAll(IBlockScripted scriptedBlock, IGeckoAnimationBuilder builder);
// TODO: Fix ScriptCustomItem
// ========================================================================
// Item Methods
// ========================================================================
// public abstract void setModel(ScriptCustomItem item, String model);
// public abstract void setTexture(ScriptCustomItem item, String texture);
// public abstract void setAnimationFile(ScriptCustomItem item, String animation);
// public abstract void setIdleAnimation(ScriptCustomItem item, String animation);
/**
* Set the geo model resource location for a customizable item.
* Works with both Scripted Items and Linked Items.
*
* @param item The item (IItemCustom or IItemLinked from event.item or API)
* @param model The model path (e.g. "geckolib3:geo/mymodel.geo.json")
*/
public abstract void setItemModel(IItemCustomizable item, String model);
/**
* Set the texture resource location for a customizable item.
*
* @param item The item
* @param texture The texture path (e.g. "geckolib3:textures/item/mytexture.png")
*/
public abstract void setItemTexture(IItemCustomizable item, String texture);
/**
* Set the animation file resource location for a customizable item.
*
* @param item The item
* @param animation The animation file path (e.g. "geckolib3:animations/mymodel.animation.json")
*/
public abstract void setItemAnimationFile(IItemCustomizable item, String animation);
/**
* Set the idle animation name for a customizable item.
*
* @param item The item
* @param animation The animation name from the animation file
*/
public abstract void setItemIdleAnimation(IItemCustomizable item, String animation);
/**
* Check if a customizable item has a gecko model assigned.
*
* @param item The item to check
* @return true if the item has a custom gecko model
*/
public abstract boolean hasItemModel(IItemCustomizable item);
/**
* Remove the gecko model from a customizable item, reverting to normal 2D rendering.
*
* @param item The item to clear the model from
*/
public abstract void clearItemModel(IItemCustomizable item);
/**
* Set the display JSON file for a gecko item.
* The file is loaded from assets/{domain}/item_displays/ folders.
* This controls how the 3D model is positioned, rotated, and scaled
* in each render context (first person, third person, inventory, ground).
*
* <p>Example: {@code GeckoAPI.setDisplayJSON(item, "sword.json")}</p>
*
* @param item The item to set the display JSON on
* @param displayFile The display JSON filename (e.g. "sword.json")
*/
public abstract void setDisplayJSON(IItemCustomizable item, String displayFile);
/**
* Get a list of all loaded display file names from item_displays/ folders.
*
* @return Array of display file names
*/
public abstract String[] getDisplayFileList();
/**
* Set the display transform for a specific render context on a gecko item.
* This controls how the 3D model is positioned, rotated, and scaled
* when rendered in that context.
*
* <p>If no per-context transform is set, the item's existing rotation/scale/translate
* properties are used as fallback.</p>
*
* @param item The item to set the display transform on
* @param context The render context: "first_person", "third_person", "inventory", or "ground"
* @param tx Translation X
* @param ty Translation Y
* @param tz Translation Z
* @param rx Rotation X (degrees)
* @param ry Rotation Y (degrees)
* @param rz Rotation Z (degrees)
* @param sx Scale X
* @param sy Scale Y
* @param sz Scale Z
*/
public abstract void setItemDisplay(IItemCustomizable item, String context,
float tx, float ty, float tz,
float rx, float ry, float rz,
float sx, float sy, float sz);
}
@@ -1,7 +1,11 @@
package com.goodbird.npcgecko.api;
import com.goodbird.npcgecko.data.CustomItemModelData;
import com.goodbird.npcgecko.data.ItemDisplayTransform;
import software.bernie.geckolib3.resource.ItemDisplayLibrary;
import com.goodbird.npcgecko.wrapper.*;
import com.goodbird.npcgecko.mixin.IDataDisplay;
import com.goodbird.npcgecko.mixin.IScriptCustomItem;
import com.goodbird.npcgecko.network.CPacketSyncManualAnim;
import com.goodbird.npcgecko.network.CPacketSyncTileManualAnim;
import com.goodbird.npcgecko.network.NetworkHandler;
@@ -11,8 +15,10 @@ import net.minecraft.util.ResourceLocation;
import noppes.npcs.api.block.IBlockScripted;
import noppes.npcs.api.entity.ICustomNpc;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.item.IItemCustomizable;
import noppes.npcs.blocks.tiles.TileScripted;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.item.ScriptCustomizableItem;
import software.bernie.geckolib3.core.builder.Animation;
import software.bernie.geckolib3.core.builder.AnimationBuilder;
import software.bernie.geckolib3.core.util.Color;
@@ -215,39 +221,93 @@ public class GeckoAPI extends AbstractGeckoAPI {
NetworkHandler.sendToAll(new CPacketSyncTileManualAnim(scriptedBlock.getMCTileEntity(), unwrap(builder)));
}
// private CustomItemModelData getOrCreateCIMD(ScriptCustomItem item){
// IScriptCustomItem scriptCustomItem = (IScriptCustomItem) item;
// if(!scriptCustomItem.hasCustomModel()){
// scriptCustomItem.setCustomModelData(new CustomItemModelData());
// }
// return scriptCustomItem.getCustomModelData();
// }
//
// @Override
// public void setModel(ScriptCustomItem item, String model) {
// CustomItemModelData data = getOrCreateCIMD(item);
// data.setModel(model);
// item.saveItemData();
// }
//
// @Override
// public void setTexture(ScriptCustomItem item, String texture) {
// CustomItemModelData data = getOrCreateCIMD(item);
// data.setTexture(texture);
// item.saveItemData();
// }
//
// @Override
// public void setAnimationFile(ScriptCustomItem item, String animation) {
// CustomItemModelData data = getOrCreateCIMD(item);
// data.setAnimFile(animation);
// item.saveItemData();
// }
//
// @Override
// public void setIdleAnimation(ScriptCustomItem item, String animation) {
// CustomItemModelData data = getOrCreateCIMD(item);
// data.setIdleAnim(animation);
// item.saveItemData();
// }
// ========================================================================
// Item Methods
// ========================================================================
private CustomItemModelData getOrCreateItemModelData(IItemCustomizable item) {
if (!(item instanceof IScriptCustomItem)) {
throw new IllegalArgumentException("Item does not support gecko models. Must be a Scripted or Linked item.");
}
IScriptCustomItem scriptItem = (IScriptCustomItem) item;
if (!scriptItem.hasCustomModel()) {
scriptItem.setCustomModelData(new CustomItemModelData());
}
return scriptItem.getCustomModelData();
}
@Override
public void setItemModel(IItemCustomizable item, String model) {
CustomItemModelData data = getOrCreateItemModelData(item);
data.setModel(model);
((ScriptCustomizableItem) item).saveItemData();
}
@Override
public void setItemTexture(IItemCustomizable item, String texture) {
CustomItemModelData data = getOrCreateItemModelData(item);
data.setTexture(texture);
((ScriptCustomizableItem) item).saveItemData();
}
@Override
public void setItemAnimationFile(IItemCustomizable item, String animation) {
CustomItemModelData data = getOrCreateItemModelData(item);
data.setAnimFile(animation);
((ScriptCustomizableItem) item).saveItemData();
}
@Override
public void setItemIdleAnimation(IItemCustomizable item, String animation) {
CustomItemModelData data = getOrCreateItemModelData(item);
data.setIdleAnim(animation);
((ScriptCustomizableItem) item).saveItemData();
}
@Override
public boolean hasItemModel(IItemCustomizable item) {
if (!(item instanceof IScriptCustomItem)) {
return false;
}
return ((IScriptCustomItem) item).hasCustomModel();
}
@Override
public void clearItemModel(IItemCustomizable item) {
if (item instanceof IScriptCustomItem) {
((IScriptCustomItem) item).setCustomModelData(null);
((ScriptCustomizableItem) item).saveItemData();
}
}
@Override
public void setDisplayJSON(IItemCustomizable item, String displayFile) {
CustomItemModelData data = getOrCreateItemModelData(item);
data.setDisplayFile(displayFile);
((ScriptCustomizableItem) item).saveItemData();
}
@Override
public String[] getDisplayFileList() {
return ItemDisplayLibrary.instance.getFileNames();
}
@Override
public void setItemDisplay(IItemCustomizable item, String context,
float tx, float ty, float tz,
float rx, float ry, float rz,
float sx, float sy, float sz) {
CustomItemModelData data = getOrCreateItemModelData(item);
ItemDisplayTransform transform = new ItemDisplayTransform(tx, ty, tz, rx, ry, rz, sx, sy, sz);
switch (context.toLowerCase()) {
case "first_person": data.setFirstPerson(transform); break;
case "third_person": data.setThirdPerson(transform); break;
case "inventory": data.setInventory(transform); break;
case "ground": data.setGround(transform); break;
default:
throw new IllegalArgumentException("Unknown display context: " + context
+ ". Use: first_person, third_person, inventory, ground");
}
((ScriptCustomizableItem) item).saveItemData();
}
}
@@ -0,0 +1,116 @@
package com.goodbird.npcgecko.client;
import com.goodbird.npcgecko.data.ItemDisplayData;
import com.goodbird.npcgecko.data.ItemDisplayTransform;
import net.minecraft.util.ResourceLocation;
import software.bernie.geckolib3.file.ItemDisplayFile;
import software.bernie.geckolib3.resource.GeckoLibCache;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Reads item display data from GeckoLibCache (which handles loading from
* resource packs and server-to-client syncing).
*
* <p>Display JSONs are looked up by filename (e.g. "sword.json"), which is
* explicitly assigned to items via {@code GeckoAPI.setDisplayJSON(item, "sword.json")}.</p>
*/
public class ItemDisplayLoader {
private static final ItemDisplayLoader INSTANCE = new ItemDisplayLoader();
public static ItemDisplayLoader getInstance() {
return INSTANCE;
}
/**
* Look up display data by filename (e.g. "sword.json").
* Searches all loaded item display files in GeckoLibCache for a matching filename.
*/
public ItemDisplayData getDisplayData(String filename) {
if (filename == null || filename.isEmpty()) return null;
HashMap<ResourceLocation, ItemDisplayFile> displays = GeckoLibCache.getInstance().getItemDisplays();
for (Map.Entry<ResourceLocation, ItemDisplayFile> entry : displays.entrySet()) {
String path = entry.getKey().getResourcePath();
String entryFilename = path.contains("/") ? path.substring(path.lastIndexOf('/') + 1) : path;
if (entryFilename.equals(filename)) {
return convert(entry.getValue());
}
}
return null;
}
/**
* Get all loaded display file names.
*/
public String[] getDisplayFileList() {
HashMap<ResourceLocation, ItemDisplayFile> displays = GeckoLibCache.getInstance().getItemDisplays();
List<String> names = new ArrayList<>();
for (ResourceLocation loc : displays.keySet()) {
String path = loc.getResourcePath();
String filename = path.contains("/") ? path.substring(path.lastIndexOf('/') + 1) : path;
names.add(filename);
}
return names.toArray(new String[0]);
}
/**
* Convert GeckoLib's ItemDisplayFile to the addon's ItemDisplayData.
*/
private ItemDisplayData convert(ItemDisplayFile file) {
ItemDisplayData data = new ItemDisplayData();
if (file.hasFirstPerson()) {
data.setFirstPerson(convertTransform(
file.getFirstPersonTranslation(),
file.getFirstPersonRotation(),
file.getFirstPersonScale()));
}
if (file.hasThirdPerson()) {
data.setThirdPerson(convertTransform(
file.getThirdPersonTranslation(),
file.getThirdPersonRotation(),
file.getThirdPersonScale()));
}
if (file.hasInventory()) {
data.setInventory(convertTransform(
file.getInventoryTranslation(),
file.getInventoryRotation(),
file.getInventoryScale()));
}
if (file.hasGround()) {
data.setGround(convertTransform(
file.getGroundTranslation(),
file.getGroundRotation(),
file.getGroundScale()));
}
return data;
}
/**
* Convert Blockbench/modern MC display values to 1.7.10 GL units.
* - Translation: multiplied by 0.0625 (÷16) matching modern MC deserialization
* - Rotation Y: offset by -90° to cancel GeoItemStackRenderer's built-in rotate(90, Y)
* - Scale: used directly
*/
private ItemDisplayTransform convertTransform(float[] translation, float[] rotation, float[] scale) {
ItemDisplayTransform t = new ItemDisplayTransform();
if (translation != null) {
t.setTranslation(
translation[0] * 0.0625F,
translation[1] * 0.0625F,
translation[2] * 0.0625F);
}
if (rotation != null) {
t.setRotation(rotation[0], rotation[1], rotation[2]);
}
if (scale != null) {
t.setScale(scale[0], scale[1], scale[2]);
}
return t;
}
}
@@ -0,0 +1,187 @@
package com.goodbird.npcgecko.client;
import com.goodbird.npcgecko.client.model.ItemModelCustom;
import com.goodbird.npcgecko.data.CustomItemModelData;
import com.goodbird.npcgecko.data.ItemDisplayData;
import com.goodbird.npcgecko.data.ItemDisplayTransform;
import com.goodbird.npcgecko.mixin.IScriptCustomItem;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import noppes.npcs.api.item.IItemCustomizable;
import noppes.npcs.api.item.IItemStack;
import noppes.npcs.scripted.NpcAPI;
import org.lwjgl.opengl.GL11;
import scala.tools.nsc.doc.base.comment.Inline;
import software.bernie.geckolib3.item.AnimatableStackWrapper;
import software.bernie.geckolib3.renderers.geo.GeoItemStackRenderer;
public class ModelItemRenderUtil {
private static final GeoItemStackRenderer RENDERER = new GeoItemStackRenderer(new ItemModelCustom());
/**
* Quick check if an ItemStack has a gecko model attached.
* Used by the shouldUseRenderHelper mixin to route gecko items
* through the EQUIPPED_BLOCK path in ForgeHooksClient.
*/
public static boolean hasGeckoModel(ItemStack itemStack) {
IItemStack iItemStack = NpcAPI.Instance().getIItemStack(itemStack);
if (!(iItemStack instanceof IItemCustomizable)) return false;
if (!(iItemStack instanceof IScriptCustomItem)) return false;
return ((IScriptCustomItem) iItemStack).hasCustomModel();
}
/**
* Attempts to render a gecko model for the given item.
* Returns true if rendering was handled, false if the item has no gecko model.
*
* With shouldUseRenderHelper returning true for EQUIPPED_BLOCK,
* ForgeHooksClient only applies translate(-0.5, -0.5, -0.5) before calling us.
* Our per-type defaults below match GeoItemRenderer.renderItem() transforms.
* GeoItemStackRenderer.render() then applies the standard GeckoLib transforms
* (translate 0.5,0.5,0.5 + rotate 90 Y) matching GeoItemRenderer.render().
*/
public static boolean tryRender(ItemRenderType type, ItemStack itemStack) {
IItemStack iItemStack = NpcAPI.Instance().getIItemStack(itemStack);
if (!(iItemStack instanceof IItemCustomizable)) return false;
IItemCustomizable scriptCustomItem = (IItemCustomizable) iItemStack;
if (!(scriptCustomItem instanceof IScriptCustomItem)) return false;
IScriptCustomItem geckoItem = (IScriptCustomItem) scriptCustomItem;
if (!geckoItem.hasCustomModel()) return false;
CustomItemModelData modelData = geckoItem.getCustomModelData();
AnimatableStackWrapper wrapper = AnimatableStackWrapper.of(itemStack).withUserData(modelData);
ItemDisplayTransform transform = resolveTransform(modelData, scriptCustomItem, type);
// Reset Resetting to the Upper Stack
GL11.glPushMatrix();
applyTranslate(transform, type);
applyRotate(transform, type);
applyScale(transform, type);
if(type == ItemRenderType.INVENTORY)
RenderHelper.disableStandardItemLighting();
RENDERER.render(wrapper, itemStack);
if(type == ItemRenderType.INVENTORY)
RenderHelper.enableStandardItemLighting();
GL11.glPopMatrix();
return true;
}
public static void applyTranslate(ItemDisplayTransform t, ItemRenderType type) {
// Inline per-context defaults
switch (type) {
case EQUIPPED_FIRST_PERSON:
GL11.glTranslatef(0.5F, 0.55F, 0.5F);
break;
case EQUIPPED:
GL11.glTranslatef(0F, -0.7F, 0F);
break;
case INVENTORY:
GL11.glTranslatef(0F, 0.05F, 0F);
break;
case ENTITY:
GL11.glTranslatef(0F, 0.0F, 0F);
break;
default:
break;
}
if (t != null && t.hasTranslation()) {
GL11.glTranslatef(t.getTranslateX(), t.getTranslateY(), t.getTranslateZ());
}
}
public static void applyRotate(ItemDisplayTransform t, ItemRenderType type) {
switch (type) {
case EQUIPPED_FIRST_PERSON:
GL11.glRotatef(-45F, 0.0F, 1.0F, 0.0F);
break;
case EQUIPPED:
break;
case INVENTORY:
GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(30F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(175F, 0.0F, 1.0F, 0.0F);
break;
case ENTITY:
break;
default:
break;
}
if (t != null && t.hasRotation()) {
GL11.glRotatef(t.getRotationY(), 0.0F, 1.0F, 0.0F);
GL11.glRotatef(t.getRotationX(), 1.0F, 0.0F, 0.0F);
GL11.glRotatef(t.getRotationZ(), 0.0F, 0.0F, 1.0F);
}
}
public static void applyScale(ItemDisplayTransform t, ItemRenderType type) {
switch (type) {
case EQUIPPED_FIRST_PERSON:
float scale = 2.36f;
GL11.glScalef(scale, scale, scale);
break;
case EQUIPPED:
//GL11.glScalef(0F, -0.5F, 0F);
break;
case INVENTORY:
scale = 1.65f;
GL11.glScalef(scale, scale, scale);
break;
case ENTITY:
//GL11.glScalef(0F, -0.5F, 0F);
break;
default:
break;
}
if (t != null && t.hasScale()) {
GL11.glScalef(t.getScaleX(), t.getScaleY(), t.getScaleZ());
}
// No per-context default scale — GeoItemRenderer doesn't scale per type
}
/**
* Resolves the display transform for a given render context.
* Priority:
* 1) Per-item NBT override (set via setItemDisplay)
* 2) Display JSON file (set via setDisplayJSON)
* 3) null — let the apply methods use their inline defaults
*/
public static ItemDisplayTransform resolveTransform(
CustomItemModelData modelData, IItemCustomizable item, ItemRenderType type) {
// 1) Per-item NBT override
ItemDisplayTransform nbtTransform = null;
switch (type) {
case EQUIPPED_FIRST_PERSON: nbtTransform = modelData.getFirstPerson(); break;
case EQUIPPED: nbtTransform = modelData.getThirdPerson(); break;
case INVENTORY: nbtTransform = modelData.getInventory(); break;
case ENTITY: nbtTransform = modelData.getGround(); break;
default: break;
}
if (nbtTransform != null) return nbtTransform;
// 2) Display JSON file (explicitly assigned via setDisplayJSON)
String displayFile = modelData.getDisplayFile();
if (displayFile != null && !displayFile.isEmpty()) {
ItemDisplayData fileData = ItemDisplayLoader.getInstance().getDisplayData(displayFile);
if (fileData != null) {
switch (type) {
case EQUIPPED_FIRST_PERSON: return fileData.getFirstPerson();
case EQUIPPED: return fileData.getThirdPerson();
case INVENTORY: return fileData.getInventory();
case ENTITY: return fileData.getGround();
default: break;
}
}
}
// 3) No transform found — apply methods will use inline defaults
return null;
}
}
@@ -1,53 +1,70 @@
// TODO: Fix ScriptCustomItem
package com.goodbird.npcgecko.client.model;
//package com.goodbird.npcgecko.client.model;
//
//import com.goodbird.npcgecko.data.CustomItemModelData;
//import com.goodbird.npcgecko.mixin.IScriptCustomItem;
//import net.minecraft.util.ResourceLocation;
//import noppes.npcs.api.item.IItemStack;
//import noppes.npcs.scripted.NpcAPI;
//import noppes.npcs.scripted.item.ScriptCustomItem;
//import software.bernie.geckolib3.resource.GeckoLibCache;
//
//public class ItemModelCustom extends AnimatedGeoModel<AnimatableStackWrapper> {
//
// private CustomItemModelData getModelData(AnimatableStackWrapper animatable){
// IItemStack istack = NpcAPI.Instance().getIItemStack(animatable.getStack());
// if(!(istack instanceof ScriptCustomItem)) return null;
// return ((IScriptCustomItem)istack).getCustomModelData();
// }
//
// @Override
// public ResourceLocation getAnimationFileLocation(AnimatableStackWrapper animatable) {
// CustomItemModelData data = getModelData(animatable);
// if(data==null || !GeckoLibCache.getInstance().getAnimations().containsKey(new ResourceLocation(data.getAnimFile()))){
// return new ResourceLocation("npcgecko","animations/none.animations.json");
// }
// return new ResourceLocation(data.getAnimFile());
// }
//
// @Override
// public ResourceLocation getModelLocation(AnimatableStackWrapper animatable) {
// CustomItemModelData data = getModelData(animatable);
// if(data==null || !GeckoLibCache.getInstance().getGeoModels().containsKey(new ResourceLocation(data.getModel()))){
// return new ResourceLocation("npcgecko","geo/modelnotfound.geo.json");
// }
// if(!GeckoLibCache.getInstance().getAnimations().containsKey(new ResourceLocation(data.getAnimFile()))){
// return new ResourceLocation("npcgecko","geo/animfilenotfound.geo.json");
// }
// return new ResourceLocation(data.getModel());
// }
//
// @Override
// public ResourceLocation getTextureLocation(AnimatableStackWrapper animatable) {
// CustomItemModelData data = getModelData(animatable);
// if(data==null || !GeckoLibCache.getInstance().getGeoModels().containsKey(new ResourceLocation(data.getModel()))){
// return new ResourceLocation("npcgecko","textures/model/alphabet.png");
// }
// if(!GeckoLibCache.getInstance().getAnimations().containsKey(new ResourceLocation(data.getAnimFile()))){
// return new ResourceLocation("npcgecko","textures/model/alphabet.png");
// }
// return new ResourceLocation(data.getTexture());
// }
//}
import com.goodbird.npcgecko.data.CustomItemModelData;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import software.bernie.geckolib3.item.AnimatableStackWrapper;
import software.bernie.geckolib3.model.AnimatedGeoModel;
import software.bernie.geckolib3.resource.GeckoLibCache;
public class ItemModelCustom extends AnimatedGeoModel<AnimatableStackWrapper> {
private CustomItemModelData getModelData(AnimatableStackWrapper animatable) {
// Primary: read from userData attached by the mixin renderer
Object userData = animatable.getUserData();
if (userData instanceof CustomItemModelData) {
return (CustomItemModelData) userData;
}
// Fallback: read directly from ItemStack NBT
if (animatable.getStack() != null && animatable.getStack().hasTagCompound()) {
NBTTagCompound root = animatable.getStack().getTagCompound();
if (root.hasKey("ItemData")) {
NBTTagCompound itemData = root.getCompoundTag("ItemData");
if (itemData.hasKey("GeckoModelData")) {
CustomItemModelData data = new CustomItemModelData();
data.readFromNBT(itemData.getCompoundTag("GeckoModelData"));
return data;
}
}
}
return null;
}
@Override
public ResourceLocation getAnimationFileLocation(AnimatableStackWrapper animatable) {
CustomItemModelData data = getModelData(animatable);
if (data == null || data.getAnimFile() == null || data.getAnimFile().isEmpty()
|| !GeckoLibCache.getInstance().getAnimations().containsKey(new ResourceLocation(data.getAnimFile()))) {
return new ResourceLocation("npcgecko", "animations/none.animations.json");
}
return new ResourceLocation(data.getAnimFile());
}
@Override
public ResourceLocation getModelLocation(AnimatableStackWrapper animatable) {
CustomItemModelData data = getModelData(animatable);
if (data == null || data.getModel() == null || data.getModel().isEmpty()
|| !GeckoLibCache.getInstance().getGeoModels().containsKey(new ResourceLocation(data.getModel()))) {
return new ResourceLocation("npcgecko", "geo/modelnotfound.geo.json");
}
if (data.getAnimFile() == null || data.getAnimFile().isEmpty()
|| !GeckoLibCache.getInstance().getAnimations().containsKey(new ResourceLocation(data.getAnimFile()))) {
return new ResourceLocation("npcgecko", "geo/animfilenotfound.geo.json");
}
return new ResourceLocation(data.getModel());
}
@Override
public ResourceLocation getTextureLocation(AnimatableStackWrapper animatable) {
CustomItemModelData data = getModelData(animatable);
if (data == null || data.getModel() == null || data.getModel().isEmpty()
|| !GeckoLibCache.getInstance().getGeoModels().containsKey(new ResourceLocation(data.getModel()))) {
return new ResourceLocation("npcgecko", "textures/model/alphabet.png");
}
if (data.getAnimFile() == null || data.getAnimFile().isEmpty()
|| !GeckoLibCache.getInstance().getAnimations().containsKey(new ResourceLocation(data.getAnimFile()))) {
return new ResourceLocation("npcgecko", "textures/model/alphabet.png");
}
return new ResourceLocation(data.getTexture());
}
}
@@ -3,12 +3,21 @@ package com.goodbird.npcgecko.data;
import net.minecraft.nbt.NBTTagCompound;
public class CustomItemModelData {
private String model = "geckolib3:geo/npc.geo.json";
private String animFile = "custom:geo_npc.animation.json";
private String texture = "geckolib3:textures/item/jack.png";
private String idleAnim = "";
private String model = "geckolib3:geo/sword.geo.json";
private String animFile = "geckolib3:animations/sword.animation.json";
private String texture = "geckolib3:textures/model/sword.png";
private String idleAnim = "animation.sword.idle";
private int transitionLengthTicks = 10;
// Display JSON filename from item_displays/ (e.g. "sword.json"). Null = auto-match by model.
private String displayFile = "";
// Per-context display transforms (null = use defaults)
private ItemDisplayTransform firstPerson;
private ItemDisplayTransform thirdPerson;
private ItemDisplayTransform inventory;
private ItemDisplayTransform ground;
public CustomItemModelData() {
}
@@ -18,6 +27,19 @@ public class CustomItemModelData {
nbttagcompound.setString("IdleAnim", idleAnim);
nbttagcompound.setString("Texture", texture);
nbttagcompound.setInteger("TransitionLengthTicks", transitionLengthTicks);
if (displayFile != null && !displayFile.isEmpty()) {
nbttagcompound.setString("DisplayFile", displayFile);
}
NBTTagCompound displayTag = new NBTTagCompound();
if (firstPerson != null) displayTag.setTag("FirstPerson", firstPerson.writeToNBT(new NBTTagCompound()));
if (thirdPerson != null) displayTag.setTag("ThirdPerson", thirdPerson.writeToNBT(new NBTTagCompound()));
if (inventory != null) displayTag.setTag("Inventory", inventory.writeToNBT(new NBTTagCompound()));
if (ground != null) displayTag.setTag("Ground", ground.writeToNBT(new NBTTagCompound()));
if (!displayTag.hasNoTags()) {
nbttagcompound.setTag("Display", displayTag);
}
return nbttagcompound;
}
@@ -30,46 +52,65 @@ public class CustomItemModelData {
if (nbttagcompound.hasKey("TransitionLengthTicks")) {
transitionLengthTicks = nbttagcompound.getInteger("TransitionLengthTicks");
}
if (nbttagcompound.hasKey("DisplayFile")) {
displayFile = nbttagcompound.getString("DisplayFile");
}
}
if (nbttagcompound.hasKey("Display")) {
NBTTagCompound displayTag = nbttagcompound.getCompoundTag("Display");
if (displayTag.hasKey("FirstPerson")) {
firstPerson = new ItemDisplayTransform();
firstPerson.readFromNBT(displayTag.getCompoundTag("FirstPerson"));
}
if (displayTag.hasKey("ThirdPerson")) {
thirdPerson = new ItemDisplayTransform();
thirdPerson.readFromNBT(displayTag.getCompoundTag("ThirdPerson"));
}
if (displayTag.hasKey("Inventory")) {
inventory = new ItemDisplayTransform();
inventory.readFromNBT(displayTag.getCompoundTag("Inventory"));
}
if (displayTag.hasKey("Ground")) {
ground = new ItemDisplayTransform();
ground.readFromNBT(displayTag.getCompoundTag("Ground"));
}
}
}
public String getModel() {
return model;
}
// --- Display transforms ---
public void setModel(String model) {
this.model = model;
}
public ItemDisplayTransform getFirstPerson() { return firstPerson; }
public void setFirstPerson(ItemDisplayTransform t) { this.firstPerson = t; }
public String getAnimFile() {
return animFile;
}
public ItemDisplayTransform getThirdPerson() { return thirdPerson; }
public void setThirdPerson(ItemDisplayTransform t) { this.thirdPerson = t; }
public void setAnimFile(String animFile) {
this.animFile = animFile;
}
public ItemDisplayTransform getInventory() { return inventory; }
public void setInventory(ItemDisplayTransform t) { this.inventory = t; }
public String getIdleAnim() {
return idleAnim;
}
public ItemDisplayTransform getGround() { return ground; }
public void setGround(ItemDisplayTransform t) { this.ground = t; }
public void setIdleAnim(String idleAnim) {
this.idleAnim = idleAnim;
}
// --- Display file ---
public int getTransitionLengthTicks() {
return transitionLengthTicks;
}
public String getDisplayFile() { return displayFile; }
public void setDisplayFile(String displayFile) { this.displayFile = displayFile != null ? displayFile : ""; }
public void setTransitionLengthTicks(int transitionLengthTicks) {
this.transitionLengthTicks = transitionLengthTicks;
}
// --- Existing getters/setters ---
public String getTexture() {
return texture;
}
public String getModel() { return model; }
public void setModel(String model) { this.model = model; }
public void setTexture(String texture) {
this.texture = texture;
}
public String getAnimFile() { return animFile; }
public void setAnimFile(String animFile) { this.animFile = animFile; }
public String getIdleAnim() { return idleAnim; }
public void setIdleAnim(String idleAnim) { this.idleAnim = idleAnim; }
public int getTransitionLengthTicks() { return transitionLengthTicks; }
public void setTransitionLengthTicks(int transitionLengthTicks) { this.transitionLengthTicks = transitionLengthTicks; }
public String getTexture() { return texture; }
public void setTexture(String texture) { this.texture = texture; }
}
@@ -0,0 +1,37 @@
package com.goodbird.npcgecko.data;
/**
* Holds per-context display transforms for a gecko item model.
* Loaded from JSON files in assets/{domain}/item_displays/.
* <p>
* JSON format:
* <pre>
* {
* "model": "npcgecko:geo/sword.geo.json",
* "display": {
* "first_person": { "translation": [x,y,z], "rotation": [x,y,z], "scale": [x,y,z] },
* "third_person": { "translation": [x,y,z], "rotation": [x,y,z], "scale": [x,y,z] },
* "inventory": { "translation": [x,y,z], "rotation": [x,y,z], "scale": [x,y,z] },
* "ground": { "translation": [x,y,z], "rotation": [x,y,z], "scale": [x,y,z] }
* }
* }
* </pre>
*/
public class ItemDisplayData {
private ItemDisplayTransform firstPerson;
private ItemDisplayTransform thirdPerson;
private ItemDisplayTransform inventory;
private ItemDisplayTransform ground;
public ItemDisplayTransform getFirstPerson() { return firstPerson; }
public void setFirstPerson(ItemDisplayTransform t) { this.firstPerson = t; }
public ItemDisplayTransform getThirdPerson() { return thirdPerson; }
public void setThirdPerson(ItemDisplayTransform t) { this.thirdPerson = t; }
public ItemDisplayTransform getInventory() { return inventory; }
public void setInventory(ItemDisplayTransform t) { this.inventory = t; }
public ItemDisplayTransform getGround() { return ground; }
public void setGround(ItemDisplayTransform t) { this.ground = t; }
}
@@ -0,0 +1,85 @@
package com.goodbird.npcgecko.data;
import net.minecraft.nbt.NBTTagCompound;
/**
* Per-context display transform for gecko item models.
* Stores translation, rotation, and scale for a single render context
* (first_person, third_person, inventory, ground).
*/
public class ItemDisplayTransform {
private float translateX, translateY, translateZ;
private float rotationX, rotationY, rotationZ;
private float scaleX = 1.0F, scaleY = 1.0F, scaleZ = 1.0F;
private boolean hasTranslation;
private boolean hasRotation;
private boolean hasScale;
public ItemDisplayTransform() {
}
public ItemDisplayTransform(float tx, float ty, float tz,
float rx, float ry, float rz,
float sx, float sy, float sz) {
this.translateX = tx; this.translateY = ty; this.translateZ = tz;
this.rotationX = rx; this.rotationY = ry; this.rotationZ = rz;
this.scaleX = sx; this.scaleY = sy; this.scaleZ = sz;
this.hasTranslation = true;
this.hasRotation = true;
this.hasScale = true;
}
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
tag.setFloat("TX", translateX);
tag.setFloat("TY", translateY);
tag.setFloat("TZ", translateZ);
tag.setFloat("RX", rotationX);
tag.setFloat("RY", rotationY);
tag.setFloat("RZ", rotationZ);
tag.setFloat("SX", scaleX);
tag.setFloat("SY", scaleY);
tag.setFloat("SZ", scaleZ);
return tag;
}
public void readFromNBT(NBTTagCompound tag) {
translateX = tag.getFloat("TX");
translateY = tag.getFloat("TY");
translateZ = tag.getFloat("TZ");
rotationX = tag.getFloat("RX");
rotationY = tag.getFloat("RY");
rotationZ = tag.getFloat("RZ");
scaleX = tag.getFloat("SX");
scaleY = tag.getFloat("SY");
scaleZ = tag.getFloat("SZ");
}
public float getTranslateX() { return translateX; }
public float getTranslateY() { return translateY; }
public float getTranslateZ() { return translateZ; }
public float getRotationX() { return rotationX; }
public float getRotationY() { return rotationY; }
public float getRotationZ() { return rotationZ; }
public float getScaleX() { return scaleX; }
public float getScaleY() { return scaleY; }
public float getScaleZ() { return scaleZ; }
public void setTranslation(float x, float y, float z) {
this.translateX = x; this.translateY = y; this.translateZ = z;
this.hasTranslation = true;
}
public void setRotation(float x, float y, float z) {
this.rotationX = x; this.rotationY = y; this.rotationZ = z;
this.hasRotation = true;
}
public void setScale(float x, float y, float z) {
this.scaleX = x; this.scaleY = y; this.scaleZ = z;
this.hasScale = true;
}
public boolean hasTranslation() { return hasTranslation; }
public boolean hasRotation() { return hasRotation; }
public boolean hasScale() { return hasScale; }
}
@@ -1,11 +1,12 @@
package com.goodbird.npcgecko.item;
import com.goodbird.npcgecko.data.CustomItemModelData;
import com.goodbird.npcgecko.mixin.IScriptCustomItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import noppes.npcs.api.item.IItemCustomizable;
import noppes.npcs.api.item.IItemStack;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.item.ScriptCustomItem;
import software.bernie.geckolib3.core.IAnimatable;
import software.bernie.geckolib3.core.PlayState;
import software.bernie.geckolib3.core.builder.AnimationBuilder;
@@ -15,9 +16,14 @@ public class ItemCustomModelPredicate {
public static <P extends Item & IAnimatable> PlayState predicate(AnimationEvent<P> event) {
ItemStack stack = (ItemStack) event.getExtraData().get(0);
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
if (!(istack instanceof ScriptCustomItem)) return PlayState.STOP;
if (!(istack instanceof IItemCustomizable)) return PlayState.STOP;
if (!(istack instanceof IScriptCustomItem)) return PlayState.STOP;
IScriptCustomItem item = (IScriptCustomItem) istack;
event.getController().setAnimation(new AnimationBuilder().loop(item.getCustomModelData().getIdleAnim()));
CustomItemModelData data = item.getCustomModelData();
if (data == null) return PlayState.STOP;
String idleAnim = data.getIdleAnim();
if (idleAnim == null || idleAnim.isEmpty()) return PlayState.STOP;
event.getController().setAnimation(new AnimationBuilder().loop(idleAnim));
return PlayState.CONTINUE;
}
}
@@ -1,54 +1,43 @@
// TODO: Fix ScriptCustomItem
package com.goodbird.npcgecko.mixin.impl;
//package com.goodbird.npcgecko.mixin.impl;
//
//import com.goodbird.npcgecko.client.model.ItemModelCustom;
//import com.goodbird.npcgecko.mixin.IScriptCustomItem;
//import net.minecraft.entity.EntityLivingBase;
//import net.minecraft.entity.item.EntityItem;
//import net.minecraft.item.ItemStack;
//import noppes.npcs.client.renderer.items.CustomItemRenderer;
//import noppes.npcs.scripted.item.ScriptCustomItem;
//import org.lwjgl.opengl.GL11;
//import org.spongepowered.asm.mixin.Mixin;
//import org.spongepowered.asm.mixin.Unique;
//import org.spongepowered.asm.mixin.injection.At;
//import org.spongepowered.asm.mixin.injection.Inject;
//import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
//import software.bernie.geckolib3.item.AnimatableStackWrapper;
//import software.bernie.geckolib3.renderers.geo.GeoItemStackRenderer;
//
//@Mixin(CustomItemRenderer.class)
//public class MixinCustomItemRenderer {
// @Unique
// private static GeoItemStackRenderer renderer = new GeoItemStackRenderer(new ItemModelCustom());
//
// @Inject(method = "renderEntityCustomItem", cancellable = true, at=@At("HEAD"), remap = false)
// public void renderEntityCustomItem(ScriptCustomItem scriptCustomItem, ItemStack itemStack, EntityItem entityItem, CallbackInfo ci) {
// if(((IScriptCustomItem)scriptCustomItem).hasCustomModel()){
// renderer.render(AnimatableStackWrapper.wrapItemStack(itemStack), itemStack);
// ci.cancel();
// }
// }
//
// @Inject(method = "renderInventoryCustomItem", cancellable = true, at=@At("HEAD"), remap = false)
// public void renderInventoryCustomItem(ScriptCustomItem scriptCustomItem, CallbackInfo ci){
// if(((IScriptCustomItem)scriptCustomItem).hasCustomModel()){
// GL11.glPushMatrix();
// GL11.glTranslated(-1.0, -1.0, 0.0);
// GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
// renderer.render(AnimatableStackWrapper.wrapItemStack(scriptCustomItem.item), scriptCustomItem.item);
// GL11.glPopMatrix();
// ci.cancel();
// }
// }
//
// @Inject(method = "renderItem3d", cancellable = true, at=@At("HEAD"), remap = false)
// public void renderItem3d(ScriptCustomItem scriptCustomItem, EntityLivingBase entityLivingBase, ItemStack itemStack, CallbackInfo ci) {
// if(((IScriptCustomItem)scriptCustomItem).hasCustomModel()){
// renderer.render(AnimatableStackWrapper.wrapItemStack(itemStack), itemStack);
// ci.cancel();
// }
// }
//
//}
import com.goodbird.npcgecko.client.ModelItemRenderUtil;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import net.minecraftforge.client.IItemRenderer.ItemRendererHelper;
import noppes.npcs.client.renderer.items.ItemCustomRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ItemCustomRenderer.class)
public class MixinCustomItemRenderer {
@Inject(
method = "shouldUseRenderHelper",
cancellable = true,
at = @At("HEAD"),
remap = false
)
public void shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper, CallbackInfoReturnable<Boolean> cir) {
if (ModelItemRenderUtil.hasGeckoModel(item)) {
// Return true for all helpers, matching GeoItemRenderer behavior.
// EQUIPPED_BLOCK → simple translate(-0.5) path in ForgeHooksClient
// INVENTORY_BLOCK → 3D isometric inventory rendering
cir.setReturnValue(true);
}
}
@Inject(
method = "renderItem(Lnet/minecraftforge/client/IItemRenderer$ItemRenderType;Lnet/minecraft/item/ItemStack;[Ljava/lang/Object;)V",
cancellable = true,
at = @At("HEAD"),
remap = false
)
public void renderItem(ItemRenderType type, ItemStack itemStack, Object[] data, CallbackInfo ci) {
if (ModelItemRenderUtil.tryRender(type, itemStack)) {
ci.cancel();
}
}
}
@@ -0,0 +1,30 @@
package com.goodbird.npcgecko.mixin.impl;
import com.goodbird.npcgecko.item.ItemCustomModelPredicate;
import net.minecraft.item.Item;
import noppes.npcs.items.ItemLinked;
import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import software.bernie.geckolib3.core.IAnimatable;
import software.bernie.geckolib3.core.controller.AnimationController;
import software.bernie.geckolib3.core.manager.AnimationData;
import software.bernie.geckolib3.core.manager.AnimationFactory;
@Mixin(ItemLinked.class)
@Implements(value = @Interface(iface = IAnimatable.class, prefix = "customNPC_Gecko_Addon$"))
public abstract class MixinItemLinked extends Item implements IAnimatable {
@Unique
public AnimationFactory customNPC_Gecko_Addon$factory = new AnimationFactory(this);
@Unique
public void customNPC_Gecko_Addon$registerControllers(AnimationData data) {
data.addAnimationController(new AnimationController<>(this, "controller", 20, ItemCustomModelPredicate::predicate));
}
@Unique
public AnimationFactory customNPC_Gecko_Addon$getFactory() {
return this.customNPC_Gecko_Addon$factory;
}
}
@@ -1,51 +1,50 @@
// TODO: Fix ScriptCustomItem
//package com.goodbird.npcgecko.mixin.impl;
//
//import com.goodbird.npcgecko.data.CustomItemModelData;
//import com.goodbird.npcgecko.mixin.IScriptCustomItem;
//import net.minecraft.nbt.NBTTagCompound;
//import noppes.npcs.scripted.item.ScriptCustomItem;
//import org.spongepowered.asm.mixin.Mixin;
//import org.spongepowered.asm.mixin.Unique;
//import org.spongepowered.asm.mixin.injection.At;
//import org.spongepowered.asm.mixin.injection.Inject;
//import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
//import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
//
//@Mixin(ScriptCustomItem.class)
//public class MixinScriptCustomItem implements IScriptCustomItem {
// @Unique
// private CustomItemModelData customNPC_Gecko_Addon$customModelData;
//
// @Inject(method = "getItemNBT", at = @At("HEAD"), remap = false)
// public void writeToNBT(NBTTagCompound nbttagcompound, CallbackInfoReturnable<NBTTagCompound> cir) {
// if(customNPC_Gecko_Addon$customModelData!=null){
// NBTTagCompound modelDataTag = new NBTTagCompound();
// customNPC_Gecko_Addon$customModelData.writeToNBT(modelDataTag);
// nbttagcompound.setTag("GeckoModelData", modelDataTag);
// }
// }
//
// @Inject(method = "setItemNBT", at = @At("HEAD"), remap = false)
// public void readFromNBT(NBTTagCompound nbttagcompound, CallbackInfo ci){
// if(nbttagcompound.hasKey("GeckoModelData")){
// customNPC_Gecko_Addon$customModelData = new CustomItemModelData();
// customNPC_Gecko_Addon$customModelData.readFromNBT(nbttagcompound.getCompoundTag("GeckoModelData"));
// }
// }
//
// @Unique
// public CustomItemModelData getCustomModelData(){
// return customNPC_Gecko_Addon$customModelData;
// }
//
// @Override
// public void setCustomModelData(CustomItemModelData data) {
// customNPC_Gecko_Addon$customModelData = data;
// }
//
// @Unique
// public boolean hasCustomModel() {
// return customNPC_Gecko_Addon$customModelData!=null;
// }
//}
package com.goodbird.npcgecko.mixin.impl;
import com.goodbird.npcgecko.data.CustomItemModelData;
import com.goodbird.npcgecko.mixin.IScriptCustomItem;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.scripted.item.ScriptCustomItem;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ScriptCustomItem.class)
public class MixinScriptCustomItem implements IScriptCustomItem {
@Unique
private CustomItemModelData customNPC_Gecko_Addon$customModelData;
@Inject(method = "getItemNBT", at = @At("RETURN"), remap = false)
public void writeGeckoData(NBTTagCompound compound, CallbackInfoReturnable<NBTTagCompound> cir) {
if (customNPC_Gecko_Addon$customModelData != null) {
NBTTagCompound modelDataTag = new NBTTagCompound();
customNPC_Gecko_Addon$customModelData.writeToNBT(modelDataTag);
compound.setTag("GeckoModelData", modelDataTag);
}
}
@Inject(method = "setItemNBT", at = @At("RETURN"), remap = false)
public void readGeckoData(NBTTagCompound compound, CallbackInfo ci) {
if (compound.hasKey("GeckoModelData")) {
customNPC_Gecko_Addon$customModelData = new CustomItemModelData();
customNPC_Gecko_Addon$customModelData.readFromNBT(compound.getCompoundTag("GeckoModelData"));
}
}
@Unique
public CustomItemModelData getCustomModelData() {
return customNPC_Gecko_Addon$customModelData;
}
@Override
public void setCustomModelData(CustomItemModelData data) {
customNPC_Gecko_Addon$customModelData = data;
}
@Unique
public boolean hasCustomModel() {
return customNPC_Gecko_Addon$customModelData != null;
}
}
@@ -0,0 +1,50 @@
package com.goodbird.npcgecko.mixin.impl;
import com.goodbird.npcgecko.data.CustomItemModelData;
import com.goodbird.npcgecko.mixin.IScriptCustomItem;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.scripted.item.ScriptLinkedItem;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ScriptLinkedItem.class)
public class MixinScriptLinkedItem implements IScriptCustomItem {
@Unique
private CustomItemModelData customNPC_Gecko_Addon$customModelData;
@Inject(method = "getItemNBT", at = @At("RETURN"), remap = false)
public void writeGeckoData(NBTTagCompound compound, CallbackInfoReturnable<NBTTagCompound> cir) {
if (customNPC_Gecko_Addon$customModelData != null) {
NBTTagCompound modelDataTag = new NBTTagCompound();
customNPC_Gecko_Addon$customModelData.writeToNBT(modelDataTag);
compound.setTag("GeckoModelData", modelDataTag);
}
}
@Inject(method = "setItemNBT", at = @At("RETURN"), remap = false)
public void readGeckoData(NBTTagCompound compound, CallbackInfo ci) {
if (compound.hasKey("GeckoModelData")) {
customNPC_Gecko_Addon$customModelData = new CustomItemModelData();
customNPC_Gecko_Addon$customModelData.readFromNBT(compound.getCompoundTag("GeckoModelData"));
}
}
@Unique
public CustomItemModelData getCustomModelData() {
return customNPC_Gecko_Addon$customModelData;
}
@Override
public void setCustomModelData(CustomItemModelData data) {
customNPC_Gecko_Addon$customModelData = data;
}
@Unique
public boolean hasCustomModel() {
return customNPC_Gecko_Addon$customModelData != null;
}
}