diff options
Diffstat (limited to 'src/main/java/gregtech/api')
25 files changed, 1061 insertions, 455 deletions
diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index cb56c52c67..0a99ea776c 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -7,6 +7,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; import gregtech.api.enums.Materials; +import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IDamagableItem; import gregtech.api.interfaces.ITexture; @@ -169,8 +170,10 @@ public class GregTech_API { public static final Map<String, ItemStack> sBookList = new ConcurrentHashMap<>(); /** * The List of all Sounds used in GT, indices are in the static Block at the bottom + * @deprecated Use {@link SoundResource} */ - public static final Map<Integer, String> sSoundList = new ConcurrentHashMap<>(); + @Deprecated + public static final Map<Integer, String> sSoundList = SoundResource.asSoundList(); /** * The List of Tools, which can be used. Accepts regular damageable Items and Electric Items */ @@ -375,39 +378,6 @@ public class GregTech_API { //sDimensionalList.add(56); //sDimensionalList.add(55); - - sSoundList.put(0, "random.break"); - sSoundList.put(1, "random.anvil_use"); - sSoundList.put(2, "random.anvil_break"); - sSoundList.put(3, "random.click"); - sSoundList.put(4, "random.fizz"); - sSoundList.put(5, "random.explode"); - sSoundList.put(6, "fire.ignite"); - - sSoundList.put(100, aTextIC2Lower + ":" + "tools.Wrench"); - sSoundList.put(101, aTextIC2Lower + ":" + "tools.RubberTrampoline"); - sSoundList.put(102, aTextIC2Lower + ":" + "tools.Painter"); - sSoundList.put(103, aTextIC2Lower + ":" + "tools.BatteryUse"); - sSoundList.put(104, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseOne"); - sSoundList.put(105, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseTwo"); - sSoundList.put(106, aTextIC2Lower + ":" + "tools.drill.DrillSoft"); - sSoundList.put(107, aTextIC2Lower + ":" + "tools.drill.DrillHard"); - sSoundList.put(108, aTextIC2Lower + ":" + "tools.ODScanner"); - sSoundList.put(109, aTextIC2Lower + ":" + "tools.InsulationCutters"); - - sSoundList.put(200, aTextIC2Lower + ":" + "machines.ExtractorOp"); - sSoundList.put(201, aTextIC2Lower + ":" + "machines.MaceratorOp"); - sSoundList.put(202, aTextIC2Lower + ":" + "machines.InductionLoop"); - sSoundList.put(203, aTextIC2Lower + ":" + "machines.CompressorOp"); - sSoundList.put(204, aTextIC2Lower + ":" + "machines.RecyclerOp"); - sSoundList.put(205, aTextIC2Lower + ":" + "machines.MinerOp"); - sSoundList.put(206, aTextIC2Lower + ":" + "machines.PumpOp"); - sSoundList.put(207, aTextIC2Lower + ":" + "machines.ElectroFurnaceLoop"); - sSoundList.put(208, aTextIC2Lower + ":" + "machines.InductionLoop"); - sSoundList.put(209, aTextIC2Lower + ":" + "machines.MachineOverload"); - sSoundList.put(210, aTextIC2Lower + ":" + "machines.InterruptOne"); - sSoundList.put(211, aTextIC2Lower + ":" + "machines.KaChing"); - sSoundList.put(212, aTextIC2Lower + ":" + "machines.MagnetizerLoop"); } /** diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java index fde3e77d4a..f5197ef502 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -952,6 +952,9 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { */ //Superconductor re-routed for mod compability. Circuits are re-routed into SuperconductorUHV aswell, internal name is now Superconductor while translated name is SuperconductorUHV + /** + * @deprecated Use {@link #SuperconductorUHV} instead + */ @Deprecated public static Materials Superconductor = new Materials(SuperconductorUHV, true);// new Materials( -1, TextureSet.SET_NONE , 1.0F, 0, 0, 0 , 255, 255, 255, 0, "Superconductor" , "Superconductor" , 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 9))); @Deprecated diff --git a/src/main/java/gregtech/api/enums/ParticleFX.java b/src/main/java/gregtech/api/enums/ParticleFX.java new file mode 100644 index 0000000000..a20c7a16e3 --- /dev/null +++ b/src/main/java/gregtech/api/enums/ParticleFX.java @@ -0,0 +1,53 @@ +package gregtech.api.enums; + +/** + * Enumerate known EntityFX particles + */ +public enum ParticleFX { + HUGE_EXPLOSION("hugeexplosion"), + LARGE_EXPLODE("largeexplode"), + FIREWORKS_SPARK("fireworksSpark"), + BUBBLE("bubble"), + SUSPENDED("suspended"), + DEPTH_SUSPEND("depthsuspend"), + TOWN_AURA("townaura"), + CRIT("crit"), + MAGIC_CRIT("magicCrit"), + SMOKE("smoke"), + MOB_SPELL("mobSpell"), + MOB_SPELL_AMBIENT("mobSpellAmbient"), + SPELL("spell"), + INSTANT_SPELL("instantSpell"), + WITCH_MAGIC("witchMagic"), + NOTE("note"), + PORTAL("portal"), + ENCHANTMENT_TABLE("enchantmenttable"), + EXPLODE("explode"), + FLAME("flame"), + LAVA("lava"), + FOOTSTEP("footstep"), + SPLASH("splash"), + WAKE("wake"), + LARGE_SMOKE("largesmoke"), + CLOUD("cloud"), + RED_DUST("reddust"), + SNOWBALL_POOF("snowballpoof"), + DRIP_WATER("dripWater"), + DRIP_LAVA("dripLava"), + SNOW_SHOVEL("snowshovel"), + SLIME("slime"), + HEART("heart"), + ANGRY_VILLAGER("angryVillager"), + HAPPY_VILLAGER("happyVillager"); + + private final String identifier; + + ParticleFX(String name) { + this.identifier = name; + } + + public String toString() { + return this.identifier; + } +} + diff --git a/src/main/java/gregtech/api/enums/SoundResource.java b/src/main/java/gregtech/api/enums/SoundResource.java new file mode 100644 index 0000000000..2994f03d2a --- /dev/null +++ b/src/main/java/gregtech/api/enums/SoundResource.java @@ -0,0 +1,361 @@ +package gregtech.api.enums; + +import com.google.common.collect.Maps; +import net.minecraft.util.ResourceLocation; + +import java.util.EnumSet; +import java.util.Locale; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import static gregtech.api.enums.GT_Values.MOD_ID_IC2; + +/** + * Enumerate known sounds with id and resource-location + * + * <p>Note that the id serve no specific purpose, if for legacy compatibility of + * a plausible yet unimplemented network packet weight optimization.</p> + */ +public enum SoundResource { + + RANDOM_BREAK(0, "random.break"), + RANDOM_ANVIL_USE(1, "random.anvil_use"), + RANDOM_ANVIL_BREAK(2, "random.anvil_break"), + RANDOM_CLICK(3, "random.click"), + RANDOM_FIZZ(4, "random.fizz"), + RANDOM_EXPLODE(5, "random.explode"), + FIRE_IGNITE(6, "fire.ignite"), + + IC2_TOOLS_WRENCH(100, MOD_ID_IC2, "tools.Wrench"), + IC2_TOOLS_RUBBER_TRAMPOLINE(101, MOD_ID_IC2, "tools.RubberTrampoline"), + IC2_TOOLS_PAINTER(102, MOD_ID_IC2, "tools.Painter"), + IC2_TOOLS_BATTERY_USE(103, MOD_ID_IC2, "tools.BatteryUse"), + IC2_TOOLS_CHAINSAW_CHAINSAW_USE_ONE(104, MOD_ID_IC2, "tools.chainsaw.ChainsawUseOne"), + IC2_TOOLS_CHAINSAW_CHAINSAW_USE_TWO(105, MOD_ID_IC2, "tools.chainsaw.ChainsawUseTwo"), + IC2_TOOLS_DRILL_DRILL_SOFT(106, MOD_ID_IC2, "tools.drill.DrillSoft"), + IC2_TOOLS_DRILL_DRILL_HARD(107, MOD_ID_IC2, "tools.drill.DrillHard"), + IC2_TOOLS_OD_SCANNER(108, MOD_ID_IC2, "tools.ODScanner"), + IC2_TOOLS_INSULATION_CUTTERS(109, MOD_ID_IC2, "tools.InsulationCutters"), + + IC2_MACHINES_EXTRACTOR_OP(200, MOD_ID_IC2, "machines.ExtractorOp"), + IC2_MACHINES_MACERATOR_OP(201, MOD_ID_IC2, "machines.MaceratorOp"), + IC2_MACHINES_INDUCTION_LOOP(202, MOD_ID_IC2, "machines.InductionLoop"), + IC2_MACHINES_COMPRESSOR_OP(203, MOD_ID_IC2, "machines.CompressorOp"), + IC2_MACHINES_RECYCLER_OP(204, MOD_ID_IC2, "machines.RecyclerOp"), + IC2_MACHINES_MINER_OP(205, MOD_ID_IC2, "machines.MinerOp"), + IC2_MACHINES_PUMP_OP(206, MOD_ID_IC2, "machines.PumpOp"), + IC2_MACHINES_ELECTROFURNACE_LOOP(207, MOD_ID_IC2, "machines.ElectroFurnaceLoop"), + @Deprecated + DEPRECATED_DUPE_OF_IC2_MACHINES_INDUCTION_LOOP(208, MOD_ID_IC2, "machines.InductionLoop"), + IC2_MACHINES_MACHINE_OVERLOAD(209, MOD_ID_IC2, "machines.MachineOverload"), + IC2_MACHINES_INTERRUPT_ONE(210, MOD_ID_IC2, "machines.InterruptOne"), + IC2_MACHINES_KA_CHING(211, MOD_ID_IC2, "machines.KaChing"), + IC2_MACHINES_MAGNETIZER_LOOP(212, MOD_ID_IC2, "machines.MagnetizerLoop"), + + /* + * Other Minecraft Sounds that were missing + */ + AMBIENT_CAVE_CAVE(-1, "ambient.cave.cave"), + AMBIENT_WEATHER_RAIN(-1, "ambient.weather.rain"), + AMBIENT_WEATHER_THUNDER(-1, "ambient.weather.thunder"), + DAMAGE_FALLBIG(-1, "damage.fallbig"), + DAMAGE_FALLSMALL(-1, "damage.fallsmall"), + DAMAGE_HIT(-1, "damage.hit"), + DAMAGE_HURTFLESH(-1, "damage.hurtflesh"), + DIG_CLOTH(-1, "dig.cloth"), + DIG_GRASS(-1, "dig.grass"), + DIG_GRAVEL(-1, "dig.gravel"), + DIG_SAND(-1, "dig.sand"), + DIG_SNOW(-1, "dig.snow"), + DIG_STONE(-1, "dig.stone"), + DIG_WOOD(-1, "dig.wood"), + FIRE_FIRE(-1, "fire.fire"), + FIREWORKS_BLAST(-1, "fireworks.blast"), + FIREWORKS_BLAST_FAR(-1, "fireworks.blast_far"), + FIREWORKS_LARGEBLAST(-1, "fireworks.largeBlast"), + FIREWORKS_LARGEBLAST_FAR(-1, "fireworks.largeBlast_far"), + FIREWORKS_LAUNCH(-1, "fireworks.launch"), + FIREWORKS_TWINKLE(-1, "fireworks.twinkle"), + FIREWORKS_TWINKLE_FAR(-1, "fireworks.twinkle_far"), + GAME_NEUTRAL_SWIM(-1, "game.neutral.swim"), + GAME_TNT_PRIMED(-1, "game.tnt.primed"), + LIQUID_LAVA(-1, "liquid.lava"), + LIQUID_LAVAPOP(-1, "liquid.lavapop"), + LIQUID_SPLASH(-1, "liquid.splash"), + LIQUID_SWIM(-1, "liquid.swim"), + LIQUID_WATER(-1, "liquid.water"), + MINECART_BASE(-1, "minecart.base"), + MINECART_INSIDE(-1, "minecart.inside"), + MOB_BAT_DEATH(-1, "mob.bat.death"), + MOB_BAT_HURT(-1, "mob.bat.hurt"), + MOB_BAT_IDLE(-1, "mob.bat.idle"), + MOB_BAT_LOOP(-1, "mob.bat.loop"), + MOB_BAT_TAKEOFF(-1, "mob.bat.takeoff"), + MOB_BLAZE_BREATHE(-1, "mob.blaze.breathe"), + MOB_BLAZE_DEATH(-1, "mob.blaze.death"), + MOB_BLAZE_HIT(-1, "mob.blaze.hit"), + MOB_CAT_HISS(-1, "mob.cat.hiss"), + MOB_CAT_HITT(-1, "mob.cat.hitt"), + MOB_CAT_MEOW(-1, "mob.cat.meow"), + MOB_CAT_PURR(-1, "mob.cat.purr"), + MOB_CAT_PURREOW(-1, "mob.cat.purreow"), + MOB_CHICKEN(-1, "mob.chicken"), + MOB_CHICKEN_HURT(-1, "mob.chicken.hurt"), + MOB_CHICKEN_PLOP(-1, "mob.chicken.plop"), + MOB_CHICKEN_SAY(-1, "mob.chicken.say"), + MOB_CHICKEN_STEP(-1, "mob.chicken.step"), + MOB_COW(-1, "mob.cow"), + MOB_COW_HURT(-1, "mob.cow.hurt"), + MOB_COW_SAY(-1, "mob.cow.say"), + MOB_COW_STEP(-1, "mob.cow.step"), + MOB_CREEPER(-1, "mob.creeper"), + MOB_CREEPER_DEATH(-1, "mob.creeper.death"), + MOB_CREEPER_SAY(-1, "mob.creeper.say"), + MOB_ENDERDRAGON_END(-1, "mob.enderdragon.end"), + MOB_ENDERDRAGON_GROWL(-1, "mob.enderdragon.growl"), + MOB_ENDERDRAGON_HIT(-1, "mob.enderdragon.hit"), + MOB_ENDERDRAGON_WINGS(-1, "mob.enderdragon.wings"), + MOB_ENDERMEN_DEATH(-1, "mob.endermen.death"), + MOB_ENDERMEN_HIT(-1, "mob.endermen.hit"), + MOB_ENDERMEN_IDLE(-1, "mob.endermen.idle"), + MOB_ENDERMEN_PORTAL(-1, "mob.endermen.portal"), + MOB_ENDERMEN_SCREAM(-1, "mob.endermen.scream"), + MOB_ENDERMEN_STARE(-1, "mob.endermen.stare"), + MOB_GHAST_AFFECTIONATE_SCREAM(-1, "mob.ghast.affectionate_scream"), + MOB_GHAST_CHARGE(-1, "mob.ghast.charge"), + MOB_GHAST_DEATH(-1, "mob.ghast.death"), + MOB_GHAST_FIREBALL(-1, "mob.ghast.fireball"), + MOB_GHAST_MOAN(-1, "mob.ghast.moan"), + MOB_GHAST_SCREAM(-1, "mob.ghast.scream"), + MOB_HORSE_ANGRY(-1, "mob.horse.angry"), + MOB_HORSE_ARMOR(-1, "mob.horse.armor"), + MOB_HORSE_BREATHE(-1, "mob.horse.breathe"), + MOB_HORSE_DEATH(-1, "mob.horse.death"), + MOB_HORSE_DONKEY_ANGRY(-1, "mob.horse.donkey.angry"), + MOB_HORSE_DONKEY_DEATH(-1, "mob.horse.donkey.death"), + MOB_HORSE_DONKEY_HIT(-1, "mob.horse.donkey.hit"), + MOB_HORSE_DONKEY_IDLE(-1, "mob.horse.donkey.idle"), + MOB_HORSE_GALLOP(-1, "mob.horse.gallop"), + MOB_HORSE_HIT(-1, "mob.horse.hit"), + MOB_HORSE_IDLE(-1, "mob.horse.idle"), + MOB_HORSE_JUMP(-1, "mob.horse.jump"), + MOB_HORSE_LAND(-1, "mob.horse.land"), + MOB_HORSE_LEATHER(-1, "mob.horse.leather"), + MOB_HORSE_SKELETON_DEATH(-1, "mob.horse.skeleton.death"), + MOB_HORSE_SKELETON_HIT(-1, "mob.horse.skeleton.hit"), + MOB_HORSE_SKELETON_IDLE(-1, "mob.horse.skeleton.idle"), + MOB_HORSE_SOFT(-1, "mob.horse.soft"), + MOB_HORSE_WOOD(-1, "mob.horse.wood"), + MOB_HORSE_ZOMBIE_DEATH(-1, "mob.horse.zombie.death"), + MOB_HORSE_ZOMBIE_HIT(-1, "mob.horse.zombie.hit"), + MOB_HORSE_ZOMBIE_IDLE(-1, "mob.horse.zombie.idle"), + MOB_IRONGOLEM_DEATH(-1, "mob.irongolem.death"), + MOB_IRONGOLEM_HIT(-1, "mob.irongolem.hit"), + MOB_IRONGOLEM_THROW(-1, "mob.irongolem.throw"), + MOB_IRONGOLEM_WALK(-1, "mob.irongolem.walk"), + MOB_MAGMACUBE_BIG(-1, "mob.magmacube.big"), + MOB_MAGMACUBE_JUMP(-1, "mob.magmacube.jump"), + MOB_MAGMACUBE_SMALL(-1, "mob.magmacube.small"), + MOB_PIG(-1, "mob.pig"), + MOB_PIG_DEATH(-1, "mob.pig.death"), + MOB_PIG_SAY(-1, "mob.pig.say"), + MOB_PIG_STEP(-1, "mob.pig.step"), + MOB_SHEEP(-1, "mob.sheep"), + MOB_SHEEP_SAY(-1, "mob.sheep.say"), + MOB_SHEEP_SHEAR(-1, "mob.sheep.shear"), + MOB_SHEEP_STEP(-1, "mob.sheep.step"), + MOB_SILVERFISH_HIT(-1, "mob.silverfish.hit"), + MOB_SILVERFISH_KILL(-1, "mob.silverfish.kill"), + MOB_SILVERFISH_SAY(-1, "mob.silverfish.say"), + MOB_SILVERFISH_STEP(-1, "mob.silverfish.step"), + MOB_SKELETON(-1, "mob.skeleton"), + MOB_SKELETON_DEATH(-1, "mob.skeleton.death"), + MOB_SKELETON_HURT(-1, "mob.skeleton.hurt"), + MOB_SKELETON_SAY(-1, "mob.skeleton.say"), + MOB_SKELETON_STEP(-1, "mob.skeleton.step"), + MOB_SLIME(-1, "mob.slime"), + MOB_SLIME_ATTACK(-1, "mob.slime.attack"), + MOB_SLIME_BIG(-1, "mob.slime.big"), + MOB_SLIME_SMALL(-1, "mob.slime.small"), + MOB_SPIDER(-1, "mob.spider"), + MOB_SPIDER_DEATH(-1, "mob.spider.death"), + MOB_SPIDER_SAY(-1, "mob.spider.say"), + MOB_SPIDER_STEP(-1, "mob.spider.step"), + MOB_VILLAGER_DEATH(-1, "mob.villager.death"), + MOB_VILLAGER_HAGGLE(-1, "mob.villager.haggle"), + MOB_VILLAGER_HIT(-1, "mob.villager.hit"), + MOB_VILLAGER_IDLE(-1, "mob.villager.idle"), + MOB_VILLAGER_NO(-1, "mob.villager.no"), + MOB_VILLAGER_YES(-1, "mob.villager.yes"), + MOB_WITHER_DEATH(-1, "mob.wither.death"), + MOB_WITHER_HURT(-1, "mob.wither.hurt"), + MOB_WITHER_IDLE(-1, "mob.wither.idle"), + MOB_WITHER_SHOOT(-1, "mob.wither.shoot"), + MOB_WITHER_SPAWN(-1, "mob.wither.spawn"), + MOB_WOLF_BARK(-1, "mob.wolf.bark"), + MOB_WOLF_DEATH(-1, "mob.wolf.death"), + MOB_WOLF_GROWL(-1, "mob.wolf.growl"), + MOB_WOLF_HOWL(-1, "mob.wolf.howl"), + MOB_WOLF_HURT(-1, "mob.wolf.hurt"), + MOB_WOLF_PANTING(-1, "mob.wolf.panting"), + MOB_WOLF_SHAKE(-1, "mob.wolf.shake"), + MOB_WOLF_STEP(-1, "mob.wolf.step"), + MOB_WOLF_WHINE(-1, "mob.wolf.whine"), + MOB_ZOMBIE(-1, "mob.zombie"), + MOB_ZOMBIE_DEATH(-1, "mob.zombie.death"), + MOB_ZOMBIE_HURT(-1, "mob.zombie.hurt"), + MOB_ZOMBIE_INFECT(-1, "mob.zombie.infect"), + MOB_ZOMBIE_METAL(-1, "mob.zombie.metal"), + MOB_ZOMBIE_REMEDY(-1, "mob.zombie.remedy"), + MOB_ZOMBIE_SAY(-1, "mob.zombie.say"), + MOB_ZOMBIE_STEP(-1, "mob.zombie.step"), + MOB_ZOMBIE_UNFECT(-1, "mob.zombie.unfect"), + MOB_ZOMBIE_WOOD(-1, "mob.zombie.wood"), + MOB_ZOMBIE_WOODBREAK(-1, "mob.zombie.woodbreak"), + MOB_ZOMBIEPIG_ZPIG(-1, "mob.zombiepig.zpig"), + MOB_ZOMBIEPIG_ZPIGANGRY(-1, "mob.zombiepig.zpigangry"), + MOB_ZOMBIEPIG_ZPIGDEATH(-1, "mob.zombiepig.zpigdeath"), + MOB_ZOMBIEPIG_ZPIGHURT(-1, "mob.zombiepig.zpighurt"), + MUSIC_GAME_CALM(-1, "music.game.calm"), + MUSIC_GAME_CREATIVE_CREATIVE(-1, "music.game.creative.creative"), + MUSIC_GAME_END_BOSS(-1, "music.game.end.boss"), + MUSIC_GAME_END_CREDITS(-1, "music.game.end.credits"), + MUSIC_GAME_END_END(-1, "music.game.end.end"), + MUSIC_GAME_HAL(-1, "music.game.hal"), + MUSIC_GAME_NETHER_NETHER(-1, "music.game.nether.nether"), + MUSIC_GAME_NUANCE(-1, "music.game.nuance"), + MUSIC_GAME_PIANO(-1, "music.game.piano"), + MUSIC_MENU_MENU(-1, "music.menu.menu"), + NOTE_BASS(-1, "note.bass"), + NOTE_BASSATTACK(-1, "note.bassattack"), + NOTE_BD(-1, "note.bd"), + NOTE_HARP(-1, "note.harp"), + NOTE_HAT(-1, "note.hat"), + NOTE_PLING(-1, "note.pling"), + NOTE_SNARE(-1, "note.snare"), + PORTAL_PORTAL(-1, "portal.portal"), + PORTAL_TRAVEL(-1, "portal.travel"), + PORTAL_TRIGGER(-1, "portal.trigger"), + RANDOM_ANVIL_LAND(-1, "random.anvil_land"), + RANDOM_BOW(-1, "random.bow"), + RANDOM_BOWHIT(-1, "random.bowhit"), + RANDOM_BREATH(-1, "random.breath"), + RANDOM_BURP(-1, "random.burp"), + RANDOM_CHESTCLOSED(-1, "random.chestclosed"), + RANDOM_CHESTOPEN(-1, "random.chestopen"), + RANDOM_CLASSIC_HURT(-1, "random.classic_hurt"), + RANDOM_DOOR_CLOSE(-1, "random.door_close"), + RANDOM_DOOR_OPEN(-1, "random.door_open"), + RANDOM_DRINK(-1, "random.drink"), + RANDOM_DRR(-1, "random.drr"), + RANDOM_EAT(-1, "random.eat"), + RANDOM_FUSE(-1, "random.fuse"), + RANDOM_GLASS(-1, "random.glass"), + RANDOM_HURT(-1, "random.hurt"), + RANDOM_LEVELUP(-1, "random.levelup"), + RANDOM_ORB(-1, "random.orb"), + RANDOM_POP(-1, "random.pop"), + RANDOM_SPLASH(-1, "random.splash"), + RANDOM_SUCCESSFUL_HIT(-1, "random.successful_hit"), + RANDOM_WOOD_CLICK(-1, "random.wood_click"), + RECORDS_11(-1, "records.11"), + RECORDS_13(-1, "records.13"), + RECORDS_BLOCKS(-1, "records.blocks"), + RECORDS_CAT(-1, "records.cat"), + RECORDS_CHIRP(-1, "records.chirp"), + RECORDS_FAR(-1, "records.far"), + RECORDS_MALL(-1, "records.mall"), + RECORDS_MELLOHI(-1, "records.mellohi"), + RECORDS_STAL(-1, "records.stal"), + RECORDS_STRAD(-1, "records.strad"), + RECORDS_WAIT(-1, "records.wait"), + RECORDS_WARD(-1, "records.ward"), + STEP_CLOTH(-1, "step.cloth"), + STEP_GRASS(-1, "step.grass"), + STEP_GRAVEL(-1, "step.gravel"), + STEP_LADDER(-1, "step.ladder"), + STEP_SAND(-1, "step.sand"), + STEP_SNOW(-1, "step.snow"), + STEP_STONE(-1, "step.stone"), + STEP_WOOD(-1, "step.wood"), + TILE_PISTON_IN(-1, "tile.piston.in"), + TILE_PISTON_OUT(-1, "tile.piston.out"), + + NONE(-1, ""); + + /** + * Internal mapping by {@code int} id + */ + private static final Map<Integer, SoundResource> ID_SOUND_MAP = new ConcurrentHashMap<>(); + /** + * Internal mapping by {@code String} ResourceLocation + */ + private static final Map<String, SoundResource> RESOURCE_STR_SOUND_MAP = new ConcurrentHashMap<>(); + + static { + EnumSet.allOf(SoundResource.class).forEach(sound -> { + if (sound.id > 0) ID_SOUND_MAP.put(sound.id, sound); + }); + EnumSet.allOf(SoundResource.class).forEach(sound -> + RESOURCE_STR_SOUND_MAP.put(sound.resourceLocation.toString(), sound)); + } + + /** + * This Sound's identifier + */ + public final int id; + + /** + * The {@link ResourceLocation} of this {@link SoundResource} + */ + public final ResourceLocation resourceLocation; + + SoundResource(final int id, final ResourceLocation resourceLocation) { + this.id = id; + this.resourceLocation = resourceLocation; + } + + SoundResource(final int id, final String resourcePath) { + this(id, new ResourceLocation(resourcePath)); + } + + SoundResource(final int id, final String resourceDomain, final String resourcePath) { + this(id, new ResourceLocation(resourceDomain.toLowerCase(Locale.ENGLISH), resourcePath)); + } + + /** + * @param id The Sounds identifier + * @return The {@link SoundResource} + */ + public static SoundResource get(int id) { + return ID_SOUND_MAP.get(id); + } + + /** + * @param resourceStr The {@link ResourceLocation}'s String of the {@link SoundResource} + * @return The {@link SoundResource} + */ + public static SoundResource get(String resourceStr) { + return RESOURCE_STR_SOUND_MAP.get(resourceStr); + } + + /** + * Provides a backward-compatible Sounds {@code Map<Integer, String>} sound list + * + * @return The map for the deprecated {@link gregtech.api.GregTech_API#sSoundList} + * @deprecated This method is planned for removal. + * <p>Use this {@link SoundResource} enum instead.</p> + */ + @Deprecated + public static Map<Integer, String> asSoundList() { + return Maps.transformValues(ID_SOUND_MAP, SoundResource::toString); + } + + /** + * @inheritDoc + */ + @Override + public String toString() { + return this.resourceLocation.toString(); + } +} diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java index 1b5e00773b..bd9e75945b 100644 --- a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java +++ b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java @@ -3,6 +3,7 @@ package gregtech.api.graphs.consumers; import cofh.api.energy.IEnergyReceiver; import gregtech.GT_Mod; import gregtech.api.GregTech_API; +import gregtech.api.enums.SoundResource; import gregtech.api.util.GT_Utility; import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.common.GT_Pollution; @@ -69,7 +70,7 @@ public class NodeEnergyReceiver extends ConsumerNode { aExplosionPower < V[15] ? 19.0F : 20.0F; int tX = mTileEntity.xCoord, tY = mTileEntity.yCoord, tZ = mTileEntity.zCoord; World tWorld = mTileEntity.getWorldObj(); - GT_Utility.sendSoundToPlayers(tWorld, GregTech_API.sSoundList.get(209), 1.0F, -1, tX, tY, tZ); + GT_Utility.sendSoundToPlayers(tWorld, SoundResource.IC2_MACHINES_MACHINE_OVERLOAD, 1.0F, -1, tX, tY, tZ); tWorld.setBlock(tX, tY, tZ, Blocks.air); if (GregTech_API.sMachineExplosions) if (GT_Mod.gregtechproxy.mPollution) diff --git a/src/main/java/gregtech/api/items/GT_Spray_Bug_Item.java b/src/main/java/gregtech/api/items/GT_Spray_Bug_Item.java index 75d4dc3e80..5b697748da 100644 --- a/src/main/java/gregtech/api/items/GT_Spray_Bug_Item.java +++ b/src/main/java/gregtech/api/items/GT_Spray_Bug_Item.java @@ -1,6 +1,6 @@ package gregtech.api.items; -import gregtech.api.GregTech_API; +import gregtech.api.enums.SoundResource; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; @@ -20,9 +20,9 @@ public class GT_Spray_Bug_Item extends GT_Tool_Item { addToEffectiveList("EntityTFTowerBroodling"); addToEffectiveList("EntityTFFireBeetle"); addToEffectiveList("EntityTFSlimeBeetle"); - setCraftingSound(GregTech_API.sSoundList.get(102)); - setBreakingSound(GregTech_API.sSoundList.get(102)); - setEntityHitSound(GregTech_API.sSoundList.get(102)); + setCraftingSound(Sounds.IC2_TOOLS_PAINTER); + setBreakingSound(Sounds.IC2_TOOLS_PAINTER); + setEntityHitSound(Sounds.IC2_TOOLS_PAINTER); setUsageAmounts(8, 4, 1);*/ } @@ -56,7 +56,7 @@ public class GT_Spray_Bug_Item extends GT_Tool_Item { int tCropBefore = ((ic2.api.crops.ICropTile) aTileEntity).getWeedExStorage(); if (tCropBefore <= 100 && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { ((ic2.api.crops.ICropTile) aTileEntity).setWeedExStorage(tCropBefore + 100); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(102), 1.0F, -1, aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, -1, aX, aY, aZ); return true; } } diff --git a/src/main/java/gregtech/api/items/GT_Spray_Foam_Item.java b/src/main/java/gregtech/api/items/GT_Spray_Foam_Item.java index 76339b9886..58bfafdffb 100644 --- a/src/main/java/gregtech/api/items/GT_Spray_Foam_Item.java +++ b/src/main/java/gregtech/api/items/GT_Spray_Foam_Item.java @@ -1,6 +1,6 @@ package gregtech.api.items; -import gregtech.api.GregTech_API; +import gregtech.api.enums.SoundResource; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; @@ -19,9 +19,9 @@ import static gregtech.api.enums.GT_Values.D1; public class GT_Spray_Foam_Item extends GT_Tool_Item { public GT_Spray_Foam_Item(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage) { super(aUnlocalized, aEnglish, "Precision Spray", aMaxDamage, aEntityDamage, true);/* - setCraftingSound(GregTech_API.sSoundList.get(102)); - setBreakingSound(GregTech_API.sSoundList.get(102)); - setEntityHitSound(GregTech_API.sSoundList.get(102)); + setCraftingSound(Sounds.IC2_TOOLS_PAINTER); + setBreakingSound(Sounds.IC2_TOOLS_PAINTER); + setEntityHitSound(Sounds.IC2_TOOLS_PAINTER); setUsageAmounts(25, 3, 1);*/ } @@ -72,7 +72,7 @@ public class GT_Spray_Foam_Item extends GT_Tool_Item { if (GT_Utility.getClassName(aTileEntity).startsWith("TileEntityCable")) { if (GT_Utility.getPublicField(aTileEntity, "foamed").getByte(aTileEntity) == 0) { if (GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(102), 1.0F, -1, aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, -1, aX, aY, aZ); GT_Utility.callPublicMethod(aTileEntity, "changeFoam", (byte) 1); return true; } @@ -85,7 +85,7 @@ public class GT_Spray_Foam_Item extends GT_Tool_Item { if (aTileEntity instanceof BaseMetaPipeEntity && (((BaseMetaPipeEntity) aTileEntity).mConnections & -64) == 0) { if (GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(102), 1.0F, -1, aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, -1, aX, aY, aZ); ((BaseMetaPipeEntity) aTileEntity).mConnections |= 64; } return true; @@ -122,7 +122,7 @@ public class GT_Spray_Foam_Item extends GT_Tool_Item { switch (0) { case 0: if (GT_Utility.isBlockAir(aWorld, aX, aY, aZ) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(102), 1.0F, -1, aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, -1, aX, aY, aZ); aWorld.setBlock(aX, aY, aZ, GT_Utility.getBlockFromStack(tStack), tStack.getItemDamage(), 3); return true; } @@ -130,7 +130,7 @@ public class GT_Spray_Foam_Item extends GT_Tool_Item { case 1: for (byte i = 0; i < 4; i++) { if (GT_Utility.isBlockAir(aWorld, aX, aY, aZ) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(102), 1.0F, -1, aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, -1, aX, aY, aZ); aWorld.setBlock(aX, aY, aZ, GT_Utility.getBlockFromStack(tStack), tStack.getItemDamage(), 3); } else { if (i == 0) return false; @@ -155,7 +155,7 @@ public class GT_Spray_Foam_Item extends GT_Tool_Item { for (byte j = 0; j < 3; j++) { if (GT_Utility.isBlockAir(aWorld, aX + (tXFactor ? i : 0), aY + (!tXFactor && tYFactor ? i : 0) + (!tZFactor && tYFactor ? j : 0), aZ + (tZFactor ? j : 0))) { if (GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(102), 1.0F, -1, aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, -1, aX, aY, aZ); aWorld.setBlock(aX + (tXFactor ? i : 0), aY + (!tXFactor && tYFactor ? i : 0) + (!tZFactor && tYFactor ? j : 0), aZ + (tZFactor ? j : 0), GT_Utility.getBlockFromStack(tStack), tStack.getItemDamage(), 3); temp = true; } else { diff --git a/src/main/java/gregtech/api/items/GT_Spray_Hardener_Item.java b/src/main/java/gregtech/api/items/GT_Spray_Hardener_Item.java index ae2bb27d77..4c8d64b5ee 100644 --- a/src/main/java/gregtech/api/items/GT_Spray_Hardener_Item.java +++ b/src/main/java/gregtech/api/items/GT_Spray_Hardener_Item.java @@ -1,6 +1,6 @@ package gregtech.api.items; -import gregtech.api.GregTech_API; +import gregtech.api.enums.SoundResource; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; @@ -17,9 +17,9 @@ import static gregtech.api.enums.GT_Values.D1; public class GT_Spray_Hardener_Item extends GT_Tool_Item { public GT_Spray_Hardener_Item(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage) { super(aUnlocalized, aEnglish, "Construction Foam Hardener", aMaxDamage, aEntityDamage, true);/* - setCraftingSound(GregTech_API.sSoundList.get(102)); - setBreakingSound(GregTech_API.sSoundList.get(102)); - setEntityHitSound(GregTech_API.sSoundList.get(102)); + setCraftingSound(Sounds.IC2_TOOLS_PAINTER); + setBreakingSound(Sounds.IC2_TOOLS_PAINTER); + setEntityHitSound(Sounds.IC2_TOOLS_PAINTER); setUsageAmounts(16, 3, 1);*/ } @@ -38,7 +38,7 @@ public class GT_Spray_Hardener_Item extends GT_Tool_Item { if (GT_Utility.getClassName(aTileEntity).startsWith("TileEntityCable")) { if (GT_Utility.getPublicField(aTileEntity, "foamed").getByte(aTileEntity) == 1) { if (GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(102), 1.0F, -1, aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, -1, aX, aY, aZ); GT_Utility.callPublicMethod(aTileEntity, "changeFoam", (byte) 2); return true; } @@ -52,7 +52,7 @@ public class GT_Spray_Hardener_Item extends GT_Tool_Item { ItemStack tStack1 = GT_ModHandler.getIC2Item("constructionFoam", 1), tStack2 = GT_ModHandler.getIC2Item("constructionFoamWall", 1); if (tStack1 != null && tStack1.isItemEqual(new ItemStack(aBlock)) && tStack2 != null && tStack2.getItem() instanceof ItemBlock) { if (GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(102), 1.0F, -1, aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, -1, aX, aY, aZ); aWorld.setBlock(aX, aY, aZ, GT_Utility.getBlockFromStack(tStack2), 7, 3); } return true; @@ -60,7 +60,7 @@ public class GT_Spray_Hardener_Item extends GT_Tool_Item { if (aTileEntity instanceof BaseMetaPipeEntity && (((BaseMetaPipeEntity) aTileEntity).mConnections & -64) == 64) { if (GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(102), 1.0F, -1, aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, -1, aX, aY, aZ); ((BaseMetaPipeEntity) aTileEntity).mConnections = (byte) ((((BaseMetaPipeEntity) aTileEntity).mConnections & ~64) | -128); } return true; diff --git a/src/main/java/gregtech/api/items/GT_Spray_Hydration_Item.java b/src/main/java/gregtech/api/items/GT_Spray_Hydration_Item.java index 2f6132261b..13ecdea3fa 100644 --- a/src/main/java/gregtech/api/items/GT_Spray_Hydration_Item.java +++ b/src/main/java/gregtech/api/items/GT_Spray_Hydration_Item.java @@ -1,6 +1,6 @@ package gregtech.api.items; -import gregtech.api.GregTech_API; +import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; @@ -13,9 +13,9 @@ import net.minecraft.world.World; public class GT_Spray_Hydration_Item extends GT_Tool_Item { public GT_Spray_Hydration_Item(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage) { super(aUnlocalized, aEnglish, "To hydrate Crops and similar", aMaxDamage, aEntityDamage, true);/* - setCraftingSound(GregTech_API.sSoundList.get(102)); - setBreakingSound(GregTech_API.sSoundList.get(102)); - setEntityHitSound(GregTech_API.sSoundList.get(102)); + setCraftingSound(Sounds.IC2_TOOLS_PAINTER); + setBreakingSound(Sounds.IC2_TOOLS_PAINTER); + setEntityHitSound(Sounds.IC2_TOOLS_PAINTER); setUsageAmounts(20, 3, 1);*/ } @@ -35,7 +35,7 @@ public class GT_Spray_Hydration_Item extends GT_Tool_Item { int tCropBefore = ((ic2.api.crops.ICropTile) aTileEntity).getHydrationStorage(); if (tCropBefore <= 100 && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { ((ic2.api.crops.ICropTile) aTileEntity).setHydrationStorage(tCropBefore + 100); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(102), 1.0F, -1, aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, -1, aX, aY, aZ); } return true; } @@ -44,7 +44,7 @@ public class GT_Spray_Hydration_Item extends GT_Tool_Item { if (aTileEntity instanceof IGregTechTileEntity) { if (((IGregTechTileEntity) aTileEntity).getColorization() >= 0 && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { ((IGregTechTileEntity) aTileEntity).setColorization((byte) -1); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(102), 1.0F, -1, aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, -1, aX, aY, aZ); } } diff --git a/src/main/java/gregtech/api/items/GT_Spray_Ice_Item.java b/src/main/java/gregtech/api/items/GT_Spray_Ice_Item.java index 400f183cbb..ddd9062d73 100644 --- a/src/main/java/gregtech/api/items/GT_Spray_Ice_Item.java +++ b/src/main/java/gregtech/api/items/GT_Spray_Ice_Item.java @@ -1,8 +1,8 @@ package gregtech.api.items; -import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SoundResource; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; @@ -26,9 +26,9 @@ public class GT_Spray_Ice_Item extends GT_Tool_Item { addToEffectiveList("EntityTFFireBeetle"); addToEffectiveList("EntityTFMazeSlime"); addToEffectiveList("EntityTFSlimeBeetle"); - setCraftingSound(GregTech_API.sSoundList.get(102)); - setBreakingSound(GregTech_API.sSoundList.get(102)); - setEntityHitSound(GregTech_API.sSoundList.get(102)); + setCraftingSound(Sounds.IC2_TOOLS_PAINTER); + setBreakingSound(Sounds.IC2_TOOLS_PAINTER); + setEntityHitSound(Sounds.IC2_TOOLS_PAINTER); setUsageAmounts(4, 16, 1);*/ for (Object tName : Arrays.asList(OrePrefixes.bucket.get(Materials.Water), OrePrefixes.cell.get(Materials.Water), OrePrefixes.capsule.get(Materials.Water))) { @@ -61,7 +61,7 @@ public class GT_Spray_Ice_Item extends GT_Tool_Item { if (aBlock == Blocks.water || aBlock == Blocks.flowing_water) { if (aMeta == 0 && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(102), 1.0F, -1, aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, -1, aX, aY, aZ); aWorld.setBlock(aX, aY, aZ, Blocks.ice, 0, 3); return true; } @@ -70,7 +70,7 @@ public class GT_Spray_Ice_Item extends GT_Tool_Item { if (aBlock == Blocks.lava || aBlock == Blocks.flowing_lava) { if (aMeta == 0 && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(102), 1.0F, -1, aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_PAINTER, 1.0F, -1, aX, aY, aZ); aWorld.setBlock(aX, aY, aZ, Blocks.obsidian, 0, 3); return true; } diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index 0d8f64030e..524e377010 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -1,19 +1,9 @@ package gregtech.api.metatileentity; -import static gregtech.GT_Mod.GT_FML_LOGGER; -import static gregtech.api.enums.GT_Values.NW; -import static gregtech.api.metatileentity.BaseMetaTileEntity.COVER_DATA_NBT_KEYS; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; - -import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; +import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures; -import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.graphs.Lock; import gregtech.api.graphs.Node; import gregtech.api.graphs.paths.NodePath; @@ -25,31 +15,30 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IPipeRenderedTileEntity; import gregtech.api.net.GT_Packet_TileEntity; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; -import gregtech.common.GT_Client; -import gregtech.common.covers.GT_Cover_Fluidfilter; +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 net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.*; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; +import java.util.*; import static gregtech.GT_Mod.GT_FML_LOGGER; import static gregtech.api.enums.GT_Values.NW; -import static gregtech.api.metatileentity.BaseMetaTileEntity.COVER_DATA_NBT_KEYS; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -59,9 +48,8 @@ import static gregtech.api.metatileentity.BaseMetaTileEntity.COVER_DATA_NBT_KEYS public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTechTileEntity, IPipeRenderedTileEntity, IDebugableTileEntity { public byte mConnections = IConnectable.NO_CONNECTION; protected MetaPipeEntity mMetaTileEntity; - private int[] mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; + private final int[] mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; private boolean mWorkUpdate = false, mWorks = true; - private final boolean mCheckConnections = false; private byte mColor = 0, oColor = 0, oStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, mLagWarningCount = 0; private int oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0; protected Node node; @@ -376,12 +364,16 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec if (mLagWarningCount > 0) { tList.add("Caused " + (mLagWarningCount >= 10 ? "more than 10" : mLagWarningCount) + " Lag Spike Warnings (anything taking longer than " + GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING + "ms) on the Server."); } - tList.add("Is" + (mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : EnumChatFormatting.RED+" not "+EnumChatFormatting.RESET) + "accessible for you"); + if (mMetaTileEntity != null) { + tList.add("Is" + (mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : EnumChatFormatting.RED+" not "+EnumChatFormatting.RESET) + "accessible for you"); + } } if(joinedIc2Enet) tList.add("Joined IC2 ENet"); - return mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList); + return mMetaTileEntity != null ? + mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList) : + new ArrayList<>(); } @Override @@ -713,7 +705,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec tNBT.setIntArray("mCoverSides", mCoverSides); if (hasValidMetaTileEntity()) mMetaTileEntity.setItemNBT(tNBT); if (!tNBT.hasNoTags()) rStack.setTagCompound(tNBT); - return new ArrayList<ItemStack>(Arrays.asList(rStack)); + return new ArrayList<>(Collections.singletonList(rStack)); } @Override @@ -741,7 +733,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec if (mMetaTileEntity.onWrenchRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { mMetaTileEntity.markDirty(); GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); } return true; } @@ -751,14 +743,14 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec setCoverDataAtSide(tSide, getCoverBehaviorAtSideNew(tSide).onCoverScrewdriverClick(tSide, getCoverIDAtSide(tSide), getComplexCoverDataAtSide(tSide), this, aPlayer, 0.5F, 0.5F, 0.5F)); mMetaTileEntity.onScrewdriverRightClick(tSide, aPlayer, aX, aY, aZ); mMetaTileEntity.markDirty(); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); } } else { if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { setCoverDataAtSide(aSide, getCoverBehaviorAtSideNew(aSide).onCoverScrewdriverClick(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ)); mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); mMetaTileEntity.markDirty(); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); } } return true; @@ -777,7 +769,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec else enableWorking(); mMetaTileEntity.markDirty(); GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("090","Machine Processing: ") + (isAllowedToWork() ? GT_Utility.trans("088","Enabled") : GT_Utility.trans("087","Disabled"))); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(101), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_RUBBER_TRAMPOLINE, 1.0F, -1, xCoord, yCoord, zCoord); } return true; } @@ -786,7 +778,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec if (mMetaTileEntity.onWireCutterRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { mMetaTileEntity.markDirty(); //logic handled internally - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); } doEnetUpdate(); return true; @@ -796,12 +788,12 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec if (mMetaTileEntity.onSolderingToolRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { mMetaTileEntity.markDirty(); //logic handled internally - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_BATTERY_USE, 1.0F, -1, xCoord, yCoord, zCoord); } else if (GT_ModHandler.useSolderingIron(tCurrentItem, aPlayer)) { mMetaTileEntity.markDirty(); mStrongRedstone ^= (1 << tSide); GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("091","Redstone Output at Side ") + tSide + GT_Utility.trans("092"," set to: ") + ((mStrongRedstone & (1 << tSide)) != 0 ? GT_Utility.trans("093","Strong") : GT_Utility.trans("094","Weak"))); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_BATTERY_USE, 3.0F, -1, xCoord, yCoord, zCoord); issueBlockUpdate(); } doEnetUpdate(); @@ -819,14 +811,14 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec setCoverItemAtSide(coverSide, tCurrentItem); mMetaTileEntity.markDirty(); if (!aPlayer.capabilities.isCreativeMode) tCurrentItem.stackSize--; - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); } return true; } } else { if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCrowbarList)) { if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(0), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.RANDOM_BREAK, 1.0F, -1, xCoord, yCoord, zCoord); dropCover(coverSide, aSide, false); mMetaTileEntity.markDirty(); } diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 5fc2e1cc9f..0af728ef27 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -20,6 +20,7 @@ import gregtech.GT_Mod; 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.graphs.GenerateNodeMap; import gregtech.api.graphs.GenerateNodeMapPower; @@ -62,11 +63,7 @@ import net.minecraftforge.fluids.FluidTankInfo; import javax.annotation.Nullable; import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.UUID; +import java.util.*; import static gregtech.GT_Mod.GT_FML_LOGGER; import static gregtech.api.enums.GT_Values.NW; @@ -82,32 +79,30 @@ import static gregtech.api.objects.XSTR.XSTR_INSTANCE; @Optional.Interface(iface = "appeng.api.networking.security.IActionHost", modid = "appliedenergistics2", striprefs = true), @Optional.Interface(iface = "appeng.me.helpers.IGridProxyable", modid = "appliedenergistics2", striprefs = true)}) public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTechTileEntity, IActionHost, IGridProxyable, IAlignmentProvider, IConstructableProvider, IDebugableTileEntity, IGregtechWailaProvider { + private static final Field ENTITY_ITEM_HEALTH_FIELD = ReflectionHelper.findField(EntityItem.class, "health", "field_70291_e"); + private final boolean[] mActiveEUInputs = new boolean[]{false, false, false, false, false, false}; + private final boolean[] mActiveEUOutputs = new boolean[]{false, false, false, false, false, false}; + private final int[] mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; + public long mLastSoundTick = 0; + public boolean mWasShutdown = false; protected MetaTileEntity mMetaTileEntity; protected long mStoredEnergy = 0, mStoredSteam = 0; protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0; protected boolean mReleaseEnergy = false; protected long[] mAverageEUInput = new long[]{0, 0, 0, 0, 0}, mAverageEUOutput = new long[]{0, 0, 0, 0, 0}; - private final boolean[] mActiveEUInputs = new boolean[]{false, false, false, false, false, false}; - private final boolean[] mActiveEUOutputs = new boolean[]{false, false, false, false, false, false}; - private final int[] mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; private boolean mHasEnoughEnergy = true, mRunningThroughTick = false, mInputDisabled = false, mOutputDisabled = false, mMuffler = false, mLockUpgrade = false; private boolean mActive = false, mWorkUpdate = false, mSteamConverter = false, mWorks = true; private boolean oRedstone = false; - private byte mColor = 0, oColor = 0, oStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage=0; + private byte mColor = 0, oColor = 0, oStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage = 0; private byte oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0; private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0; private long oOutput = 0, mAcceptedAmperes = Long.MAX_VALUE; - public long mLastSoundTick = 0; private long mLastCheckTick = 0; private String mOwnerName = ""; private UUID mOwnerUuid = GT_Utility.defaultUuid; private NBTTagCompound mRecipeStuff = new NBTTagCompound(); private int cableUpdateDelay = 30; - public boolean mWasShutdown = false; - - private static final Field ENTITY_ITEM_HEALTH_FIELD = ReflectionHelper.findField(EntityItem.class, "health", "field_70291_e"); - public BaseMetaTileEntity() { } @@ -170,7 +165,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec mOwnerName = aNBT.getString("mOwnerName"); try { mOwnerUuid = UUID.fromString(aNBT.getString("mOwnerUuid")); - } catch (IllegalArgumentException e){ + } catch (IllegalArgumentException e) { mOwnerUuid = null; } mLockUpgrade = aNBT.getBoolean("mLockUpgrade"); @@ -284,7 +279,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } } if (aSideServer && mTickTimer > 10) { - if(!doCoverThings()) { + if (!doCoverThings()) { mRunningThroughTick = false; return; } @@ -381,7 +376,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (getRandomNumber(10) == 0) { try { GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } GT_Log.exp.println("Machine at: " + this.getXCoord() + " | " + this.getYCoord() + " | " + this.getZCoord() + " DIMID: " + this.worldObj.provider.dimensionId + " explosion due to rain!"); doEnergyExplosion(); } else { @@ -396,7 +392,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering() && getRandomNumber(3) == 0) { try { GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } GT_Log.exp.println("Machine at: " + this.getXCoord() + " | " + this.getYCoord() + " | " + this.getZCoord() + " DIMID: " + this.worldObj.provider.dimensionId + " explosion due to Thunderstorm!"); doEnergyExplosion(); } @@ -509,7 +506,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec tTime = System.nanoTime() - tTime; if (mTimeStatistics.length > 0) mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) % mTimeStatistics.length] = (int) tTime; - if (tTime > 0 && tTime > (GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING* 1000000L) && mTickTimer > 1000 && getMetaTileEntity().doTickProfilingMessageDuringThisTick() && mLagWarningCount++ < 10) + if (tTime > 0 && tTime > (GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING * 1000000L) && mTickTimer > 1000 && getMetaTileEntity().doTickProfilingMessageDuringThisTick() && mLagWarningCount++ < 10) GT_FML_LOGGER.warn("WARNING: Possible Lag Source at [" + xCoord + ", " + yCoord + ", " + zCoord + "] in Dimension " + worldObj.provider.dimensionId + " with " + tTime + "ns caused by an instance of " + getMetaTileEntity().getClass()); } @@ -518,7 +515,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override public void getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { - if(hasValidMetaTileEntity() && getMetaTileEntity() != null) { + if (hasValidMetaTileEntity() && getMetaTileEntity() != null) { getMetaTileEntity().getWailaBody(itemStack, currenttip, accessor, config); } super.getWailaBody(itemStack, currenttip, accessor, config); @@ -527,7 +524,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, int z) { super.getWailaNBTData(player, tile, tag, world, x, y, z); - if(hasValidMetaTileEntity() && getMetaTileEntity() != null) { + if (hasValidMetaTileEntity() && getMetaTileEntity() != null) { getMetaTileEntity().getWailaNBTData(player, tile, tag, world, x, y, z); } } @@ -573,7 +570,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Deprecated public final void receiveMetaTileEntityData(short aID, int aCover0, int aCover1, int aCover2, int aCover3, int aCover4, int aCover5, byte aTextureData, byte aUpdateData, byte aRedstoneData, byte aColorData) { - receiveMetaTileEntityData(aID, aCover0, aCover1, aCover2, aCover3, aCover4, aCover5, aTextureData, (byte)0, aUpdateData, aRedstoneData, aColorData); + receiveMetaTileEntityData(aID, aCover0, aCover1, aCover2, aCover3, aCover4, aCover5, aTextureData, (byte) 0, aUpdateData, aRedstoneData, aColorData); } @@ -597,15 +594,15 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec mFacing = (byte) (aValue & 7); mActive = ((aValue & 8) != 0); mRedstone = ((aValue & 16) != 0); - //mLockUpgrade = ((aValue&32) != 0); - mWorks = ((aValue & 64) != 0); + //mLockUpgrade = ((aValue&32) != 0); + mWorks = ((aValue & 64) != 0); break; case GregTechTileClientEvents.CHANGE_CUSTOM_DATA: if (hasValidMetaTileEntity()) { if ((aValue & 0x80) == 0) //Is texture index mMetaTileEntity.onValueUpdate((byte) (aValue & 0x7F)); else if (mMetaTileEntity instanceof GT_MetaTileEntity_Hatch)//is texture page and hatch - ((GT_MetaTileEntity_Hatch) mMetaTileEntity).onTexturePageUpdate((byte) (aValue & 0x7F)); + ((GT_MetaTileEntity_Hatch) mMetaTileEntity).onTexturePageUpdate((byte) (aValue & 0x7F)); } break; case GregTechTileClientEvents.CHANGE_COLOR: @@ -644,7 +641,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec public ArrayList<String> getDebugInfo(EntityPlayer aPlayer, int aLogLevel) { final ArrayList<String> tList = new ArrayList<>(); if (aLogLevel > 2) { - tList.add("Meta-ID: " +EnumChatFormatting.BLUE+ mID +EnumChatFormatting.RESET + (canAccessData() ? EnumChatFormatting.GREEN+" valid"+EnumChatFormatting.RESET : EnumChatFormatting.RED+" invalid"+EnumChatFormatting.RESET) + (mMetaTileEntity == null ? EnumChatFormatting.RED+" MetaTileEntity == null!"+EnumChatFormatting.RESET : " ")); + tList.add("Meta-ID: " + EnumChatFormatting.BLUE + mID + EnumChatFormatting.RESET + (canAccessData() ? EnumChatFormatting.GREEN + " valid" + EnumChatFormatting.RESET : EnumChatFormatting.RED + " invalid" + EnumChatFormatting.RESET) + (mMetaTileEntity == null ? EnumChatFormatting.RED + " MetaTileEntity == null!" + EnumChatFormatting.RESET : " ")); } if (aLogLevel > 1) { if (mTimeStatistics.length > 0) { @@ -659,23 +656,23 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec //tList.add("tTime " + tTime); } tList.add("Average CPU load of ~" + GT_Utility.formatNumbers(tAverageTime / mTimeStatistics.length) + "ns over " + GT_Utility.formatNumbers(mTimeStatistics.length) + " ticks with worst time of " + GT_Utility.formatNumbers(tWorstTime) + "ns."); - tList.add("Recorded " + GT_Utility.formatNumbers(mMetaTileEntity.mSoundRequests) + " sound requests in " + GT_Utility.formatNumbers(mTickTimer - mLastCheckTick) + " ticks." ); + tList.add("Recorded " + GT_Utility.formatNumbers(mMetaTileEntity.mSoundRequests) + " sound requests in " + GT_Utility.formatNumbers(mTickTimer - mLastCheckTick) + " ticks."); mLastCheckTick = mTickTimer; mMetaTileEntity.mSoundRequests = 0; } if (mLagWarningCount > 0) { tList.add("Caused " + (mLagWarningCount >= 10 ? "more than 10" : mLagWarningCount) + " Lag Spike Warnings (anything taking longer than " + GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING + "ms) on the Server."); } - tList.add("Is" + (mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : EnumChatFormatting.RED+" not "+EnumChatFormatting.RESET) + "accessible for you"); + tList.add("Is" + (mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : EnumChatFormatting.RED + " not " + EnumChatFormatting.RESET) + "accessible for you"); } if (aLogLevel > 0) { if (getSteamCapacity() > 0 && hasSteamEngineUpgrade()) tList.add(GT_Utility.formatNumbers(getStoredSteam()) + " of " + GT_Utility.formatNumbers(getSteamCapacity()) + " Steam"); - tList.add("Machine is " + (mActive ? EnumChatFormatting.GREEN+"active"+EnumChatFormatting.RESET : EnumChatFormatting.RED+"inactive"+EnumChatFormatting.RESET)); + tList.add("Machine is " + (mActive ? EnumChatFormatting.GREEN + "active" + EnumChatFormatting.RESET : EnumChatFormatting.RED + "inactive" + EnumChatFormatting.RESET)); if (!mHasEnoughEnergy) - tList.add(EnumChatFormatting.RED+"ATTENTION: This Device needs more power."+EnumChatFormatting.RESET); + tList.add(EnumChatFormatting.RED + "ATTENTION: This Device needs more power." + EnumChatFormatting.RESET); } - if(joinedIc2Enet) + if (joinedIc2Enet) tList.add("Joined IC2 ENet"); return mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList); } @@ -922,7 +919,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override public boolean inputEnergyFrom(byte aSide, boolean waitForActive) { if (aSide == 6) return true; - if (isServerSide() && waitForActive) return ((aSide >= 0 && aSide < 6) && mActiveEUInputs[aSide]) && !mReleaseEnergy; + if (isServerSide() && waitForActive) + return ((aSide >= 0 && aSide < 6) && mActiveEUInputs[aSide]) && !mReleaseEnergy; return isEnergyInputSide(aSide); } @@ -934,7 +932,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override public boolean outputsEnergyTo(byte aSide, boolean waitForActive) { if (aSide == 6) return true; - if (isServerSide() && waitForActive) return ((aSide >= 0 && aSide < 6) && mActiveEUOutputs[aSide]) || mReleaseEnergy; + if (isServerSide() && waitForActive) + return ((aSide >= 0 && aSide < 6) && mActiveEUOutputs[aSide]) || mReleaseEnergy; return isEnergyOutputSide(aSide); } @@ -951,15 +950,15 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec public void generatePowerNodes() { if (isServerSide() && (isEnetInput() || isEnetOutput())) { final int time = MinecraftServer.getServer().getTickCounter(); - for (byte i = 0;i<6;i++) { - if (outputsEnergyTo(i,false) || inputEnergyFrom(i,false)) { + for (byte i = 0; i < 6; i++) { + if (outputsEnergyTo(i, false) || inputEnergyFrom(i, false)) { final IGregTechTileEntity TE = getIGregTechTileEntityAtSide(i); if (TE instanceof BaseMetaPipeEntity) { final Node node = ((BaseMetaPipeEntity) TE).getNode(); if (node == null) { new GenerateNodeMapPower((BaseMetaPipeEntity) TE); } else if (node.mCreationTime != time) { - GenerateNodeMap.clearNodeMap(node,-1); + GenerateNodeMap.clearNodeMap(node, -1); new GenerateNodeMapPower((BaseMetaPipeEntity) TE); } } @@ -1041,8 +1040,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec public ITexture[] getTexture(Block aBlock, byte aSide) { final ITexture coverTexture = getCoverTexture(aSide); final ITexture[] textureUncovered = hasValidMetaTileEntity() ? - mMetaTileEntity.getTexture(this, aSide, mFacing, (byte) (mColor - 1), mActive, getOutputRedstoneSignal(aSide) > 0) : - Textures.BlockIcons.ERROR_RENDERING; + mMetaTileEntity.getTexture(this, aSide, mFacing, (byte) (mColor - 1), mActive, getOutputRedstoneSignal(aSide) > 0) : + Textures.BlockIcons.ERROR_RENDERING; final ITexture[] textureCovered; if (coverTexture != null) { textureCovered = Arrays.copyOf(textureUncovered, textureUncovered.length + 1); @@ -1160,17 +1159,19 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec try { mReleaseEnergy = true; IEnergyConnected.Util.emitEnergyToNetwork(V[5], Math.max(1, getStoredEU() / V[5]), this); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } mReleaseEnergy = false; // Normal Explosion Code mMetaTileEntity.onExplosion(); - if(GT_Mod.gregtechproxy.mExplosionItemDrop){ + if (GT_Mod.gregtechproxy.mExplosionItemDrop) { for (int i = 0; i < this.getSizeInventory(); i++) { final ItemStack tItem = this.getStackInSlot(i); if ((tItem != null) && (tItem.stackSize > 0) && (this.isValidSlot(i))) { - dropItems(tItem); - this.setInventorySlotContents(i, null); } + dropItems(tItem); + this.setInventorySlotContents(i, null); + } } } if (mRecipeStuff != null) { @@ -1186,8 +1187,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } } - public void dropItems(ItemStack tItem){ - if(tItem==null)return; + public void dropItems(ItemStack tItem) { + if (tItem == null) return; final EntityItem tItemEntity = new EntityItem(this.worldObj, this.xCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, this.yCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, this.zCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); if (tItem.hasTagCompound()) { tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy()); @@ -1198,9 +1199,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec tItemEntity.hurtResistantTime = 999999; tItemEntity.lifespan = 60000; try { - if(ENTITY_ITEM_HEALTH_FIELD != null) + if (ENTITY_ITEM_HEALTH_FIELD != null) ENTITY_ITEM_HEALTH_FIELD.setInt(tItemEntity, 99999999); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } this.worldObj.spawnEntityInWorld(tItemEntity); tItem.stackSize = 0; } @@ -1251,13 +1253,13 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec return true; } if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) { - if(aPlayer.isSneaking() && mMetaTileEntity instanceof GT_MetaTileEntity_BasicMachine && ((GT_MetaTileEntity_BasicMachine)mMetaTileEntity).setMainFacing(GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ))){ + if (aPlayer.isSneaking() && mMetaTileEntity instanceof GT_MetaTileEntity_BasicMachine && ((GT_MetaTileEntity_BasicMachine) mMetaTileEntity).setMainFacing(GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ))) { GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); cableUpdateDelay = 10; - }else if (mMetaTileEntity.onWrenchRightClick(aSide, GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ), aPlayer, aX, aY, aZ)) { + } else if (mMetaTileEntity.onWrenchRightClick(aSide, GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ), aPlayer, aX, aY, aZ)) { GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); cableUpdateDelay = 10; } return true; @@ -1267,7 +1269,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) { setCoverDataAtSide(aSide, getCoverBehaviorAtSideNew(aSide).onCoverScrewdriverClick(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ)); mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); } return true; } @@ -1276,8 +1278,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { mInputDisabled = !mInputDisabled; if (mInputDisabled) mOutputDisabled = !mOutputDisabled; - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("086","Auto-Input: ") + (mInputDisabled ? GT_Utility.trans("087","Disabled") : GT_Utility.trans("088","Enabled") + GT_Utility.trans("089"," Auto-Output: ") + (mOutputDisabled ? GT_Utility.trans("087","Disabled") : GT_Utility.trans("088","Enabled")))); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(1), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("086", "Auto-Input: ") + (mInputDisabled ? GT_Utility.trans("087", "Disabled") : GT_Utility.trans("088", "Enabled") + GT_Utility.trans("089", " Auto-Output: ") + (mOutputDisabled ? GT_Utility.trans("087", "Disabled") : GT_Utility.trans("088", "Enabled")))); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.RANDOM_ANVIL_USE, 1.0F, -1, xCoord, yCoord, zCoord); } return true; } @@ -1292,7 +1294,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec tChat = getMetaTileEntity().getAlternativeModeText(); GT_Utility.sendChatToPlayer(aPlayer, tChat); } - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(101), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_RUBBER_TRAMPOLINE, 1.0F, -1, xCoord, yCoord, zCoord); } return true; } @@ -1301,11 +1303,11 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); if (mMetaTileEntity.onSolderingToolRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { //logic handled internally - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_BATTERY_USE, 1.0F, -1, xCoord, yCoord, zCoord); } else if (GT_ModHandler.useSolderingIron(tCurrentItem, aPlayer)) { mStrongRedstone ^= (1 << tSide); - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("091","Redstone Output at Side ") + tSide + GT_Utility.trans("092"," set to: ") + ((mStrongRedstone & (1 << tSide)) != 0 ? GT_Utility.trans("093","Strong") : GT_Utility.trans("094","Weak"))); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("091", "Redstone Output at Side ") + tSide + GT_Utility.trans("092", " set to: ") + ((mStrongRedstone & (1 << tSide)) != 0 ? GT_Utility.trans("093", "Strong") : GT_Utility.trans("094", "Weak"))); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_BATTERY_USE, 3.0F, -1, xCoord, yCoord, zCoord); issueBlockUpdate(); } doEnetUpdate(); @@ -1314,10 +1316,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList)) { - final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); + final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); if (mMetaTileEntity.onWireCutterRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { //logic handled internally - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); } doEnetUpdate(); cableUpdateDelay = 10; @@ -1330,25 +1332,23 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (getCoverIDAtSide(coverSide) == 0) { if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCovers.keySet())) { if (GregTech_API.getCoverBehaviorNew(tCurrentItem).isCoverPlaceable(coverSide, tCurrentItem, this) && - mMetaTileEntity.allowCoverOnSide(coverSide, new GT_ItemStack(tCurrentItem))) - { + mMetaTileEntity.allowCoverOnSide(coverSide, new GT_ItemStack(tCurrentItem))) { setCoverItemAtSide(coverSide, tCurrentItem); if (!aPlayer.capabilities.isCreativeMode) tCurrentItem.stackSize--; - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); } return true; } } else { if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCrowbarList)) { if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(0), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.RANDOM_BREAK, 1.0F, -1, xCoord, yCoord, zCoord); dropCover(coverSide, aSide, false); } return true; } } - } - else if (aPlayer.isSneaking()) { //Sneak click, no tool -> open cover config if possible. + } else if (aPlayer.isSneaking()) { //Sneak click, no tool -> open cover config if possible. aSide = (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) : aSide; return getCoverIDAtSide(aSide) > 0 && getCoverBehaviorAtSideNew(aSide).onCoverShiftRightClick(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this, aPlayer); } @@ -1362,7 +1362,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (isUpgradable() && tCurrentItem != null) { if (ItemList.Upgrade_Muffler.isStackEqual(aPlayer.inventory.getCurrentItem())) { if (addMufflerUpgrade()) { - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.RANDOM_CLICK, 1.0F, -1, xCoord, yCoord, zCoord); if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--; } return true; @@ -1372,7 +1372,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec mLockUpgrade = true; setOwnerName(aPlayer.getDisplayName()); setOwnerUuid(aPlayer.getUniqueID()); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers(worldObj, SoundResource.RANDOM_CLICK, 1.0F, -1, xCoord, yCoord, zCoord); if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--; } return true; @@ -1382,7 +1382,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } try { - if (!aPlayer.isSneaking() && hasValidMetaTileEntity()) return mMetaTileEntity.onRightclick(this, aPlayer, aSide, aX, aY, aZ); + if (!aPlayer.isSneaking() && hasValidMetaTileEntity()) + return mMetaTileEntity.onRightclick(this, aPlayer, aSide, aX, aY, aZ); } catch (Throwable e) { GT_Log.err.println("Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); @@ -1465,9 +1466,9 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } @Override - public byte getGeneralRS(byte aSide){ - if(mMetaTileEntity==null) return 0; - return mMetaTileEntity.allowGeneralRedstoneOutput() ? mSidedRedstone[aSide] : 0; + public byte getGeneralRS(byte aSide) { + if (mMetaTileEntity == null) return 0; + return mMetaTileEntity.allowGeneralRedstoneOutput() ? mSidedRedstone[aSide] : 0; } @@ -1598,7 +1599,6 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } - @Override public ItemStack decrStackSize(int aIndex, int aAmount) { if (canAccessData()) { @@ -1613,7 +1613,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (!canAccessData() || !mMetaTileEntity.isElectric() || !inputEnergyFrom(aSide) || aAmperage <= 0 || aVoltage <= 0 || getStoredEU() >= getEUCapacity() || mMetaTileEntity.maxAmperesIn() <= mAcceptedAmperes) return 0; if (aVoltage > getInputVoltage()) { - GT_Log.exp.println("Energy Explosion, injected "+aVoltage+"EU/t in a "+getInputVoltage()+"EU/t Machine!"); + GT_Log.exp.println("Energy Explosion, injected " + aVoltage + "EU/t in a " + getInputVoltage() + "EU/t Machine!"); doExplosion(aVoltage); return 0; } @@ -1654,10 +1654,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec (mRunningThroughTick || !mInputDisabled) && ( aSide == ForgeDirection.UNKNOWN || - ( - mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && - getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this) - ) + ( + mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && + getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this) + ) ) ) return mMetaTileEntity.fill(aSide, aFluid, doFill); @@ -1670,10 +1670,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec (mRunningThroughTick || !mOutputDisabled) && ( aSide == ForgeDirection.UNKNOWN || - ( - mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && - getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), mMetaTileEntity.getFluid() == null ? null : mMetaTileEntity.getFluid().getFluid(), this) - ) + ( + mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && + getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), mMetaTileEntity.getFluid() == null ? null : mMetaTileEntity.getFluid().getFluid(), this) + ) ) ) return mMetaTileEntity.drain(aSide, maxDrain, doDrain); @@ -1686,10 +1686,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec (mRunningThroughTick || !mOutputDisabled) && ( aSide == ForgeDirection.UNKNOWN || - ( - mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && - getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this) - ) + ( + mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && + getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this) + ) ) ) return mMetaTileEntity.drain(aSide, aFluid, doDrain); @@ -1702,10 +1702,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec (mRunningThroughTick || !mInputDisabled) && ( aSide == ForgeDirection.UNKNOWN || - ( - mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && - getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid, this) - ) + ( + mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && + getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid, this) + ) ) ) return mMetaTileEntity.canFill(aSide, aFluid); @@ -1718,10 +1718,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec (mRunningThroughTick || !mOutputDisabled) && ( aSide == ForgeDirection.UNKNOWN || - ( - mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && - getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid, this) - ) + ( + mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && + getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid, this) + ) ) ) return mMetaTileEntity.canDrain(aSide, aFluid); @@ -1735,10 +1735,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (canAccessData() && ( aSide == ForgeDirection.UNKNOWN || - ( - mMetaTileEntity.isLiquidInput(tSide) && getCoverBehaviorAtSideNew(tSide).letsFluidIn(tSide, getCoverIDAtSide(tSide), getComplexCoverDataAtSide(tSide), null, this)) || + ( + mMetaTileEntity.isLiquidInput(tSide) && getCoverBehaviorAtSideNew(tSide).letsFluidIn(tSide, getCoverIDAtSide(tSide), getComplexCoverDataAtSide(tSide), null, this)) || (mMetaTileEntity.isLiquidOutput(tSide) && getCoverBehaviorAtSideNew(tSide).letsFluidOut(tSide, getCoverIDAtSide(tSide), getComplexCoverDataAtSide(tSide), null, this) - ) + ) ) ) return mMetaTileEntity.getTankInfo(aSide); @@ -1918,76 +1918,78 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec mMetaTileEntity.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); } - /** - * Shifts the machine Inventory index according to the change in Input/Output Slots. - * This is NOT done automatically. If you want to change slot count for a machine this method needs to be adapted. - * Currently this method only works for GT_MetaTileEntity_BasicMachine - * @param slotIndex The original Inventory index - * @param nbtVersion The GregTech version in which the original Inventory Index was saved. - * @return The corrected Inventory index - */ - private int migrateInventoryIndex(int slotIndex, int nbtVersion){ - final int oldInputSize; - final int newInputSize; - final int oldOutputSize; - final int newOutputSize; - final int chemistryUpdateVersion = GT_Mod.calculateTotalGTVersion(509, 31); - final int configCircuitAdditionVersion = GT_Mod.calculateTotalGTVersion(509, 40); - // 4 is old GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT - if (nbtVersion < configCircuitAdditionVersion && getMetaTileEntity() instanceof GT_MetaTileEntity_BasicMachine && slotIndex >= 4) - slotIndex += 1; - if (mID >= 211 && mID <= 218) {//Assembler - if (nbtVersion < chemistryUpdateVersion) { - oldInputSize = 2; - oldOutputSize = 1; - } else { - return slotIndex; - } - newInputSize = 6; - newOutputSize = 1; - - - } else if (mID >= 421 && mID <= 428){//Chemical Reactor - if (nbtVersion < chemistryUpdateVersion) { - oldInputSize = 2; - oldOutputSize = 1; - } else { - return slotIndex; - } - newInputSize = 2; - newOutputSize = 2; - - } else if (mID >= 531 && mID <= 538) {//Distillery - if (nbtVersion < chemistryUpdateVersion) { - oldInputSize = 1; - oldOutputSize = 0; - } else { - return slotIndex; - } - newInputSize = 1; - newOutputSize = 1; - } else if (mID >= 581 && mID <=588){//Mixer - if (nbtVersion < chemistryUpdateVersion) { - oldInputSize = 4; - oldOutputSize = 1; - }else{ - return slotIndex; - } - newInputSize = 6; - newOutputSize = 1; - - } else { - return slotIndex; - } - - int indexShift = 0; - if (slotIndex >= GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT + oldInputSize) {indexShift += newInputSize - oldInputSize; - } - if (slotIndex >= GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT + oldInputSize + oldOutputSize) { - indexShift += newOutputSize - oldOutputSize; - } - return slotIndex + indexShift; - } + /** + * Shifts the machine Inventory index according to the change in Input/Output Slots. + * This is NOT done automatically. If you want to change slot count for a machine this method needs to be adapted. + * Currently this method only works for GT_MetaTileEntity_BasicMachine + * + * @param slotIndex The original Inventory index + * @param nbtVersion The GregTech version in which the original Inventory Index was saved. + * @return The corrected Inventory index + */ + private int migrateInventoryIndex(int slotIndex, int nbtVersion) { + final int oldInputSize; + final int newInputSize; + final int oldOutputSize; + final int newOutputSize; + final int chemistryUpdateVersion = GT_Mod.calculateTotalGTVersion(509, 31); + final int configCircuitAdditionVersion = GT_Mod.calculateTotalGTVersion(509, 40); + // 4 is old GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT + if (nbtVersion < configCircuitAdditionVersion && getMetaTileEntity() instanceof GT_MetaTileEntity_BasicMachine && slotIndex >= 4) + slotIndex += 1; + if (mID >= 211 && mID <= 218) {//Assembler + if (nbtVersion < chemistryUpdateVersion) { + oldInputSize = 2; + oldOutputSize = 1; + } else { + return slotIndex; + } + newInputSize = 6; + newOutputSize = 1; + + + } else if (mID >= 421 && mID <= 428) {//Chemical Reactor + if (nbtVersion < chemistryUpdateVersion) { + oldInputSize = 2; + oldOutputSize = 1; + } else { + return slotIndex; + } + newInputSize = 2; + newOutputSize = 2; + + } else if (mID >= 531 && mID <= 538) {//Distillery + if (nbtVersion < chemistryUpdateVersion) { + oldInputSize = 1; + oldOutputSize = 0; + } else { + return slotIndex; + } + newInputSize = 1; + newOutputSize = 1; + } else if (mID >= 581 && mID <= 588) {//Mixer + if (nbtVersion < chemistryUpdateVersion) { + oldInputSize = 4; + oldOutputSize = 1; + } else { + return slotIndex; + } + newInputSize = 6; + newOutputSize = 1; + + } else { + return slotIndex; + } + + int indexShift = 0; + if (slotIndex >= GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT + oldInputSize) { + indexShift += newInputSize - oldInputSize; + } + if (slotIndex >= GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT + oldInputSize + oldOutputSize) { + indexShift += newOutputSize - oldOutputSize; + } + return slotIndex + indexShift; + } @Override @Optional.Method(modid = "appliedenergistics2") @@ -2002,18 +2004,19 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Optional.Method(modid = "appliedenergistics2") public AECableType getCableConnectionType(ForgeDirection forgeDirection) { return mMetaTileEntity == null ? AECableType.NONE : mMetaTileEntity.getCableConnectionType(forgeDirection); - } + } @Override @Optional.Method(modid = "appliedenergistics2") - public void securityBreak() {} + public void securityBreak() { + } @Override @Optional.Method(modid = "appliedenergistics2") public IGridNode getActionableNode() { final AENetworkProxy gp = getProxy(); return gp != null ? gp.getNode() : null; - } + } @Override @Optional.Method(modid = "appliedenergistics2") @@ -2023,7 +2026,9 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override @Optional.Method(modid = "appliedenergistics2") - public DimensionalCoord getLocation() { return new DimensionalCoord( this ); } + public DimensionalCoord getLocation() { + return new DimensionalCoord(this); + } @Override @Optional.Method(modid = "appliedenergistics2") @@ -2032,22 +2037,20 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec mMetaTileEntity.gridChanged(); } - @TileEvent( TileEventType.WORLD_NBT_READ ) + @TileEvent(TileEventType.WORLD_NBT_READ) @Optional.Method(modid = "appliedenergistics2") - public void readFromNBT_AENetwork( final NBTTagCompound data ) - { + public void readFromNBT_AENetwork(final NBTTagCompound data) { final AENetworkProxy gp = getProxy(); if (gp != null) - getProxy().readFromNBT( data ); + getProxy().readFromNBT(data); } - @TileEvent( TileEventType.WORLD_NBT_WRITE ) + @TileEvent(TileEventType.WORLD_NBT_WRITE) @Optional.Method(modid = "appliedenergistics2") - public void writeToNBT_AENetwork( final NBTTagCompound data ) - { + public void writeToNBT_AENetwork(final NBTTagCompound data) { final AENetworkProxy gp = getProxy(); if (gp != null) - gp.writeToNBT( data ); + gp.writeToNBT(data); } @Optional.Method(modid = "appliedenergistics2") @@ -2066,12 +2069,12 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override public boolean wasShutdown() { - return mWasShutdown; + return mWasShutdown; } @Override public void setShutdownStatus(boolean newStatus) { - mWasShutdown = newStatus; + mWasShutdown = newStatus; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index 6230940058..58e7131f43 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -8,14 +8,18 @@ import cpw.mods.fml.relauncher.SideOnly; import gnu.trove.list.TIntList; import gnu.trove.list.array.TIntArrayList; import gregtech.api.GregTech_API; +import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.metatileentity.IMachineCallback; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; import gregtech.common.GT_Client; -import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_Cleanroom; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import net.minecraft.block.Block; @@ -944,7 +948,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac aExplosionPower < V[15] ? 19.0F : 20.0F; int tX = getBaseMetaTileEntity().getXCoord(), tY = getBaseMetaTileEntity().getYCoord(), tZ = getBaseMetaTileEntity().getZCoord(); World tWorld = getBaseMetaTileEntity().getWorld(); - GT_Utility.sendSoundToPlayers(tWorld, GregTech_API.sSoundList.get(209), 1.0F, -1, tX, tY, tZ); + GT_Utility.sendSoundToPlayers(tWorld, SoundResource.IC2_MACHINES_MACHINE_OVERLOAD, 1.0F, -1, tX, tY, tZ); 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); diff --git a/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java b/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java index 65993f2941..431ed3cc30 100644 --- a/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java +++ b/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java @@ -1,6 +1,6 @@ package gregtech.api.metatileentity.examples; -import gregtech.api.GregTech_API; +import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -76,7 +76,7 @@ public class GT_MetaTileEntity_E_Furnace extends GT_MetaTileEntity_BasicMachine @Override 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(207), 10, 1.0F, aX, aY, aZ); + if (aIndex == 1) GT_Utility.doSoundAtClient(SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP, 10, 1.0F, aX, aY, aZ); } @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 12485806b3..c67c7d6e41 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 @@ -3,10 +3,8 @@ package gregtech.api.metatileentity.implementations; import cpw.mods.fml.common.Optional; import gregtech.GT_Mod; import gregtech.api.GregTech_API; -import gregtech.api.enums.Dyes; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.Textures; +import gregtech.api.enums.ParticleFX; +import gregtech.api.enums.*; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; @@ -14,12 +12,8 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_CoverBehavior; -import gregtech.api.util.GT_CoverBehaviorBase; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; -import gregtech.api.util.ISerializableObject; -import gregtech.api.util.WorldSpawnedEventBuilder; +import gregtech.api.util.*; +import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; import gregtech.common.GT_Client; import gregtech.common.covers.GT_Cover_Drain; import gregtech.common.covers.GT_Cover_FluidRegulator; @@ -105,12 +99,12 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { return new ITexture[]{aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) : TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; byte tMask = 0; byte[][] sRestrictionArray = { - {2, 3, 5, 4}, - {2, 3, 4, 5}, - {1, 0, 4, 5}, - {1, 0, 4, 5}, - {1, 0, 2, 3}, - {1, 0, 2, 3} + {2, 3, 5, 4}, + {2, 3, 4, 5}, + {1, 0, 4, 5}, + {1, 0, 4, 5}, + {1, 0, 2, 3}, + {1, 0, 2, 3} }; if (aSide >= 0 && aSide < 6) { for (byte i = 0; i < 4; i++) if (isInputDisabledAtSide(sRestrictionArray[aSide][i])) tMask |= 1 << i; @@ -140,7 +134,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); } - protected static final ITexture getRestrictorTexture(byte aMask) { + protected static ITexture getRestrictorTexture(byte aMask) { switch (aMask) { case 1: return TextureFactory.of(Textures.BlockIcons.PIPE_RESTRICTOR_UP); @@ -348,8 +342,8 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { final IGregTechTileEntity gTank = tTank instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTank : null; if (isConnectedAtSide(aSide) && tTank != null && (mLastReceivedFrom & (1 << aSide)) == 0 && - getBaseMetaTileEntity().getCoverBehaviorAtSideNew(aSide).letsFluidOut(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), tFluid.getFluid(), getBaseMetaTileEntity()) && - (gTank == null || gTank.getCoverBehaviorAtSideNew(tSide).letsFluidIn(tSide, gTank.getCoverIDAtSide(tSide), gTank.getComplexCoverDataAtSide(tSide), tFluid.getFluid(), gTank))) { + getBaseMetaTileEntity().getCoverBehaviorAtSideNew(aSide).letsFluidOut(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), tFluid.getFluid(), getBaseMetaTileEntity()) && + (gTank == null || gTank.getCoverBehaviorAtSideNew(tSide).letsFluidIn(tSide, gTank.getCoverIDAtSide(tSide), gTank.getComplexCoverDataAtSide(tSide), tFluid.getFluid(), gTank))) { if (tTank.fill(ForgeDirection.getOrientation(tSide), tFluid, false) > 0) { tTanks.add(new MutableTriple<>(tTank, ForgeDirection.getOrientation(tSide), 0)); } @@ -455,8 +449,8 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { final FluidTankInfo[] tInfo = fTileEntity.getTankInfo(ForgeDirection.getOrientation(tSide)); if (tInfo != null) { return tInfo.length > 0 - || (GregTech_API.mTranslocator && isTranslocator(tTileEntity)) - || gTileEntity != null && gTileEntity.getCoverBehaviorAtSideNew(tSide) instanceof GT_Cover_FluidRegulator; + || (GregTech_API.mTranslocator && isTranslocator(tTileEntity)) + || gTileEntity != null && gTileEntity.getCoverBehaviorAtSideNew(tSide) instanceof GT_Cover_FluidRegulator; } } @@ -485,23 +479,23 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { public void doSound(byte aIndex, double aX, double aY, double aZ) { super.doSound(aIndex, aX, aY, aZ); if (aIndex == 9) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(4), 5, 1.0F, aX, aY, aZ); + GT_Utility.doSoundAtClient(SoundResource.RANDOM_FIZZ, 5, 1.0F, aX, aY, aZ); - new WorldSpawnedEventBuilder.ParticleEventBuilder() - .setIdentifier("largesmoke") - .setWorld(getBaseMetaTileEntity().getWorld()) - .<WorldSpawnedEventBuilder.ParticleEventBuilder>times(6, (x, i) -> x - .setMotion( - ForgeDirection.getOrientation(i).offsetX / 5.0, - ForgeDirection.getOrientation(i).offsetY / 5.0, - ForgeDirection.getOrientation(i).offsetZ / 5.0 - ) - .setPosition( - aX - 0.5 + XSTR_INSTANCE.nextFloat(), - aY - 0.5 + XSTR_INSTANCE.nextFloat(), - aZ - 0.5 + XSTR_INSTANCE.nextFloat() - ).run() - ); + new ParticleEventBuilder() + .setIdentifier(ParticleFX.CLOUD) + .setWorld(getBaseMetaTileEntity().getWorld()) + .<ParticleEventBuilder>times(6, (x, i) -> x + .setMotion( + ForgeDirection.getOrientation(i).offsetX / 5.0, + ForgeDirection.getOrientation(i).offsetY / 5.0, + ForgeDirection.getOrientation(i).offsetZ / 5.0 + ) + .setPosition( + aX - 0.5 + XSTR_INSTANCE.nextFloat(), + aY - 0.5 + XSTR_INSTANCE.nextFloat(), + aZ - 0.5 + XSTR_INSTANCE.nextFloat() + ).run() + ); } } @@ -574,7 +568,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { return fill_default_intoIndex(aSide, aFluid, doFill, index); } - private final int fill_default_intoIndex(ForgeDirection aSide, FluidStack aFluid, boolean doFill, int index) { + private int fill_default_intoIndex(ForgeDirection aSide, FluidStack aFluid, boolean doFill, int index) { if (index < 0 || index >= mPipeAmount) return 0; if (aFluid == null || aFluid.getFluid().getID() <= 0) return 0; @@ -613,7 +607,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { @Override public final FluidStack drain(int maxDrain, boolean doDrain) { - FluidStack drained = null; + FluidStack drained; for (int i = 0; i < mPipeAmount; i++) { if ((drained = drainFromIndex(maxDrain, doDrain, i)) != null) return drained; @@ -621,7 +615,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { return null; } - private final FluidStack drainFromIndex(int maxDrain, boolean doDrain, int index) { + private FluidStack drainFromIndex(int maxDrain, boolean doDrain, int index) { if (index < 0 || index >= mPipeAmount) return null; if (mFluids[index] == null) return null; if (mFluids[index].amount <= 0) { @@ -656,14 +650,14 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { public String[] getDescription() { if (mPipeAmount == 1) { return new String[]{ - EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + GT_Utility.formatNumbers(mCapacity * 20) + "%%% L/sec" + EnumChatFormatting.GRAY, - EnumChatFormatting.RED + "Heat Limit: %%%" + GT_Utility.formatNumbers(mHeatResistance) + "%%% K" + EnumChatFormatting.GRAY + EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + GT_Utility.formatNumbers(mCapacity * 20L) + "%%% L/sec" + EnumChatFormatting.GRAY, + EnumChatFormatting.RED + "Heat Limit: %%%" + GT_Utility.formatNumbers(mHeatResistance) + "%%% K" + EnumChatFormatting.GRAY }; } else { return new String[]{ - EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + GT_Utility.formatNumbers(mCapacity * 20) + "%%% L/sec" + EnumChatFormatting.GRAY, - EnumChatFormatting.RED + "Heat Limit: %%%" + GT_Utility.formatNumbers(mHeatResistance) + "%%% K" + EnumChatFormatting.GRAY, - EnumChatFormatting.AQUA + "Pipe Amount: %%%" + mPipeAmount + EnumChatFormatting.GRAY + EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + GT_Utility.formatNumbers(mCapacity * 20L) + "%%% L/sec" + EnumChatFormatting.GRAY, + EnumChatFormatting.RED + "Heat Limit: %%%" + GT_Utility.formatNumbers(mHeatResistance) + "%%% K" + EnumChatFormatting.GRAY, + EnumChatFormatting.AQUA + "Pipe Amount: %%%" + mPipeAmount + EnumChatFormatting.GRAY }; } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 85ebcc0e17..bfc8fd0096 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -3,6 +3,7 @@ package gregtech.api.metatileentity.implementations; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; +import gregtech.api.enums.SoundResource; import gregtech.api.gui.GT_Container_BasicMachine; import gregtech.api.gui.GT_GUIContainer_BasicMachine; import gregtech.api.interfaces.ITexture; @@ -716,7 +717,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public void doSound(byte aIndex, double aX, double aY, double aZ) { super.doSound(aIndex, aX, aY, aZ); - if (aIndex == 8) GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(210), 100, 1.0F, aX, aY, aZ); + if (aIndex == 8) GT_Utility.doSoundAtClient(SoundResource.IC2_MACHINES_INTERRUPT_ONE, 100, 1.0F, aX, aY, aZ); } public boolean doesAutoOutput() { 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 02e94a7ea9..f185a9c246 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 @@ -1,17 +1,19 @@ package gregtech.api.metatileentity.implementations; import gregtech.api.GregTech_API; +import gregtech.api.enums.ParticleFX; import gregtech.api.enums.Dyes; +import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Log; -import gregtech.common.power.Power; import gregtech.api.util.GT_Recipe; -import gregtech.common.power.SteamPower; import gregtech.api.util.GT_Utility; -import gregtech.api.util.WorldSpawnedEventBuilder; +import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; +import gregtech.common.power.Power; +import gregtech.common.power.SteamPower; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; @@ -20,13 +22,7 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; import static gregtech.api.enums.GT_Values.D1; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_BRONZE_BOTTOM; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_BRONZE_SIDE; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_BRONZE_TOP; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; +import static gregtech.api.enums.Textures.BlockIcons.*; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; /** @@ -43,7 +39,7 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileE super(aID, aName, aNameRegional, aHighPressure ? 2 : 1, 0, aDescription, aInputSlotCount, aOutputSlotCount, "", ""); } - public GT_MetaTileEntity_BasicMachine_Bronze(String aName, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, boolean aHighPressure) { + public GT_MetaTileEntity_BasicMachine_Bronze(String aName, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, boolean aHighPressure) { super(aName, aHighPressure ? 2 : 1, 0, aDescription, aTextures, aInputSlotCount, aOutputSlotCount, "", ""); } @@ -185,23 +181,23 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileE public void doSound(byte aIndex, double aX, double aY, double aZ) { super.doSound(aIndex, aX, aY, aZ); if (aIndex == 9) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(4), 5, 1.0F, aX, aY, aZ); - - new WorldSpawnedEventBuilder.ParticleEventBuilder() - .setIdentifier("largesmoke") - .setWorld(getBaseMetaTileEntity().getWorld()) - .setMotion( - ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetX / 5.0, - ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetY / 5.0, - ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetZ / 5.0 - ) - .<WorldSpawnedEventBuilder.ParticleEventBuilder>times(8, x -> x - .setPosition( - aX - 0.5 + XSTR_INSTANCE.nextFloat(), - aY - 0.5 + XSTR_INSTANCE.nextFloat(), - aZ - 0.5 + XSTR_INSTANCE.nextFloat() - ).run() - ); + GT_Utility.doSoundAtClient(SoundResource.RANDOM_FIZZ, 5, 1.0F, aX, aY, aZ); + + new ParticleEventBuilder() + .setIdentifier(ParticleFX.CLOUD) + .setWorld(getBaseMetaTileEntity().getWorld()) + .setMotion( + ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetX / 5.0, + ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetY / 5.0, + ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetZ / 5.0 + ) + .<ParticleEventBuilder>times(8, x -> x + .setPosition( + aX - 0.5 + XSTR_INSTANCE.nextFloat(), + aY - 0.5 + XSTR_INSTANCE.nextFloat(), + aZ - 0.5 + XSTR_INSTANCE.nextFloat() + ).run() + ); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java index feeebf0cf4..46c11f5e7a 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,11 @@ 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 cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.ParticleFX; +import gregtech.api.enums.*; import gregtech.api.enums.Textures.BlockIcons.CustomIcon; -import gregtech.api.enums.Tier; import gregtech.api.gui.GT_Container_BasicMachine; import gregtech.api.gui.GT_GUIContainer_BasicMachine; import gregtech.api.interfaces.ITexture; @@ -17,20 +17,24 @@ import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.api.util.WorldSpawnedEventBuilder; +import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; import ic2.core.Ic2Items; +import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; 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.objects.XSTR.XSTR_INSTANCE; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -40,15 +44,16 @@ import static gregtech.api.enums.GT_Values.ticksBetweenSounds; */ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_BasicMachine { private final GT_Recipe.GT_Recipe_Map mRecipes; - private final int mTankCapacity, mSpecialEffect; - private final String mSound; + private final int mTankCapacity; + private final SpecialEffects mSpecialEffect; + private final ResourceLocation mSoundResourceLocation; private final boolean mSharedTank, mRequiresFluidForFiltering; private final byte mGUIParameterA, mGUIParameterB; public GT_MetaTileEntity_BasicMachine_GT_Recipe( - int aID, String aName, String aNameRegional, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes, - int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, String aSound, boolean aSharedTank, - boolean aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, Object[] aRecipe + int aID, String aName, String aNameRegional, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes, + int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, ResourceLocation aSound, boolean aSharedTank, + boolean aRequiresFluidForFiltering, SpecialEffects aSpecialEffect, String aOverlays, Object[] aRecipe ) { super(aID, aName, aNameRegional, aTier, aRecipes.mAmperage, aDescription, aInputSlots, aOutputSlots, aGUIName, aRecipes.mNEIName, TextureFactory.of( @@ -81,7 +86,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ this.mSpecialEffect = aSpecialEffect; this.mRequiresFluidForFiltering = aRequiresFluidForFiltering; this.mRecipes = aRecipes; - this.mSound = aSound; + this.mSoundResourceLocation = aSound; this.mGUIParameterA = (byte) aGUIParameterA; this.mGUIParameterB = (byte) aGUIParameterB; @@ -124,12 +129,12 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ case 7: case 8: if (Loader.isModLoaded("bartworks")) {//todo remove via provider pattern on all enums? - aRecipe[i] = "blockGlass"+VN[aTier]; + aRecipe[i] = "blockGlass" + VN[aTier]; break; } default: if (Loader.isModLoaded("bartworks")) {//todo remove via provider pattern on all enums? - aRecipe[i] = "blockGlass"+VN[8]; + aRecipe[i] = "blockGlass" + VN[8]; } else { aRecipe[i] = Ic2Items.reinforcedGlass; } @@ -697,7 +702,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ if ( !GT_ModHandler.addCraftingRecipe( - getStackForm(1), + getStackForm(1), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, aRecipe ) ) { @@ -707,33 +712,62 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ } public GT_MetaTileEntity_BasicMachine_GT_Recipe( - String aName, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, - int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, + int aID, String aName, String aNameRegional, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes, + int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, SoundResource aSound, boolean aSharedTank, + boolean aRequiresFluidForFiltering, SpecialEffects aSpecialEffect, String aOverlays, Object[] aRecipe + ) { + this( + aID, aName, aNameRegional, aTier, aDescription, aRecipes, + aInputSlots, aOutputSlots, aTankCapacity, aGUIParameterA, aGUIParameterB, aGUIName, aSound.resourceLocation, aSharedTank, + aRequiresFluidForFiltering, aSpecialEffect, aOverlays, aRecipe); + } + + /** + * @inheritDoc + * @deprecated Use {@link #GT_MetaTileEntity_BasicMachine_GT_Recipe( + * int aID, String, String, int, String, GT_Recipe.GT_Recipe_Map, + * int, int, int, int, int, String, ResourceLocation, boolean, + * boolean, SpecialEffects, String , Object[])} + */ + @Deprecated + public GT_MetaTileEntity_BasicMachine_GT_Recipe( + int aID, String aName, String aNameRegional, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes, + int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, String aSound, boolean aSharedTank, + boolean aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, Object[] aRecipe + ) { + this(aID, aName, aNameRegional, aTier, aDescription, aRecipes, + aInputSlots, aOutputSlots, aTankCapacity, aGUIParameterA, aGUIParameterB, aGUIName, new ResourceLocation(aSound), aSharedTank, + aRequiresFluidForFiltering, SpecialEffects.fromId(aSpecialEffect), aOverlays, aRecipe); + } + + public GT_MetaTileEntity_BasicMachine_GT_Recipe( + String aName, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, + int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect ) { super(aName, aTier, aAmperage, aDescription, aTextures, aInputSlots, aOutputSlots, aGUIName, aNEIName); this.mSharedTank = aSharedTank; this.mTankCapacity = aTankCapacity; - this.mSpecialEffect = aSpecialEffect; + this.mSpecialEffect = SpecialEffects.fromId(aSpecialEffect); this.mRequiresFluidForFiltering = aRequiresFluidForFiltering; this.mRecipes = aRecipes; - this.mSound = aSound; + this.mSoundResourceLocation = new ResourceLocation(aSound); this.mGUIParameterA = (byte) aGUIParameterA; this.mGUIParameterB = (byte) aGUIParameterB; } public GT_MetaTileEntity_BasicMachine_GT_Recipe( - String aName, int aTier, String[] aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, - int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, + String aName, int aTier, String[] aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, + int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect ) { super(aName, aTier, aAmperage, aDescription, aTextures, aInputSlots, aOutputSlots, aGUIName, aNEIName); this.mSharedTank = aSharedTank; this.mTankCapacity = aTankCapacity; - this.mSpecialEffect = aSpecialEffect; + this.mSpecialEffect = SpecialEffects.fromId(aSpecialEffect); this.mRequiresFluidForFiltering = aRequiresFluidForFiltering; this.mRecipes = aRecipes; - this.mSound = aSound; + this.mSoundResourceLocation = new ResourceLocation(aSound); this.mGUIParameterA = (byte) aGUIParameterA; this.mGUIParameterB = (byte) aGUIParameterB; } @@ -741,9 +775,9 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_BasicMachine_GT_Recipe( - this.mName, this.mTier, this.mDescriptionArray, this.mRecipes, this.mInputSlotCount, this.mOutputItems == null ? 0 : this.mOutputItems.length, - this.mTankCapacity, this.mAmperage, this.mGUIParameterA, this.mGUIParameterB, this.mTextures, this.mGUIName, this.mNEIName, this.mSound, - this.mSharedTank, this.mRequiresFluidForFiltering, this.mSpecialEffect + this.mName, this.mTier, this.mDescriptionArray, this.mRecipes, this.mInputSlotCount, this.mOutputItems == null ? 0 : this.mOutputItems.length, + this.mTankCapacity, this.mAmperage, this.mGUIParameterA, this.mGUIParameterB, this.mTextures, this.mGUIName, this.mNEIName, this.mSoundResourceLocation.toString(), + this.mSharedTank, this.mRequiresFluidForFiltering, this.mSpecialEffect.ordinal() ); } @@ -755,8 +789,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_GUIContainer_BasicMachine( - aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), this.mGUIName, - GT_Utility.isStringValid(this.mNEIName) ? this.mNEIName : this.getRecipeList() != null ? this.getRecipeList().mUnlocalizedName : "", + aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), this.mGUIName, + GT_Utility.isStringValid(this.mNEIName) ? this.mNEIName : this.getRecipeList() != null ? this.getRecipeList().mUnlocalizedName : "", this.mGUIParameterA, this.mGUIParameterB ); } @@ -772,33 +806,33 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ return !this.mRequiresFluidForFiltering && this.getRecipeList().containsInput(aStack); else return this.getRecipeList().findRecipe( - this.getBaseMetaTileEntity(), this.mLastRecipe, true, true, V[this.mTier], new FluidStack[]{this.getFillableStack()}, - this.getSpecialSlot(), appendSelectedCircuit(aStack) - ) != null; + this.getBaseMetaTileEntity(), this.mLastRecipe, true, true, V[this.mTier], new FluidStack[]{this.getFillableStack()}, + this.getSpecialSlot(), appendSelectedCircuit(aStack) + ) != null; case 2: - + return ( - !this.mRequiresFluidForFiltering || this.getFillableStack() != null) && + !this.mRequiresFluidForFiltering || this.getFillableStack() != null) && ( ( - (this.getInputAt(0) != null && this.getInputAt(1) != null) || + (this.getInputAt(0) != null && this.getInputAt(1) != null) || ( - this.getInputAt(0) == null && this.getInputAt(1) == null ? - this.getRecipeList().containsInput(aStack) : + this.getInputAt(0) == null && this.getInputAt(1) == null ? + this.getRecipeList().containsInput(aStack) : ( - this.getRecipeList().containsInput(aStack) && - this.getRecipeList().findRecipe( - this.getBaseMetaTileEntity(), this.mLastRecipe, true, true, V[this.mTier], - new FluidStack[]{this.getFillableStack()}, - this.getSpecialSlot(), aIndex == this.getInputSlot() ? - appendSelectedCircuit(aStack, this.getInputAt(1)) : - appendSelectedCircuit(this.getInputAt(0), aStack) - ) != null + this.getRecipeList().containsInput(aStack) && + this.getRecipeList().findRecipe( + this.getBaseMetaTileEntity(), this.mLastRecipe, true, true, V[this.mTier], + new FluidStack[]{this.getFillableStack()}, + this.getSpecialSlot(), aIndex == this.getInputSlot() ? + appendSelectedCircuit(aStack, this.getInputAt(1)) : + appendSelectedCircuit(this.getInputAt(0), aStack) + ) != null ) ) ) ); - default:{ + default: { int tID = this.getBaseMetaTileEntity().getMetaTileID(); if (tID >= 211 && tID <= 218 || tID >= 1180 && tID <= 1187 || tID >= 10780 && tID <= 10786) { //assembler lv-iv; circuit asseblers lv - uv; assemblers luv-uev if (GT_Utility.isStackValid(aStack)) @@ -822,29 +856,102 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPreTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive()) { + //noinspection SwitchStatementWithTooFewBranches switch (this.mSpecialEffect) { - case 0: - break; - case 1: - if (aBaseMetaTileEntity.getFrontFacing() != 1 && aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0 && !aBaseMetaTileEntity.getOpacityAtSide((byte) 1)) { + case TOP_SMOKE: + + final byte topFacing = (byte) ForgeDirection.UP.ordinal(); + + if (aBaseMetaTileEntity.getFrontFacing() != topFacing + && aBaseMetaTileEntity.getCoverIDAtSide(topFacing) == 0 + && !aBaseMetaTileEntity.getOpacityAtSide(topFacing)) { - Random tRandom = aBaseMetaTileEntity.getWorld().rand; new WorldSpawnedEventBuilder.ParticleEventBuilder() - .setMotion(0.0D, 0.0D, 0.0D) - .setIdentifier("smoke") - .setPosition( - aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F, - aBaseMetaTileEntity.getYCoord() + 0.9F + tRandom.nextFloat() * 0.2F, - aBaseMetaTileEntity.getZCoord() + 0.8F - tRandom.nextFloat() * 0.6F - ) - .setWorld(aBaseMetaTileEntity.getWorld()) - .run(); + .setMotion(0.0D, 0.0D, 0.0D) + .setIdentifier(ParticleFX.SMOKE) + .setPosition( + aBaseMetaTileEntity.getXCoord() + 0.8F - XSTR_INSTANCE.nextFloat() * 0.6F, + aBaseMetaTileEntity.getYCoord() + 0.9F + XSTR_INSTANCE.nextFloat() * 0.2F, + aBaseMetaTileEntity.getZCoord() + 0.8F - XSTR_INSTANCE.nextFloat() * 0.6F + ) + .setWorld(aBaseMetaTileEntity.getWorld()) + .run(); } break; + default: + break; } } } + /** + * Handles {@link Block#randomDisplayTick} driven Special Effects + * + * @param aBaseMetaTileEntity The entity that will handle the {@see Block#randomDisplayTick} + */ + @SideOnly(Side.CLIENT) + @Override + public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { + + //noinspection SwitchStatementWithTooFewBranches + switch (this.mSpecialEffect) { + case MAIN_RANDOM_SPARKS: + // Random Sparkles at main face + if (aBaseMetaTileEntity.isActive() && XSTR_INSTANCE.nextInt(3) == 0) { + + final byte mainFacing = (byte) this.mMainFacing; + + if (mainFacing > 1 + && aBaseMetaTileEntity.getCoverIDAtSide(mainFacing) == 0 + && !aBaseMetaTileEntity.getOpacityAtSide(mainFacing)) { + + final double oX = aBaseMetaTileEntity.getXCoord(); + final double oY = aBaseMetaTileEntity.getYCoord(); + final double oZ = aBaseMetaTileEntity.getZCoord(); + final double offset = 0.02D; + final double horizontal = 0.5D + XSTR_INSTANCE.nextFloat() * 8D / 16D - 4D / 16D; + + final double x, y, z, mX, mZ; + + y = oY + XSTR_INSTANCE.nextFloat() * 10D / 16D + 5D / 16D; + + if (mainFacing == ForgeDirection.WEST.ordinal()) { + x = oX - offset; + mX = -.05D; + z = oZ + horizontal; + mZ = 0D; + } else if (mainFacing == ForgeDirection.EAST.ordinal()) { + x = oX + offset; + mX = .05D; + z = oZ + horizontal; + mZ = 0D; + } else if (mainFacing == ForgeDirection.NORTH.ordinal()) { + x = oX + horizontal; + mX = 0D; + z = oZ - offset; + mZ = -.05D; + } else // if (frontFacing == ForgeDirection.SOUTH.ordinal()) + { + x = oX + horizontal; + mX = 0D; + z = oZ + offset; + mZ = .05D; + } + + ParticleEventBuilder particleEventBuilder = + (new ParticleEventBuilder()) + .setMotion(mX, 0, mZ) + .setPosition(x, y, z) + .setWorld(getBaseMetaTileEntity().getWorld()); + particleEventBuilder.setIdentifier(ParticleFX.LAVA).run(); + } + } + break; + default: + break; + } + } + @Override public GT_Recipe.GT_Recipe_Map getRecipeList() { return this.mRecipes; @@ -858,7 +965,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ @Override public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1 && GT_Utility.isStringValid(this.mSound)) GT_Utility.doSoundAtClient(this.mSound, 100, 1.0F, aX, aY, aZ); + if (aIndex == 1 && GT_Utility.isStringValid(this.mSoundResourceLocation)) + GT_Utility.doSoundAtClient(this.mSoundResourceLocation, 100, 1.0F, aX, aY, aZ); } @Override @@ -866,7 +974,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ BaseMetaTileEntity myMetaTileEntity = ((BaseMetaTileEntity) this.getBaseMetaTileEntity()); // Added to throttle sounds. To reduce lag, this is on the server side so BlockUpdate packets aren't sent. if (myMetaTileEntity.mTickTimer > (myMetaTileEntity.mLastSoundTick+ticksBetweenSounds)) { - if (GT_Utility.isStringValid(this.mSound)) this.sendLoopStart((byte) 1); + if (GT_Utility.isStringValid(this.mSoundResourceLocation)) this.sendLoopStart((byte) 1); // Does not have overflow protection, but they are longs. myMetaTileEntity.mLastSoundTick = myMetaTileEntity.mTickTimer; } @@ -888,4 +996,23 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ } public enum X {PUMP, WIRE, WIRE4, HULL, PIPE, GLASS, PLATE, MOTOR, ROTOR, SENSOR, PISTON, CIRCUIT, EMITTER, CONVEYOR, ROBOT_ARM, COIL_HEATING, COIL_ELECTRIC, STICK_MAGNETIC, STICK_DISTILLATION, BETTER_CIRCUIT, FIELD_GENERATOR, COIL_HEATING_DOUBLE, STICK_ELECTROMAGNETIC} + + /** + * Special Effects + */ + public enum SpecialEffects { + NONE, + TOP_SMOKE, + MAIN_RANDOM_SPARKS; + + static final SpecialEffects[] VALID_SPECIAL_EFFECTS = { + NONE, + TOP_SMOKE, + MAIN_RANDOM_SPARKS + }; + + static SpecialEffects fromId(int id) { + return id >= 0 && id < VALID_SPECIAL_EFFECTS.length ? VALID_SPECIAL_EFFECTS[id] : NONE; + } + } } 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 fa8eb8a9df..6d59b4ff7f 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 @@ -3,6 +3,7 @@ package gregtech.api.metatileentity.implementations; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; +import gregtech.api.enums.ParticleFX; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -92,7 +93,7 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isClientSide() && this.getBaseMetaTileEntity().isActive()) { - pollutionParticles(this.getBaseMetaTileEntity().getWorld(), "largesmoke"); + pollutionParticles(this.getBaseMetaTileEntity().getWorld(), ParticleFX.LARGE_SMOKE.toString()); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 6fea43e960..87d2c65df5 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -1134,19 +1134,19 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } @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(); if(tag.getBoolean("incompleteStructure")) { - currenttip.add(RED + "** INCOMPLETE STRUCTURE **" + RESET); + currentTip.add(RED + "** INCOMPLETE STRUCTURE **" + RESET); } - currenttip.add((tag.getBoolean("hasProblems") ? (RED + "** HAS PROBLEMS **") : GREEN + "Running Fine") + RESET + currentTip.add((tag.getBoolean("hasProblems") ? (RED + "** HAS PROBLEMS **") : GREEN + "Running Fine") + RESET + " Efficiency: " + tag.getFloat("efficiency") + "%"); - currenttip.add(String.format("Progress: %d s / %d s", tag.getInteger("progress"), tag.getInteger("maxProgress"))); + currentTip.add(String.format("Progress: %d s / %d s", tag.getInteger("progress"), tag.getInteger("maxProgress"))); - super.getWailaBody(itemStack, currenttip, accessor, config); + super.getWailaBody(itemStack, currentTip, accessor, config); } @Override diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_Sound.java b/src/main/java/gregtech/api/threads/GT_Runnable_Sound.java index dad93ff98c..441d46ad58 100644 --- a/src/main/java/gregtech/api/threads/GT_Runnable_Sound.java +++ b/src/main/java/gregtech/api/threads/GT_Runnable_Sound.java @@ -2,32 +2,41 @@ package gregtech.api.threads; import gregtech.api.util.GT_PlayedSound; import gregtech.api.util.GT_Utility; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class GT_Runnable_Sound implements Runnable { private final int mX, mY, mZ, mTimeUntilNextSound; private final World mWorld; - private final String mSoundName; + private final ResourceLocation mSoundResourceLocation; private final float mSoundStrength, mSoundModulation; - public GT_Runnable_Sound(World aWorld, int aX, int aY, int aZ, int aTimeUntilNextSound, String aSoundName, float aSoundStrength, float aSoundModulation) { + public GT_Runnable_Sound(World aWorld, int aX, int aY, int aZ, int aTimeUntilNextSound, ResourceLocation aSoundResourceLocation, float aSoundStrength, float aSoundModulation) { mWorld = aWorld; mX = aX; mY = aY; mZ = aZ; mTimeUntilNextSound = aTimeUntilNextSound; - mSoundName = aSoundName; + mSoundResourceLocation = aSoundResourceLocation; mSoundStrength = aSoundStrength; mSoundModulation = aSoundModulation; } + /** + * @deprecated Use {@link #GT_Runnable_Sound(World, int, int, int, int, ResourceLocation, float, float)} + */ + @Deprecated + public GT_Runnable_Sound(World aWorld, int aX, int aY, int aZ, int aTimeUntilNextSound, String aSoundName, float aSoundStrength, float aSoundModulation) { + this(aWorld, aX, aY, aZ, aTimeUntilNextSound, new ResourceLocation(aSoundName), aSoundStrength, aSoundModulation); + } + @Override public void run() { try { GT_PlayedSound tSound; - if (GT_Utility.sPlayedSoundMap.keySet().contains(tSound = new GT_PlayedSound(mSoundName, mX, mY, mZ))) + if (GT_Utility.sPlayedSoundMap.containsKey(tSound = new GT_PlayedSound(mSoundResourceLocation, mX, mY, mZ))) return; - mWorld.playSound(mX, mY, mZ, mSoundName, mSoundStrength, mSoundModulation, false); + mWorld.playSound(mX, mY, mZ, mSoundResourceLocation.toString(), mSoundStrength, mSoundModulation, false); GT_Utility.sPlayedSoundMap.put(tSound, mTimeUntilNextSound); } catch (Throwable e) {/**/} } diff --git a/src/main/java/gregtech/api/util/GT_FoodStat.java b/src/main/java/gregtech/api/util/GT_FoodStat.java index 193977476a..87c38a8073 100644 --- a/src/main/java/gregtech/api/util/GT_FoodStat.java +++ b/src/main/java/gregtech/api/util/GT_FoodStat.java @@ -1,6 +1,7 @@ package gregtech.api.util; import gregtech.api.damagesources.GT_DamageSources; +import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.IFoodStat; import gregtech.api.items.GT_MetaBase_Item; import net.minecraft.entity.player.EntityPlayer; @@ -70,7 +71,7 @@ public class GT_FoodStat implements IFoodStat { aPlayer.dropPlayerItemWithRandomChoice(tStack, true); new WorldSpawnedEventBuilder.SoundAtEntityEventBuilder() - .setIdentifier("random.burp") + .setIdentifier(SoundResource.RANDOM_BURP) .setVolume(0.5F) .setPitch(aPlayer.worldObj.rand.nextFloat() * 0.1F + 0.9F) .setEntity(aPlayer) diff --git a/src/main/java/gregtech/api/util/GT_PlayedSound.java b/src/main/java/gregtech/api/util/GT_PlayedSound.java index 82c728ff8b..fa27bbb9d4 100644 --- a/src/main/java/gregtech/api/util/GT_PlayedSound.java +++ b/src/main/java/gregtech/api/util/GT_PlayedSound.java @@ -1,18 +1,29 @@ package gregtech.api.util; +import net.minecraft.util.ResourceLocation; + import static gregtech.api.enums.GT_Values.E; public class GT_PlayedSound { public final String mSoundName; public final int mX, mY, mZ; - public GT_PlayedSound(String aSoundName, double aX, double aY, double aZ) { - mSoundName = aSoundName == null ? E : aSoundName; + public GT_PlayedSound(ResourceLocation aSoundResourceLocation, double aX, double aY, double aZ) { + mSoundName = aSoundResourceLocation.toString(); mX = (int) aX; mY = (int) aY; mZ = (int) aZ; } + /** + * @inheritDoc + * @deprecated Use {@link GT_PlayedSound(ResourceLocation, double, double, double)} + */ + @Deprecated + public GT_PlayedSound(String aSoundName, double aX, double aY, double aZ) { + this(new ResourceLocation(aSoundName == null ? E : aSoundName), aX, aY, aZ); + } + @Override public boolean equals(Object aObject) { if (aObject instanceof GT_PlayedSound) { diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 70659c7003..e244bb4460 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -14,13 +14,7 @@ import gregtech.api.GregTech_API; import gregtech.api.damagesources.GT_DamageSources; import gregtech.api.damagesources.GT_DamageSources.DamageSourceHotItem; import gregtech.api.enchants.Enchantment_Radioactivity; -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.SubTag; -import gregtech.api.enums.Textures; -import gregtech.api.enums.ToolDictNames; +import gregtech.api.enums.*; import gregtech.api.events.BlockScanningEvent; import gregtech.api.interfaces.IBlockContainer; import gregtech.api.interfaces.IDebugableBlock; @@ -76,11 +70,7 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.DamageSource; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.MathHelper; +import net.minecraft.util.*; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraft.world.chunk.Chunk; @@ -1387,7 +1377,7 @@ public class GT_Utility { } } ItemStack[] tStack = GT_OreDictUnificator.getStackArray(true, aOutput); - if(tStack==null||(tStack.length>0&& areStacksEqual(aInput, tStack[0])))return false; + if(tStack.length > 0 && areStacksEqual(aInput, tStack[0]))return false; if (tOreName != null) { if(tOreName.toString().equals("dustAsh")&&tStack[0].getUnlocalizedName().equals("tile.volcanicAsh"))return false; aRecipeList.put(new RecipeInputOreDict(tOreName.toString(), aInput.stackSize), new RecipeOutput(aNBT, tStack)); @@ -1443,31 +1433,91 @@ public class GT_Utility { return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, GT.getThePlayer()); } + public static boolean doSoundAtClient(SoundResource sound, int aTimeUntilNextSound, float aSoundStrength) { + return doSoundAtClient(sound.resourceLocation, aTimeUntilNextSound, aSoundStrength, GT.getThePlayer()); + } + + public static boolean doSoundAtClient(ResourceLocation aSoundResourceLocation, int aTimeUntilNextSound, float aSoundStrength) { + return doSoundAtClient(aSoundResourceLocation, aTimeUntilNextSound, aSoundStrength, GT.getThePlayer()); + } + public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, Entity aEntity) { if (aEntity == null) return false; return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, aEntity.posX, aEntity.posY, aEntity.posZ); } + public static boolean doSoundAtClient(ResourceLocation aSoundResourceLocation, int aTimeUntilNextSound, float aSoundStrength, Entity aEntity) { + if (aEntity == null) return false; + return doSoundAtClient(aSoundResourceLocation.toString(), aTimeUntilNextSound, aSoundStrength, aEntity.posX, aEntity.posY, aEntity.posZ); + } + + public static boolean doSoundAtClient(ResourceLocation aSoundResourceLocation, int aTimeUntilNextSound, float aSoundStrength, double aX, double aY, double aZ) { + return doSoundAtClient(aSoundResourceLocation, aTimeUntilNextSound, aSoundStrength, 1.01818028F, aX, aY, aZ); + } + + /** + * @inheritDoc + * @deprecated Use {@link #doSoundAtClient(ResourceLocation, int, float, double, double, double)} + */ + @Deprecated public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, double aX, double aY, double aZ) { - return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, 1.01818028F, aX, aY, aZ); + return doSoundAtClient(new ResourceLocation(aSoundName), aTimeUntilNextSound, aSoundStrength, 1.01818028F, aX, aY, aZ); } - public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, float aSoundModulation, double aX, double aY, double aZ) { - if (isStringInvalid(aSoundName) || !FMLCommonHandler.instance().getEffectiveSide().isClient() || GT.getThePlayer() == null || !GT.getThePlayer().worldObj.isRemote) + public static boolean doSoundAtClient(SoundResource aSound, int aTimeUntilNextSound, float aSoundStrength, double aX, double aY, double aZ) { + return doSoundAtClient(aSound.resourceLocation, aTimeUntilNextSound, aSoundStrength, aX, aY, aZ); + } + + public static boolean doSoundAtClient( + SoundResource aSound, int aTimeUntilNextSound, float aSoundStrength, float aSoundModulation, + double aX, double aY, double aZ) { + return doSoundAtClient(aSound.resourceLocation, aTimeUntilNextSound, aSoundStrength, aSoundModulation, aX, aY, aZ); + } + + + public static boolean doSoundAtClient( + ResourceLocation aSoundResourceLocation, int aTimeUntilNextSound, float aSoundStrength, float aSoundModulation, + double aX, double aY, double aZ) { + if (!FMLCommonHandler.instance().getEffectiveSide().isClient() + || GT.getThePlayer() == null + || !GT.getThePlayer().worldObj.isRemote) return false; if (GregTech_API.sMultiThreadedSounds) - new Thread(new GT_Runnable_Sound(GT.getThePlayer().worldObj, MathHelper.floor_double(aX), MathHelper.floor_double(aY), MathHelper.floor_double(aZ), aTimeUntilNextSound, aSoundName, aSoundStrength, aSoundModulation), "Sound Effect").start(); + new Thread(new GT_Runnable_Sound( + GT.getThePlayer().worldObj, + MathHelper.floor_double(aX), MathHelper.floor_double(aY), MathHelper.floor_double(aZ), + aTimeUntilNextSound, aSoundResourceLocation, aSoundStrength, aSoundModulation), "Sound Effect") + .start(); else - new GT_Runnable_Sound(GT.getThePlayer().worldObj, MathHelper.floor_double(aX), MathHelper.floor_double(aY), MathHelper.floor_double(aZ), aTimeUntilNextSound, aSoundName, aSoundStrength, aSoundModulation).run(); + new GT_Runnable_Sound( + GT.getThePlayer().worldObj, + MathHelper.floor_double(aX), MathHelper.floor_double(aY), MathHelper.floor_double(aZ), + aTimeUntilNextSound, aSoundResourceLocation, aSoundStrength, aSoundModulation).run(); return true; } + /** + * @inheritDoc + * @Deprecated Use {@link #doSoundAtClient(ResourceLocation, int, float, float, double, double, double)} + */ + @Deprecated + public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, float aSoundModulation, double aX, double aY, double aZ) { + if (isStringInvalid(aSoundName)) return false; + return doSoundAtClient(new ResourceLocation(aSoundName), aTimeUntilNextSound, aSoundStrength, aSoundModulation, aX, aY, aZ); + } + public static boolean sendSoundToPlayers(World aWorld, String aSoundName, float aSoundStrength, float aSoundModulation, int aX, int aY, int aZ) { if (isStringInvalid(aSoundName) || aWorld == null || aWorld.isRemote) return false; NW.sendPacketToAllPlayersInRange(aWorld, new GT_Packet_Sound(aSoundName, aSoundStrength, aSoundModulation, aX, (short) aY, aZ), aX, aZ); return true; } + public static boolean sendSoundToPlayers(World aWorld, SoundResource sound, float aSoundStrength, float aSoundModulation, int aX, int aY, int aZ) { + if (aWorld == null || aWorld.isRemote) return false; + NW.sendPacketToAllPlayersInRange(aWorld, new GT_Packet_Sound(sound.resourceLocation.toString(), aSoundStrength, aSoundModulation, aX, (short) aY, aZ), aX, aZ); + return true; + } + public static int stackToInt(ItemStack aStack) { if (isStackInvalid(aStack)) return 0; return itemToInt(aStack.getItem(), Items.feather.getDamage(aStack)); diff --git a/src/main/java/gregtech/api/util/WorldSpawnedEventBuilder.java b/src/main/java/gregtech/api/util/WorldSpawnedEventBuilder.java index 354b3748be..f2bb79657a 100644 --- a/src/main/java/gregtech/api/util/WorldSpawnedEventBuilder.java +++ b/src/main/java/gregtech/api/util/WorldSpawnedEventBuilder.java @@ -27,7 +27,7 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { return this; } - /* Methodes */ + /* Methods */ @SuppressWarnings("unchecked") public <U extends WorldSpawnedEventBuilder> void times(int times, Consumer<U> action) { @@ -66,6 +66,7 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { private interface IStringIdentifierWorldSpawnedEvent { String getIdentifier(); IStringIdentifierWorldSpawnedEvent setIdentifier(String identifier); + IStringIdentifierWorldSpawnedEvent setIdentifier(Enum<?> identifier); } private interface ISoundWorldSpawnedEvent { @@ -150,6 +151,12 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { this.identifier = identifier; return this; } + + @Override + public StringIdentifierPositionedWorldSpawnedEventBuilder setIdentifier(Enum<?> identifier){ + this.identifier = identifier.toString(); + return this; + } } private abstract static class SoundStringIdentifierPositionedWorldSpawnedEventBuilder extends StringIdentifierPositionedWorldSpawnedEventBuilder implements ISoundWorldSpawnedEvent { @@ -221,6 +228,11 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { } @Override + public ParticleEventBuilder setIdentifier(Enum<?> identifier) { + return (ParticleEventBuilder) super.setIdentifier(identifier); + } + + @Override public void run() { if (getPosition() == null || getIdentifier() == null || getMotion() == null || getWorld() == null) throw new IllegalStateException("Position, identifier, motion and world must be set"); @@ -256,6 +268,11 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { } @Override + public SoundEffectEventBuilder setIdentifier(Enum<?> identifier) { + return (SoundEffectEventBuilder) super.setIdentifier(identifier); + } + + @Override public SoundEffectEventBuilder setPitch(float pitch) { return (SoundEffectEventBuilder) super.setPitch(pitch); } @@ -497,6 +514,12 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { } @Override + public SoundAtEntityEventBuilder setIdentifier(Enum<?> identifier) { + this.identifier = identifier.toString(); + return this; + } + + @Override public float getPitch() { return pitch; } @@ -556,6 +579,12 @@ public abstract class WorldSpawnedEventBuilder implements Runnable { } @Override + public SoundToNearExceptEventBuilder setIdentifier(Enum<?> identifier) { + this.identifier = identifier.toString(); + return this; + } + + @Override public float getPitch() { return pitch; } |