From 47f41ff5b7475314b625ece697627973a865f158 Mon Sep 17 00:00:00 2001 From: luisc Date: Wed, 2 Feb 2022 22:11:49 -0600 Subject: [PATCH 01/18] Added custom kill types --- src/main/java/noppes/npcs/ServerEventsHandler.java | 11 ++++++++++- .../client/gui/questtypes/GuiNpcQuestTypeKill.java | 14 +++++++++++--- src/main/java/noppes/npcs/quests/QuestKill.java | 7 +++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/main/java/noppes/npcs/ServerEventsHandler.java b/src/main/java/noppes/npcs/ServerEventsHandler.java index 09049d05e..5d996b6c7 100644 --- a/src/main/java/noppes/npcs/ServerEventsHandler.java +++ b/src/main/java/noppes/npcs/ServerEventsHandler.java @@ -308,7 +308,16 @@ public class ServerEventsHandler { } String name = entityName; QuestKill quest = (QuestKill) data.quest.questInterface; - if(quest.targetType == 1 && !(entity instanceof EntityNPCInterface)) + + Class entityType = EntityNPCInterface.class; + if(quest.targetType == 2) { + try { + entityType = Class.forName(quest.customTargetType); + } catch (ClassNotFoundException notFoundException) { + continue; + } + } + if(quest.targetType > 0 && !(entityType.isInstance(entity))) continue; if(quest.targets.containsKey(entity.getCommandSenderName())) name = entity.getCommandSenderName(); diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java index 40a5cc9ae..0e1dc39e1 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java @@ -88,8 +88,12 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi addScroll(scroll); guiTop += 50; - this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 300, 98, 20, "gui.back")); - this.addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + 260, 98, 20, new String[]{"Any", "NPCs"}, quest.targetType)); + this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 310, 98, 20, "gui.back")); + this.addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + 260, 98, 20, new String[]{"Any", "NPCs", "Custom"}, quest.targetType)); + + this.addTextField(new GuiNpcTextField(36, this, fontRendererObj, guiLeft + 4, guiTop + 282, 180, 20, quest.customTargetType)); + this.getTextField(36).setVisible(this.getButton(1).getValue() == 2); + guiTop -= 50; scroll.visible = GuiNpcTextField.isFieldActive(); @@ -101,7 +105,8 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi close(); } if (guibutton.id == 1) { - quest.targetType = guibutton.displayString.equals("NPCs") ? 1 : 0; + quest.targetType = this.getButton(1).getValue(); + this.getTextField(36).setVisible(this.getButton(1).getValue() == 2); } } public void mouseClicked(int i, int j, int k) @@ -117,6 +122,9 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi if(guiNpcTextField.id < 12) lastSelected = guiNpcTextField; + if(guiNpcTextField.id == 36) + quest.customTargetType = guiNpcTextField.getText(); + saveTargets(); } private void saveTargets(){ diff --git a/src/main/java/noppes/npcs/quests/QuestKill.java b/src/main/java/noppes/npcs/quests/QuestKill.java index d4568c1eb..79206dffd 100644 --- a/src/main/java/noppes/npcs/quests/QuestKill.java +++ b/src/main/java/noppes/npcs/quests/QuestKill.java @@ -20,12 +20,14 @@ import noppes.npcs.scripted.handler.data.IQuestObjective; public class QuestKill extends QuestInterface implements IQuestKill { public HashMap targets = new HashMap(); public int targetType = 0; + public String customTargetType = "noppes.npcs.entity.EntityCustomNpc"; @Override public void writeEntityToNBT(NBTTagCompound compound) { compound.setTag("QuestKills", NBTTags.nbtStringIntegerMap(targets)); //compound.setTag("QuestDialogs", NBTTags.nbtStringIntegerMap(targets)); compound.setInteger("TargetType",targetType); + compound.setString("CustomTargetType",customTargetType); } @Override @@ -40,6 +42,7 @@ public class QuestKill extends QuestInterface implements IQuestKill { //targets = NBTTags.getStringIntegerMap(compound.getTagList("QuestDialogs", 10)); targetType = compound.getInteger("TargetType"); + customTargetType = compound.getString("CustomTargetType"); } @Override @@ -106,8 +109,8 @@ public class QuestKill extends QuestInterface implements IQuestKill { public void setTargetType(int type) { if(type < 0) type = 0; - if(type > 1) - type = 1; + if(type > 2) + type = 2; this.targetType = type; } From 18e02461a6fb0c834df790df2cc46cea4dcd2a50 Mon Sep 17 00:00:00 2001 From: luisc Date: Sun, 6 Feb 2022 12:39:07 -0600 Subject: [PATCH 02/18] Added misspelled cancel functions to player & forge events, and correctly spelled cancel functions to npc events --- .../java/noppes/npcs/scripted/event/CustomNPCsEvent.java | 6 ++++++ src/main/java/noppes/npcs/scripted/event/ScriptEvent.java | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java b/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java index 9aa5c5aa4..d7f46473f 100644 --- a/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java @@ -13,4 +13,10 @@ public class CustomNPCsEvent extends Event{ public CustomNPCsEvent() { } + + public void setCancelled(boolean bo){ + this.setCanceled(bo); + } + + public boolean isCancelled(){return this.isCanceled();} } diff --git a/src/main/java/noppes/npcs/scripted/event/ScriptEvent.java b/src/main/java/noppes/npcs/scripted/event/ScriptEvent.java index 5a5a8cbfd..12a951ca2 100644 --- a/src/main/java/noppes/npcs/scripted/event/ScriptEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/ScriptEvent.java @@ -11,4 +11,12 @@ class ScriptEvent{ public boolean isCancelled(){ return isCancelled; } + + public void setCanceled(boolean bo){ + isCancelled = bo; + } + + public boolean isCanceled(){ + return isCancelled; + } } From 3d1caf494b936b47243f5dbcfd7b0f5ca495116b Mon Sep 17 00:00:00 2001 From: luisc Date: Wed, 16 Feb 2022 12:57:46 -0600 Subject: [PATCH 03/18] Small fix to min XP and max XP text fields in NPC inventory menu --- .../noppes/npcs/client/gui/mainmenu/GuiNPCInv.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java index 690adbdd8..6348803eb 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java @@ -46,13 +46,14 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, IT addLabel(new GuiNpcLabel(0,"inv.minExp", guiLeft + 118, guiTop + 18)); addTextField(new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 108, guiTop + 29, 60, 20, npc.inventory.minExp + "")); getTextField(0).integersOnly = true; - getTextField(0).setMinMaxDefault(0, npc.inventory.maxExp, 0); addLabel(new GuiNpcLabel(1,"inv.maxExp", guiLeft + 118, guiTop + 52)); addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 108, guiTop + 63, 60, 20, npc.inventory.maxExp + "")); getTextField(1).integersOnly = true; - getTextField(1).setMinMaxDefault(npc.inventory.maxExp, Short.MAX_VALUE, 0); - + + getTextField(0).setMinMaxDefault(0, getTextField(1).getInteger(), 0); + getTextField(1).setMinMaxDefault(getTextField(0).getInteger(), Short.MAX_VALUE, 0); + addButton(new GuiNpcButton(10, guiLeft + 88, guiTop + 88, 80, 20, new String[]{"stats.normal", "inv.auto"}, npc.inventory.lootMode)); addLabel(new GuiNpcLabel(2,"inv.npcInventory", guiLeft + 191, guiTop + 5)); @@ -194,7 +195,9 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, IT public void unFocused(GuiNpcTextField textfield) { if(textfield.id >= 2){ chances.put(textfield.id-2, Double.parseDouble(textfield.getText())); - this.save(); } + getTextField(0).setMinMaxDefault(0, getTextField(1).getInteger(), 0); + getTextField(1).setMinMaxDefault(getTextField(0).getInteger(), Short.MAX_VALUE, 0); + this.save(); } } From 33e884c217066608f6368d46f42fa3a7d76571cd Mon Sep 17 00:00:00 2001 From: luisc Date: Fri, 18 Feb 2022 03:34:20 -0600 Subject: [PATCH 04/18] Flying is now smoother, NPCs can pathfind downwards easier while flying. --- .../npcs/ai/pathfinder/FlyPathFinder.java | 86 ++++--------------- .../npcs/ai/pathfinder/FlyingMoveHelper.java | 50 ++++------- .../ai/pathfinder/PathNavigateFlying.java | 6 +- .../npcs/entity/EntityNPCInterface.java | 5 ++ 4 files changed, 44 insertions(+), 103 deletions(-) diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java index 9673520d5..33a26639c 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java @@ -166,79 +166,27 @@ public class FlyPathFinder extends PathFinder b0 = 1; } - FlyPathPoint pathpoint3 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord, p_75860_2_.zCoord + 1, p_75860_3_, b0); - FlyPathPoint pathpoint4 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord, p_75860_2_.zCoord, p_75860_3_, b0); - FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord, p_75860_2_.zCoord, p_75860_3_, b0); - FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord, p_75860_2_.zCoord - 1, p_75860_3_, b0); + for(int y = -1; y <= 1; y ++) { + FlyPathPoint pathpoint3 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0); + FlyPathPoint pathpoint4 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0); + FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0); + FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0); - FlyPathPoint pathpoint7 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + 1, p_75860_2_.zCoord + 1, p_75860_3_, b0); - FlyPathPoint pathpoint8 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + 1, p_75860_2_.zCoord, p_75860_3_, b0); - FlyPathPoint pathpoint9 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + 1, p_75860_2_.zCoord, p_75860_3_, b0); - FlyPathPoint pathpoint10 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + 1, p_75860_2_.zCoord - 1, p_75860_3_, b0); + if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_) { + this.pathOptions[i++] = pathpoint3; + } - FlyPathPoint pathpoint11 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord - 1, p_75860_2_.zCoord + 1, p_75860_3_, b0); - FlyPathPoint pathpoint12 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord - 1, p_75860_2_.zCoord, p_75860_3_, b0); - FlyPathPoint pathpoint13 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord - 1, p_75860_2_.zCoord, p_75860_3_, b0); - FlyPathPoint pathpoint14 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord - 1, p_75860_2_.zCoord - 1, p_75860_3_, b0); + if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(p_75860_4_) < p_75860_5_) { + this.pathOptions[i++] = pathpoint4; + } - if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_) - { - this.pathOptions[i++] = pathpoint3; - } + if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(p_75860_4_) < p_75860_5_) { + this.pathOptions[i++] = pathpoint5; + } - if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(p_75860_4_) < p_75860_5_) - { - this.pathOptions[i++] = pathpoint4; - } - - if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(p_75860_4_) < p_75860_5_) - { - this.pathOptions[i++] = pathpoint5; - } - - if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(p_75860_4_) < p_75860_5_) - { - this.pathOptions[i++] = pathpoint6; - } - - if (pathpoint7 != null && !pathpoint7.isFirst && pathpoint7.distanceTo(p_75860_4_) < p_75860_5_) - { - this.pathOptions[i++] = pathpoint7; - } - - if (pathpoint8 != null && !pathpoint8.isFirst && pathpoint8.distanceTo(p_75860_4_) < p_75860_5_) - { - this.pathOptions[i++] = pathpoint8; - } - - if (pathpoint9 != null && !pathpoint9.isFirst && pathpoint9.distanceTo(p_75860_4_) < p_75860_5_) - { - this.pathOptions[i++] = pathpoint9; - } - - if (pathpoint10 != null && !pathpoint10.isFirst && pathpoint10.distanceTo(p_75860_4_) < p_75860_5_) - { - this.pathOptions[i++] = pathpoint10; - } - - if (pathpoint11 != null && !pathpoint11.isFirst && pathpoint11.distanceTo(p_75860_4_) < p_75860_5_) - { - this.pathOptions[i++] = pathpoint11; - } - - if (pathpoint12 != null && !pathpoint12.isFirst && pathpoint12.distanceTo(p_75860_4_) < p_75860_5_) - { - this.pathOptions[i++] = pathpoint12; - } - - if (pathpoint13 != null && !pathpoint13.isFirst && pathpoint13.distanceTo(p_75860_4_) < p_75860_5_) - { - this.pathOptions[i++] = pathpoint13; - } - - if (pathpoint14 != null && !pathpoint14.isFirst && pathpoint14.distanceTo(p_75860_4_) < p_75860_5_) - { - this.pathOptions[i++] = pathpoint14; + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(p_75860_4_) < p_75860_5_) { + this.pathOptions[i++] = pathpoint6; + } } return i; diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java index e316c7fb2..b754b2514 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java @@ -29,45 +29,33 @@ public class FlyingMoveHelper extends EntityMoveHelper{ if (this.update) { this.update = false; - double speed = this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue(); - double speedMult = 0.6000000238418579D / 0.5D; + double speed = this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue() * this.entity.ai.flySpeed; double d0 = this.posX - this.entity.posX; - double d1 = this.posY - this.entity.posY; + double d1 = this.posY - MathHelper.floor_double(this.entity.boundingBox.minY + 0.05D); double d2 = this.posZ - this.entity.posZ; double d4 = d0 * d0 + d1 * d1 + d2 * d2; + double d5 = MathHelper.sqrt_double(d4); + + double heightOffGround = 0; + if(this.entity.ai.hasFlyLimit) { + for (int blockY = (int) this.posY; blockY > 0; blockY--) { + heightOffGround = this.posY - blockY; + if (this.entity.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.entity.ai.flyHeightLimit){ + break; + } + } + } if (this.entity.hurtTime == 0 && d4 > 0.5D) { - if (this.posY != this.entity.posY) { - if (this.entity.motionY * Math.signum(this.entity.posY - this.posY) > 0.0D) { - this.entity.motionY = 0.0D; - } + this.entity.motionX += (d0 / d5 * speed - this.entity.motionX) * speed; + this.entity.motionZ += (d2 / d5 * speed - this.entity.motionZ) * speed; - double verticalSpeed = Math.abs(this.entity.posY - this.posY); - if(verticalSpeed > speed * speedMult) - verticalSpeed = speed * speedMult; - verticalSpeed += this.entity.ai.flySpeed/2.0D; - - if(verticalSpeed > Math.abs(this.entity.posY - this.posY)) - verticalSpeed = Math.abs(this.entity.posY - this.posY); - - int blockY = (int) this.posY; - double heightOffGround = 0; - if(this.entity.ai.hasFlyLimit) { - for (blockY = (int) this.posY; blockY > 0; blockY--) { - heightOffGround = this.posY - blockY; - if (this.entity.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.entity.ai.flyHeightLimit){ - break; - } - } - } - if(heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit) - this.entity.motionY -= Math.signum(this.entity.posY - this.posY) * verticalSpeed; + if (heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit) { + this.entity.motionY = ((d1 / d5) * speed); + if(this.entity.motionY < 0 && this.entity.motionY > -6 * this.entity.ai.getWalkingSpeed()/5.0D) + this.entity.motionY *= 5; } - - double d5 = MathHelper.sqrt_double(d4); - this.entity.motionX += (d0 / d5 * speed - this.entity.motionX) * speed * speedMult; - this.entity.motionZ += (d2 / d5 * speed - this.entity.motionZ) * speed * speedMult; } this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),30.0F); diff --git a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java index b98743930..581c46139 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java @@ -289,15 +289,15 @@ public class PathNavigateFlying extends PathNavigate { private Vec3 getEntityPosition() { - return Vec3.createVectorHelper(this.theEntity.posX, (double)this.getPathableYPos(), this.theEntity.posZ); + return Vec3.createVectorHelper(this.theEntity.posX, this.getPathableYPos(), this.theEntity.posZ); } /** * Gets the safe pathing Y position for the entity depending on if it can path swim or not */ - private int getPathableYPos() + private double getPathableYPos() { - return (int)(this.theEntity.boundingBox.minY + 0.5D); + return this.theEntity.boundingBox.minY + 0.05D; } /** diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index f9419d802..c339a524d 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -243,6 +243,11 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti script.setWorld(world); } + public int getMaxSafePointTries() + { + return 5; + } + @Override public boolean attackEntityAsMob(Entity par1Entity){ float f = stats.getAttackStrength(); From 732e97e0fe984b1d1e30055dc502d91fd299c61f Mon Sep 17 00:00:00 2001 From: luisc Date: Sun, 20 Feb 2022 00:56:57 -0600 Subject: [PATCH 05/18] Override updateLeashedState() function in EntityNPCInterface. NPCs can't be leashed anyway. This should avoid the "does not know how to add entity" crash with NPCs. --- src/main/java/noppes/npcs/entity/EntityNPCInterface.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index c339a524d..54ec303ae 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -1817,4 +1817,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti { this.display.modelType = val; } + + protected void updateLeashedState(){} } From c2a669fbebaebdc0e1113c43b7885597f40b90ba Mon Sep 17 00:00:00 2001 From: luisc Date: Mon, 21 Feb 2022 20:16:42 -0600 Subject: [PATCH 06/18] The setForm() function in ScriptDBCPlayer prevents crashes from form levels that are out of bounds now. --- .../npcs/scripted/entity/ScriptDBCPlayer.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java index be7dffda8..7ea50063b 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java @@ -445,6 +445,26 @@ public class ScriptDBCPlayer extends ScriptPlayer{ } public void setForm(byte form){ + if(form < 0) + return; + + switch(getRace()){ + case 0: + case 3: + if(form > 3) + return; + break; + case 1: + case 2: + if(form > 15) + return; + break; + case 4: + if(form > 7) + return; + break; + } + player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState",form); } public byte getForm(){ From 450e065e2770c4f16160390be6141633a181ef68 Mon Sep 17 00:00:00 2001 From: luisc Date: Tue, 22 Feb 2022 01:52:47 -0600 Subject: [PATCH 07/18] Slightly improved flight pathing downwards. --- .../npcs/ai/pathfinder/FlyingMoveHelper.java | 8 ++-- .../noppes/npcs/entity/EntityNPCFlying.java | 47 ++++++++++--------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java index b754b2514..f47667a08 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java @@ -52,13 +52,13 @@ public class FlyingMoveHelper extends EntityMoveHelper{ this.entity.motionZ += (d2 / d5 * speed - this.entity.motionZ) * speed; if (heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit) { - this.entity.motionY = ((d1 / d5) * speed); - if(this.entity.motionY < 0 && this.entity.motionY > -6 * this.entity.ai.getWalkingSpeed()/5.0D) - this.entity.motionY *= 5; + this.entity.motionY += (d1 / d5 * speed - this.entity.motionY) * speed; } + + this.entity.velocityChanged = true; } - this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),30.0F); + this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),18.0F); } } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java index d8dd7e23f..79322b806 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java @@ -3,9 +3,12 @@ package noppes.npcs.entity; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.util.MathHelper; import net.minecraft.world.World; +import noppes.npcs.constants.EnumRoleType; +import noppes.npcs.roles.RoleCompanion; public abstract class EntityNPCFlying extends EntityNPCInterface { @@ -30,17 +33,21 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { super.updateFallState(p_180433_1_, p_180433_3_); } - public void onLivingUpdate() + @Override + public boolean isOnLadder(){ + return false; + } + + public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) { - super.onLivingUpdate(); - if(!canFly()){ + if(!this.canFly() || this.hurtTime != 0) { + super.moveEntityWithHeading(p_70612_1_, p_70612_2_); return; } - int blockY = (int) this.posY; double heightOffGround = 0; if(this.ai.hasFlyLimit) { - for (blockY = (int) this.posY; blockY > 0; blockY--) { + for (int blockY = (int) this.posY; blockY > 0; blockY--) { heightOffGround = this.posY - blockY; if (this.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.ai.flyHeightLimit){ break; @@ -48,24 +55,18 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { } } - if (!this.onGround && !this.velocityChanged && this.motionY < 0 && this.hurtTime == 0) - { - if(heightOffGround >= this.ai.flyHeightLimit && this.ai.hasFlyLimit){ - this.motionY *= 0.8D; - this.velocityChanged = true; - } else { - this.motionY *= this.ai.flyGravity; - this.velocityChanged = true; - } + if(this.getNavigator().noPath()) + this.motionY = 0.0D; + + if(heightOffGround < this.ai.flyHeightLimit || !this.ai.hasFlyLimit) { + double d3 = this.motionY; + super.moveEntityWithHeading(p_70612_1_, p_70612_2_); + this.motionY = d3; + + this.fallDistance = 0.0F; + this.velocityChanged = true; + } else { + super.moveEntityWithHeading(p_70612_1_,p_70612_2_); } } - - @Override - public boolean isOnLadder(){ - return false; - } - - - - } From ee02988d8c602d65ca393be5cb280c77de3e8bf7 Mon Sep 17 00:00:00 2001 From: luisc Date: Tue, 22 Feb 2022 22:14:05 -0600 Subject: [PATCH 08/18] Removed client-side imports from EntityNPCFlying --- src/main/java/noppes/npcs/entity/EntityNPCFlying.java | 7 ------- .../noppes/npcs/scripted/gui/ScriptGuiTexturedRect.java | 1 - 2 files changed, 8 deletions(-) diff --git a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java index 79322b806..d57d89b4f 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java @@ -1,14 +1,7 @@ package noppes.npcs.entity; -import net.minecraft.entity.Entity; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.EntityAISwimming; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import noppes.npcs.constants.EnumRoleType; -import noppes.npcs.roles.RoleCompanion; public abstract class EntityNPCFlying extends EntityNPCInterface { diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiTexturedRect.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiTexturedRect.java index a2b66012a..051ef6592 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiTexturedRect.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiTexturedRect.java @@ -1,7 +1,6 @@ package noppes.npcs.scripted.gui; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.client.gui.custom.GuiCustom; import noppes.npcs.scripted.interfaces.ITexturedRect; public class ScriptGuiTexturedRect extends ScriptGuiComponent implements ITexturedRect { From 22b622d46ccb110fae279590d15887b8659f5f79 Mon Sep 17 00:00:00 2001 From: luisc Date: Wed, 23 Feb 2022 00:39:01 -0600 Subject: [PATCH 09/18] Fixed hovering text for custom GUI labels and textured rectangles. --- .../npcs/client/gui/custom/components/CustomGuiLabel.java | 4 +++- .../client/gui/custom/components/CustomGuiTexturedRect.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) 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 e17ad09d4..798d6dd16 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 @@ -119,7 +119,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { } public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) { - boolean hovered = mouseX >= this.field_146162_g && mouseY >= this.field_146174_h && mouseX < this.field_146162_g + this.field_146167_a && mouseY < this.field_146174_h + this.field_146161_f; + boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.field_146167_a && mouseY < this.y + this.field_146161_f; this.drawLabel(); if (hovered && this.hoverText != null && this.hoverText.length > 0) { this.parent.hoverText = this.hoverText; @@ -146,6 +146,8 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { lbl.color = component.getColor(); lbl.alpha = component.getAlpha(); lbl.rotation = component.getRotation(); + lbl.field_146167_a = component.getWidth(); + lbl.field_146161_f = component.getHeight(); return lbl; } 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 4be936f3c..d6a78862b 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 @@ -71,7 +71,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 && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; + 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; mc.getTextureManager().bindTexture(this.texture); GL11.glPushMatrix(); From 403738262cefeb1c0d5d65391eab4a97f0bcbec3 Mon Sep 17 00:00:00 2001 From: luisc Date: Sun, 27 Feb 2022 23:08:24 -0600 Subject: [PATCH 10/18] Added timer functions. ticks(int id): Gets the remaining ticks in the timer that matches this id. setTicks(int id, int ticks): Sets the remaining ticks in the timer that matches this id. maxTicks(int id): Gets the maximum ticks that must elapse for the timer that matches this id to finish. setMaxTicks(int id, int ticks): Sets the maximum ticks that must elapse for the timer that matches this id to finish. repeats(int id): Returns true if the timer with the given id is set to repeat, false otherwise. setRepeats(int id, bool repeat): Sets whether the timer with the given id should repeat. If true, the timer will repeat, and not repeat otherwise. --- .../noppes/npcs/entity/data/DataTimers.java | 34 +++++++++++++++++++ .../npcs/scripted/interfaces/ITimers.java | 12 +++++++ 2 files changed, 46 insertions(+) diff --git a/src/main/java/noppes/npcs/entity/data/DataTimers.java b/src/main/java/noppes/npcs/entity/data/DataTimers.java index 58378e07a..76550f747 100644 --- a/src/main/java/noppes/npcs/entity/data/DataTimers.java +++ b/src/main/java/noppes/npcs/entity/data/DataTimers.java @@ -55,6 +55,40 @@ public class DataTimers implements ITimers { } } + public int ticks(int id){ + return this.timers.get(Integer.valueOf(id)).ticks; + } + + public void setTicks(int id, int ticks){ + DataTimers.Timer timer = (DataTimers.Timer)this.timers.get(Integer.valueOf(id)); + if(ticks < 0) + ticks = 0; + if(ticks > timer.timerTicks) + ticks = timer.timerTicks; + + timer.ticks = ticks; + } + + public int maxTicks(int id){ + return this.timers.get(Integer.valueOf(id)).timerTicks; + } + + public void setMaxTicks(int id, int maxTicks){ + DataTimers.Timer timer = (DataTimers.Timer)this.timers.get(Integer.valueOf(id)); + if(maxTicks < 0) + maxTicks = 0; + + timer.timerTicks = maxTicks; + } + + public boolean repeats(int id){ + return this.timers.get(Integer.valueOf(id)).repeat; + } + + public void setRepeats(int id, boolean repeat){ + this.timers.get(Integer.valueOf(id)).repeat = repeat; + } + public void writeToNBT(NBTTagCompound compound) { NBTTagList list = new NBTTagList(); Iterator var3 = this.timers.values().iterator(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ITimers.java b/src/main/java/noppes/npcs/scripted/interfaces/ITimers.java index f69b93032..df3623e97 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ITimers.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ITimers.java @@ -18,5 +18,17 @@ public interface ITimers { void clear(); + int ticks(int id); + + void setTicks(int id, int ticks); + + int maxTicks(int id); + + void setMaxTicks(int id, int maxTicks); + + boolean repeats(int id); + + void setRepeats(int id, boolean repeat); + int size(); } From d2d3cef681276f92471e3ece3fa391bca26ff766 Mon Sep 17 00:00:00 2001 From: luisc Date: Sun, 27 Feb 2022 23:11:52 -0600 Subject: [PATCH 11/18] When setMaxTicks() is called and the remaining ticks in a timer are greater than that value, the remaining ticks are updated to the new max tick value. --- src/main/java/noppes/npcs/entity/data/DataTimers.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/noppes/npcs/entity/data/DataTimers.java b/src/main/java/noppes/npcs/entity/data/DataTimers.java index 76550f747..6c0008c7e 100644 --- a/src/main/java/noppes/npcs/entity/data/DataTimers.java +++ b/src/main/java/noppes/npcs/entity/data/DataTimers.java @@ -77,6 +77,8 @@ public class DataTimers implements ITimers { DataTimers.Timer timer = (DataTimers.Timer)this.timers.get(Integer.valueOf(id)); if(maxTicks < 0) maxTicks = 0; + if(timer.ticks > maxTicks) + timer.ticks = maxTicks; timer.timerTicks = maxTicks; } From 65ab37158ff2dc25dd94932b1511dd03cd2cf46a Mon Sep 17 00:00:00 2001 From: luisc Date: Sun, 27 Feb 2022 23:23:41 -0600 Subject: [PATCH 12/18] Fixed flying limits not working on flying NPCs with the new smoother flight --- .../noppes/npcs/entity/EntityNPCFlying.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java index d57d89b4f..e588e2f93 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java @@ -48,18 +48,19 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { } } + if(heightOffGround > this.ai.flyHeightLimit && this.ai.hasFlyLimit){ + super.moveEntityWithHeading(p_70612_1_,p_70612_2_); + return; + } + + double d3 = this.motionY; + super.moveEntityWithHeading(p_70612_1_, p_70612_2_); + this.motionY = d3; + + this.fallDistance = 0.0F; + this.velocityChanged = true; + if(this.getNavigator().noPath()) this.motionY = 0.0D; - - if(heightOffGround < this.ai.flyHeightLimit || !this.ai.hasFlyLimit) { - double d3 = this.motionY; - super.moveEntityWithHeading(p_70612_1_, p_70612_2_); - this.motionY = d3; - - this.fallDistance = 0.0F; - this.velocityChanged = true; - } else { - super.moveEntityWithHeading(p_70612_1_,p_70612_2_); - } } } From 7f8246e04e06bfde08227c0ffa67a3092a39e6c1 Mon Sep 17 00:00:00 2001 From: luisc Date: Wed, 2 Mar 2022 18:18:03 -0600 Subject: [PATCH 13/18] PARTICLE ROTATION --- .../java/noppes/npcs/NoppesUtilServer.java | 10 +- .../java/noppes/npcs/client/NoppesUtil.java | 24 ++ .../noppes/npcs/client/fx/EntityCustomFX.java | 277 +++++++++--------- .../npcs/scripted/ScriptEntityParticle.java | 142 ++++++--- .../npcs/scripted/entity/ScriptEntity.java | 12 +- .../npcs/scripted/interfaces/IEntity.java | 34 ++- 6 files changed, 318 insertions(+), 181 deletions(-) diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index 6feca3dd1..91f1fc631 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -312,11 +312,15 @@ public class NoppesUtilServer { Server.sendAssociatedData(entity, EnumPacketClient.PARTICLE, entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle); } - public static void spawnScriptedParticle(Entity entity, String directory, int HEXcolor, int amount, int maxAge, + public static void spawnScriptedParticle(String directory, int HEXcolor, int amount, int maxAge, double x, double y, double z, double motionX, double motionY, double motionZ, float gravity, float scale1, float scale2, float scaleRate, int scaleRateStart, float alpha1, float alpha2, float alphaRate, int alphaRateStart, + float rotation1, float rotation2, float rotationRate, int rotationRateStart, + float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, + float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, + float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart, int entityID ){ Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE, @@ -325,6 +329,10 @@ public class NoppesUtilServer { motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, alpha1, alpha2, alphaRate, alphaRateStart, + rotation1, rotation2, rotationRate, rotationRateStart, + rotationX1, rotationX2, rotationXRate, rotationXRateStart, + rotationY1, rotationY2, rotationYRate, rotationYRateStart, + rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, entityID ); } diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index cfe3ce72e..a56100828 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -98,6 +98,26 @@ public class NoppesUtil { float alphaRate = buffer.readFloat(); int alphaRateStart = buffer.readInt(); + float rotation1 = buffer.readFloat(); + float rotation2 = buffer.readFloat(); + float rotationRate = buffer.readFloat(); + int rotationRateStart = buffer.readInt(); + + float rotationX1 = buffer.readFloat(); + float rotationX2 = buffer.readFloat(); + float rotationXRate = buffer.readFloat(); + int rotationXRateStart = buffer.readInt(); + + float rotationY1 = buffer.readFloat(); + float rotationY2 = buffer.readFloat(); + float rotationYRate = buffer.readFloat(); + int rotationYRateStart = buffer.readInt(); + + float rotationZ1 = buffer.readFloat(); + float rotationZ2 = buffer.readFloat(); + float rotationZRate = buffer.readFloat(); + int rotationZRateStart = buffer.readInt(); + int entityID = buffer.readInt(); World worldObj = Minecraft.getMinecraft().theWorld; @@ -113,6 +133,10 @@ public class NoppesUtil { motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, alpha1, alpha2, alphaRate, alphaRateStart, + rotation1, rotation2, rotationRate, rotationRateStart, + rotationX1, rotationX2, rotationXRate, rotationXRateStart, + rotationY1, rotationY2, rotationYRate, rotationYRateStart, + rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, maxAge ); diff --git a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java index 3ba3a02d6..f432ae0bd 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java +++ b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java @@ -7,7 +7,6 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.ClientProxy; -import org.lwjgl.Sys; import org.lwjgl.opengl.GL11; public class EntityCustomFX extends EntityFX { @@ -27,10 +26,38 @@ public class EntityCustomFX extends EntityFX { public float alphaRate = 0.0F; public int alphaRateStart = 0; + public float rotation = 0; + public float rotation1 = 0; + public float rotation2 = 0; + public float rotationRate = 0.0F; + public int rotationRateStart = 0; + + public float rotationX = 0; + public float rotationX1 = 0; + public float rotationX2 = 0; + public float rotationXRate = 0.0F; + public int rotationXRateStart = 0; + + public float rotationY = 0; + public float rotationY1 = 0; + public float rotationY2 = 0; + public float rotationYRate = 0.0F; + public int rotationYRateStart = 0; + + public float rotationZ = 0; + public float rotationZ1 = 0; + public float rotationZ2 = 0; + public float rotationZRate = 0.0F; + public int rotationZRateStart = 0; + public EntityCustomFX(Entity entity, String directory, int HEXColor, double x, double y, double z, double motionX, double motionY, double motionZ, float gravity, float scale1, float scale2, float scaleRate, int scaleRateStart, float alpha1, float alpha2, float alphaRate, int alphaRateStart, + float rotation1, float rotation2, float rotationRate, int rotationRateStart, + float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, + float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, + float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart, int age) { super(entity.worldObj, x, y, z, motionX, motionY, motionZ); @@ -50,6 +77,38 @@ public class EntityCustomFX extends EntityFX { if(alpha1 > alpha2) this.alphaRate *= -1; + this.rotation1 = rotation1; + this.rotation2 = rotation2; + this.rotationRate = Math.abs(rotationRate); + this.rotationRateStart = rotationRateStart; + rotation = rotation1; + if(rotation1 > rotation2) + this.rotationRate *= -1; + + this.rotationX1 = rotationX1; + this.rotationX2 = rotationX2; + this.rotationXRate = Math.abs(rotationXRate); + this.rotationXRateStart = rotationXRateStart; + rotationX = rotationX1; + if(rotationX1 > rotationX2) + this.rotationXRate *= -1; + + this.rotationY1 = rotationY1; + this.rotationY2 = rotationY2; + this.rotationYRate = Math.abs(rotationYRate); + this.rotationYRateStart = rotationYRateStart; + rotationY = rotationY1; + if(rotationY1 > rotationY2) + this.rotationYRate *= -1; + + this.rotationZ1 = rotationZ1; + this.rotationZ2 = rotationZ2; + this.rotationZRate = Math.abs(rotationZRate); + this.rotationZRateStart = rotationZRateStart; + rotationZ = rotationZ1; + if(rotationZ1 > rotationZ2) + this.rotationZRate *= -1; + particleGravity = gravity/0.04F; particleMaxAge = age; @@ -74,148 +133,96 @@ public class EntityCustomFX extends EntityFX { location = new ResourceLocation(directory); } - /* - par2 = partial tick time - par3 = ActiveRenderInfo.rotationX; - par4 = ActiveRenderInfo.rotationZ; - par5 = ActiveRenderInfo.rotationYZ; - par6 = ActiveRenderInfo.rotationXY; - par7 = ActiveRenderInfo.rotationXZ; - */ - @Override - public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + public void renderParticle(Tessellator tessellator, float partialTick, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch) { - if(move){ - startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)par2); - startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)par2); - startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)par2); - } - Tessellator tessellator = Tessellator.instance; tessellator.draw(); - - float scale = this.scaleRate / (float)particleMaxAge; - if((this.scaleRate < 0 && particleScale+scale < this.scale2) || (this.scaleRate > 0 && particleScale+scale > this.scale2)) - particleScale = this.scale2; - else if(particleAge >= this.scaleRateStart) - particleScale += scale; - - float alpha = this.alphaRate / (float)particleMaxAge; - if((this.alphaRate < 0 && particleAlpha+alpha < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alpha > this.alpha2)) - particleAlpha = this.alpha2; - else if(particleAge >= this.alphaRateStart) - particleAlpha += alpha; - - ClientProxy.bindTexture(location); - - float f = 0.0f; - float f1 = 1.0f; - float f2 = 0.0f; - float f3 = 1.0f; - float f4 = 0.1F * particleScale; - float f5 = (float)(((prevPosX + (posX - prevPosX) * (double)par2) - interpPosX) + startX); - float f6 = (float)(((prevPosY + (posY - prevPosY) * (double)par2) - interpPosY) + startY); - float f7 = (float)(((prevPosZ + (posZ - prevPosZ) * (double)par2) - interpPosZ) + startZ); - - tessellator.startDrawingQuads(); - tessellator.setBrightness(240); - par1Tessellator.setColorOpaque_F(1, 1, 1); - par1Tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); - par1Tessellator.addVertexWithUV(f5 - par3 * f4 - par6 * f4, f6 - par4 * f4, f7 - par5 * f4 - par7 * f4, f1, f3); - par1Tessellator.addVertexWithUV((f5 - par3 * f4) + par6 * f4, f6 + par4 * f4, (f7 - par5 * f4) + par7 * f4, f1, f2); - par1Tessellator.addVertexWithUV(f5 + par3 * f4 + par6 * f4, f6 + par4 * f4, f7 + par5 * f4 + par7 * f4, f, f2); - par1Tessellator.addVertexWithUV((f5 + par3 * f4) - par6 * f4, f6 - par4 * f4, (f7 + par5 * f4) - par7 * f4, f, f3); - - /* - Minecraft minecraft = Minecraft.getMinecraft(); - EntityPlayer player = minecraft.thePlayer; - - double angle = Minecraft.getMinecraft().theWorld.getWorldTime()%360; - double angleRad = (angle/180)*Math.PI; - - double diffX = player.posX - this.startX; - double diffY = player.posY - player.getYOffset() - this.startY; - double diffZ = player.posZ - this.startZ; - - double yaw = (player.rotationYaw/180)*Math.PI; - double pitch = (player.rotationPitch/180)*Math.PI; - - double angleX = Math.sin(yaw)*Math.cos(pitch); - if(Math.abs(angleX) < 0.0001){ - angleX = 0.0D; - } - double angleY = Math.sin(pitch); - if(Math.abs(angleY) < 0.0001){ - angleY = 0.0D; - } - double angleZ = -Math.cos(yaw)*Math.cos(pitch); - if(Math.abs(angleZ) < 0.0001){ - angleZ = 0.0D; - } - - double angleXtranslateX = 0.0D; - double angleXtranslateY = 0.0D;//(-diffY + Math.cos(angleRad)*diffY) + (-Math.sin(angleRad)*diffZ); - double angleXtranslateZ = 0.0D;//(Math.sin(angleRad)*diffY) + (-diffZ + Math.cos(angleRad)*diffZ); - - double angleYtranslateX = 0.0D;//(-diffX + Math.cos(angleRad)*diffX) + (Math.sin(angleRad)*diffZ); - double angleYtranslateY = 0.0D; - double angleYtranslateZ = 0.0D;//(-Math.sin(angleRad)*diffX) + (-diffZ + Math.cos(angleRad)*diffZ); - - double angleZtranslateX = 0.0D;//(-diffX + Math.cos(angleRad)*diffX) + (-Math.sin(angleRad)*diffY); - double angleZtranslateY = 0.0D;//(Math.sin(angleRad)*diffX) + (-diffY + Math.cos(angleRad)*diffY); - double angleZtranslateZ = 0.0D; - - double translateX = angleXtranslateX + angleYtranslateX + angleZtranslateX; - double translateY = angleXtranslateY + angleYtranslateY + angleZtranslateY; - double translateZ = angleXtranslateZ + angleYtranslateZ + angleZtranslateZ; - - //distance in the X & Z plane - double distXZ = Math.sqrt(Math.pow(diffX,2) + Math.pow(diffZ,2)); - //distance in the X & Y plane - double distXY = Math.sqrt(Math.pow(diffX,2) + Math.pow(diffY,2)); - //distance in the Y & Z plane - double distYZ = Math.sqrt(Math.pow(diffY,2) + Math.pow(diffZ,2)); - - double signDiffX = Math.signum(diffX); - double signDiffY = Math.signum(diffY); - double signDiffZ = Math.signum(diffZ); - - double angleXtoNorm = Math.sin(Math.acos(diffX/distXZ)); - double angleZtoNorm = Math.sin(Math.acos(diffZ/distXZ)); - - double angleDiffX = (Math.abs(Math.cos(yaw))-angleXtoNorm); - double angleDiffZ = (Math.abs(Math.cos(yaw))-angleZtoNorm); - - double translateX = -Math.abs(angleDiffX*angleZ*distXZ)*signDiffX; - double translateY = 0; - double translateZ = -Math.abs(angleDiffX*angleX*distXZ)*signDiffZ + Math.cos(angleRad)*Math.abs(angleDiffX*angleX*distXZ)*signDiffZ; - - if(minecraft.currentScreen == null) { - System.out.println(); - //System.out.printf("diffX: %f, diffY: %f, diffZ: %f\n", diffX, diffY, diffZ); - //System.out.printf("angleX: %f, angleY: %f, angleZ: %f\n", angleX, angleY, angleZ); - //System.out.printf("angleXtoNorm: %f, angleZtoNorm: %f\n", angleXtoNorm, angleZtoNorm); - System.out.printf("Math.sin(yaw): %f\n", Math.sin(yaw)); - System.out.printf("Math.cos(yaw): %f\n", Math.cos(yaw)); - //System.out.printf("Math.sin(pitch): %f\n", Math.sin(pitch)); - //System.out.printf("Math.cos(pitch): %f\n", Math.cos(pitch)); - System.out.printf("angleDiffX: %f\n", angleDiffX); - System.out.printf("angleDiffZ: %f\n", angleDiffZ); - System.out.printf("translateX: %f\n", Math.cos(angleRad)*Math.abs(angleDiffX*angleZ*distXZ)*signDiffX); - System.out.printf("translateZ: %f\n", Math.cos(angleRad)*Math.abs(angleDiffX*angleX*distXZ)*signDiffZ); - } - */ - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 1.0F); + ClientProxy.bindTexture(location); + GL11.glTexParameterf(3553, 10242, 10497.0F); + GL11.glTexParameterf(3553, 10243, 10497.0F); + GL11.glDisable(2884); + GL11.glEnable(3042); - //GL11.glTranslated(translateX,translateY,translateZ); - //GL11.glRotated(angle, angleX, angleY, angleZ); + if(move){ + startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTick); + startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTick); + startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTick); + } + + float scaleChange = this.scaleRate / (float)particleMaxAge; + if((this.scaleRate < 0 && particleScale+scaleChange < this.scale2) || (this.scaleRate > 0 && particleScale+scaleChange > this.scale2)) + particleScale = this.scale2; + else if(particleAge >= this.scaleRateStart) + particleScale += scaleChange; + + float alphaChange = this.alphaRate / (float)particleMaxAge; + if((this.alphaRate < 0 && particleAlpha+alphaChange < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alphaChange > this.alpha2)) + particleAlpha = this.alpha2; + else if(particleAge >= this.alphaRateStart) + particleAlpha += alphaChange; + + float rotationChange = this.rotationRate / (float)particleMaxAge; + if((this.rotationRate < 0 && rotation+rotationChange < this.rotation2) || (this.rotationRate > 0 && rotation+rotationChange > this.rotation2)) + rotation = this.rotation2; + else if(particleAge >= this.rotationRateStart) + rotation += rotationChange; + + float rotationXChange = this.rotationXRate / (float)particleMaxAge; + if((this.rotationXRate < 0 && rotationX+rotationXChange < this.rotationX2) || (this.rotationXRate > 0 && rotationX+rotationXChange > this.rotationX2)) + rotationX = this.rotationX2; + else if(particleAge >= this.rotationXRateStart) + rotationX += rotationXChange; + + float rotationYChange = this.rotationYRate / (float)particleMaxAge; + if((this.rotationYRate < 0 && rotationY+rotationYChange < this.rotationY2) || (this.rotationYRate > 0 && rotationY+rotationYChange > this.rotationY2)) + rotationY = this.rotationY2; + else if(particleAge >= this.rotationYRateStart) + rotationY += rotationYChange; + + float rotationZChange = this.rotationZRate / (float)particleMaxAge; + if((this.rotationZRate < 0 && rotationZ+rotationZChange < this.rotationZ2) || (this.rotationZRate > 0 && rotationZ+rotationZChange > this.rotationZ2)) + rotationZ = this.rotationZ2; + else if(particleAge >= this.rotationZRateStart) + rotationZ += rotationZChange; + + float u1 = 0.0f; + float u2 = 1.0f; + float v1 = 0.0f; + float v2 = 1.0f; + + float renderScale = 0.1F * particleScale; + + float posX = (float)(((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX); + float posY = (float)(((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY); + float posZ = (float)(((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ); + + GL11.glTranslated((double)posX, (double)posY, (double)posZ); + + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + double yaw = (player.rotationYaw/180)*Math.PI; + double pitch = (player.rotationPitch/180)*Math.PI; + + GL11.glRotated(rotation, Math.sin(yaw)*Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw)*Math.cos(pitch)); + GL11.glRotated(rotationX, 1.0,0.0,0.0); + GL11.glRotated(rotationY, 0.0,1.0,0.0); + GL11.glRotated(rotationZ, 0.0,0.0,1.0); + + tessellator.startDrawingQuads(); + tessellator.setBrightness(240); + tessellator.setColorOpaque_F(1, 1, 1); + tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); + tessellator.addVertexWithUV( - cosYaw * renderScale - sinSinPitch * renderScale, - cosPitch * renderScale, - sinYaw * renderScale - cosSinPitch * renderScale, u2, v2); + tessellator.addVertexWithUV(( - cosYaw * renderScale) + sinSinPitch * renderScale, + cosPitch * renderScale, ( - sinYaw * renderScale) + cosSinPitch * renderScale, u2, v1); + tessellator.addVertexWithUV( + cosYaw * renderScale + sinSinPitch * renderScale, + cosPitch * renderScale, + sinYaw * renderScale + cosSinPitch * renderScale, u1, v1); + tessellator.addVertexWithUV(( + cosYaw * renderScale) - sinSinPitch * renderScale, - cosPitch * renderScale, ( + sinYaw * renderScale) - cosSinPitch * renderScale, u1, v2); tessellator.draw(); - ClientProxy.bindTexture(resource); - tessellator.startDrawingQuads(); GL11.glPopMatrix(); + + GL11.glColor4f(1, 1, 1, 1.0F); + ClientProxy.bindTexture(resource); + tessellator.startDrawingQuads(); } public int getFXLayer(){ diff --git a/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java b/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java index bc7e15120..63560c784 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java @@ -18,17 +18,45 @@ public class ScriptEntityParticle { private float alpha1 = 1.0f,alpha2 = 1.0f,alphaRate = 0.0f; private int scaleRateStart = 0, alphaRateStart = 0; + public float rotation = 0; + public float rotation1 = 0; + public float rotation2 = 0; + public float rotationRate = 0.0F; + public int rotationRateStart = 0; + + public float rotationX = 0; + public float rotationX1 = 0; + public float rotationX2 = 0; + public float rotationXRate = 0.0F; + public int rotationXRateStart = 0; + + public float rotationY = 0; + public float rotationY1 = 0; + public float rotationY2 = 0; + public float rotationYRate = 0.0F; + public int rotationYRateStart = 0; + + public float rotationZ = 0; + public float rotationZ1 = 0; + public float rotationZ2 = 0; + public float rotationZRate = 0.0F; + public int rotationZRateStart = 0; + public ScriptEntityParticle(String directory){ this.directory = directory; } public void spawnOnEntity(ScriptEntity entity){ int entityID = entity.getMCEntity().getEntityId(); - NoppesUtilServer.spawnScriptedParticle(entity.getMCEntity(), directory, HEXcolor, amount, maxAge, + NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge, x, y, z, motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, alpha1, alpha2, alphaRate, alphaRateStart, + rotation1, rotation2, rotationRate, rotationRateStart, + rotationX1, rotationX2, rotationXRate, rotationXRateStart, + rotationY1, rotationY2, rotationYRate, rotationYRateStart, + rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, entityID ); } @@ -52,11 +80,9 @@ public class ScriptEntityParticle { public double getX() { return x; } - public double getY() { return y; } - public double getZ() { return z; } @@ -64,50 +90,61 @@ public class ScriptEntityParticle { public double getMotionX() { return motionX; } - public double getMotionY() { return motionY; } - public double getMotionZ() { return motionZ; } - public float getGravity() { return gravity; } - public float getScale1() { - return scale1; - } - - public float getScale2() { - return scale2; - } - - public float getScaleRate() { - return scaleRate; - } - public float getAlpha1() { return alpha1; } - public float getAlpha2() { return alpha2; } - public float getAlphaRate() { return alphaRate; } + public int getAlphaRateStart() { + return alphaRateStart; + } + public float getScale1() { + return scale1; + } + public float getScale2() { + return scale2; + } + public float getScaleRate() { + return scaleRate; + } public int getScaleRateStart() { return scaleRateStart; } - public int getAlphaRateStart() { - return alphaRateStart; - } + public float getRotation1() {return rotation1;} + public float getRotation2() {return rotation2;} + public float getRotationRate() {return rotationRate;} + public int getRotationRateStart() {return rotationRateStart;} + + public float getRotationX1() {return rotationX1;} + public float getRotationX2() {return rotationX2;} + public float getRotationXRate() {return rotationXRate;} + public int getRotationXRateStart() {return rotationXRateStart;} + + public float getRotationY1() {return rotationY1;} + public float getRotationY2() {return rotationY2;} + public float getRotationYRate() {return rotationYRate;} + public int getRotationYRateStart() {return rotationYRateStart;} + + public float getRotationZ1() {return rotationZ1;} + public float getRotationZ2() {return rotationZ2;} + public float getRotationZRate() {return rotationZRate;} + public int getRotationZRateStart() {return rotationZRateStart;} public void setDirectory(String directory) { this.directory = directory; @@ -130,15 +167,12 @@ public class ScriptEntityParticle { this.y = y; this.z = z; } - public void setX(double x) { this.x = x; } - public void setY(double y) { this.y = y; } - public void setZ(double z) { this.z = z; } @@ -149,19 +183,15 @@ public class ScriptEntityParticle { this.motionZ = motionZ; this.gravity = gravity; } - public void setMotionX(double motionX) { this.motionX = motionX; } - public void setMotionY(double motionY) { this.motionY = motionY; } - public void setMotionZ(double motionZ) { this.motionZ = motionZ; } - public void setGravity(float gravity) { this.gravity = gravity; } @@ -172,19 +202,15 @@ public class ScriptEntityParticle { this.scaleRate = scaleRate; this.scaleRateStart = scaleRateStart; } - public void setScale1(float scale1) { this.scale1 = scale1; } - public void setScale2(float scale2) { this.scale2 = scale2; } - public void setScaleRate(float scaleRate) { this.scaleRate = scaleRate; } - public void setScaleRateStart(int scaleRateStart) { this.scaleRateStart = scaleRateStart; } @@ -195,20 +221,60 @@ public class ScriptEntityParticle { this.alphaRate = alphaRate; this.alphaRateStart = alphaRateStart; } - public void setAlpha1(float alpha1) { this.alpha1 = alpha1; } - public void setAlpha2(float alpha2) { this.alpha2 = alpha2; } - public void setAlphaRate(float alphaRate) { this.alphaRate = alphaRate; } - public void setAlphaRateStart(int alphaRateStart) { this.alphaRateStart = alphaRateStart; } + + public void setRotation(float rotation1, float rotation2, float rotationRate, int rotationRateStart){ + this.rotation1 = rotation1; + this.rotation2 = rotation2; + this.rotationRate = rotationRate; + this.rotationRateStart = rotationRateStart; + } + public void setRotation1(float rotation1) {this.rotation1 = rotation1;} + public void setRotation2(float rotation2) {this.rotation2 = rotation2;} + public void setRotationRate(float rotationRate) {this.rotationRate = rotationRate;} + public void setRotationRateStart(int rotationRateStart) {this.rotationRateStart = rotationRateStart;} + + public void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart){ + this.rotationX1 = rotationX1; + this.rotationX2 = rotationX2; + this.rotationXRate = rotationXRate; + this.rotationXRateStart = rotationXRateStart; + } + public void setRotationX1(float rotationX1) {this.rotationX1 = rotationX1;} + public void setRotationX2(float rotationX2) {this.rotationX2 = rotationX2;} + public void setRotationXRate(float rotationXRate) {this.rotationXRate = rotationXRate;} + public void setRotationXRateStart(int rotationXRateStart) {this.rotationXRateStart = rotationXRateStart;} + + public void setRotationY(float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart){ + this.rotationY1 = rotationY1; + this.rotationY2 = rotationY2; + this.rotationYRate = rotationYRate; + this.rotationYRateStart = rotationYRateStart; + } + public void setRotationY1(float rotationY1) {this.rotationY1 = rotationY1;} + public void setRotationY2(float rotationY2) {this.rotationY2 = rotationY2;} + public void setRotationYRate(float rotationYRate) {this.rotationYRate = rotationYRate;} + public void setRotationYRateStart(int rotationYRateStart) {this.rotationYRateStart = rotationYRateStart;} + + public void setRotationZ(float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart){ + this.rotationZ1 = rotationZ1; + this.rotationZ2 = rotationZ2; + this.rotationZRate = rotationZRate; + this.rotationZRateStart = rotationZRateStart; + } + public void setRotationZ1(float rotationZ1) {this.rotationZ1 = rotationZ1;} + public void setRotationZ2(float rotationZ2) {this.rotationZ2 = rotationZ2;} + public void setRotationZRate(float rotationZRate) {this.rotationZRate = rotationZRate;} + public void setRotationZRateStart(int rotationZRateStart) {this.rotationZRateStart = rotationZRateStart;} } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index dab54f511..b284701f0 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -67,14 +67,22 @@ public class ScriptEntity implements IEntity { double x, double y, double z, double motionX, double motionY, double motionZ, float gravity, float scale1, float scale2, float scaleRate, int scaleRateStart, - float alpha1, float alpha2, float alphaRate, int alphaRateStart + float alpha1, float alpha2, float alphaRate, int alphaRateStart, + float rotation1, float rotation2, float rotationRate, int rotationRateStart, + float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, + float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, + float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart ) { int entityID = entity.getEntityId(); - NoppesUtilServer.spawnScriptedParticle(entity, directory, HEXcolor, amount, maxAge, + NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge, x, y, z, motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, alpha1, alpha2, alphaRate, alphaRateStart, + rotation1, rotation2, rotationRate, rotationRateStart, + rotationX1, rotationX2, rotationXRate, rotationXRateStart, + rotationY1, rotationY2, rotationYRate, rotationYRateStart, + rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, entityID ); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java b/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java index 27cdbc218..a806676d9 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java @@ -34,12 +34,36 @@ public interface IEntity { * @param alpha2 The particle's ending transparency * @param scaleRate Multiplier for the particle's transparency growth rate * @param alphaRateStart The time at which the particle begins appearing/fading + * + * @param rotation1 The particle's starting rotation angle with respect to the player's vision + * @param rotation2 The particle's final rotation angle with respect to the player's vision + * @param rotationRate The rate at which the particle rotates with respect to the player's vision + * @param rotationRateStart The time at which the particle begins rotating + + * @param rotationX1 The particle's starting rotation angle with respect to the X-axis + * @param rotationX2 The particle's final rotation angle with respect to the X-axis + * @param rotationXRate The rate at which the particle rotates with respect to the X-axis + * @param rotationXRateStart The time at which the particle begins rotating over the X-axis + + * @param rotationY1 The particle's starting rotation angle with respect to the Y-axis + * @param rotationY2 The particle's final rotation angle with respect to the Y-axis + * @param rotationYRate The rate at which the particle rotates with respect to the Y-axis + * @param rotationYRateStart The time at which the particle begins rotating over the Y-axis + + * @param rotationZ1 The particle's starting rotation angle with respect to the Z-axis + * @param rotationZ2 The particle's final rotation angle with respect to the Z-axis + * @param rotationZRate The rate at which the particle rotates with respect to the Z-axis + * @param rotationZRateStart The time at which the particle begins rotating over the Z-axis */ - public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge, - double x, double y, double z, - double motionX, double motionY, double motionZ, float gravity, - float scale1, float scale2, float scaleRate, int scaleRateStart, - float alpha1, float alpha2, float alphaRate, int alphaRateStart + void spawnParticle(String directory, int HEXcolor, int amount, int maxAge, + double x, double y, double z, + double motionX, double motionY, double motionZ, float gravity, + float scale1, float scale2, float scaleRate, int scaleRateStart, + float alpha1, float alpha2, float alphaRate, int alphaRateStart, + float rotation1, float rotation2, float rotationRate, int rotationRateStart, + float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, + float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, + float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart ); public double getYOffset(); From f1741b466089539c088ffa6c1ff7c54de8530787 Mon Sep 17 00:00:00 2001 From: luisc Date: Wed, 2 Mar 2022 19:35:24 -0600 Subject: [PATCH 14/18] Removed some unnecessary lines of OpenGL code --- src/main/java/noppes/npcs/client/fx/EntityCustomFX.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java index f432ae0bd..210d66ae8 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java +++ b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java @@ -139,10 +139,6 @@ public class EntityCustomFX extends EntityFX { tessellator.draw(); GL11.glPushMatrix(); ClientProxy.bindTexture(location); - GL11.glTexParameterf(3553, 10242, 10497.0F); - GL11.glTexParameterf(3553, 10243, 10497.0F); - GL11.glDisable(2884); - GL11.glEnable(3042); if(move){ startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTick); From 75b7c01f8799ee0d2f91d09a28b7bf64c7616a9a Mon Sep 17 00:00:00 2001 From: luisc Date: Wed, 2 Mar 2022 19:36:15 -0600 Subject: [PATCH 15/18] Removed some unnecessary fields in ScriptEntityParticle --- src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java b/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java index 63560c784..318385b6b 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java @@ -18,25 +18,21 @@ public class ScriptEntityParticle { private float alpha1 = 1.0f,alpha2 = 1.0f,alphaRate = 0.0f; private int scaleRateStart = 0, alphaRateStart = 0; - public float rotation = 0; public float rotation1 = 0; public float rotation2 = 0; public float rotationRate = 0.0F; public int rotationRateStart = 0; - public float rotationX = 0; public float rotationX1 = 0; public float rotationX2 = 0; public float rotationXRate = 0.0F; public int rotationXRateStart = 0; - public float rotationY = 0; public float rotationY1 = 0; public float rotationY2 = 0; public float rotationYRate = 0.0F; public int rotationYRateStart = 0; - public float rotationZ = 0; public float rotationZ1 = 0; public float rotationZ2 = 0; public float rotationZRate = 0.0F; From 1cb27a9e7a5278d88639821bd07868ce7e5b2f46 Mon Sep 17 00:00:00 2001 From: luisc Date: Fri, 4 Mar 2022 18:08:05 -0600 Subject: [PATCH 16/18] Implemented XYZ rotations correctly, now clearly rotate around an axis respective to the player's camera. --- .../java/noppes/npcs/NoppesUtilServer.java | 2 -- .../java/noppes/npcs/client/NoppesUtil.java | 6 ---- .../noppes/npcs/client/fx/EntityCustomFX.java | 35 ++++++------------- .../npcs/client/gui/roles/GuiNpcPuppet.java | 2 -- .../npcs/scripted/ScriptEntityParticle.java | 22 ------------ .../npcs/scripted/entity/ScriptEntity.java | 1 - 6 files changed, 10 insertions(+), 58 deletions(-) diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index 91f1fc631..44c99b19c 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -317,7 +317,6 @@ public class NoppesUtilServer { double motionX, double motionY, double motionZ, float gravity, float scale1, float scale2, float scaleRate, int scaleRateStart, float alpha1, float alpha2, float alphaRate, int alphaRateStart, - float rotation1, float rotation2, float rotationRate, int rotationRateStart, float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart, @@ -329,7 +328,6 @@ public class NoppesUtilServer { motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, alpha1, alpha2, alphaRate, alphaRateStart, - rotation1, rotation2, rotationRate, rotationRateStart, rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index a56100828..d9aee3bf3 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -98,11 +98,6 @@ public class NoppesUtil { float alphaRate = buffer.readFloat(); int alphaRateStart = buffer.readInt(); - float rotation1 = buffer.readFloat(); - float rotation2 = buffer.readFloat(); - float rotationRate = buffer.readFloat(); - int rotationRateStart = buffer.readInt(); - float rotationX1 = buffer.readFloat(); float rotationX2 = buffer.readFloat(); float rotationXRate = buffer.readFloat(); @@ -133,7 +128,6 @@ public class NoppesUtil { motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, alpha1, alpha2, alphaRate, alphaRateStart, - rotation1, rotation2, rotationRate, rotationRateStart, rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, diff --git a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java index 210d66ae8..8f8ce3861 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java +++ b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java @@ -26,12 +26,6 @@ public class EntityCustomFX extends EntityFX { public float alphaRate = 0.0F; public int alphaRateStart = 0; - public float rotation = 0; - public float rotation1 = 0; - public float rotation2 = 0; - public float rotationRate = 0.0F; - public int rotationRateStart = 0; - public float rotationX = 0; public float rotationX1 = 0; public float rotationX2 = 0; @@ -54,7 +48,6 @@ public class EntityCustomFX extends EntityFX { double motionX, double motionY, double motionZ, float gravity, float scale1, float scale2, float scaleRate, int scaleRateStart, float alpha1, float alpha2, float alphaRate, int alphaRateStart, - float rotation1, float rotation2, float rotationRate, int rotationRateStart, float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart, @@ -77,14 +70,6 @@ public class EntityCustomFX extends EntityFX { if(alpha1 > alpha2) this.alphaRate *= -1; - this.rotation1 = rotation1; - this.rotation2 = rotation2; - this.rotationRate = Math.abs(rotationRate); - this.rotationRateStart = rotationRateStart; - rotation = rotation1; - if(rotation1 > rotation2) - this.rotationRate *= -1; - this.rotationX1 = rotationX1; this.rotationX2 = rotationX2; this.rotationXRate = Math.abs(rotationXRate); @@ -158,12 +143,6 @@ public class EntityCustomFX extends EntityFX { else if(particleAge >= this.alphaRateStart) particleAlpha += alphaChange; - float rotationChange = this.rotationRate / (float)particleMaxAge; - if((this.rotationRate < 0 && rotation+rotationChange < this.rotation2) || (this.rotationRate > 0 && rotation+rotationChange > this.rotation2)) - rotation = this.rotation2; - else if(particleAge >= this.rotationRateStart) - rotation += rotationChange; - float rotationXChange = this.rotationXRate / (float)particleMaxAge; if((this.rotationXRate < 0 && rotationX+rotationXChange < this.rotationX2) || (this.rotationXRate > 0 && rotationX+rotationXChange > this.rotationX2)) rotationX = this.rotationX2; @@ -199,10 +178,16 @@ public class EntityCustomFX extends EntityFX { double yaw = (player.rotationYaw/180)*Math.PI; double pitch = (player.rotationPitch/180)*Math.PI; - GL11.glRotated(rotation, Math.sin(yaw)*Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw)*Math.cos(pitch)); - GL11.glRotated(rotationX, 1.0,0.0,0.0); - GL11.glRotated(rotationY, 0.0,1.0,0.0); - GL11.glRotated(rotationZ, 0.0,0.0,1.0); + if(Math.abs(rotationX%360) >= 90 && Math.abs(rotationX%360) < 270) { + rotationX += 180*Math.signum(rotationX); + } + if(Math.abs(rotationY%360) >= 90 && Math.abs(rotationY%360) < 270) { + rotationY += 180*Math.signum(rotationY); + } + + GL11.glRotated(rotationX, Math.cos(yaw)*Math.cos(pitch),0.0,Math.sin(yaw)*Math.cos(pitch)); + GL11.glRotated(rotationY, -Math.sin(yaw)*Math.sin(pitch), Math.cos(pitch), Math.cos(yaw)*Math.sin(pitch)); + GL11.glRotated(rotationZ, Math.sin(yaw)*Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw)*Math.cos(pitch)); tessellator.startDrawingQuads(); tessellator.setBrightness(240); diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcPuppet.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcPuppet.java index 7b04d2970..5babcd504 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcPuppet.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcPuppet.java @@ -163,8 +163,6 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener{ } if(btn.id == 170 || btn.id == 171 || btn.id == 172){ if(btn.id == 170){ - System.out.println(part.rotationX); - System.out.println(rotateX.sliderValue); part.rotationX = 0.0f; rotateX.sliderValue = 0.5f; int percent = (int) ((rotateX.sliderValue) * 360); diff --git a/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java b/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java index 318385b6b..01d913d13 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java @@ -18,11 +18,6 @@ public class ScriptEntityParticle { private float alpha1 = 1.0f,alpha2 = 1.0f,alphaRate = 0.0f; private int scaleRateStart = 0, alphaRateStart = 0; - public float rotation1 = 0; - public float rotation2 = 0; - public float rotationRate = 0.0F; - public int rotationRateStart = 0; - public float rotationX1 = 0; public float rotationX2 = 0; public float rotationXRate = 0.0F; @@ -49,7 +44,6 @@ public class ScriptEntityParticle { motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, alpha1, alpha2, alphaRate, alphaRateStart, - rotation1, rotation2, rotationRate, rotationRateStart, rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, @@ -122,11 +116,6 @@ public class ScriptEntityParticle { return scaleRateStart; } - public float getRotation1() {return rotation1;} - public float getRotation2() {return rotation2;} - public float getRotationRate() {return rotationRate;} - public int getRotationRateStart() {return rotationRateStart;} - public float getRotationX1() {return rotationX1;} public float getRotationX2() {return rotationX2;} public float getRotationXRate() {return rotationXRate;} @@ -230,17 +219,6 @@ public class ScriptEntityParticle { this.alphaRateStart = alphaRateStart; } - public void setRotation(float rotation1, float rotation2, float rotationRate, int rotationRateStart){ - this.rotation1 = rotation1; - this.rotation2 = rotation2; - this.rotationRate = rotationRate; - this.rotationRateStart = rotationRateStart; - } - public void setRotation1(float rotation1) {this.rotation1 = rotation1;} - public void setRotation2(float rotation2) {this.rotation2 = rotation2;} - public void setRotationRate(float rotationRate) {this.rotationRate = rotationRate;} - public void setRotationRateStart(int rotationRateStart) {this.rotationRateStart = rotationRateStart;} - public void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart){ this.rotationX1 = rotationX1; this.rotationX2 = rotationX2; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index b284701f0..30282fd07 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -79,7 +79,6 @@ public class ScriptEntity implements IEntity { motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, alpha1, alpha2, alphaRate, alphaRateStart, - rotation1, rotation2, rotationRate, rotationRateStart, rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, From 16321dd4ff2671db1295630ee8b024a857a0bda3 Mon Sep 17 00:00:00 2001 From: luisc Date: Sun, 6 Mar 2022 13:47:47 -0600 Subject: [PATCH 17/18] Added hasLore() function to ScriptItemStack Fixed getLore() null pointer error --- .../noppes/npcs/scripted/ScriptItemStack.java | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/main/java/noppes/npcs/scripted/ScriptItemStack.java b/src/main/java/noppes/npcs/scripted/ScriptItemStack.java index 23764c5c1..81fb082a0 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptItemStack.java +++ b/src/main/java/noppes/npcs/scripted/ScriptItemStack.java @@ -224,23 +224,33 @@ public class ScriptItemStack implements IItemStack { } public String[] getLore() { - NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display"); - if (compound != null && compound.func_150299_b("Lore") == 9) { - NBTTagList nbttaglist = compound.getTagList("Lore", 8); - if (nbttaglist.tagCount() < 1) { - return new String[0]; - } else { - List lore = new ArrayList(); + if (this.item.getTagCompound() != null) { + NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display"); + if(compound != null && compound.func_150299_b("Lore") == 9) { + NBTTagList nbttaglist = compound.getTagList("Lore", 8); + if (nbttaglist.tagCount() > 0) { + List lore = new ArrayList(); - for(int i = 0; i < nbttaglist.tagCount(); ++i) { - lore.add(nbttaglist.getStringTagAt(i)); + for (int i = 0; i < nbttaglist.tagCount(); ++i) { + lore.add(nbttaglist.getStringTagAt(i)); + } + + return (String[]) ((String[]) lore.toArray(new String[lore.size()])); } - - return (String[])((String[])lore.toArray(new String[lore.size()])); } - } else { - return new String[0]; } + return new String[0]; + } + + public boolean hasLore() { + if (this.item.getTagCompound() != null) { + NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display"); + if (compound != null && compound.func_150299_b("Lore") == 9) { + NBTTagList nbttaglist = compound.getTagList("Lore", 8); + return nbttaglist.tagCount() > 0; + } + } + return false; } public void setLore(String[] lore) { From 60e14f548eccc60fa1e89e3b9b9d4d45bf166790 Mon Sep 17 00:00:00 2001 From: luisc Date: Wed, 9 Mar 2022 00:33:55 -0600 Subject: [PATCH 18/18] Custom GUIs now only close when the ESC key is pressed. --- src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java b/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java index f94cb1461..544465490 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java +++ b/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java @@ -513,7 +513,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD } protected void keyTyped(char typedChar, int keyCode) { - if (keyCode == 1 || keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode()) + if (keyCode == 1) { this.mc.thePlayer.closeScreen(); }