aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/entities
diff options
context:
space:
mode:
authorbasdxz <tudurap.com@gmail.com>2021-03-12 15:50:33 +0000
committerGitHub <noreply@github.com>2021-03-12 15:50:33 +0000
commit98d83c9b27f103ed440e4136faffedfe7b36b505 (patch)
tree5d707fd0beb70f6949b67aa15d122839eb67d475 /src/main/java/gregtech/common/entities
parentf1a9f1226eb2b5f0592fdc4613f5e632c4faedad (diff)
parent9a5aa6f3f3a64c46b2a4f119f965f0c755d26cd2 (diff)
downloadGT5-Unofficial-98d83c9b27f103ed440e4136faffedfe7b36b505.tar.gz
GT5-Unofficial-98d83c9b27f103ed440e4136faffedfe7b36b505.tar.bz2
GT5-Unofficial-98d83c9b27f103ed440e4136faffedfe7b36b505.zip
Merge pull request #462 from GTNewHorizons/WorldEventWrapper
Refactor World Events
Diffstat (limited to 'src/main/java/gregtech/common/entities')
-rw-r--r--src/main/java/gregtech/common/entities/GT_Entity_Arrow.java27
1 files changed, 21 insertions, 6 deletions
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..2983a6580c 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.WorldSpawnedEventBuilder;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.Enchantment;
@@ -241,10 +242,19 @@ public class GT_Entity_Arrow extends EntityArrow {
}
}
}
+ WorldSpawnedEventBuilder.ParticleEventBuilder events = new WorldSpawnedEventBuilder.ParticleEventBuilder()
+ .setWorld(this.worldObj);
+
if (getIsCritical()) {
- 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.setIdentifier("crit")
+ .setMotion(-this.motionX, -this.motionY + 0.2D, -this.motionZ)
+ .<WorldSpawnedEventBuilder.ParticleEventBuilder>times(4, (x, i) ->
+ x.setPosition(
+ this.posX + this.motionX * i / 4.0D,
+ this.posY + this.motionY * i / 4.0D,
+ this.posZ + this.motionZ * i / 4.0D
+ ).run()
+ );
}
this.posX += this.motionX;
this.posY += this.motionY;
@@ -266,9 +276,14 @@ public class GT_Entity_Arrow extends EntityArrow {
this.rotationYaw = (this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F);
float tFrictionMultiplier = 0.99F;
if (isInWater()) {
- 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.setMotion(-this.motionX, -this.motionY + 0.2D, -this.motionZ)
+ .setIdentifier("bubble")
+ .setPosition(
+ this.posX - this.motionX * 0.25D,
+ this.posY - this.motionY * 0.25D,
+ this.posZ - this.motionZ * 0.25D
+ )
+ .times(4, Runnable::run);
tFrictionMultiplier = 0.8F;
}
if (isWet()) {