From 74464417fd78c389b9d84173a7f9aeb4443ae0b6 Mon Sep 17 00:00:00 2001 From: Léa Gris Date: Sat, 23 Jul 2022 13:21:54 +0200 Subject: 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. --- .../boilers/GT_MetaTileEntity_Boiler.java | 45 +++--- .../boilers/GT_MetaTileEntity_Boiler_Bronze.java | 84 +++++------ .../boilers/GT_MetaTileEntity_Boiler_Solar.java | 6 +- .../GT_MetaTileEntity_DieselGenerator.java | 37 +++++ .../GT_MetaTileEntity_MagicalEnergyAbsorber.java | 155 ++++++++++++++------- .../machines/basic/GT_MetaTileEntity_Scanner.java | 113 ++++++++------- ...GT_MetaTileEntity_LongDistancePipelineBase.java | 82 +++++------ .../multi/GT_MetaTileEntity_AssemblyLine.java | 11 +- .../multi/GT_MetaTileEntity_Charcoal_Pit.java | 3 +- .../GT_MetaTileEntity_ImplosionCompressor.java | 59 ++++---- .../GT_MetaTileEntity_PrimitiveBlastFurnace.java | 54 ++++++- .../GT_MetaTileEntity_AlloySmelter_Bronze.java | 52 +++---- .../GT_MetaTileEntity_AlloySmelter_Steel.java | 52 +++---- .../steam/GT_MetaTileEntity_Compressor_Bronze.java | 52 +++---- .../steam/GT_MetaTileEntity_Compressor_Steel.java | 52 +++---- .../steam/GT_MetaTileEntity_Extractor_Bronze.java | 52 +++---- .../steam/GT_MetaTileEntity_Extractor_Steel.java | 52 +++---- .../GT_MetaTileEntity_ForgeHammer_Bronze.java | 121 ++++++++++++---- .../steam/GT_MetaTileEntity_ForgeHammer_Steel.java | 121 ++++++++++++---- .../steam/GT_MetaTileEntity_Furnace_Bronze.java | 54 +++---- .../steam/GT_MetaTileEntity_Furnace_Steel.java | 52 +++---- .../steam/GT_MetaTileEntity_Macerator_Bronze.java | 80 ++++++----- .../steam/GT_MetaTileEntity_Macerator_Steel.java | 70 +++++----- .../storage/GT_MetaTileEntity_Locker.java | 4 +- 24 files changed, 875 insertions(+), 588 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities') 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) - .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).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 currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + public void getWailaBody(ItemStack itemStack, List 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 sSubscribedCrystals = new ConcurrentHashMap<>(4); - private static final List sPrimalAspects = (THAUMCRAFT_LOADED) ? Aspect.getPrimalAspects() : new ArrayList(); + private static final List sPrimalAspects = (THAUMCRAFT_LOADED) ? Aspect.getPrimalAspects() : new ArrayList<>(); + private static final Map 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 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_MagicalEnergyAbsorber extends GT_MetaTileEntity_B } ItemStack tOutputStack = GT_Utility.copyAmount(1L, tStack); - if (isDisenchantableItem(tOutputStack)) { - tEU = tEU * getEfficiency() / 100; - EnchantmentHelper.setEnchantments(new HashMap<>(), tOutputStack); - } else if (isEnchantedBook(tOutputStack)) { - tOutputStack = new ItemStack(Items.book, 1); + if (tOutputStack != null) { + if (isDisenchantableItem(tOutputStack)) { + tEU = tEU * getEfficiency() / 100; + EnchantmentHelper.setEnchantments(new HashMap<>(), tOutputStack); + } else if (isEnchantedBook(tOutputStack)) { + tOutputStack = new ItemStack(Items.book, 1); + } } - // Only consume input if can store EU and push output + // Only consume input when it can store EU and push output if ((getBaseMetaTileEntity().getStoredEU() + tEU) < getBaseMetaTileEntity().getEUCapacity() - && getBaseMetaTileEntity().addStackToSlot(getOutputSlot(), tOutputStack)) { + && getBaseMetaTileEntity().addStackToSlot(getOutputSlot(), tOutputStack)) { decrStackSize(getInputSlot(), 1); } else { tEU = 0; @@ -419,11 +470,11 @@ public class GT_MetaTileEntity_MagicalEnergyAbsorber extends GT_MetaTileEntity_B if (!hasEgg()) return 0; if (!sAllowMultipleEggs) { if (sActiveSiphon != null - && sActiveSiphon != this - && sActiveSiphon.getBaseMetaTileEntity() != null - && !sActiveSiphon.getBaseMetaTileEntity().isInvalidTileEntity() - && sActiveSiphon.isChunkLoaded() - && sActiveSiphon.hasEgg()) { + && sActiveSiphon != this + && sActiveSiphon.getBaseMetaTileEntity() != null + && !sActiveSiphon.getBaseMetaTileEntity().isInvalidTileEntity() + && sActiveSiphon.isChunkLoaded() + && sActiveSiphon.hasEgg()) { getBaseMetaTileEntity().doExplosion(Integer.MAX_VALUE); } else { setActiveSiphon(this); @@ -483,9 +534,9 @@ public class GT_MetaTileEntity_MagicalEnergyAbsorber extends GT_MetaTileEntity_B // try to drain 1 of whatever aspect available in containers within RANGE for (int i = mAvailableEssentiaAspects.size() - 1; i >= 0 && tEUtoGen > 0; i--) { Aspect aspect = mAvailableEssentiaAspects.get(i); - long tAspectEU = (sAspectsEnergy.get(aspect) * getEfficiency()) / 100; + long tAspectEU = ((long) sAspectsEnergy.get(aspect) * getEfficiency()) / 100; if (tAspectEU <= tEUtoGen - && AspectSourceHelper.drainEssentia((TileEntity) getBaseMetaTileEntity(), aspect, ForgeDirection.UNKNOWN, mMagicalEnergyBB.getRange())) { + && AspectSourceHelper.drainEssentia((TileEntity) getBaseMetaTileEntity(), aspect, ForgeDirection.UNKNOWN, mMagicalEnergyBB.getRange())) { tEUtoGen -= tAspectEU; tEU += tAspectEU; } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java index 1573c951eb..4bc9a56e2f 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java @@ -1,14 +1,12 @@ package gregtech.common.tileentities.machines.basic; -import cpw.mods.fml.common.FMLCommonHandler; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; import gregtech.GT_Mod; -import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -16,7 +14,6 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachin import gregtech.api.objects.ItemData; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_AssemblyLineUtils; -import gregtech.api.util.GT_Assemblyline_Server; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; @@ -24,11 +21,13 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.common.items.behaviors.Behaviour_DataOrb; import net.minecraft.init.Items; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; +import java.util.Objects; + +import static gregtech.api.enums.GT_Values.*; import static gregtech.api.enums.Textures.BlockIcons.*; import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes; @@ -36,30 +35,30 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { public GT_MetaTileEntity_Scanner(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 1, "Scans Crops and other things.", 1, 1, "Scanner.png", "", - TextureFactory.of( - TextureFactory.of(OVERLAY_SIDE_SCANNER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_SIDE_SCANNER_ACTIVE_GLOW).glow().build()), - TextureFactory.of( - TextureFactory.of(OVERLAY_SIDE_SCANNER), - TextureFactory.builder().addIcon(OVERLAY_SIDE_SCANNER_GLOW).glow().build()), - TextureFactory.of( - TextureFactory.of(OVERLAY_FRONT_SCANNER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_SCANNER_ACTIVE_GLOW).glow().build()), - TextureFactory.of( - TextureFactory.of(OVERLAY_FRONT_SCANNER), - TextureFactory.builder().addIcon(OVERLAY_FRONT_SCANNER_GLOW).glow().build()), - TextureFactory.of( - TextureFactory.of(OVERLAY_TOP_SCANNER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_TOP_SCANNER_ACTIVE_GLOW).glow().build()), - TextureFactory.of( - TextureFactory.of(OVERLAY_TOP_SCANNER), - TextureFactory.builder().addIcon(OVERLAY_TOP_SCANNER_GLOW).glow().build()), - TextureFactory.of( - TextureFactory.of(OVERLAY_BOTTOM_SCANNER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_BOTTOM_SCANNER_ACTIVE_GLOW).glow().build()), - TextureFactory.of( - TextureFactory.of(OVERLAY_BOTTOM_SCANNER), - TextureFactory.builder().addIcon(OVERLAY_BOTTOM_SCANNER_GLOW).glow().build())); + TextureFactory.of( + TextureFactory.of(OVERLAY_SIDE_SCANNER_ACTIVE), + TextureFactory.builder().addIcon(OVERLAY_SIDE_SCANNER_ACTIVE_GLOW).glow().build()), + TextureFactory.of( + TextureFactory.of(OVERLAY_SIDE_SCANNER), + TextureFactory.builder().addIcon(OVERLAY_SIDE_SCANNER_GLOW).glow().build()), + TextureFactory.of( + TextureFactory.of(OVERLAY_FRONT_SCANNER_ACTIVE), + TextureFactory.builder().addIcon(OVERLAY_FRONT_SCANNER_ACTIVE_GLOW).glow().build()), + TextureFactory.of( + TextureFactory.of(OVERLAY_FRONT_SCANNER), + TextureFactory.builder().addIcon(OVERLAY_FRONT_SCANNER_GLOW).glow().build()), + TextureFactory.of( + TextureFactory.of(OVERLAY_TOP_SCANNER_ACTIVE), + TextureFactory.builder().addIcon(OVERLAY_TOP_SCANNER_ACTIVE_GLOW).glow().build()), + TextureFactory.of( + TextureFactory.of(OVERLAY_TOP_SCANNER), + TextureFactory.builder().addIcon(OVERLAY_TOP_SCANNER_GLOW).glow().build()), + TextureFactory.of( + TextureFactory.of(OVERLAY_BOTTOM_SCANNER_ACTIVE), + TextureFactory.builder().addIcon(OVERLAY_BOTTOM_SCANNER_ACTIVE_GLOW).glow().build()), + TextureFactory.of( + TextureFactory.of(OVERLAY_BOTTOM_SCANNER), + TextureFactory.builder().addIcon(OVERLAY_BOTTOM_SCANNER_GLOW).glow().build())); } public GT_MetaTileEntity_Scanner(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { @@ -105,7 +104,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { return 2; } } catch (Throwable e) { - if (GT_Values.D1) { + if (D1) { e.printStackTrace(GT_Log.err); } } @@ -127,6 +126,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { } aStack.stackSize -= 1; this.mOutputItems[0] = GT_Utility.copyAmount(1L, aStack); + assert this.mOutputItems[0] != null; this.mOutputItems[0].setTagCompound(tNBT); return 2; } @@ -170,6 +170,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { aStack.stackSize -= 1; this.mOutputItems[0] = GT_Utility.copyAmount(1L, getSpecialSlot()); + assert this.mOutputItems[0] != null; this.mOutputItems[0].setTagCompound(aStack.getTagCompound()); calculateOverclockedNess(30, 128); //In case recipe is too OP for that machine @@ -182,6 +183,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { aStack.stackSize -= 1; this.mOutputItems[0] = GT_Utility.copyAmount(1L, getSpecialSlot()); + assert this.mOutputItems[0] != null; this.mOutputItems[0].setTagCompound(GT_Utility.getNBTContainingShort(new NBTTagCompound(), "map_id", (short) aStack.getItemDamage())); calculateOverclockedNess(30, 128); //In case recipe is too OP for that machine @@ -195,27 +197,32 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; String sTier = ""; - if (aStack.getItem().getIdFromItem(aStack.getItem()) == GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 0).getItem().getIdFromItem(GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 0).getItem())) { - if (aStack.getItemDamage() == 0 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 0).copy().toString())) + int stackItemID = Item.getIdFromItem(aStack.getItem()); + int stackItemDamage = aStack.getItemDamage(); + if (stackItemID == Item.getIdFromItem(Objects.requireNonNull(GT_ModHandler.getModItem(MOD_ID_GC_CORE, "item.schematic", 1L, 0)).getItem())) { + if (stackItemDamage == 0 && aStack.toString().equals(Objects.requireNonNull(GT_ModHandler.getModItem(MOD_ID_GC_CORE, "item.schematic", 1L, 0)).copy().toString())) sTier = "100"; - else if (aStack.getItemDamage() == 1 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 1).copy().toString())) + else if (stackItemDamage == 1 && aStack.toString().equals(Objects.requireNonNull(GT_ModHandler.getModItem(MOD_ID_GC_CORE, "item.schematic", 1L, 1)).copy().toString())) sTier = "2"; - } else if (aStack.getItem().getIdFromItem(aStack.getItem()) == GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 0).getItem().getIdFromItem(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 0).getItem())) { - if (aStack.getItemDamage() == 0 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 0).copy().toString())) - sTier = "3"; - else if (aStack.getItemDamage() == 1 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 1).copy().toString())) - sTier = "101"; - else if (aStack.getItemDamage() == 2 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 2).copy().toString())) - sTier = "102"; - } else if (aStack.getUnlocalizedName().matches(".*\\d+.*")) - sTier = aStack.getUnlocalizedName().split("(?<=\\D)(?=\\d)")[1].substring(0, 1); - else - sTier = "1"; + } else { + if (stackItemID == Item.getIdFromItem(Objects.requireNonNull(GT_ModHandler.getModItem(MOD_ID_GC_MARS, "item.schematic", 1L, 0)).getItem())) { + if (stackItemDamage == 0 && aStack.toString().equals(Objects.requireNonNull(GT_ModHandler.getModItem(MOD_ID_GC_MARS, "item.schematic", 1L, 0)).copy().toString())) + sTier = "3"; + else if (stackItemDamage == 1 && aStack.toString().equals(Objects.requireNonNull(GT_ModHandler.getModItem(MOD_ID_GC_MARS, "item.schematic", 1L, 1)).copy().toString())) + sTier = "101"; + else if (stackItemDamage == 2 && aStack.toString().equals(Objects.requireNonNull(GT_ModHandler.getModItem(MOD_ID_GC_MARS, "item.schematic", 1L, 2)).copy().toString())) + sTier = "102"; + } else if (aStack.getUnlocalizedName().matches(".*\\d+.*")) + sTier = aStack.getUnlocalizedName().split("(?<=\\D)(?=\\d)")[1].substring(0, 1); + else + sTier = "1"; + } getSpecialSlot().stackSize -= 1; aStack.stackSize -= 1; this.mOutputItems[0] = GT_Utility.copyAmount(1L, getSpecialSlot()); + assert this.mOutputItems[0] != null; this.mOutputItems[0].setTagCompound(GT_Utility.getNBTContainingShort(new NBTTagCompound(), "rocket_tier", Short.parseShort(sTier))); calculateOverclockedNess(480, 36000); @@ -241,7 +248,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { } } - if (ItemList.Tool_DataStick.isStackEqual(getSpecialSlot(), false, true) && aStack != null) { + if (ItemList.Tool_DataStick.isStackEqual(getSpecialSlot(), false, true)) { for (GT_Recipe.GT_Recipe_AssemblyLine tRecipe : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) { if (GT_Utility.areStacksEqual(tRecipe.mResearchItem, aStack, true)) { boolean failScanner = true; @@ -254,20 +261,12 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { if (failScanner) { return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; } - - String s = tRecipe.mOutput.getDisplayName(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - s = GT_Assemblyline_Server.lServerNames.get(tRecipe.mOutput.getDisplayName()); - if (s == null) - s = tRecipe.mOutput.getDisplayName(); - } this.mOutputItems[0] = GT_Utility.copyAmount(1L, getSpecialSlot()); - // Use Assline Utils if (GT_AssemblyLineUtils.setAssemblyLineRecipeOnDataStick(this.mOutputItems[0], tRecipe)) { - aStack.stackSize -= 1; + aStack.stackSize -= 1; calculateOverclockedNess(30, tRecipe.mResearchTime); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) @@ -275,7 +274,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { getSpecialSlot().stackSize -= 1; return 2; } - + } } } @@ -314,7 +313,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { super.startSoundLoop(aIndex, aX, aY, aZ); if (aIndex == 1) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(212), 10, 1.0F, aX, aY, aZ); + GT_Utility.doSoundAtClient(SoundResource.IC2_MACHINES_MAGNETIZER_LOOP, 10, 1.0F, aX, aY, aZ); } } diff --git a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java index c349ace362..a74f8123ec 100644 --- a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java @@ -1,7 +1,7 @@ /** - * + * * Inspired/ported from GregTech 6 under the LGPL license - * + * * Copyright (c) 2020 GregTech-6 Team * * This file is part of GregTech. @@ -66,7 +66,7 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta public GT_MetaTileEntity_LongDistancePipelineBase(int aID, String aName, String aNameRegional, int aTier, String aDescription) { super(aID, aName, aNameRegional, aTier, aDescription); } - + public GT_MetaTileEntity_LongDistancePipelineBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); } @@ -99,7 +99,7 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta public boolean isSameClass(GT_MetaTileEntity_LongDistancePipelineBase other) { return false; } - + @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; @@ -112,7 +112,7 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta } return false; } - + public boolean isDead() { return getBaseMetaTileEntity() == null || getBaseMetaTileEntity().isDead(); } @@ -122,7 +122,7 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta if (gt_tile == null || !gt_tile.isAllowedToWork() || gt_tile.isClientSide()) return false; World world = gt_tile.getWorld(); if (world == null) return false; - + if (mTargetPos == null) { // We don't have a target position, scan the pipes scanPipes(); @@ -133,9 +133,9 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta // Only check if the target position is loaded TileEntity te = world.getTileEntity(mTargetPos.posX, mTargetPos.posY, mTargetPos.posZ); final IMetaTileEntity tMeta; - if (te instanceof BaseMetaTileEntity && + if (te instanceof BaseMetaTileEntity && ((tMeta = ((BaseMetaTileEntity)te).getMetaTileEntity()) instanceof GT_MetaTileEntity_LongDistancePipelineBase) && - isSameClass((GT_MetaTileEntity_LongDistancePipelineBase)tMeta)) + isSameClass((GT_MetaTileEntity_LongDistancePipelineBase)tMeta)) { // It's the right type! mTarget = (GT_MetaTileEntity_LongDistancePipelineBase)tMeta; @@ -164,54 +164,54 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta aList.addAll(Arrays.asList("Is the Target", "Sender is at: X: " + coords.posX + " Y: " + coords.posY + " Z: " + coords.posZ)); } else { aList.addAll( - Arrays.asList(checkTarget() ? "Has Target" : "Has no loaded Target", + Arrays.asList(checkTarget() ? "Has Target" : "Has no loaded Target", "Target should be around: X: " + mTargetPos.posX + " Y: " + mTargetPos.posY + " Z: " + mTargetPos.posZ )); - } + } return aList; } - + // What meta should the pipes for this pipeline have public abstract int getPipeMeta(); - + protected void scanPipes() { if (mSender != null && !mSender.isDead() && mSender.mTarget == this) return; - + // Check if we need to scan anything final IGregTechTileEntity gtTile = getBaseMetaTileEntity(); if (gtTile == null) return; - + final World world = gtTile.getWorld(); if (world == null) return; - + mTargetPos = getCoords(); mTarget = this; mSender = null; - + // Start scanning from the output side Block aBlock = gtTile.getBlockAtSide(gtTile.getBackFacing()); - + if(aBlock instanceof GT_Block_LongDistancePipe) { byte aMetaData = gtTile.getMetaIDAtSide(gtTile.getBackFacing()); if (aMetaData != getPipeMeta()) return; - + HashSet tVisited = new HashSet<>(Collections.singletonList(getCoords())), tWires = new HashSet<>(); - Queue + Queue tQueue = new LinkedList<>(Collections.singletonList(getFacingOffset(gtTile, gtTile.getBackFacing()))); while (!tQueue.isEmpty()) { final ChunkCoordinates aCoords = tQueue.poll(); - + if(world.getBlock(aCoords.posX, aCoords.posY, aCoords.posZ) == aBlock && world.getBlockMetadata(aCoords.posX, aCoords.posY, aCoords.posZ) == aMetaData) { // We've got another pipe/wire block - // TODO: Make sure it's the right type of pipe/wire via meta + // TODO: Make sure it's the right type of pipe/wire via meta ChunkCoordinates tCoords; tWires.add(aCoords); - + // For each direction, if we haven't already visisted that coordinate, add it to the end of the queue if (tVisited.add(tCoords = new ChunkCoordinates(aCoords.posX + 1, aCoords.posY, aCoords.posZ))) tQueue.add(tCoords); if (tVisited.add(tCoords = new ChunkCoordinates(aCoords.posX - 1, aCoords.posY, aCoords.posZ))) tQueue.add(tCoords); @@ -223,12 +223,12 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta // It's not a block - let's see if it's a tile entity TileEntity tTileEntity = world.getTileEntity(aCoords.posX, aCoords.posY, aCoords.posZ); if ( - tTileEntity != gtTile && tTileEntity instanceof BaseMetaTileEntity && - ((BaseMetaTileEntity)tTileEntity).getMetaTileEntity() instanceof GT_MetaTileEntity_LongDistancePipelineBase) + tTileEntity != gtTile && tTileEntity instanceof BaseMetaTileEntity && + ((BaseMetaTileEntity)tTileEntity).getMetaTileEntity() instanceof GT_MetaTileEntity_LongDistancePipelineBase) { final GT_MetaTileEntity_LongDistancePipelineBase tGtTile = (GT_MetaTileEntity_LongDistancePipelineBase)((BaseMetaTileEntity) tTileEntity).getMetaTileEntity(); if (isSameClass(tGtTile) && tWires.contains( - tGtTile.getFacingOffset((BaseMetaTileEntity)tTileEntity, ((BaseMetaTileEntity) tTileEntity).getFrontFacing()) + tGtTile.getFacingOffset((BaseMetaTileEntity)tTileEntity, ((BaseMetaTileEntity) tTileEntity).getFrontFacing()) )) { // If it's the same class, and we've scanned a wire in front of it (the input side), we've found our target // still need to check if it's distant enough @@ -244,7 +244,7 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta } } } - + // Remove this block from the visited because we might end up back here from another wire that IS connected to the // input side tVisited.remove(aCoords); @@ -252,7 +252,7 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta } } } - + } protected int getDistanceToSelf(ChunkCoordinates aCoords) { @@ -265,15 +265,15 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta return new ChunkCoordinates( gt_tile.getOffsetX(aSide, 1), gt_tile.getOffsetY(aSide, 1), gt_tile.getOffsetZ(aSide, 1) ); - + } - + public ChunkCoordinates getCoords() { final IGregTechTileEntity gt_tile = getBaseMetaTileEntity(); return new ChunkCoordinates(gt_tile.getXCoord(), gt_tile.getYCoord(), gt_tile.getZCoord()); } - @Override + @Override public void onMachineBlockUpdate() { //GT_Mod.GT_FML_LOGGER.info("You're dead to me"); mTargetPos = null; mSender = null; @@ -288,33 +288,33 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta public boolean shouldTriggerBlockUpdate() { return true; } @Override - public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { final NBTTagCompound tag = accessor.getNBTData(); final int facing = getBaseMetaTileEntity().getFrontFacing(); final int side = (byte) accessor.getSide().ordinal(); if (side == facing) - currenttip.add(GOLD + "Pipeline Input" + RESET); + currentTip.add(GOLD + "Pipeline Input" + RESET); else if (side == ForgeDirection.OPPOSITES[facing]) - currenttip.add(BLUE + "Pipeline Output" + RESET); + currentTip.add(BLUE + "Pipeline Output" + RESET); else - currenttip.add("Pipeline Side"); + currentTip.add("Pipeline Side"); if (tag.getBoolean("hasSender")) - currenttip.add("Other End of Input: " + GREEN + "distance" + RESET); + currentTip.add("Other End of Input: " + GREEN + "distance" + RESET); else if (tag.getBoolean("hasTooCloseSender")) - currenttip.add("Other End of Input: " + RED + "too close" + RESET); + currentTip.add("Other End of Input: " + RED + "too close" + RESET); else - currenttip.add("Other End of Input: " + YELLOW + "cannot found(may need to update other end)" + RESET); + currentTip.add("Other End of Input: " + YELLOW + "cannot found(may need to update other end)" + RESET); if (tag.getBoolean("hasTarget")) - currenttip.add("Other End of Output: " + GREEN + "distance" + RESET); + currentTip.add("Other End of Output: " + GREEN + "distance" + RESET); else if (tag.getBoolean("hasTooCloseTarget")) - currenttip.add("Other End of Output: " + RED + "too close" + RESET); + currentTip.add("Other End of Output: " + RED + "too close" + RESET); else - currenttip.add("Other End of Output: " + YELLOW + "cannot found" + RESET); + currentTip.add("Other End of Output: " + YELLOW + "cannot found" + RESET); - super.getWailaBody(itemStack, currenttip, accessor, config); + super.getWailaBody(itemStack, currentTip, accessor, config); } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java index fae9ff3fec..674b674b1c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -6,13 +6,19 @@ import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; +import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures; import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.*; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_MultiInput; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_AssemblyLineUtils; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; @@ -24,7 +30,6 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; -import java.util.Arrays; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAnyMeta; @@ -329,7 +334,7 @@ public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMu public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { super.startSoundLoop(aIndex, aX, aY, aZ); if (aIndex == 20) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(212), 10, 1.0F, aX, aY, aZ); + GT_Utility.doSoundAtClient(SoundResource.IC2_MACHINES_MAGNETIZER_LOOP, 10, 1.0F, aX, aY, aZ); } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java index b6c9b230a1..5f6a34832e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java @@ -2,6 +2,7 @@ package gregtech.common.tileentities.machines.multi; import gregtech.GT_Mod; import gregtech.api.GregTech_API; +import gregtech.api.enums.ParticleFX; import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.ISecondaryDescribable; import gregtech.api.interfaces.ITexture; @@ -282,7 +283,7 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_TooltipMul new WorldSpawnedEventBuilder.ParticleEventBuilder() .setMotion(0D,0.3D,0D) - .setIdentifier("largesmoke") + .setIdentifier(ParticleFX.LARGE_SMOKE) .setPosition( aBaseMetaTileEntity.getOffsetX((byte) 1, 1) + XSTR_INSTANCE.nextFloat(), aBaseMetaTileEntity.getOffsetY((byte) 1, 1), diff --git a/src/main/java/gregtech/common/t