From 1ca5a306fc6e3aa7892903672a8af91b27706edf Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Sun, 19 Jun 2022 15:18:13 -0500 Subject: [PATCH] IDBCPlayer: -Items can be set in vanity or armor slots, based on a "vanity" boolean value in setItem(). ISkinOverlay: -Renamed setScale to setTextureScale. --- .../npcs/client/renderer/RenderNPCInterface.java | 4 +--- .../noppes/npcs/controllers/data/SkinOverlay.java | 10 +++++----- .../npcs/scripted/entity/ScriptDBCPlayer.java | 14 +++++++++----- .../npcs/scripted/interfaces/ISkinOverlay.java | 6 +++--- .../scripted/interfaces/entity/IDBCPlayer.java | 4 ++-- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index f66147b9a..52fe1c364 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -5,7 +5,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; import java.util.Map; import net.minecraft.client.Minecraft; @@ -23,7 +22,6 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.BossStatus; -import net.minecraft.util.ReportedException; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.model.ModelMPM; @@ -264,7 +262,7 @@ public class RenderNPCInterface extends RenderLiving{ GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); GL11.glTranslatef(npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedX(), npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedY(), 0.0F); - GL11.glScalef(overlayData.getScaleX(), overlayData.getScaleY(), 1.0F); + GL11.glScalef(overlayData.getTextureScaleX(), overlayData.getTextureScaleY(), 1.0F); GL11.glMatrixMode(GL11.GL_MODELVIEW); float scale = 1.005f * overlayData.getSize(); diff --git a/src/main/java/noppes/npcs/controllers/data/SkinOverlay.java b/src/main/java/noppes/npcs/controllers/data/SkinOverlay.java index 217ecedd6..264556815 100644 --- a/src/main/java/noppes/npcs/controllers/data/SkinOverlay.java +++ b/src/main/java/noppes/npcs/controllers/data/SkinOverlay.java @@ -71,15 +71,15 @@ public class SkinOverlay implements ISkinOverlay { return size; } - public void setScale(float scaleX, float scaleY) { + public void setTextureScale(float scaleX, float scaleY) { this.scaleX = scaleX; this.scaleY = scaleY; this.updateClient(); } - public float getScaleX() { + public float getTextureScaleX() { return scaleX; } - public float getScaleY() { + public float getTextureScaleY() { return scaleY; } @@ -142,8 +142,8 @@ public class SkinOverlay implements ISkinOverlay { compound.setFloat("SkinOverlaySize", this.getSize()); compound.setFloat("SkinOverlaySpeedX", this.getSpeedX()); compound.setFloat("SkinOverlaySpeedY", this.getSpeedY()); - compound.setFloat("SkinOverlayScaleX", this.getScaleX()); - compound.setFloat("SkinOverlayScaleY", this.getScaleY()); + compound.setFloat("SkinOverlayScaleX", this.getTextureScaleX()); + compound.setFloat("SkinOverlayScaleY", this.getTextureScaleY()); compound.setFloat("SkinOverlayOffsetX", this.getOffsetX()); compound.setFloat("SkinOverlayOffsetY", this.getOffsetY()); compound.setFloat("SkinOverlayOffsetZ", this.getOffsetZ()); diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java index a5c95a2dd..4c1392b98 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java @@ -428,14 +428,16 @@ public class ScriptDBCPlayer extends ScriptPlayer i return compound.getCompoundTag("JRMCEP").getString("extracode"); } - public void setItem(byte slot, IItemStack itemStack) { + public void setItem(IItemStack itemStack, byte slot, boolean vanity) { NBTTagCompound compound = new NBTTagCompound(); this.player.writeToNBT(compound); + byte offset = (byte) (vanity ? 10 : 2); + NBTTagList newList = new NBTTagList(); NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag",10); for (int i = 0; i < list.tagCount(); i++) { - if (list.getCompoundTagAt(i).getByte("Slot") != slot) { + if (offset - list.getCompoundTagAt(i).getByte("Slot") != slot) { newList.appendTag(list.getCompoundTagAt(i)); } } @@ -444,20 +446,22 @@ public class ScriptDBCPlayer extends ScriptPlayer i if (itemStack != null) { itemStack.getMCItemStack().writeToNBT(compoundItem); } - compoundItem.setByte("Slot", slot); + compoundItem.setByte("Slot", (byte) (offset - slot)); newList.appendTag(compoundItem); compound.getCompoundTag("JRMCEP").setTag("dbcExtraInvTag", newList); this.player.readFromNBT(compound); } - public IItemStack getItem(byte slot) { + public IItemStack getItem(byte slot, boolean vanity) { NBTTagCompound compound = new NBTTagCompound(); this.player.writeToNBT(compound); + byte offset = (byte) (vanity ? 10 : 2); + NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag",10); for (int i = 0; i < list.tagCount(); i++) { - if (list.getCompoundTagAt(i).getByte("Slot") == slot) { + if (offset - list.getCompoundTagAt(i).getByte("Slot") == slot) { return NpcAPI.Instance().getIItemStack(ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i))); } } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java b/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java index 4bf83f0d8..269adb6bb 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java @@ -43,9 +43,9 @@ public interface ISkinOverlay { /** * Sets the texture scale of the overlay. Higher values will "zoom in" to the texture more. */ - void setScale(float scaleX, float scaleY); - float getScaleX(); - float getScaleY(); + void setTextureScale(float scaleX, float scaleY); + float getTextureScaleX(); + float getTextureScaleY(); /** * Sets the "texture speed" by which the texture shifts on each render tick. Used to create a powered creeper effect! diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/IDBCPlayer.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IDBCPlayer.java index 52d799e06..cb969d359 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/IDBCPlayer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IDBCPlayer.java @@ -60,8 +60,8 @@ public interface IDBCPlayer extends IPlayer { * 10 - 1st Vanity Slot Down to the right * @param itemStack The item stack to be set into the slot. Set to null to remove the stack in that slot. */ - void setItem(byte slot, IItemStack itemStack); - IItemStack getItem(byte slot); + void setItem(IItemStack itemStack, byte slot, boolean vanity); + IItemStack getItem(byte slot, boolean vanity); IItemStack[] getInventory(); void setForm(byte form);