diff options
author | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2021-03-10 18:21:44 +0100 |
---|---|---|
committer | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2021-03-10 18:21:44 +0100 |
commit | f03e907ac73d92bfaf5948e1cae7848675439497 (patch) | |
tree | 194d69bd2c9e62813da4c74e49ba7ab968c79bc6 /src | |
parent | 2d7fe3783011c605a90cf48c04bb575e0e75a72b (diff) | |
download | GT5-Unofficial-f03e907ac73d92bfaf5948e1cae7848675439497.tar.gz GT5-Unofficial-f03e907ac73d92bfaf5948e1cae7848675439497.tar.bz2 GT5-Unofficial-f03e907ac73d92bfaf5948e1cae7848675439497.zip |
Refactor World Events
World events have way to many parameters, so the code gets unreadable, this commit fixes that behavior.
Diffstat (limited to 'src')
17 files changed, 288 insertions, 88 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..66b0e5b27c 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java @@ -3,9 +3,11 @@ package gregtech.api.interfaces.tileentity; import cofh.api.energy.IEnergyReceiver; import gregtech.GT_Mod; import gregtech.api.GregTech_API; +import gregtech.api.util.PositionedWorldEvent; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Pollution; import ic2.api.energy.tile.IEnergySink; +import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -112,7 +114,10 @@ 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); + + PositionedWorldEvent<Entity> event = new PositionedWorldEvent<>(tWorld); + event.setPosition(tX + 0.5, tY + 0.5, tZ + 0.5); + event.createExplosion(tStrength, true); } } } diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index 31ec73d04b..8fc06b3dc4 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.PositionedWorldEvent; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_LanguageManager; @@ -697,8 +698,11 @@ 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){ + PositionedWorldEvent<Entity> event = new PositionedWorldEvent<>(tWorld); + event.setPosition(tX + 0.5, tY + 0.5, tZ + 0.5); + event.createExplosion(tStrength, true); + } } @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..dd207a1b39 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.PositionedWorldEvent; import gregtech.common.GT_Client; import gregtech.common.covers.GT_Cover_Drain; import gregtech.common.covers.GT_Cover_FluidRegulator; @@ -444,8 +445,20 @@ 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); + PositionedWorldEvent<String> events = new PositionedWorldEvent<>(getBaseMetaTileEntity().getWorld(), "largesmoke"); + + for (int i = 0; i < 6; i++){ + events.setPosition( + aX - 0.5 + XSTR_INSTANCE.nextFloat(), + aY - 0.5 + XSTR_INSTANCE.nextFloat(), + aZ - 0.5 + XSTR_INSTANCE.nextFloat() + ); + events.spawnParticle( + ForgeDirection.getOrientation(i).offsetX / 5.0, + ForgeDirection.getOrientation(i).offsetY / 5.0, + ForgeDirection.getOrientation(i).offsetZ / 5.0 + ); + } } } 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..50b942d294 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.PositionedWorldEvent; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; @@ -153,8 +154,20 @@ 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); + PositionedWorldEvent<String> events = new PositionedWorldEvent<>(getBaseMetaTileEntity().getWorld(), "largesmoke"); + + for (int i = 0; i < 8; i++){ + events.setPosition( + aX - 0.5 + XSTR_INSTANCE.nextFloat(), + aY - 0.5 + XSTR_INSTANCE.nextFloat(), + aZ - 0.5 + XSTR_INSTANCE.nextFloat() + ); + events.spawnParticle( + ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetX / 5.0, + ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetY / 5.0, + ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetZ / 5.0 + ); + } } } 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..759c6c4c02 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.PositionedWorldEvent; 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,15 @@ 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 + PositionedWorldEvent<String> events = new PositionedWorldEvent<>(aBaseMetaTileEntity.getWorld(), "smoke"); + Random tRandom = events.getWorld().rand; + + events.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 ); + events.spawnParticle(0.0D, 0.0D, 0.0D); } 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..d8b1655b43 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.PositionedWorldEvent; import gregtech.common.GT_Pollution; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -140,14 +141,20 @@ 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); + PositionedWorldEvent<String> events = new PositionedWorldEvent<>(aWorld, name); - 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); + events.spawnParticle(xSpd, ySpd, zSpd); + } + if (chk2) { + events.setPosition(xPos + ran2 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F); + events.spawnParticle(xSpd, ySpd, zSpd); + } + if (chk3) { + events.setPosition(xPos + ran3 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F); + events.spawnParticle(xSpd, ySpd, zSpd); + } } 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..da3b220845 100644 --- a/src/main/java/gregtech/api/util/GT_FoodStat.java +++ b/src/main/java/gregtech/api/util/GT_FoodStat.java @@ -68,7 +68,8 @@ 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); + PositionedWorldEvent<Object> event = new PositionedWorldEvent<>(aPlayer.worldObj, "random.burp"); + event.playSoundAtEntity(aPlayer,0.5F, aPlayer.worldObj.rand.nextFloat() * 0.1F + 0.9F); if (!aPlayer.worldObj.isRemote) { if (mMilk) { aPlayer.curePotionEffects(new ItemStack(Items.milk_bucket, 1, 0)); @@ -79,7 +80,9 @@ public class GT_FoodStat implements IFoodStat { } } if (mExplosive) { - aPlayer.worldObj.newExplosion(aPlayer, aPlayer.posX, aPlayer.posY, aPlayer.posZ, 4, true, true); + event.setThing(aPlayer); + event.setPosition(aPlayer.posX, aPlayer.posY, aPlayer.posZ); + event.newExplosion(4,true, true); aPlayer.attackEntityFrom(GT_DamageSources.getExplodingDamage(), Float.MAX_VALUE); } } diff --git a/src/main/java/gregtech/api/util/PositionedWorldEvent.java b/src/main/java/gregtech/api/util/PositionedWorldEvent.java new file mode 100644 index 0000000000..ce5543b320 --- /dev/null +++ b/src/main/java/gregtech/api/util/PositionedWorldEvent.java @@ -0,0 +1,144 @@ +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; + +@SuppressWarnings("unused") +public class PositionedWorldEvent<T> { + + public PositionedWorldEvent() {} + + public PositionedWorldEvent(World world) { + this.world = world; + } + + public PositionedWorldEvent(Vec3 position) { + this.position = position; + } + + public PositionedWorldEvent(T thing) { + this.thing = thing; + } + + public PositionedWorldEvent(World world, T thing) { + this(world); + this.thing = thing; + } + + public PositionedWorldEvent(World world, Vec3 position) { + this(world); + this.position = position; + } + + public PositionedWorldEvent(Vec3 position, T thing) { + this(position); + this.thing = thing; + } + + public PositionedWorldEvent(T thing, Vec3 position) { + this(position, thing); + } + + public PositionedWorldEvent(World world, Vec3 position, T thing) { + this(world, position); + this.thing = thing; + } + + public PositionedWorldEvent(World world, T thing, Vec3 position) { + this(world, position, thing); + } + + private World world; + private Vec3 position; + private T thing; + + public World getWorld() { + return world; + } + + public void setWorld(World world) { + this.world = world; + } + + public Vec3 getPosition() { + return position; + } + + public void setPosition(Vec3 position) { + this.position = position; + } + + public void setPosition(double x, double y, double z) { + this.position = Vec3.createVectorHelper(x, y, z); + } + + public T getThing() { + return thing; + } + + public void setThing(T thing) { + this.thing = thing; + } + + public void spawnParticle(double motionX, double motionY, double motionZ) { + if (position == null || !(thing instanceof String) || world == null) + return; + + world.spawnParticle((String) thing, position.xCoord, position.yCoord, position.zCoord, motionX, motionY, motionZ); + } + + public void playSoundEffect(float volume, float pitch) { + if (position == null || !(thing instanceof String) || world == null) + return; + + world.playSoundEffect(position.xCoord, position.yCoord, position.zCoord, (String) thing, volume, pitch); + } + + public void playRecord() { + if (position == null || !(thing instanceof String) || world == null) + return; + + world.playRecord((String) thing, (int) position.xCoord, (int) position.yCoord, (int) position.zCoord); + } + + public void playSound(float volume, float pitch, boolean proximity) { + if (position == null || !(thing instanceof String) || world == null) + return; + + world.playSound(position.xCoord, position.yCoord, position.zCoord, (String) thing, volume, pitch, proximity); + } + + public void createExplosion(float strength, boolean isSmoking) { + newExplosion(strength, false, isSmoking); + } + + public void newExplosion(float strength, boolean isFlaming, boolean isSmoking) { + if (position == null || world == null) + return; + + world.newExplosion((Entity) thing, position.xCoord, position.yCoord, position.zCoord, strength, isFlaming, isSmoking); + } + + public boolean extinguishFire(int side) { + if (position == null || world == null) + return false; + + return world.extinguishFire((EntityPlayer) thing, (int) position.xCoord, (int) position.yCoord, (int) position.zCoord, side); + } + + public void playSoundAtEntity(Entity entity, float volume, float pitch) { + if (!(thing instanceof String)) { + return; + } + world.playSoundAtEntity(entity, (String) thing, volume, pitch); + } + + public void playSoundToNearExcept(EntityPlayer player, float volume, float pitch) { + if (!(thing instanceof String)) { + return; + } + world.playSoundToNearExcept(player, (String) thing, volume, pitch); + } +}
\ 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..13c9a22a97 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); + PositionedWorldEvent<String> events = new PositionedWorldEvent<>(aWorld); + events.setPosition(aX, aY, aZ); + if (tString.startsWith("streaming.")){ + events.setThing(tString.substring(10)); + events.playRecord(); + } + else{ + events.setThing(tString); + events.playSound( + 3F, + tString.startsWith("note.") ? (float) Math.pow(2D, (double) (aStack.stackSize - 13) / 12D) : 1.0F, + false + ); + } } 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..e34ae1cada 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,9 @@ 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); + + PositionedWorldEvent<String> events = new PositionedWorldEvent<>(aEvent.entityPlayer.worldObj, "random.bow"); + events.playSoundAtEntity(aEvent.entityPlayer, 1.0F, 0.64893958288F + tSpeed * 0.5F); 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..aca5963c8a 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.PositionedWorldEvent; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -255,8 +256,9 @@ 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); - + PositionedWorldEvent<String> events = new PositionedWorldEvent<>(world, "game.tnt.primed"); + events.playSoundAtEntity(entitytntprimed, 1.0F, 1.0F); + 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..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<String> 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; } 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..149c9b9a82 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.PositionedWorldEvent; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -39,7 +40,9 @@ 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); + PositionedWorldEvent<String> events = new PositionedWorldEvent<>(aWorld, Blocks.farmland.stepSound.getStepResourcePath()); + events.setPosition(aX + 0.5F, aY + 0.5F, aZ + 0.5F); + events.playSoundEffect((Blocks.farmland.stepSound.getVolume() + 1.0F) / 2.0F, Blocks.farmland.stepSound.getPitch() * 0.8F); 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..7e564545f1 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,9 +262,16 @@ 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); + GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(4), 2, 1.0F, aX, aY, aZ); + PositionedWorldEvent<String> events = new PositionedWorldEvent<>(getBaseMetaTileEntity().getWorld(), "largesmoke"); + 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); + events.setPosition( + aX - 0.5D + XSTR_INSTANCE.nextFloat(), + aY, + aZ - 0.5D + XSTR_INSTANCE.nextFloat() + ); + events.spawnParticle(0.0D, 0.0D, 0.0D); } } } 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..b29bd73bd1 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.PositionedWorldEvent; import gregtech.common.GT_Pollution; import gregtech.common.gui.GT_Container_PrimitiveBlastFurnace; import gregtech.common.gui.GT_GUIContainer_PrimitiveBlastFurnace; @@ -16,6 +17,7 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.Vec3; import net.minecraft.world.ChunkPosition; import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.input.Keyboard; @@ -177,10 +179,16 @@ public abstract class GT_MetaTileEntity_PrimitiveBlastFurnace extends MetaTileEn public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { - aBaseMetaTileEntity.getWorld().spawnParticle("largesmoke", + + Vec3 position = Vec3.createVectorHelper( 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); + aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + XSTR_INSTANCE.nextFloat() + ); + + PositionedWorldEvent<String> events = new PositionedWorldEvent<>(aBaseMetaTileEntity.getWorld(), position,"largesmoke"); + + events.spawnParticle(0.0D, 0.3D, 0.0D); } 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..3f77245887 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.PositionedWorldEvent; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -43,8 +44,10 @@ 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); + PositionedWorldEvent<String> events = new PositionedWorldEvent<>(getBaseMetaTileEntity().getWorld(), "smoke"); + Random tRandom = events.getWorld().rand; + events.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); + events.spawnParticle(0.0D, 0.0D, 0.0D); } } 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..a5a0286c03 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.PositionedWorldEvent; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -43,8 +44,10 @@ 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); + PositionedWorldEvent<String> events = new PositionedWorldEvent<>(getBaseMetaTileEntity().getWorld(), "smoke"); + Random tRandom = events.getWorld().rand; + events.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); + events.spawnParticle(0.0D, 0.0D, 0.0D); } } |