diff options
author | basdxz <tudurap.com@gmail.com> | 2021-03-12 15:50:33 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-12 15:50:33 +0000 |
commit | 98d83c9b27f103ed440e4136faffedfe7b36b505 (patch) | |
tree | 5d707fd0beb70f6949b67aa15d122839eb67d475 /src/main/java | |
parent | f1a9f1226eb2b5f0592fdc4613f5e632c4faedad (diff) | |
parent | 9a5aa6f3f3a64c46b2a4f119f965f0c755d26cd2 (diff) | |
download | GT5-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')
17 files changed, 814 insertions, 96 deletions
diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java index 47bec844ee..158b53068d 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java @@ -4,6 +4,7 @@ import cofh.api.energy.IEnergyReceiver; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.common.GT_Pollution; import ic2.api.energy.tile.IEnergySink; import net.minecraft.init.Blocks; @@ -112,7 +113,13 @@ public interface IEnergyConnected extends IColoredTileEntity, IHasWorldObjectAnd if (GregTech_API.sMachineExplosions) if (GT_Mod.gregtechproxy.mPollution) GT_Pollution.addPollution(tWorld.getChunkFromBlockCoords(tX, tZ), 100000); - tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true); + + new WorldSpawnedEventBuilder.ExplosionEffectEventBuilder() + .setStrength(tStrength) + .setSmoking(true) + .setPosition(tX + 0.5, tY + 0.5, tZ + 0.5) + .setWorld(tWorld) + .run(); } } } diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index 31ec73d04b..0716d84bd6 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java @@ -9,6 +9,7 @@ import gregtech.api.interfaces.tileentity.IColoredTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_LanguageManager; @@ -697,8 +698,14 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { int tX = getBaseMetaTileEntity().getXCoord(), tY = getBaseMetaTileEntity().getYCoord(), tZ = getBaseMetaTileEntity().getZCoord(); World tWorld = getBaseMetaTileEntity().getWorld(); tWorld.setBlock(tX, tY, tZ, Blocks.air); - if (GregTech_API.sMachineExplosions) - tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true); + if (GregTech_API.sMachineExplosions){ + new WorldSpawnedEventBuilder.ExplosionEffectEventBuilder() + .setStrength(tStrength) + .setSmoking(true) + .setPosition(tX + 0.5, tY + 0.5, tZ + 0.5) + .setWorld(tWorld) + .run(); + } } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java index e472305a36..e6c24ec4b1 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java @@ -17,6 +17,7 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.common.GT_Client; import gregtech.common.covers.GT_Cover_Drain; import gregtech.common.covers.GT_Cover_FluidRegulator; @@ -444,8 +445,22 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { super.doSound(aIndex, aX, aY, aZ); if (aIndex == 9) { GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(4), 5, 1.0F, aX, aY, aZ); - for (byte i = 0; i < 6; i++) - getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5 + XSTR_INSTANCE.nextFloat(), aY - 0.5 + XSTR_INSTANCE.nextFloat(), aZ - 0.5 + XSTR_INSTANCE.nextFloat(), ForgeDirection.getOrientation(i).offsetX / 5.0, ForgeDirection.getOrientation(i).offsetY / 5.0, ForgeDirection.getOrientation(i).offsetZ / 5.0); + + new WorldSpawnedEventBuilder.ParticleEventBuilder() + .setIdentifier("largesmoke") + .setWorld(getBaseMetaTileEntity().getWorld()) + .<WorldSpawnedEventBuilder.ParticleEventBuilder>times(6, (x, i) -> x + .setMotion( + ForgeDirection.getOrientation(i).offsetX / 5.0, + ForgeDirection.getOrientation(i).offsetY / 5.0, + ForgeDirection.getOrientation(i).offsetZ / 5.0 + ) + .setPosition( + aX - 0.5 + XSTR_INSTANCE.nextFloat(), + aY - 0.5 + XSTR_INSTANCE.nextFloat(), + aZ - 0.5 + XSTR_INSTANCE.nextFloat() + ).run() + ); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java index 23aa69213c..7fdc564b0a 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java @@ -8,6 +8,7 @@ import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; @@ -153,8 +154,22 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileE super.doSound(aIndex, aX, aY, aZ); if (aIndex == 9) { GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(4), 5, 1.0F, aX, aY, aZ); - for (int l = 0; l < 8; ++l) - getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5 + XSTR_INSTANCE.nextFloat(), aY - 0.5 + XSTR_INSTANCE.nextFloat(), aZ - 0.5 + XSTR_INSTANCE.nextFloat(), ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetX / 5.0, ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetY / 5.0, ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetZ / 5.0); + + new WorldSpawnedEventBuilder.ParticleEventBuilder() + .setIdentifier("largesmoke") + .setWorld(getBaseMetaTileEntity().getWorld()) + .setMotion( + ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetX / 5.0, + ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetY / 5.0, + ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetZ / 5.0 + ) + .<WorldSpawnedEventBuilder.ParticleEventBuilder>times(8, x -> x + .setPosition( + aX - 0.5 + XSTR_INSTANCE.nextFloat(), + aY - 0.5 + XSTR_INSTANCE.nextFloat(), + aZ - 0.5 + XSTR_INSTANCE.nextFloat() + ).run() + ); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java index 147973b183..84b9fd9d5f 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java @@ -1,11 +1,7 @@ package gregtech.api.metatileentity.implementations; import cpw.mods.fml.common.Loader; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.Textures; -import gregtech.api.enums.Tier; +import gregtech.api.enums.*; import gregtech.api.gui.GT_Container_BasicMachine; import gregtech.api.gui.GT_GUIContainer_BasicMachine; import gregtech.api.interfaces.ITexture; @@ -16,6 +12,7 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder; import ic2.core.Ic2Items; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; @@ -26,10 +23,7 @@ import net.minecraftforge.oredict.OreDictionary; import java.util.Locale; import java.util.Random; -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.GT_Values.VN; -import static gregtech.api.enums.GT_Values.W; -import static gregtech.api.enums.GT_Values.ticksBetweenSounds; +import static gregtech.api.enums.GT_Values.*; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -806,12 +800,18 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ break; case 1: if (aBaseMetaTileEntity.getFrontFacing() != 1 && aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0 && !aBaseMetaTileEntity.getOpacityAtSide((byte) 1)) { + Random tRandom = aBaseMetaTileEntity.getWorld().rand; - aBaseMetaTileEntity.getWorld().spawnParticle( - "smoke", aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F, - aBaseMetaTileEntity.getYCoord() + 0.9F + tRandom.nextFloat() * 0.2F, - aBaseMetaTileEntity.getZCoord() + 0.8F - tRandom.nextFloat() * 0.6F, 0.0D, 0.0D, 0.0D - ); + new WorldSpawnedEventBuilder.ParticleEventBuilder() + .setMotion(0.0D, 0.0D, 0.0D) + .setIdentifier("smoke") + .setPosition( + aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F, + aBaseMetaTileEntity.getYCoord() + 0.9F + tRandom.nextFloat() * 0.2F, + aBaseMetaTileEntity.getZCoord() + 0.8F - tRandom.nextFloat() * 0.6F + ) + .setWorld(aBaseMetaTileEntity.getWorld()) + .run(); } break; } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java index e651df066b..49a28d28ff 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java @@ -9,6 +9,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.common.GT_Pollution; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -140,14 +141,23 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { zSpd = aDir.offsetZ * (0.1F + 0.2F * XSTR_INSTANCE.nextFloat()); } - if (chk1) - aWorld.spawnParticle(name, xPos + ran1 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F, xSpd, ySpd, zSpd); + WorldSpawnedEventBuilder.ParticleEventBuilder events = new WorldSpawnedEventBuilder.ParticleEventBuilder() + .setIdentifier(name) + .setWorld(aWorld) + .setMotion(xSpd, ySpd, zSpd); - if (chk2) - aWorld.spawnParticle(name, xPos + ran2 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F, xSpd, ySpd, zSpd); - - if (chk3) - aWorld.spawnParticle(name, xPos + ran3 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F, xSpd, ySpd, zSpd); + if (chk1) { + events.setPosition(xPos + ran1 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F) + .run(); + } + if (chk2) { + events.setPosition(xPos + ran2 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F) + .run(); + } + if (chk3) { + events.setPosition(xPos + ran3 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F) + .run(); + } } public int calculatePollutionReduction(int aPollution) { diff --git a/src/main/java/gregtech/api/util/GT_FoodStat.java b/src/main/java/gregtech/api/util/GT_FoodStat.java index d0fe9bdbf4..3d55291398 100644 --- a/src/main/java/gregtech/api/util/GT_FoodStat.java +++ b/src/main/java/gregtech/api/util/GT_FoodStat.java @@ -68,7 +68,15 @@ public class GT_FoodStat implements IFoodStat { ItemStack tStack = GT_OreDictUnificator.get(GT_Utility.copy(mEmptyContainer)); if (tStack != null && !aPlayer.inventory.addItemStackToInventory(tStack)) aPlayer.dropPlayerItemWithRandomChoice(tStack, true); - aPlayer.worldObj.playSoundAtEntity(aPlayer, "random.burp", 0.5F, aPlayer.worldObj.rand.nextFloat() * 0.1F + 0.9F); + + new WorldSpawnedEventBuilder.SoundAtEntityEventBuilder() + .setIdentifier("random.burp") + .setVolume(0.5F) + .setPitch(aPlayer.worldObj.rand.nextFloat() * 0.1F + 0.9F) + .setEntity(aPlayer) + .setWorld(aPlayer.worldObj) + .run(); + if (!aPlayer.worldObj.isRemote) { if (mMilk) { aPlayer.curePotionEffects(new ItemStack(Items.milk_bucket, 1, 0)); @@ -79,7 +87,14 @@ public class GT_FoodStat implements IFoodStat { } } if (mExplosive) { - aPlayer.worldObj.newExplosion(aPlayer, aPlayer.posX, aPlayer.posY, aPlayer.posZ, 4, true, true); + new WorldSpawnedEventBuilder.ExplosionEffectEventBuilder() + .setSmoking(true) + .setFlaming(true) + .setStrength(4f) + .setPosition(aPlayer.posX, aPlayer.posY, aPlayer.posZ) + .setEntity(aPlayer) + .setWorld(aPlayer.worldObj) + .run(); aPlayer.attackEntityFrom(GT_DamageSources.getExplodingDamage(), Float.MAX_VALUE); } } diff --git a/src/main/java/gregtech/api/util/WorldSpawnedEventBuilder.java b/src/main/java/gregtech/api/util/WorldSpawnedEventBuilder.java new file mode 100644 index 0000000000..109a534d0d --- /dev/null +++ b/src/main/java/gregtech/api/util/WorldSpawnedEventBuilder.java @@ -0,0 +1,601 @@ +package gregtech.api.util; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +import java.util.Objects; +import java.util.function.BiConsumer; +import java.util.function.Consumer; + +@SuppressWarnings("unused") +public abstract class WorldSpawnedEventBuilder implements Runnable { + private static final String ILLEGAL_STATE_STR1 = "Position, identifier and world must be set"; + /* Variables */ + + private World world; + + /* Getters, Setters */ + + public World getWorld() { + return world; + } + + public WorldSpawnedEventBuilder setWorld(World world) { + this.world = world; + return this; + } + + /* Methodes */ + + @SuppressWarnings("unchecked") + public <U extends WorldSpawnedEventBuilder> void times(int times, Consumer<U> action) { + Objects.requireNonNull(action); + for (int i = 0; i < times; i++) { + action.accept((U) this); + } + } + + @SuppressWarnings("unchecked") + public <U extends WorldSpawnedEventBuilder> void times(int times, BiConsumer<U, Integer> action) { + Objects.requireNonNull(action); + for (int i = 0; i < times; i++) { + action.accept((U) this, i); + } + } + + /* Interfaces */ + + private interface IPositionedWorldSpawnedEvent { + Vec3 getPosition(); + IPositionedWorldSpawnedEvent setPosition(Vec3 position); + IPositionedWorldSpawnedEvent setPosition(double x, double y, double z); + } + + private interface IEntityWorldSpawnedEvent { + Entity getEntity(); + IEntityWorldSpawnedEvent setEntity(Entity entity); + } + + private interface IEntityPlayerWorldSpawnedEvent { + EntityPlayer getEntityPlayer(); + IEntityPlayerWorldSpawnedEvent setEntityPlayer(EntityPlayer entity); + } + + private interface IStringIdentifierWorldSpawnedEvent { + String getIdentifier(); + IStringIdentifierWorldSpawnedEvent setIdentifier(String identifier); + } + + private interface ISoundWorldSpawnedEvent { + float getPitch(); + float getVolume(); + ISoundWorldSpawnedEvent setPitch(float pitch); + ISoundWorldSpawnedEvent setVolume(float volume); + } + + /* Abstract Classes */ + + private abstract static class EntityWorldSpawnedEventBuilder extends WorldSpawnedEventBuilder implements IEntityWorldSpawnedEvent { + + private Entity entity; + + @Override + public Entity getEntity() { + return entity; + } + + @Override + public EntityWorldSpawnedEventBuilder setEntity(Entity entity) { + this.entity = entity; + return this; + } + } + + private abstract static class PositionedEntityWorldSpawnedEventBuilder extends EntityWorldSpawnedEventBuilder implements IPositionedWorldSpawnedEvent { + + private Vec3 position; + + @Override + public Vec3 getPosition() { + return position; + } + + @Override + public PositionedEntityWorldSpawnedEventBuilder setPosition(Vec3 position) { + this.position = position; + return this; + } + + @Override + public PositionedEntityWorldSpawnedEventBuilder setPosition(double x, double y, double z) { + this.position = Vec3.createVectorHelper(x, y, z); + return this; + } + + } + + private abstract static class PositionedWorldSpawnedEventBuilder extends WorldSpawnedEventBuilder implements IPositionedWorldSpawnedEvent { + private Vec3 position; + + public Vec3 getPosition() { + return position; + } + + public PositionedWorldSpawnedEventBuilder setPosition(Vec3 position) { + this.position = position; + return this; + } + + public PositionedWorldSpawnedEventBuilder setPosition(double x, double y, double z) { + this.position = Vec3.createVectorHelper(x, y, z); + return this; + } + } + + private abstract static class StringIdentifierPositionedWorldSpawnedEventBuilder extends PositionedWorldSpawnedEventBuilder implements IStringIdentifierWorldSpawnedEvent { + private String identifier; + + @Override + public String getIdentifier() { + return identifier; + } + + @Override + public StringIdentifierPositionedWorldSpawnedEventBuilder setIdentifier(String identifier) { + this.identifier = identifier; + return this; + } + } + + private abstract static class SoundStringIdentifierPositionedWorldSpawnedEventBuilder extends StringIdentifierPositionedWorldSpawnedEventBuilder implements ISoundWorldSpawnedEvent { + + private float pitch; + private float volume; + + @Override + public float getPitch() { + return pitch; + } + + @Override + public float getVolume() { + return volume; + } + + @Override + public SoundStringIdentifierPositionedWorldSpawnedEventBuilder setPitch(float pitch) { + this.pitch = pitch; + return this; + } + + @Override + public SoundStringIdentifierPositionedWorldSpawnedEventBuilder setVolume(float volume) { + this.volume = volume; + return this; + } + } + + /* Implementations */ + + public static final class ParticleEventBuilder extends StringIdentifierPositionedWorldSpawnedEventBuilder { + + private Vec3 motion; + + public Vec3 getMotion() { + return motion; + } + + public ParticleEventBuilder setMotion(double x, double y, double z) { + this.motion = Vec3.createVectorHelper(x, y, z); + return this; + } + + public ParticleEventBuilder setMotion(Vec3 motion) { + this.motion = motion; + return this; + } + + @Override + public ParticleEventBuilder setWorld(World world) { + return (ParticleEventBuilder) super.setWorld(world); + } + + @Override + public ParticleEventBuilder setPosition(Vec3 position) { + return (ParticleEventBuilder) super.setPosition(position); + } + + @Override + public ParticleEventBuilder setPosition(double x, double y, double z) { + return (ParticleEventBuilder) super.setPosition(x, y, z); + } + + @Override + public ParticleEventBuilder setIdentifier(String identifier) { + return (ParticleEventBuilder) super.setIdentifier(identifier); + } + + @Override + public void run() { + if (getPosition() == null || getIdentifier() == null || getMotion() == null || getWorld() == null) + throw new IllegalStateException("Position, identifier, motion and world must be set"); + + getWorld().spawnParticle( + getIdentifier(), + getPosition().xCoord, getPosition().yCoord, getPosition().zCoord, + getMotion().xCoord, getMotion().yCoord, getMotion().zCoord + ); + } + } + + public static final class SoundEffectEventBuilder extends SoundStringIdentifierPositionedWorldSpawnedEventBuilder { + + @Override + public SoundEffectEventBuilder setWorld(World world) { + return (SoundEffectEventBuilder) super.setWorld(world); + } + + @Override + public SoundEffectEventBuilder setPosition(Vec3 position) { + return (SoundEffectEventBuilder) super.setPosition(position); + } + + @Override + public SoundEffectEventBuilder setPosition(double x, double y, double z) { + return (SoundEffectEventBuilder) super.setPosition(x, y, z); + } + + @Override + public SoundEffectEventBuilder setIdentifier(String identifier) { + return (SoundEffectEventBuilder) super.setIdentifier(identifier); + } + + @Override + public SoundEffectEventBuilder setPitch(float pitch) { + return (SoundEffectEventBuilder) super.setPitch(pitch); + } + + @Override + public SoundEffectEventBuilder setVolume(float volume) { + return (SoundEffectEventBuilder) super.setVolume(volume); + } + + @Override + public void run() { + if (getPosition() == null || getIdentifier() == null || getWorld() == null) + throw new IllegalStateException(ILLEGAL_STATE_STR1); + + getWorld().playSoundEffect( + getPosition().xCoord, getPosition().yCoord, getPosition().zCoord, + getIdentifier(), + getPitch(), getVolume() + ); + } + } + + public static final class SoundEventBuilder extends SoundStringIdentifierPositionedWorldSpawnedEventBuilder { + + private boolean proximity; + + public boolean isProximity() { + return proximity; + } + + @Override + public SoundEventBuilder setWorld(World world) { + return (SoundEventBuilder) super.setWorld(world); + } + + @Override + public SoundEventBuilder setPosition(Vec3 position) { + return (SoundEventBuilder) super.setPosition(position); + } + + @Override + public SoundEventBuilder setPosition(double x, double y, double z) { + return (SoundEventBuilder) super.setPosition(x, y, z); + } + + @Override + public SoundEventBuilder setIdentifier(String identifier) { + return (SoundEventBuilder) super.setIdentifier(identifier); + } + + @Override + public SoundEventBuilder setPitch(float pitch) { + return (SoundEventBuilder) super.setPitch(pitch); + } + + @Override + public SoundEventBuilder setVolume(float volume) { + return (SoundEventBuilder) super.setVolume(volume); + } + + public SoundEventBuilder setProximity(boolean proximity) { + this.proximity = proximity; + return this; + } + + @Override + public void run() { + if (getPosition() == null || getIdentifier() == null || getWorld() == null) + throw new IllegalStateException(ILLEGAL_STATE_STR1); + + getWorld().playSound( + getPosition().xCoord, getPosition().yCoord, getPosition().zCoord, + getIdentifier(), + getPitch(), getVolume(), isProximity() + ); + } + } + + /** + * Positional Data is rounded down due to this targeting a block. + */ + public static final class RecordEffectEventBuilder extends StringIdentifierPositionedWorldSpawnedEventBuilder { + + @Override + public RecordEffectEventBuilder setWorld(World world) { + return (RecordEffectEventBuilder) super.setWorld(world); + } + + @Override + public RecordEffectEventBuilder setPosition(Vec3 position) { + return (RecordEffectEventBuilder) super.setPosition(position); + } + + @Override + public RecordEffectEventBuilder setPosition(double x, double y, double z) { + return (RecordEffectEventBuilder) super.setPosition(x, y, z); + } + + @Override + public RecordEffectEventBuilder setIdentifier(String identifier) { + return (RecordEffectEventBuilder) super.setIdentifier(identifier); + } + + @Override + public void run() { + if (getPosition() == null || getIdentifier() == null || getWorld() == null) + throw new IllegalStateException(ILLEGAL_STATE_STR1); + + getWorld().playRecord( + getIdentifier(), + (int) getPosition().xCoord,(int) getPosition().yCoord,(int) getPosition().zCoord + ); + } + } + + public static final class ExplosionEffectEventBuilder extends PositionedEntityWorldSpawnedEventBuilder { + private boolean isFlaming, isSmoking; + private float strength; + + + public float getStrength() { + return strength; + } + + public ExplosionEffectEventBuilder setStrength(float strength) { + this.strength = strength; + return this; + } + + public boolean isFlaming() { + return isFlaming; + } + + public ExplosionEffectEventBuilder setFlaming(boolean flaming) { + isFlaming = flaming; + return this; + } + + public boolean isSmoking() { + return isSmoking; + } + + public ExplosionEffectEventBuilder setSmoking(boolean smoking) { + isSmoking = smoking; + return this; + } + + @Override + public ExplosionEffectEventBuilder setWorld(World world) { + return (ExplosionEffectEventBuilder) super.setWorld(world); + } + + @Override + public ExplosionEffectEventBuilder setEntity(Entity entity) { + return (ExplosionEffectEventBuilder) super.setEntity(entity); + } + + @Override + public ExplosionEffectEventBuilder setPosition(double x, double y, double z) { + return (ExplosionEffectEventBuilder) super.setPosition(x, y, z); + } + + @Override + public void run() { + if (getPosition() == null || getWorld() == null) + throw new IllegalStateException("Position and world must be set"); + + getWorld().newExplosion(getEntity(), getPosition().xCoord, getPosition().yCoord, getPosition().zCoord, strength, isFlaming, isSmoking); + } + } + + /** + * Positional Data is rounded down due to this targeting a block. + */ + public static final class ExtinguishFireEffectEventBuilder extends PositionedWorldSpawnedEventBuilder implements IEntityPlayerWorldSpawnedEvent { + + private int side; + private EntityPlayer entityPlayer; + + public int getSide() { + return side; + } + + public ExtinguishFireEffectEventBuilder setSide(int side) { + this.side = side; + return this; + } + + @Override + public EntityPlayer getEntityPlayer() { + return entityPlayer; + } + + @Override + public ExtinguishFireEffectEventBuilder setEntityPlayer(EntityPlayer entity) { + this.entityPlayer = entity; + return this; + } + + @Override + public ExtinguishFireEffectEventBuilder setWorld(World world) { + return (ExtinguishFireEffectEventBuilder) super.setWorld(world); + } + + @Override + public ExtinguishFireEffectEventBuilder setPosition(Vec3 position) { + return (ExtinguishFireEffectEventBuilder) super.setPosition(position); + } + + @Override + public ExtinguishFireEffectEventBuilder setPosition(double x, double y, double z) { + return (ExtinguishFireEffectEventBuilder) super.setPosition(x, y, z); + } + + @Override + public void run() { + if (getEntityPlayer() == null || getPosition() == null || getWorld() == null) + throw new IllegalStateException("EntityPlayer, position and world must be set"); + + getWorld().extinguishFire(getEntityPlayer(), (int) getPosition().xCoord, (int) getPosition().yCoord, (int) getPosition().zCoord, side); + } + } + + public static final class SoundAtEntityEventBuilder extends EntityWorldSpawnedEventBuilder implements ISoundWorldSpawnedEvent, IStringIdentifierWorldSpawnedEvent { + + private float pitch; + private float volume; + private String identifier; + + @Override + public String getIdentifier() { + return identifier; + } + + @Override + public SoundAtEntityEventBuilder setIdentifier(String identifier) { + this.identifier = identifier; + return this; + } + + @Override + public float getPitch() { + return pitch; + } + + @Override + public float getVolume() { + return volume; + } + + @Override + public SoundAtEntityEventBuilder setPitch(float pitch) { + this.pitch = pitch; + return this; + } + + @Override + public SoundAtEntityEventBuilder setVolume(float volume) { + this.volume = volume; + return this; + } + + @Override + public SoundAtEntityEventBuilder setWorld(World world) { + return (SoundAtEntityEventBuilder) super.setWorld(world); + } + + @Override + public SoundAtEntityEventBuilder setEntity(Entity entity) { + return (SoundAtEntityEventBuilder) super.setEntity(entity); + } + + @Override + public void run() { + if (getWorld() == null || getIdentifier() == null || getEntity() == null) + throw new IllegalStateException("World, Identifier and entity must be set!"); + + getWorld().playSoundAtEntity(getEntity(), getIdentifier(), volume, pitch); + } + } + + public static final class SoundToNearExceptEventBuilder extends WorldSpawnedEventBuilder implements ISoundWorldSpawnedEvent, IStringIdentifierWorldSpawnedEvent, IEntityPlayerWorldSpawnedEvent { + + private float pitch; + private float volume; + private String identifier; + private EntityPlayer entityPlayer; + + @Override + public String getIdentifier() { + return identifier; + } + + @Override + public SoundToNearExceptEventBuilder setIdentifier(String identifier) { + this.identifier = identifier; + return this; + } + + @Override + public float getPitch() { + return pitch; + } + + @Override + public float getVolume() { + return volume; + } + + @Override + public SoundToNearExceptEventBuilder setPitch(float pitch) { + this.pitch = pitch; + return this; + } + + @Override + public SoundToNearExceptEventBuilder setVolume(float volume) { + this.volume = volume; + return this; + } + + @Override + public SoundToNearExceptEventBuilder setWorld(World world) { + return (SoundToNearExceptEventBuilder) super.setWorld(world); + } + + @Override + public void run() { + if (getWorld() == null || getIdentifier() == null || getEntityPlayer() == null) + throw new IllegalStateException("World, Identifier and EntityPlayer must be set!"); + + getWorld().playSoundAtEntity(getEntityPlayer(), getIdentifier(), volume, pitch); + } + + @Override + public EntityPlayer getEntityPlayer() { + return entityPlayer; + } + + @Override + public SoundToNearExceptEventBuilder setEntityPlayer(EntityPlayer entity) { + entityPlayer = entity; + return this; + } + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index e4847543ec..b820c3b53a 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -17,20 +17,10 @@ import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.ITurnable; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_PlayedSound; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; +import gregtech.api.util.*; import gregtech.common.entities.GT_Entity_Arrow; import gregtech.common.entities.GT_Entity_Arrow_Potion; -import gregtech.common.render.GT_CapeRenderer; -import gregtech.common.render.GT_FlaskRenderer; -import gregtech.common.render.GT_FluidDisplayStackRenderer; -import gregtech.common.render.GT_MetaGenerated_Item_Renderer; -import gregtech.common.render.GT_MetaGenerated_Tool_Renderer; -import gregtech.common.render.GT_PollutionRenderer; -import gregtech.common.render.GT_Renderer_Block; -import gregtech.common.render.GT_Renderer_Entity_Arrow; +import gregtech.common.render.*; import ic2.api.tile.IWrenchable; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; @@ -46,13 +36,7 @@ import net.minecraftforge.oredict.OreDictionary; import org.lwjgl.opengl.GL11; import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Scanner; +import java.util.*; // Referenced classes of package gregtech.common: // GT_Proxy @@ -648,10 +632,20 @@ public class GT_Client extends GT_Proxy tString = (new StringBuilder()).append(tString).append("wherearewenow").toString(); break; } - if (tString.startsWith("streaming.")) - aWorld.playRecord(tString.substring(10, tString.length()), (int) aX, (int) aY, (int) aZ); - else - aWorld.playSound(aX, aY, aZ, tString, 3F, tString.startsWith("note.") ? (float) Math.pow(2D, (double) (aStack.stackSize - 13) / 12D) : 1.0F, false); + if (tString.startsWith("streaming.")){ + new WorldSpawnedEventBuilder.RecordEffectEventBuilder() + .setIdentifier(tString.substring(10)) + .setPosition(aX, aY, aZ) + .run(); + } + else{ + new WorldSpawnedEventBuilder.SoundEventBuilder() + .setVolume(3f) + .setPitch(tString.startsWith("note.") ? (float) Math.pow(2D, (double) (aStack.stackSize - 13) / 12D) : 1.0F) + .setIdentifier(tString) + .setPosition(aX, aY, aZ) + .run(); + } } public static int hideValue=0; diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index e4e3592eb3..ecca0097fb 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -33,22 +33,8 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Item; import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.objects.GT_ChunkManager; -import gregtech.api.objects.GT_Fluid; -import gregtech.api.objects.GT_FluidStack; -import gregtech.api.objects.GT_UO_DimensionList; -import gregtech.api.objects.ItemData; -import gregtech.api.util.GT_CLS_Compat; -import gregtech.api.util.GT_CoverBehavior; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_RecipeRegistrator; -import gregtech.api.util.GT_Shaped_Recipe; -import gregtech.api.util.GT_Shapeless_Recipe; -import gregtech.api.util.GT_Utility; +import gregtech.api.objects.*; +import gregtech.api.util.*; import gregtech.common.entities.GT_Entity_Arrow; import gregtech.common.gui.GT_ContainerVolumetricFlask; import gregtech.common.gui.GT_GUIContainerVolumetricFlask; @@ -781,8 +767,14 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { } aEvent.bow.damageItem(1, aEvent.entityPlayer); aEvent.bow.getItem(); - aEvent.entityPlayer.worldObj.playSoundAtEntity(aEvent.entityPlayer, "random.bow", 1.0F, 0.64893958288F + tSpeed - * 0.5F); + + new WorldSpawnedEventBuilder.SoundAtEntityEventBuilder() + .setPitch(0.64893958288F + tSpeed * 0.5F) + .setVolume(1f) + .setIdentifier("random.bow") + .setEntity(aEvent.entityPlayer) + .setWorld(aEvent.entityPlayer.worldObj) + .run(); tArrowEntity.canBePickedUp = 1; if (!aEvent.entityPlayer.capabilities.isCreativeMode) { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java b/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java index 6b3b0823fb..4a63bef40f 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java @@ -11,6 +11,7 @@ import gregtech.api.items.GT_Generic_Block; import gregtech.api.objects.GT_CopiedBlockTexture; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.WorldSpawnedEventBuilder; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -255,8 +256,13 @@ public class GT_Block_Reinforced extends GT_Generic_Block { if(!world.isRemote && world.getBlockMetadata(x, y, z)==5){ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, x + 0.5F, y + 0.5F, z + 0.5F, player); world.spawnEntityInWorld(entitytntprimed); - world.playSoundAtEntity(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F); - + new WorldSpawnedEventBuilder.SoundAtEntityEventBuilder() + .setPitch(1f) + .setVolume(1f) + .setIdentifier("game.tnt.primed") + .setEntity(entitytntprimed) + .setWorld(world) + .run(); world.setBlockToAir(x, y, z); return false; } 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()) { diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Hoe.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Hoe.java index 98631581ab..8b7947ac7d 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Hoe.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Hoe.java @@ -5,6 +5,7 @@ import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -39,7 +40,13 @@ public class Behaviour_Hoe extends Behaviour_None { } Block aBlock = aWorld.getBlock(aX, aY, aZ); if ((aSide != 0) && (GT_Utility.isBlockAir(aWorld, aX, aY + 1, aZ)) && ((aBlock == Blocks.grass) || (aBlock == Blocks.dirt))) { - aWorld.playSoundEffect(aX + 0.5F, aY + 0.5F, aZ + 0.5F, Blocks.farmland.stepSound.getStepResourcePath(), (Blocks.farmland.stepSound.getVolume() + 1.0F) / 2.0F, Blocks.farmland.stepSound.getPitch() * 0.8F); + new WorldSpawnedEventBuilder.SoundEventBuilder() + .setVolume((Blocks.farmland.stepSound.getVolume() + 1.0F) / 2.0F) + .setPitch(Blocks.farmland.stepSound.getPitch() * 0.8F) + .setIdentifier(Blocks.farmland.stepSound.getStepResourcePath()) + .setPosition(aX + 0.5F, aY + 0.5F, aZ + 0.5F) + .setWorld(aWorld) + .run(); if (aWorld.isRemote) { return true; } diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java index f728d375fa..3e80c33b6d 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java @@ -8,10 +8,7 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; +import gregtech.api.util.*; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -265,10 +262,19 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa public void doSound(byte aIndex, double aX, double aY, double aZ) { if (aIndex == 1) { - GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(4), 2, 1.0F, aX, aY, aZ); - for (int l = 0; l < 8; l++) { - getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5D + XSTR_INSTANCE.nextFloat(), aY, aZ - 0.5D + XSTR_INSTANCE.nextFloat(), 0.0D, 0.0D, 0.0D); - } + GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(4), 2, 1.0F, aX, aY, aZ); + + new WorldSpawnedEventBuilder.ParticleEventBuilder() + .setIdentifier("largesmoke") + .setWorld(getBaseMetaTileEntity().getWorld()) + .setMotion(0D,0D,0D) + .<WorldSpawnedEventBuilder.ParticleEventBuilder>times(8, x -> x + .setPosition( + aX - 0.5D + XSTR_INSTANCE.nextFloat(), + aY, + aZ - 0.5D + XSTR_INSTANCE.nextFloat() + ).run() + ); } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java index 225cd24e3e..763244d5c1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java @@ -7,6 +7,7 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.common.GT_Pollution; import gregtech.common.gui.GT_Container_PrimitiveBlastFurnace; import gregtech.common.gui.GT_GUIContainer_PrimitiveBlastFurnace; @@ -177,10 +178,17 @@ public abstract class GT_MetaTileEntity_PrimitiveBlastFurnace extends MetaTileEn public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { - aBaseMetaTileEntity.getWorld().spawnParticle("largesmoke", - aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1) + XSTR_INSTANCE.nextFloat(), - aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + XSTR_INSTANCE.nextFloat(), 0.0D, 0.3D, 0.0D); + + new WorldSpawnedEventBuilder.ParticleEventBuilder() + .setMotion(0D,0.3D,0D) + .setIdentifier("largesmoke") + .setPosition( + aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1) + XSTR_INSTANCE.nextFloat(), + aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1), + aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + XSTR_INSTANCE.nextFloat() + ) + .setWorld(getBaseMetaTileEntity().getWorld()) + .run(); } if (aBaseMetaTileEntity.isServerSide()) { if (this.mUpdate-- == 0) { diff --git a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Bronze.java b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Bronze.java index 90f35edbc3..758d206755 100644 --- a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Bronze.java +++ b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Bronze.java @@ -11,6 +11,7 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -43,8 +44,17 @@ public class GT_MetaTileEntity_Macerator_Bronze extends GT_MetaTileEntity_BasicM public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPreTick(aBaseMetaTileEntity, aTick); if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { - Random tRandom = aBaseMetaTileEntity.getWorld().rand; - aBaseMetaTileEntity.getWorld().spawnParticle("smoke", aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F, aBaseMetaTileEntity.getYCoord() + 0.9F + tRandom.nextFloat() * 0.2F, aBaseMetaTileEntity.getZCoord() + 0.8F - tRandom.nextFloat() * 0.6F, 0.0D, 0.0D, 0.0D); + Random tRandom = getBaseMetaTileEntity().getWorld().rand; + new WorldSpawnedEventBuilder.ParticleEventBuilder() + .setMotion(0D,0.0D,0D) + .setIdentifier("smoke") + .setPosition( + aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F, + aBaseMetaTileEntity.getYCoord() + 0.9F + tRandom.nextFloat() * 0.2F, + aBaseMetaTileEntity.getZCoord() + 0.8F - tRandom.nextFloat() * 0.6F + ) + .setWorld(getBaseMetaTileEntity().getWorld()) + .run(); } } diff --git a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Steel.java b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Steel.java index b59f5403b4..235b341210 100644 --- a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Steel.java +++ b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Steel.java @@ -11,6 +11,7 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -43,8 +44,17 @@ public class GT_MetaTileEntity_Macerator_Steel extends GT_MetaTileEntity_BasicMa public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPreTick(aBaseMetaTileEntity, aTick); if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { - Random tRandom = aBaseMetaTileEntity.getWorld().rand; - aBaseMetaTileEntity.getWorld().spawnParticle("smoke", aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F, aBaseMetaTileEntity.getYCoord() + 0.9F + tRandom.nextFloat() * 0.2F, aBaseMetaTileEntity.getZCoord() + 0.8F - tRandom.nextFloat() * 0.6F, 0.0D, 0.0D, 0.0D); + Random tRandom = getBaseMetaTileEntity().getWorld().rand; + new WorldSpawnedEventBuilder.ParticleEventBuilder() + .setMotion(0D,0.0D,0D) + .setIdentifier("smoke") + .setPosition( + aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F, + aBaseMetaTileEntity.getYCoord() + 0.9F + tRandom.nextFloat() * 0.2F, + aBaseMetaTileEntity.getZCoord() + 0.8F - tRandom.nextFloat() * 0.6F + ) + .setWorld(getBaseMetaTileEntity().getWorld()) + .run(); } } |