mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-26 02:13:04 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0f78f0efa | ||
|
|
ce9941e3ee | ||
|
|
7b6c7c1c33 | ||
|
|
b848dc0d7a | ||
|
|
e9f810dc21 | ||
|
|
20583d9b0d | ||
|
|
2b6f63a3e3 | ||
|
|
b86c1ceabb | ||
|
|
07640d9b6b | ||
|
|
b490e04bb0 | ||
|
|
99616854a7 | ||
|
|
236b901e61 | ||
|
|
810e29ca75 | ||
|
|
d119a7524e | ||
|
|
2b5fcc12cc |
No files matched your search
+1
-1
Submodule src/api updated: 445fc594f3...bbbea878fe.
@@ -55,6 +55,7 @@ import kamkeel.npcs.network.packets.request.naturalspawns.NaturalSpawnGetAllPack
|
|||||||
import kamkeel.npcs.network.packets.request.naturalspawns.NaturalSpawnGetPacket;
|
import kamkeel.npcs.network.packets.request.naturalspawns.NaturalSpawnGetPacket;
|
||||||
import kamkeel.npcs.network.packets.request.naturalspawns.NaturalSpawnRemovePacket;
|
import kamkeel.npcs.network.packets.request.naturalspawns.NaturalSpawnRemovePacket;
|
||||||
import kamkeel.npcs.network.packets.request.naturalspawns.NaturalSpawnSavePacket;
|
import kamkeel.npcs.network.packets.request.naturalspawns.NaturalSpawnSavePacket;
|
||||||
|
import kamkeel.npcs.network.packets.request.nbtbook.NbtBookPacket;
|
||||||
import kamkeel.npcs.network.packets.request.npc.*;
|
import kamkeel.npcs.network.packets.request.npc.*;
|
||||||
import kamkeel.npcs.network.packets.request.party.*;
|
import kamkeel.npcs.network.packets.request.party.*;
|
||||||
import kamkeel.npcs.network.packets.request.pather.MovingPathGetPacket;
|
import kamkeel.npcs.network.packets.request.pather.MovingPathGetPacket;
|
||||||
@@ -318,6 +319,7 @@ public class PacketHandler {
|
|||||||
REQUEST_PACKET.registerPacket(new ColorBrushPacket());
|
REQUEST_PACKET.registerPacket(new ColorBrushPacket());
|
||||||
REQUEST_PACKET.registerPacket(new ColorSetPacket());
|
REQUEST_PACKET.registerPacket(new ColorSetPacket());
|
||||||
REQUEST_PACKET.registerPacket(new HammerPacket());
|
REQUEST_PACKET.registerPacket(new HammerPacket());
|
||||||
|
REQUEST_PACKET.registerPacket(new NbtBookPacket());
|
||||||
|
|
||||||
// Custom Effect Packets
|
// Custom Effect Packets
|
||||||
REQUEST_PACKET.registerPacket(new EffectGetPacket());
|
REQUEST_PACKET.registerPacket(new EffectGetPacket());
|
||||||
|
|||||||
@@ -230,6 +230,10 @@ public class PacketUtil {
|
|||||||
tabCompound.setInteger("TotalScripts", containers.size());
|
tabCompound.setInteger("TotalScripts", containers.size());
|
||||||
GuiDataPacket.sendGuiData(player, tabCompound);
|
GuiDataPacket.sendGuiData(player, tabCompound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NBTTagCompound loadComplete = new NBTTagCompound();
|
||||||
|
loadComplete.setInteger("LoadComplete", 1);
|
||||||
|
GuiDataPacket.sendGuiData(player, loadComplete);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveScripts(IScriptHandler data, ByteBuf buffer) throws IOException {
|
public static void saveScripts(IScriptHandler data, ByteBuf buffer) throws IOException {
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ public enum EnumRequestPacket {
|
|||||||
|
|
||||||
ColorSet,
|
ColorSet,
|
||||||
ColorBrush,
|
ColorBrush,
|
||||||
|
Hammer,
|
||||||
|
|
||||||
MagicCycleRemove,
|
MagicCycleRemove,
|
||||||
MagicCycleSave,
|
MagicCycleSave,
|
||||||
@@ -192,5 +193,7 @@ public enum EnumRequestPacket {
|
|||||||
MagicGet,
|
MagicGet,
|
||||||
MagicSave,
|
MagicSave,
|
||||||
NpcMagicGet,
|
NpcMagicGet,
|
||||||
NpcMagicSave, Hammer,
|
NpcMagicSave,
|
||||||
|
|
||||||
|
NbtBookSave,
|
||||||
}
|
}
|
||||||
@@ -49,9 +49,6 @@ public final class CustomGuiClosePacket extends AbstractPacket {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||||
if (!(player.openContainer instanceof ContainerCustomGui))
|
|
||||||
return;
|
|
||||||
|
|
||||||
NBTTagCompound comp = ByteBufUtils.readNBT(in);
|
NBTTagCompound comp = ByteBufUtils.readNBT(in);
|
||||||
EventHooks.onCustomGuiClose((IPlayer) NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(comp));
|
EventHooks.onCustomGuiClose((IPlayer) NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(comp));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,116 @@
|
|||||||
|
package kamkeel.npcs.network.packets.request.nbtbook;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import kamkeel.npcs.network.*;
|
||||||
|
import kamkeel.npcs.network.enums.EnumRequestPacket;
|
||||||
|
import kamkeel.npcs.util.ByteBufUtils;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import noppes.npcs.CustomNpcsPermissions;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class NbtBookPacket extends AbstractPacket {
|
||||||
|
|
||||||
|
public static String packetName = "Request|NbtBook";
|
||||||
|
|
||||||
|
private Action type;
|
||||||
|
|
||||||
|
private int entityId;
|
||||||
|
|
||||||
|
private NBTTagCompound compound;
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
private int z;
|
||||||
|
|
||||||
|
public NbtBookPacket() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public NbtBookPacket(int entityId, NBTTagCompound compound) {
|
||||||
|
this.type = Action.ENTITY;
|
||||||
|
this.entityId = entityId;
|
||||||
|
this.compound = compound;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NbtBookPacket(int x, int y, int z, NBTTagCompound compound) {
|
||||||
|
this.type = Action.BLOCK;
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
this.compound = compound;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Enum getType() {
|
||||||
|
return EnumRequestPacket.NbtBookSave;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PacketChannel getChannel() {
|
||||||
|
return PacketHandler.REQUEST_PACKET;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomNpcsPermissions.Permission getPermission() {
|
||||||
|
return CustomNpcsPermissions.TOOL_NBT_BOOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public void sendData(ByteBuf out) throws IOException {
|
||||||
|
out.writeInt(type.ordinal());
|
||||||
|
if(type == Action.BLOCK) {
|
||||||
|
out.writeInt(x);
|
||||||
|
out.writeInt(y);
|
||||||
|
out.writeInt(z);
|
||||||
|
} else if(type == Action.ENTITY) {
|
||||||
|
out.writeInt(entityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteBufUtils.writeNBT(out, compound);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||||
|
if (!(player instanceof EntityPlayerMP))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Action requestedAction = Action.values()[in.readInt()];
|
||||||
|
if (requestedAction == Action.BLOCK) {
|
||||||
|
int x = in.readInt();
|
||||||
|
int y = in.readInt();
|
||||||
|
int z = in.readInt();
|
||||||
|
NBTTagCompound compound = ByteBufUtils.readNBT(in);
|
||||||
|
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
|
||||||
|
if(tile != null) {
|
||||||
|
tile.readFromNBT(compound);
|
||||||
|
tile.markDirty();
|
||||||
|
}
|
||||||
|
} else if (requestedAction == Action.ENTITY) {
|
||||||
|
int entityId = in.readInt();
|
||||||
|
NBTTagCompound compound = ByteBufUtils.readNBT(in);
|
||||||
|
Entity entity = player.worldObj.getEntityByID(entityId);
|
||||||
|
if(entity != null) {
|
||||||
|
entity.readFromNBT(compound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SaveBlock(int x, int y, int z, NBTTagCompound compound) {
|
||||||
|
PacketClient.sendClient(new NbtBookPacket(x, y, z, compound));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SaveEntity(int entityId, NBTTagCompound compound) {
|
||||||
|
PacketClient.sendClient(new NbtBookPacket(entityId, compound));
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum Action {
|
||||||
|
BLOCK,
|
||||||
|
ENTITY
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,6 +28,7 @@ public class CustomItems {
|
|||||||
public static Item mount;
|
public static Item mount;
|
||||||
public static Item teleporter;
|
public static Item teleporter;
|
||||||
public static Item tool;
|
public static Item tool;
|
||||||
|
public static Item nbt_book;
|
||||||
|
|
||||||
public static Item scripted_item;
|
public static Item scripted_item;
|
||||||
public static Item linked_item;
|
public static Item linked_item;
|
||||||
@@ -249,6 +250,7 @@ public class CustomItems {
|
|||||||
scripted_item = new ItemScripted().setUnlocalizedName("scripted_item").setFull3D();
|
scripted_item = new ItemScripted().setUnlocalizedName("scripted_item").setFull3D();
|
||||||
linked_item = new ItemLinked().setUnlocalizedName("linked_item").setFull3D();
|
linked_item = new ItemLinked().setUnlocalizedName("linked_item").setFull3D();
|
||||||
tool = new ItemNpcTool().setUnlocalizedName("npcTool").setFull3D();
|
tool = new ItemNpcTool().setUnlocalizedName("npcTool").setFull3D();
|
||||||
|
nbt_book = new ItemNbtBook().setUnlocalizedName("npc_book");
|
||||||
|
|
||||||
redstoneBlock = new BlockNpcRedstone().setHardness(50.0F).setResistance(2000).setBlockName("npcRedstoneBlock").setBlockTextureName("customnpcs:npcRedstoneBlock").setCreativeTab(tab);
|
redstoneBlock = new BlockNpcRedstone().setHardness(50.0F).setResistance(2000).setBlockName("npcRedstoneBlock").setBlockTextureName("customnpcs:npcRedstoneBlock").setCreativeTab(tab);
|
||||||
carpentyBench = new BlockCarpentryBench().setBlockName("npcCarpentyBench").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypePiston).setCreativeTab(tabBlocks);
|
carpentyBench = new BlockCarpentryBench().setBlockName("npcCarpentyBench").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypePiston).setCreativeTab(tabBlocks);
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ public class CustomNpcsPermissions {
|
|||||||
public static final Permission TOOL_CLONER = new Permission("customnpcs.tool.cloner");
|
public static final Permission TOOL_CLONER = new Permission("customnpcs.tool.cloner");
|
||||||
public static final Permission TOOL_SCRIPTED_ITEM = new Permission("customnpcs.tool.scripteditem");
|
public static final Permission TOOL_SCRIPTED_ITEM = new Permission("customnpcs.tool.scripteditem");
|
||||||
public static final Permission TOOL_TELEPORTER = new Permission("customnpcs.tool.teleporter");
|
public static final Permission TOOL_TELEPORTER = new Permission("customnpcs.tool.teleporter");
|
||||||
|
public static final Permission TOOL_NBT_BOOK = new Permission("customnpcs.tool.nbtbook");
|
||||||
|
|
||||||
|
|
||||||
// Edit Villager
|
// Edit Villager
|
||||||
public static final Permission EDIT_VILLAGER = new Permission("customnpcs.edit.villager");
|
public static final Permission EDIT_VILLAGER = new Permission("customnpcs.edit.villager");
|
||||||
|
|||||||
@@ -390,6 +390,11 @@ public class EventHooks {
|
|||||||
return NpcAPI.EVENT_BUS.post(event);
|
return NpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerRightClick(PlayerDataScript handler, PlayerEvent.RightClickEvent event) {
|
||||||
|
handler.callScript(EnumScriptType.RIGHT_CLICK, event);
|
||||||
|
return NpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean onProfileChange(PlayerDataScript handler, IPlayer player, IProfile profile, int newSlot, int prevSlot, boolean post) {
|
public static boolean onProfileChange(PlayerDataScript handler, IPlayer player, IProfile profile, int newSlot, int prevSlot, boolean post) {
|
||||||
PlayerEvent.ProfileEvent.Changed event = new PlayerEvent.ProfileEvent.Changed(player, profile, newSlot, prevSlot, post);
|
PlayerEvent.ProfileEvent.Changed event = new PlayerEvent.ProfileEvent.Changed(player, profile, newSlot, prevSlot, post);
|
||||||
handler.callScript(EnumScriptType.PROFILE_CHANGE, event);
|
handler.callScript(EnumScriptType.PROFILE_CHANGE, event);
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ public class ScriptItemEventHandler {
|
|||||||
|
|
||||||
ItemNpcTool.setColor(held.getTagCompound(), color);
|
ItemNpcTool.setColor(held.getTagCompound(), color);
|
||||||
e.setCanceled(true);
|
e.setCanceled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import net.minecraftforge.event.entity.item.ItemTossEvent;
|
|||||||
import net.minecraftforge.event.entity.living.*;
|
import net.minecraftforge.event.entity.living.*;
|
||||||
import net.minecraftforge.event.entity.player.*;
|
import net.minecraftforge.event.entity.player.*;
|
||||||
import net.minecraftforge.event.world.BlockEvent;
|
import net.minecraftforge.event.world.BlockEvent;
|
||||||
|
import noppes.npcs.api.IWorld;
|
||||||
import noppes.npcs.api.entity.IPlayer;
|
import noppes.npcs.api.entity.IPlayer;
|
||||||
import noppes.npcs.api.item.IItemCustomizable;
|
import noppes.npcs.api.item.IItemCustomizable;
|
||||||
import noppes.npcs.config.ConfigMain;
|
import noppes.npcs.config.ConfigMain;
|
||||||
@@ -33,9 +34,12 @@ import noppes.npcs.controllers.PlayerDataController;
|
|||||||
import noppes.npcs.controllers.ScriptController;
|
import noppes.npcs.controllers.ScriptController;
|
||||||
import noppes.npcs.controllers.data.*;
|
import noppes.npcs.controllers.data.*;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
import noppes.npcs.items.ItemNbtBook;
|
||||||
import noppes.npcs.items.ItemNpcTool;
|
import noppes.npcs.items.ItemNpcTool;
|
||||||
|
import noppes.npcs.items.ItemScripted;
|
||||||
import noppes.npcs.quests.QuestItem;
|
import noppes.npcs.quests.QuestItem;
|
||||||
import noppes.npcs.scripted.NpcAPI;
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
|
import noppes.npcs.scripted.event.ItemEvent;
|
||||||
|
|
||||||
import static noppes.npcs.config.ConfigMain.TrackedQuestUpdateFrequency;
|
import static noppes.npcs.config.ConfigMain.TrackedQuestUpdateFrequency;
|
||||||
|
|
||||||
@@ -122,10 +126,59 @@ public class ScriptPlayerEventHandler {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) {
|
if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) {
|
||||||
|
if(event.entityPlayer.getHeldItem() != null && event.entityPlayer.getHeldItem().getItem() != null && event.entityPlayer.getHeldItem().getItem() == CustomItems.nbt_book) {
|
||||||
|
((ItemNbtBook)event.entityPlayer.getHeldItem().getItem()).entityEvent(event);
|
||||||
|
event.setCanceled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer);
|
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer);
|
||||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
|
IPlayer ip = NoppesUtilServer.getIPlayer(event.entityPlayer);
|
||||||
noppes.npcs.scripted.event.player.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.player.PlayerEvent.InteractEvent(scriptPlayer, 1, NpcAPI.Instance().getIEntity(event.target));
|
|
||||||
event.setCanceled(EventHooks.onPlayerInteract(handler, ev));
|
noppes.npcs.scripted.event.player.PlayerEvent.RightClickEvent rightClickEvent = new noppes.npcs.scripted.event.player.PlayerEvent.RightClickEvent(ip, 1, NpcAPI.Instance().getIEntity(event.target));
|
||||||
|
boolean rightClick = EventHooks.onPlayerRightClick(handler, rightClickEvent);
|
||||||
|
|
||||||
|
noppes.npcs.scripted.event.player.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.player.PlayerEvent.InteractEvent(ip, 1, NpcAPI.Instance().getIEntity(event.target));
|
||||||
|
boolean interact = EventHooks.onPlayerInteract(handler, ev);
|
||||||
|
|
||||||
|
event.setCanceled(rightClick || interact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerInteractEvent event) {
|
||||||
|
if (event.entityPlayer == null || event.entityPlayer.worldObj == null || event.entityPlayer.worldObj.isRemote || !(event.entityPlayer instanceof EntityPlayerMP))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
IPlayer ip = NoppesUtilServer.getIPlayer(event.entityPlayer);
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer);
|
||||||
|
PlayerData pd = PlayerData.get(event.entityPlayer);
|
||||||
|
if (pd == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR){
|
||||||
|
if (pd.hadInteract) {
|
||||||
|
pd.hadInteract = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
noppes.npcs.scripted.event.player.PlayerEvent.RightClickEvent rightClickEvent = new noppes.npcs.scripted.event.player.PlayerEvent.RightClickEvent(ip, 0, null);
|
||||||
|
event.setCanceled(EventHooks.onPlayerRightClick(handler, rightClickEvent));
|
||||||
|
} else if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK){
|
||||||
|
if(event.entityPlayer.getHeldItem() != null && event.entityPlayer.getHeldItem().getItem() != null && event.entityPlayer.getHeldItem().getItem() == CustomItems.nbt_book) {
|
||||||
|
((ItemNbtBook)event.entityPlayer.getHeldItem().getItem()).blockEvent(event);
|
||||||
|
event.setCanceled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pd.hadInteract = true;
|
||||||
|
IWorld iw = (IWorld) NpcAPI.Instance().getIWorld(event.world);
|
||||||
|
Object blockCtx = NpcAPI.Instance().getIBlock(iw, event.x, event.y, event.z);
|
||||||
|
noppes.npcs.scripted.event.player.PlayerEvent.RightClickEvent rightClickEvent = new noppes.npcs.scripted.event.player.PlayerEvent.RightClickEvent(ip, 2, blockCtx);
|
||||||
|
event.setCanceled(EventHooks.onPlayerRightClick(handler, rightClickEvent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import net.minecraft.network.Packet;
|
|||||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.Facing;
|
||||||
|
|
||||||
import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG;
|
import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG;
|
||||||
|
|
||||||
@@ -18,6 +19,11 @@ public class TileVariant extends TileEntity {
|
|||||||
public int variant = 14;
|
public int variant = 14;
|
||||||
public int rotation;
|
public int rotation;
|
||||||
|
|
||||||
|
// Rotation = 0 Couch is Facing North
|
||||||
|
// Rotation = 1 Couch is Facing East
|
||||||
|
// Rotation = 2 Couch is Facing South
|
||||||
|
// Rotation = 3 Couch is Facing West
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound compound) {
|
public void readFromNBT(NBTTagCompound compound) {
|
||||||
super.readFromNBT(compound);
|
super.readFromNBT(compound);
|
||||||
version = compound.getInteger("CNPCVersion");
|
version = compound.getInteger("CNPCVersion");
|
||||||
|
|||||||
@@ -431,6 +431,9 @@ public class ClientProxy extends CommonProxy {
|
|||||||
else if (gui == EnumGuiType.MagicBook)
|
else if (gui == EnumGuiType.MagicBook)
|
||||||
return new GuiNpcMagicBook();
|
return new GuiNpcMagicBook();
|
||||||
|
|
||||||
|
else if (gui == EnumGuiType.NbtBook)
|
||||||
|
return new GuiNbtBook(x, y, z);
|
||||||
|
|
||||||
else if (gui == EnumGuiType.GlobalRemote)
|
else if (gui == EnumGuiType.GlobalRemote)
|
||||||
return new GuiNPCGlobalMainMenu(null);
|
return new GuiNPCGlobalMainMenu(null);
|
||||||
|
|
||||||
|
|||||||
@@ -98,8 +98,6 @@ public class ImageDownloadAlt extends SimpleTexture {
|
|||||||
this.imageThread = new Thread("Texture Downloader #" + threadDownloadCounter.incrementAndGet()) {
|
this.imageThread = new Thread("Texture Downloader #" + threadDownloadCounter.incrementAndGet()) {
|
||||||
public void run() {
|
public void run() {
|
||||||
HttpURLConnection connection = null;
|
HttpURLConnection connection = null;
|
||||||
ImageDownloadAlt.logger.debug("Downloading http texture from {} to {}", new Object[]{ImageDownloadAlt.this.imageUrl, ImageDownloadAlt.this.cacheFile});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
URL url = new URL(ImageDownloadAlt.this.imageUrl);
|
URL url = new URL(ImageDownloadAlt.this.imageUrl);
|
||||||
connection = (HttpURLConnection) (url).openConnection(Minecraft.getMinecraft().getProxy());
|
connection = (HttpURLConnection) (url).openConnection(Minecraft.getMinecraft().getProxy());
|
||||||
|
|||||||
@@ -0,0 +1,175 @@
|
|||||||
|
package noppes.npcs.client.gui;
|
||||||
|
|
||||||
|
import kamkeel.npcs.network.packets.request.nbtbook.NbtBookPacket;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.JsonToNBT;
|
||||||
|
import net.minecraft.nbt.NBTException;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||||
|
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||||
|
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||||
|
import noppes.npcs.client.gui.util.IGuiData;
|
||||||
|
import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
public class GuiNbtBook extends GuiNPCInterface implements IGuiData{
|
||||||
|
|
||||||
|
private int x, y, z;
|
||||||
|
private TileEntity tile;
|
||||||
|
private Block block;
|
||||||
|
private ItemStack blockStack;
|
||||||
|
|
||||||
|
private int entityId;
|
||||||
|
private Entity entity;
|
||||||
|
|
||||||
|
private NBTTagCompound originalCompound;
|
||||||
|
private NBTTagCompound compound;
|
||||||
|
|
||||||
|
private String faultyText = null;
|
||||||
|
private String errorMessage = null;
|
||||||
|
|
||||||
|
public GuiNbtBook(int x, int y, int z) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
setBackground("menubg.png");
|
||||||
|
xSize = 256;
|
||||||
|
ySize = 216;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui(){
|
||||||
|
super.initGui();
|
||||||
|
if(block != null) {
|
||||||
|
addLabel(new GuiNpcLabel(11, "x: " + x + ", y: " + y + ", z: " + z, guiLeft + 60, guiTop + 6));
|
||||||
|
addLabel(new GuiNpcLabel(12, "id: " + Block.blockRegistry.getNameForObject(block), guiLeft + 60, guiTop + 16));
|
||||||
|
}
|
||||||
|
if(entity != null) {
|
||||||
|
addLabel(new GuiNpcLabel(12, "id: " + entity.getClass().getSimpleName(), guiLeft + 60, guiTop + 6));
|
||||||
|
}
|
||||||
|
|
||||||
|
addButton(new GuiNpcButton(0, guiLeft + 38, guiTop + 144, 180,20, "nbt.edit"));
|
||||||
|
getButton(0).enabled = compound != null && !compound.hasNoTags();
|
||||||
|
|
||||||
|
addLabel(new GuiNpcLabel(0, "", guiLeft + 4, guiTop + 167));
|
||||||
|
addLabel(new GuiNpcLabel(1, "", guiLeft + 4, guiTop + 177));
|
||||||
|
|
||||||
|
addButton(new GuiNpcButton(66, guiLeft + 128, guiTop + 190,120,20, "gui.close"));
|
||||||
|
addButton(new GuiNpcButton(67, guiLeft + 4, guiTop + 190,120,20, "gui.save"));
|
||||||
|
|
||||||
|
if(errorMessage != null) {
|
||||||
|
getButton(67).enabled = false;
|
||||||
|
int i = errorMessage.indexOf(" at: ");
|
||||||
|
if(i > 0) {
|
||||||
|
getLabel(0).label = errorMessage.substring(0, i);
|
||||||
|
getLabel(1).label = errorMessage.substring(i);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
getLabel(0).label = errorMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(getButton(67).enabled && originalCompound != null) {
|
||||||
|
getButton(67).enabled = !originalCompound.equals(compound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton guibutton) {
|
||||||
|
int id = guibutton.id;
|
||||||
|
if(id == 0) {
|
||||||
|
if(faultyText != null) {
|
||||||
|
setSubGui(new SubGuiNpcTextArea(compound.toString(), faultyText).enableHighlighting());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setSubGui(new SubGuiNpcTextArea(compound.toString()).enableHighlighting());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(id == 67) {
|
||||||
|
getLabel(0).label = "Saved";
|
||||||
|
if(compound.equals(originalCompound))
|
||||||
|
return;
|
||||||
|
if(tile == null) {
|
||||||
|
NbtBookPacket.SaveEntity(entityId, compound);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NbtBookPacket.SaveBlock(x, y, z, compound);
|
||||||
|
}
|
||||||
|
originalCompound = (NBTTagCompound) compound.copy();
|
||||||
|
getButton(67).enabled = false;
|
||||||
|
}
|
||||||
|
if(id == 66) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
|
if(hasSubGui())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(block != null) {
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
GL11.glTranslatef(guiLeft + 4, guiTop + 4, 0);
|
||||||
|
GL11.glScalef(3, 3, 3);
|
||||||
|
RenderHelper.enableGUIStandardItemLighting();
|
||||||
|
if(blockStack != null){
|
||||||
|
itemRender.renderItemAndEffectIntoGUI(this.mc.fontRenderer, this.mc.getTextureManager(), blockStack,0, 0);
|
||||||
|
itemRender.renderItemOverlayIntoGUI(this.mc.fontRenderer, this.mc.getTextureManager(), blockStack, 0, 0);
|
||||||
|
}
|
||||||
|
RenderHelper.disableStandardItemLighting();
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entity instanceof EntityLivingBase) {
|
||||||
|
drawNpc((EntityLivingBase)entity, 20, 80, 1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closeSubGui(SubGuiInterface gui) {
|
||||||
|
super.closeSubGui(gui);
|
||||||
|
|
||||||
|
if(gui instanceof SubGuiNpcTextArea){
|
||||||
|
try {
|
||||||
|
compound = (NBTTagCompound) JsonToNBT.func_150315_a(((SubGuiNpcTextArea)gui).text);
|
||||||
|
errorMessage = faultyText = null;
|
||||||
|
} catch (NBTException e) {
|
||||||
|
errorMessage = e.getLocalizedMessage();
|
||||||
|
faultyText = ((SubGuiNpcTextArea)gui).text;
|
||||||
|
}
|
||||||
|
initGui();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
|
if(compound.hasKey("EntityId")) {
|
||||||
|
entityId = compound.getInteger("EntityId");
|
||||||
|
entity = player.worldObj.getEntityByID(entityId);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tile = player.worldObj.getTileEntity(x, y, z);
|
||||||
|
block = player.worldObj.getBlock(x, y, z);
|
||||||
|
if(block != null && Item.getItemFromBlock(block) != null){
|
||||||
|
blockStack = new ItemStack(Item.getItemFromBlock(block), 1, player.worldObj.getBlockMetadata(x, y, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
originalCompound = compound.getCompoundTag("Data");
|
||||||
|
this.compound = (NBTTagCompound) originalCompound.copy();
|
||||||
|
initGui();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
public Map<String, List<String>> languages = new HashMap<String, List<String>>();
|
public Map<String, List<String>> languages = new HashMap<String, List<String>>();
|
||||||
|
|
||||||
private static int activeConsole = 0;
|
private static int activeConsole = 0;
|
||||||
|
boolean loaded = false;
|
||||||
|
|
||||||
public GuiScript(EntityNPCInterface npc) {
|
public GuiScript(EntityNPCInterface npc) {
|
||||||
super(npc);
|
super(npc);
|
||||||
@@ -258,12 +259,15 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
}
|
}
|
||||||
this.languages = languages;
|
this.languages = languages;
|
||||||
initGui();
|
initGui();
|
||||||
|
loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save() {
|
public void save() {
|
||||||
setScript();
|
if(loaded){
|
||||||
NPCScriptPacket.Save(script.writeToNBT(new NBTTagCompound()));
|
setScript();
|
||||||
|
NPCScriptPacket.Save(script.writeToNBT(new NBTTagCompound()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener,
|
|||||||
addLabel(new GuiNpcLabel(50, "magic.interaction", guiLeft + 170, guiTop + 30 + 160 + 5));
|
addLabel(new GuiNpcLabel(50, "magic.interaction", guiLeft + 170, guiTop + 30 + 160 + 5));
|
||||||
interactionField = new GuiNpcTextField(90, this, fontRendererObj, guiLeft + 245, guiTop + 30 + 160, 45, 20, "");
|
interactionField = new GuiNpcTextField(90, this, fontRendererObj, guiLeft + 245, guiTop + 30 + 160, 45, 20, "");
|
||||||
interactionField.setFloatsOnly();
|
interactionField.setFloatsOnly();
|
||||||
|
interactionField.setMinMaxDefaultFloat(-Float.MAX_VALUE, Float.MAX_VALUE, 0.0f);
|
||||||
|
|
||||||
addTextField(interactionField);
|
addTextField(interactionField);
|
||||||
if (selectedInteraction != null) {
|
if (selectedInteraction != null) {
|
||||||
interactionField.setText(interactionValues.get(selectedInteraction) + "");
|
interactionField.setText(interactionValues.get(selectedInteraction) + "");
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ package noppes.npcs.client.gui;
|
|||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import noppes.npcs.NoppesStringUtils;
|
import noppes.npcs.NoppesStringUtils;
|
||||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
import noppes.npcs.client.gui.util.*;
|
||||||
import noppes.npcs.client.gui.util.GuiNpcTextArea;
|
|
||||||
import noppes.npcs.client.gui.util.SubGuiInterface;
|
|
||||||
|
|
||||||
public class SubGuiNpcTextArea extends SubGuiInterface {
|
public class SubGuiNpcTextArea extends SubGuiInterface implements ITextChangeListener {
|
||||||
public String text;
|
public String text;
|
||||||
private GuiNpcTextArea textarea;
|
public String originalText;
|
||||||
|
private GuiScriptTextArea textarea;
|
||||||
|
private boolean highlighting = false;
|
||||||
|
|
||||||
public SubGuiNpcTextArea(String text) {
|
public SubGuiNpcTextArea(String text) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
@@ -18,6 +18,11 @@ public class SubGuiNpcTextArea extends SubGuiInterface {
|
|||||||
closeOnEsc = true;
|
closeOnEsc = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SubGuiNpcTextArea(String originalText, String text){
|
||||||
|
this(text);
|
||||||
|
this.originalText = originalText;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
xSize = (int) (width * 0.88);
|
xSize = (int) (width * 0.88);
|
||||||
@@ -26,13 +31,20 @@ public class SubGuiNpcTextArea extends SubGuiInterface {
|
|||||||
super.initGui();
|
super.initGui();
|
||||||
if (textarea != null)
|
if (textarea != null)
|
||||||
this.text = textarea.getText();
|
this.text = textarea.getText();
|
||||||
|
if(textarea != null)
|
||||||
|
this.text = textarea.getText();
|
||||||
int yoffset = (int) (ySize * 0.02);
|
int yoffset = (int) (ySize * 0.02);
|
||||||
this.addTextField(textarea = new GuiNpcTextArea(2, this, guiLeft + yoffset, guiTop + yoffset, xSize - 100 - yoffset * 2, ySize - yoffset * 2, text));
|
|
||||||
|
|
||||||
|
textarea = new GuiScriptTextArea(this, 2, guiLeft + 1 + yoffset, guiTop + yoffset, xSize - 100 - yoffset, (int) (ySize) - yoffset * 2, text);
|
||||||
|
textarea.setListener(this);
|
||||||
|
if(highlighting)
|
||||||
|
textarea.enableCodeHighlighting();
|
||||||
|
addTextField(textarea);
|
||||||
|
|
||||||
this.buttonList.add(new GuiNpcButton(102, guiLeft + xSize - 90 - yoffset, guiTop + 20, 56, 20, "gui.clear"));
|
this.buttonList.add(new GuiNpcButton(102, guiLeft + xSize - 90 - yoffset, guiTop + 20, 56, 20, "gui.clear"));
|
||||||
this.buttonList.add(new GuiNpcButton(101, guiLeft + xSize - 90 - yoffset, guiTop + 43, 56, 20, "gui.paste"));
|
this.buttonList.add(new GuiNpcButton(101, guiLeft + xSize - 90 - yoffset, guiTop + 43, 56, 20, "gui.paste"));
|
||||||
this.buttonList.add(new GuiNpcButton(100, guiLeft + xSize - 90 - yoffset, guiTop + 66, 56, 20, "gui.copy"));
|
this.buttonList.add(new GuiNpcButton(100, guiLeft + xSize - 90 - yoffset, guiTop + 66, 56, 20, "gui.copy"));
|
||||||
|
this.buttonList.add(new GuiNpcButton(103, guiLeft + xSize - 90 - yoffset, guiTop + 89, 56, 20, "remote.reset"));
|
||||||
|
|
||||||
this.buttonList.add(new GuiNpcButton(0, guiLeft + xSize - 90 - yoffset, guiTop + 160, 56, 20, "gui.close"));
|
this.buttonList.add(new GuiNpcButton(0, guiLeft + xSize - 90 - yoffset, guiTop + 160, 56, 20, "gui.close"));
|
||||||
|
|
||||||
@@ -47,20 +59,33 @@ public class SubGuiNpcTextArea extends SubGuiInterface {
|
|||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SubGuiNpcTextArea enableHighlighting() {
|
||||||
|
highlighting = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buttonEvent(GuiButton guibutton) {
|
public void buttonEvent(GuiButton guibutton) {
|
||||||
int id = guibutton.id;
|
int id = guibutton.id;
|
||||||
if (id == 100) {
|
if (id == 100) {
|
||||||
NoppesStringUtils.setClipboardContents(getTextField(2).getText());
|
NoppesStringUtils.setClipboardContents(textarea.getText());
|
||||||
}
|
}
|
||||||
if (id == 101) {
|
if (id == 101) {
|
||||||
getTextField(2).setText(NoppesStringUtils.getClipboardContents());
|
textarea.setText(NoppesStringUtils.getClipboardContents());
|
||||||
}
|
}
|
||||||
if (id == 102) {
|
if (id == 102) {
|
||||||
getTextField(2).setText("");
|
textarea.setText("");
|
||||||
}
|
}
|
||||||
if (id == 0) {
|
if (id == 103) {
|
||||||
|
textarea.setText(originalText);
|
||||||
|
}
|
||||||
|
if(id == 0){
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void textUpdate(String text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -119,6 +119,7 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData {
|
|||||||
@Override
|
@Override
|
||||||
public void setGuiData(NBTTagCompound compound) {
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
if (compound.hasKey("RoleData")) {
|
if (compound.hasKey("RoleData")) {
|
||||||
|
npc.advanced.setRole(compound.getByte("RoleData"));
|
||||||
if (npc.roleInterface != null)
|
if (npc.roleInterface != null)
|
||||||
npc.roleInterface.readFromNBT(compound);
|
npc.roleInterface.readFromNBT(compound);
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ public class GuiNPCEventScripts extends GuiScriptInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setGuiData(NBTTagCompound compound) {
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
|
if(compound.hasKey("LoadComplete")){
|
||||||
|
loaded = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!compound.hasKey("Tab")) {
|
if (!compound.hasKey("Tab")) {
|
||||||
script.setLanguage(compound.getString("ScriptLanguage"));
|
script.setLanguage(compound.getString("ScriptLanguage"));
|
||||||
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||||
@@ -58,16 +63,18 @@ public class GuiNPCEventScripts extends GuiScriptInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
super.save();
|
if(loaded) {
|
||||||
List<ScriptContainer> containers = this.script.getScripts();
|
super.save();
|
||||||
for (int i = 0; i < containers.size(); i++) {
|
List<ScriptContainer> containers = this.script.getScripts();
|
||||||
ScriptContainer container = containers.get(i);
|
for (int i = 0; i < containers.size(); i++) {
|
||||||
EventScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
ScriptContainer container = containers.get(i);
|
||||||
|
EventScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||||
|
}
|
||||||
|
NBTTagCompound scriptData = new NBTTagCompound();
|
||||||
|
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
||||||
|
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
||||||
|
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
||||||
|
EventScriptPacket.Save(-1, containers.size(), scriptData);
|
||||||
}
|
}
|
||||||
NBTTagCompound scriptData = new NBTTagCompound();
|
|
||||||
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
|
||||||
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
|
||||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
|
||||||
EventScriptPacket.Save(-1, containers.size(), scriptData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,6 +35,11 @@ public class GuiScriptAllNPCs extends GuiScriptInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setGuiData(NBTTagCompound compound) {
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
|
if(compound.hasKey("LoadComplete")){
|
||||||
|
loaded = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!compound.hasKey("Tab")) {
|
if (!compound.hasKey("Tab")) {
|
||||||
script.setLanguage(compound.getString("ScriptLanguage"));
|
script.setLanguage(compound.getString("ScriptLanguage"));
|
||||||
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||||
@@ -54,16 +59,18 @@ public class GuiScriptAllNPCs extends GuiScriptInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
super.save();
|
if(loaded){
|
||||||
List<ScriptContainer> containers = this.script.getScripts();
|
super.save();
|
||||||
for (int i = 0; i < containers.size(); i++) {
|
List<ScriptContainer> containers = this.script.getScripts();
|
||||||
ScriptContainer container = containers.get(i);
|
for (int i = 0; i < containers.size(); i++) {
|
||||||
GlobalNPCScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
ScriptContainer container = containers.get(i);
|
||||||
|
GlobalNPCScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||||
|
}
|
||||||
|
NBTTagCompound scriptData = new NBTTagCompound();
|
||||||
|
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
||||||
|
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
||||||
|
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
||||||
|
GlobalNPCScriptPacket.Save(-1, containers.size(), scriptData);
|
||||||
}
|
}
|
||||||
NBTTagCompound scriptData = new NBTTagCompound();
|
|
||||||
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
|
||||||
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
|
||||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
|
||||||
GlobalNPCScriptPacket.Save(-1, containers.size(), scriptData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,10 +30,13 @@ public class GuiScriptBlock extends GuiScriptInterface {
|
|||||||
public void setGuiData(NBTTagCompound compound) {
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
this.tileScripted.setNBT(compound);
|
this.tileScripted.setNBT(compound);
|
||||||
super.setGuiData(compound);
|
super.setGuiData(compound);
|
||||||
|
loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
super.save();
|
if(loaded) {
|
||||||
BlockScriptPacket.Save(tileScripted.xCoord, tileScripted.yCoord, tileScripted.zCoord, this.tileScripted.getNBT(new NBTTagCompound()));
|
super.save();
|
||||||
|
BlockScriptPacket.Save(tileScripted.xCoord, tileScripted.yCoord, tileScripted.zCoord, this.tileScripted.getNBT(new NBTTagCompound()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback
|
|||||||
public final GuiNPCManageEffects parent;
|
public final GuiNPCManageEffects parent;
|
||||||
public final CustomEffect effect;
|
public final CustomEffect effect;
|
||||||
private final EffectScript scriptHandler;
|
private final EffectScript scriptHandler;
|
||||||
|
boolean loaded = false;
|
||||||
|
|
||||||
public GuiScriptEffect(GuiNPCManageEffects parent, CustomEffect effect) {
|
public GuiScriptEffect(GuiNPCManageEffects parent, CustomEffect effect) {
|
||||||
this.drawDefaultBackground = true;
|
this.drawDefaultBackground = true;
|
||||||
@@ -315,6 +315,11 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setGuiData(NBTTagCompound compound) {
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
|
if(compound.hasKey("LoadComplete")){
|
||||||
|
loaded = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!compound.hasKey("Tab")) {
|
if (!compound.hasKey("Tab")) {
|
||||||
this.scriptHandler.setLanguage(compound.getString("ScriptLanguage"));
|
this.scriptHandler.setLanguage(compound.getString("ScriptLanguage"));
|
||||||
this.scriptHandler.setEnabled(compound.getBoolean("ScriptEnabled"));
|
this.scriptHandler.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||||
@@ -326,7 +331,6 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback
|
|||||||
this.scriptHandler.container = container;
|
this.scriptHandler.container = container;
|
||||||
this.initGui();
|
this.initGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copiedSetGuiData(NBTTagCompound compound) {
|
private void copiedSetGuiData(NBTTagCompound compound) {
|
||||||
@@ -350,19 +354,21 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
this.setScript();
|
if(loaded) {
|
||||||
|
this.setScript();
|
||||||
|
|
||||||
List<ScriptContainer> containers = this.scriptHandler.getScripts();
|
List<ScriptContainer> containers = this.scriptHandler.getScripts();
|
||||||
for (int i = 0; i < containers.size(); i++) {
|
for (int i = 0; i < containers.size(); i++) {
|
||||||
ScriptContainer container = containers.get(i);
|
ScriptContainer container = containers.get(i);
|
||||||
EffectScriptPacket.Save(effect.id, i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
EffectScriptPacket.Save(effect.id, i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||||
|
}
|
||||||
|
NBTTagCompound scriptData = new NBTTagCompound();
|
||||||
|
scriptData.setString("ScriptLanguage", this.scriptHandler.getLanguage());
|
||||||
|
scriptData.setBoolean("ScriptEnabled", this.scriptHandler.getEnabled());
|
||||||
|
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.scriptHandler.getConsoleText()));
|
||||||
|
|
||||||
|
EffectScriptPacket.Save(effect.id, -1, containers.size(), scriptData);
|
||||||
}
|
}
|
||||||
NBTTagCompound scriptData = new NBTTagCompound();
|
|
||||||
scriptData.setString("ScriptLanguage", this.scriptHandler.getLanguage());
|
|
||||||
scriptData.setBoolean("ScriptEnabled", this.scriptHandler.getEnabled());
|
|
||||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.scriptHandler.getConsoleText()));
|
|
||||||
|
|
||||||
EffectScriptPacket.Save(effect.id, -1, containers.size(), scriptData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void textUpdate(String text) {
|
public void textUpdate(String text) {
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ public class GuiScriptForge extends GuiScriptInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setGuiData(NBTTagCompound compound) {
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
|
if(compound.hasKey("LoadComplete")){
|
||||||
|
loaded = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!compound.hasKey("Tab")) {
|
if (!compound.hasKey("Tab")) {
|
||||||
script.setLanguage(compound.getString("ScriptLanguage"));
|
script.setLanguage(compound.getString("ScriptLanguage"));
|
||||||
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||||
@@ -84,16 +89,18 @@ public class GuiScriptForge extends GuiScriptInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
super.save();
|
if(loaded) {
|
||||||
List<ScriptContainer> containers = this.script.getScripts();
|
super.save();
|
||||||
for (int i = 0; i < containers.size(); i++) {
|
List<ScriptContainer> containers = this.script.getScripts();
|
||||||
ScriptContainer container = containers.get(i);
|
for (int i = 0; i < containers.size(); i++) {
|
||||||
ForgeScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
ScriptContainer container = containers.get(i);
|
||||||
|
ForgeScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||||
|
}
|
||||||
|
NBTTagCompound scriptData = new NBTTagCompound();
|
||||||
|
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
||||||
|
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
||||||
|
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
||||||
|
ForgeScriptPacket.Save(-1, containers.size(), scriptData);
|
||||||
}
|
}
|
||||||
NBTTagCompound scriptData = new NBTTagCompound();
|
|
||||||
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
|
||||||
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
|
||||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
|
||||||
ForgeScriptPacket.Save(-1, containers.size(), scriptData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
|||||||
public Map<String, List<String>> languages = new HashMap();
|
public Map<String, List<String>> languages = new HashMap();
|
||||||
private int scriptLimit = 1;
|
private int scriptLimit = 1;
|
||||||
public List<String> hookList = new ArrayList<String>();
|
public List<String> hookList = new ArrayList<String>();
|
||||||
|
protected boolean loaded = false;
|
||||||
|
|
||||||
public GuiScriptInterface() {
|
public GuiScriptInterface() {
|
||||||
this.drawDefaultBackground = true;
|
this.drawDefaultBackground = true;
|
||||||
@@ -338,7 +339,8 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
this.setScript();
|
if(loaded)
|
||||||
|
this.setScript();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void textUpdate(String text) {
|
public void textUpdate(String text) {
|
||||||
|
|||||||
@@ -44,12 +44,15 @@ public class GuiScriptItem extends GuiScriptInterface {
|
|||||||
this.item.setMCNbt(compound);
|
this.item.setMCNbt(compound);
|
||||||
this.item.loadScriptData();
|
this.item.loadScriptData();
|
||||||
super.setGuiData(compound);
|
super.setGuiData(compound);
|
||||||
|
loaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
super.save();
|
if(loaded) {
|
||||||
ItemScriptPacket.Save(this.item.getMCNbt());
|
super.save();
|
||||||
|
ItemScriptPacket.Save(this.item.getMCNbt());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getConsoleText() {
|
protected String getConsoleText() {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall
|
|||||||
public final GuiNPCManageLinked parent;
|
public final GuiNPCManageLinked parent;
|
||||||
public final LinkedItem linkedItem;
|
public final LinkedItem linkedItem;
|
||||||
private final LinkedItemScript scriptHandler;
|
private final LinkedItemScript scriptHandler;
|
||||||
|
boolean loaded = false;
|
||||||
|
|
||||||
public GuiScriptLinkedItem(GuiNPCManageLinked parent, LinkedItem linkedItem) {
|
public GuiScriptLinkedItem(GuiNPCManageLinked parent, LinkedItem linkedItem) {
|
||||||
this.drawDefaultBackground = true;
|
this.drawDefaultBackground = true;
|
||||||
@@ -326,6 +327,11 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setGuiData(NBTTagCompound compound) {
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
|
if(compound.hasKey("LoadComplete")){
|
||||||
|
loaded = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!compound.hasKey("Tab")) {
|
if (!compound.hasKey("Tab")) {
|
||||||
this.scriptHandler.setLanguage(compound.getString("ScriptLanguage"));
|
this.scriptHandler.setLanguage(compound.getString("ScriptLanguage"));
|
||||||
this.scriptHandler.setEnabled(compound.getBoolean("ScriptEnabled"));
|
this.scriptHandler.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||||
@@ -361,19 +367,21 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
this.setScript();
|
if(loaded) {
|
||||||
|
this.setScript();
|
||||||
|
|
||||||
List<ScriptContainer> containers = this.scriptHandler.getScripts();
|
List<ScriptContainer> containers = this.scriptHandler.getScripts();
|
||||||
for (int i = 0; i < containers.size(); i++) {
|
for (int i = 0; i < containers.size(); i++) {
|
||||||
ScriptContainer container = containers.get(i);
|
ScriptContainer container = containers.get(i);
|
||||||
LinkedItemScriptPacket.Save(linkedItem.id, i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
LinkedItemScriptPacket.Save(linkedItem.id, i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||||
|
}
|
||||||
|
NBTTagCompound scriptData = new NBTTagCompound();
|
||||||
|
scriptData.setString("ScriptLanguage", this.scriptHandler.getLanguage());
|
||||||
|
scriptData.setBoolean("ScriptEnabled", this.scriptHandler.getEnabled());
|
||||||
|
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.scriptHandler.getConsoleText()));
|
||||||
|
|
||||||
|
LinkedItemScriptPacket.Save(linkedItem.id, -1, containers.size(), scriptData);
|
||||||
}
|
}
|
||||||
NBTTagCompound scriptData = new NBTTagCompound();
|
|
||||||
scriptData.setString("ScriptLanguage", this.scriptHandler.getLanguage());
|
|
||||||
scriptData.setBoolean("ScriptEnabled", this.scriptHandler.getEnabled());
|
|
||||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.scriptHandler.getConsoleText()));
|
|
||||||
|
|
||||||
LinkedItemScriptPacket.Save(linkedItem.id, -1, containers.size(), scriptData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void textUpdate(String text) {
|
public void textUpdate(String text) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public class GuiScriptPlayers extends GuiScriptInterface {
|
|||||||
hookList.add(EnumScriptType.INIT.function);
|
hookList.add(EnumScriptType.INIT.function);
|
||||||
hookList.add(EnumScriptType.TICK.function);
|
hookList.add(EnumScriptType.TICK.function);
|
||||||
hookList.add(EnumScriptType.INTERACT.function);
|
hookList.add(EnumScriptType.INTERACT.function);
|
||||||
|
hookList.add(EnumScriptType.RIGHT_CLICK.function);
|
||||||
hookList.add(EnumScriptType.ATTACK.function);
|
hookList.add(EnumScriptType.ATTACK.function);
|
||||||
hookList.add(EnumScriptType.ATTACKED.function);
|
hookList.add(EnumScriptType.ATTACKED.function);
|
||||||
hookList.add(EnumScriptType.DAMAGED_ENTITY.function);
|
hookList.add(EnumScriptType.DAMAGED_ENTITY.function);
|
||||||
@@ -90,6 +91,11 @@ public class GuiScriptPlayers extends GuiScriptInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setGuiData(NBTTagCompound compound) {
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
|
if(compound.hasKey("LoadComplete")){
|
||||||
|
loaded = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!compound.hasKey("Tab")) {
|
if (!compound.hasKey("Tab")) {
|
||||||
script.setLanguage(compound.getString("ScriptLanguage"));
|
script.setLanguage(compound.getString("ScriptLanguage"));
|
||||||
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||||
@@ -109,16 +115,18 @@ public class GuiScriptPlayers extends GuiScriptInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
super.save();
|
if(loaded) {
|
||||||
List<ScriptContainer> containers = this.script.getScripts();
|
super.save();
|
||||||
for (int i = 0; i < containers.size(); i++) {
|
List<ScriptContainer> containers = this.script.getScripts();
|
||||||
ScriptContainer container = containers.get(i);
|
for (int i = 0; i < containers.size(); i++) {
|
||||||
PlayerScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
ScriptContainer container = containers.get(i);
|
||||||
|
PlayerScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||||
|
}
|
||||||
|
NBTTagCompound scriptData = new NBTTagCompound();
|
||||||
|
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
||||||
|
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
||||||
|
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
||||||
|
PlayerScriptPacket.Save(-1, containers.size(), scriptData);
|
||||||
}
|
}
|
||||||
NBTTagCompound scriptData = new NBTTagCompound();
|
|
||||||
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
|
||||||
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
|
||||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
|
||||||
PlayerScriptPacket.Save(-1, containers.size(), scriptData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,10 +15,14 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GuiNpcTextArea extends GuiNpcTextField {
|
public class GuiNpcTextArea extends GuiNpcTextField {
|
||||||
public boolean inMenu = true;
|
public int id;
|
||||||
public boolean numbersOnly = false;
|
public int x;
|
||||||
private int posX, posY, width, height;
|
public int y;
|
||||||
|
public int width;
|
||||||
|
public int height;
|
||||||
private int cursorCounter;
|
private int cursorCounter;
|
||||||
|
private ITextChangeListener listener;
|
||||||
|
public String text = null;
|
||||||
private FontContainer font;
|
private FontContainer font;
|
||||||
private int cursorPosition = 0;
|
private int cursorPosition = 0;
|
||||||
private int listHeight;
|
private int listHeight;
|
||||||
@@ -30,8 +34,8 @@ public class GuiNpcTextArea extends GuiNpcTextField {
|
|||||||
|
|
||||||
public GuiNpcTextArea(int id, GuiScreen guiscreen, int i, int j, int k, int l, String s) {
|
public GuiNpcTextArea(int id, GuiScreen guiscreen, int i, int j, int k, int l, String s) {
|
||||||
super(id, guiscreen, i, j, k, l, s);
|
super(id, guiscreen, i, j, k, l, s);
|
||||||
posX = i;
|
x = i;
|
||||||
posY = j;
|
y = j;
|
||||||
width = k;
|
width = k;
|
||||||
listHeight = height = l;
|
listHeight = height = l;
|
||||||
this.font = ClientProxy.Font;
|
this.font = ClientProxy.Font;
|
||||||
@@ -101,8 +105,8 @@ public class GuiNpcTextArea extends GuiNpcTextField {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = i - posX;
|
int x = i - this.x;
|
||||||
int y = (j - posY - 4) / font.height() + getStartLineY();
|
int y = (j - this.y - 4) / font.height() + getStartLineY();
|
||||||
cursorPosition = 0;
|
cursorPosition = 0;
|
||||||
int charCount = 0;
|
int charCount = 0;
|
||||||
int lineCount = 0;
|
int lineCount = 0;
|
||||||
@@ -160,8 +164,8 @@ public class GuiNpcTextArea extends GuiNpcTextField {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawTextBox(int mouseX, int mouseY) {
|
public void drawTextBox(int mouseX, int mouseY) {
|
||||||
drawRect(posX - 1, posY - 1, posX + width + 1, posY + height + 1, 0xffa0a0a0);
|
drawRect(x - 1, y - 1, x + width + 1, y + height + 1, 0xffa0a0a0);
|
||||||
drawRect(posX, posY, posX + width, posY + height, 0xff000000);
|
drawRect(x, y, x + width, y + height, 0xff000000);
|
||||||
|
|
||||||
//int color = isEnabled?0xe0e0e0:0x707070;
|
//int color = isEnabled?0xe0e0e0:0x707070;
|
||||||
int color = 0xe0e0e0;
|
int color = 0xe0e0e0;
|
||||||
@@ -180,13 +184,13 @@ public class GuiNpcTextArea extends GuiNpcTextField {
|
|||||||
for (char c : wholeLine.toCharArray()) {
|
for (char c : wholeLine.toCharArray()) {
|
||||||
if (font.width(line + c) > maxSize && wrapLine) {
|
if (font.width(line + c) > maxSize && wrapLine) {
|
||||||
if (lineCount >= startLine && lineCount < maxLine)
|
if (lineCount >= startLine && lineCount < maxLine)
|
||||||
drawString(null, line, posX + 4, posY + 4 + ((lineCount - startLine) * font.height()), color);
|
drawString(null, line, x + 4, y + 4 + ((lineCount - startLine) * font.height()), color);
|
||||||
line = "";
|
line = "";
|
||||||
lineCount++;
|
lineCount++;
|
||||||
}
|
}
|
||||||
if (flag && charCount == cursorPosition && lineCount >= startLine && lineCount < maxLine && canEdit) {
|
if (flag && charCount == cursorPosition && lineCount >= startLine && lineCount < maxLine && canEdit) {
|
||||||
int xx = posX + font.width(line) + 4;
|
int xx = x + font.width(line) + 4;
|
||||||
int yy = posY + ((lineCount - startLine) * font.height()) + 4;
|
int yy = y + ((lineCount - startLine) * font.height()) + 4;
|
||||||
if (getText().length() == cursorPosition) {
|
if (getText().length() == cursorPosition) {
|
||||||
font.drawString("_", xx, yy, color);
|
font.drawString("_", xx, yy, color);
|
||||||
} else {
|
} else {
|
||||||
@@ -197,10 +201,10 @@ public class GuiNpcTextArea extends GuiNpcTextField {
|
|||||||
line += c;
|
line += c;
|
||||||
}
|
}
|
||||||
if (lineCount >= startLine && lineCount < maxLine) {
|
if (lineCount >= startLine && lineCount < maxLine) {
|
||||||
drawString(null, line, posX + 4, posY + 4 + ((lineCount - startLine) * (font.height())), color);
|
drawString(null, line, x + 4, y + 4 + ((lineCount - startLine) * (font.height())), color);
|
||||||
if (flag && charCount == cursorPosition && canEdit) {
|
if (flag && charCount == cursorPosition && canEdit) {
|
||||||
int xx = posX + font.width(line) + 4;
|
int xx = x + font.width(line) + 4;
|
||||||
int yy = posY + ((lineCount - startLine) * font.height()) + 4;
|
int yy = y + ((lineCount - startLine) * font.height()) + 4;
|
||||||
if (getText().length() == cursorPosition) {
|
if (getText().length() == cursorPosition) {
|
||||||
font.drawString("_", xx, yy, color);
|
font.drawString("_", xx, yy, color);
|
||||||
} else {
|
} else {
|
||||||
@@ -221,12 +225,12 @@ public class GuiNpcTextArea extends GuiNpcTextField {
|
|||||||
if (Mouse.isButtonDown(0)) {
|
if (Mouse.isButtonDown(0)) {
|
||||||
if (clickVerticalBar) {
|
if (clickVerticalBar) {
|
||||||
if (startClick >= 0)
|
if (startClick >= 0)
|
||||||
addScrollY(startClick - (mouseY - posY));
|
addScrollY(startClick - (mouseY - y));
|
||||||
|
|
||||||
if (hoverVerticalScrollBar(mouseX, mouseY))
|
if (hoverVerticalScrollBar(mouseX, mouseY))
|
||||||
startClick = mouseY - posY;
|
startClick = mouseY - y;
|
||||||
|
|
||||||
startClick = mouseY - posY;
|
startClick = mouseY - y;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
clickVerticalBar = false;
|
clickVerticalBar = false;
|
||||||
@@ -260,7 +264,7 @@ public class GuiNpcTextArea extends GuiNpcTextField {
|
|||||||
if (listHeight <= height - 4)
|
if (listHeight <= height - 4)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (posY < y && posY + height > y && x < posX + width && x > posX + (width - 8))
|
if (this.y < y && this.y + height > y && x < this.x + width && x > this.x + (width - 8))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -281,12 +285,12 @@ public class GuiNpcTextArea extends GuiNpcTextField {
|
|||||||
p_146188_4_ = i1;
|
p_146188_4_ = i1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_146188_3_ > this.posX + this.width) {
|
if (p_146188_3_ > this.x + this.width) {
|
||||||
p_146188_3_ = this.posX + this.width;
|
p_146188_3_ = this.x + this.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_146188_1_ > this.posX + this.width) {
|
if (p_146188_1_ > this.x + this.width) {
|
||||||
p_146188_1_ = this.posX + this.width;
|
p_146188_1_ = this.x + this.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.instance;
|
Tessellator tessellator = Tessellator.instance;
|
||||||
@@ -312,8 +316,8 @@ public class GuiNpcTextArea extends GuiNpcTextField {
|
|||||||
if (listHeight <= height - 4)
|
if (listHeight <= height - 4)
|
||||||
return;
|
return;
|
||||||
Minecraft.getMinecraft().renderEngine.bindTexture(GuiCustomScroll.resource);
|
Minecraft.getMinecraft().renderEngine.bindTexture(GuiCustomScroll.resource);
|
||||||
int x = posX + width - 6;
|
int x = this.x + width - 6;
|
||||||
int y = (int) (posY + scrolledY * height) + 2;
|
int y = (int) (this.y + scrolledY * height) + 2;
|
||||||
GL11.glColor4f(1, 1, 1, 1);
|
GL11.glColor4f(1, 1, 1, 1);
|
||||||
int sbSize = getVerticalBarSize();
|
int sbSize = getVerticalBarSize();
|
||||||
drawTexturedModalRect(x, y, width, 9, 5, 1);
|
drawTexturedModalRect(x, y, width, 9, 5, 1);
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class BlockCouchWoolRenderer extends BlockRendererInterface {
|
|||||||
setCouchWood(var1.getBlockMetadata());
|
setCouchWood(var1.getBlockMetadata());
|
||||||
if (tile.hasCornerLeft) {
|
if (tile.hasCornerLeft) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glRotatef(90, 0, 1, 0);
|
GL11.glRotatef(270, 0, 1, 0);
|
||||||
modelCouchCorner.CouchBack.render(0.0625F);
|
modelCouchCorner.CouchBack.render(0.0625F);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
} else if (tile.hasCornerRight)
|
} else if (tile.hasCornerRight)
|
||||||
@@ -119,8 +119,12 @@ public class BlockCouchWoolRenderer extends BlockRendererInterface {
|
|||||||
float[] color = ColorUtil.hexToRGB(tile.color);
|
float[] color = ColorUtil.hexToRGB(tile.color);
|
||||||
GL11.glColor3f(color[0], color[1], color[2]);
|
GL11.glColor3f(color[0], color[1], color[2]);
|
||||||
|
|
||||||
if (tile.hasCornerLeft)
|
if (tile.hasCornerLeft){
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glRotatef(270, 0, 1, 0);
|
||||||
modelCouchCorner.Cussion.render(0.0625F);
|
modelCouchCorner.Cussion.render(0.0625F);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
else if (tile.hasCornerRight)
|
else if (tile.hasCornerRight)
|
||||||
modelCouchCorner.Cussion.render(0.0625F);
|
modelCouchCorner.Cussion.render(0.0625F);
|
||||||
else if (tile.hasLeft && tile.hasRight)
|
else if (tile.hasLeft && tile.hasRight)
|
||||||
|
|||||||
@@ -63,5 +63,6 @@ public enum EnumGuiType {
|
|||||||
ScriptItem,
|
ScriptItem,
|
||||||
ScriptBlock,
|
ScriptBlock,
|
||||||
Paintbrush,
|
Paintbrush,
|
||||||
MagicBook;
|
MagicBook,
|
||||||
|
NbtBook;
|
||||||
}
|
}
|
||||||
@@ -92,22 +92,20 @@ public class ScriptContainer {
|
|||||||
|
|
||||||
private String getFullCode() {
|
private String getFullCode() {
|
||||||
if (!this.evaluated) {
|
if (!this.evaluated) {
|
||||||
this.fullscript = this.script;
|
// build includes first
|
||||||
if (!this.fullscript.isEmpty()) {
|
StringBuilder sb = new StringBuilder();
|
||||||
this.fullscript = this.fullscript + "\n";
|
for (String loc : this.scripts) {
|
||||||
}
|
String code = ScriptController.Instance.scripts.get(loc);
|
||||||
|
|
||||||
Iterator var1 = this.scripts.iterator();
|
|
||||||
|
|
||||||
while (var1.hasNext()) {
|
|
||||||
String loc = (String) var1.next();
|
|
||||||
String code = (String) ScriptController.Instance.scripts.get(loc);
|
|
||||||
if (code != null && !code.isEmpty()) {
|
if (code != null && !code.isEmpty()) {
|
||||||
this.fullscript = this.fullscript + code + "\n";
|
sb.append(code).append("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// then your per‐hook script
|
||||||
this.unknownFunctions = new HashSet<String>();
|
if (this.script != null && !this.script.isEmpty()) {
|
||||||
|
sb.append(this.script).append("\n");
|
||||||
|
}
|
||||||
|
this.fullscript = sb.toString();
|
||||||
|
this.unknownFunctions = new HashSet<>();
|
||||||
}
|
}
|
||||||
return this.fullscript;
|
return this.fullscript;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ public class DataScript implements INpcScriptHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void callScript(String hookName, Event event) {
|
public void callScript(String hookName, Event event) {
|
||||||
try {
|
try {
|
||||||
EnumScriptType enumScriptType = EnumScriptType.valueOf(hookName);
|
EnumScriptType enumScriptType = EnumScriptType.valueOfIgnoreCase(hookName);
|
||||||
this.callScript(enumScriptType, event);
|
this.callScript(enumScriptType, event);
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package noppes.npcs.controllers.data.action;
|
package noppes.npcs.controllers.data.action;
|
||||||
|
|
||||||
import noppes.npcs.api.handler.data.IAction;
|
import noppes.npcs.api.handler.data.IAction;
|
||||||
import noppes.npcs.config.ConfigScript;
|
|
||||||
import noppes.npcs.scripted.ScriptedActionManager;
|
import noppes.npcs.scripted.ScriptedActionManager;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -128,7 +127,7 @@ public class Action implements IAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IAction addData(String key, Object v) {
|
public IAction setData(String key, Object v) {
|
||||||
dataStore.put(key, v);
|
dataStore.put(key, v);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -139,6 +138,11 @@ public class Action implements IAction {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasData(String key) {
|
||||||
|
return dataStore.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getUpdateEveryXTick() {
|
public int getUpdateEveryXTick() {
|
||||||
return updateEveryXTick;
|
return updateEveryXTick;
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package noppes.npcs.items;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import kamkeel.npcs.network.PacketHandler;
|
||||||
|
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.event.entity.player.EntityInteractEvent;
|
||||||
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
|
import noppes.npcs.*;
|
||||||
|
import noppes.npcs.config.ConfigMain;
|
||||||
|
import noppes.npcs.constants.EnumGuiType;
|
||||||
|
import noppes.npcs.entity.EntityCustomNpc;
|
||||||
|
|
||||||
|
public class ItemNbtBook extends Item {
|
||||||
|
|
||||||
|
public ItemNbtBook() {
|
||||||
|
maxStackSize = 1;
|
||||||
|
setCreativeTab(CustomItems.tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer player) {
|
||||||
|
if (!par2World.isRemote)
|
||||||
|
return par1ItemStack;
|
||||||
|
else if (CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.TOOL_NBT_BOOK)) {
|
||||||
|
CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.NbtBook, player);
|
||||||
|
} else
|
||||||
|
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
|
||||||
|
return par1ItemStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void blockEvent(PlayerInteractEvent event) {
|
||||||
|
NBTTagCompound data = new NBTTagCompound();
|
||||||
|
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
|
||||||
|
if(tile != null) {
|
||||||
|
tile.writeToNBT(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
|
compound.setTag("Data", data);
|
||||||
|
GuiDataPacket.sendGuiData((EntityPlayerMP) event.entityPlayer, compound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void entityEvent(EntityInteractEvent event) {
|
||||||
|
if(event.target instanceof EntityPlayer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NBTTagCompound data = new NBTTagCompound();
|
||||||
|
event.target.writeToNBTOptional(data);
|
||||||
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
|
compound.setInteger("EntityId", event.target.getEntityId());
|
||||||
|
compound.setTag("Data", data);
|
||||||
|
GuiDataPacket.sendGuiData((EntityPlayerMP) event.entityPlayer, compound);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColorFromItemStack(ItemStack par1ItemStack, int par2) {
|
||||||
|
return 0x8B4513;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public void registerIcons(IIconRegister par1IconRegister) {
|
||||||
|
this.itemIcon = Items.book.getIconFromDamage(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Item setUnlocalizedName(String name) {
|
||||||
|
GameRegistry.registerItem(this, name);
|
||||||
|
return super.setUnlocalizedName(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -136,7 +136,11 @@ public class ScriptWorld implements IWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IBlock getTopBlock(int x, int z) {
|
public IBlock getTopBlock(int x, int z) {
|
||||||
return NpcAPI.Instance().getIBlock(this, x, world.getTopSolidOrLiquidBlock(x, z), z);
|
int yAbove = world.getTopSolidOrLiquidBlock(x, z);
|
||||||
|
if (yAbove <= 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return NpcAPI.Instance().getIBlock(this, x, yAbove - 1, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBlock getTopBlock(IPos pos) {
|
public IBlock getTopBlock(IPos pos) {
|
||||||
|
|||||||
@@ -13,13 +13,16 @@ import noppes.npcs.api.IDamageSource;
|
|||||||
import noppes.npcs.api.entity.IEntity;
|
import noppes.npcs.api.entity.IEntity;
|
||||||
import noppes.npcs.api.entity.IEntityLivingBase;
|
import noppes.npcs.api.entity.IEntityLivingBase;
|
||||||
import noppes.npcs.api.entity.IPlayer;
|
import noppes.npcs.api.entity.IPlayer;
|
||||||
|
import noppes.npcs.api.event.IItemEvent;
|
||||||
import noppes.npcs.api.event.IPlayerEvent;
|
import noppes.npcs.api.event.IPlayerEvent;
|
||||||
import noppes.npcs.api.handler.data.IPlayerEffect;
|
import noppes.npcs.api.handler.data.IPlayerEffect;
|
||||||
import noppes.npcs.api.handler.data.IProfile;
|
import noppes.npcs.api.handler.data.IProfile;
|
||||||
|
import noppes.npcs.api.item.IItemCustomizable;
|
||||||
import noppes.npcs.api.item.IItemStack;
|
import noppes.npcs.api.item.IItemStack;
|
||||||
import noppes.npcs.constants.EnumScriptType;
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
import noppes.npcs.scripted.NpcAPI;
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
import noppes.npcs.scripted.event.CustomNPCsEvent;
|
import noppes.npcs.scripted.event.CustomNPCsEvent;
|
||||||
|
import noppes.npcs.scripted.event.ItemEvent;
|
||||||
|
|
||||||
public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
|
public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
|
||||||
public final IPlayer player;
|
public final IPlayer player;
|
||||||
@@ -650,6 +653,38 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Cancelable
|
||||||
|
public static class RightClickEvent extends PlayerEvent implements IPlayerEvent.RightClickEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0:air, 1:entity, 2:block
|
||||||
|
*/
|
||||||
|
public final int type;
|
||||||
|
public final Object target;
|
||||||
|
|
||||||
|
public RightClickEvent(IPlayer player, int type, Object target) {
|
||||||
|
super(player);
|
||||||
|
this.type = type;
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHookName() {
|
||||||
|
return EnumScriptType.RIGHT_CLICK.function;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getTarget() {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPlayer getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class UpdateEvent extends PlayerEvent implements IPlayerEvent.UpdateEvent {
|
public static class UpdateEvent extends PlayerEvent implements IPlayerEvent.UpdateEvent {
|
||||||
public UpdateEvent(IPlayer player) {
|
public UpdateEvent(IPlayer player) {
|
||||||
super(player);
|
super(player);
|
||||||
|
|||||||
Reference in new issue
Block a user