From 19e14983aa449f7adcb41d09b314afc3c2fe978f Mon Sep 17 00:00:00 2001 From: "Luis C.M" <42545778+c0508383@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:10:03 -0500 Subject: [PATCH] IWorld: -Fixed isPlaceCancelled and isBreakCancelled functions --- src/api | 2 +- .../noppes/npcs/entity/EntityNPCInterface.java | 15 +++------------ .../java/noppes/npcs/scripted/ScriptWorld.java | 14 ++++++++++++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/api b/src/api index 3570b3af0..21b4d91fc 160000 --- a/src/api +++ b/src/api @@ -1 +1 @@ -Subproject commit 3570b3af0caeacecbf231fa8f626f569b3bd482d +Subproject commit 21b4d91fc7ac0d69026fc9ebb1185961190061db diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index a63b147cf..e00e9b159 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -57,6 +57,7 @@ import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.*; import noppes.npcs.entity.data.DataTimers; import noppes.npcs.roles.*; +import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptNpc; import noppes.npcs.scripted.event.NpcEvent; import noppes.npcs.util.GameProfileAlt; @@ -69,7 +70,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti public static final GameProfileAlt chateventProfile = new GameProfileAlt(); public static FakePlayer chateventPlayer; - public static FakePlayer CommandPlayer; public DataDisplay display; public DataStats stats; public DataAI ai; @@ -901,6 +901,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti EntityUtil.Copy(this, chateventPlayer); chateventProfile.npc = this; chateventPlayer.refreshDisplayName(); + IItemStack stack = NpcAPI.Instance().createItem("minecraft:stone",0,1); + chateventPlayer.setCurrentItemOrArmor(0, stack.getMCItemStack()); return chateventPlayer; } @@ -1578,17 +1580,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti display.readToNBT(compound); } - public Entity func_174793_f() { - if (this.worldObj.isRemote) { - return this; - } else { - EntityUtil.Copy(this, CommandPlayer); - CommandPlayer.setWorld(this.worldObj); - CommandPlayer.setPosition(this.posX, this.posY, this.posZ); - return CommandPlayer; - } - } - @Override public String getCommandSenderName() { return display.name; diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index 8cd529566..cf45ac060 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -20,6 +20,7 @@ import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.BlockSnapshot; +import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.event.world.BlockEvent; import noppes.npcs.CustomNpcs; import noppes.npcs.NoppesUtilServer; @@ -30,6 +31,7 @@ import noppes.npcs.api.handler.data.ISound; import noppes.npcs.api.item.IItemStack; import noppes.npcs.api.scoreboard.IScoreboard; import noppes.npcs.blocks.tiles.TileBigSign; +import noppes.npcs.client.EntityUtil; import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.ServerCloneController; import noppes.npcs.entity.EntityNPCInterface; @@ -476,9 +478,13 @@ public class ScriptWorld implements IWorld { Block mcBlock = block.getMCBlock(); int metadata = this.getBlockMetadata(posX,posY,posZ); + FakePlayer fakePlayer = new FakePlayer(this.world, EntityNPCInterface.chateventProfile); + IItemStack stack = NpcAPI.Instance().createItem("minecraft:stone",0,1); + fakePlayer.setCurrentItemOrArmor(0, stack.getMCItemStack()); + final BlockEvent.PlaceEvent placeEvent = new BlockEvent.PlaceEvent( new BlockSnapshot(this.world, (int)Math.floor(posX), (int)Math.floor(posY), (int)Math.floor(posZ), mcBlock, metadata), - Blocks.air, EntityNPCInterface.CommandPlayer); + Blocks.air, fakePlayer); MinecraftForge.EVENT_BUS.post(placeEvent); @@ -498,8 +504,12 @@ public class ScriptWorld implements IWorld { Block mcBlock = block.getMCBlock(); int metadata = this.getBlockMetadata(posX,posY,posZ); + FakePlayer fakePlayer = new FakePlayer(this.world, EntityNPCInterface.chateventProfile); + IItemStack stack = NpcAPI.Instance().createItem("minecraft:stone",0,1); + fakePlayer.setCurrentItemOrArmor(0, stack.getMCItemStack()); + final BlockEvent.BreakEvent placeEvent = new BlockEvent.BreakEvent(posX, posY, posZ, world, - mcBlock, metadata, EntityNPCInterface.CommandPlayer); + mcBlock, metadata, fakePlayer); MinecraftForge.EVENT_BUS.post(placeEvent);