From 165ec6ea1eec30096d115c84026cf2376e44eab1 Mon Sep 17 00:00:00 2001 From: Goodbird Date: Sat, 20 Jan 2024 18:02:01 +0300 Subject: [PATCH 1/4] Added an interface for the scripted block --- .../noppes/npcs/api/block/IBlockScripted.java | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 java/noppes/npcs/api/block/IBlockScripted.java diff --git a/java/noppes/npcs/api/block/IBlockScripted.java b/java/noppes/npcs/api/block/IBlockScripted.java new file mode 100644 index 0000000..8cb6687 --- /dev/null +++ b/java/noppes/npcs/api/block/IBlockScripted.java @@ -0,0 +1,97 @@ +package noppes.npcs.api.block; + +import noppes.npcs.api.IBlock; +import noppes.npcs.api.ITimers; +import noppes.npcs.api.item.IItemStack; + +public interface IBlockScripted extends IBlock { + + /** + * @param item The item to be set as model + */ + void setModel(IItemStack item); + + void setModel(String name); + + IItemStack getModel(); + + ITimers getTimers(); + + /** + * @param strength Sets the strength of the redstone signal (0-15) + */ + void setRedstonePower(int strength); + + /** + * @return Returns the current redstone power (0-15) this block is giving off + */ + int getRedstonePower(); + + void setIsLadder(boolean enabled); + + boolean getIsLadder(); + + /** + * @param value Sets the light value (0-15) + */ + void setLight(int value); + + /** + * @return Returns the light value (0-15) + */ + int getLight(); + + /** + * @param x Scale x (0-10) + * @param y Scale y (0-10) + * @param z Scale z (0-10) + */ + void setScale(float x, float y, float z); + + float getScaleX(); + + float getScaleY(); + + float getScaleZ(); + + /** + * @param x Rotation x (0-359) + * @param y Rotation y (0-359) + * @param z Rotation z (0-359) + */ + void setRotation(int x, int y, int z); + + int getRotationX(); + + int getRotationY(); + + int getRotationZ(); + + /** + * On servers the enable-command-block option in the server.properties needs to be set to true
+ * Use /gamerule commandBlockOutput false/true to turn off/on command block feedback
+ * Setting NpcUseOpCommands to true in the CustomNPCs.cfg should allow the npc to run op commands, be warned this could be a major security risk, use at own risk
+ * For permission plugins the commands are run under uuid:c9c843f8-4cb1-4c82-aa61-e264291b7bd6 and name:[customnpcs] + * @param command The command to be executed + * @return Returns the commands output + */ + String executeCommand(String command); + + boolean getIsPassible(); + + void setIsPassible(boolean bo); + + /** + * @return Harvesting hardness (-1 makes it unharvestable) + */ + float getHardness(); + + void setHardness(float hardness); + + /** + * @return Explosion resistance (-1 makes it unexplodable) + */ + float getResistance(); + + void setResistance(float resistance); +} From 427245d6bc9a7e4a487f833991db47f4d22520bd Mon Sep 17 00:00:00 2001 From: Goodbird Date: Sun, 21 Jan 2024 10:55:09 +0300 Subject: [PATCH 2/4] Added text plane interface and linked it to scripted block interface --- .../noppes/npcs/api/block/IBlockScripted.java | 15 ++++++- java/noppes/npcs/api/block/ITextPlane.java | 42 +++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 java/noppes/npcs/api/block/ITextPlane.java diff --git a/java/noppes/npcs/api/block/IBlockScripted.java b/java/noppes/npcs/api/block/IBlockScripted.java index 8cb6687..e49b93d 100644 --- a/java/noppes/npcs/api/block/IBlockScripted.java +++ b/java/noppes/npcs/api/block/IBlockScripted.java @@ -73,9 +73,8 @@ public interface IBlockScripted extends IBlock { * Setting NpcUseOpCommands to true in the CustomNPCs.cfg should allow the npc to run op commands, be warned this could be a major security risk, use at own risk
* For permission plugins the commands are run under uuid:c9c843f8-4cb1-4c82-aa61-e264291b7bd6 and name:[customnpcs] * @param command The command to be executed - * @return Returns the commands output */ - String executeCommand(String command); + void executeCommand(String command); boolean getIsPassible(); @@ -94,4 +93,16 @@ public interface IBlockScripted extends IBlock { float getResistance(); void setResistance(float resistance); + + ITextPlane getTextPlane(); + + ITextPlane getTextPlane2(); + + ITextPlane getTextPlane3(); + + ITextPlane getTextPlane4(); + + ITextPlane getTextPlane5(); + + ITextPlane getTextPlane6(); } diff --git a/java/noppes/npcs/api/block/ITextPlane.java b/java/noppes/npcs/api/block/ITextPlane.java new file mode 100644 index 0000000..337bf07 --- /dev/null +++ b/java/noppes/npcs/api/block/ITextPlane.java @@ -0,0 +1,42 @@ +package noppes.npcs.api.block; + +public interface ITextPlane { + + public String getText(); + + public void setText(String text); + + public int getRotationX(); + + public int getRotationY(); + + public int getRotationZ(); + + public void setRotationX(int x); + + public void setRotationY(int y); + + /** + * @param z Default: 0.5 + */ + public void setRotationZ(int z); + + public float getOffsetX(); + + public float getOffsetY(); + + public float getOffsetZ(); + + public void setOffsetX(float x); + + public void setOffsetY(float y); + + public void setOffsetZ(float z); + + public float getScale(); + + /** + * @param scale Default: 1 + */ + public void setScale(float scale); +} From 0895815b34f1278cbe06fe70a4432893e0d2dea4 Mon Sep 17 00:00:00 2001 From: Goodbird Date: Sun, 21 Jan 2024 10:55:28 +0300 Subject: [PATCH 3/4] Added scripted block event interfaces --- java/noppes/npcs/api/event/IBlockEvent.java | 72 +++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 java/noppes/npcs/api/event/IBlockEvent.java diff --git a/java/noppes/npcs/api/event/IBlockEvent.java b/java/noppes/npcs/api/event/IBlockEvent.java new file mode 100644 index 0000000..2e85076 --- /dev/null +++ b/java/noppes/npcs/api/event/IBlockEvent.java @@ -0,0 +1,72 @@ +package noppes.npcs.api.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import noppes.npcs.api.IBlock; +import noppes.npcs.api.IPos; +import noppes.npcs.api.entity.IEntity; +import noppes.npcs.api.entity.IPlayer; + +public interface IBlockEvent extends ICustomNPCsEvent { + IBlock getBlock(); + @Cancelable + interface EntityFallenUponEvent extends IBlockEvent{ + IEntity getEntity(); + float getDistanceFallen(); + } + + @Cancelable + interface InteractEvent extends IBlockEvent { + IPlayer getPlayer(); + + float getHitX(); + + float getHitY(); + + float getHitZ(); + + int getSide(); + } + + interface RedstoneEvent extends IBlockEvent{ + int getPrevPower(); + int getPower(); + } + interface BreakEvent extends IBlockEvent{ + + } + @Cancelable + interface ExplodedEvent extends IBlockEvent{ + + } + interface RainFillEvent extends IBlockEvent{ + + } + + interface NeighborChangedEvent extends IBlockEvent { + IPos getChangedPos(); + } + + interface InitEvent extends IBlockEvent{ + + } + interface UpdateEvent extends IBlockEvent{ + + } + + interface ClickedEvent extends IBlockEvent { + IPlayer getPlayer(); + } + + @Cancelable + interface HarvestedEvent extends IBlockEvent { + IPlayer getPlayer(); + } + + interface CollidedEvent extends IBlockEvent { + IEntity getEntity(); + } + + interface TimerEvent extends IBlockEvent { + int getId(); + } +} From 7200c08d3219a5635721f5db1bc3d9721c63b1d5 Mon Sep 17 00:00:00 2001 From: Goodbird Date: Mon, 22 Jan 2024 20:30:49 +0300 Subject: [PATCH 4/4] Implemented storeddata and tempdata --- .../noppes/npcs/api/block/IBlockScripted.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/java/noppes/npcs/api/block/IBlockScripted.java b/java/noppes/npcs/api/block/IBlockScripted.java index e49b93d..8036abe 100644 --- a/java/noppes/npcs/api/block/IBlockScripted.java +++ b/java/noppes/npcs/api/block/IBlockScripted.java @@ -105,4 +105,28 @@ public interface IBlockScripted extends IBlock { ITextPlane getTextPlane5(); ITextPlane getTextPlane6(); + + void setStoredData(String key, Object value); + + Object getStoredData(String key); + + void removeStoredData(String key); + + boolean hasStoredData(String key); + + void clearStoredData(); + + String[] getStoredDataKeys(); + + void removeTempData(String key); + + void setTempData(String key, Object value); + + boolean hasTempData(String key); + + Object getTempData(String key); + + void clearTempData(); + + String[] getTempDataKeys(); }