From f03e907ac73d92bfaf5948e1cae7848675439497 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Wed, 10 Mar 2021 18:21:44 +0100 Subject: Refactor World Events World events have way to many parameters, so the code gets unreadable, this commit fixes that behavior. --- .../java/gregtech/common/entities/GT_Entity_Arrow.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/common/entities') diff --git a/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java b/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java index d655a75c99..65fe475360 100644 --- a/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java +++ b/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java @@ -4,6 +4,7 @@ import com.mojang.authlib.GameProfile; import gregtech.api.objects.ItemData; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; +import gregtech.api.util.PositionedWorldEvent; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.enchantment.Enchantment; @@ -241,9 +242,16 @@ public class GT_Entity_Arrow extends EntityArrow { } } } + PositionedWorldEvent events = new PositionedWorldEvent<>(this.worldObj); if (getIsCritical()) { + events.setThing("crit"); for (int i = 0; i < 4; i++) { - this.worldObj.spawnParticle("crit", this.posX + this.motionX * i / 4.0D, this.posY + this.motionY * i / 4.0D, this.posZ + this.motionZ * i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ); + events.setPosition( + this.posX + this.motionX * i / 4.0D, + this.posY + this.motionY * i / 4.0D, + this.posZ + this.motionZ * i / 4.0D + ); + events.spawnParticle(-this.motionX, -this.motionY + 0.2D, -this.motionZ); } } this.posX += this.motionX; @@ -266,8 +274,10 @@ public class GT_Entity_Arrow extends EntityArrow { this.rotationYaw = (this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F); float tFrictionMultiplier = 0.99F; if (isInWater()) { + events.setThing("bubble"); + events.setPosition(this.posX - this.motionX * 0.25D, this.posY - this.motionY * 0.25D, this.posZ - this.motionZ * 0.25D); for (int l = 0; l < 4; l++) { - this.worldObj.spawnParticle("bubble", this.posX - this.motionX * 0.25D, this.posY - this.motionY * 0.25D, this.posZ - this.motionZ * 0.25D, this.motionX, this.motionY, this.motionZ); + events.spawnParticle(this.motionX, this.motionY, this.motionZ); } tFrictionMultiplier = 0.8F; } -- cgit