diff options
| author | Léa Gris <lea.gris@noiraude.net> | 2022-07-23 13:21:54 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-23 13:21:54 +0200 |
| commit | 74464417fd78c389b9d84173a7f9aeb4443ae0b6 (patch) | |
| tree | 84170a821c75e6198801438e7d5da71df48b2beb /src/main/java/gregtech/common/tileentities | |
| parent | 4f4a5e495e5a71467fb22ae5694f508193bc5f13 (diff) | |
| download | GT5-Unofficial-74464417fd78c389b9d84173a7f9aeb4443ae0b6.tar.gz GT5-Unofficial-74464417fd78c389b9d84173a7f9aeb4443ae0b6.tar.bz2 GT5-Unofficial-74464417fd78c389b9d84173a7f9aeb4443ae0b6.zip | |
add(api/enums): particle and sound effect enumerations (#1154)
* add(api/enums): particle and sound effect enumerations
- Adds new GregTech API enumerations:
- `ParticleFX`: Enumerates known EntityFX particles.
- `SoundResource`: Enumerates known sounds with, id and ResourceLocation.
- Refactors code to use the new enumerations instead of string literals.
- Uses `ParticleFX` and `onRandomDisplayTick` to improve or implement
new particle effects for these machines:
- BBF: Adds random flames in front of the firebox.
- Steam machines: Changes pressure-exhaust particles to white vapour,
rather than dark smoke.
- Magic Energy Absorber: Adds random effect, of absorbed magical purple
particles, by the EnderDragon Egg siphon.
- Forge Hammer: Adds sparse random sparks, ejected from the main face.
Diffstat (limited to 'src/main/java/gregtech/common/tileentities')
24 files changed, 875 insertions, 588 deletions
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 96b991e767..9eebaaabc4 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 @@ -2,8 +2,10 @@ package gregtech.common.tileentities.boilers; import gregtech.GT_Mod; import gregtech.api.GregTech_API; +import gregtech.api.enums.ParticleFX; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; +import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; @@ -11,7 +13,7 @@ import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; -import gregtech.api.util.WorldSpawnedEventBuilder; +import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; import gregtech.common.GT_Pollution; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; @@ -24,6 +26,7 @@ import net.minecraftforge.fluids.IFluidHandler; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTank { + public static final byte SOUND_EVENT_LET_OFF_EXCESS_STEAM = 1; public int mTemperature = 20; public int mProcessingEnergy = 0; public int mLossTimer = 0; @@ -31,8 +34,6 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa public boolean mHadNoWater = false; private int mExcessWater = 0; - public static final byte SOUND_EVENT_LET_OFF_EXCESS_STEAM = 1; - public GT_MetaTileEntity_Boiler(int aID, String aName, String aNameRegional, String aDescription, ITexture... aTextures) { super(aID, aName, aNameRegional, 0, 4, aDescription, aTextures); } @@ -44,7 +45,7 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa public GT_MetaTileEntity_Boiler(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 4, aDescription, aTextures); } - + public GT_MetaTileEntity_Boiler(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, 4, aDescription, aTextures); } @@ -190,7 +191,8 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa } try { aNBT.setTag("mSteam", this.mSteam.writeToNBT(new NBTTagCompound())); - } catch (Throwable ignored) {} + } catch (Throwable ignored) { + } } @Override @@ -224,8 +226,7 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { pollute(aTick); - if (isNotAllowedToWork(aBaseMetaTileEntity, aTick)) - return; + if (isNotAllowedToWork(aBaseMetaTileEntity, aTick)) return; calculateCooldown(); pushSteamToInventories(aBaseMetaTileEntity); @@ -292,27 +293,23 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa return false; } - protected void onDangerousWaterLack(IGregTechTileEntity tile, long ticks) { + protected void onDangerousWaterLack(IGregTechTileEntity tile, long ignoredTicks) { tile.doExplosion(2048L); } protected final void pushSteamToSide(IGregTechTileEntity aBaseMetaTileEntity, int aSide) { IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide((byte) aSide); - if (tTileEntity == null) - return; + if (tTileEntity == null) return; FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(aSide), Math.max(1, this.mSteam.amount / 2), false); - if (tDrained == null) - return; + if (tDrained == null) return; int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(aSide).getOpposite(), tDrained, false); - if (tFilledAmount <= 0) - return; + if (tFilledAmount <= 0) return; tTileEntity.fill(ForgeDirection.getOrientation(aSide).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(aSide), tFilledAmount, true), true); } protected void pushSteamToInventories(IGregTechTileEntity aBaseMetaTileEntity) { for (int i = 1; (this.mSteam != null) && (i < 6); i++) { - if (i == aBaseMetaTileEntity.getFrontFacing()) - continue; + if (i == aBaseMetaTileEntity.getFrontFacing()) continue; pushSteamToSide(aBaseMetaTileEntity, i); } } @@ -342,19 +339,9 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa @Override public void doSound(byte aIndex, double aX, double aY, double aZ) { if (aIndex == GT_MetaTileEntity_Boiler.SOUND_EVENT_LET_OFF_EXCESS_STEAM) { - 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() - ); + GT_Utility.doSoundAtClient(SoundResource.RANDOM_FIZZ, 2, 1.0F, aX, aY, aZ); + + new ParticleEventBuilder().setIdentifier(ParticleFX.CLOUD).setWorld(getBaseMetaTileEntity().getWorld()).setMotion(0D, 0D, 0D).<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/boilers/GT_MetaTileEntity_Boiler_Bronze.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java index bdd291a83c..4b4a0299c1 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java @@ -3,6 +3,7 @@ package gregtech.common.tileentities.boilers; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; +import gregtech.api.enums.ParticleFX; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.ITexture; @@ -12,7 +13,7 @@ import gregtech.api.objects.XSTR; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; -import gregtech.api.util.WorldSpawnedEventBuilder; +import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; import gregtech.common.GT_Pollution; import gregtech.common.gui.GT_Container_Boiler; import gregtech.common.gui.GT_GUIContainer_Boiler; @@ -36,7 +37,7 @@ public class GT_MetaTileEntity_Boiler_Bronze extends GT_MetaTileEntity_Boiler { super(aID, aName, aNameRegional, new String[]{ "An early way to get Steam Power", "Produces 120L of Steam per second", - "Causes "+Integer.toString(GT_Mod.gregtechproxy.mPollutionSmallCoalBoilerPerSecond)+" Pollution per second"}); + "Causes " + GT_Mod.gregtechproxy.mPollutionSmallCoalBoilerPerSecond + " Pollution per second"}); } public GT_MetaTileEntity_Boiler_Bronze(int aID, String aName, String aNameRegional, String[] aDescription) { @@ -95,6 +96,11 @@ public class GT_MetaTileEntity_Boiler_Bronze extends GT_MetaTileEntity_Boiler { return new GT_MetaTileEntity_Boiler_Bronze(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); } + /** + * Draws random flames and smoke particles in front of active boiler + * + * @param aBaseMetaTileEntity The entity that will handle the {@link Block#randomDisplayTick} + */ @SideOnly(Side.CLIENT) @Override public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { @@ -102,47 +108,43 @@ public class GT_MetaTileEntity_Boiler_Bronze extends GT_MetaTileEntity_Boiler { final byte frontFacing = aBaseMetaTileEntity.getFrontFacing(); - final double oX = aBaseMetaTileEntity.getOffsetX(frontFacing, 1) + 0.5F; - final double oY = aBaseMetaTileEntity.getOffsetY(frontFacing, 1) + XSTR_INSTANCE.nextFloat() * 6.0F / 16.0F; - final double oZ = aBaseMetaTileEntity.getOffsetZ(frontFacing, 1) + 0.5F; - final double offset = -0.48F; - final double horizontal = XSTR_INSTANCE.nextFloat() * 0.6F - 0.3F; - - final double x, z; + if (frontFacing > 1 + && aBaseMetaTileEntity.getCoverIDAtSide(frontFacing) == 0 + && !aBaseMetaTileEntity.getOpacityAtSide(frontFacing)) { + + final double oX = aBaseMetaTileEntity.getOffsetX(frontFacing, 1) + 8D / 16D; + final double oY = aBaseMetaTileEntity.getOffsetY(frontFacing, 1); + final double oZ = aBaseMetaTileEntity.getOffsetZ(frontFacing, 1) + 8D / 16D; + final double offset = -0.48D; + final double horizontal = XSTR_INSTANCE.nextFloat() * 10D / 16D - 5D / 16D; + + final double x, y, z; + + y = oY + XSTR_INSTANCE.nextFloat() * 6D / 16D; + + if (frontFacing == ForgeDirection.WEST.ordinal()) { + x = oX - offset; + z = oZ + horizontal; + } else if (frontFacing == ForgeDirection.EAST.ordinal()) { + x = oX + offset; + z = oZ + horizontal; + } else if (frontFacing == ForgeDirection.NORTH.ordinal()) { + x = oX + horizontal; + z = oZ - offset; + } else // if (frontFacing == ForgeDirection.SOUTH.ordinal()) + { + x = oX + horizontal; + z = oZ + offset; + } - if (frontFacing == ForgeDirection.WEST.ordinal()) - { - x = (oX - offset); - z = oZ + horizontal; - } - else if (frontFacing == ForgeDirection.EAST.ordinal()) - { - x = oX + offset; - z = oZ + horizontal; + ParticleEventBuilder particleEventBuilder = + (new ParticleEventBuilder()) + .setMotion(0D, 0D, 0D) + .setPosition(x, y, z) + .setWorld(getBaseMetaTileEntity().getWorld()); + particleEventBuilder.setIdentifier(ParticleFX.SMOKE).run(); + particleEventBuilder.setIdentifier(ParticleFX.FLAME).run(); } - else if (frontFacing == ForgeDirection.NORTH.ordinal()) - { - x = oX + horizontal; - z = oZ - offset; - } - else // if (frontFacing == ForgeDirection.SOUTH.ordinal()) - { - x = oX + horizontal; - z = oZ + offset; - } - - new WorldSpawnedEventBuilder.ParticleEventBuilder() - .setMotion(0D, 0.0D, 0D) - .setIdentifier("smoke") - .setPosition(x, oY, z) - .setWorld(getBaseMetaTileEntity().getWorld()) - .run(); - new WorldSpawnedEventBuilder.ParticleEventBuilder() - .setMotion(0D, 0.0D, 0D) - .setIdentifier("flame") - .setPosition(x, oY, z) - .setWorld(getBaseMetaTileEntity().getWorld()) - .run(); } } diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java index 5aa481ecd0..caa1df1543 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java @@ -274,11 +274,11 @@ public class GT_MetaTileEntity_Boiler_Solar extends GT_MetaTileEntity_Boiler { } @Override - public void getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + public void getWailaBody(ItemStack itemStack, List<String> currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { final NBTTagCompound tag = accessor.getNBTData(); - currenttip.add(String.format((GOLD + "Solar Boiler Output: " + RESET + "%d/%d L/s"), tag.getInteger("calcificationOutput"), tag.getInteger("maxCalcificationOutput"))); + currentTip.add(String.format((GOLD + "Solar Boiler Output: " + RESET + "%d/%d L/s"), tag.getInteger("calcificationOutput"), tag.getInteger("maxCalcificationOutput"))); - super.getWailaBody(itemStack, currenttip, accessor, config); + super.getWailaBody(itemStack, currentTip, accessor, config); } @Override diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java index f025ed34ec..6a712b41f5 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java @@ -1,8 +1,11 @@ package gregtech.common.tileentities.generators; import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; import gregtech.api.GregTech_API; +import gregtech.api.enums.ParticleFX; import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.ItemList; import gregtech.api.interfaces.ITexture; @@ -14,9 +17,13 @@ import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; +import net.minecraft.block.Block; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import static gregtech.api.enums.Textures.BlockIcons.*; +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; public class GT_MetaTileEntity_DieselGenerator extends GT_MetaTileEntity_BasicGenerator { @@ -92,6 +99,36 @@ public class GT_MetaTileEntity_DieselGenerator extends GT_MetaTileEntity_BasicGe super.onPostTick(aBaseMetaTileEntity, aTick); } + /** + * Draws random smoke particles on top when active + * + * @param aBaseMetaTileEntity The entity that will handle the {@link Block#randomDisplayTick} + */ + @SideOnly(Side.CLIENT) + @Override + public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { + if (aBaseMetaTileEntity.isActive()) { + + final byte topFacing = (byte) ForgeDirection.UP.ordinal(); + + if (aBaseMetaTileEntity.getCoverIDAtSide(topFacing) == 0 + && !aBaseMetaTileEntity.getOpacityAtSide(topFacing)) { + + final double x = aBaseMetaTileEntity.getOffsetX(topFacing, 1) + 2D / 16D + + XSTR_INSTANCE.nextFloat() * 14D / 16D; + final double y = aBaseMetaTileEntity.getOffsetY(topFacing, 1) + 1D / 32D; + final double z = aBaseMetaTileEntity.getOffsetZ(topFacing, 1) + 2D / 16D + + XSTR_INSTANCE.nextFloat() * 14D / 16D; + + new ParticleEventBuilder() + .setMotion(0D, 0D, 0D) + .setPosition(x, y, z) + .setWorld(getBaseMetaTileEntity().getWorld()) + .setIdentifier(ParticleFX.SMOKE).run(); + } + } + } + @Override public ITexture[] getFront(byte aColor) { return new ITexture[]{super.getFront(aColor)[0], TextureFactory.of( diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java index 6cbc0a4cc4..4158a22b47 100644 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java +++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java @@ -2,7 +2,10 @@ package gregtech.common.tileentities.generators; import com.google.common.base.Enums; import cpw.mods.fml.common.Loader; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; +import gregtech.api.enums.ParticleFX; import gregtech.api.enums.TC_Aspects; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -14,6 +17,7 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; import net.minecraft.block.Block; import net.minecraft.block.BlockDragonEgg; import net.minecraft.enchantment.Enchantment; @@ -49,6 +53,7 @@ import static gregtech.api.enums.ConfigCategories.machineconfig; import static gregtech.api.enums.GT_Values.MOD_ID_TC; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.Textures.BlockIcons.*; +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; import static net.minecraft.util.EnumChatFormatting.GRAY; import static net.minecraft.util.EnumChatFormatting.GREEN; import static net.minecraft.util.EnumChatFormatting.LIGHT_PURPLE; @@ -64,18 +69,18 @@ public class GT_MetaTileEntity_MagicalEnergyAbsorber extends GT_MetaTileEntity_B private static final boolean THAUMCRAFT_LOADED = Loader.isModLoaded(MOD_ID_TC); private static final ConcurrentHashMap<UUID, GT_MetaTileEntity_MagicalEnergyAbsorber> sSubscribedCrystals = new ConcurrentHashMap<>(4); - private static final List<Aspect> sPrimalAspects = (THAUMCRAFT_LOADED) ? Aspect.getPrimalAspects() : new ArrayList<Aspect>(); + private static final List<Aspect> sPrimalAspects = (THAUMCRAFT_LOADED) ? Aspect.getPrimalAspects() : new ArrayList<>(); + private static final Map<Aspect, Integer> sAspectsEnergy = new HashMap<>(); private static boolean sAllowMultipleEggs = false; private static GT_MetaTileEntity_MagicalEnergyAbsorber sActiveSiphon = null; private static int sEnergyPerEndercrystal = 512; private static int sEnergyFromVis = 20; private static int sEnergyPerEssentia = 320; - private static final Map<Aspect, Integer> sAspectsEnergy = new HashMap<>(); private static int sDragonEggEnergyPerTick = 2048; private static int sCreeperEggEnergyPerTick = 512; + private final MagicalEnergyBB mMagicalEnergyBB = new MagicalEnergyBB(this, mTier, mTier + 2); private int mEfficiency; private int mMaxVisPerDrain; - private final MagicalEnergyBB mMagicalEnergyBB = new MagicalEnergyBB(this, mTier, mTier + 2); private long mNextGenerateTickRate = 1; private int mNoGenerationTicks = 0; private boolean mUsingEssentia = true; @@ -104,10 +109,11 @@ public class GT_MetaTileEntity_MagicalEnergyAbsorber extends GT_MetaTileEntity_B sEnergyFromVis = aConfig.get(machineconfig, "MagicEnergyAbsorber.EnergyPerVis", 20); sEnergyPerEssentia = aConfig.get(machineconfig, "MagicEnergyAbsorber.EnergyPerEssentia", 320); for (Aspect tAspect : Aspect.aspects.values()) { + //noinspection UnstableApiUsage sAspectsEnergy.put(tAspect, - Enums.getIfPresent(TC_Aspects.class, - tAspect.getTag().toUpperCase(Locale.ENGLISH)).or(TC_Aspects.AER).mValue - * sEnergyPerEssentia); + Enums.getIfPresent(TC_Aspects.class, + tAspect.getTag().toUpperCase(Locale.ENGLISH)).or(TC_Aspects.AER).mValue + * sEnergyPerEssentia); } } } @@ -120,7 +126,7 @@ public class GT_MetaTileEntity_MagicalEnergyAbsorber extends GT_MetaTileEntity_B public void onConfigLoad(GT_Config aConfig) { sharedConfigLoad(aConfig); mEfficiency = aConfig.get(machineconfig, "MagicEnergyAbsorber.efficiency.tier." + mTier, 100 - mTier * 10); - mMaxVisPerDrain = (int) Math.round(Math.sqrt(V[mTier] * 10000 / (sEnergyFromVis * (getEfficiency() != 0 ? getEfficiency() : 100)))); + mMaxVisPerDrain = (int) Math.round(Math.sqrt((double) (V[mTier] * 10000) / (sEnergyFromVis * (getEfficiency() != 0 ? getEfficiency() : 100)))); if (Math.pow(mMaxVisPerDrain, 2) * sEnergyFromVis * (getEfficiency() != 0 ? getEfficiency() : 100) < V[mTier]) { mMaxVisPerDrain += 1; } @@ -207,83 +213,83 @@ public class GT_MetaTileEntity_MagicalEnergyAbsorber extends GT_MetaTileEntity_B @Override public ITexture[] getFront(byte aColor) { return new ITexture[]{ - super.getFront(aColor)[0], - TextureFactory.of(MACHINE_CASING_MAGIC), - TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_GLOW).glow().build(), - OVERLAYS_ENERGY_OUT[mTier]}; + super.getFront(aColor)[0], + TextureFactory.of(MACHINE_CASING_MAGIC), + TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_GLOW).glow().build(), + OVERLAYS_ENERGY_OUT[mTier]}; } @Override public ITexture[] getBack(byte aColor) { return new ITexture[]{ - super.getBack(aColor)[0], - TextureFactory.of(MACHINE_CASING_MAGIC_FRONT), - TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_FRONT_GLOW).glow().build()}; + super.getBack(aColor)[0], + TextureFactory.of(MACHINE_CASING_MAGIC_FRONT), + TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_FRONT_GLOW).glow().build()}; } @Override public ITexture[] getBottom(byte aColor) { return new ITexture[]{ - super.getBottom(aColor)[0], - TextureFactory.of(MACHINE_CASING_MAGIC), - TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_GLOW).glow().build()}; + super.getBottom(aColor)[0], + TextureFactory.of(MACHINE_CASING_MAGIC), + TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_GLOW).glow().build()}; } @Override public ITexture[] getTop(byte aColor) { return new ITexture[]{ - super.getTop(aColor)[0], - TextureFactory.of(MACHINE_CASING_DRAGONEGG)}; + super.getTop(aColor)[0], + TextureFactory.of(MACHINE_CASING_DRAGONEGG)}; } @Override public ITexture[] getSides(byte aColor) { return new ITexture[]{ - super.getSides(aColor)[0], - TextureFactory.of(MACHINE_CASING_MAGIC), - TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_GLOW).glow().build()}; + super.getSides(aColor)[0], + TextureFactory.of(MACHINE_CASING_MAGIC), + TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_GLOW).glow().build()}; } @Override public ITexture[] getFrontActive(byte aColor) { return new ITexture[]{ - super.getFrontActive(aColor)[0], - TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), - TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW).glow().build(), - OVERLAYS_ENERGY_OUT[mTier]}; + super.getFrontActive(aColor)[0], + TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), + TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW).glow().build(), + OVERLAYS_ENERGY_OUT[mTier]}; } @Override public ITexture[] getBackActive(byte aColor) { return new ITexture[]{ - super.getBackActive(aColor)[0], - TextureFactory.of(MACHINE_CASING_MAGIC_FRONT_ACTIVE), - TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_FRONT_ACTIVE_GLOW).glow().build()}; + super.getBackActive(aColor)[0], + TextureFactory.of(MACHINE_CASING_MAGIC_FRONT_ACTIVE), + TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_FRONT_ACTIVE_GLOW).glow().build()}; } @Override public ITexture[] getBottomActive(byte aColor) { return new ITexture[]{ - super.getBottomActive(aColor)[0], - TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), - TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW).glow().build()}; + super.getBottomActive(aColor)[0], + TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), + TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW).glow().build()}; } @Override public ITexture[] getTopActive(byte aColor) { return new ITexture[]{ - super.getTopActive(aColor)[0], - TextureFactory.of(MACHINE_CASING_DRAGONEGG), - TextureFactory.builder().addIcon(MACHINE_CASING_DRAGONEGG_GLOW).glow().build() + super.getTopActive(aColor)[0], + TextureFactory.of(MACHINE_CASING_DRAGONEGG), + TextureFactory.builder().addIcon(MACHINE_CASING_DRAGONEGG_GLOW).glow().build() }; } @Override public ITexture[] getSidesActive(byte aColor) { return new ITexture[]{ - super.getSidesActive(aColor)[0], - TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), - TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW).glow().build()}; + super.getSidesActive(aColor)[0], + TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), + TextureFactory.builder().addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW).glow().build()}; } @Override @@ -329,6 +335,49 @@ public class GT_MetaTileEntity_MagicalEnergyAbsorber extends GT_MetaTileEntity_B } } + /** + * Draws random portal particles on top when active with an egg on top + * + * @param aBaseMetaTileEntity The entity that will handle the {@link Block#randomDisplayTick} + */ + @SideOnly(Side.CLIENT) + @Override + public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { + + if (aBaseMetaTileEntity.isActive()) { + + final byte topFacing = (byte) ForgeDirection.UP.ordinal(); + + if (isEgg(aBaseMetaTileEntity.getBlockAtSide(topFacing))) { + + final double oX = aBaseMetaTileEntity.getXCoord() + 8D / 16D; + final double oY = aBaseMetaTileEntity.getYCoord() + 17D / 32D; + final double oZ = aBaseMetaTileEntity.getZCoord() + 8D / 16D; + + final ParticleEventBuilder particleEventBuilder = new ParticleEventBuilder() + .setWorld(getBaseMetaTileEntity().getWorld()) + .setIdentifier(ParticleFX.PORTAL); + + for (int i = 0; i < 9; i++) { + final double dX = (XSTR_INSTANCE.nextFloat() - 0.5D) / 2D; + final double dY = XSTR_INSTANCE.nextFloat() * 1.5; + final double dZ = (XSTR_INSTANCE.nextFloat() - 0.5D) / 2D; + + final double x = oX + dX; + final double y = oY + dY; + final double z = oZ + dZ; + + final double mX = dX * 4D; + final double dXZ = Math.sqrt(dX * dX + dZ * dZ); + final double mY = -(dXZ * dY) / 4D; + final double mZ = dZ * 4D; + + particleEventBuilder.setMotion(mX, mY, mZ).setPosition(x, y, z).run(); + } + } + } + } + @Override public int getPollution() { return 0; @@ -393,16 +442,18 @@ public class GT_MetaTileEntity_MagicalEnergyAbsorbe |
