mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 07:39:41 +00:00
Revert the NPC tool click guard; Backhand now drops the offhand click itself
This commit is contained in:
1 parent
8f4fcae735
commit
0dc0e72b62
2 files changed
-16
No files matched your search
@@ -104,7 +104,6 @@ public class ServerEventsHandler {
|
||||
return;
|
||||
}
|
||||
event.setCanceled(true);
|
||||
((EntityNPCInterface) event.target).markToolUse(event.entityPlayer);
|
||||
NoppesUtilServer.sendOpenGui(event.entityPlayer, EnumGuiType.MainMenuDisplay, (EntityNPCInterface) event.target);
|
||||
if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
||||
LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "WAND", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface) (event.target)).display.getName(), (int) (event.target).posX, (int) (event.target).posY, (int) (event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName()));
|
||||
@@ -120,7 +119,6 @@ public class ServerEventsHandler {
|
||||
PacketHandler.Instance.sendToPlayer(new ClonerPacket(compound), (EntityPlayerMP) event.entityPlayer);
|
||||
data.cloned = compound;
|
||||
if (event.target instanceof EntityNPCInterface) {
|
||||
((EntityNPCInterface) event.target).markToolUse(event.entityPlayer);
|
||||
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface) event.target);
|
||||
}
|
||||
event.setCanceled(true);
|
||||
@@ -128,7 +126,6 @@ public class ServerEventsHandler {
|
||||
if (!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_SCRIPTER))
|
||||
return;
|
||||
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface) event.target);
|
||||
((EntityNPCInterface) event.target).markToolUse(event.entityPlayer);
|
||||
event.setCanceled(true);
|
||||
GuiOpenPacket.openGUI((EntityPlayerMP) event.entityPlayer, EnumGuiType.Script, 0, 0, 0);
|
||||
if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
||||
|
||||
@@ -539,23 +539,10 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
updateClient = false;
|
||||
}
|
||||
|
||||
/** Who last used a tool on this NPC and when, so an offhand click right after it does not run the interact. */
|
||||
private String toolUser;
|
||||
private long toolUsedAt;
|
||||
|
||||
/** Marks that this player just used the Wand, Scripter or Cloner on this NPC. */
|
||||
public void markToolUse(EntityPlayer player) {
|
||||
toolUser = player.getCommandSenderName();
|
||||
toolUsedAt = worldObj.getTotalWorldTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean interact(EntityPlayer player) {
|
||||
if (worldObj.isRemote)
|
||||
return false;
|
||||
// An offhand mod like Backhand clicks again with the other hand after a tool click is cancelled
|
||||
if (player.getCommandSenderName().equals(toolUser) && worldObj.getTotalWorldTime() - toolUsedAt <= 2)
|
||||
return true;
|
||||
ItemStack currentItem = player.inventory.getCurrentItem();
|
||||
if (currentItem != null) {
|
||||
Item item = currentItem.getItem();
|
||||
|
||||
Reference in new issue
Block a user