From 5026e30437fb0c4868a56cea747d616ce5392646 Mon Sep 17 00:00:00 2001 From: luisc Date: Thu, 13 Feb 2025 14:48:20 -0600 Subject: [PATCH 1/5] NBT changes to accommodate nullable fields --- java/noppes/npcs/api/item/IItemCustom.java | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/java/noppes/npcs/api/item/IItemCustom.java b/java/noppes/npcs/api/item/IItemCustom.java index 3c2febc..f928e2b 100644 --- a/java/noppes/npcs/api/item/IItemCustom.java +++ b/java/noppes/npcs/api/item/IItemCustom.java @@ -95,37 +95,37 @@ public interface IItemCustom extends IItemStack { * Checks if the durability bar should be shown for the scripted item. * @return True if the durability bar should be shown, false otherwise */ - boolean getDurabilityShow(); + Boolean getDurabilityShow(); /** * Sets whether the durability bar should be shown for the scripted item. * @param durabilityShow True if the durability bar should be shown, false otherwise */ - void setDurabilityShow(boolean durabilityShow); + void setDurabilityShow(Boolean durabilityShow); /** * Gets the color of the durability bar for the scripted item. * @return The durability bar color */ - int getDurabilityColor(); + Integer getDurabilityColor(); /** * Sets the color of the durability bar for the scripted item. * @param durabilityColor The durability bar color */ - void setDurabilityColor(int durabilityColor); + void setDurabilityColor(Integer durabilityColor); /** * Gets the color of the scripted item. * @return The item color */ - int getColor(); + Integer getColor(); /** * Sets the color of the scripted item. * @param color The item color */ - void setColor(int color); + void setColor(Integer color); /** * Gets the maximum item use duration for the scripted item. @@ -169,7 +169,7 @@ public interface IItemCustom extends IItemStack { * @param rotationY The Y-axis rotation * @param rotationZ The Z-axis rotation */ - void setRotation(float rotationX, float rotationY, float rotationZ); + void setRotation(Float rotationX, Float rotationY, Float rotationZ); /** * Sets the rotation rate values for the scripted item. Spinning Speed @@ -177,7 +177,7 @@ public interface IItemCustom extends IItemStack { * @param rotationYRate The Y-axis rotation rate * @param rotationZRate The Z-axis rotation rate */ - void setRotationRate(float rotationXRate, float rotationYRate, float rotationZRate); + void setRotationRate(Float rotationXRate, Float rotationYRate, Float rotationZRate); /** * Sets the scale values for the scripted item. @@ -185,7 +185,7 @@ public interface IItemCustom extends IItemStack { * @param scaleY The Y-axis scale * @param scaleZ The Z-axis scale */ - void setScale(float scaleX, float scaleY, float scaleZ); + void setScale(Float scaleX, Float scaleY, Float scaleZ); /** * Sets the translation values for the scripted item. @@ -193,77 +193,77 @@ public interface IItemCustom extends IItemStack { * @param translateY The Y-axis translation * @param translateZ The Z-axis translation */ - void setTranslate(float translateX, float translateY, float translateZ); + void setTranslate(Float translateX, Float translateY, Float translateZ); /** * Gets the X-axis rotation for the scripted item. * @return The X-axis rotation */ - float getRotationX(); + Float getRotationX(); /** * Gets the Y-axis rotation for the scripted item. * @return The Y-axis rotation */ - float getRotationY(); + Float getRotationY(); /** * Gets the Z-axis rotation for the scripted item. * @return The Z-axis rotation */ - float getRotationZ(); + Float getRotationZ(); /** * Gets the X-axis rotation rate for the scripted item. * @return The X-axis rotation rate */ - float getRotationXRate(); + Float getRotationXRate(); /** * Gets the Y-axis rotation rate for the scripted item. * @return The Y-axis rotation rate */ - float getRotationYRate(); + Float getRotationYRate(); /** * Gets the Z-axis rotation rate for the scripted item. * @return The Z-axis rotation rate */ - float getRotationZRate(); + Float getRotationZRate(); /** * Gets the X-axis scale for the scripted item. * @return The X-axis scale */ - float getScaleX(); + Float getScaleX(); /** * Gets the Y-axis scale for the scripted item. * @return The Y-axis scale */ - float getScaleY(); + Float getScaleY(); /** * Gets the Z-axis scale for the scripted item. * @return The Z-axis scale */ - float getScaleZ(); + Float getScaleZ(); /** * Gets the X-axis translation for the scripted item. * @return The X-axis translation */ - float getTranslateX(); + Float getTranslateX(); /** * Gets the Y-axis translation for the scripted item. * @return The Y-axis translation */ - float getTranslateY(); + Float getTranslateY(); /** * Gets the Z-axis translation for the scripted item. * @return The Z-axis translation */ - float getTranslateZ(); + Float getTranslateZ(); } From fecfbc72242f1c6b645f9ef6659f9be38a912042 Mon Sep 17 00:00:00 2001 From: luisc Date: Thu, 13 Feb 2025 18:44:10 -0600 Subject: [PATCH 2/5] Created IItemCustomizable interface --- java/noppes/npcs/api/item/IItemCustom.java | 202 +---------------- .../npcs/api/item/IItemCustomizable.java | 206 ++++++++++++++++++ 2 files changed, 207 insertions(+), 201 deletions(-) create mode 100644 java/noppes/npcs/api/item/IItemCustomizable.java diff --git a/java/noppes/npcs/api/item/IItemCustom.java b/java/noppes/npcs/api/item/IItemCustom.java index f928e2b..355d900 100644 --- a/java/noppes/npcs/api/item/IItemCustom.java +++ b/java/noppes/npcs/api/item/IItemCustom.java @@ -1,6 +1,6 @@ package noppes.npcs.api.item; -public interface IItemCustom extends IItemStack { +public interface IItemCustom extends IItemCustomizable { /** * @return true if scripted item script is enabled @@ -12,42 +12,18 @@ public interface IItemCustom extends IItemStack { */ void setEnabled(boolean enable); - /** - * Gets the texture path for the scripted item. - * @return The texture path - */ - String getTexture(); - - /** - * Sets the texture path for the scripted item. Can be a URL - * @param texture The texture path - */ - void setTexture(String texture); - /** * Sets the armor type for the scripted item. * @param armorType The armor type */ void setArmorType(int armorType); - /** - * Gets the armor type for the scripted item. - * @return The armor type - */ - int getArmorType(); - /** * Sets whether the scripted item is a tool. * @param isTool True if the item is a tool, false otherwise */ void setIsTool(boolean isTool); - /** - * Checks if the scripted item is a tool. Allows for enchanting - * @return True if the item is a tool, false otherwise - */ - boolean isTool(); - /** * Sets whether the scripted item is a normal item. Will disable * all forms of Rotation, Translation, Scale Rendering in hand and on ground @@ -55,84 +31,24 @@ public interface IItemCustom extends IItemStack { */ void setIsNormalItem(boolean normalItem); - /** - * Checks if the scripted item is a normal item. - * @return True if the item is a normal item, false otherwise - */ - boolean isNormalItem(); - /** * Sets the dig speed for the scripted item. * @param digSpeed The dig speed */ void setDigSpeed(int digSpeed); - /** - * Gets the dig speed for the scripted item. - * @return The dig speed - */ - int getDigSpeed(); - /** * Sets the maximum stack size for the scripted item. * @param maxStackSize The maximum stack size */ void setMaxStackSize(int maxStackSize); - /** - * Gets the current durability value for the scripted item. - * @return The durability value - */ - double getDurabilityValue(); - /** * Sets the current durability value for the scripted item. * @param durabilityValue The durability value */ void setDurabilityValue(float durabilityValue); - /** - * Checks if the durability bar should be shown for the scripted item. - * @return True if the durability bar should be shown, false otherwise - */ - Boolean getDurabilityShow(); - - /** - * Sets whether the durability bar should be shown for the scripted item. - * @param durabilityShow True if the durability bar should be shown, false otherwise - */ - void setDurabilityShow(Boolean durabilityShow); - - /** - * Gets the color of the durability bar for the scripted item. - * @return The durability bar color - */ - Integer getDurabilityColor(); - - /** - * Sets the color of the durability bar for the scripted item. - * @param durabilityColor The durability bar color - */ - void setDurabilityColor(Integer durabilityColor); - - /** - * Gets the color of the scripted item. - * @return The item color - */ - Integer getColor(); - - /** - * Sets the color of the scripted item. - * @param color The item color - */ - void setColor(Integer color); - - /** - * Gets the maximum item use duration for the scripted item. - * @return The maximum item use duration - */ - int getMaxItemUseDuration(); - /** * Sets the maximum item use duration for the scripted item. * @param duration The maximum item use duration @@ -145,125 +61,9 @@ public interface IItemCustom extends IItemStack { */ void setItemUseAction(int action); - /** - * Gets the item use action for the scripted item. - * @return The item use action - */ - int getItemUseAction(); - - /** - * Gets the enchantability for the scripted item. - * @return The enchantability - */ - int getEnchantability(); - /** * Sets the enchantability for the scripted item. * @param enchantability The enchantability */ void setEnchantability(int enchantability); - - /** - * Sets the rotation values for the scripted item. - * @param rotationX The X-axis rotation - * @param rotationY The Y-axis rotation - * @param rotationZ The Z-axis rotation - */ - void setRotation(Float rotationX, Float rotationY, Float rotationZ); - - /** - * Sets the rotation rate values for the scripted item. Spinning Speed - * @param rotationXRate The X-axis rotation rate - * @param rotationYRate The Y-axis rotation rate - * @param rotationZRate The Z-axis rotation rate - */ - void setRotationRate(Float rotationXRate, Float rotationYRate, Float rotationZRate); - - /** - * Sets the scale values for the scripted item. - * @param scaleX The X-axis scale - * @param scaleY The Y-axis scale - * @param scaleZ The Z-axis scale - */ - void setScale(Float scaleX, Float scaleY, Float scaleZ); - - /** - * Sets the translation values for the scripted item. - * @param translateX The X-axis translation - * @param translateY The Y-axis translation - * @param translateZ The Z-axis translation - */ - void setTranslate(Float translateX, Float translateY, Float translateZ); - - /** - * Gets the X-axis rotation for the scripted item. - * @return The X-axis rotation - */ - Float getRotationX(); - - /** - * Gets the Y-axis rotation for the scripted item. - * @return The Y-axis rotation - */ - Float getRotationY(); - - /** - * Gets the Z-axis rotation for the scripted item. - * @return The Z-axis rotation - */ - Float getRotationZ(); - - /** - * Gets the X-axis rotation rate for the scripted item. - * @return The X-axis rotation rate - */ - Float getRotationXRate(); - - /** - * Gets the Y-axis rotation rate for the scripted item. - * @return The Y-axis rotation rate - */ - Float getRotationYRate(); - - /** - * Gets the Z-axis rotation rate for the scripted item. - * @return The Z-axis rotation rate - */ - Float getRotationZRate(); - - /** - * Gets the X-axis scale for the scripted item. - * @return The X-axis scale - */ - Float getScaleX(); - - /** - * Gets the Y-axis scale for the scripted item. - * @return The Y-axis scale - */ - Float getScaleY(); - - /** - * Gets the Z-axis scale for the scripted item. - * @return The Z-axis scale - */ - Float getScaleZ(); - - /** - * Gets the X-axis translation for the scripted item. - * @return The X-axis translation - */ - Float getTranslateX(); - - /** - * Gets the Y-axis translation for the scripted item. - * @return The Y-axis translation - */ - Float getTranslateY(); - - /** - * Gets the Z-axis translation for the scripted item. - * @return The Z-axis translation - */ - Float getTranslateZ(); } diff --git a/java/noppes/npcs/api/item/IItemCustomizable.java b/java/noppes/npcs/api/item/IItemCustomizable.java new file mode 100644 index 0000000..d53e8e1 --- /dev/null +++ b/java/noppes/npcs/api/item/IItemCustomizable.java @@ -0,0 +1,206 @@ +package noppes.npcs.api.item; + +public interface IItemCustomizable extends IItemStack { + + int getMaxStackSize(); + + /** + * Gets the armor type for the scripted item. + * @return The armor type + */ + int getArmorType(); + + /** + * Checks if the scripted item is a tool. Allows for enchanting + * @return True if the item is a tool, false otherwise + */ + boolean isTool(); + + /** + * Checks if the scripted item is a normal item. + * @return True if the item is a normal item, false otherwise + */ + boolean isNormalItem(); + + /** + * Gets the dig speed for the scripted item. + * @return The dig speed + */ + int getDigSpeed(); + + /** + * Gets the current durability value for the scripted item. + * @return The durability value + */ + double getDurabilityValue(); + + /** + * Gets the maximum item use duration for the scripted item. + * @return The maximum item use duration + */ + int getMaxItemUseDuration(); + + /** + * Gets the item use action for the scripted item. + * @return The item use action + */ + int getItemUseAction(); + + /** + * Gets the enchantability for the scripted item. + * @return The enchantability + */ + int getEnchantability(); + + /** + * Gets the texture path for the scripted item. + * @return The texture path + */ + String getTexture(); + + /** + * Sets the texture path for the scripted item. Can be a URL + * @param texture The texture path + */ + void setTexture(String texture); + + /** + * Checks if the durability bar should be shown for the scripted item. + * @return True if the durability bar should be shown, false otherwise + */ + Boolean getDurabilityShow(); + + /** + * Sets whether the durability bar should be shown for the scripted item. + * @param durabilityShow True if the durability bar should be shown, false otherwise + */ + void setDurabilityShow(Boolean durabilityShow); + + /** + * Gets the color of the durability bar for the scripted item. + * @return The durability bar color + */ + Integer getDurabilityColor(); + + /** + * Sets the color of the durability bar for the scripted item. + * @param durabilityColor The durability bar color + */ + void setDurabilityColor(Integer durabilityColor); + + /** + * Gets the color of the scripted item. + * @return The item color + */ + Integer getColor(); + + /** + * Sets the color of the scripted item. + * @param color The item color + */ + void setColor(Integer color); + + /** + * Sets the rotation values for the scripted item. + * @param rotationX The X-axis rotation + * @param rotationY The Y-axis rotation + * @param rotationZ The Z-axis rotation + */ + void setRotation(Float rotationX, Float rotationY, Float rotationZ); + + /** + * Sets the rotation rate values for the scripted item. Spinning Speed + * @param rotationXRate The X-axis rotation rate + * @param rotationYRate The Y-axis rotation rate + * @param rotationZRate The Z-axis rotation rate + */ + void setRotationRate(Float rotationXRate, Float rotationYRate, Float rotationZRate); + + /** + * Sets the scale values for the scripted item. + * @param scaleX The X-axis scale + * @param scaleY The Y-axis scale + * @param scaleZ The Z-axis scale + */ + void setScale(Float scaleX, Float scaleY, Float scaleZ); + + /** + * Sets the translation values for the scripted item. + * @param translateX The X-axis translation + * @param translateY The Y-axis translation + * @param translateZ The Z-axis translation + */ + void setTranslate(Float translateX, Float translateY, Float translateZ); + + /** + * Gets the X-axis rotation for the scripted item. + * @return The X-axis rotation + */ + Float getRotationX(); + + /** + * Gets the Y-axis rotation for the scripted item. + * @return The Y-axis rotation + */ + Float getRotationY(); + + /** + * Gets the Z-axis rotation for the scripted item. + * @return The Z-axis rotation + */ + Float getRotationZ(); + + /** + * Gets the X-axis rotation rate for the scripted item. + * @return The X-axis rotation rate + */ + Float getRotationXRate(); + + /** + * Gets the Y-axis rotation rate for the scripted item. + * @return The Y-axis rotation rate + */ + Float getRotationYRate(); + + /** + * Gets the Z-axis rotation rate for the scripted item. + * @return The Z-axis rotation rate + */ + Float getRotationZRate(); + + /** + * Gets the X-axis scale for the scripted item. + * @return The X-axis scale + */ + Float getScaleX(); + + /** + * Gets the Y-axis scale for the scripted item. + * @return The Y-axis scale + */ + Float getScaleY(); + + /** + * Gets the Z-axis scale for the scripted item. + * @return The Z-axis scale + */ + Float getScaleZ(); + + /** + * Gets the X-axis translation for the scripted item. + * @return The X-axis translation + */ + Float getTranslateX(); + + /** + * Gets the Y-axis translation for the scripted item. + * @return The Y-axis translation + */ + Float getTranslateY(); + + /** + * Gets the Z-axis translation for the scripted item. + * @return The Z-axis translation + */ + Float getTranslateZ(); +} From d093c00493d4dfd82f2f250008432ca6536c4529 Mon Sep 17 00:00:00 2001 From: luisc Date: Thu, 13 Feb 2025 19:00:20 -0600 Subject: [PATCH 3/5] Made item events use IItemCustomizable interface. --- java/noppes/npcs/api/event/IItemEvent.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/noppes/npcs/api/event/IItemEvent.java b/java/noppes/npcs/api/event/IItemEvent.java index 89ae4d9..981d160 100644 --- a/java/noppes/npcs/api/event/IItemEvent.java +++ b/java/noppes/npcs/api/event/IItemEvent.java @@ -3,11 +3,11 @@ package noppes.npcs.api.event; import cpw.mods.fml.common.eventhandler.Cancelable; import noppes.npcs.api.entity.IEntity; import noppes.npcs.api.entity.IPlayer; -import noppes.npcs.api.item.IItemCustom; +import noppes.npcs.api.item.IItemCustomizable; public interface IItemEvent extends ICustomNPCsEvent { - IItemCustom getItem(); + IItemCustomizable getItem(); interface InitEvent extends IItemEvent { } From 232da0325b4c8b10c4ebc3e5f726e3cfd2df86fb Mon Sep 17 00:00:00 2001 From: luisc Date: Fri, 14 Feb 2025 12:28:17 -0600 Subject: [PATCH 4/5] More linked item changes --- java/noppes/npcs/api/item/IItemCustomizable.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/java/noppes/npcs/api/item/IItemCustomizable.java b/java/noppes/npcs/api/item/IItemCustomizable.java index d53e8e1..50a3f34 100644 --- a/java/noppes/npcs/api/item/IItemCustomizable.java +++ b/java/noppes/npcs/api/item/IItemCustomizable.java @@ -1,7 +1,11 @@ package noppes.npcs.api.item; +import noppes.npcs.controllers.data.INpcScriptHandler; + public interface IItemCustomizable extends IItemStack { + INpcScriptHandler getScriptHandler(); + int getMaxStackSize(); /** From 299136c9db54f283f83de15db0382898c3090dc4 Mon Sep 17 00:00:00 2001 From: luisc Date: Fri, 14 Feb 2025 12:29:52 -0600 Subject: [PATCH 5/5] Made ScriptLinkedItem implement IItemLinked api interface --- java/noppes/npcs/api/item/IItemLinked.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/noppes/npcs/api/item/IItemLinked.java b/java/noppes/npcs/api/item/IItemLinked.java index 60f4f3c..0b7466f 100644 --- a/java/noppes/npcs/api/item/IItemLinked.java +++ b/java/noppes/npcs/api/item/IItemLinked.java @@ -1,5 +1,5 @@ package noppes.npcs.api.item; -public interface IItemLinked extends IItemCustom { +public interface IItemLinked extends IItemCustomizable { }