From 79955f549e1be098ecde4347affc67d40a92900e Mon Sep 17 00:00:00 2001 From: Kam Date: Tue, 18 Feb 2025 04:45:47 -0500 Subject: [PATCH] Complete Some Todos and Remove Some --- .../noppes/npcs/client/AssetsBrowser.java | 12 +++---- .../client/gui/script/GuiScriptEffect.java | 1 - .../gui/script/GuiScriptLinkedItem.java | 1 - .../blocks/BlockScriptedRenderer.java | 4 +-- .../npcs/entity/EntityNPCInterface.java | 31 ++++++++++++------- .../java/noppes/npcs/roles/JobHealer.java | 13 ++++---- 6 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/main/java/noppes/npcs/client/AssetsBrowser.java b/src/main/java/noppes/npcs/client/AssetsBrowser.java index d32aa3f3e..c7418684d 100644 --- a/src/main/java/noppes/npcs/client/AssetsBrowser.java +++ b/src/main/java/noppes/npcs/client/AssetsBrowser.java @@ -42,10 +42,10 @@ public class AssetsBrowser { private void getFiles() { folders.clear(); files.clear(); - + ResourcePackRepository repos = Minecraft.getMinecraft().getResourcePackRepository(); SimpleReloadableResourceManager simplemanager = (SimpleReloadableResourceManager) Minecraft.getMinecraft().getResourceManager(); - + Map map = ObfuscationReflectionHelper.getPrivateValue(SimpleReloadableResourceManager.class, simplemanager, 2); HashSet set = new HashSet(); for(String name: map.keySet()){ @@ -62,7 +62,7 @@ public class AssetsBrowser { } } } - + for(String file : set){ progressFile(new File(file)); } @@ -97,7 +97,7 @@ public class AssetsBrowser { ZipEntry zipentry = entries.nextElement(); String entryName = zipentry.getName(); checkFile(entryName); - + } zip.close(); } @@ -109,7 +109,7 @@ public class AssetsBrowser { e.printStackTrace(); } } - + private void checkFolder(File file, int length){ File[] files = file.listFiles(); if(files == null){ @@ -128,7 +128,7 @@ public class AssetsBrowser { checkFile(name); } } - + private void checkFile(String name){ if(!name.startsWith("/")) name = "/" + name; diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptEffect.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptEffect.java index c4529bcf4..b0d837a55 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptEffect.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptEffect.java @@ -105,7 +105,6 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback this.addButton(new GuiNpcButton(105, left1 + 61, this.guiTop + 21 + yoffset, 60, 20, "gui.remove")); this.addButton(new GuiNpcButton(107, left1, this.guiTop + 66 + yoffset, 80, 20, "script.loadscript")); - // TODO Uncomment if script lists ever get added this.getButton(107).enabled = false; GuiCustomScroll scroll = (new GuiCustomScroll(this, 0)).setUnselectable(); diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptLinkedItem.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptLinkedItem.java index e8a0de9ef..9ce208e25 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptLinkedItem.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptLinkedItem.java @@ -116,7 +116,6 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall this.addButton(new GuiNpcButton(105, left1 + 61, this.guiTop + 21 + yoffset, 60, 20, "gui.remove")); this.addButton(new GuiNpcButton(107, left1, this.guiTop + 66 + yoffset, 80, 20, "script.loadscript")); - // TODO Uncomment if script lists ever get added this.getButton(107).enabled = false; GuiCustomScroll scroll = (new GuiCustomScroll(this, 0)).setUnselectable(); diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockScriptedRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockScriptedRenderer.java index 8904892b5..4148da831 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockScriptedRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockScriptedRenderer.java @@ -192,9 +192,7 @@ public class BlockScriptedRenderer extends BlockRendererInterface{ } @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - //TODO - } + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {} @Override public boolean shouldRender3DInInventory(int modelId) { diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 9b826bdd2..7673cd361 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -687,17 +687,26 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti } public EntityProjectile shoot(double x, double y, double z, int accuracy, ItemStack proj, boolean indirect){ - EntityProjectile projectile = new EntityProjectile(this.worldObj, this, proj.copy(), true); - //TODO calculate height of the thrower - double varX = x - this.posX; - double varY = y - (this.posY + this.getEyeHeight()); - double varZ = z - this.posZ; - float varF = projectile.hasGravity() ? MathHelper.sqrt_double(varX * varX + varZ * varZ) : 0.0F; - float angle = projectile.getAngleForXYZ(varX, varY, varZ, varF, indirect); - float acc = 20.0F - MathHelper.floor_float(accuracy / 5.0F); - projectile.setThrowableHeading(varX, varY, varZ, angle, acc); - worldObj.spawnEntityInWorld(projectile); - return projectile; + EntityProjectile projectile = new EntityProjectile(this.worldObj, this, proj.copy(), true); + + double throwerHeight = this.getEyeHeight(); // default eye height + if (this.currentAnimation == EnumAnimation.LYING || this.currentAnimation == EnumAnimation.CRAWLING) { + // When lying or crawling, assume the effective throw point is roughly halfway up the entity + throwerHeight = this.height * 0.5; + } else if (this.currentAnimation == EnumAnimation.SITTING) { + // When sitting, adjust accordingly (example factor) + throwerHeight = this.height * 0.7; + } + + double varX = x - this.posX; + double varY = y - (this.posY + throwerHeight); + double varZ = z - this.posZ; + float varF = projectile.hasGravity() ? MathHelper.sqrt_double(varX * varX + varZ * varZ) : 0.0F; + float angle = projectile.getAngleForXYZ(varX, varY, varZ, varF, indirect); + float acc = 20.0F - MathHelper.floor_float(accuracy / 5.0F); + projectile.setThrowableHeading(varX, varY, varZ, angle, acc); + worldObj.spawnEntityInWorld(projectile); + return projectile; } private void clearTasks(EntityAITasks tasks){ diff --git a/src/main/java/noppes/npcs/roles/JobHealer.java b/src/main/java/noppes/npcs/roles/JobHealer.java index e7727ef57..29d756bc2 100644 --- a/src/main/java/noppes/npcs/roles/JobHealer.java +++ b/src/main/java/noppes/npcs/roles/JobHealer.java @@ -31,16 +31,15 @@ public class JobHealer extends JobInterface{ speed = nbttagcompound.getInteger("HealerSpeed"); } private List toHeal = new ArrayList(); - - //TODO heal food, heal potion effects, heal more types of entities besides just the player and npcs + public boolean aiShouldExecute() { healTicks++; - if (healTicks < speed * 10) + if (healTicks < speed * 10) return false; - + for(Object plObj: npc.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, npc.boundingBox.expand(range, range/2, range))){ EntityLivingBase entity = (EntityLivingBase) plObj; - + if(entity instanceof EntityPlayer){ EntityPlayer player = (EntityPlayer) entity; if(player.getHealth() < player.getMaxHealth() && !npc.faction.isAggressiveToPlayer(player)) @@ -51,7 +50,7 @@ public class JobHealer extends JobInterface{ if(npc.getHealth() < npc.getMaxHealth() && !this.npc.faction.isAggressiveToNpc(npc)) toHeal.add(npc); } - + } healTicks = 0; @@ -65,7 +64,7 @@ public class JobHealer extends JobInterface{ } toHeal.clear(); } - + public void heal(EntityLivingBase entity, float amount){ entity.heal(amount); NoppesUtilServer.spawnParticle(entity, "heal",entity.dimension);