diff --git a/build.gradle b/build.gradle index c8813fb74..a8f09fb92 100644 --- a/build.gradle +++ b/build.gradle @@ -38,7 +38,7 @@ configurations { apply plugin: 'forge' -version = "1.9-beta4" +version = "1.9-beta5" group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "CustomNPC-Plus" diff --git a/src/api b/src/api index f5bf161c4..c8ee84008 160000 --- a/src/api +++ b/src/api @@ -1 +1 @@ -Subproject commit f5bf161c474ba661d4b6f59f756c43805c03a1b7 +Subproject commit c8ee840082c1fda50cbef778d4d0260cb7900224 diff --git a/src/main/java/kamkeel/addon/AddonManager.java b/src/main/java/kamkeel/addon/AddonManager.java new file mode 100644 index 000000000..10cde3311 --- /dev/null +++ b/src/main/java/kamkeel/addon/AddonManager.java @@ -0,0 +1,21 @@ +package kamkeel.addon; + +import kamkeel.addon.client.GeckoAddonClient; + +public class AddonManager { + public static AddonManager Instance; + + // Manager class to easily disable mixin manipulated + // addons for debugging and testing + + public AddonManager(){ + Instance = this; + load(); + } + + public void load(){ + // Gecko Addon Initialization + new GeckoAddon(); + new GeckoAddonClient(); + } +} diff --git a/src/main/java/kamkeel/addon/GeckoAddon.java b/src/main/java/kamkeel/addon/GeckoAddon.java new file mode 100644 index 000000000..97c7a50c2 --- /dev/null +++ b/src/main/java/kamkeel/addon/GeckoAddon.java @@ -0,0 +1,20 @@ +package kamkeel.addon; + +import net.minecraft.entity.EntityLivingBase; + +public class GeckoAddon { + public static GeckoAddon instance; + public boolean supportEnabled = true; + + /** + * This class is a shell class to be changed via mixins + * The Addon Mod will replace all blank functions within + * this class to change the ongoing code. + */ + public GeckoAddon(){ + instance = this; + } + + public void geckoCopyData(EntityLivingBase copied, EntityLivingBase entity){} + +} \ No newline at end of file diff --git a/src/main/java/kamkeel/addon/client/GeckoAddonClient.java b/src/main/java/kamkeel/addon/client/GeckoAddonClient.java new file mode 100644 index 000000000..088488314 --- /dev/null +++ b/src/main/java/kamkeel/addon/client/GeckoAddonClient.java @@ -0,0 +1,37 @@ +package kamkeel.addon.client; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.entity.EntityLivingBase; +import noppes.npcs.client.gui.model.GuiCreationScreen; +import noppes.npcs.client.gui.util.GuiNPCInterface2; +import noppes.npcs.client.gui.util.GuiNpcButton; +import noppes.npcs.client.model.ModelMPM; +import noppes.npcs.entity.EntityNPCInterface; + +public class GeckoAddonClient { + public static GeckoAddonClient Instance; + public boolean supportEnabled = true; + + /** + * This class is a shell class to be changed via mixins + * The Addon Mod will replace all blank functions within + * this class to change the ongoing code. + * The fewer classes modified by mixins the safer. + * These are for mixins affecting only client-side classes. + */ + public GeckoAddonClient(){ + Instance = this; + } + + // Creation Screen Mixins + public void showGeckoButtons(GuiCreationScreen creationScreen, EntityLivingBase entity){} + public void geckoGuiCreationScreenActionPerformed(GuiCreationScreen creationScreen, GuiNpcButton btn){} + + // Npc Display Mixins + public void geckoNpcDisplayInitGui(GuiNPCInterface2 guiNPCInterface){} + public void geckoNpcDisplayActionPerformed(GuiNPCInterface2 guiNPCInterface, GuiNpcButton btn){} + + // Render Npc Mixins + public boolean isGeckoModel(ModelBase mainModel){ return false;} + public void geckoRenderModel(ModelMPM mainModel, EntityNPCInterface npc, float rotationYaw, float renderPartialTicks) {} +} diff --git a/src/main/java/noppes/npcs/CustomNpcs.java b/src/main/java/noppes/npcs/CustomNpcs.java index d78f46e16..f43f300b2 100644 --- a/src/main/java/noppes/npcs/CustomNpcs.java +++ b/src/main/java/noppes/npcs/CustomNpcs.java @@ -1,14 +1,14 @@ package noppes.npcs; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.*; import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.*; import cpw.mods.fml.common.network.FMLEventChannel; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.EntityRegistry; import foxz.command.CommandNoppes; +import kamkeel.addon.AddonManager; +import kamkeel.addon.GeckoAddon; import kamkeel.command.CommandKamkeel; import kamkeel.developer.Developer; import net.minecraft.block.Block; @@ -35,7 +35,7 @@ import noppes.npcs.scripted.NpcAPI; import java.io.File; import java.util.Set; -@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.9-beta4") +@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.9-beta5") public class CustomNpcs { @SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy") @@ -168,7 +168,9 @@ public class CustomNpcs { new CustomNpcsPermissions(); new Developer(); + // Load Mod Support PixelmonHelper.load(); + new AddonManager(); } @EventHandler @@ -258,7 +260,6 @@ public class CustomNpcs { EntityRegistry.registerModEntity(cl, name, NewEntityStartId++, this, range, update, velocity); } - public static File getWorldSaveDirectory() { MinecraftServer server = MinecraftServer.getServer(); File saves = new File("."); diff --git a/src/main/java/noppes/npcs/DataDisplay.java b/src/main/java/noppes/npcs/DataDisplay.java index 565b4bbbe..831e4270c 100644 --- a/src/main/java/noppes/npcs/DataDisplay.java +++ b/src/main/java/noppes/npcs/DataDisplay.java @@ -16,9 +16,7 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.data.DataSkinOverlays; import noppes.npcs.util.ValueUtil; -import java.util.ArrayList; -import java.util.Random; -import java.util.UUID; +import java.util.*; public class DataDisplay { public EntityNPCInterface npc; @@ -45,7 +43,7 @@ public class DataDisplay { public String glowTexture = ""; public int visible = 0; //0:visible 1:Invisible 2:semi-invisible - + public int modelSize = 5; public int showName = 0; @@ -53,7 +51,7 @@ public class DataDisplay { public int modelType = 0; public boolean disableLivingAnimation = false; - + public byte showBossBar = 0; public ArrayList invisibleToList = new ArrayList<>(); @@ -80,6 +78,7 @@ public class DataDisplay { nbttagcompound.setString("Title", title); nbttagcompound.setString("SkinUrl", url); nbttagcompound.setString("Texture", texture); + nbttagcompound.setString("CloakTexture", cloakTexture); nbttagcompound.setByte("UsingSkinUrl", skinType); nbttagcompound.setString("GlowTexture", glowTexture); @@ -94,7 +93,7 @@ public class DataDisplay { NBTUtil.func_152460_a(nbttagcompound1, this.playerProfile); nbttagcompound.setTag("SkinUsername", nbttagcompound1); } - + nbttagcompound.setInteger("Size", modelSize); nbttagcompound.setInteger("modelType", modelType); @@ -121,12 +120,12 @@ public class DataDisplay { setMarkovGender(nbttagcompound.getInteger("MarkovGender")); title = nbttagcompound.getString("Title"); - + url = nbttagcompound.getString("SkinUrl"); int prevSkinType = skinType; skinType = nbttagcompound.getByte("UsingSkinUrl"); - + this.playerProfile = null; if(skinType == 1){ if (nbttagcompound.hasKey("SkinUsername", 10)){ @@ -139,8 +138,9 @@ public class DataDisplay { } String prevTexture = texture; - + texture = nbttagcompound.getString("Texture"); + cloakTexture = nbttagcompound.getString("CloakTexture"); glowTexture = nbttagcompound.getString("GlowTexture"); @@ -169,7 +169,7 @@ public class DataDisplay { modelSize = ConfigMain.NpcSizeLimit; modelType = nbttagcompound.getInteger("modelType"); - + showName = nbttagcompound.getInteger("ShowName"); visible = nbttagcompound.getInteger("NpcVisible"); @@ -197,7 +197,7 @@ public class DataDisplay { npc.textureLocation = null; npc.updateHitbox(); } - + public void loadProfile(){ if (this.playerProfile != null && !StringUtils.isNullOrEmpty(this.playerProfile.getName()) && MinecraftServer.getServer() != null){ if (!this.playerProfile.isComplete() || !this.playerProfile.getProperties().containsKey("textures")){ @@ -215,7 +215,7 @@ public class DataDisplay { } } } - + public boolean showName() { if(npc.isKilled()) return false; @@ -265,5 +265,4 @@ public class DataDisplay { return; this.markovGeneratorId = ValueUtil.clamp(id, 0, CustomNpcs.MARKOV_GENERATOR.length-1); } - } diff --git a/src/main/java/noppes/npcs/DataInventory.java b/src/main/java/noppes/npcs/DataInventory.java index c4e5b8c9a..992a68ae5 100644 --- a/src/main/java/noppes/npcs/DataInventory.java +++ b/src/main/java/noppes/npcs/DataInventory.java @@ -22,6 +22,7 @@ public class DataInventory implements IInventory { public HashMap items = new HashMap(); public HashMap dropchance = new HashMap(); public HashMap weapons = new HashMap(); + public HashMap prevWeapons = new HashMap(); public HashMap armor = new HashMap(); public int minExp = 0; diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index ccfb16114..415960599 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -550,7 +550,7 @@ public class ClientProxy extends CommonProxy { public FontContainer(String fontType, int fontSize) { textFont = new StringCache(); - textFont.setDefaultFont("Arial Unicode MS", fontSize, true); + textFont.setDefaultFont("Arial", fontSize, true); useCustomFont = !fontType.equalsIgnoreCase("minecraft"); try { if(!useCustomFont || fontType.isEmpty() || fontType.equalsIgnoreCase("default")) @@ -558,7 +558,7 @@ public class ClientProxy extends CommonProxy { else textFont.setDefaultFont(fontType, fontSize, true); } catch (Exception e) { - LogWriter.info("Failed loading font so using Arial Unicode MS"); + LogWriter.info("Failed loading font so using Arial"); } } diff --git a/src/main/java/noppes/npcs/client/EntityUtil.java b/src/main/java/noppes/npcs/client/EntityUtil.java index 05954bce4..cdb96dc15 100644 --- a/src/main/java/noppes/npcs/client/EntityUtil.java +++ b/src/main/java/noppes/npcs/client/EntityUtil.java @@ -1,5 +1,6 @@ package noppes.npcs.client; +import kamkeel.addon.GeckoAddon; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.EntityDragon; import net.minecraft.entity.passive.EntityChicken; @@ -83,7 +84,9 @@ public class EntityUtil { for(int i = 0; i < 5; i++){ entity.setCurrentItemOrArmor(i, copied.getEquipmentInSlot(i)); } - + + GeckoAddon.instance.geckoCopyData(copied, entity); + if(copied instanceof EntityNPCInterface && entity instanceof EntityNPCInterface){ EntityNPCInterface npc = (EntityNPCInterface) copied; EntityNPCInterface target = (EntityNPCInterface) entity; diff --git a/src/main/java/noppes/npcs/client/PacketHandlerClient.java b/src/main/java/noppes/npcs/client/PacketHandlerClient.java index 652204301..299190896 100644 --- a/src/main/java/noppes/npcs/client/PacketHandlerClient.java +++ b/src/main/java/noppes/npcs/client/PacketHandlerClient.java @@ -375,5 +375,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); + } } } diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java index 4d397e556..58deee21f 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java @@ -1,8 +1,3 @@ -// -// Source code recreated from a .class file by IntelliJ IDEA -// (powered by FernFlower decompiler) -// - package noppes.npcs.client.gui.custom.components; import com.ibm.icu.text.ArabicShaping; diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java index f92dfc205..8a8c8da8c 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java @@ -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); diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java index 45eb9a332..cab63a372 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java @@ -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); diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java index 6ffbbae45..0b994ed3b 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java @@ -1,6 +1,7 @@ package noppes.npcs.client.gui.mainmenu; import com.mojang.authlib.GameProfile; +import kamkeel.addon.client.GeckoAddonClient; import net.minecraft.client.gui.GuiButton; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.DataDisplay; @@ -95,6 +96,7 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene addLabel(new GuiNpcLabel(10,"display.bossbar", guiLeft + 5, y + 5)); this.addButton(new GuiNpcButton(10, guiLeft + 120, y, 110, 20, new String[]{"display.hide","display.show","display.showAttacking"}, display.showBossBar)); + GeckoAddonClient.Instance.geckoNpcDisplayInitGui(this); } @Override @@ -192,6 +194,8 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene else if(button.id == 15){ setSubGui(new SubGuiNpcName(display)); } + + GeckoAddonClient.Instance.geckoNpcDisplayActionPerformed(this, button); } @Override diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java index 866b1e84e..fbc3c7ccd 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java @@ -1,5 +1,7 @@ package noppes.npcs.client.gui.model; +import kamkeel.addon.GeckoAddon; +import kamkeel.addon.client.GeckoAddonClient; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; @@ -42,8 +44,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol for(Object name : mapping.keySet()){ Class c = (Class) mapping.get(name); try { - if(!EntityCustomNpc.class.isAssignableFrom(c) && EntityLiving.class.isAssignableFrom(c) && c.getConstructor(new Class[] {World.class}) != null && !Modifier.isAbstract(c.getModifiers())){ - if(RenderManager.instance.getEntityClassRenderObject(c) instanceof RendererLivingEntity) + if(!EntityCustomNpc.class.isAssignableFrom(c) && EntityLiving.class.isAssignableFrom(c) && c.getConstructor(World.class) != null && !Modifier.isAbstract(c.getModifiers())){ if(RenderManager.instance.getEntityClassRenderObject(c) instanceof RendererLivingEntity) data.put(name.toString(),c.asSubclass(EntityLivingBase.class)); } } catch (SecurityException e) { @@ -166,6 +167,8 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol addLabel(new GuiNpcLabel(201, "Breed", guiLeft, y + 5 + i * 22, 0xFFFFFF)); addButton(new GuiNpcButton(201, guiLeft + 80, y + i * 22, 50, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"}, breed)); } + + GeckoAddonClient.Instance.showGeckoButtons(this, entity); } private boolean isIgnored(String tag){ for(String s : ignoredTags) @@ -316,6 +319,8 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol updateTexture(); } catch (Exception ignored) {} } + + GeckoAddonClient.Instance.geckoGuiCreationScreenActionPerformed(this, button); } private void updateTexture(){ diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java b/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java index 28e336450..da1ee04f3 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java @@ -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; } } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index cdbae56c2..35d2c656e 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -2,6 +2,8 @@ package noppes.npcs.client.renderer; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; +import kamkeel.addon.GeckoAddon; +import kamkeel.addon.client.GeckoAddonClient; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.gui.FontRenderer; @@ -10,7 +12,6 @@ import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.texture.ITextureObject; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.SkinManager; @@ -32,7 +33,6 @@ import org.lwjgl.opengl.GL11; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.security.MessageDigest; @@ -219,7 +219,9 @@ public class RenderNPCInterface extends RenderLiving{ protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7) { EntityNPCInterface npc = (EntityNPCInterface) entityliving; - if (this.getEntityTexture(entityliving) != null) { + if(GeckoAddonClient.Instance.isGeckoModel(mainModel)){ + GeckoAddonClient.Instance.geckoRenderModel((ModelMPM) mainModel, npc, npc.rotationYaw, Minecraft.getMinecraft().timer.renderPartialTicks); + } else if (this.getEntityTexture(entityliving) != null) { super.renderModel(entityliving, par2, par3, par4, par5, par6, par7); } @@ -290,6 +292,31 @@ public class RenderNPCInterface extends RenderLiving{ npc.display.overlayRenderTicks++; } } + + private void renderGeoModel(EntityNPCInterface npc, float rot, float partial) + { + ((ModelMPM) mainModel).entity.renderYawOffset = ((ModelMPM) mainModel).entity.prevRenderYawOffset = 0; + if (!npc.isInvisible()) + { + RenderManager.instance.renderEntityWithPosYaw(((ModelMPM) mainModel).entity, 0,0,0,rot,partial); + } + else if (!npc.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) + { + GL11.glPushMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.15F); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); + RenderManager.instance.renderEntityWithPosYaw(((ModelMPM) mainModel).entity, 0,0,0,rot,partial); + GL11.glDisable(GL11.GL_BLEND); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glPopMatrix(); + GL11.glDepthMask(true); + } + } + + @Override protected float handleRotationFloat(EntityLivingBase par1EntityLiving, float par2){ EntityNPCInterface npc = (EntityNPCInterface) par1EntityLiving; diff --git a/src/main/java/noppes/npcs/constants/EnumPacketClient.java b/src/main/java/noppes/npcs/constants/EnumPacketClient.java index 3bca0b655..5d50bf33b 100644 --- a/src/main/java/noppes/npcs/constants/EnumPacketClient.java +++ b/src/main/java/noppes/npcs/constants/EnumPacketClient.java @@ -50,5 +50,6 @@ public enum EnumPacketClient { STOP_SOUND_FOR, PAUSE_SOUNDS, CONTINUE_SOUNDS, - STOP_SOUNDS + STOP_SOUNDS, + SYNC_WEAPON } diff --git a/src/main/java/noppes/npcs/containers/ContainerCustomGui.java b/src/main/java/noppes/npcs/containers/ContainerCustomGui.java index 1432bab76..ef4995dbd 100644 --- a/src/main/java/noppes/npcs/containers/ContainerCustomGui.java +++ b/src/main/java/noppes/npcs/containers/ContainerCustomGui.java @@ -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 { diff --git a/src/main/java/noppes/npcs/controllers/CustomGuiController.java b/src/main/java/noppes/npcs/controllers/CustomGuiController.java index 815bc96d8..dc4817b39 100644 --- a/src/main/java/noppes/npcs/controllers/CustomGuiController.java +++ b/src/main/java/noppes/npcs/controllers/CustomGuiController.java @@ -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 { diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index ef66faf00..ea473122d 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -26,6 +26,7 @@ import net.minecraft.nbt.NBTTagCompound; 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; @@ -200,6 +201,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(); } } @@ -1553,6 +1569,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){ @@ -1585,6 +1602,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))); diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java index 11e3da306..830aba090 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -19,6 +19,7 @@ import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Items; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.item.*; @@ -378,7 +379,7 @@ public class NpcAPI extends AbstractNpcAPI { scriptStack = new ScriptCustomItem(itemstack); } else if (itemstack.getItem() instanceof ItemArmor) { scriptStack = new ScriptItemArmor(itemstack); - } else if (itemstack.getItem() instanceof ItemBook) { + } else if (itemstack.getItem() instanceof ItemWritableBook || itemstack.getItem() instanceof ItemEditableBook || itemstack.getItem() == Items.written_book || itemstack.getItem() == Items.writable_book) { scriptStack = new ScriptItemBook(itemstack); } else if (itemstack.getItem() instanceof ItemBlock) { scriptStack = new ScriptItemBlock(itemstack); diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index 224be6ad8..3413a6c87 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -1126,7 +1126,7 @@ public class ScriptWorld implements IWorld { /** * Sends a packet from the server to the client everytime its called. Probably should not use this too much. - * @param particle Particle name. Particle name list: http://minecraft.gamepedia.com/Particles + * @param particle Particle name. Particle name list: http://minecraft.wiki/w/Particles * @param x The x position * @param y The y position * @param z The z position diff --git a/src/main/java/noppes/npcs/scripted/constants/RoleType.java b/src/main/java/noppes/npcs/scripted/constants/RoleType.java index 7fbc1f421..c06b501cb 100644 --- a/src/main/java/noppes/npcs/scripted/constants/RoleType.java +++ b/src/main/java/noppes/npcs/scripted/constants/RoleType.java @@ -2,9 +2,10 @@ package noppes.npcs.scripted.constants; public class RoleType { public static final int UNKNOWN = 0; - public static final int MAILMAN = 1; - public static final int TRADER = 2; - public static final int FOLLOWER = 3; - public static final int BANK = 4; - public static final int TRANSPORTER = 5; + public static final int TRADER = 1; + public static final int FOLLOWER = 2; + public static final int BANK = 3; + public static final int TRANSPORTER = 4; + public static final int POSTMAN = 5; + public static final int COMPANION = 6; } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java index eecfa87a5..6fa27d757 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java @@ -237,7 +237,7 @@ public class ScriptLivingBase extends ScriptEntity/effect command + * Works the same as the /effect command * @param effect * @param duration The duration in seconds * @param strength The amplifier of the potion effect diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 8fde773b6..da55bca12 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -404,6 +404,8 @@ public class ScriptNpc extends ScriptLiving imp return new ScriptRoleTrader(npc); else if(npc.advanced.role == EnumRoleType.Transporter) return new ScriptRoleTransporter(npc); + else if(npc.advanced.role == EnumRoleType.Companion) + return new ScriptRoleCompanion(npc); return new ScriptRoleInterface(npc); } @@ -481,7 +483,7 @@ public class ScriptNpc extends ScriptLiving imp npc.inventory.setOffHand(null); else npc.inventory.setOffHand(item.getMCItemStack()); - npc.script.clientNeedsUpdate = true; + //npc.script.clientNeedsUpdate = true; } /** diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 34e58a59c..4bbc83e0f 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -629,7 +629,7 @@ public class ScriptPlayer extends ScriptLivingBase } /** - * @param achievement The achievement id. For a complete list see http://minecraft.gamepedia.com/Achievements + * @param achievement The achievement id. For a complete list see http://minecraft.wiki/w/Achievements * @return Returns whether or not the player has this achievement */ public boolean hasAchievement(String achievement){ diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleCompanion.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleCompanion.java new file mode 100644 index 000000000..db20a3d4f --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleCompanion.java @@ -0,0 +1,17 @@ +package noppes.npcs.scripted.roles; + +import noppes.npcs.api.roles.IRoleMailman; +import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.scripted.constants.RoleType; + +public class ScriptRoleCompanion extends ScriptRoleInterface implements IRoleMailman { + + public ScriptRoleCompanion(EntityNPCInterface npc) { + super(npc); + } + + @Override + public int getType(){ + return RoleType.COMPANION; + } +} diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleMailman.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleMailman.java index 47693fd59..5f6c3199e 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleMailman.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleMailman.java @@ -12,6 +12,6 @@ public class ScriptRoleMailman extends ScriptRoleInterface implements IRoleMailm @Override public int getType(){ - return RoleType.MAILMAN; + return RoleType.POSTMAN; } } diff --git a/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboard.java b/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboard.java index 9e3e82883..75b9f7055 100644 --- a/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboard.java +++ b/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboard.java @@ -63,7 +63,7 @@ public class ScriptScoreboard implements IScoreboard { /** * @version 1.8 * @param objective Scoreboard objective name (1-16 chars) - * @param criteria The criteria see http://minecraft.gamepedia.com/Scoreboard#Objectives + * @param criteria The criteria see http://minecraft.wiki/w/Scoreboard#Objectives * @return Returns the created ScoreboardObjective, returns null if it failed to create */ public IScoreboardObjective addObjective(String objective, String criteria){