Merge pull request #110 from Goodbird-git/minor-fixes

A lot of fixes of minor bugs
This commit is contained in:
Kam authored and GitHub committed 2024-01-18 15:58:20 -05:00
commit 514432afa6
46 files changed
+1194 -372

No files matched your search

+1 -1
View File
@@ -38,7 +38,7 @@ configurations {
apply plugin: 'forge'
version = "1.9-beta3"
version = "1.9-beta3.2"
group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "CustomNPC-Plus"
+5 -5
View File
@@ -161,23 +161,23 @@ public class DataAdvanced {
}
public Line getInteractLine() {
return interactLines.getLine(!orderedLines);
return (Line) interactLines.getLine(!orderedLines);
}
public Line getAttackLine() {
return attackLines.getLine(!orderedLines);
return (Line) attackLines.getLine(!orderedLines);
}
public Line getKilledLine() {
return killedLines.getLine(!orderedLines);
return (Line) killedLines.getLine(!orderedLines);
}
public Line getKillLine() {
return killLines.getLine(!orderedLines);
return (Line) killLines.getLine(!orderedLines);
}
public Line getWorldLine() {
return worldLines.getLine(!orderedLines);
return (Line) worldLines.getLine(!orderedLines);
}
public void setRole(int i) {
@@ -22,6 +22,7 @@ public class DataInventory implements IInventory {
public HashMap<Integer,ItemStack> items = new HashMap<Integer,ItemStack>();
public HashMap<Integer,Double> dropchance = new HashMap<Integer,Double>();
public HashMap<Integer,ItemStack> weapons = new HashMap<Integer, ItemStack>();
public HashMap<Integer,ItemStack> prevWeapons = new HashMap<Integer, ItemStack>();
public HashMap<Integer,ItemStack> armor = new HashMap<Integer, ItemStack>();
public int minExp = 0;
+16
View File
@@ -262,6 +262,14 @@ public class EventHooks {
script.run(EnumScriptType.PROJECTILE_TICK, event);
}
}
EntityLivingBase thrower = projectile.getThrower();
if(thrower != null){
if(thrower instanceof EntityNPCInterface){
((EntityNPCInterface) thrower).script.callScript(EnumScriptType.PROJECTILE_TICK, event);
}
}
NpcAPI.EVENT_BUS.post(event);
}
@@ -272,6 +280,14 @@ public class EventHooks {
script.run(EnumScriptType.PROJECTILE_IMPACT, event);
}
}
EntityLivingBase thrower = projectile.getThrower();
if(thrower != null){
if(thrower instanceof EntityNPCInterface){
((EntityNPCInterface) thrower).script.callScript(EnumScriptType.PROJECTILE_IMPACT, event);
}
}
NpcAPI.EVENT_BUS.post(event);
}
@@ -672,17 +672,20 @@ public class NoppesUtilServer {
}
public static DialogOption setNpcDialog(int slot, int dialogId, EntityPlayer player) throws IOException {
EntityNPCInterface npc = getEditingNpc(player);
return setNpcDialog(slot, dialogId, getEditingNpc(player));
}
public static DialogOption setNpcDialog(int slot, int dialogId, EntityNPCInterface npc) {
if(npc == null)
return null;
if(!npc.dialogs.containsKey(slot))
npc.dialogs.put(slot, new DialogOption());
DialogOption option = npc.dialogs.get(slot);
option.dialogId = dialogId;
if(option.hasDialog())
option.title = option.getDialog().title;
return option;
}
@@ -271,38 +271,42 @@ public class PacketHandlerPlayer{
}
}
}
else if(type == EnumPlayerPacket.SignSave){
else if(type == EnumPlayerPacket.SignSave) {
int x = buffer.readInt(), y = buffer.readInt(), z = buffer.readInt();
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
if(tile == null || !(tile instanceof TileBigSign))
return;
TileBigSign sign = (TileBigSign) tile;
if(sign.canEdit){
sign.setText(Server.readString(buffer));
sign.canEdit = false;
player.worldObj.markBlockForUpdate(x, y, z);
if (player.worldObj.blockExists(x, y, z)) {
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
if (!(tile instanceof TileBigSign))
return;
TileBigSign sign = (TileBigSign) tile;
if (sign.canEdit) {
sign.setText(Server.readString(buffer));
sign.canEdit = false;
player.worldObj.markBlockForUpdate(x, y, z);
}
}
}
else if(type == EnumPlayerPacket.SaveBook){
else if(type == EnumPlayerPacket.SaveBook) {
int x = buffer.readInt(), y = buffer.readInt(), z = buffer.readInt();
TileEntity tileentity = player.worldObj.getTileEntity(x, y, z);
if(!(tileentity instanceof TileBook))
return;
TileBook tile = (TileBook) tileentity;
if(tile.book.getItem() == Items.written_book)
return;
boolean sign = buffer.readBoolean();
ItemStack book = ItemStack.loadItemStackFromNBT(Server.readNBT(buffer));
if(book == null)
return;
if(book.getItem() == Items.writable_book && !sign && ItemWritableBook.func_150930_a(book.getTagCompound())){
tile.book.setTagInfo("pages", book.getTagCompound().getTagList("pages", 8));
}
if(book.getItem() == Items.written_book && sign && ItemEditableBook.validBookTagContents(book.getTagCompound())){
tile.book.setTagInfo("author", new NBTTagString(player.getCommandSenderName()));
tile.book.setTagInfo("title", new NBTTagString(book.getTagCompound().getString("title")));
tile.book.setTagInfo("pages", book.getTagCompound().getTagList("pages", 8));
tile.book.func_150996_a(Items.written_book);
if (player.worldObj.blockExists(x, y, z)) {
TileEntity tileentity = player.worldObj.getTileEntity(x, y, z);
if (!(tileentity instanceof TileBook))
return;
TileBook tile = (TileBook) tileentity;
if (tile.book.getItem() == Items.written_book)
return;
boolean sign = buffer.readBoolean();
ItemStack book = ItemStack.loadItemStackFromNBT(Server.readNBT(buffer));
if (book == null)
return;
if (book.getItem() == Items.writable_book && !sign && ItemWritableBook.func_150930_a(book.getTagCompound())) {
tile.book.setTagInfo("pages", book.getTagCompound().getTagList("pages", 8));
}
if (book.getItem() == Items.written_book && sign && ItemEditableBook.validBookTagContents(book.getTagCompound())) {
tile.book.setTagInfo("author", new NBTTagString(player.getCommandSenderName()));
tile.book.setTagInfo("title", new NBTTagString(book.getTagCompound().getString("title")));
tile.book.setTagInfo("pages", book.getTagCompound().getTagList("pages", 8));
tile.book.func_150996_a(Items.written_book);
}
}
}
}
@@ -108,6 +108,38 @@ public class PacketHandlerServer{
}
compound.setTag("TagNames",tagList);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} else if (type == EnumPacketServer.CacheAnimation) {
PlayerDataController.Instance.getPlayerData(player).animationData.cacheAnimation(buffer.readInt());
return;
} else if (type == EnumPacketServer.GetPartyData || type == EnumPacketServer.CreateParty) {
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
if (type == EnumPacketServer.CreateParty) {
Party party = PartyController.Instance().createParty();
party.addPlayer(player);
party.setLeader(player);
}
NBTTagCompound compound = new NBTTagCompound();
if (playerData.partyUUID != null) {
Party party = PartyController.Instance().getParty(playerData.partyUUID);
compound = party.writeToNBT();
Quest quest = (Quest) QuestController.Instance.get(party.getCurrentQuestID());
if (quest != null) {
compound.setString("QuestName", quest.getName());
compound.setString("QuestCategory", quest.getCategory().getName());
}
}
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} else if (type == EnumPacketServer.DisbandParty) {
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
if (playerData.partyUUID != null) {
PartyController.Instance().disbandParty(playerData.partyUUID);
}
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("Disband", true);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
}
if(type.needsNpc && npc == null){
@@ -1,11 +1,13 @@
package noppes.npcs.client;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.client.gui.OverlayQuestTracking;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.renderer.ImageData;
import noppes.npcs.config.ConfigClient;
import noppes.npcs.controllers.data.Party;
import noppes.npcs.controllers.data.SkinOverlay;
import noppes.npcs.util.CacheHashMap;
@@ -14,11 +16,15 @@ import java.util.UUID;
public class ClientCacheHandler {
private static final CacheHashMap<String, CacheHashMap.CachedObject<ImageData>> imageDataCache = new CacheHashMap<>((long) ConfigClient.CacheLife * 60 * 1000);
public static final HashMap<Integer, Animation> animationCache = new HashMap<>();
public static OverlayQuestTracking questTrackingOverlay = null;
public static HashMap<Integer, OverlayCustom> customOverlays = new HashMap<>();
public static HashMap<UUID, HashMap<Integer, SkinOverlay>> skinOverlays = new HashMap<>();
public static HashMap<UUID, AnimationData> playerAnimations = new HashMap<>();
public static Party party;
public static ImageData getImageData(String directory) {
synchronized (imageDataCache) {
if (!imageDataCache.containsKey(directory)) {
@@ -39,9 +45,11 @@ public class ClientCacheHandler {
public static void clearCache() {
ClientCacheHandler.imageDataCache.clear();
ClientCacheHandler.animationCache.clear();
ClientCacheHandler.questTrackingOverlay = null;
ClientCacheHandler.customOverlays.clear();
ClientCacheHandler.skinOverlays.clear();
ClientCacheHandler.playerAnimations.clear();
party = null;
}
}
@@ -108,7 +108,7 @@ public class ClientEventHandler {
ClientEventHandler.playerModel = null;
}
if (data != null && data.isActive()) {
if (data != null && data.isActive() && !Minecraft.getMinecraft().isGamePaused()) {
Animation animation = data.animation;
if (data.isActive() && animation.currentFrame().useRenderTicks()) {
animation.increaseTime();
@@ -62,8 +62,7 @@ import noppes.npcs.entity.data.ModelData;
import noppes.npcs.entity.data.ModelPartData;
import noppes.npcs.items.ItemScripted;
import org.lwjgl.input.Keyboard;
import tconstruct.client.tabs.InventoryTabFactions;
import tconstruct.client.tabs.InventoryTabQuests;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.InventoryTabVanilla;
import tconstruct.client.tabs.TabRegistry;
@@ -152,8 +151,7 @@ public class ClientProxy extends CommonProxy {
if (TabRegistry.getTabList().size() < 2){
TabRegistry.registerTab(new InventoryTabVanilla());
}
TabRegistry.registerTab(new InventoryTabFactions());
TabRegistry.registerTab(new InventoryTabQuests());
TabRegistry.registerTab(new InventoryTabCustomNpc());
}
}
@@ -3,18 +3,16 @@ package noppes.npcs.client;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ContainerPlayer;
import net.minecraft.world.World;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.client.controllers.MusicController;
import noppes.npcs.client.controllers.ScriptSoundController;
import noppes.npcs.client.gui.player.GuiQuestLog;
import noppes.npcs.client.gui.player.inventory.GuiQuestLog;
import noppes.npcs.client.renderer.RenderNPCInterface;
import noppes.npcs.constants.EnumPlayerPacket;
import org.lwjgl.input.Keyboard;
@@ -28,17 +28,18 @@ import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.player.GuiBook;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.config.ConfigClient;
import noppes.npcs.constants.EnumAnimationPart;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.RecipeController;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.controllers.data.RecipeCarpentry;
import noppes.npcs.controllers.data.*;
import noppes.npcs.entity.EntityDialogNpc;
import noppes.npcs.entity.EntityNPCInterface;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class PacketHandlerClient extends PacketHandlerServer{
@@ -299,22 +300,56 @@ public class PacketHandlerClient extends PacketHandlerServer{
}
else if(type == EnumPacketClient.UPDATE_ANIMATIONS) {
NBTTagCompound compound = Server.readNBT(buffer);
AnimationData animationData = null;
if (compound.hasKey("EntityId")) {
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(compound.getInteger("EntityId"));
if (entity instanceof EntityNPCInterface) {
AnimationData data = ((EntityNPCInterface) entity).display.animationData;
data.readFromNBT(compound);
data.animation = new Animation();
data.animation.readFromNBT(compound.getCompoundTag("Animation"));
animationData = ((EntityNPCInterface) entity).display.animationData;
}
} else {
EntityPlayer sendingPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(Server.readString(buffer));
if (sendingPlayer != null) {
AnimationData data = new AnimationData(sendingPlayer);
data.readFromNBT(compound);
data.animation = new Animation();
data.animation.readFromNBT(compound.getCompoundTag("Animation"));
ClientCacheHandler.playerAnimations.put(sendingPlayer.getUniqueID(), data);
if (!ClientCacheHandler.playerAnimations.containsKey(sendingPlayer.getUniqueID())) {
ClientCacheHandler.playerAnimations.put(sendingPlayer.getUniqueID(), new AnimationData(sendingPlayer));
}
animationData = ClientCacheHandler.playerAnimations.get(sendingPlayer.getUniqueID());
}
}
if (animationData != null) {
animationData.readFromNBT(compound);
int animationId;
if (compound.hasKey("AnimationID")) {
animationId = compound.getInteger("AnimationID");
} else {
Animation animation = new Animation();
animation.readFromNBT(compound.getCompoundTag("Animation"));
ClientCacheHandler.animationCache.put(animation.getID(), animation);
animationId = animation.getID();
}
if (animationData.allowAnimation) {
Animation animation = new Animation();
animation.readFromNBT(ClientCacheHandler.animationCache.get(animationId).writeToNBT());
if (animationData.animation != null && animation.frames.size() > 0) {
Frame frame = (Frame) animationData.animation.currentFrame();
if (frame != null) {
Frame firstFrame = animation.frames.get(0);
for (Map.Entry<EnumAnimationPart, FramePart> entry : frame.frameParts.entrySet()) {
if (firstFrame.frameParts.containsKey(entry.getKey())) {
FramePart prevFramePart = entry.getValue();
FramePart newFramePart = firstFrame.frameParts.get(entry.getKey());
for (int i = 0; i < 3; i++) {
newFramePart.prevPivots[i] = prevFramePart.prevPivots[i];
newFramePart.prevRotations[i] = prevFramePart.prevRotations[i];
}
}
}
}
}
animationData.animation = animation;
animation.parent = animationData;
Client.sendData(EnumPacketServer.CacheAnimation, animationId);
}
}
}
@@ -358,5 +393,14 @@ public class PacketHandlerClient extends PacketHandlerServer{
else if(type == EnumPacketClient.STOP_SOUNDS) {
ScriptSoundController.Instance.stopAllSounds();
}
else if(type == EnumPacketClient.SYNC_WEAPON) {
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(buffer.readInt());
if(!(entity instanceof EntityNPCInterface))
return;
EntityNPCInterface npc = (EntityNPCInterface) entity;
int weaponSlotIndex = buffer.readInt();
ItemStack stack = ItemStack.loadItemStackFromNBT(Server.readNBT(buffer));
npc.inventory.weapons.put(weaponSlotIndex,stack);
}
}
}
@@ -85,7 +85,7 @@ public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHo
}
public ICustomGuiComponent toComponent() {
ScriptGuiScroll component = new ScriptGuiScroll(this.id, this.guiLeft - GuiCustom.guiLeft, this.guiTop - GuiCustom.guiTop, this.width, this.height, (String[])this.getList().toArray(new String[0]));
ScriptGuiScroll component = new ScriptGuiScroll(this.id, this.guiLeft - GuiCustom.guiLeft, this.guiTop - GuiCustom.guiTop, this.xSize, this.ySize, (String[])this.getList().toArray(new String[0]));
component.setHoverText(this.hoverText);
component.setColor(color);
component.setAlpha(alpha);
@@ -63,7 +63,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
}
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
boolean hovered = mouseX >= this.x + GuiCustom.guiLeft && mouseY >= this.y + GuiCustom.guiTop && mouseX < this.x + GuiCustom.guiLeft + this.width && mouseY < this.y + GuiCustom.guiTop + this.height;
boolean hovered = mouseX >= this.x + GuiCustom.guiLeft && mouseY >= this.y + GuiCustom.guiTop && mouseX < this.x + GuiCustom.guiLeft + this.width*scale && mouseY < this.y + GuiCustom.guiTop + this.height*scale;
if (this.imageData != null && this.imageData.imageLoaded()) {
int totalWidth = this.imageData.getTotalWidth();
@@ -80,7 +80,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
float blue = (color & 255) / 255f;
GL11.glColor4f(red, green, blue, this.alpha);
GL11.glTranslatef(GuiCustom.guiLeft + this.x - u1 * totalWidth, GuiCustom.guiTop + this.y - v1 * totalHeight, (float) this.id);
GL11.glTranslatef(GuiCustom.guiLeft + this.x, GuiCustom.guiTop + this.y, (float) this.id);
GL11.glRotatef(this.rotation, 0.0F, 0.0F, 1.0F);
GL11.glScalef(this.scale, this.scale, this.scale);
@@ -1,186 +0,0 @@
package noppes.npcs.client.gui.player;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.gui.util.GuiButtonNextPage;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.controllers.data.Faction;
import noppes.npcs.controllers.data.PlayerFactionData;
import org.lwjgl.opengl.GL11;
import tconstruct.client.tabs.InventoryTabFactions;
import tconstruct.client.tabs.TabRegistry;
import java.util.ArrayList;
public class GuiFaction extends GuiNPCInterface implements IGuiData{
private int xSize;
private int ySize;
private int guiLeft;
private int guiTop;
private ArrayList<Faction> playerFactions = new ArrayList<Faction>();
private int page = 0;
private int pages = 1;
private GuiButtonNextPage buttonNextPage;
private GuiButtonNextPage buttonPreviousPage;
private ResourceLocation indicator;
public GuiFaction() {
super();
xSize = 200;
ySize = 195;
this.drawDefaultBackground = false;
title = "";
NoppesUtilPlayer.sendData(EnumPlayerPacket.FactionsGet);
indicator = getResource("standardbg.png");
}
@Override
public void initGui()
{
super.initGui();
guiLeft = (width - xSize) / 2;
guiTop = (height - ySize) / 2 + 12;
TabRegistry.updateTabValues(guiLeft, guiTop + 8, InventoryTabFactions.class);
TabRegistry.addTabsToList(buttonList);
this.buttonList.add(buttonNextPage = new GuiButtonNextPage(1, guiLeft + xSize - 43, guiTop + 180, true));
this.buttonList.add(buttonPreviousPage = new GuiButtonNextPage(2, guiLeft + 20, guiTop + 180, false));
updateButtons();
}
@Override
public void drawScreen(int i, int j, float f)
{
drawDefaultBackground();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(indicator);
drawTexturedModalRect(guiLeft, guiTop + 8, 0, 0, xSize, ySize);
drawTexturedModalRect(guiLeft + 4, guiTop + 8, 56, 0, 200, ySize);
if(playerFactions.isEmpty()){
String noFaction = StatCollector.translateToLocal("faction.nostanding");
fontRendererObj.drawString(noFaction,guiLeft + (xSize - fontRendererObj.getStringWidth(noFaction)) / 2,guiTop + 80, CustomNpcResourceListener.DefaultTextColor);
}
else
renderScreen();
super.drawScreen(i, j, f);
}
private void renderScreen(){
int size = 5;
if(playerFactions.size() % 5 != 0 && page == pages)
size = playerFactions.size() % 5;
for(int id = 0 ; id < size; id++){
drawHorizontalLine(guiLeft + 2, guiLeft + xSize, guiTop + 14 + id * 30, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor);
Faction faction = playerFactions.get((page - 1) * 5 + id);
String name = faction.name;
String points = " : " + faction.defaultPoints;
String standing = StatCollector.translateToLocal("faction.friendly");
int color = 0x00FF00;
if(faction.defaultPoints < faction.neutralPoints){
standing = StatCollector.translateToLocal("faction.unfriendly");
color = 0xFF0000;
points += "/" + faction.neutralPoints;
}
else if(faction.defaultPoints < faction.friendlyPoints){
standing = StatCollector.translateToLocal("faction.neutral");
color = 0xF2FF00;
points += "/" + faction.friendlyPoints;
}
else{
points += "/-";
}
fontRendererObj.drawString(name, guiLeft + (xSize - fontRendererObj.getStringWidth(name)) / 2, guiTop + 19 + id * 30, faction.color);
fontRendererObj.drawString(standing, width / 2 - fontRendererObj.getStringWidth(standing) - 1, guiTop + 33 + id * 30, color);
fontRendererObj.drawString(points, width / 2, guiTop + 33 + id * 30, CustomNpcResourceListener.DefaultTextColor);
}
drawHorizontalLine(guiLeft + 2, guiLeft + xSize, guiTop + 14 + size * 30, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor);
if(pages > 1){
String s = page +"/" + pages;
fontRendererObj.drawString(s, guiLeft + (xSize - fontRendererObj.getStringWidth(s)) / 2, guiTop + 203, CustomNpcResourceListener.DefaultTextColor);
}
}
@Override
protected void actionPerformed(GuiButton guibutton){
if(!(guibutton instanceof GuiButtonNextPage))
return;
int id = guibutton.id;
if(id == 1){
page++;
}
if(id == 2){
page--;
}
updateButtons();
}
private void updateButtons(){
buttonNextPage.setVisible(page < pages);
buttonPreviousPage.setVisible(page > 1);
}
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
{
}
@Override
public void keyTyped(char c, int i)
{
if (i == 1 || isInventoryKey(i))
{
close();
}
}
@Override
public void save() {
}
@Override
public void setGuiData(NBTTagCompound compound) {
playerFactions = new ArrayList<Faction>();
NBTTagList list = compound.getTagList("FactionList", 10);
for(int i = 0; i < list.tagCount(); i++){
Faction faction = new Faction();
faction.readNBT(list.getCompoundTagAt(i));
playerFactions.add(faction);
}
PlayerFactionData data = new PlayerFactionData();
data.loadNBTData(compound);
for(int id : data.factionData.keySet()){
int points = data.factionData.get(id);
for(Faction faction : playerFactions){
if(faction.id == id)
faction.defaultPoints = points;
}
}
pages = (playerFactions.size() - 1) / 5 ;
pages++;
page = 1;
updateButtons();
}
}
@@ -0,0 +1,52 @@
package noppes.npcs.client.gui.player.inventory;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.CustomItems;
import noppes.npcs.client.gui.util.GuiMenuSideButton;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.TabRegistry;
public class GuiCNPCInventory extends GuiNPCInterface {
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
protected static int activeTab = 0;
private Minecraft mc = Minecraft.getMinecraft();
public GuiCNPCInventory() {
super();
xSize = 280;
ySize = 180;
drawDefaultBackground = false;
}
public void initGui(){
super.initGui();
guiTop +=10;
TabRegistry.addTabsToList(buttonList);
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
GuiMenuSideButton questsButton = new GuiMenuSideButton(100, guiLeft + xSize + 37, this.guiTop + 3, 22, 22, "");
questsButton.rightSided = true;
questsButton.active = activeTab == 0;
questsButton.renderStack = new ItemStack(CustomItems.letter);
addButton(questsButton);
GuiMenuSideButton partyButton = new GuiMenuSideButton(101, guiLeft + xSize + 37, this.guiTop + 3 + 21, 22, 22, "");
partyButton.rightSided = true;
partyButton.active = activeTab == 1;
partyButton.renderStack = new ItemStack(CustomItems.bag);
addButton(partyButton);
GuiMenuSideButton factionButton = new GuiMenuSideButton(102, guiLeft + xSize + 37, this.guiTop + 3 + 21*2, 22, 22, "");
factionButton.rightSided = true;
factionButton.active = activeTab == 2;
factionButton.renderStack = new ItemStack(CustomItems.wallBanner);
addButton(factionButton);
}
@Override
public void save() {}
}
@@ -0,0 +1,211 @@
package noppes.npcs.client.gui.player.inventory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.gui.util.GuiButtonNextPage;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.controllers.data.Faction;
import noppes.npcs.controllers.data.PlayerFactionData;
import org.lwjgl.opengl.GL11;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.TabRegistry;
import java.util.ArrayList;
public class GuiFaction extends GuiCNPCInventory implements IGuiData{
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
private ArrayList<Faction> playerFactions = new ArrayList<Faction>();
private Minecraft mc = Minecraft.getMinecraft();
private int page = 0;
private int pages = 1;
private GuiButtonNextPage buttonNextPage;
private GuiButtonNextPage buttonPreviousPage;
public GuiFaction() {
super();
xSize = 280;
ySize = 180;
this.drawDefaultBackground = false;
title = "";
activeTab = 2;
NoppesUtilPlayer.sendData(EnumPlayerPacket.FactionsGet);
}
@Override
public void initGui()
{
super.initGui();
TabRegistry.addTabsToList(buttonList);
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
this.buttonList.add(buttonNextPage = new GuiButtonNextPage(1, (guiLeft + (xSize + 35) / 2) + 25, guiTop + 170, true));
this.buttonList.add(buttonPreviousPage = new GuiButtonNextPage(2, (guiLeft + (xSize + 35) / 2) - 40, guiTop + 170, false));
updateButtons();
}
@Override
public void drawScreen(int i, int j, float f)
{
drawDefaultBackground();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(resource);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 252, 195);
drawTexturedModalRect(guiLeft + 252, guiTop, 188, 0, 67, 195);
if(playerFactions.isEmpty()){
String noFaction = StatCollector.translateToLocal("faction.nostanding");
fontRendererObj.drawString(noFaction,guiLeft + (xSize - fontRendererObj.getStringWidth(noFaction)) / 2,guiTop + 80, CustomNpcResourceListener.DefaultTextColor);
}
else
renderScreen();
super.drawScreen(i, j, f);
}
private void renderScreen(){
int size = 10;
if(playerFactions.size() % 10 != 0 && page == pages)
size = playerFactions.size() % 10;
int hLine = 5;
if(size < 5){
hLine = size;
}
int count = -1;
for(int id = 0 ; id < size; id++){
count++;
Faction faction = playerFactions.get((page - 1) * 10 + id);
String name = faction.name;
String points = " : " + faction.defaultPoints;
String standing = StatCollector.translateToLocal("faction.friendly");
int color = 0x00FF00;
if(faction.defaultPoints < faction.neutralPoints){
standing = StatCollector.translateToLocal("faction.unfriendly");
color = 0xFF0000;
points += "/" + faction.neutralPoints;
}
else if(faction.defaultPoints < faction.friendlyPoints){
standing = StatCollector.translateToLocal("faction.neutral");
color = 0xF2FF00;
points += "/" + faction.friendlyPoints;
}
else{
points += "/-";
}
drawVerticalLine(guiLeft + (xSize + 45) / 2, (guiTop + ySize - 15), guiTop + 13, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor);
if(count < 5){
drawHorizontalLine(guiLeft + 2, guiLeft + xSize + 35, guiTop + 14 + count * 30, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor);
fontRendererObj.drawString(name, guiLeft + (xSize + 45 - fontRendererObj.getStringWidth(name)) / 4, guiTop + 19 + count * 30, faction.color);
fontRendererObj.drawString(standing, (guiLeft + (xSize + 45) / 4) - fontRendererObj.getStringWidth(standing), guiTop + 33 + count * 30, color);
fontRendererObj.drawString(points, (guiLeft + (xSize + 45) / 4), guiTop + 33 + count * 30, CustomNpcResourceListener.DefaultTextColor);
}
else {
fontRendererObj.drawString(name, guiLeft + 3*(xSize + 45 - fontRendererObj.getStringWidth(name)) / 4, guiTop + 19 + (count - 5) * 30, faction.color);
fontRendererObj.drawString(standing, (guiLeft + 3*(xSize + 45) / 4) - fontRendererObj.getStringWidth(standing) - 10, guiTop + 33 + (count - 5) * 30, color);
fontRendererObj.drawString(points, (guiLeft + 3*(xSize + 45) / 4) - 10, guiTop + 33 + (count - 5) * 30, CustomNpcResourceListener.DefaultTextColor);
}
drawHorizontalLine(guiLeft + 2, guiLeft + xSize + 35, guiTop + 14 + hLine * 30, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor);
}
if(pages > 1){
String s = page +"/" + pages;
fontRendererObj.drawString(s, guiLeft + (xSize + 45 - fontRendererObj.getStringWidth(s)) / 2, guiTop + 175, CustomNpcResourceListener.DefaultTextColor);
}
}
@Override
protected void actionPerformed(GuiButton guibutton){
if (guibutton.id >= 100) {
if (guibutton.id == 100 && activeTab != 0) {
activeTab = 0;
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
}
if (guibutton.id == 101 && activeTab != 1) {
activeTab = 1;
mc.displayGuiScreen(new GuiParty(mc.thePlayer));
}
if (guibutton.id == 102 && activeTab != 2) {
activeTab = 2;
mc.displayGuiScreen(new GuiFaction());
}
}
if(!(guibutton instanceof GuiButtonNextPage))
return;
int id = guibutton.id;
if(id == 1){
page++;
}
if(id == 2){
page--;
}
updateButtons();
}
private void updateButtons(){
buttonNextPage.setVisible(page < pages);
buttonPreviousPage.setVisible(page > 1);
}
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
{
}
@Override
public void keyTyped(char c, int i)
{
if (i == 1 || isInventoryKey(i))
{
close();
}
}
@Override
public void save() {
}
@Override
public void setGuiData(NBTTagCompound compound) {
playerFactions = new ArrayList<Faction>();
NBTTagList list = compound.getTagList("FactionList", 10);
for(int i = 0; i < list.tagCount(); i++){
Faction faction = new Faction();
faction.readNBT(list.getCompoundTagAt(i));
playerFactions.add(faction);
}
PlayerFactionData data = new PlayerFactionData();
data.loadNBTData(compound);
for(int id : data.factionData.keySet()){
int points = data.factionData.get(id);
for(Faction faction : playerFactions){
if(faction.id == id)
faction.defaultPoints = points;
}
}
pages = (playerFactions.size() - 1) / 10 ;
pages++;
page = 1;
updateButtons();
}
}
@@ -0,0 +1,229 @@
package noppes.npcs.client.gui.player.inventory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.Client;
import noppes.npcs.client.ClientCacheHandler;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.data.Party;
import org.lwjgl.opengl.GL11;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.TabRegistry;
import java.util.ArrayList;
import java.util.UUID;
public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, ITopButtonListener,ICustomScrollListener, IGuiData {
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
private final EntityPlayer player;
private Minecraft mc = Minecraft.getMinecraft();
private boolean receivedData;
private long renderTicks;
public GuiParty(EntityPlayer player) {
super();
this.player = player;
xSize = 280;
ySize = 180;
drawDefaultBackground = false;
activeTab = 1;
Client.sendData(EnumPacketServer.GetPartyData);
}
public void initGui(){
super.initGui();
Party party = ClientCacheHandler.party;
TabRegistry.addTabsToList(buttonList);
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
if (receivedData) {
if (party == null) {
//
//create party button
//
GuiNpcButton createPartyButton = new GuiNpcButton(200, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 20, "Create Party");
createPartyButton.width = 100;
this.addButton(createPartyButton);
this.addLabel(new GuiNpcLabel(201, "You're not in a party!", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 30));
this.addLabel(new GuiNpcLabel(202, "Either wait for an invite", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 20));
this.addLabel(new GuiNpcLabel(203, "or create one.", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 10));
//party invites list
//
GuiCustomScroll inviteScroll = new GuiCustomScroll(this, 210, false);
inviteScroll.setSize(150, 160);
inviteScroll.guiLeft = guiLeft + 5;
inviteScroll.guiTop = guiTop + 5;
this.addScroll(inviteScroll);
GuiNpcButton acceptButton = new GuiNpcButton(215, guiLeft + 15, guiTop + ySize - 12, "Accept");
acceptButton.width = 60;
this.addButton(acceptButton);
GuiNpcButton ignoreButton = new GuiNpcButton(220, guiLeft + 80, guiTop + ySize - 12, "Ignore");
ignoreButton.width = 60;
this.addButton(ignoreButton);
} else {
//
//party player list
//
GuiCustomScroll playerScroll = new GuiCustomScroll(this, 300, false);
playerScroll.setSize(150, 160);
playerScroll.guiLeft = guiLeft + 5;
playerScroll.guiTop = guiTop + 5;
playerScroll.setList(new ArrayList<>(party.getPlayerNames()));
this.addScroll(playerScroll);
//set leader button
//
GuiNpcButton leaderButton = new GuiNpcButton(305, guiLeft + 5, guiTop + ySize - 12, "Make Leader");
leaderButton.width = 70;
this.addButton(leaderButton);
//kick player button
//
GuiNpcButton kickButton = new GuiNpcButton(315, guiLeft + 85, guiTop + ySize - 12, "Kick");
kickButton.width = 70;
this.addButton(kickButton);
//toggle friendly fire
//
GuiNpcButton friendlyFireButton = new GuiNpcButton(320, guiLeft + xSize/2 + 95, guiTop + ySize/2, new String[] {"On", "Off"}, 0); //party.friendlyFire() ? 0 : 1
friendlyFireButton.width = 40;
this.addButton(friendlyFireButton);
GuiNpcLabel friendlyFireLabel = new GuiNpcLabel(321, "Friendly Fire:", guiLeft + xSize/2 + 20, guiTop + ySize/2 + 5);
this.addLabel(friendlyFireLabel);
//send invite button (opens subgui)
//
GuiNpcTextField playerTextField = new GuiNpcTextField(325, this, guiLeft + xSize/2 + 20, guiTop + ySize/2 + 40,100, 20, "");
this.addTextField(playerTextField);
GuiNpcButton inviteButton = new GuiNpcButton(330, guiLeft + xSize/2 + 125, guiTop + ySize/2 + 40, "Invite");
inviteButton.width = 50;
this.addButton(inviteButton);
//disband party
//
GuiNpcButton disbandButton = new GuiNpcButton(335, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 70, "Disband Party");
disbandButton.width = 100;
this.addButton(disbandButton);
}
}
}
@Override
protected void actionPerformed(GuiButton guibutton){
switch (guibutton.id) {
case 200:
Client.sendData(EnumPacketServer.CreateParty);
receivedData = false;
break;
case 335:
Client.sendData(EnumPacketServer.DisbandParty);
receivedData = false;
break;
}
initGui();
if (guibutton.id == 100 && activeTab != 0) {
activeTab = 0;
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
}
if (guibutton.id == 101 && activeTab != 1) {
activeTab = 1;
mc.displayGuiScreen(new GuiParty(mc.thePlayer));
}
if (guibutton.id == 102 && activeTab != 2) {
activeTab = 2;
mc.displayGuiScreen(new GuiFaction());
}
}
@Override
public void drawScreen(int i, int j, float f){
renderTicks++;
drawDefaultBackground();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(resource);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 252, 195);
drawTexturedModalRect(guiLeft + 252, guiTop, 188, 0, 67, 195);
super.drawScreen(i, j, f);
if(!receivedData){
String periods = "";
for (int k = 0; k < (renderTicks/10)%4; k++) {
periods += ".";
}
fontRendererObj.drawString(StatCollector.translateToLocal("gui.loading") + periods,guiLeft + xSize/2,guiTop + 80, CustomNpcResourceListener.DefaultTextColor);
}
}
@Override
public void keyTyped(char c, int i)
{
super.keyTyped(c, i);
if (!GuiNpcTextField.isFieldActive()) {
if (i == 1 || i == mc.gameSettings.keyBindInventory.getKeyCode()) // inventory key
{
mc.displayGuiScreen(null);
mc.setIngameFocus();
}
}
}
@Override
public boolean doesGuiPauseGame()
{
return false;
}
@Override
public void setGuiData(NBTTagCompound compound) {
this.receivedData = true;
if (compound.hasKey("PartyUUID")) {
Party party = ClientCacheHandler.party;
UUID uuid = UUID.fromString(compound.getString("PartyUUID"));
if (party == null || !party.getPartyUUID().equals(uuid)) {
ClientCacheHandler.party = new Party(uuid);
party = ClientCacheHandler.party;
}
party.readFromNBT(compound);
} else if (compound.hasKey("Disband")) {
ClientCacheHandler.party = null;
}
initGui();
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
this.save();
}
@Override
public void save() {
}
@Override
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
}
@Override
public void unFocused(GuiNpcTextField textfield) {
}
}
@@ -1,4 +1,4 @@
package noppes.npcs.client.gui.player;
package noppes.npcs.client.gui.player.inventory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
@@ -17,14 +17,13 @@ import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.util.ValueUtil;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import tconstruct.client.tabs.InventoryTabQuests;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.TabRegistry;
import java.util.*;
public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,ICustomScrollListener, IGuiData{
public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,ICustomScrollListener, IGuiData{
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
@@ -51,14 +50,13 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
ySize = 180;
NoppesUtilPlayer.sendData(EnumPlayerPacket.QuestLog);
drawDefaultBackground = false;
activeTab = 0;
}
public void initGui(){
super.initGui();
sideButtons.clear();
guiTop +=10;
TabRegistry.addTabsToList(buttonList);
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabQuests.class);
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
noQuests = false;
@@ -124,6 +122,18 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
data.toggleQuestAlerts();
}
initGui();
if (guibutton.id == 100 && activeTab != 0) {
activeTab = 0;
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
}
if (guibutton.id == 101 && activeTab != 1) {
activeTab = 1;
mc.displayGuiScreen(new GuiParty(mc.thePlayer));
}
if (guibutton.id == 102 && activeTab != 2) {
activeTab = 2;
mc.displayGuiScreen(new GuiFaction());
}
}
@Override
public void drawScreen(int i, int j, float f){
@@ -128,7 +128,7 @@ public class GuiCustomScroll extends GuiScreen
i -= guiLeft;
j -= guiTop;
if(Mouse.isButtonDown(0)){
if(i >= xSize-11 && i < xSize-6 && j >= 4 && j < ySize){
if(i >= xSize-9 && i < xSize-4 && j >= 4 && j < ySize){
isScrolling = true;
}
}
@@ -2,20 +2,27 @@ package noppes.npcs.client.gui.util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class GuiMenuSideButton extends GuiNpcButton{
public static final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/menusidebutton.png");
public static final ResourceLocation resource2 = new ResourceLocation("customnpcs","textures/gui/menusidebutton2.png");
public boolean active;
public boolean rightSided;
public ItemStack renderStack;
public GuiMenuSideButton(int i, int j, int k, String s){
this(i, j, k, 200, 20, s);
public GuiMenuSideButton(int id, int x, int y, String s){
this(id, x, y, 200, 20, s);
}
public GuiMenuSideButton(int i, int j, int k, int l, int i1, String s){
super(i, j, k, l, i1, s);
public GuiMenuSideButton(int id, int x, int y, int width, int height, String s){
super(id, x, y, width, height, s);
active = false;
}
@@ -23,7 +30,7 @@ public class GuiMenuSideButton extends GuiNpcButton{
public int getHoverState(boolean flag){
if (active)
return 0;
return 1;
return super.getHoverState(flag);
}
@Override
@@ -32,13 +39,38 @@ public class GuiMenuSideButton extends GuiNpcButton{
return;
}
FontRenderer fontrenderer = minecraft.fontRenderer;
minecraft.renderEngine.bindTexture(resource);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int width = this.width + (active?2:0);
field_146123_n = i >= xPosition && j >= yPosition && i < xPosition + width && j < yPosition + height;
int k = getHoverState(field_146123_n);
drawTexturedModalRect(xPosition, yPosition, 0, k * 22, width, height);
if (this.rightSided) {
minecraft.renderEngine.bindTexture(resource2);
drawTexturedModalRect(xPosition, yPosition, 197 - width, k * 22, width, height);
} else {
minecraft.renderEngine.bindTexture(resource);
drawTexturedModalRect(xPosition, yPosition, 0, k * 22, width, height);
}
mouseDragged(minecraft, i, j);
if (this.renderStack != null) {
RenderHelper.enableGUIStandardItemLighting();
this.zLevel = 100.0F;
RenderItem itemRenderer = RenderItem.getInstance();
itemRenderer.zLevel = 100.0F;
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
itemRenderer.renderItemAndEffectIntoGUI(minecraft.fontRenderer,
minecraft.renderEngine, this.renderStack, xPosition + 2, yPosition + height/2 - 8);
itemRenderer.renderItemOverlayIntoGUI(minecraft.fontRenderer,
minecraft.renderEngine, this.renderStack, xPosition + 2, yPosition + height/2 - 8);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
itemRenderer.zLevel = 0.0F;
this.zLevel = 0.0F;
RenderHelper.disableStandardItemLighting();
}
String text = "";
float maxWidth = width * 0.75f;
@@ -229,6 +229,8 @@ public class ModelLegs extends ModelScaleRenderer{
}
public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity)
{
if(this.entity==null) return;
ModelPartData part = this.entity.modelData.legParts;
rotationPointZ = 0;
rotationPointY = 0;
@@ -82,6 +82,8 @@ public class ModelTail extends ModelScaleRenderer {
public void setRotationAngles(float par1, float par2, float par3,
float par4, float par5, float par6, Entity entity) {
if(this.entity==null) return;
rotateAngleY = MathHelper.cos(par1 * 0.6662F) * 0.3f * par2;
rotateAngleX = MathHelper.sin(par3 * 0.067F) * 0.05F;
@@ -49,5 +49,6 @@ public enum EnumPacketClient {
STOP_SOUND_FOR,
PAUSE_SOUNDS,
CONTINUE_SOUNDS,
STOP_SOUNDS
STOP_SOUNDS,
SYNC_WEAPON
}
@@ -91,10 +91,12 @@ public enum EnumPacketServer {
RemoteTpToNpc,QuestGet, QuestCategoryGet,
SaveTileEntity,
NaturalSpawnGetAll, MailOpenSetup,
DimensionsGet, DimensionTeleport, GetTileEntity, Gui, IsGuiOpen,
DimensionsGet, DimensionTeleport, GetTileEntity, Gui, IsGuiOpen, CacheAnimation,
CustomGuiButton,CustomGuiScrollClick,CustomGuiClose,CustomGuiUnfocused,
CreateParty, GetPartyData, DisbandParty,
ServerUpdateSkinOverlays;
public CustomNpcsPermissions.Permission permission = null;
@@ -39,10 +39,9 @@ public class ContainerCustomGui extends Container {
this.addPlayerInventory(player, this.customGui.getPlayerInvX(), this.customGui.getPlayerInvY());
}
Iterator var3 = this.customGui.getSlots().iterator();
while(var3.hasNext()) {
IItemSlot slot = (IItemSlot)var3.next();
slotCount=0;
inventorySlots.clear();
for (IItemSlot slot : this.customGui.getSlots()) {
if (slot.hasStack()) {
this.addSlot(player, slot.getPosX(), slot.getPosY(), slot, slot.getStack().getMCItemStack(), player.worldObj.isRemote);
} else {
@@ -3,15 +3,12 @@ package noppes.npcs.controllers;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter;
import noppes.npcs.api.handler.IAnimationHandler;
import noppes.npcs.api.handler.data.IAnimation;
import noppes.npcs.api.handler.data.IFaction;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.Faction;
import noppes.npcs.controllers.data.TagMap;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.util.NBTJsonUtil;
import java.io.*;
@@ -120,6 +117,10 @@ public class AnimationController implements IAnimationHandler {
animations.remove(animation.getID());
animations.put(animation.getID(), (Animation) animation);
for (PlayerData playerData : PlayerDataController.Instance.getAllPlayerData()) {
playerData.animationData.uncacheAnimation(animation.getID());
}
saveAnimationMap();
// Save Animation File
@@ -32,6 +32,7 @@ public class CustomGuiController {
public static boolean updateGui(IPlayer player, ScriptGui gui) {
if (((EntityPlayerMP)player.getMCEntity()).openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui)((EntityPlayerMP)player.getMCEntity()).openContainer).setGui(gui, (EntityPlayer)player.getMCEntity());
Server.sendDataChecked((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
return true;
} else {
@@ -0,0 +1,47 @@
package noppes.npcs.controllers;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.controllers.data.Party;
import noppes.npcs.controllers.data.PlayerData;
import java.util.HashMap;
import java.util.UUID;
public class PartyController {
private static PartyController Instance;
private HashMap<UUID, Party> parties = new HashMap<>();
private PartyController() {
}
public static PartyController Instance() {
if (Instance == null) {
Instance = new PartyController();
}
return Instance;
}
public Party createParty() {
Party party = new Party();
this.parties.put(party.getPartyUUID(), party);
return party;
}
public Party getParty(UUID partyUUID) {
return this.parties.get(partyUUID);
}
public void disbandParty(UUID partyUUID) {
Party party = this.parties.get(partyUUID);
if (party != null) {
for (UUID uuid: party.getPlayerUUIDs()) {
EntityPlayer player = NoppesUtilServer.getPlayer(uuid);
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
playerData.partyUUID = null;
}
this.parties.remove(partyUUID);
}
}
}
@@ -281,6 +281,17 @@ public class PlayerDataController {
return data;
}
public ArrayList<PlayerData> getAllPlayerData() {
ArrayList<PlayerData> playerDataList = new ArrayList<>();
List<?> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
for (Object o : list) {
if (o instanceof EntityPlayer) {
playerDataList.add(this.getPlayerData((EntityPlayer)o));
}
}
return playerDataList;
}
public PlayerData getPlayerData(EntityPlayer player){
PlayerData data = getPlayerDataCache(player.getUniqueID().toString());
if(data != null){
@@ -2,6 +2,7 @@ package noppes.npcs.controllers.data;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.api.handler.data.IAnimation;
@@ -13,7 +14,7 @@ import java.util.ArrayList;
public class Animation implements IAnimation {
public AnimationData parent; //Client-sided only
public int id = -1; // Only for internal usage
public ArrayList<Frame> frames = new ArrayList<>();
@@ -229,6 +230,10 @@ public class Animation implements IAnimation {
if (paused)
return;
if (this.parent != null && this.currentFrame < this.frames.size()) {
this.parent.finishedFrame = this.currentFrame;
}
this.currentFrameTime++;
if (this.currentFrameTime == this.currentFrame().getDuration()) {
Frame prevFrame = (Frame) this.currentFrame();
@@ -247,6 +252,8 @@ public class Animation implements IAnimation {
nextFrame.frameParts.get(part).prevPivots = prevFrame.frameParts.get(part).prevPivots;
}
}
} else if (this.parent != null && this.currentFrame > this.loop) {
this.parent.finishedTime = this.parent.animationEntity.getAge();
}
}
}
@@ -1,17 +1,23 @@
package noppes.npcs.controllers.data;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import noppes.npcs.DataDisplay;
import noppes.npcs.Server;
import noppes.npcs.api.handler.data.IAnimationData;
import noppes.npcs.api.handler.data.IAnimation;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
public class AnimationData implements IAnimationData {
//Server-side: DataDisplay, PlayerData
//Client-side: DataDisplay, EntityPlayer
@@ -20,19 +26,45 @@ public class AnimationData implements IAnimationData {
public Animation animation;
public boolean allowAnimation = false;
private final HashSet<Integer> cachedAnimationIDs = new HashSet<>();
//Client-side values
public EntityLivingBase animationEntity;
public int finishedTime = -1;
public int finishedFrame = -1;
public AnimationData(Object parent){
this.parent = parent;
if (parent instanceof DataDisplay) {
this.animationEntity = ((DataDisplay) parent).npc;
} else if (parent instanceof EntityPlayer) {
this.animationEntity = (EntityLivingBase) parent;
}
}
public void updateClient() {
NBTTagCompound compound = new NBTTagCompound();
compound = this.writeToNBT(compound);
compound.setTag("Animation",this.animation == null ? new NBTTagCompound() : this.animation.writeToNBT());
if (parent instanceof PlayerData) {
Server.sendToAll(EnumPacketClient.UPDATE_ANIMATIONS, compound, ((PlayerData) parent).player.getCommandSenderName());
} else if (parent instanceof DataDisplay) {
compound.setInteger("EntityId",((DataDisplay) parent).npc.getEntityId());
Server.sendAssociatedData(((DataDisplay) parent).npc, EnumPacketClient.UPDATE_ANIMATIONS, compound);
this.updateClient(new EntityPlayer[0]);
}
public void updateClient(EntityPlayer... excludedPlayers) {
EntityLivingBase sendingEntity = parent instanceof PlayerData ? ((PlayerData) parent).player : parent instanceof DataDisplay ? ((DataDisplay) parent).npc : null;
float range = parent instanceof PlayerData ? 160 : 60;
if (sendingEntity != null) {
List<EntityPlayer> entities = sendingEntity.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(
sendingEntity.posX - range, sendingEntity.posY - range, sendingEntity.posZ - range,
sendingEntity.posX + range, sendingEntity.posY + range, sendingEntity.posZ + range));
entities.removeIf(player -> Arrays.stream(excludedPlayers).anyMatch(exp -> player == exp));
NBTTagCompound animationNBT = null;
for (EntityPlayer player : entities) {
AnimationData animationData = PlayerDataController.Instance.getPlayerData(player).animationData;
if (animationNBT == null && this.animation != null && !animationData.isCached(this.animation.getID())) {
animationNBT = this.animation.writeToNBT();
}
animationData.viewAnimation(this.animation, sendingEntity, this, animationNBT);
}
}
}
@@ -62,17 +94,49 @@ public class AnimationData implements IAnimationData {
}
}
public boolean isCached(int id) {
return this.cachedAnimationIDs.contains(id);
}
public void cacheAnimation(int id) {
this.cachedAnimationIDs.add(id);
}
public void uncacheAnimation(int id) {
this.cachedAnimationIDs.remove(id);
}
public void viewAnimation(Animation animation, EntityLivingBase entity, AnimationData animationData, NBTTagCompound animationNBT) {
NBTTagCompound data = animationData.writeToNBT(new NBTTagCompound());
if (animation != null) {
if (this.cachedAnimationIDs.contains(animation.getID())) {
data.setInteger("AnimationID", animation.getID());
} else {
data.setTag("Animation", animationNBT);
}
}
if (!(entity instanceof EntityPlayer)) {
data.setInteger("EntityId", entity.getEntityId());
}
Server.sendData((EntityPlayerMP) ((PlayerData) parent).player, EnumPacketClient.UPDATE_ANIMATIONS, data, entity.getCommandSenderName());
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setBoolean("AllowAnimation", allowAnimation);
return compound;
}
public void readFromNBT(NBTTagCompound compound) {
this.allowAnimation = compound.getBoolean("AllowAnimation");
this.setEnabled(compound.getBoolean("AllowAnimation"));
}
public void setEnabled(boolean enabled) {
this.allowAnimation = enabled;
if (this.allowAnimation != enabled) {
this.allowAnimation = enabled;
if (this.parent instanceof EntityPlayer) {
this.finishedTime = enabled ? -1 : ((EntityPlayer) this.parent).getAge();
}
}
}
public boolean enabled() {
@@ -2,9 +2,11 @@ package noppes.npcs.controllers.data;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.api.entity.IEntityLivingBase;
import noppes.npcs.api.handler.data.ILine;
public class Line {
public class Line implements ILine {
public Line(){
@@ -17,21 +19,55 @@ public class Line {
public String sound = "";
public boolean hideText = false;
public Line copy() {
public ILine copy() {
Line line = new Line(text);
line.sound = sound;
line.hideText = hideText;
return line;
}
public Line formatTarget(EntityLivingBase entity) {
public ILine formatTarget(EntityLivingBase entity) {
if(entity == null)
return this;
Line line = copy();
Line line = (Line) copy();
if(entity instanceof EntityPlayer)
line.text = line.text.replace("@target", ((EntityPlayer) entity).getDisplayName());
else
line.text = line.text.replace("@target", entity.getCommandSenderName());
return line;
}
public ILine formatTarget(IEntityLivingBase entityLivingBase) {
return this.formatTarget(entityLivingBase.getMCEntity());
}
@Override
public String getText() {
return this.text;
}
@Override
public void setText(String text) {
this.text = text;
}
@Override
public String getSound() {
return this.sound;
}
@Override
public void setSound(String sound) {
this.sound = sound;
}
@Override
public void hideText(boolean hide) {
this.hideText = hide;
}
@Override
public boolean hideText() {
return this.hideText;
}
}
@@ -2,13 +2,15 @@ package noppes.npcs.controllers.data;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.api.handler.data.ILine;
import noppes.npcs.api.handler.data.ILines;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
public class Lines {
public class Lines implements ILines {
private static final Random random = new Random();
private int lastLine = -1;
@@ -49,7 +51,11 @@ public class Lines {
lines = map;
}
public Line getLine(boolean isRandom) {
public ILine createLine(String text) {
return new Line(text);
}
public ILine getLine(boolean isRandom) {
if(lines.isEmpty())
return null;
if(isRandom){
@@ -66,7 +72,27 @@ public class Lines {
}
}
public ILine getLine(int lineIndex) {
return lines.get(lineIndex);
}
public void setLine(int lineIndex, ILine line) {
lines.put(lineIndex, (Line) line);
}
public void removeLine(int lineIndex) {
lines.remove(lineIndex);
}
public void clear() {
lines.clear();
}
public boolean isEmpty() {
return lines.isEmpty();
}
public Integer[] getKeys() {
return lines.keySet().toArray(new Integer[0]);
}
}
@@ -2,7 +2,13 @@ package noppes.npcs.controllers.data;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.api.handler.IPlayerQuestData;
import noppes.npcs.api.handler.data.IQuest;
import noppes.npcs.controllers.PlayerDataController;
@@ -14,8 +20,7 @@ import java.net.URL;
import java.util.*;
public class Party {
private final UUID partyUUID = UUID.randomUUID();
private final UUID partyUUID;
private UUID partyLeader;
private final HashMap<UUID, String> partyMembers = new HashMap<>();
@@ -23,12 +28,21 @@ public class Party {
private int currentQuestID = -1;
public UUID getPartyLeader() {
return partyLeader;
private boolean friendlyFire;
//Client-sided
private String partyLeaderName;
public Party() {
this.partyUUID = UUID.randomUUID();
}
public void setPartyLeader(UUID partyLeader) {
this.partyLeader = partyLeader;
public Party(UUID uuid) {
this.partyUUID = uuid;
}
public UUID getPartyUUID() {
return this.partyUUID;
}
public int getCurrentQuestID() {
@@ -44,6 +58,9 @@ public class Party {
return false;
}
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
playerData.partyUUID = this.partyUUID;
partyMembers.put(player.getUniqueID(), player.getCommandSenderName());
partyOrder.add(player.getUniqueID());
return true;
@@ -71,12 +88,13 @@ public class Party {
return false;
}
public boolean removePlayer(UUID player) {
if(partyMembers.containsKey(player)){
partyMembers.remove(player);
partyOrder.remove(player);
public boolean removePlayer(EntityPlayer player) {
UUID uuid = player.getUniqueID();
if(partyMembers.containsKey(uuid)){
partyMembers.remove(uuid);
partyOrder.remove(uuid);
if(player.equals(partyLeader)){
if(uuid.equals(partyLeader)){
if(partyMembers.size() > 0){
partyLeader = partyOrder.get(0);
}
@@ -88,8 +106,8 @@ public class Party {
return false;
}
public boolean hasPlayer(UUID player) {
return partyMembers.containsKey(player);
public boolean hasPlayer(EntityPlayer player) {
return partyMembers.containsKey(player.getUniqueID());
}
public boolean hasPlayer(String playerName) {
@@ -100,8 +118,18 @@ public class Party {
return partyMembers.containsKey(uuid);
}
public boolean setLeader(UUID uuid){
if(partyLeader.equals(uuid)){
public EntityPlayer getPartyLeader() {
return NoppesUtilServer.getPlayer(this.partyLeader);
}
@SideOnly(Side.CLIENT)
public String getPartyLeaderName() {
return this.partyLeaderName;
}
public boolean setLeader(EntityPlayer player){
UUID uuid = player.getUniqueID();
if(partyLeader != null && partyLeader.equals(uuid)){
return false;
}
@@ -120,6 +148,14 @@ public class Party {
return true;
}
public Collection<String> getPlayerNames() {
return this.partyMembers.values();
}
public Collection<UUID> getPlayerUUIDs() {
return this.partyMembers.keySet();
}
// To Be Called DURING Invite, Leave, Quest Switch, Leader Switch, etc.
public static boolean validateQuest(int questID, Collection<EntityPlayer> players){
IQuest quest = QuestController.Instance.get(questID);
@@ -154,6 +190,14 @@ public class Party {
}
}
public void toggleFriendlyFire() {
this.friendlyFire = !this.friendlyFire;
}
public boolean friendlyFire() {
return this.friendlyFire;
}
public static UUID getUUID(String name) {
UUID uuid = null;
try {
@@ -168,4 +212,35 @@ public class Party {
return uuid;
}
public void readFromNBT(NBTTagCompound compound) {
this.partyLeaderName = compound.getString("PartyLeader");
this.currentQuestID = compound.getInteger("PartyQuestID");
NBTTagList list = compound.getTagList("PartyMembers", 10);
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound tagCompound = list.getCompoundTagAt(i);
UUID uuid = UUID.fromString(tagCompound.getString("UUID"));
String playerName = tagCompound.getString("PlayerName");
this.partyOrder.add(uuid);
this.partyMembers.put(uuid, playerName);
}
}
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setString("PartyUUID", this.partyUUID.toString());
compound.setInteger("PartyQuestID", this.currentQuestID);
compound.setString("PartyLeader", getPartyLeader().getCommandSenderName());
NBTTagList list = new NBTTagList();
for (UUID uuid : this.partyOrder) {
NBTTagCompound uuidCompound = new NBTTagCompound();
uuidCompound.setString("UUID", uuid.toString());
uuidCompound.setString("PlayerName", this.partyMembers.get(uuid));
list.appendTag(uuidCompound);
}
compound.setTag("PartyMembers", list);
return compound;
}
}
@@ -23,9 +23,11 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S04PacketEntityEquipment;
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.*;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
@@ -46,6 +48,7 @@ import noppes.npcs.ai.target.EntityAIClosestTarget;
import noppes.npcs.ai.target.EntityAIOwnerHurtByTarget;
import noppes.npcs.ai.target.EntityAIOwnerHurtTarget;
import noppes.npcs.api.entity.ICustomNpc;
import noppes.npcs.api.handler.data.ILine;
import noppes.npcs.api.item.IItemStack;
import noppes.npcs.client.EntityUtil;
import noppes.npcs.config.ConfigMain;
@@ -197,6 +200,21 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
if (this.ticksExisted % 10 == 0) {
EventHooks.onNPCUpdate(this);
}
for(int i=1;i<3;i++){
ItemStack itemstack = inventory.prevWeapons.get(i);
ItemStack itemstack1 = inventory.weapons.get(i);
if (!ItemStack.areItemStacksEqual(itemstack1, itemstack))
{
NBTTagCompound itemNBT = new NBTTagCompound();
if(itemstack1!=null){
itemstack1.writeToNBT(itemNBT);
}
for(Object obj: MinecraftServer.getServer().getConfigurationManager().playerEntityList){
Server.sendData((EntityPlayerMP) obj, EnumPacketClient.SYNC_WEAPON, getEntityId(), i, itemNBT);
}
inventory.prevWeapons.put(i,itemstack1 == null ? null : itemstack1.copy());
}
}
this.timers.update();
}
}
@@ -914,28 +932,28 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
return chateventPlayer;
}
public void saySurrounding(Line line) {
if (line == null || line.text == null || getFakePlayer() == null)
public void saySurrounding(ILine line) {
if (line == null || line.getText() == null || getFakePlayer() == null)
return;
ServerChatEvent event = new ServerChatEvent(getFakePlayer(), line.text, new ChatComponentTranslation(line.text.replace("%", "%%")));
ServerChatEvent event = new ServerChatEvent(getFakePlayer(), line.getText(), new ChatComponentTranslation(line.getText().replace("%", "%%")));
if (MinecraftForge.EVENT_BUS.post(event) || event.component == null){
return;
}
line.text = event.component.getUnformattedText().replace("%%", "%");
line.setText(event.component.getUnformattedText().replace("%%", "%"));
List<EntityPlayer> inRange = worldObj.getEntitiesWithinAABB(
EntityPlayer.class, this.boundingBox.expand(20D, 20D, 20D));
for (EntityPlayer player : inRange)
say(player, line);
}
public void say(EntityPlayer player, Line line) {
if (line == null || !this.canSee(player) || line.text == null)
public void say(EntityPlayer player, ILine line) {
if (line == null || !this.canSee(player) || line.getText() == null)
return;
if(!line.sound.isEmpty()){
Server.sendData((EntityPlayerMP)player, EnumPacketClient.PLAY_SOUND, line.sound, (float)posX, (float)posY, (float)posZ);
if(!line.getSound().isEmpty()){
Server.sendData((EntityPlayerMP)player, EnumPacketClient.PLAY_SOUND, line.getSound(), (float)posX, (float)posY, (float)posZ);
}
Server.sendData((EntityPlayerMP)player, EnumPacketClient.CHATBUBBLE, this.getEntityId(), line.text, !line.hideText);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.CHATBUBBLE, this.getEntityId(), line.getText(), !line.hideText());
}
public boolean getAlwaysRenderNameTagForRender(){
return true;
@@ -1546,6 +1564,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
compound.setInteger("StandingState", ai.standingType.ordinal());
compound.setInteger("MovingState", ai.movingType.ordinal());
compound.setInteger("Orientation", ai.orientation);
compound.setFloat("OffsetY",ai.bodyOffsetY);
compound.setInteger("Role", advanced.role.ordinal());
compound.setInteger("Job", advanced.job.ordinal());
if(advanced.job == EnumJobType.Bard){
@@ -1578,6 +1597,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
ai.standingType = EnumStandingType.values()[compound.getInteger("StandingState") % EnumStandingType.values().length];
ai.movingType = EnumMovingType.values()[compound.getInteger("MovingState") % EnumMovingType.values().length];
ai.orientation = compound.getInteger("Orientation");
ai.bodyOffsetY=compound.getFloat("OffsetY");
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(stats.maxHealth);
inventory.setArmor(NBTTags.getItemStackList(compound.getTagList("Armor", 10)));
@@ -29,6 +29,7 @@ import noppes.npcs.DataStats;
import noppes.npcs.EventHooks;
import noppes.npcs.api.IPos;
import noppes.npcs.api.IWorld;
import noppes.npcs.api.entity.IEntity;
import noppes.npcs.api.entity.IProjectile;
import noppes.npcs.constants.EnumParticleType;
import noppes.npcs.constants.EnumPotionType;
@@ -219,6 +220,9 @@ public class EntityProjectile extends EntityThrowable {
public void onUpdate()
{
super.onEntityUpdate();
if (ticksExisted >= 1200) {
this.setDead();
}
if(++ticksExisted % 10 == 0){
EventHooks.onProjectileTick(this);
}
@@ -261,7 +265,7 @@ public class EntityProjectile extends EntityThrowable {
{
++this.ticksInGround;
if (this.ticksInGround == 1200)
if (this.ticksInGround >= 1200)
{
this.setDead();
}
@@ -280,7 +284,7 @@ public class EntityProjectile extends EntityThrowable {
{
++this.ticksInAir;
if (this.ticksInAir == 1200)
if (this.ticksInAir >= 1200)
{
this.setDead();
}
@@ -449,7 +453,8 @@ public class EntityProjectile extends EntityThrowable {
if (!this.worldObj.isRemote) {
ProjectileEvent.ImpactEvent event;
if (movingobjectposition.entityHit != null) {
event = new ProjectileEvent.ImpactEvent((IProjectile) NpcAPI.Instance().getIEntity(this), 0, movingobjectposition.entityHit);
IEntity target = NpcAPI.Instance().getIEntity(movingobjectposition.entityHit);
event = new ProjectileEvent.ImpactEvent((IProjectile) NpcAPI.Instance().getIEntity(this), 0, target);
} else {
IPos pos = NpcAPI.Instance().getIPos(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
IWorld world = NpcAPI.Instance().getIWorld(this.worldObj);
@@ -5,6 +5,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.client.ClientCacheHandler;
import noppes.npcs.client.ClientEventHandler;
@@ -123,7 +124,9 @@ public abstract class MixinModelRenderer {
}
catch (Exception ignored){}
if (partType != null && animData != null) {
if (partType != null && animData != null && animData.animation != null) {
boolean animDataActive = animData.isActive();
if (!ClientEventHandler.originalValues.containsKey((ModelRenderer) (Object) this)) {
FramePart part = new FramePart();
part.pivot = new float[]{prevPointX, prevPointY, prevPointZ};
@@ -131,23 +134,38 @@ public abstract class MixinModelRenderer {
ClientEventHandler.originalValues.put((ModelRenderer) (Object) this, part);
}
FramePart originalPart = ClientEventHandler.originalValues.get((ModelRenderer) (Object) this);
if (animData.isActive()) {
Frame frame = (Frame) animData.animation.currentFrame();
if (frame.frameParts.containsKey(partType)) {
FramePart part = frame.frameParts.get(partType);
if (partType == mainPartType) {
Frame frame = (Frame) animData.animation.currentFrame();
if (!animDataActive && animData.finishedFrame >= 0 && animData.finishedFrame < animData.animation.frames.size()) {
frame = animData.animation.frames.get(animData.finishedFrame);
}
if (frame != null && frame.frameParts.containsKey(partType)) {
FramePart part = frame.frameParts.get(partType);
if (partType == mainPartType) {
if (animDataActive) {
part.interpolateAngles();
part.interpolateOffset();
} else {
float speed = 0.4F;
part.prevPivots[0] = part.prevPivots[0] * (1.0F - speed);
part.prevPivots[1] = part.prevPivots[1] * (1.0F - speed);
part.prevPivots[2] = part.prevPivots[2] * (1.0F - speed);
part.prevRotations[0] = part.prevRotations[0] * (1.0F - speed) + (this.rotateAngleX * speed);
part.prevRotations[1] = part.prevRotations[1] * (1.0F - speed) + (this.rotateAngleY * speed);
part.prevRotations[2] = part.prevRotations[2] * (1.0F - speed) + (this.rotateAngleZ * speed);
}
if (animDataActive || (partType != EnumAnimationPart.HEAD && ClientEventHandler.renderingPlayer.getAge() - animData.finishedTime < 20)) {
this.rotationPointX = originalPart.pivot[0] + part.prevPivots[0];
this.rotationPointY = originalPart.pivot[1] + part.prevPivots[1];
this.rotationPointZ = originalPart.pivot[2] + part.prevPivots[2];
this.rotateAngleX = part.prevRotations[0];
this.rotateAngleY = part.prevRotations[1];
this.rotateAngleZ = part.prevRotations[2];
} else {
currentPart = part;
this.rotateAngleZ += part.prevRotations[2];
}
} else {
currentPart = part;
this.rotateAngleZ += part.prevRotations[2];
}
}
}
@@ -10,13 +10,16 @@ import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.entity.data.IModelData;
import noppes.npcs.api.handler.IOverlayHandler;
import noppes.npcs.api.handler.data.IAnimationData;
import noppes.npcs.api.handler.data.IDialog;
import noppes.npcs.api.handler.data.IFaction;
import noppes.npcs.api.handler.data.ILines;
import noppes.npcs.api.item.IItemStack;
import noppes.npcs.api.jobs.IJob;
import noppes.npcs.api.roles.IRole;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.constants.*;
import noppes.npcs.controllers.FactionController;
import noppes.npcs.controllers.data.DialogOption;
import noppes.npcs.controllers.data.Line;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
@@ -326,7 +329,49 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
return;
npc.say((EntityPlayer) player.getMCEntity(), new Line(message));
}
public IDialog getDialog(int slot) {
return NpcAPI.Instance().getDialogs().get(this.getDialogId(slot));
}
public int getDialogId(int slot) {
if (npc.dialogs.containsKey(slot)) {
DialogOption option = npc.dialogs.get(slot);
if (option.hasDialog()) {
return option.dialogId;
}
}
return -1;
}
public void setDialog(int slot, IDialog dialog) {
this.setDialog(slot, dialog.getId());
}
public void setDialog(int slot, int dialogId) {
NoppesUtilServer.setNpcDialog(slot,dialogId, this.npc);
}
public ILines getInteractLines() {
return this.npc.advanced.interactLines;
}
public ILines getWorldLines() {
return this.npc.advanced.worldLines;
}
public ILines getAttackLines() {
return this.npc.advanced.attackLines;
}
public ILines getKilledLines() {
return this.npc.advanced.killedLines;
}
public ILines getKillLines() {
return this.npc.advanced.killLines;
}
/**
* Kill the npc, doesnt't despawn it
*/
@@ -436,7 +481,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
npc.inventory.setOffHand(null);
else
npc.inventory.setOffHand(item.getMCItemStack());
npc.script.clientNeedsUpdate = true;
//npc.script.clientNeedsUpdate = true;
}
/**
@@ -79,6 +79,10 @@ public class ScriptProjectile<T extends EntityProjectile> extends ScriptEntity<T
return type == EntityType.PROJECTILE || super.typeOf(type);
}
public IEntity getThrower() {
return NpcAPI.Instance().getIEntity(entity.getThrower());
}
public void enableEvents() {
if(ScriptContainer.Current == null)
throw new CustomNPCsException("Can only be called during scripts");
@@ -1,18 +1,31 @@
package noppes.npcs.scripted.event;
import noppes.npcs.api.IBlock;
import noppes.npcs.api.entity.IEntity;
import noppes.npcs.api.entity.IProjectile;
import noppes.npcs.api.event.IProjectileEvent;
public class ProjectileEvent extends CustomNPCsEvent {
public class ProjectileEvent extends CustomNPCsEvent implements IProjectileEvent {
public IProjectile projectile;
public IEntity source;
public ProjectileEvent(IProjectile projectile) {
this.projectile = projectile;
this.source = projectile.getThrower();
}
public IProjectile getProjectile() {
return projectile;
}
public IEntity getSource() {
return source;
}
/**
* projectileTick
*/
public static class UpdateEvent extends ProjectileEvent {
public static class UpdateEvent extends ProjectileEvent implements IProjectileEvent.UpdateEvent {
public UpdateEvent(IProjectile projectile) {
super(projectile);
}
@@ -21,7 +34,7 @@ public class ProjectileEvent extends CustomNPCsEvent {
/**
* projectileImpact
*/
public static class ImpactEvent extends ProjectileEvent {
public static class ImpactEvent extends ProjectileEvent implements IProjectileEvent.ImpactEvent {
/**
* 0:entity, 1:block
*/
@@ -33,5 +46,21 @@ public class ProjectileEvent extends CustomNPCsEvent {
this.type = type;
this.target = target;
}
public int getType() {
return type;
}
public IEntity getEntity() {
if(type == 0)
return (IEntity) target;
return null;
}
public IBlock getBlock() {
if(type == 1)
return (IBlock) target;
return null;
}
}
}
@@ -4,10 +4,10 @@ import net.minecraft.client.Minecraft;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import noppes.npcs.CustomItems;
import noppes.npcs.client.gui.player.GuiQuestLog;
import noppes.npcs.client.gui.player.inventory.GuiQuestLog;
public class InventoryTabQuests extends AbstractTab {
public InventoryTabQuests() {
public class InventoryTabCustomNpc extends AbstractTab {
public InventoryTabCustomNpc() {
super(0, 0, 0, new ItemStack(CustomItems.letter));
if(CustomItems.letter == null)
@@ -1,37 +0,0 @@
package tconstruct.client.tabs;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import noppes.npcs.CustomItems;
import noppes.npcs.client.gui.player.GuiFaction;
public class InventoryTabFactions extends AbstractTab {
public InventoryTabFactions() {
super(0, 0, 0, new ItemStack(CustomItems.wallBanner, 1, 1));
if(CustomItems.wallBanner == null)
renderStack = new ItemStack(Blocks.tnt);
}
@Override
public void onTabClicked() {
Thread t = new Thread(){
@Override
public void run(){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
Minecraft mc = Minecraft.getMinecraft();
mc.displayGuiScreen(new GuiFaction());
}
};
t.start();
}
@Override
public boolean shouldAddToList() {
return true;
}
}
@@ -10,7 +10,18 @@ public class InventoryTabVanilla extends AbstractTab {
@Override
public void onTabClicked() {
TabRegistry.openInventoryGui();
Thread t = new Thread(){
@Override
public void run(){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
TabRegistry.openInventoryGui();
}
};
t.start();
}
@Override
@@ -127,6 +127,7 @@ gui.reset=Reset
gui.filters=Filters
gui.selectAll=Select All
gui.deselectAll=Deselect All
gui.loading=Loading
scale.shared=Shared
filter.contains=Contains
Binary file not shown.

After

Width:  |  Height:  |  Size: 716 B