diff --git a/gradle.properties b/gradle.properties index fd9d61e6fb..8fe6b5d192 100644 --- a/gradle.properties +++ b/gradle.properties @@ -44,7 +44,7 @@ developmentEnvironmentUserName = Developer # - jabel: Jabel syntax-only support, compiles to J8 bytecode # - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs) # - modern: Native modern Java bytecode, no downgrading -enableModernJavaSyntax = jabel +enableModernJavaSyntax = jvmDowngrader # If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues, # and should *not* be used in most situations. -1 disables this. @@ -52,12 +52,12 @@ enableModernJavaSyntax = jabel # Target JVM version for JVM Downgrader bytecode downgrading. # Only used when enableModernJavaSyntax = jvmDowngrader -# downgradeTargetVersion = 8 +downgradeTargetVersion = 8 # Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only). # Classes will be available in META-INF/versions/N/ for each version N in this list. # Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade). -# jvmDowngraderMultiReleaseVersions = 21,25 +jvmDowngraderMultiReleaseVersions = 25 # Specifies how JVM Downgrader API stubs are provided. Options: # - shade: Shade minimized stubs into the jar @@ -65,7 +65,7 @@ enableModernJavaSyntax = jabel # - external: Another dependency provides stubs (no constraint, no warning) # - (empty): Warning reminding you to configure stubs # Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md -# jvmDowngraderStubsProvider = +jvmDowngraderStubsProvider = gtnhlib # Enables injecting missing generics into the decompiled source code for a better coding experience. # Turns most publicly visible List, Map, etc. into proper List, Map types. diff --git a/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java b/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java index c996dc8189..00b1959654 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java @@ -65,7 +65,6 @@ import WayofTime.alchemicalWizardry.common.LifeBucketHandler; import WayofTime.alchemicalWizardry.common.LifeEssence; import WayofTime.alchemicalWizardry.common.ModLivingDropsEvent; -import WayofTime.alchemicalWizardry.common.NewPacketHandler; import WayofTime.alchemicalWizardry.common.achievements.ModAchievements; import WayofTime.alchemicalWizardry.common.alchemy.CombinedPotionRegistry; import WayofTime.alchemicalWizardry.common.block.ArmourForge; @@ -627,8 +626,6 @@ public Item getTabIconItem() { serverSide = "WayofTime.alchemicalWizardry.common.CommonProxy") public static CommonProxy proxy; - public static final HoldingPacketHandler packetPipeline = new HoldingPacketHandler(); - @EventHandler public void preInit(FMLPreInitializationEvent event) { @@ -662,8 +659,8 @@ public void preInit(FMLPreInitializationEvent event) { f.set(null, newPotionTypes); } } catch (Exception e) { - System.err.println("Severe error, please report this to the mod author:"); - System.err.println(e); + AlchemicalWizardry.logger.error("Severe error, please report this to the mod author:"); + AlchemicalWizardry.logger.error(e); } } } @@ -689,7 +686,6 @@ public void preInit(FMLPreInitializationEvent event) { Object eventHook = new AlchemicalWizardryEventHooks(); FMLCommonHandler.instance().bus().register(eventHook); MinecraftForge.EVENT_BUS.register(eventHook); - NewPacketHandler.INSTANCE.ordinal(); HoldingPacketHandler.init(); ClientToServerPacketHandler.init(); ModAchievements.init(); @@ -727,7 +723,7 @@ private static void generateDefaultConfig(String destination, String source) { out.close(); } } - } catch (Exception e) {} + } catch (Exception ignored) {} } } @@ -1967,43 +1963,43 @@ public void load(FMLInitializationEvent event) { new ItemStack(ModItems.standardBindingAgent), 1, 3, - this.standardBindingAgentDungeonChance / 5)); + standardBindingAgentDungeonChance / 5)); ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem( new WeightedRandomChestContent( new ItemStack(ModItems.mundanePowerCatalyst), 1, 1, - this.mundanePowerCatalystDungeonChance / 5)); + mundanePowerCatalystDungeonChance / 5)); ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem( new WeightedRandomChestContent( new ItemStack(ModItems.mundaneLengtheningCatalyst), 1, 1, - this.mundaneLengtheningCatalystDungeonChance / 5)); + mundaneLengtheningCatalystDungeonChance / 5)); ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem( new WeightedRandomChestContent( new ItemStack(ModItems.averagePowerCatalyst), 1, 1, - this.averagePowerCatalystDungeonChance / 5)); + averagePowerCatalystDungeonChance / 5)); ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem( new WeightedRandomChestContent( new ItemStack(ModItems.averageLengtheningCatalyst), 1, 1, - this.averageLengtheningCatalystDungeonChance / 5)); + averageLengtheningCatalystDungeonChance / 5)); ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem( new WeightedRandomChestContent( new ItemStack(ModItems.greaterPowerCatalyst), 1, 1, - this.greaterPowerCatalystDungeonChance / 5)); + greaterPowerCatalystDungeonChance / 5)); ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem( new WeightedRandomChestContent( new ItemStack(ModItems.greaterLengtheningCatalyst), 1, 1, - this.greaterLengtheningCatalystDungeonChance / 5)); + greaterLengtheningCatalystDungeonChance / 5)); // Ore Dictionary Registration OreDictionary.registerOre("oreCoal", Blocks.coal_ore); @@ -3310,7 +3306,7 @@ public void postInit(FMLPostInitializationEvent event) { RecipeHolder.init(); long finalTime = System.nanoTime(); AlchemicalWizardry.logger - .info("Recipe Holder initialized: took " + (finalTime - initialTime) / 1000000f + "ms."); + .info("Recipe Holder initialized: took {}ms.", (finalTime - initialTime) / 1000000f); ModItems.itemMailCatalogue = new ItemMailOrderCatalogue().setUnlocalizedName("itemMailCatalogue"); GameRegistry.registerItem(ModItems.itemMailCatalogue, "itemMailCatalogue"); @@ -3424,7 +3420,7 @@ public static void blacklistDemons() { .newInstance("registerGrinderBlacklist", mobClasses[i]); method.invoke(null, bloodMagic, "MineFactoryReloaded", message); } catch (Exception e) { - logger.log(Level.ERROR, "Failed to blacklist Grinder for " + mobs[i]); + logger.log(Level.ERROR, "Failed to blacklist Grinder for {}", mobs[i]); } } } @@ -3737,7 +3733,7 @@ public static void initRituals() { new RitualEffectWater(), "Ritual of the Full Spring", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/AlchemyArrays/WaterArray.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/AlchemyArrays/WaterArray.png"), 0, 30, 255, @@ -3755,7 +3751,7 @@ public static void initRituals() { new RitualEffectLava(), "Serenade of the Nether", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/AlchemyArrays/LavaArray.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/AlchemyArrays/LavaArray.png"), 255, 0, 0, @@ -3773,7 +3769,7 @@ public static void initRituals() { new RitualEffectGrowth(), "Ritual of the Green Grove", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/AlchemyArrays/GreenGroveArray.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/AlchemyArrays/GreenGroveArray.png"), 244, 164, 96, @@ -3791,7 +3787,9 @@ public static void initRituals() { new RitualEffectInterdiction(), "Interdiction Ritual", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/AlchemyArrays/InterdictionArray.png"), + new ResourceLocation( + "alchemicalwizardry", + "textures/models/AlchemyArrays/InterdictionArray.png"), 27, 227, 206, @@ -3809,7 +3807,7 @@ public static void initRituals() { new RitualEffectContainment(), "Ritual of Containment", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 186, 21, 21, @@ -3827,7 +3825,7 @@ public static void initRituals() { new RitualEffectBinding(), "Ritual of Binding", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/TransCircleBinding.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/TransCircleBinding.png"), 193, 7, 7, @@ -3845,7 +3843,7 @@ public static void initRituals() { new RitualEffectUnbinding(), "Ritual of Unbinding", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 193, 7, 7, @@ -3863,7 +3861,7 @@ public static void initRituals() { new RitualEffectJumping(), "Ritual of the High Jump", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 10, 183, 173, @@ -3881,7 +3879,7 @@ public static void initRituals() { new RitualEffectMagnetic(), "Ritual of Magnetism", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/AlchemyArrays/MagnetismArray.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/AlchemyArrays/MagnetismArray.png"), 126, 39, 0, @@ -3899,7 +3897,7 @@ public static void initRituals() { new RitualEffectCrushing(), "Ritual of the Crusher", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -3917,7 +3915,7 @@ public static void initRituals() { new RitualEffectLeap(), "Ritual of Speed", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -3935,7 +3933,7 @@ public static void initRituals() { new RitualEffectAnimalGrowth(), "Ritual of the Shepherd", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -3954,7 +3952,8 @@ public static void initRituals() { "Well of Suffering", new AlchemyCircleRenderer( new ResourceLocation( - "alchemicalwizardry:textures/models/AlchemyArrays/WellOfSufferingArray.png"), + "alchemicalwizardry", + "textures/models/AlchemyArrays/WellOfSufferingArray.png"), 0, 0, 0, @@ -3972,7 +3971,7 @@ public static void initRituals() { new RitualEffectHealing(), "Ritual of Regeneration", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -3990,7 +3989,7 @@ public static void initRituals() { new RitualEffectFeatheredKnife(), "Ritual of the Feathered Knife", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4008,7 +4007,7 @@ public static void initRituals() { new RitualEffectFeatheredEarth(), "Ritual of the Feathered Earth", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4026,7 +4025,7 @@ public static void initRituals() { new RitualEffectBiomeChanger(), "Ritual of Gaia's Transformation", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4044,7 +4043,7 @@ public static void initRituals() { new RitualEffectFlight(), "Reverence of the Condor", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4062,7 +4061,7 @@ public static void initRituals() { new RitualEffectSummonMeteor(), "Mark of the Falling Tower", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4080,7 +4079,7 @@ public static void initRituals() { new RitualEffectAutoAlchemy(), "Ballad of Alchemy", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4098,7 +4097,7 @@ public static void initRituals() { new RitualEffectExpulsion(), "Aura of Expulsion", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4116,7 +4115,7 @@ public static void initRituals() { new RitualEffectSupression(), "Dome of Supression", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4134,7 +4133,7 @@ public static void initRituals() { new RitualEffectItemSuction(), "Call of the Zephyr", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4152,7 +4151,7 @@ public static void initRituals() { new RitualEffectHarvest(), "Reap of the Harvest Moon", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4170,7 +4169,7 @@ public static void initRituals() { new RitualEffectLifeConduit(), "Cry of the Eternal Soul", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4188,7 +4187,7 @@ public static void initRituals() { new RitualEffectEllipsoid(), "Focus of the Ellipsoid", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4206,7 +4205,7 @@ public static void initRituals() { new RitualEffectEvaporation(), "Song of Evaporation", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4224,7 +4223,7 @@ public static void initRituals() { new RitualEffectSpawnWard(), "Ward of Sacrosanctity", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4242,7 +4241,7 @@ public static void initRituals() { new RitualEffectVeilOfEvil(), "Veil of Evil", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4260,7 +4259,7 @@ public static void initRituals() { new RitualEffectFullStomach(), "Requiem of the Satiated Stomach", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/SimpleTransCircle.png"), 0, 0, 0, @@ -4278,7 +4277,7 @@ public static void initRituals() { new RitualEffectDemonPortal(), "Convocation of the Damned", new AlchemyCircleRenderer( - new ResourceLocation("alchemicalwizardry:textures/models/TransCircleDemon.png"), + new ResourceLocation("alchemicalwizardry", "textures/models/TransCircleDemon.png"), 220, 22, 22, diff --git a/src/main/java/WayofTime/alchemicalWizardry/BloodMagicConfiguration.java b/src/main/java/WayofTime/alchemicalWizardry/BloodMagicConfiguration.java index bafcd85e0d..282f4f8a06 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/BloodMagicConfiguration.java +++ b/src/main/java/WayofTime/alchemicalWizardry/BloodMagicConfiguration.java @@ -10,6 +10,7 @@ import java.util.Map.Entry; import net.minecraft.block.Block; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntityEnderman; @@ -49,7 +50,7 @@ public class BloodMagicConfiguration { public static void init(File configFile) { for (String s : DEFAULT_COLOR_LIST.split(";")) { String[] ct = s.split(","); - colorList.add(new ColourThreshold(Integer.valueOf(ct[0].trim()), ct[1].trim())); + colorList.add(new ColourThreshold(Integer.parseInt(ct[0].trim()), ct[1].trim())); } config = new Configuration(configFile); @@ -109,15 +110,12 @@ public static void syncConfig() { 0, Integer.MAX_VALUE, "The default LP cost to use for meteors if the \"cost\" property is not present in its config file.\n"); - AlchemicalWizardry.defaultMeteorBlock = config.getString( - "defaultMeteorBlock", - "meteor", - "", - "The block to use for filler in meteors if none is provided in the meteor's config file and " - + "that\nmeteor's fillerChance is greater than 0. Also used as a fallback for empty ore " - + "lists in meteor configs.\nSpecify the block with the " - + "format:\n\"modId:itemName:meta\"\nDefaults to minecraft:stone:0 if no block is provided or " - + "the provided block cannot be found."); + AlchemicalWizardry.defaultMeteorBlock = config.getString("defaultMeteorBlock", "meteor", "", """ + The block to use for filler in meteors if none is provided in the meteor's config file and that + meteor's fillerChance is greater than 0. Also used as a fallback for empty ore lists in meteor configs. + Specify the block with the format: + "modId:itemName:meta" + Defaults to minecraft:stone:0 if no block is provided or the provided block cannot be found."""); MeteorComponent.setDefaultMeteorBlock(); AlchemicalWizardry.allowedCrushedOresArray = config.get( "oreCrushing", @@ -639,10 +637,11 @@ public static void finishLoading() { "altar blocks", "fifthTierBeacons", new String[] { "minecraft:beacon", "etfuturum:beacon", "chisel:beacon:*" }, - "Valid blocks for the Blood Altar's tier 5 beacons:\n" - + "Use the following format for all of these entries: mod:block(:meta). Meta * or 32767 allows for any meta.\n" - + "An empty entry allows for any non-air block to be used for that part of the structure.\n" - + "Invalid or missing blocks are skipped. If all entries are invalid, any block can be used as a fallback."); + """ + Valid blocks for the Blood Altar's tier 5 beacons: + Use the following format for all of these entries: mod:block(:meta). Meta * or 32767 allows for any meta. + An empty entry allows for any non-air block to be used for that part of the structure. + Invalid or missing blocks are skipped. If all entries are invalid, any block can be used as a fallback."""); AlchemicalWizardry.thirdTierCaps = readBlockConfig( "altar blocks", "thirdTierCaps", @@ -680,10 +679,9 @@ public static void finishLoading() { public static void loadCustomLPValues() { AlchemicalWizardry.lpPerSactificeCustom = new HashMap<>(); - for (Object object : EntityList.stringToClassMapping.entrySet()) { - Entry entry = (Entry) object; - String entityName = (String) entry.getKey(); - Class entityClass = (Class) entry.getValue(); + for (Entry> entry : EntityList.stringToClassMapping.entrySet()) { + String entityName = entry.getKey(); + Class entityClass = entry.getValue(); if (EntityLivingBase.class.isAssignableFrom(entityClass) && !Modifier.isAbstract(entityClass.getModifiers())) { int lpAmount = 500; @@ -717,15 +715,13 @@ public static void set(String categoryName, String propertyName, String newValue } public static void loadBlacklist() { - AlchemicalWizardry.wellBlacklist = new ArrayList(); - for (Object o : stringToClassMapping.entrySet()) { - Entry entry = (Entry) o; - Class curClass = (Class) entry.getValue(); + AlchemicalWizardry.wellBlacklist = new ArrayList<>(); + for (Entry> entry : stringToClassMapping.entrySet()) { + Class curClass = entry.getValue(); boolean valid = EntityLivingBase.class.isAssignableFrom(curClass) && !Modifier.isAbstract(curClass.getModifiers()); if (valid) { - boolean blacklisted = config.get("wellOfSufferingBlackList", entry.getKey().toString(), false) - .getBoolean(); + boolean blacklisted = config.get("wellOfSufferingBlackList", entry.getKey(), false).getBoolean(); if (blacklisted) AlchemicalWizardry.wellBlacklist.add(curClass); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/BlockStack.java b/src/main/java/WayofTime/alchemicalWizardry/api/BlockStack.java index 577f5db51c..216d8e6b8d 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/BlockStack.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/BlockStack.java @@ -1,5 +1,7 @@ package WayofTime.alchemicalWizardry.api; +import javax.annotation.Nonnull; + import net.minecraft.block.Block; import cpw.mods.fml.common.registry.GameData; @@ -7,42 +9,11 @@ /** * A Block with a set metadata. Similar to an ItemStack. */ -public class BlockStack { - - private final Block block; - private final int meta; - - public BlockStack(Block block, int meta) { - this.block = block; - this.meta = meta; - } - - public BlockStack(Block block) { - this(block, 0); - } - - public Block getBlock() { - return block; - } - - public int getMeta() { - return meta; - } +public record BlockStack(Block block, int meta) { + @Nonnull @Override public String toString() { return GameData.getBlockRegistry().getNameForObject(block) + ":" + meta; } - - @Override - public boolean equals(Object obj) { - BlockStack blockStack = (BlockStack) obj; - - return blockStack.block == this.getBlock() && blockStack.meta == this.getMeta(); - } - - @Override - public int hashCode() { - return super.hashCode(); - } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/ColourAndCoords.java b/src/main/java/WayofTime/alchemicalWizardry/api/ColourAndCoords.java index 68e6531d29..f80c95f6bd 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/ColourAndCoords.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/ColourAndCoords.java @@ -2,27 +2,7 @@ import net.minecraft.nbt.NBTTagCompound; -public class ColourAndCoords { - - public int colourRed; - public int colourGreen; - public int colourBlue; - public int colourIntensity; - - public int xCoord; - public int yCoord; - public int zCoord; - - public ColourAndCoords(int red, int green, int blue, int intensity, int x, int y, int z) { - this.colourRed = red; - this.colourGreen = green; - this.colourBlue = blue; - this.colourIntensity = intensity; - - this.xCoord = x; - this.yCoord = y; - this.zCoord = z; - } +public record ColourAndCoords(int red, int green, int blue, int intensity, int x, int y, int z) { public static ColourAndCoords readFromNBT(NBTTagCompound tag) { return new ColourAndCoords( @@ -36,13 +16,13 @@ public static ColourAndCoords readFromNBT(NBTTagCompound tag) { } public NBTTagCompound writeToNBT(NBTTagCompound tag) { - tag.setInteger("colourRed", colourRed); - tag.setInteger("colourGreen", colourGreen); - tag.setInteger("colourBlue", colourBlue); - tag.setInteger("colourIntensity", colourIntensity); - tag.setInteger("xCoord", xCoord); - tag.setInteger("yCoord", yCoord); - tag.setInteger("zCoord", zCoord); + tag.setInteger("colourRed", red); + tag.setInteger("colourGreen", green); + tag.setInteger("colourBlue", blue); + tag.setInteger("colourIntensity", intensity); + tag.setInteger("xCoord", x); + tag.setInteger("yCoord", y); + tag.setInteger("zCoord", z); return tag; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/Int3.java b/src/main/java/WayofTime/alchemicalWizardry/api/Int3.java index 2a04c547a3..f9416b039e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/Int3.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/Int3.java @@ -2,40 +2,17 @@ import net.minecraft.nbt.NBTTagCompound; -public class Int3 { - - public int xCoord; - public int yCoord; - public int zCoord; - - public Int3(int xCoord, int yCoord, int zCoord) { - this.xCoord = xCoord; - this.yCoord = yCoord; - this.zCoord = zCoord; - } +public record Int3(int x, int y, int z) { public static Int3 readFromNBT(NBTTagCompound tag) { return new Int3(tag.getInteger("xCoord"), tag.getInteger("yCoord"), tag.getInteger("zCoord")); } public NBTTagCompound writeToNBT(NBTTagCompound tag) { - tag.setInteger("xCoord", xCoord); - tag.setInteger("yCoord", yCoord); - tag.setInteger("zCoord", zCoord); + tag.setInteger("xCoord", x); + tag.setInteger("yCoord", y); + tag.setInteger("zCoord", z); return tag; } - - @Override - public boolean equals(Object o) { - return o instanceof Int3 - ? ((Int3) o).xCoord == this.xCoord && ((Int3) o).yCoord == this.yCoord - && ((Int3) o).zCoord == this.zCoord - : false; - } - - @Override - public int hashCode() { - return this.xCoord + this.yCoord << 8 + this.zCoord << 16; - } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/Vector3.java b/src/main/java/WayofTime/alchemicalWizardry/api/Vector3.java index 6c4e7ea128..4e4e850ca4 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/Vector3.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/Vector3.java @@ -1,41 +1,17 @@ package WayofTime.alchemicalWizardry.api; -/* - * Created in Scala by Alex-Hawks Translated and implemented by Arcaratus - */ -public class Vector3 { +import javax.annotation.Nonnull; - public int x, y, z; +public record Vector3(int x, int y, int z) { - public Vector3(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - - public Vector3 add(Vector3 vec1) { - return new Vector3(this.x + vec1.x, this.y + vec1.y, this.z + vec1.z); + public Vector3 add(Vector3 vec) { + return new Vector3(this.x + vec.x, this.y + vec.y, this.z + vec.z); } @Override + @Nonnull public String toString() { - return "V3(" + x + "}, " + y + "}," + z + "})"; + return "V3({" + x + "}, {" + y + "}, {" + z + "})"; } - private boolean canEqual(Object object) { - return object instanceof Vector3; - } - - @Override - public boolean equals(Object object) { - return object == this || object instanceof Vector3 && canEqual(this) - && this.x == ((Vector3) object).x - && this.y == ((Vector3) object).y - && this.z == ((Vector3) object).z; - } - - @Override - public int hashCode() { - return 48131 * x - 95021 * y + z; - } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemicalPotionCreationHandler.java b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemicalPotionCreationHandler.java index 8b2efce2e7..646df82607 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemicalPotionCreationHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemicalPotionCreationHandler.java @@ -6,7 +6,7 @@ public class AlchemicalPotionCreationHandler { - public static ArrayList registeredPotionEffects = new ArrayList(); + public static ArrayList registeredPotionEffects = new ArrayList<>(); public static void addPotion(ItemStack itemStack, int potionID, int tickDuration) { registeredPotionEffects.add(new AlchemyPotionHandlerComponent(itemStack, potionID, tickDuration)); @@ -15,7 +15,7 @@ public static void addPotion(ItemStack itemStack, int potionID, int tickDuration public static int getPotionIDForStack(ItemStack itemStack) { for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects) { if (aphc.compareItemStack(itemStack)) { - return aphc.getPotionID(); + return aphc.potionID(); } } @@ -26,7 +26,7 @@ public static int getPotionTickDurationForStack(ItemStack itemStack) { { for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects) { if (aphc.compareItemStack(itemStack)) { - return aphc.getTickDuration(); + return aphc.tickDuration(); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHandlerComponent.java b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHandlerComponent.java index 63fdb6b197..fa501fe5c5 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHandlerComponent.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHandlerComponent.java @@ -3,17 +3,7 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -public class AlchemyPotionHandlerComponent { - - private ItemStack itemStack; - private int potionID; - private int tickDuration; - - public AlchemyPotionHandlerComponent(ItemStack itemStack, int potionID, int tickDuration) { - this.itemStack = itemStack; - this.potionID = potionID; - this.tickDuration = tickDuration; - } +public record AlchemyPotionHandlerComponent(ItemStack itemStack, int potionID, int tickDuration) { public boolean compareItemStack(ItemStack comparedStack) { if (comparedStack != null && itemStack != null) { @@ -30,16 +20,4 @@ public boolean compareItemStack(ItemStack comparedStack) { return false; } - - public ItemStack getItemStack() { - return itemStack; - } - - public int getPotionID() { - return this.potionID; - } - - public int getTickDuration() { - return this.tickDuration; - } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHelper.java b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHelper.java index dbe8de6abe..3516b0028b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHelper.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyPotionHelper.java @@ -6,8 +6,8 @@ public class AlchemyPotionHelper { - private int potionID; - private int tickDuration; + private final int potionID; + private final int tickDuration; private int concentration; private int durationFactor; diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipe.java b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipe.java index 4a0efa8acf..1aeb081fde 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipe.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipe.java @@ -6,10 +6,10 @@ public class AlchemyRecipe { - private ItemStack output; - private ItemStack[] recipe; - private int bloodOrbLevel; - private int amountNeeded; + private final ItemStack output; + private final ItemStack[] recipe; + private final int bloodOrbLevel; + private final int amountNeeded; public AlchemyRecipe(ItemStack output, int amountNeeded, ItemStack[] recipe, int bloodOrbLevel) { this.output = output; diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipeRegistry.java b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipeRegistry.java index 6016f95f6b..16bfe2874a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipeRegistry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/AlchemyRecipeRegistry.java @@ -9,7 +9,7 @@ public class AlchemyRecipeRegistry { - public static List recipes = new ArrayList(); + public static List recipes = new ArrayList<>(); public static void registerRecipe(ItemStack output, int amountNeeded, ItemStack[] recipe, int bloodOrbLevel) { recipes.add(new AlchemyRecipe(output, amountNeeded, recipe, bloodOrbLevel)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/Reagent.java b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/Reagent.java index 915ecc08e3..ec437704da 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/Reagent.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/Reagent.java @@ -1,41 +1,7 @@ package WayofTime.alchemicalWizardry.api.alchemy.energy; -public class Reagent { - - public final String name; +public record Reagent(String name, int red, int green, int blue, int intensity) { public static final int REAGENT_SIZE = 1000; - private int colourRed = 0; - private int colourGreen = 0; - private int colourBlue = 0; - private int colourIntensity = 255; - - public Reagent(String name) { - this.name = name; - } - - public void setColour(int red, int green, int blue, int intensity) { - this.colourRed = red; - this.colourGreen = green; - this.colourBlue = blue; - this.colourIntensity = intensity; - } - - public int getColourRed() { - return colourRed; - } - - public int getColourGreen() { - return colourGreen; - } - - public int getColourBlue() { - return colourBlue; - } - - public int getColourIntensity() { - return colourIntensity; - } - } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentRegistry.java b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentRegistry.java index 00594ee38d..4c04cbdb5d 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentRegistry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentRegistry.java @@ -1,6 +1,7 @@ package WayofTime.alchemicalWizardry.api.alchemy.energy; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -9,8 +10,8 @@ public class ReagentRegistry { - public static Map reagentList = new HashMap(); - public static Map itemToReagentMap = new HashMap(); + public static Map reagentList = new LinkedHashMap<>(); + public static Map itemToReagentMap = new HashMap<>(); public static Reagent sanctusReagent; public static Reagent incendiumReagent; @@ -21,7 +22,6 @@ public class ReagentRegistry { public static Reagent crystallosReagent; public static Reagent terraeReagent; public static Reagent tenebraeReagent; - public static Reagent offensaReagent; public static Reagent praesidiumReagent; public static Reagent orbisTerraeReagent; @@ -30,71 +30,51 @@ public class ReagentRegistry { public static Reagent potentiaReagent; public static void initReagents() { - sanctusReagent = new Reagent("sanctus"); - incendiumReagent = new Reagent("incendium"); - aquasalusReagent = new Reagent("aquasalus"); - magicalesReagent = new Reagent("magicales"); - aetherReagent = new Reagent("aether"); - crepitousReagent = new Reagent("crepitous"); - crystallosReagent = new Reagent("crystallos"); - terraeReagent = new Reagent("terrae"); - tenebraeReagent = new Reagent("tenebrae"); - offensaReagent = new Reagent("offensa"); - praesidiumReagent = new Reagent("praesidium"); - orbisTerraeReagent = new Reagent("orbisTerrae"); - virtusReagent = new Reagent("virtus"); - reductusReagent = new Reagent("reductus"); - potentiaReagent = new Reagent("potentia"); - - sanctusReagent.setColour(255, 255, 0, 255); - incendiumReagent.setColour(255, 0, 0, 255); - aquasalusReagent.setColour(0, 0, 255, 255); - magicalesReagent.setColour(150, 0, 146, 255); - aetherReagent.setColour(105, 223, 86, 255); - crepitousReagent.setColour(145, 145, 145, 255); - crystallosReagent.setColour(135, 255, 231, 255); - terraeReagent.setColour(147, 48, 13, 255); - tenebraeReagent.setColour(86, 86, 86, 255); - offensaReagent.setColour(126, 0, 0, 255); - praesidiumReagent.setColour(135, 135, 135, 255); - orbisTerraeReagent.setColour(32, 94, 14, 255); - virtusReagent.setColour(180, 0, 0, 255); - reductusReagent.setColour(20, 93, 2, 255); - potentiaReagent.setColour(64, 81, 208, 255); - - registerReagent("sanctus", sanctusReagent); - registerReagent("incendium", incendiumReagent); - registerReagent("aquasalus", aquasalusReagent); - registerReagent("magicales", magicalesReagent); - registerReagent("aether", aetherReagent); - registerReagent("crepitous", crepitousReagent); - registerReagent("crystallos", crystallosReagent); - registerReagent("terrae", terraeReagent); - registerReagent("tenebrae", tenebraeReagent); - registerReagent("offensa", offensaReagent); - registerReagent("praesidium", praesidiumReagent); - registerReagent("orbisTerrae", orbisTerraeReagent); - registerReagent("virtus", virtusReagent); - registerReagent("reductus", reductusReagent); - registerReagent("potentia", potentiaReagent); + sanctusReagent = new Reagent("sanctus", 255, 255, 0, 255); + incendiumReagent = new Reagent("incendium", 255, 0, 0, 255); + aquasalusReagent = new Reagent("aquasalus", 0, 0, 255, 255); + magicalesReagent = new Reagent("magicales", 150, 0, 146, 255); + aetherReagent = new Reagent("aether", 105, 223, 86, 255); + crepitousReagent = new Reagent("crepitous", 145, 145, 145, 255); + crystallosReagent = new Reagent("crystallos", 135, 255, 231, 255); + terraeReagent = new Reagent("terrae", 147, 48, 13, 255); + tenebraeReagent = new Reagent("tenebrae", 86, 86, 86, 255); + offensaReagent = new Reagent("offensa", 126, 0, 0, 255); + praesidiumReagent = new Reagent("praesidium", 135, 135, 135, 255); + orbisTerraeReagent = new Reagent("orbisTerrae", 32, 94, 14, 255); + virtusReagent = new Reagent("virtus", 180, 0, 0, 255); + reductusReagent = new Reagent("reductus", 20, 93, 2, 255); + potentiaReagent = new Reagent("potentia", 64, 81, 208, 255); + + registerReagent(sanctusReagent); + registerReagent(incendiumReagent); + registerReagent(aquasalusReagent); + registerReagent(magicalesReagent); + registerReagent(aetherReagent); + registerReagent(crepitousReagent); + registerReagent(crystallosReagent); + registerReagent(terraeReagent); + registerReagent(tenebraeReagent); + registerReagent(offensaReagent); + registerReagent(praesidiumReagent); + registerReagent(orbisTerraeReagent); + registerReagent(virtusReagent); + registerReagent(reductusReagent); + registerReagent(potentiaReagent); } - public static boolean registerReagent(String key, Reagent reagent) { - if (reagentList.containsKey(key) || reagent == null) { + public static boolean registerReagent(Reagent reagent) { + if (reagent == null || reagentList.containsKey(reagent.name())) { return false; } - reagentList.put(key, reagent); + reagentList.put(reagent.name(), reagent); return true; } public static Reagent getReagentForKey(String key) { - if (reagentList.containsKey(key)) { - return reagentList.get(key); - } - - return null; + return reagentList.get(key); } public static String getKeyForReagent(Reagent reagent) { @@ -141,9 +121,8 @@ public static ItemStack getItemForReagent(Reagent reagent) { if (entry.getValue() != null && entry.getValue().reagent == reagent) { if (entry.getKey() == null) { return null; - } else { - return entry.getKey().copy(); } + return entry.getKey().copy(); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentStack.java b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentStack.java index 353b1dfad5..3ef7c02b1f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentStack.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/ReagentStack.java @@ -24,9 +24,8 @@ public static ReagentStack loadReagentStackFromNBT(NBTTagCompound tag) { } int amount = tag.getInteger("amount"); - ReagentStack stack = new ReagentStack(reagent, amount); - return stack; + return new ReagentStack(reagent, amount); } public NBTTagCompound writeToNBT(NBTTagCompound tag) { @@ -36,15 +35,6 @@ public NBTTagCompound writeToNBT(NBTTagCompound tag) { return tag; } - public ReagentStack splitStack(int amount) { - ReagentStack copyStack = this.copy(); - int splitAmount = Math.min(amount, this.amount); - copyStack.amount = splitAmount; - this.amount -= splitAmount; - - return copyStack; - } - public ReagentStack copy() { return new ReagentStack(this.reagent, this.amount); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/TileSegmentedReagentHandler.java b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/TileSegmentedReagentHandler.java index 56552e2093..daa8383737 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/TileSegmentedReagentHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/alchemy/energy/TileSegmentedReagentHandler.java @@ -26,7 +26,7 @@ public TileSegmentedReagentHandler(int numberOfTanks) { public TileSegmentedReagentHandler(int numberOfTanks, int tankSize) { super(); - this.attunedTankMap = new HashMap(); + this.attunedTankMap = new HashMap<>(); this.tanks = new ReagentContainer[numberOfTanks]; for (int i = 0; i < numberOfTanks; i++) { this.tanks[i] = new ReagentContainer(tankSize); @@ -62,10 +62,10 @@ public void writeToNBT(NBTTagCompound tag) { NBTTagList tagList = new NBTTagList(); - for (int i = 0; i < this.tanks.length; i++) { + for (ReagentContainer tank : this.tanks) { NBTTagCompound savedTag = new NBTTagCompound(); - if (this.tanks[i] != null) { - this.tanks[i].writeToNBT(savedTag); + if (tank != null) { + tank.writeToNBT(savedTag); } tagList.appendTag(savedTag); } @@ -101,8 +101,8 @@ public int fill(ForgeDirection from, ReagentStack resource, boolean doFill) { ReagentStack remainingStack = resource.copy(); remainingStack.amount = maxFill - totalFill; - boolean doesReagentMatch = tanks[i].getReagent() == null ? false - : tanks[i].getReagent().isReagentEqual(remainingStack); + boolean doesReagentMatch = tanks[i].getReagent() != null + && tanks[i].getReagent().isReagentEqual(remainingStack); if (doesReagentMatch) { totalFill += tanks[i].fill(remainingStack, doFill); @@ -151,13 +151,13 @@ public ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean do Reagent reagent = resource.reagent; int drained = 0; - for (int i = 0; i < tanks.length; i++) { + for (ReagentContainer tank : tanks) { if (drained >= maxDrain) { break; } - if (resource.isReagentEqual(tanks[i].getReagent())) { - ReagentStack drainStack = tanks[i].drain(maxDrain - drained, doDrain); + if (resource.isReagentEqual(tank.getReagent())) { + ReagentStack drainStack = tank.drain(maxDrain - drained, doDrain); if (drainStack != null) { drained += drainStack.amount; } @@ -170,8 +170,8 @@ public ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean do /* Only returns the amount from the first available tank */ @Override public ReagentStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - for (int i = 0; i < tanks.length; i++) { - ReagentStack stack = tanks[i].drain(maxDrain, doDrain); + for (ReagentContainer tank : tanks) { + ReagentStack stack = tank.drain(maxDrain, doDrain); if (stack != null) { return stack; } @@ -226,14 +226,4 @@ public void setTanksTunedToReagent(Reagent reagent, int total) { public Map getAttunedTankMap() { return this.attunedTankMap; } - - public boolean areTanksEmpty() { - for (int i = 0; i < this.tanks.length; i++) { - if (tanks[i] != null && tanks[i].reagentStack != null) { - return false; - } - } - - return true; - } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/AltarRecipe.java b/src/main/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/AltarRecipe.java index 2d2acb620d..dbef51a6f3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/AltarRecipe.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/altarRecipeRegistry/AltarRecipe.java @@ -50,7 +50,7 @@ public boolean doesRequiredItemMatch(ItemStack comparedStack, int tierCheck) { } return tierCheck >= minTier && this.requiredItem.isItemEqual(comparedStack) - && (this.useTag ? this.areRequiredTagsEqual(comparedStack) : true); + && (!this.useTag || this.areRequiredTagsEqual(comparedStack)); } public boolean areRequiredTagsEqual(ItemStack comparedStack) { @@ -69,11 +69,10 @@ public boolean areRequiredTagsEqual(ItemStack comparedStack) { } protected boolean areTagsEqual(NBTTagCompound tag, NBTTagCompound comparedTag) { - Set set = tag.func_150296_c(); + Set set = tag.func_150296_c(); for (Object obj : set) { - if (obj instanceof String) { - String str = (String) obj; + if (obj instanceof String str) { NBTBase baseTag = comparedTag.getTag(str); diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/bindingRegistry/BindingRegistry.java b/src/main/java/WayofTime/alchemicalWizardry/api/bindingRegistry/BindingRegistry.java index 8792df58bb..97d7944275 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/bindingRegistry/BindingRegistry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/bindingRegistry/BindingRegistry.java @@ -7,7 +7,7 @@ public class BindingRegistry { - public static List bindingRecipes = new LinkedList(); + public static List bindingRecipes = new LinkedList<>(); public static void registerRecipe(ItemStack output, ItemStack input) { bindingRecipes.add(new BindingRecipe(output, input)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/command/SubCommandBase.java b/src/main/java/WayofTime/alchemicalWizardry/api/command/SubCommandBase.java index f817d4dd91..78b4303fe2 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/command/SubCommandBase.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/command/SubCommandBase.java @@ -15,8 +15,8 @@ public abstract class SubCommandBase implements ISubCommand { - private ICommand parent; - private String name; + private final ICommand parent; + private final String name; public SubCommandBase(ICommand parent, String name) { this.parent = parent; diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/compress/CompressionRegistry.java b/src/main/java/WayofTime/alchemicalWizardry/api/compress/CompressionRegistry.java index 0f1db26d71..f6e50e464c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/compress/CompressionRegistry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/compress/CompressionRegistry.java @@ -15,8 +15,8 @@ */ public class CompressionRegistry { - public static List compressionRegistry = new ArrayList(); - public static Map thresholdMap = new HashMap(); + public static List compressionRegistry = new ArrayList<>(); + public static Map thresholdMap = new HashMap<>(); public static void registerHandler(CompressionHandler handler) { compressionRegistry.add(handler); diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/guide/OrbRecipeRenderer.java b/src/main/java/WayofTime/alchemicalWizardry/api/guide/OrbRecipeRenderer.java index d1c2982c20..e2915bc406 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/guide/OrbRecipeRenderer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/guide/OrbRecipeRenderer.java @@ -43,8 +43,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft + guiBase.xSize / 2, guiTop + 12, 0); - if (recipe instanceof ShapelessBloodOrbRecipe) { - ShapelessBloodOrbRecipe shapelessBloodOrbRecipe = (ShapelessBloodOrbRecipe) recipe; + if (recipe instanceof ShapelessBloodOrbRecipe shapelessBloodOrbRecipe) { List list = shapelessBloodOrbRecipe.getInput(); int width = 3; @@ -60,24 +59,23 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int Object component = list.get(y * width + x); if (component != null) { - if (component instanceof ItemStack) { - GuiHelper.drawItemStack((ItemStack) component, stackX, stackY); + if (component instanceof ItemStack item) { + GuiHelper.drawItemStack(item, stackX, stackY); if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) { - guiBase.renderToolTip((ItemStack) component, stackX, stackY); + guiBase.renderToolTip(item, stackX, stackY); } - } else if (component instanceof Integer) { - GuiHelper.drawItemStack(APISpellHelper.getOrbForLevel((Integer) component), stackX, stackY); + } else if (component instanceof Integer integer) { + GuiHelper.drawItemStack(APISpellHelper.getOrbForLevel(integer), stackX, stackY); if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) { - guiBase.renderToolTip( - APISpellHelper.getOrbForLevel((Integer) component), - stackX, - stackY); + guiBase.renderToolTip(APISpellHelper.getOrbForLevel(integer), stackX, stackY); } } else { - if (((ArrayList) component).isEmpty()) return; - GuiHelper.drawItemStack(((ArrayList) component).get(0), stackX, stackY); + @SuppressWarnings("unchecked") + ArrayList items = (ArrayList) component; + if (items.isEmpty()) return; + GuiHelper.drawItemStack(items.get(0), stackX, stackY); if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) { - guiBase.renderToolTip(((ArrayList) component).get(0), stackX, stackY); + guiBase.renderToolTip(items.get(0), stackX, stackY); } } } @@ -99,24 +97,23 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int int stackY = (y + 1) * 18 + (guiTop + guiBase.ySize / 5); Object component = shapedBloodOrbRecipe.getInput()[y * width + x]; if (component != null) { - if (component instanceof ItemStack) { - GuiHelper.drawItemStack((ItemStack) component, stackX, stackY); + if (component instanceof ItemStack item) { + GuiHelper.drawItemStack(item, stackX, stackY); if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) { - guiBase.renderToolTip((ItemStack) component, stackX, stackY); + guiBase.renderToolTip(item, stackX, stackY); } - } else if (component instanceof Integer) { - GuiHelper.drawItemStack(APISpellHelper.getOrbForLevel((Integer) component), stackX, stackY); + } else if (component instanceof Integer integer) { + GuiHelper.drawItemStack(APISpellHelper.getOrbForLevel(integer), stackX, stackY); if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) { - guiBase.renderToolTip( - APISpellHelper.getOrbForLevel((Integer) component), - stackX, - stackY); + guiBase.renderToolTip(APISpellHelper.getOrbForLevel(integer), stackX, stackY); } } else { - if (((ArrayList) component).isEmpty()) return; - GuiHelper.drawItemStack(((ArrayList) component).get(0), stackX, stackY); + @SuppressWarnings("unchecked") + ArrayList items = (ArrayList) component; + if (items.isEmpty()) return; + GuiHelper.drawItemStack(items.get(0), stackX, stackY); if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) { - guiBase.renderToolTip(((ArrayList) component).get(0), stackX, stackY); + guiBase.renderToolTip(items.get(0), stackX, stackY); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/guide/PageRitualMultiBlock.java b/src/main/java/WayofTime/alchemicalWizardry/api/guide/PageRitualMultiBlock.java deleted file mode 100644 index c6adcfded3..0000000000 --- a/src/main/java/WayofTime/alchemicalWizardry/api/guide/PageRitualMultiBlock.java +++ /dev/null @@ -1,98 +0,0 @@ -package WayofTime.alchemicalWizardry.api.guide; - -import java.util.List; - -import net.minecraft.item.ItemStack; - -import WayofTime.alchemicalWizardry.api.rituals.RitualComponent; -import WayofTime.alchemicalWizardry.api.rituals.Rituals; - -public class PageRitualMultiBlock extends PageMultiBlock { - - private static ItemStack blankStone; - private static ItemStack waterStone; - private static ItemStack fireStone; - private static ItemStack earthStone; - private static ItemStack airStone; - private static ItemStack duskStone; - private static ItemStack dawnStone; - - static { - // blankStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.BLANK); - // waterStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.WATER); - // fireStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.FIRE); - // earthStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.EARTH); - // airStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.AIR); - // duskStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.DUSK); - // dawnStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.DAWN); - } - - private PageRitualMultiBlock(ItemStack[][][] structure) { - super(structure); - } - - public static PageRitualMultiBlock getPageForRitual(String ritualID) { - return getPageForRitual(Rituals.getRitualList(ritualID)); - } - - public static PageRitualMultiBlock getPageForRitual(List ritualComponents) { - int minX = 0; - int minY = 0; - int minZ = 0; - - int maxX = 0; - int maxY = 0; - int maxZ = 0; - - for (RitualComponent comp : ritualComponents) { - minX = Math.min(comp.getX(), minX); - minY = Math.min(comp.getY(), minY); - minZ = Math.min(comp.getZ(), minZ); - - maxX = Math.max(comp.getX(), maxX); - maxY = Math.max(comp.getY(), maxY); - maxZ = Math.max(comp.getZ(), maxZ); - } - - System.out.println( - "Min: (" + minX + ", " + minY + ", " + minZ + "), Max: (" + maxX + ", " + maxY + ", " + maxZ + ")"); - - ItemStack[][][] tempStructure = new ItemStack[maxY - minY + 1][maxX - minX + 1][maxZ - minZ + 1]; // First value - // is - // vertical, - // second is - // down to the - // left, third - // is down to - // the right - - for (RitualComponent comp : ritualComponents) { - tempStructure[comp.getY() - minY][comp.getX() - minX][comp.getZ() - minZ] = getStackForRitualStone( - comp.getStoneType()); - } - - // tempStructure[-minY][-minX][-minZ] = new ItemStack(ModBlocks.blockMasterStone); - - return new PageRitualMultiBlock(tempStructure); - } - - private static ItemStack getStackForRitualStone(int type) { - switch (type) { - case RitualComponent.BLANK: - return blankStone; - case RitualComponent.WATER: - return waterStone; - case RitualComponent.FIRE: - return fireStone; - case RitualComponent.EARTH: - return earthStone; - case RitualComponent.AIR: - return airStone; - case RitualComponent.DUSK: - return duskStone; - case RitualComponent.DAWN: - return dawnStone; - } - return blankStone; - } -} diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/harvest/HarvestRegistry.java b/src/main/java/WayofTime/alchemicalWizardry/api/harvest/HarvestRegistry.java index a1246c3522..3b8f8374e7 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/harvest/HarvestRegistry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/harvest/HarvestRegistry.java @@ -8,7 +8,7 @@ public class HarvestRegistry { - public static List handlerList = new ArrayList(); + public static List handlerList = new ArrayList<>(); public static void registerHarvestHandler(IHarvestHandler handler) { handlerList.add(handler); diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/items/ItemSpellMultiTool.java b/src/main/java/WayofTime/alchemicalWizardry/api/items/ItemSpellMultiTool.java index b66ed9aa54..3ffc5dccd5 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/items/ItemSpellMultiTool.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/items/ItemSpellMultiTool.java @@ -19,6 +19,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; @@ -35,7 +36,7 @@ public class ItemSpellMultiTool extends Item { private static final String harvestLevelSuffix = "harvestLvl"; private static final String digLevelSuffix = "digLvl"; private static final String tagName = "BloodMagicTool"; - private Random rand = new Random(); + private final Random rand = new Random(); public ItemSpellMultiTool() { super(); @@ -50,32 +51,26 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, - EntityLivingBase par3EntityLivingBase) { - float damage = this.getCustomItemAttack(par1ItemStack); + public boolean hitEntity(ItemStack item, EntityLivingBase target, EntityLivingBase attacker) { + float damage = this.getCustomItemAttack(item); - float f = (float) par3EntityLivingBase.getEntityAttribute(SharedMonsterAttributes.attackDamage) - .getAttributeValue(); - - SpellParadigmTool parad = this.loadParadigmFromStack(par1ItemStack); + SpellParadigmTool parad = this.loadParadigmFromStack(item); if (parad != null) { - parad.onLeftClickEntity(par1ItemStack, par2EntityLivingBase, par3EntityLivingBase); + parad.onLeftClickEntity(item, target, attacker); + damage += parad.getAddedDamageForEntity(target); } - damage += parad.getAddedDamageForEntity(par2EntityLivingBase); - - if (rand.nextFloat() < this.getCritChance(par1ItemStack)) { + if (rand.nextFloat() < this.getCritChance(item)) { damage *= 1.75f; } - damage *= f; + damage *= (float) attacker.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); - if (par3EntityLivingBase instanceof EntityPlayer) { - par2EntityLivingBase - .attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) par3EntityLivingBase), damage); + if (attacker instanceof EntityPlayer player) { + target.attackEntityFrom(DamageSource.causePlayerDamage(player), damage); } else { - par2EntityLivingBase.attackEntityFrom(DamageSource.causeMobDamage(par3EntityLivingBase), damage); + target.attackEntityFrom(DamageSource.causeMobDamage(attacker), damage); } return true; @@ -223,24 +218,24 @@ public String getToolClassForMaterial(Material mat) { String testString = "pickaxe"; Material[] matList = this.getMaterialsForToolclass(testString); - for (int i = 0; i < matList.length; i++) { - if (matList[i] == mat) { + for (Material material : matList) { + if (material == mat) { return testString; } } testString = "shovel"; matList = this.getMaterialsForToolclass(testString); - for (int i = 0; i < matList.length; i++) { - if (matList[i] == mat) { + for (Material material : matList) { + if (material == mat) { return testString; } } testString = "axe"; matList = this.getMaterialsForToolclass(testString); - for (int i = 0; i < matList.length; i++) { - if (matList[i] == mat) { + for (Material material : matList) { + if (material == mat) { return testString; } } @@ -248,8 +243,9 @@ public String getToolClassForMaterial(Material mat) { return null; } + @Override public Set getToolClasses(ItemStack stack) { - Set set = new HashSet(); + Set set = new HashSet<>(); if (this.getHarvestLevel(stack, "pickaxe") > -1) { set.add("pickaxe"); @@ -270,10 +266,10 @@ public Set getToolClasses(ItemStack stack) { public float getDigSpeed(ItemStack stack, Block block, int meta) { String toolClass = block.getHarvestTool(meta); - if (toolClass == null || toolClass.equals("")) { + if (toolClass == null || toolClass.isEmpty()) { toolClass = getToolClassOfMaterial(block.getMaterial()); - if (toolClass == "") { + if (toolClass.isEmpty()) { return 1.0f; } } @@ -329,11 +325,6 @@ public boolean canHarvestBlock(Block par1Block, ItemStack itemStack) { return true; } - @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return false; - } - @Override public void onUpdate(ItemStack toolStack, World world, Entity par3Entity, int par4, boolean par5) { if (world.isRemote) { @@ -371,7 +362,7 @@ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, Enti if (mop != null && mop.typeOfHit.equals(MovingObjectPosition.MovingObjectType.BLOCK)) { cost = parad.onRightClickBlock(par1ItemStack, par3EntityPlayer, par2World, mop); } else { - cost = parad.onRightClickAir(par1ItemStack, par2World, par3EntityPlayer); + cost = parad.onRightClickAir(par1ItemStack, par3EntityPlayer); } if (cost > 0) { @@ -382,23 +373,21 @@ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, Enti } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add("A mace filled with ancient alchemy"); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add("A mace filled with ancient alchemy"); - if (!(par1ItemStack.getTagCompound() == null)) { - if (!par1ItemStack.getTagCompound().getString("ownerName").equals("")) { - par3List.add("Current owner: " + par1ItemStack.getTagCompound().getString("ownerName")); + if (!(item.getTagCompound() == null)) { + if (!item.getTagCompound().getString("ownerName").isEmpty()) { + tooltip.add("Current owner: " + item.getTagCompound().getString("ownerName")); } - for (String str : this.getToolListString(par1ItemStack)) { - par3List.add(str); - } + tooltip.addAll(this.getToolListString(item)); - par3List.add(""); - float damage = this.getCustomItemAttack(par1ItemStack); - par3List.add("\u00A79+" + ((int) (damage * 10)) / 10.0f + " " + "Attack Damage"); - float critChance = ((int) (this.getCritChance(par1ItemStack) * 1000)) / 10.0f; - par3List.add("\u00A79+" + critChance + "% " + "Crit Chance"); + tooltip.add(""); + float damage = this.getCustomItemAttack(item); + tooltip.add(EnumChatFormatting.BLUE + "+" + ((int) (damage * 10)) / 10.0f + " " + "Attack Damage"); + float critChance = ((int) (this.getCritChance(item) * 1000)) / 10.0f; + tooltip.add(EnumChatFormatting.BLUE + "+" + critChance + "% " + "Crit Chance"); } } @@ -519,25 +508,24 @@ public void setContainedCrystal(ItemStack container, ItemStack crystal) { public void setDuration(ItemStack container, World world, int duration) { if (world.isRemote) { return; - } else { - World overWorld = DimensionManager.getWorld(0); - long worldtime = overWorld.getTotalWorldTime(); + } + World overWorld = DimensionManager.getWorld(0); + long worldtime = overWorld.getTotalWorldTime(); - if (container.hasTagCompound()) { - NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName); + if (container.hasTagCompound()) { + NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName); - tag.setLong("duration", Math.max(duration + worldtime, worldtime)); + tag.setLong("duration", Math.max(duration + worldtime, worldtime)); - container.getTagCompound().setTag(tagName, tag); - } else { - container.setTagCompound(new NBTTagCompound()); + container.getTagCompound().setTag(tagName, tag); + } else { + container.setTagCompound(new NBTTagCompound()); - NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName); + NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName); - tag.setLong("duration", Math.max(duration + worldtime, worldtime)); + tag.setLong("duration", Math.max(duration + worldtime, worldtime)); - container.getTagCompound().setTag(tagName, tag); - } + container.getTagCompound().setTag(tagName, tag); } } @@ -586,9 +574,9 @@ public SpellParadigmTool loadParadigmFromStack(ItemStack container) { NBTTagList tagList = tagiest.getTagList("Effects", Constants.NBT.TAG_COMPOUND); - List spellEffectList = new LinkedList(); + List spellEffectList = new LinkedList<>(); for (int i = 0; i < tagList.tagCount(); i++) { - NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i); + NBTTagCompound tag = tagList.getCompoundTagAt(i); SpellEffect eff = SpellEffect.getEffectFromTag(tag); if (eff != null) { @@ -667,9 +655,9 @@ public List getToolListString(ItemStack container) { NBTTagList tagList = tagiest.getTagList("ToolTips", Constants.NBT.TAG_COMPOUND); - List toolTipList = new LinkedList(); + List toolTipList = new LinkedList<>(); for (int i = 0; i < tagList.tagCount(); i++) { - NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i); + NBTTagCompound tag = tagList.getCompoundTagAt(i); String str = tag.getString("tip"); if (str != null) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/items/ShapedBloodOrbRecipe.java b/src/main/java/WayofTime/alchemicalWizardry/api/items/ShapedBloodOrbRecipe.java index 08a11c8dc9..b3f04a542e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/items/ShapedBloodOrbRecipe.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/items/ShapedBloodOrbRecipe.java @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; @@ -25,8 +24,8 @@ public class ShapedBloodOrbRecipe implements IRecipe { private static final int MAX_CRAFT_GRID_WIDTH = 3; private static final int MAX_CRAFT_GRID_HEIGHT = 3; - private ItemStack output = null; - private Object[] input = null; + private final ItemStack output; + private final Object[] input; public int width = 0; public int height = 0; private boolean mirrored = true; @@ -42,7 +41,7 @@ public ShapedBloodOrbRecipe(Item result, Object... recipe) { public ShapedBloodOrbRecipe(ItemStack result, Object... recipe) { output = result.copy(); - String shape = ""; + StringBuilder shape = new StringBuilder(); int idx = 0; if (recipe[idx] instanceof Boolean) { @@ -59,26 +58,26 @@ public ShapedBloodOrbRecipe(ItemStack result, Object... recipe) { for (String s : parts) { width = s.length(); - shape += s; + shape.append(s); } height = parts.length; } else { while (recipe[idx] instanceof String) { String s = (String) recipe[idx++]; - shape += s; + shape.append(s); width = s.length(); height++; } } if (width * height != shape.length()) { - String ret = "Invalid shaped ore recipe: "; + StringBuilder ret = new StringBuilder("Invalid shaped ore recipe: "); for (Object tmp : recipe) { - ret += tmp + ", "; + ret.append(tmp).append(", "); } - ret += output; - throw new RuntimeException(ret); + ret.append(output); + throw new RuntimeException(ret.toString()); } HashMap itemMap = new HashMap(); @@ -87,36 +86,31 @@ public ShapedBloodOrbRecipe(ItemStack result, Object... recipe) { Character chr = (Character) recipe[idx]; Object in = recipe[idx + 1]; - if (in instanceof IBloodOrb - || (in instanceof ItemStack && ((ItemStack) in).getItem() instanceof IBloodOrb)) { // If the item is - // an instanceof - // IBloodOrb then - // save the level - // of the - // orb - if (in instanceof ItemStack) itemMap.put(chr, ((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel()); - else itemMap.put(chr, ((IBloodOrb) in).getOrbLevel()); - } else if (in instanceof ItemStack) { - itemMap.put(chr, ((ItemStack) in).copy()); - } else if (in instanceof Item) { - itemMap.put(chr, new ItemStack((Item) in)); - } else if (in instanceof Block) { - itemMap.put(chr, new ItemStack((Block) in, 1, OreDictionary.WILDCARD_VALUE)); - } else if (in instanceof String) { - itemMap.put(chr, OreDictionary.getOres((String) in)); + if (in instanceof IBloodOrb orb) { + itemMap.put(chr, orb.getOrbLevel()); + } else if (in instanceof ItemStack stack && stack.getItem() instanceof IBloodOrb orb) { + itemMap.put(chr, orb.getOrbLevel()); + } else if (in instanceof ItemStack stack) { + itemMap.put(chr, stack.copy()); + } else if (in instanceof Item item) { + itemMap.put(chr, new ItemStack(item)); + } else if (in instanceof Block block) { + itemMap.put(chr, new ItemStack(block, 1, OreDictionary.WILDCARD_VALUE)); + } else if (in instanceof String string) { + itemMap.put(chr, OreDictionary.getOres(string)); } else { - String ret = "Invalid shaped ore recipe: "; + StringBuilder ret = new StringBuilder("Invalid shaped ore recipe: "); for (Object tmp : recipe) { - ret += tmp + ", "; + ret.append(tmp).append(", "); } - ret += output; - throw new RuntimeException(ret); + ret.append(output); + throw new RuntimeException(ret.toString()); } } input = new Object[width * height]; int x = 0; - for (char chr : shape.toCharArray()) { + for (char chr : shape.toString().toCharArray()) { input[x++] = itemMap.get(chr); } } @@ -193,29 +187,27 @@ private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolea } ItemStack slot = inv.getStackInRowAndColumn(x, y); - // If target is integer, then we should be check the blood orb value of the item instead - if (target instanceof Integer) { - if (slot != null && slot.getItem() instanceof IBloodOrb) { - IBloodOrb orb = (IBloodOrb) slot.getItem(); - if (orb.getOrbLevel() < (Integer) target) { - return false; - } - } else return false; - } else if (target instanceof ItemStack) { - if (!OreDictionary.itemMatches((ItemStack) target, slot, false)) { + // If target is integer, then we should check the blood orb value of the item instead + if (target instanceof Integer orbLevel) { + if (slot == null || !(slot.getItem() instanceof IBloodOrb orb)) { return false; } - } else if (target instanceof ArrayList) { - boolean matched = false; - - Iterator itr = ((ArrayList) target).iterator(); - while (itr.hasNext() && !matched) { - matched = OreDictionary.itemMatches(itr.next(), slot, false); + if (orb.getOrbLevel() < orbLevel) { + return false; } - - if (!matched) { + } else if (target instanceof ItemStack stack) { + if (!OreDictionary.itemMatches(stack, slot, false)) { return false; } + } else if (target instanceof ArrayList) { + boolean matched = false; + for (ItemStack item : ((ArrayList) target)) { + if (OreDictionary.itemMatches(item, slot, false)) { + matched = true; + break; + } + } + if (!matched) return false; } else if (target == null && slot != null) { return false; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/items/ShapelessBloodOrbRecipe.java b/src/main/java/WayofTime/alchemicalWizardry/api/items/ShapelessBloodOrbRecipe.java index 6e5eaf14eb..d157ee62b4 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/items/ShapelessBloodOrbRecipe.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/items/ShapelessBloodOrbRecipe.java @@ -1,8 +1,6 @@ package WayofTime.alchemicalWizardry.api.items; import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -22,8 +20,8 @@ */ public class ShapelessBloodOrbRecipe implements IRecipe { - private ItemStack output = null; - private ArrayList input = new ArrayList(); + private final ItemStack output; + private final ArrayList input = new ArrayList<>(); public ShapelessBloodOrbRecipe(Block result, Object... recipe) { this(new ItemStack(result), recipe); @@ -36,34 +34,33 @@ public ShapelessBloodOrbRecipe(Item result, Object... recipe) { public ShapelessBloodOrbRecipe(ItemStack result, Object... recipe) { output = result.copy(); for (Object in : recipe) { - if (in instanceof IBloodOrb) { // If the item is an instanceof IBloodOrb then save the level of the orb - input.add(((IBloodOrb) in).getOrbLevel()); - } else if (in instanceof ItemStack) { - if (((ItemStack) in).getItem() instanceof IBloodOrb) { - input.add(((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel()); - } else input.add(((ItemStack) in).copy()); - } else if (in instanceof Item) { - input.add(new ItemStack((Item) in)); - } else if (in instanceof Block) { - input.add(new ItemStack((Block) in)); - } else if (in instanceof String) { - input.add(OreDictionary.getOres((String) in)); + if (in instanceof IBloodOrb orb) { + input.add(orb.getOrbLevel()); + } else if (in instanceof ItemStack stack && stack.getItem() instanceof IBloodOrb orb) { + input.add(orb.getOrbLevel()); + } else if (in instanceof ItemStack stack) { + input.add(stack.copy()); + } else if (in instanceof Item item) { + input.add(new ItemStack(item)); + } else if (in instanceof Block block) { + input.add(new ItemStack(block, 1, OreDictionary.WILDCARD_VALUE)); + } else if (in instanceof String string) { + input.add(OreDictionary.getOres(string)); } else { - String ret = "Invalid shapeless ore recipe: "; + StringBuilder ret = new StringBuilder("Invalid shapeless ore recipe: "); for (Object tmp : recipe) { - ret += tmp + ", "; + ret.append(tmp).append(", "); } - ret += output; - throw new RuntimeException(ret); + ret.append(output); + throw new RuntimeException(ret.toString()); } } } - @SuppressWarnings("unchecked") ShapelessBloodOrbRecipe(ShapelessRecipes recipe, Map replacements) { output = recipe.getRecipeOutput(); - for (ItemStack ingred : ((List) recipe.recipeItems)) { + for (ItemStack ingred : recipe.recipeItems) { Object finalObj = ingred; for (Entry replace : replacements.entrySet()) { if (OreDictionary.itemMatches(replace.getKey(), ingred, false)) { @@ -92,36 +89,35 @@ public ItemStack getCraftingResult(InventoryCrafting var1) { @SuppressWarnings("unchecked") @Override - public boolean matches(InventoryCrafting var1, World world) { - ArrayList required = new ArrayList(input); + public boolean matches(InventoryCrafting inv, World world) { + ArrayList required = new ArrayList<>(input); - for (int x = 0; x < var1.getSizeInventory(); x++) { - ItemStack slot = var1.getStackInSlot(x); + for (int x = 0; x < inv.getSizeInventory(); x++) { + ItemStack slot = inv.getStackInSlot(x); if (slot != null) { boolean inRecipe = false; - Iterator req = required.iterator(); - while (req.hasNext()) { + for (Object next : required) { boolean match = false; - Object next = req.next(); - - // If target is integer, then we should be check the blood orb value of the item instead - if (next instanceof Integer) { - if (slot != null && slot.getItem() instanceof IBloodOrb) { - IBloodOrb orb = (IBloodOrb) slot.getItem(); - if (orb.getOrbLevel() < (Integer) next) { - return false; - } - } else return false; + // If target is integer, then we should check the blood orb value of the item instead + if (next instanceof Integer orbLevel) { + if (!(slot.getItem() instanceof IBloodOrb orb)) { + return false; + } + if (orb.getOrbLevel() < orbLevel) { + return false; + } match = true; - } else if (next instanceof ItemStack) { - match = OreDictionary.itemMatches((ItemStack) next, slot, false); + } else if (next instanceof ItemStack item) { + match = OreDictionary.itemMatches(item, slot, false); } else if (next instanceof ArrayList) { - Iterator itr = ((ArrayList) next).iterator(); - while (itr.hasNext() && !match) { - match = OreDictionary.itemMatches(itr.next(), slot, false); + for (ItemStack item : ((ArrayList) next)) { + if (OreDictionary.itemMatches(item, slot, false)) { + match = true; + break; + } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/items/interfaces/IBindable.java b/src/main/java/WayofTime/alchemicalWizardry/api/items/interfaces/IBindable.java index 99d1fc01b4..cb484fbf8c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/items/interfaces/IBindable.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/items/interfaces/IBindable.java @@ -19,16 +19,16 @@ public interface IBindable { * Used by bound tools and the energy blaster/bazooka to check if they should skip their right click function. * Drains the soul network by the amount returned by rightClickCost. */ - default boolean checkRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (toggle(par1ItemStack, par2World, par3EntityPlayer)) { + default boolean checkRightClick(ItemStack item, World world, EntityPlayer player) { + if (toggle(item, world, player)) { return true; } - if (par2World.isRemote) { + if (world.isRemote) { return true; } - if (!isActive(par1ItemStack) || SpellHelper.isFakePlayer(par2World, par3EntityPlayer)) { + if (!isActive(item) || SpellHelper.isFakePlayer(world, player)) { return true; } @@ -36,12 +36,11 @@ default boolean checkRightClick(ItemStack par1ItemStack, World par2World, Entity return true; } - if (par3EntityPlayer.isPotionActive(AlchemicalWizardry.customPotionInhibit)) { + if (player.isPotionActive(AlchemicalWizardry.customPotionInhibit)) { return true; } - if (!(par3EntityPlayer.capabilities.isCreativeMode - || EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, rightClickCost()))) { + if (!(player.capabilities.isCreativeMode || EnergyItems.syphonBatteries(item, player, rightClickCost()))) { return true; } @@ -51,45 +50,45 @@ default boolean checkRightClick(ItemStack par1ItemStack, World par2World, Entity /** * Adds the active state and owner information to an item if it has the relevant tags. */ - default void addBindingInformation(ItemStack par1ItemStack, List par3List) { - NBTTagCompound itemTag = getTag(par1ItemStack); + default void addBindingInformation(ItemStack item, List tooltip) { + NBTTagCompound itemTag = getTag(item); if (itemTag.getBoolean("isActive")) { - par3List.add(StatCollector.translateToLocal("tooltip.sigil.state.activated")); + tooltip.add(StatCollector.translateToLocal("tooltip.sigil.state.activated")); } else if (itemTag.hasKey("isActive")) { // Only if present and set to false rather than not present at all - par3List.add(StatCollector.translateToLocal("tooltip.sigil.state.deactivated")); + tooltip.add(StatCollector.translateToLocal("tooltip.sigil.state.deactivated")); } - if (!itemTag.getString("ownerName").equals("")) { - par3List.add( + if (!itemTag.getString("ownerName").isEmpty()) { + tooltip.add( StatCollector.translateToLocal("tooltip.owner.currentowner") + " " + itemTag.getString("ownerName")); } } - static void setActive(ItemStack par1ItemStack, boolean state) { - NBTTagCompound itemTag = getTag(par1ItemStack); + static void setActive(ItemStack item, boolean state) { + NBTTagCompound itemTag = getTag(item); itemTag.setBoolean("isActive", state); } - static boolean isActive(ItemStack par1ItemStack) { - NBTTagCompound itemTag = getTag(par1ItemStack); + static boolean isActive(ItemStack item) { + NBTTagCompound itemTag = getTag(item); return itemTag.getBoolean("isActive"); } - static NBTTagCompound getTag(ItemStack par1ItemStack) { - NBTTagCompound itemTag = par1ItemStack.getTagCompound(); + static NBTTagCompound getTag(ItemStack item) { + NBTTagCompound itemTag = item.getTagCompound(); if (itemTag == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); - itemTag = par1ItemStack.getTagCompound(); + item.setTagCompound(new NBTTagCompound()); + itemTag = item.getTagCompound(); } return itemTag; } - default boolean toggle(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - setActive(par1ItemStack, !isActive(par1ItemStack)); - setDrainTick(par1ItemStack, par2World); + default boolean toggle(ItemStack item, World world, EntityPlayer player) { + if (!checkAndSetItemOwner(item, player) || player.isSneaking()) { + setActive(item, !isActive(item)); + setDrainTick(item, world); return true; } return false; @@ -99,11 +98,11 @@ default boolean toggle(ItemStack par1ItemStack, World par2World, EntityPlayer pa * Checks if the current tick is the proper tick to do a passive drain based on getDrainTicks. If it is, it runs * doPassiveDrain and returns true. Otherwise, returns false. */ - default boolean checkPassiveDrain(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - NBTTagCompound itemTag = getTag(par1ItemStack); - if (par2World.getTotalWorldTime() % this.drainTicks() == itemTag.getInteger("worldTimeDelay") + default boolean checkPassiveDrain(ItemStack item, World world, EntityPlayer player) { + NBTTagCompound itemTag = getTag(item); + if (world.getTotalWorldTime() % this.drainTicks() == itemTag.getInteger("worldTimeDelay") && itemTag.getBoolean("isActive")) { - this.doPassiveDrain(par1ItemStack, par3EntityPlayer); + this.doPassiveDrain(item, player); return true; } return false; @@ -112,10 +111,10 @@ default boolean checkPassiveDrain(ItemStack par1ItemStack, World par2World, Enti /** * The action to take when checkPassiveDrain is run on the proper tick based on getDrainTicks. */ - default void doPassiveDrain(ItemStack par1ItemStack, EntityPlayer par3EntityPlayer) { - if (!par3EntityPlayer.capabilities.isCreativeMode) { - if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, drainCost())) { - setActive(par1ItemStack, false); + default void doPassiveDrain(ItemStack item, EntityPlayer player) { + if (!player.capabilities.isCreativeMode) { + if (!EnergyItems.syphonBatteries(item, player, drainCost())) { + setActive(item, false); } } } @@ -123,9 +122,8 @@ default void doPassiveDrain(ItemStack par1ItemStack, EntityPlayer par3EntityPlay /** * Sets the drain tick delay based on the current world age and getDrainTicks(). */ - default void setDrainTick(ItemStack par1ItemStack, World par2World) { - getTag(par1ItemStack) - .setInteger("worldTimeDelay", (int) (par2World.getTotalWorldTime() - 1) % this.drainTicks()); + default void setDrainTick(ItemStack item, World world) { + getTag(item).setInteger("worldTimeDelay", (int) (world.getTotalWorldTime() - 1) % this.drainTicks()); } static boolean checkAndSetItemOwner(ItemStack item, EntityPlayer player) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/items/interfaces/ISigil.java b/src/main/java/WayofTime/alchemicalWizardry/api/items/interfaces/ISigil.java index 7b0aa972cd..47f02dc4a2 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/items/interfaces/ISigil.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/items/interfaces/ISigil.java @@ -12,20 +12,19 @@ public interface ISigil extends IBindable { * Toggles the state of the sigil. Returns true if the sigil is active after the toggle or false if it is inactive * after the toggle. */ - default boolean toggleSigil(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - IBindable.setActive(par1ItemStack, !IBindable.isActive(par1ItemStack)); + default boolean toggleSigil(ItemStack item, World world, EntityPlayer player) { + IBindable.setActive(item, !IBindable.isActive(item)); - if (!par3EntityPlayer.capabilities.isCreativeMode - && !EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, this.drainCost())) { - IBindable.setActive(par1ItemStack, false); + if (!player.capabilities.isCreativeMode && !EnergyItems.syphonBatteries(item, player, this.drainCost())) { + IBindable.setActive(item, false); } - if (IBindable.isActive(par1ItemStack)) { - par1ItemStack.setItemDamage(1); - this.setDrainTick(par1ItemStack, par2World); + if (IBindable.isActive(item)) { + item.setItemDamage(1); + this.setDrainTick(item, world); return true; } else { - par1ItemStack.setItemDamage(par1ItemStack.getMaxDamage()); + item.setItemDamage(item.getMaxDamage()); return false; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/rituals/LocalRitualStorage.java b/src/main/java/WayofTime/alchemicalWizardry/api/rituals/LocalRitualStorage.java index b1aba07748..d745a95f88 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/rituals/LocalRitualStorage.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/rituals/LocalRitualStorage.java @@ -32,8 +32,8 @@ public Int3 getLocation() { } public void setLocation(Int3 location) { - this.xCoord = location.xCoord; - this.yCoord = location.yCoord; - this.zCoord = location.zCoord; + this.xCoord = location.x(); + this.yCoord = location.y(); + this.zCoord = location.z(); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/rituals/RitualComponent.java b/src/main/java/WayofTime/alchemicalWizardry/api/rituals/RitualComponent.java index 8e06f34af4..755b144c4c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/rituals/RitualComponent.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/rituals/RitualComponent.java @@ -1,11 +1,7 @@ package WayofTime.alchemicalWizardry.api.rituals; -public class RitualComponent { +public record RitualComponent(int x, int y, int z, int stoneType) { - private int x; - private int y; - private int z; - private int stoneType; public static final int BLANK = 0; public static final int WATER = 1; public static final int FIRE = 2; @@ -14,52 +10,21 @@ public class RitualComponent { public static final int DUSK = 5; public static final int DAWN = 6; - public RitualComponent(int x, int y, int z, int stoneType) { - this.x = x; - this.y = y; - this.z = z; - this.stoneType = stoneType; + public int x(int direction) { + return switch (direction) { + case 2 -> -this.z(); + case 3 -> -this.x(); + case 4 -> this.z(); + default -> this.x(); + }; } - public int getX() { - return this.x; - } - - public int getY() { - return this.y; - } - - public int getZ() { - return this.z; - } - - public int getX(int direction) { - switch (direction) { - case 2: - return -this.getZ(); - case 3: - return -this.getX(); - case 4: - return this.getZ(); - default: - return this.getX(); - } - } - - public int getZ(int direction) { - switch (direction) { - case 2: - return this.getX(); - case 3: - return -this.getZ(); - case 4: - return -this.getX(); - default: - return this.getZ(); - } - } - - public int getStoneType() { - return this.stoneType; + public int z(int direction) { + return switch (direction) { + case 2 -> this.x(); + case 3 -> -this.z(); + case 4 -> -this.x(); + default -> this.z(); + }; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/rituals/Rituals.java b/src/main/java/WayofTime/alchemicalWizardry/api/rituals/Rituals.java index 2c6e190349..0fc37d92fa 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/rituals/Rituals.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/rituals/Rituals.java @@ -27,8 +27,8 @@ public class Rituals { public final MRSRenderer customRenderer; - public static Map ritualMap = new HashMap(); - public static List keyList = new LinkedList(); + public static Map ritualMap = new HashMap<>(); + public static List keyList = new LinkedList<>(); public Rituals(int crystalLevel, int actCost, RitualEffect effect, String name, MRSRenderer renderer) { this.crystalLevel = crystalLevel; @@ -83,11 +83,9 @@ public static boolean registerRitual(String key, int crystalLevel, int actCost, public void removeRitualFromList() { if (ritualMap.containsValue(this)) { - ritualMap.remove(ritualMap.remove(this.name)); - } - if (keyList.contains(this.name)) { - keyList.remove(this.name); + ritualMap.remove(this.name); } + keyList.remove(this.name); } public static String checkValidRitual(World world, int x, int y, int z) { @@ -132,17 +130,17 @@ public static boolean checkDirectionOfRitualValid(World world, int x, int y, int TileEntity te; for (RitualComponent rc : ritual) { - test = world.getBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)); - te = world.getTileEntity(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)); + test = world.getBlock(x + rc.x(direction), y + rc.y(), z + rc.z(direction)); + te = world.getTileEntity(x + rc.x(direction), y + rc.y(), z + rc.z(direction)); if (!(test instanceof IRitualStone && ((IRitualStone) test).isRuneType( world, - x + rc.getX(direction), + x + rc.x(direction), y, - z + rc.getZ(direction), - world.getBlockMetadata(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)), - rc.getStoneType())) - && !(te instanceof ITileRitualStone && ((ITileRitualStone) te).isRuneType(rc.getStoneType()))) { + z + rc.z(direction), + world.getBlockMetadata(x + rc.x(direction), y + rc.y(), z + rc.z(direction)), + rc.stoneType())) + && !(te instanceof ITileRitualStone && ((ITileRitualStone) te).isRuneType(rc.stoneType()))) { return false; } } @@ -287,7 +285,7 @@ public static String getNextRitualKey(String key) { String firstKey = ""; for (String str : keyList) { - if (firstKey.equals("")) { + if (firstKey.isEmpty()) { firstKey = str; } if (hasSpotted) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/soulNetwork/ComplexNetworkHandler.java b/src/main/java/WayofTime/alchemicalWizardry/api/soulNetwork/ComplexNetworkHandler.java index 39886dd28c..3e473c26cf 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/soulNetwork/ComplexNetworkHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/soulNetwork/ComplexNetworkHandler.java @@ -24,7 +24,7 @@ public class ComplexNetworkHandler { public static String fileName = "config/BloodMagic/soulnetworkKeys"; - static HashMap keyMap = new HashMap(); + static HashMap keyMap = new HashMap<>(); public static UUID getUUIDFromPlayer(EntityPlayer player) { return player.getPersistentID(); @@ -90,13 +90,12 @@ public static void load() { try { br = new BufferedReader(new FileReader(save)); - HashMap schema = gson.fromJson(br, keyMap.getClass()); - keyMap = schema; + keyMap = gson.fromJson(br, keyMap.getClass()); if (keyMap != null) { for (Entry entry : keyMap.entrySet()) { - System.out.println("" + entry.getValue() + " gave: " + entry.getKey()); + System.out.println(entry.getValue() + " gave: " + entry.getKey()); } } } catch (FileNotFoundException e) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/soulNetwork/SoulNetworkHandler.java b/src/main/java/WayofTime/alchemicalWizardry/api/soulNetwork/SoulNetworkHandler.java index 2ed78129d3..c6b67e775c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/soulNetwork/SoulNetworkHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/soulNetwork/SoulNetworkHandler.java @@ -24,7 +24,7 @@ public class SoulNetworkHandler { public static boolean syphonFromNetworkWhileInContainer(ItemStack ist, int damageToBeDone) { String ownerName = ""; - if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals(""))) { + if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").isEmpty())) { ownerName = ist.getTagCompound().getString("ownerName"); } @@ -121,26 +121,19 @@ public static void setMaxEssenceToMax(String ownerName, int maxEssence) { */ @Deprecated public static int getMaximumForOrbTier(int maxOrb) { - switch (maxOrb) { - case 1: - return 5000; - case 2: - return 25000; - case 3: - return 150000; - case 4: - return 1000000; - case 5: - return 10000000; - case 6: - return 30000000; - default: - return 1; - } + return switch (maxOrb) { + case 1 -> 5000; + case 2 -> 25000; + case 3 -> 150000; + case 4 -> 1000000; + case 5 -> 10000000; + case 6 -> 30000000; + default -> 1; + }; } public static int syphonFromNetwork(ItemStack ist, int damageToBeDone) { - if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals(""))) { + if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").isEmpty())) { String ownerName = ist.getTagCompound().getString("ownerName"); return syphonFromNetwork(ownerName, damageToBeDone); @@ -177,7 +170,7 @@ public static int syphonFromNetwork(String ownerName, int damageToBeDone) { * * @param ist Owned itemStack * @param player Player using the item - * @param drain + * @param drain The amount of LP to drain * @return True if the action should be executed and false if it should not. Always returns false if client-sided. */ public static boolean syphonAndDamageFromNetwork(ItemStack ist, EntityPlayer player, int drain) { @@ -185,7 +178,7 @@ public static boolean syphonAndDamageFromNetwork(ItemStack ist, EntityPlayer pla return false; } - if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals(""))) { + if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").isEmpty())) { String ownerName = ist.getTagCompound().getString("ownerName"); ItemDrainNetworkEvent event = new ItemDrainNetworkEvent(player, ownerName, ist, drain); @@ -217,15 +210,13 @@ public static boolean syphonAndDamageFromNetwork(String ownerName, EntityPlayer } World world = player.worldObj; - if (world != null) { - world.playSoundEffect( - (double) ((float) player.posX + 0.5F), - (double) ((float) player.posY + 0.5F), - (double) ((float) player.posZ + 0.5F), - "random.fizz", - 0.5F, - 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); - } + world.playSoundEffect( + (float) player.posX + 0.5F, + (float) player.posY + 0.5F, + (float) player.posZ + 0.5F, + "random.fizz", + 0.5F, + 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); int amount = SoulNetworkHandler.syphonFromNetwork(ownerName, damageToBeDone); @@ -235,7 +226,7 @@ public static boolean syphonAndDamageFromNetwork(String ownerName, EntityPlayer } public static boolean canSyphonFromOnlyNetwork(ItemStack ist, int damageToBeDone) { - if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals(""))) { + if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").isEmpty())) { String ownerName = ist.getTagCompound().getString("ownerName"); return canSyphonFromOnlyNetwork(ownerName, damageToBeDone); @@ -299,9 +290,6 @@ public static void setCurrentEssence(String ownerName, int essence) { /** * A method to add to an owner's network up to a maximum value. * - * @param ownerName - * @param addedEssence - * @param maximum * @return amount added to the network */ public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence, int maximum) { @@ -384,7 +372,7 @@ public static boolean checkAndSetItemPlayer(ItemStack item, EntityPlayer player) } } - if (item.hasTagCompound() && !item.getTagCompound().getString("ownerName").equals("")) return true; + if (item.hasTagCompound() && !item.getTagCompound().getString("ownerName").isEmpty()) return true; ItemBindEvent event = new ItemBindEvent(player, SoulNetworkHandler.getUsername(player), item); @@ -416,7 +404,7 @@ public static EntityPlayer getPlayerForUsername(String str) { } public static void causeNauseaToPlayer(ItemStack stack) { - if (stack.getTagCompound() != null && !(stack.getTagCompound().getString("ownerName").equals(""))) { + if (stack.getTagCompound() != null && !(stack.getTagCompound().getString("ownerName").isEmpty())) { String ownerName = stack.getTagCompound().getString("ownerName"); SoulNetworkHandler.causeNauseaToPlayer(ownerName); diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/spell/APISpellHelper.java b/src/main/java/WayofTime/alchemicalWizardry/api/spell/APISpellHelper.java index 61aedd5fbc..38b9363b9a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/spell/APISpellHelper.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/spell/APISpellHelper.java @@ -10,8 +10,6 @@ import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; @@ -21,14 +19,12 @@ import WayofTime.alchemicalWizardry.ModItems; import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent; import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry; -import cpw.mods.fml.common.registry.GameRegistry; public class APISpellHelper { /** * Thanks Kihira! <3 * - * @param player * @return persistent data tag */ private static NBTTagCompound getPersistentDataTag(EntityPlayer player) { @@ -174,22 +170,15 @@ public static void setPlayerReagentRegenCooldownTag(EntityPlayer player, int amo } public static ItemStack getOrbForLevel(int level) { - switch (level) { - case 1: - return new ItemStack(ModItems.weakBloodOrb); - case 2: - return new ItemStack(ModItems.apprenticeBloodOrb); - case 3: - return new ItemStack(ModItems.magicianBloodOrb); - case 4: - return new ItemStack(ModItems.masterBloodOrb); - case 5: - return new ItemStack(ModItems.archmageBloodOrb); - case 6: - return new ItemStack(ModItems.transcendentBloodOrb); - default: - return new ItemStack(Blocks.fire); - } + return switch (level) { + case 1 -> new ItemStack(ModItems.weakBloodOrb); + case 2 -> new ItemStack(ModItems.apprenticeBloodOrb); + case 3 -> new ItemStack(ModItems.magicianBloodOrb); + case 4 -> new ItemStack(ModItems.masterBloodOrb); + case 5 -> new ItemStack(ModItems.archmageBloodOrb); + case 6 -> new ItemStack(ModItems.transcendentBloodOrb); + default -> new ItemStack(Blocks.fire); + }; } public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range) { @@ -207,10 +196,6 @@ public static MovingObjectPosition raytraceFromEntity(World world, Entity player float f6 = MathHelper.sin(-f1 * 0.017453292F); float f7 = f4 * f5; float f8 = f3 * f5; - // if (player instanceof EntityPlayerMP) - { - // d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance(); - } Vec3 vec31 = vec3.addVector((double) f7 * range, (double) f6 * range, (double) f8 * range); return world.func_147447_a(vec3, vec31, par3, !par3, par3); } @@ -259,90 +244,18 @@ public static void spawnItemListInWorld(List items, World world, floa } public static String getNumeralForInt(int num) { - switch (num) { - case 1: - return "I"; - case 2: - return "II"; - case 3: - return "III"; - case 4: - return "IV"; - case 5: - return "V"; - case 6: - return "VI"; - case 7: - return "VII"; - case 8: - return "VIII"; - case 9: - return "IX"; - case 10: - return "X"; - default: - return ""; - } - } - - public static Block getBlockForString(String str) { - String[] parts = str.split(":"); - String modId = parts[0]; - String name = parts[1]; - return GameRegistry.findBlock(modId, name); - } - - public static Item getItemForString(String str) { - String[] parts = str.split(":"); - String modId = parts[0]; - String name = parts[1]; - return GameRegistry.findItem(modId, name); - } - - public static ItemStack getItemStackForString(String str) { - String[] parts = str.split(":"); - int meta = 0; - if (parts.length >= 3) { - meta = Integer.decode(parts[2]); - } else if (parts.length < 2) { - return null; - } - String modId = parts[0]; - String name = parts[1]; - - String itemString = modId + ":" + name; - Item item = APISpellHelper.getItemForString(itemString); - if (item != null) { - return new ItemStack(item, 1, meta); - } - - Block block = APISpellHelper.getBlockForString(itemString); - if (block != null) { - return new ItemStack(block, 1, meta); - } - - return null; - } - - public static IRecipe getRecipeForItemStack(ItemStack reqStack) // Does not match NBT. Durrr! -smack- - { - if (reqStack == null) { - return null; // Why are you even doing this to yourself!? You know this can't be healthy! - } - List craftingList = CraftingManager.getInstance().getRecipeList(); - for (Object posRecipe : craftingList) { - if (posRecipe instanceof IRecipe) { - ItemStack outputStack = ((IRecipe) posRecipe).getRecipeOutput(); - if (outputStack != null) { - if (outputStack.getItem() == reqStack.getItem() && (outputStack.getItem().getHasSubtypes() - ? outputStack.getItemDamage() == reqStack.getItemDamage() - : true)) { - return (IRecipe) posRecipe; - } - } - } - } - - return null; + return switch (num) { + case 1 -> "I"; + case 2 -> "II"; + case 3 -> "III"; + case 4 -> "IV"; + case 5 -> "V"; + case 6 -> "VI"; + case 7 -> "VII"; + case 8 -> "VIII"; + case 9 -> "IX"; + case 10 -> "X"; + default -> ""; + }; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/spell/EntitySpellProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/api/spell/EntitySpellProjectile.java index e7bdf85fee..f42bd7c280 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/spell/EntitySpellProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/spell/EntitySpellProjectile.java @@ -1,7 +1,6 @@ package WayofTime.alchemicalWizardry.api.spell; import java.util.ArrayList; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -43,35 +42,27 @@ public class EntitySpellProjectile extends Entity implements IProjectile { // Custom variables private int maxRicochet = 0; private float damage = 1; - public List impactList = new ArrayList(); + public List impactList = new ArrayList<>(); private boolean penetration = false; - public List updateEffectList = new ArrayList(); - public List spellEffectList = new LinkedList(); + public List updateEffectList = new ArrayList<>(); + public List spellEffectList = new LinkedList<>(); private int blocksBroken = 0; - public EntitySpellProjectile(World par1World) { - super(par1World); + public EntitySpellProjectile(World world) { + super(world); this.setSize(0.5F, 0.5F); } - public EntitySpellProjectile(World par1World, double par2, double par4, double par6) { - super(par1World); - this.setSize(0.5F, 0.5F); - this.setPosition(par2, par4, par6); - yOffset = 0.0F; - } - - public EntitySpellProjectile(World par1World, EntityPlayer par2EntityPlayer) { - super(par1World); - shootingEntity = par2EntityPlayer; - float par3 = 0.8F; + public EntitySpellProjectile(World world, EntityPlayer player) { + super(world); + shootingEntity = player; this.setSize(0.1F, 0.1F); this.setLocationAndAngles( - par2EntityPlayer.posX, - par2EntityPlayer.posY + par2EntityPlayer.getEyeHeight(), - par2EntityPlayer.posZ, - par2EntityPlayer.rotationYaw, - par2EntityPlayer.rotationPitch); + player.posX, + player.posY + player.getEyeHeight(), + player.posZ, + player.rotationYaw, + player.rotationPitch); posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; posY -= 0.2D; posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; @@ -82,7 +73,7 @@ public EntitySpellProjectile(World par1World, EntityPlayer par2EntityPlayer) { motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI); motionY = -MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI); - this.setThrowableHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F); + this.setThrowableHeading(motionX, motionY, motionZ, 1.2f, 1.0F); } @Override @@ -90,62 +81,48 @@ protected void entityInit() { dataWatcher.addObject(16, 0); } - /** - * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. - */ @Override - public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8) { - float var9 = MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5); - var1 /= var9; - var3 /= var9; - var5 /= var9; - var1 += rand.nextGaussian() * 0.007499999832361937D * var8; - var3 += rand.nextGaussian() * 0.007499999832361937D * var8; - var5 += rand.nextGaussian() * 0.007499999832361937D * var8; - var1 *= var7; - var3 *= var7; - var5 *= var7; - motionX = var1; - motionY = var3; - motionZ = var5; - float var10 = MathHelper.sqrt_double(var1 * var1 + var5 * var5); - prevRotationYaw = rotationYaw = (float) (Math.atan2(var1, var5) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float) (Math.atan2(var3, var10) * 180.0D / Math.PI); + public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) { + float distance = MathHelper.sqrt_double(x * x + y * y + z * z); + x /= distance; + y /= distance; + z /= distance; + x += rand.nextGaussian() * 0.0075D * inaccuracy; + y += rand.nextGaussian() * 0.0075D * inaccuracy; + z += rand.nextGaussian() * 0.0075D * inaccuracy; + x *= velocity; + y *= velocity; + z *= velocity; + motionX = x; + motionY = y; + motionZ = z; + float horizontalDistance = MathHelper.sqrt_double(x * x + z * z); + prevRotationYaw = rotationYaw = (float) (Math.atan2(x, z) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch = (float) (Math.atan2(y, horizontalDistance) * 180.0D / Math.PI); } @Override @SideOnly(Side.CLIENT) - /** - * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX, - * posY, posZ, yaw, pitch - */ - public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) { - this.setPosition(par1, par3, par5); - this.setRotation(par7, par8); + public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int rotationIncrements) { + this.setPosition(x, y, z); + this.setRotation(yaw, pitch); } @Override @SideOnly(Side.CLIENT) - /** - * Sets the velocity to the args. Args: x, y, z - */ - public void setVelocity(double par1, double par3, double par5) { - motionX = par1; - motionY = par3; - motionZ = par5; + public void setVelocity(double x, double y, double z) { + motionX = x; + motionY = y; + motionZ = z; if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) { - float var7 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); - prevRotationYaw = rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float) (Math.atan2(par3, var7) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch; + float horizontalDistance = MathHelper.sqrt_double(x * x + z * z); + prevRotationYaw = rotationYaw = (float) (Math.atan2(x, z) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch = (float) (Math.atan2(y, horizontalDistance) * 180.0D / Math.PI); prevRotationYaw = rotationYaw; this.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch); } } - /** - * Called to update the entity's position/logic. - */ @Override public void onUpdate() { super.onUpdate(); @@ -154,17 +131,16 @@ public void onUpdate() { this.setDead(); } if (shootingEntity == null) { - List players = worldObj.getEntitiesWithinAABB( + List players = worldObj.getEntitiesWithinAABB( EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1)); - Iterator i = players.iterator(); + double closestDistance = Double.MAX_VALUE; EntityPlayer closestPlayer = null; - while (i.hasNext()) { - EntityPlayer e = (EntityPlayer) i.next(); - double distance = e.getDistanceToEntity(this); + for (EntityPlayer player : players) { + double distance = player.getDistanceToEntity(this); if (distance < closestDistance) { - closestPlayer = e; + closestPlayer = player; } } if (closestPlayer != null) { @@ -172,84 +148,69 @@ public void onUpdate() { } } if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) { - float var1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); + float horizontalDistance = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); prevRotationYaw = rotationYaw = (float) (Math.atan2(motionX, motionZ) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float) (Math.atan2(motionY, var1) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch = (float) (Math.atan2(motionY, horizontalDistance) * 180.0D / Math.PI); } - Block var16 = worldObj.getBlock(xTile, yTile, zTile); + Block block = worldObj.getBlock(xTile, yTile, zTile); - if (var16 != null) { - var16.setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile); - AxisAlignedBB var2 = var16.getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile); + if (block != null) { + block.setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile); + AxisAlignedBB collision = block.getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile); - if (var2 != null && var2.isVecInside(APISpellHelper.createVec3(posX, posY, posZ))) { + if (collision != null && collision.isVecInside(APISpellHelper.createVec3(posX, posY, posZ))) { inGround = true; } } - if (inGround) { - Block var18 = worldObj.getBlock(xTile, yTile, zTile); - int var19 = worldObj.getBlockMetadata(xTile, yTile, zTile); - - // if (var18.equals(Block.getBlockById(inTile)) && var19 == inData) - { - // this.groundImpact(); - // this.setDead(); - } - } else { + if (!inGround) { ++ticksInAir; - if (ticksInAir > 1 && ticksInAir < 3) { - // worldObj.spawnParticle("flame", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + - // smallGauss(0.1D), 0D, 0D, 0D); + if (ticksInAir == 2) { for (int particles = 0; particles < 3; particles++) { this.doFiringParticles(); } } - Vec3 var17 = APISpellHelper.createVec3(posX, posY, posZ); - Vec3 var3 = APISpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ); - MovingObjectPosition var4 = worldObj.func_147447_a(var17, var3, true, false, false); - var17 = APISpellHelper.createVec3(posX, posY, posZ); - var3 = APISpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ); + Vec3 start = APISpellHelper.createVec3(posX, posY, posZ); + Vec3 end = APISpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ); + MovingObjectPosition movement = worldObj.func_147447_a(start, end, true, false, false); + start = APISpellHelper.createVec3(posX, posY, posZ); + end = APISpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ); - if (var4 != null) { - var3 = APISpellHelper.createVec3(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord); + if (movement != null) { + end = APISpellHelper.createVec3(movement.hitVec.xCoord, movement.hitVec.yCoord, movement.hitVec.zCoord); } - Entity var5 = null; - List var6 = worldObj.getEntitiesWithinAABBExcludingEntity( + Entity closestEntity = null; + List entitiesInRange = worldObj.getEntitiesWithinAABBExcludingEntity( this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); - double var7 = 0.0D; - Iterator var9 = var6.iterator(); - float var11; + double closestDistance = 0.0D; - while (var9.hasNext()) { - Entity var10 = (Entity) var9.next(); + for (Entity entity : entitiesInRange) { - if (var10.canBeCollidedWith() && (var10 != shootingEntity || ticksInAir >= 5)) { - var11 = 0.3F; - AxisAlignedBB var12 = var10.boundingBox.expand(var11, var11, var11); - MovingObjectPosition var13 = var12.calculateIntercept(var17, var3); + if (entity.canBeCollidedWith() && (entity != shootingEntity || ticksInAir >= 5)) { + AxisAlignedBB box = entity.boundingBox.expand(0.3F, 0.3F, 0.3F); + MovingObjectPosition intercept = box.calculateIntercept(start, end); - if (var13 != null) { - double var14 = var17.distanceTo(var13.hitVec); + if (intercept != null) { + double distance = start.distanceTo(intercept.hitVec); - if (var14 < var7 || var7 == 0.0D) { - var5 = var10; - var7 = var14; + if (distance < closestDistance || closestDistance == 0.0D) { + closestEntity = entity; + closestDistance = distance; } } } } - if (var5 != null) { - var4 = new MovingObjectPosition(var5); + if (closestEntity != null) { + movement = new MovingObjectPosition(closestEntity); } - if (var4 != null) { - this.onImpact(var4); + if (movement != null) { + this.onImpact(movement); if (scheduledForDeath) { this.setDead(); @@ -259,16 +220,7 @@ public void onUpdate() { posX += motionX; posY += motionY; posZ += motionZ; - MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); this.setPosition(posX, posY, posZ); - // this.doBlockCollisions(); - } - } - - private void doFlightParticles() { - if (ticksInAir % 3 == 0) { - double gauss = gaussian(1.0F); - worldObj.spawnParticle("mobSpell", posX, posY, posZ, gauss, gauss, 0.0F); } } @@ -284,17 +236,14 @@ private void doFiringParticles() { worldObj.spawnParticle("flame", posX, posY, posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ)); } - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ @Override - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - par1NBTTagCompound.setShort("xTile", (short) xTile); - par1NBTTagCompound.setShort("yTile", (short) yTile); - par1NBTTagCompound.setShort("zTile", (short) zTile); - par1NBTTagCompound.setByte("inTile", (byte) inTile); - par1NBTTagCompound.setByte("inData", (byte) inData); - par1NBTTagCompound.setByte("inGround", (byte) (inGround ? 1 : 0)); + public void writeEntityToNBT(NBTTagCompound tag) { + tag.setShort("xTile", (short) xTile); + tag.setShort("yTile", (short) yTile); + tag.setShort("zTile", (short) zTile); + tag.setByte("inTile", (byte) inTile); + tag.setByte("inData", (byte) inData); + tag.setByte("inGround", (byte) (inGround ? 1 : 0)); NBTTagList effectList = new NBTTagList(); @@ -302,50 +251,34 @@ public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { effectList.appendTag(eff.getTag()); } - // for (String str : this.effectList) - // { - // if (str != null) - // { - // NBTTagCompound tag = new NBTTagCompound(); - // - // tag.setString("Class", str); - // effectList.appendTag(tag); - // } - // } - - par1NBTTagCompound.setTag("Effects", effectList); - par1NBTTagCompound.setInteger("blocksBroken", blocksBroken); - par1NBTTagCompound.setBoolean("isSilkTouch", isSilkTouch); + tag.setTag("Effects", effectList); + tag.setInteger("blocksBroken", blocksBroken); + tag.setBoolean("isSilkTouch", isSilkTouch); } - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ @Override - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - xTile = par1NBTTagCompound.getShort("xTile"); - yTile = par1NBTTagCompound.getShort("yTile"); - zTile = par1NBTTagCompound.getShort("zTile"); - inTile = par1NBTTagCompound.getByte("inTile") & 255; - inData = par1NBTTagCompound.getByte("inData") & 255; - inGround = par1NBTTagCompound.getByte("inGround") == 1; - blocksBroken = par1NBTTagCompound.getInteger("blocksBroken"); - isSilkTouch = par1NBTTagCompound.getBoolean("isSilkTouch"); - - NBTTagList tagList = par1NBTTagCompound.getTagList("Effects", Constants.NBT.TAG_COMPOUND); - - List spellEffectList = new LinkedList(); + public void readEntityFromNBT(NBTTagCompound tag) { + xTile = tag.getShort("xTile"); + yTile = tag.getShort("yTile"); + zTile = tag.getShort("zTile"); + inTile = tag.getByte("inTile") & 255; + inData = tag.getByte("inData") & 255; + inGround = tag.getByte("inGround") == 1; + blocksBroken = tag.getInteger("blocksBroken"); + isSilkTouch = tag.getBoolean("isSilkTouch"); + + NBTTagList tagList = tag.getTagList("Effects", Constants.NBT.TAG_COMPOUND); + + List spellEffectList = new LinkedList<>(); for (int i = 0; i < tagList.tagCount(); i++) { - NBTTagCompound tag = tagList.getCompoundTagAt(i); - - SpellEffect eff = SpellEffect.getEffectFromTag(tag); + SpellEffect eff = SpellEffect.getEffectFromTag(tagList.getCompoundTagAt(i)); if (eff != null) { spellEffectList.add(eff); } } this.spellEffectList = spellEffectList; - // this.effectList = new LinkedList(); + // this.effectList = new LinkedList<>(); // for (int i = 0; i < tagList.tagCount(); i++) // { // NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i); @@ -374,39 +307,11 @@ public float getShadowSize() { return 0.0F; } - /** - * Sets the amount of knockback the arrow applies when it hits a mob. - */ - public void setKnockbackStrength(int par1) {} - - /** - * If returns false, the item will not inflict any damage against entities. - */ @Override public boolean canAttackWithItem() { return false; } - /** - * Whether the arrow has a stream of critical hit particles flying behind it. - */ - public void setIsCritical(boolean par1) { - byte var2 = dataWatcher.getWatchableObjectByte(16); - if (par1) { - dataWatcher.updateObject(16, var2 | 1); - } else { - dataWatcher.updateObject(16, var2 & -2); - } - } - - /** - * Whether the arrow has a stream of critical hit particles flying behind it. - */ - public boolean getIsCritical() { - byte var1 = dataWatcher.getWatchableObjectByte(16); - return (var1 & 1) != 0; - } - private void onImpact(MovingObjectPosition mop) { if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null) { if (mop.entityHit == shootingEntity) return; @@ -471,87 +376,23 @@ private double gaussian(double d) { private void ricochet(int sideHit) { switch (sideHit) { - case 0: - case 1: - // topHit, bottomHit, reflect Y - motionY = motionY * -1; - break; - case 2: - case 3: - // westHit, eastHit, reflect Z - motionZ = motionZ * -1; - break; - case 4: - case 5: - // southHit, northHit, reflect X - motionX = motionX * -1; - break; + case 0, 1 -> motionY = motionY * -1; // topHit, bottomHit, reflect Y + case 2, 3 -> motionZ = motionZ * -1; // westHit, eastHit, reflect Z + case 4, 5 -> motionX = motionX * -1; // southHit, northHit, reflect X } ricochetCounter++; if (ricochetCounter > this.getRicochetMax()) { scheduledForDeath = true; for (int particles = 0; particles < 4; particles++) { switch (sideHit) { - case 0: - worldObj.spawnParticle( - "smoke", - posX, - posY, - posZ, - gaussian(0.1D), - -gaussian(0.1D), - gaussian(0.1D)); - break; - case 1: - worldObj.spawnParticle( - "smoke", - posX, - posY, - posZ, - gaussian(0.1D), - gaussian(0.1D), - gaussian(0.1D)); - break; - case 2: - worldObj.spawnParticle( - "smoke", - posX, - posY, - posZ, - gaussian(0.1D), - gaussian(0.1D), - -gaussian(0.1D)); - break; - case 3: - worldObj.spawnParticle( - "smoke", - posX, - posY, - posZ, - gaussian(0.1D), - gaussian(0.1D), - gaussian(0.1D)); - break; - case 4: - worldObj.spawnParticle( - "smoke", - posX, - posY, - posZ, - -gaussian(0.1D), - gaussian(0.1D), - gaussian(0.1D)); - break; - case 5: - worldObj.spawnParticle( - "smoke", - posX, - posY, - posZ, - gaussian(0.1D), - gaussian(0.1D), - gaussian(0.1D)); - break; + case 0 -> worldObj + .spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), -gaussian(0.1D), gaussian(0.1D)); + case 1, 3, 5 -> worldObj + .spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D)); + case 2 -> worldObj + .spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), -gaussian(0.1D)); + case 4 -> worldObj + .spawnParticle("smoke", posX, posY, posZ, -gaussian(0.1D), gaussian(0.1D), gaussian(0.1D)); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/spell/IToolUpdateEffect.java b/src/main/java/WayofTime/alchemicalWizardry/api/spell/IToolUpdateEffect.java index f8032e8db9..b522e3dc36 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/spell/IToolUpdateEffect.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/spell/IToolUpdateEffect.java @@ -6,5 +6,5 @@ public interface IToolUpdateEffect { - int onUpdate(ItemStack toolStack, World world, Entity par3Entity, int invSlot, boolean inHand); + int onUpdate(ItemStack toolStack, World world, Entity entity, int invSlot, boolean inHand); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellEffect.java b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellEffect.java index 2230353ec1..96476aa5d7 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellEffect.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellEffect.java @@ -2,6 +2,8 @@ import net.minecraft.nbt.NBTTagCompound; +import WayofTime.alchemicalWizardry.AlchemicalWizardry; + /** * New wrapper class to enclose the ComplexSpellEffect */ @@ -34,15 +36,9 @@ public SpellEffect(ComplexSpellType type, ComplexSpellModifier modifier) { public void enhanceEffect(SpellEnhancement enh) { if (enh != null) { switch (enh.getState()) { - case SpellEnhancement.POWER: - this.powerEnhancement++; - break; - case SpellEnhancement.EFFICIENCY: - this.costEnhancement++; - break; - case SpellEnhancement.POTENCY: - this.potencyEnhancement++; - break; + case SpellEnhancement.POWER -> this.powerEnhancement++; + case SpellEnhancement.EFFICIENCY -> this.costEnhancement++; + case SpellEnhancement.POTENCY -> this.potencyEnhancement++; } } } @@ -60,7 +56,7 @@ public void modifyParadigm(SpellParadigm parad) // When modifying the paradigm i return; } - Class paraClass = parad.getClass(); + Class paraClass = parad.getClass(); ComplexSpellEffect effect = SpellEffectRegistry .getSpellEffect(paraClass, type, modifier, powerEnhancement, potencyEnhancement, costEnhancement); @@ -75,7 +71,7 @@ public int getCostOfEffect(SpellParadigm parad) { return 0; } - Class paraClass = parad.getClass(); + Class paraClass = parad.getClass(); ComplexSpellEffect effect = SpellEffectRegistry .getSpellEffect(paraClass, type, modifier, powerEnhancement, potencyEnhancement, costEnhancement); @@ -102,29 +98,23 @@ public NBTTagCompound getTag() { public static SpellEffect getEffectFromTag(NBTTagCompound tag) { try { - Class clazz = Class.forName(tag.getString("Class")); - if (clazz != null) { - try { - Object obj = clazz.newInstance(); - if (obj instanceof SpellEffect) { - SpellEffect eff = (SpellEffect) obj; - - eff.type = SpellEffectRegistry.getTypeForKey(tag.getString("type")); - eff.modifier = SpellEffectRegistry.getModifierForKey(tag.getString("modifier")); - eff.powerEnhancement = tag.getInteger("power"); - eff.costEnhancement = tag.getInteger("cost"); - eff.potencyEnhancement = tag.getInteger("potency"); - - return eff; - } - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); + Class clazz = Class.forName(tag.getString("Class")); + try { + Object obj = clazz.newInstance(); + if (obj instanceof SpellEffect eff) { + eff.type = SpellEffectRegistry.getTypeForKey(tag.getString("type")); + eff.modifier = SpellEffectRegistry.getModifierForKey(tag.getString("modifier")); + eff.powerEnhancement = tag.getInteger("power"); + eff.costEnhancement = tag.getInteger("cost"); + eff.potencyEnhancement = tag.getInteger("potency"); + + return eff; } + } catch (InstantiationException | IllegalAccessException e) { + AlchemicalWizardry.logger.error(e); } } catch (ClassNotFoundException e) { - e.printStackTrace(); + AlchemicalWizardry.logger.error(e); } return null; } @@ -141,339 +131,3 @@ public int getCostEnhancements() { return this.costEnhancement; } } - -// package WayofTime.alchemicalWizardry.common.spell.complex.effect; -// -// import WayofTime.alchemicalWizardry.common.spell.complex.*; -// import WayofTime.alchemicalWizardry.common.spell.complex.enhancement.SpellEnhancement; -// import net.minecraft.nbt.NBTTagCompound; -// -// public abstract class SpellEffect -// { -// protected int modifierState; -// protected int powerEnhancement; -// protected int costEnhancement; -// protected int potencyEnhancement; -// -// public SpellEffect() -// { -// this.modifierState = SpellModifier.DEFAULT; -// this.powerEnhancement = 0; -// this.costEnhancement = 0; -// this.potencyEnhancement = 0; -// } -// -// public void enhanceEffect(SpellEnhancement enh) -// { -// if (enh != null) -// { -// switch (enh.getState()) -// { -// case SpellEnhancement.POWER: -// this.powerEnhancement++; -// break; -// case SpellEnhancement.EFFICIENCY: -// this.costEnhancement++; -// break; -// case SpellEnhancement.POTENCY: -// this.potencyEnhancement++; -// break; -// } -// } -// } -// -// public void modifyEffect(SpellModifier mod) -// { -// if (mod != null) -// modifierState = mod.getModifier(); -// } -// -// public void modifyParadigm(SpellParadigm parad) //When modifying the paradigm it will instead get the class name -// and ask the registry -// { -// if (parad instanceof SpellParadigmProjectile) -// { -// this.modifyProjectileParadigm((SpellParadigmProjectile) parad); -// } -// if (parad instanceof SpellParadigmSelf) -// { -// this.modifySelfParadigm((SpellParadigmSelf) parad); -// } -// if (parad instanceof SpellParadigmMelee) -// { -// this.modifyMeleeParadigm((SpellParadigmMelee) parad); -// } -// if (parad instanceof SpellParadigmTool) -// { -// this.modifyToolParadigm((SpellParadigmTool) parad); -// } -// } -// -// public void modifyProjectileParadigm(SpellParadigmProjectile parad) -// { -// switch (modifierState) -// { -// case SpellModifier.DEFAULT: -// this.defaultModificationProjectile(parad); -// break; -// case SpellModifier.OFFENSIVE: -// this.offensiveModificationProjectile(parad); -// break; -// case SpellModifier.DEFENSIVE: -// this.defensiveModificationProjectile(parad); -// break; -// case SpellModifier.ENVIRONMENTAL: -// this.environmentalModificationProjectile(parad); -// break; -// } -// } -// -// public abstract void defaultModificationProjectile(SpellParadigmProjectile parad); -// -// public abstract void offensiveModificationProjectile(SpellParadigmProjectile parad); -// -// public abstract void defensiveModificationProjectile(SpellParadigmProjectile parad); -// -// public abstract void environmentalModificationProjectile(SpellParadigmProjectile parad); -// -// public void modifySelfParadigm(SpellParadigmSelf parad) -// { -// switch (modifierState) -// { -// case SpellModifier.DEFAULT: -// this.defaultModificationSelf(parad); -// break; -// case SpellModifier.OFFENSIVE: -// this.offensiveModificationSelf(parad); -// break; -// case SpellModifier.DEFENSIVE: -// this.defensiveModificationSelf(parad); -// break; -// case SpellModifier.ENVIRONMENTAL: -// this.environmentalModificationSelf(parad); -// break; -// } -// } -// -// public abstract void defaultModificationSelf(SpellParadigmSelf parad); -// -// public abstract void offensiveModificationSelf(SpellParadigmSelf parad); -// -// public abstract void defensiveModificationSelf(SpellParadigmSelf parad); -// -// public abstract void environmentalModificationSelf(SpellParadigmSelf parad); -// -// public void modifyMeleeParadigm(SpellParadigmMelee parad) -// { -// switch (modifierState) -// { -// case SpellModifier.DEFAULT: -// this.defaultModificationMelee(parad); -// break; -// case SpellModifier.OFFENSIVE: -// this.offensiveModificationMelee(parad); -// break; -// case SpellModifier.DEFENSIVE: -// this.defensiveModificationMelee(parad); -// break; -// case SpellModifier.ENVIRONMENTAL: -// this.environmentalModificationMelee(parad); -// break; -// } -// } -// -// public abstract void defaultModificationMelee(SpellParadigmMelee parad); -// -// public abstract void offensiveModificationMelee(SpellParadigmMelee parad); -// -// public abstract void defensiveModificationMelee(SpellParadigmMelee parad); -// -// public abstract void environmentalModificationMelee(SpellParadigmMelee parad); -// -// public void modifyToolParadigm(SpellParadigmTool parad) -// { -// switch (modifierState) -// { -// case SpellModifier.DEFAULT: -// this.defaultModificationTool(parad); -// break; -// case SpellModifier.OFFENSIVE: -// this.offensiveModificationTool(parad); -// break; -// case SpellModifier.DEFENSIVE: -// this.defensiveModificationTool(parad); -// break; -// case SpellModifier.ENVIRONMENTAL: -// this.environmentalModificationTool(parad); -// break; -// } -// } -// -// public abstract void defaultModificationTool(SpellParadigmTool parad); -// -// public abstract void offensiveModificationTool(SpellParadigmTool parad); -// -// public abstract void defensiveModificationTool(SpellParadigmTool parad); -// -// public abstract void environmentalModificationTool(SpellParadigmTool parad); -// -// public int getCostForProjectile() -// { -// switch (this.modifierState) -// { -// case SpellModifier.DEFAULT: -// return this.getCostForDefaultProjectile(); -// case SpellModifier.OFFENSIVE: -// return this.getCostForOffenseProjectile(); -// case SpellModifier.DEFENSIVE: -// return this.getCostForDefenseProjectile(); -// case SpellModifier.ENVIRONMENTAL: -// return this.getCostForEnvironmentProjectile(); -// } -// return 0; -// } -// -// protected abstract int getCostForDefaultProjectile(); -// -// protected abstract int getCostForOffenseProjectile(); -// -// protected abstract int getCostForDefenseProjectile(); -// -// protected abstract int getCostForEnvironmentProjectile(); -// -// public int getCostForSelf() -// { -// switch (this.modifierState) -// { -// case SpellModifier.DEFAULT: -// return this.getCostForDefaultSelf(); -// case SpellModifier.OFFENSIVE: -// return this.getCostForOffenseSelf(); -// case SpellModifier.DEFENSIVE: -// return this.getCostForDefenseSelf(); -// case SpellModifier.ENVIRONMENTAL: -// return this.getCostForEnvironmentSelf(); -// } -// return 0; -// } -// -// protected abstract int getCostForDefaultSelf(); -// -// protected abstract int getCostForOffenseSelf(); -// -// protected abstract int getCostForDefenseSelf(); -// -// protected abstract int getCostForEnvironmentSelf(); -// -// public int getCostForMelee() -// { -// switch (this.modifierState) -// { -// case SpellModifier.DEFAULT: -// return this.getCostForDefaultMelee(); -// case SpellModifier.OFFENSIVE: -// return this.getCostForOffenseMelee(); -// case SpellModifier.DEFENSIVE: -// return this.getCostForDefenseMelee(); -// case SpellModifier.ENVIRONMENTAL: -// return this.getCostForEnvironmentMelee(); -// } -// return 0; -// } -// -// protected abstract int getCostForDefaultMelee(); -// -// protected abstract int getCostForOffenseMelee(); -// -// protected abstract int getCostForDefenseMelee(); -// -// protected abstract int getCostForEnvironmentMelee(); -// -// public int getCostForTool() -// { -// switch (this.modifierState) -// { -// case SpellModifier.DEFAULT: -// return this.getCostForDefaultTool(); -// case SpellModifier.OFFENSIVE: -// return this.getCostForOffenseTool(); -// case SpellModifier.DEFENSIVE: -// return this.getCostForDefenseTool(); -// case SpellModifier.ENVIRONMENTAL: -// return this.getCostForEnvironmentTool(); -// } -// return 0; -// } -// -// protected abstract int getCostForDefaultTool(); -// -// protected abstract int getCostForOffenseTool(); -// -// protected abstract int getCostForDefenseTool(); -// -// protected abstract int getCostForEnvironmentTool(); -// -// public int getPowerEnhancements() -// { -// return this.powerEnhancement; -// } -// -// public int getCostEnhancements() -// { -// return this.costEnhancement; -// } -// -// public int getPotencyEnhancements() -// { -// return this.potencyEnhancement; -// } -// -// public NBTTagCompound getTag() -// { -// NBTTagCompound tag = new NBTTagCompound(); -// -// tag.setString("Class", this.getClass().getName()); -// tag.setInteger("modifier", modifierState); -// tag.setInteger("power", powerEnhancement); -// tag.setInteger("cost", costEnhancement); -// tag.setInteger("potency", potencyEnhancement); -// -// return tag; -// } -// -// public static SpellEffect getEffectFromTag(NBTTagCompound tag) -// { -// try -// { -// Class clazz = Class.forName(tag.getString("Class")); -// if (clazz != null) -// { -// try -// { -// Object obj = clazz.newInstance(); -// if (obj instanceof SpellEffect) -// { -// SpellEffect eff = (SpellEffect) obj; -// -// eff.modifierState = tag.getInteger("modifier"); -// eff.powerEnhancement = tag.getInteger("power"); -// eff.costEnhancement = tag.getInteger("cost"); -// eff.potencyEnhancement = tag.getInteger("potency"); -// -// return eff; -// } -// } catch (InstantiationException e) -// { -// e.printStackTrace(); -// } catch (IllegalAccessException e) -// { -// e.printStackTrace(); -// } -// } -// } catch (ClassNotFoundException e) -// { -// e.printStackTrace(); -// } -// return null; -// } -// } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellEffectRegistry.java b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellEffectRegistry.java index 8d12d0f910..43e4cfb0a2 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellEffectRegistry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellEffectRegistry.java @@ -8,9 +8,9 @@ public class SpellEffectRegistry { - public static Map, List> effectRegistry = new HashMap(); - public static Map typeRegistry = new HashMap(); - public static Map modifierRegistry = new HashMap(); + public static Map, List> effectRegistry = new HashMap<>(); + public static Map typeRegistry = new HashMap<>(); + public static Map modifierRegistry = new HashMap<>(); public static void registerSpellEffect(Class paraClass, ComplexSpellEffect effect) { if (paraClass == null || effect == null) { @@ -36,24 +36,12 @@ public static void registerSpellEffect(Class paraClass, effectList.add(effect); } else { - List effectList = new LinkedList(); + List effectList = new LinkedList<>(); effectList.add(effect); effectRegistry.put(paraClass, effectList); } } - /** - * - * @param paraClass - * @param type - * @param mod - * @return A copy of the spell effect - */ - public static ComplexSpellEffect getSpellEffect(Class paraClass, ComplexSpellType type, - ComplexSpellModifier mod) { - return SpellEffectRegistry.getSpellEffect(paraClass, type, mod, 0, 0, 0); - } - public static ComplexSpellEffect getSpellEffect(Class paraClass, ComplexSpellType type, ComplexSpellModifier mod, int power, int potency, int cost) { if (paraClass == null || type == null || mod == null) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancement.java b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancement.java index ca2f0665da..8bfc3b2ec2 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancement.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellEnhancement.java @@ -6,7 +6,7 @@ public class SpellEnhancement { public static final int EFFICIENCY = 1; public static final int POTENCY = 2; - private int state = POWER; + private final int state; protected SpellEnhancement(int state) { this.state = state; diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigm.java b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigm.java index e6628c9c09..faf04fd949 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigm.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigm.java @@ -9,7 +9,7 @@ public abstract class SpellParadigm { - protected List bufferedEffectList = new LinkedList(); + protected List bufferedEffectList = new LinkedList<>(); public void addBufferedEffect(SpellEffect effect) { if (effect != null) { @@ -55,7 +55,7 @@ public SpellEffect getBufferedEffect() { if (bufferedEffectList.isEmpty()) { return null; } else { - return bufferedEffectList.get(bufferedEffectList.size() - 1); + return bufferedEffectList.getLast(); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmMelee.java b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmMelee.java index 7ea96ebe66..ed66fd7182 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmMelee.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmMelee.java @@ -11,12 +11,12 @@ public class SpellParadigmMelee extends SpellParadigm { - private List entityEffectList; - private List worldEffectList; + private final List entityEffectList; + private final List worldEffectList; public SpellParadigmMelee() { - this.entityEffectList = new ArrayList(); - this.worldEffectList = new ArrayList(); + this.entityEffectList = new ArrayList<>(); + this.worldEffectList = new ArrayList<>(); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmProjectile.java index 3237a4e242..4a7ee1d484 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmProjectile.java @@ -25,8 +25,8 @@ public SpellParadigmProjectile() { this.damageSource = DamageSource.generic; this.damage = 1; this.cost = 0; - this.impactList = new ArrayList(); - this.updateEffectList = new ArrayList(); + this.impactList = new ArrayList<>(); + this.updateEffectList = new ArrayList<>(); this.penetration = false; this.ricochetMax = 0; this.isSilkTouch = false; diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmSelf.java b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmSelf.java index f2a167c68a..88ff97989c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmSelf.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmSelf.java @@ -14,7 +14,7 @@ public class SpellParadigmSelf extends SpellParadigm { public List selfSpellEffectList; public SpellParadigmSelf() { - selfSpellEffectList = new ArrayList(); + selfSpellEffectList = new ArrayList<>(); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmTool.java b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmTool.java index 4f1b68d111..301700ce11 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmTool.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/spell/SpellParadigmTool.java @@ -22,23 +22,23 @@ public class SpellParadigmTool extends SpellParadigm { - private List leftClickEffectList; - private List rightClickEffectList; - private List toolUpdateEffectList; - private List toolSummonEffectList; - private List toolBanishEffectList; - private List breakBlockEffectList; - private List itemManipulatorEffectList; - private List digAreaEffectList; - private List specialDamageEffectList; - - private HashMap harvestLevel; - private HashMap digSpeed; - private HashMap maxDamageHash; - private HashMap critChanceHash; - private HashMap durationHash; - - private HashMap toolInfoString; + private final List leftClickEffectList; + private final List rightClickEffectList; + private final List toolUpdateEffectList; + private final List toolSummonEffectList; + private final List toolBanishEffectList; + private final List breakBlockEffectList; + private final List itemManipulatorEffectList; + private final List digAreaEffectList; + private final List specialDamageEffectList; + + private final HashMap harvestLevel; + private final HashMap digSpeed; + private final HashMap maxDamageHash; + private final HashMap critChanceHash; + private final HashMap durationHash; + + private final HashMap toolInfoString; private int fortuneLevel; private boolean silkTouch; @@ -48,31 +48,31 @@ public class SpellParadigmTool extends SpellParadigm { public static Item customTool; public SpellParadigmTool() { - this.leftClickEffectList = new LinkedList(); - this.rightClickEffectList = new LinkedList(); - this.toolUpdateEffectList = new LinkedList(); - this.toolSummonEffectList = new LinkedList(); - this.toolBanishEffectList = new LinkedList(); - this.breakBlockEffectList = new LinkedList(); - this.itemManipulatorEffectList = new LinkedList(); - this.digAreaEffectList = new LinkedList(); - this.specialDamageEffectList = new LinkedList(); - this.durationHash = new HashMap(); - - this.toolInfoString = new HashMap(); - this.critChanceHash = new HashMap(); - - this.harvestLevel = new HashMap(); + this.leftClickEffectList = new LinkedList<>(); + this.rightClickEffectList = new LinkedList<>(); + this.toolUpdateEffectList = new LinkedList<>(); + this.toolSummonEffectList = new LinkedList<>(); + this.toolBanishEffectList = new LinkedList<>(); + this.breakBlockEffectList = new LinkedList<>(); + this.itemManipulatorEffectList = new LinkedList<>(); + this.digAreaEffectList = new LinkedList<>(); + this.specialDamageEffectList = new LinkedList<>(); + this.durationHash = new HashMap<>(); + + this.toolInfoString = new HashMap<>(); + this.critChanceHash = new HashMap<>(); + + this.harvestLevel = new HashMap<>(); this.harvestLevel.put("pickaxe", -1); this.harvestLevel.put("shovel", -1); this.harvestLevel.put("axe", -1); - this.digSpeed = new HashMap(); + this.digSpeed = new HashMap<>(); this.digSpeed.put("pickaxe", 1.0f); this.digSpeed.put("shovel", 1.0f); this.digSpeed.put("axe", 1.0f); - this.maxDamageHash = new HashMap(); + this.maxDamageHash = new HashMap<>(); this.maxDamageHash.put("default", 5.0f); this.fortuneLevel = 0; @@ -104,7 +104,6 @@ public void castSpell(World world, EntityPlayer entityPlayer, ItemStack crystal) } /** - * @param crystalStack * @return stack containing the new multitool */ public ItemStack prepareTool(ItemStack crystalStack, World world) { @@ -145,11 +144,7 @@ public ItemStack prepareTool(ItemStack crystalStack, World world) { itemTool.setCritChance(toolStack, this.getCritChance() / 100f); - List toolStringList = new LinkedList(); - - for (String str : this.toolInfoString.values()) { - toolStringList.add(str); - } + List toolStringList = new LinkedList<>(this.toolInfoString.values()); itemTool.setToolListString(toolStack, toolStringList); @@ -256,7 +251,7 @@ public int onRightClickBlock(ItemStack toolStack, EntityLivingBase weilder, Worl return total; } - public int onRightClickAir(ItemStack toolStack, World world, EntityPlayer player) { + public int onRightClickAir(ItemStack toolStack, EntityPlayer player) { int total = 0; for (IRightClickEffect effect : this.rightClickEffectList) { total += effect.onRightClickAir(toolStack, player); @@ -265,10 +260,10 @@ public int onRightClickAir(ItemStack toolStack, World world, EntityPlayer player return total; } - public int onUpdate(ItemStack toolStack, World world, Entity par3Entity, int invSlot, boolean inHand) { + public int onUpdate(ItemStack toolStack, World world, Entity entity, int invSlot, boolean inHand) { int total = 0; for (IToolUpdateEffect effect : this.toolUpdateEffectList) { - total += effect.onUpdate(toolStack, world, par3Entity, invSlot, inHand); + total += effect.onUpdate(toolStack, world, entity, invSlot, inHand); } return total; @@ -306,8 +301,7 @@ public List handleItemList(ItemStack toolStack, List items List heldList = items; for (IItemManipulator eff : this.itemManipulatorEffectList) { - List newHeldList = eff.handleItemsOnBlockBroken(toolStack, heldList); - heldList = newHeldList; + heldList = eff.handleItemsOnBlockBroken(toolStack, heldList); } return heldList; @@ -404,7 +398,7 @@ public float getCritChance() { } public float getAddedDamageForEntity(Entity entity) { - HashMap hash = new HashMap(); + HashMap hash = new HashMap<>(); for (ISpecialDamageEffect effect : this.specialDamageEffectList) { hash.put(effect.getKey(), effect.getDamageForEntity(entity)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistry.java b/src/main/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistry.java index a7662879fb..1c6c429345 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistry.java @@ -9,7 +9,7 @@ public class SummoningRegistry { - public static List summoningList = new ArrayList(); + public static List summoningList = new ArrayList<>(); public static void registerSummon(SummoningHelper s, ItemStack[] ring1, ItemStack[] ring2, ItemStack[] ring3, int amountUsed, int bloodOrbLevel) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistryComponent.java b/src/main/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistryComponent.java index 2159232b8b..17385191c9 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistryComponent.java +++ b/src/main/java/WayofTime/alchemicalWizardry/api/summoningRegistry/SummoningRegistryComponent.java @@ -74,22 +74,11 @@ public boolean compareRing(int ring, ItemStack[] checkedRingRecipe) { return false; } - switch (ring) { - case 1: - recipe = ring1; - break; - - case 2: - recipe = ring2; - break; - - case 3: - recipe = ring3; - break; - - default: - recipe = ring1; - } + recipe = switch (ring) { + case 2 -> ring2; + case 3 -> ring3; + default -> ring1; + }; if (recipe.length != 6) { ItemStack[] newRecipe = new ItemStack[6]; @@ -175,19 +164,12 @@ public int getBloodOrbLevel() { } public ItemStack[] getRingRecipeForRing(int ring) { - switch (ring) { - case 1: - return ring1; - - case 2: - return ring2; - - case 3: - return ring3; - - default: - return null; - } + return switch (ring) { + case 1 -> ring1; + case 2 -> ring2; + case 3 -> ring3; + default -> null; + }; } public String getSummoningHelperID() { diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/ClientEventHandler.java b/src/main/java/WayofTime/alchemicalWizardry/client/ClientEventHandler.java index 1e2ce4d0b3..c9a903d32c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/ClientEventHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/ClientEventHandler.java @@ -12,56 +12,14 @@ import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.InputEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; +import cpw.mods.fml.common.gameevent.TickEvent; public class ClientEventHandler { - private Minecraft mc = FMLClientHandler.instance().getClient(); + private final Minecraft mc = FMLClientHandler.instance().getClient(); public static ResourceLocation currentPlayerTexture = null; - // @SideOnly(Side.CLIENT) - // @SubscribeEvent - // public void renderPOVArmour(RenderHandEvent event) - // { - // if (this.mc.thePlayer.worldObj.isRemote && this.mc.gameSettings.thirdPersonView == 0 && - // !this.mc.renderViewEntity.isPlayerSleeping() && !this.mc.gameSettings.hideGUI && - // !this.mc.playerController.enableEverythingIsScrewedUpMode()) - // { - // currentPlayerTexture = ((AbstractClientPlayer) mc.thePlayer).getLocationSkin(); - // - // ClientUtils.renderPlayerArmourInPOV(mc.thePlayer, event.partialTicks); - // event.setCanceled(true); - // } - // } - - // @SubscribeEvent(priority = EventPriority.LOWEST) - // public void onPlayerRenderTick(RenderPlayerEvent.Pre event) - // { - // ModelBiped model = ((BoundArmour)ModItems.boundPlate).getArmorModel(event.entityPlayer, new - // ItemStack(ModItems.boundPlate), 2); - // String texture = ((BoundArmour)ModItems.boundPlate).getArmorTexture(new ItemStack(ModItems.boundPlate), - // event.entityPlayer, 2, ""); - // - // ResourceLocation resourcelocation = new ResourceLocation(texture); - // event.renderer.modelBipedMain.bipedBody.addChild(model.bipedBody); - // Minecraft.getMinecraft().renderEngine.bindTexture(resourcelocation); - // - // } - - @SubscribeEvent - public void onKeyInput(InputEvent.KeyInputEvent event) { - // if(KeyBindings.omegaTest.isPressed()) - // { - // System.out.println("ping"); - //// NewPacketHandler.INSTANCE.sendToServer(NewPacketHandler.getKeyboardPressPacket((byte)2)); - // ClientToServerPacketHandler.INSTANCE.sendToServer(new - // MessageKeyPressed(MessageKeyPressed.Key.OMEGA_ACTIVE)); - // } - } - @SubscribeEvent public void onPlayerSoundEvent(SoundEvent event) { if (Minecraft.getMinecraft() != null) { @@ -89,21 +47,9 @@ public void onOverlayEvent(RenderBlockOverlayEvent event) { } @SubscribeEvent - public void onTick(RenderTickEvent event) { - if (event.phase.equals(Phase.START)) return; + public void onTick(TickEvent.RenderTickEvent event) { + if (event.phase.equals(TickEvent.Phase.START)) return; - if (!RenderHelper.onTickInGame(mc)) {} + RenderHelper.onTickInGame(mc); } - - // @SubscribeEvent - // public void onRenderLivingPlayerPre(RenderPlayerEvent.Pre event) - // { - // GL11.glDisable(2929); - // } - // - // @SubscribeEvent - // public void onRenderLivingPlayerPost(RenderPlayerEvent.Post event) - // { - // GL11.glEnable(2929); - // } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/ClientUtils.java b/src/main/java/WayofTime/alchemicalWizardry/client/ClientUtils.java deleted file mode 100644 index 874a47bd90..0000000000 --- a/src/main/java/WayofTime/alchemicalWizardry/client/ClientUtils.java +++ /dev/null @@ -1,344 +0,0 @@ -package WayofTime.alchemicalWizardry.client; - -import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON; -import static net.minecraftforge.client.IItemRenderer.ItemRenderType.FIRST_PERSON_MAP; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityClientPlayerMP; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.RenderPlayer; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumAction; -import net.minecraft.item.ItemCloth; -import net.minecraft.item.ItemMap; -import net.minecraft.item.ItemStack; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.storage.MapData; -import net.minecraftforge.client.IItemRenderer; -import net.minecraftforge.client.MinecraftForgeClient; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - -public class ClientUtils { - - public static Minecraft mc = Minecraft.getMinecraft(); - - private static final ResourceLocation RES_MAP_BACKGROUND = new ResourceLocation("textures/map/map_background.png"); - - public static void renderPlayerArmourInPOV(EntityPlayer player, float partialTickTime) { - GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); - float f1 = 1.0f; // this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * - // partialTickTime; - EntityClientPlayerMP entityclientplayermp = mc.thePlayer; - float f2 = entityclientplayermp.prevRotationPitch - + (entityclientplayermp.rotationPitch - entityclientplayermp.prevRotationPitch) * partialTickTime; - // GL11.glPushMatrix(); - GL11.glRotatef( - 180 - (entityclientplayermp.prevRotationYaw - + (entityclientplayermp.rotationYaw - entityclientplayermp.prevRotationYaw) * partialTickTime), - 0.0F, - 1.0F, - 0.0F); - GL11.glRotatef(-f2, 1.0F, 0.0F, 0.0F); - RenderHelper.enableStandardItemLighting(); - // GL11.glPopMatrix(); - EntityPlayerSP entityplayersp = (EntityPlayerSP) entityclientplayermp; - float f3 = entityplayersp.prevRenderArmPitch - + (entityplayersp.renderArmPitch - entityplayersp.prevRenderArmPitch) * partialTickTime; - float f4 = entityplayersp.prevRenderArmYaw - + (entityplayersp.renderArmYaw - entityplayersp.prevRenderArmYaw) * partialTickTime; - GL11.glRotatef((entityclientplayermp.rotationPitch - f3) * 0.1F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef((entityclientplayermp.rotationYaw - f4) * 0.1F, 0.0F, 1.0F, 0.0F); - ItemStack itemstack = player.getCurrentEquippedItem(); - - if (itemstack != null && itemstack.getItem() instanceof ItemCloth) { - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - } - - int i = mc.theWorld.getLightBrightnessForSkyBlocks( - MathHelper.floor_double(entityclientplayermp.posX), - MathHelper.floor_double(entityclientplayermp.posY), - MathHelper.floor_double(entityclientplayermp.posZ), - 0); - int j = i % 65536; - int k = i / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - float f5; - float f6; - float f7; - - if (itemstack != null) { - int l = itemstack.getItem().getColorFromItemStack(itemstack, 0); - f5 = (float) (l >> 16 & 255) / 255.0F; - f6 = (float) (l >> 8 & 255) / 255.0F; - f7 = (float) (l & 255) / 255.0F; - GL11.glColor4f(f5, f6, f7, 1.0F); - } else { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - } - - float f8; - float f9; - float f10; - float f13; - Render render; - RenderPlayer renderplayer; - - if (itemstack != null && itemstack.getItem() instanceof ItemMap) { - GL11.glPushMatrix(); - f13 = 0.8F; - f5 = entityclientplayermp.getSwingProgress(partialTickTime); - f6 = MathHelper.sin(f5 * (float) Math.PI); - f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI); - GL11.glTranslatef( - -f7 * 0.4F, - MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI * 2.0F) * 0.2F, - -f6 * 0.2F); - f5 = 1.0F - f2 / 45.0F + 0.1F; - - if (f5 < 0.0F) { - f5 = 0.0F; - } - - if (f5 > 1.0F) { - f5 = 1.0F; - } - - f5 = -MathHelper.cos(f5 * (float) Math.PI) * 0.5F + 0.5F; - GL11.glTranslatef(0.0F, 0.0F * f13 - (1.0F - f1) * 1.2F - f5 * 0.5F + 0.04F, -0.9F * f13); - GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(f5 * -85.0F, 0.0F, 0.0F, 1.0F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - mc.getTextureManager().bindTexture(entityclientplayermp.getLocationSkin()); - - for (int i1 = 0; i1 < 2; ++i1) { - int j1 = i1 * 2 - 1; - GL11.glPushMatrix(); - GL11.glTranslatef(-0.0F, -0.6F, 1.1F * (float) j1); - GL11.glRotatef((float) (-45 * j1), 1.0F, 0.0F, 0.0F); - GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(59.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef((float) (-65 * j1), 0.0F, 1.0F, 0.0F); - render = RenderManager.instance.getEntityRenderObject(mc.thePlayer); - renderplayer = (RenderPlayer) render; - f10 = 1.0F; - GL11.glScalef(f10, f10, f10); - renderFirstPersonArm(renderplayer, mc.thePlayer); - GL11.glPopMatrix(); - } - - f6 = entityclientplayermp.getSwingProgress(partialTickTime); - f7 = MathHelper.sin(f6 * f6 * (float) Math.PI); - f8 = MathHelper.sin(MathHelper.sqrt_float(f6) * (float) Math.PI); - GL11.glRotatef(-f7 * 20.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-f8 * 20.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(-f8 * 80.0F, 1.0F, 0.0F, 0.0F); - f9 = 0.38F; - GL11.glScalef(f9, f9, f9); - GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); - GL11.glTranslatef(-1.0F, -1.0F, 0.0F); - f10 = 0.015625F; - GL11.glScalef(f10, f10, f10); - mc.getTextureManager().bindTexture(RES_MAP_BACKGROUND); - Tessellator tessellator = Tessellator.instance; - GL11.glNormal3f(0.0F, 0.0F, -1.0F); - tessellator.startDrawingQuads(); - byte b0 = 7; - tessellator.addVertexWithUV((double) (0 - b0), (double) (128 + b0), 0.0D, 0.0D, 1.0D); - tessellator.addVertexWithUV((double) (128 + b0), (double) (128 + b0), 0.0D, 1.0D, 1.0D); - tessellator.addVertexWithUV((double) (128 + b0), (double) (0 - b0), 0.0D, 1.0D, 0.0D); - tessellator.addVertexWithUV((double) (0 - b0), (double) (0 - b0), 0.0D, 0.0D, 0.0D); - tessellator.draw(); - - IItemRenderer custom = MinecraftForgeClient.getItemRenderer(itemstack, FIRST_PERSON_MAP); - MapData mapdata = ((ItemMap) itemstack.getItem()).getMapData(itemstack, mc.theWorld); - - if (custom == null) { - if (mapdata != null) { - mc.entityRenderer.getMapItemRenderer().func_148250_a(mapdata, false); - } - } else { - custom.renderItem(FIRST_PERSON_MAP, itemstack, mc.thePlayer, mc.getTextureManager(), mapdata); - } - - GL11.glPopMatrix(); - } else if (itemstack != null) { - GL11.glPushMatrix(); - f13 = 0.8F; - - if (entityclientplayermp.getItemInUseCount() > 0) { - EnumAction enumaction = itemstack.getItemUseAction(); - - if (enumaction == EnumAction.eat || enumaction == EnumAction.drink) { - f6 = (float) entityclientplayermp.getItemInUseCount() - partialTickTime + 1.0F; - f7 = 1.0F - f6 / (float) itemstack.getMaxItemUseDuration(); - f8 = 1.0F - f7; - f8 = f8 * f8 * f8; - f8 = f8 * f8 * f8; - f8 = f8 * f8 * f8; - f9 = 1.0F - f8; - GL11.glTranslatef( - 0.0F, - MathHelper.abs(MathHelper.cos(f6 / 4.0F * (float) Math.PI) * 0.1F) - * (float) ((double) f7 > 0.2D ? 1 : 0), - 0.0F); - GL11.glTranslatef(f9 * 0.6F, -f9 * 0.5F, 0.0F); - GL11.glRotatef(f9 * 90.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(f9 * 10.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(f9 * 30.0F, 0.0F, 0.0F, 1.0F); - } - } else { - f5 = entityclientplayermp.getSwingProgress(partialTickTime); - f6 = MathHelper.sin(f5 * (float) Math.PI); - f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI); - GL11.glTranslatef( - -f7 * 0.4F, - MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI * 2.0F) * 0.2F, - -f6 * 0.2F); - } - - GL11.glTranslatef(0.7F * f13, -0.65F * f13 - (1.0F - f1) * 0.6F, -0.9F * f13); - GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - f5 = entityclientplayermp.getSwingProgress(partialTickTime); - f6 = MathHelper.sin(f5 * f5 * (float) Math.PI); - f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI); - GL11.glRotatef(-f6 * 20.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-f7 * 20.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(-f7 * 80.0F, 1.0F, 0.0F, 0.0F); - f8 = 0.4F; - GL11.glScalef(f8, f8, f8); - float f11; - float f12; - - if (entityclientplayermp.getItemInUseCount() > 0) { - EnumAction enumaction1 = itemstack.getItemUseAction(); - - if (enumaction1 == EnumAction.block) { - GL11.glTranslatef(-0.5F, 0.2F, 0.0F); - GL11.glRotatef(30.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-80.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(60.0F, 0.0F, 1.0F, 0.0F); - } else if (enumaction1 == EnumAction.bow) { - GL11.glRotatef(-18.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(-12.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-8.0F, 1.0F, 0.0F, 0.0F); - GL11.glTranslatef(-0.9F, 0.2F, 0.0F); - f10 = (float) itemstack.getMaxItemUseDuration() - - ((float) entityclientplayermp.getItemInUseCount() - partialTickTime + 1.0F); - f11 = f10 / 20.0F; - f11 = (f11 * f11 + f11 * 2.0F) / 3.0F; - - if (f11 > 1.0F) { - f11 = 1.0F; - } - - if (f11 > 0.1F) { - GL11.glTranslatef(0.0F, MathHelper.sin((f10 - 0.1F) * 1.3F) * 0.01F * (f11 - 0.1F), 0.0F); - } - - GL11.glTranslatef(0.0F, 0.0F, f11 * 0.1F); - GL11.glRotatef(-335.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.5F, 0.0F); - f12 = 1.0F + f11 * 0.2F; - GL11.glScalef(1.0F, 1.0F, f12); - GL11.glTranslatef(0.0F, -0.5F, 0.0F); - GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); - } - } - - if (itemstack.getItem().shouldRotateAroundWhenRendering()) { - GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); - } - - if (itemstack.getItem().requiresMultipleRenderPasses()) { - RenderManager.instance.itemRenderer - .renderItem(entityclientplayermp, itemstack, 0, EQUIPPED_FIRST_PERSON); - for (int x = 1; x < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); x++) { - int k1 = itemstack.getItem().getColorFromItemStack(itemstack, x); - f10 = (float) (k1 >> 16 & 255) / 255.0F; - f11 = (float) (k1 >> 8 & 255) / 255.0F; - f12 = (float) (k1 & 255) / 255.0F; - GL11.glColor4f(1.0F * f10, 1.0F * f11, 1.0F * f12, 1.0F); - RenderManager.instance.itemRenderer - .renderItem(entityclientplayermp, itemstack, x, EQUIPPED_FIRST_PERSON); - } - } else { - RenderManager.instance.itemRenderer - .renderItem(entityclientplayermp, itemstack, 0, EQUIPPED_FIRST_PERSON); - } - - GL11.glPopMatrix(); - } else if (!entityclientplayermp.isInvisible()) { - GL11.glPushMatrix(); - f13 = 0.8F; - f5 = entityclientplayermp.getSwingProgress(partialTickTime); - f6 = MathHelper.sin(f5 * (float) Math.PI); - f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI); - GL11.glTranslatef( - -f7 * 0.3F, - MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI * 2.0F) * 0.4F, - -f6 * 0.4F); - GL11.glTranslatef(0.8F * f13, -0.75F * f13 - (1.0F - f1) * 0.6F, -0.9F * f13); - GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - f5 = entityclientplayermp.getSwingProgress(partialTickTime); - f6 = MathHelper.sin(f5 * f5 * (float) Math.PI); - f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI); - GL11.glRotatef(f7 * 70.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-f6 * 20.0F, 0.0F, 0.0F, 1.0F); - mc.getTextureManager().bindTexture(entityclientplayermp.getLocationSkin()); - GL11.glTranslatef(-1.0F, 3.6F, 3.5F); - GL11.glRotatef(120.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(200.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); - GL11.glScalef(1.0F, 1.0F, 1.0F); - GL11.glTranslatef(5.6F, 0.0F, 0.0F); - render = RenderManager.instance.getEntityRenderObject(mc.thePlayer); - renderplayer = (RenderPlayer) render; - f10 = 1.0F; - GL11.glScalef(f10, f10, f10); - renderFirstPersonArm(renderplayer, mc.thePlayer); - GL11.glPopMatrix(); - } - - if (itemstack != null && itemstack.getItem() instanceof ItemCloth) { - GL11.glDisable(GL11.GL_BLEND); - } - - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - RenderHelper.disableStandardItemLighting(); - } - - public static void renderFirstPersonArm(RenderPlayer renderer, EntityPlayer player) { - float f = 1.0F; - GL11.glColor3f(f, f, f); - - GL11.glPushMatrix(); - ModelRenderer mRenderer = new POVArmourModelWrapper(renderer.modelBipedMain); - renderer.modelBipedMain.onGround = 0.0F; - renderer.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, player); - renderer.modelBipedMain.bipedRightArm.render(0.0625F); - - GL11.glPushMatrix(); - mRenderer.rotateAngleX = renderer.modelBipedMain.bipedRightArm.rotateAngleX; - mRenderer.rotateAngleY = renderer.modelBipedMain.bipedRightArm.rotateAngleY; - mRenderer.rotateAngleZ = renderer.modelBipedMain.bipedRightArm.rotateAngleZ; - mRenderer.render(0.0625F); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - } -} diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/POVArmourModelWrapper.java b/src/main/java/WayofTime/alchemicalWizardry/client/POVArmourModelWrapper.java index 05f4a2d67c..c8c75b304b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/POVArmourModelWrapper.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/POVArmourModelWrapper.java @@ -10,7 +10,6 @@ import org.lwjgl.opengl.GL11; import WayofTime.alchemicalWizardry.ModItems; -import WayofTime.alchemicalWizardry.common.items.armour.BoundArmour; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -23,12 +22,11 @@ public class POVArmourModelWrapper extends ModelRenderer { public POVArmourModelWrapper(ModelBase model) { super(model); ItemStack plateStack = new ItemStack(ModItems.boundPlateFire); - ModelBiped bipedModel = ((BoundArmour) ModItems.boundPlateFire) + ModelBiped bipedModel = ModItems.boundPlateFire .getArmorModel(Minecraft.getMinecraft().thePlayer, plateStack, 1); armModel = bipedModel.bipedRightArm; resource = new ResourceLocation( - ((BoundArmour) ModItems.boundPlateFire) - .getArmorTexture(plateStack, Minecraft.getMinecraft().thePlayer, 1, "POV")); + ModItems.boundPlateFire.getArmorTexture(plateStack, Minecraft.getMinecraft().thePlayer, 1, "POV")); addBox(0, 0, 0, 0, 0, 0); // Adds in a blank box as it's required in certain cases such as rendering arrows in // entities } @@ -36,7 +34,6 @@ public POVArmourModelWrapper(ModelBase model) { @Override public void render(float partialTicks) { GL11.glPushMatrix(); - // GL11.glTranslated(0.3, -.1, 0); Minecraft.getMinecraft().renderEngine.bindTexture(resource); armModel.rotateAngleX = this.rotateAngleX; armModel.rotateAngleY = this.rotateAngleY; diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIAlchemyRecipeHandler.java b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIAlchemyRecipeHandler.java index 07aef6e8c9..42a8dfd9f8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIAlchemyRecipeHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIAlchemyRecipeHandler.java @@ -1,7 +1,7 @@ package WayofTime.alchemicalWizardry.client.nei; -import static WayofTime.alchemicalWizardry.client.ClientUtils.mc; import static WayofTime.alchemicalWizardry.client.nei.NEIConfig.getBloodOrbs; +import static WayofTime.alchemicalWizardry.client.renderer.RenderHelper.mc; import java.awt.Rectangle; import java.util.ArrayList; diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEICalcinatorHandler.java b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEICalcinatorHandler.java index 333986e19d..f1a73668f3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEICalcinatorHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEICalcinatorHandler.java @@ -1,7 +1,7 @@ package WayofTime.alchemicalWizardry.client.nei; -import static WayofTime.alchemicalWizardry.client.ClientUtils.mc; import static WayofTime.alchemicalWizardry.client.nei.NEIConfig.ARROW_TEXTURE; +import static WayofTime.alchemicalWizardry.client.renderer.RenderHelper.mc; import static codechicken.lib.gui.GuiDraw.fontRenderer; import java.awt.Rectangle; @@ -59,7 +59,7 @@ public CachedReagentInfo(ReagentStack reagent) { .translateToLocalFormatted("text.recipe.alchemicCalcinator.reagent", formattedAmount); this.amountTextWidth = fontRenderer.getStringWidth(amountText); - this.nameText = this.reagent.name; + this.nameText = this.reagent.name(); this.nameTextWidth = fontRenderer.getStringWidth(nameText); } @@ -85,7 +85,7 @@ public void onDraw(int x, int y) { textX = x + 84 - (nameTextWidth / 2); textY += 10; - int color = reagent.getColourRed() << 16 | reagent.getColourGreen() << 8 | reagent.getColourBlue(); + int color = reagent.red() << 16 | reagent.green() << 8 | reagent.blue(); fontRenderer.drawString(nameText, textX, textY, color); } @@ -116,10 +116,10 @@ private void drawColoredProgressBar(int x, int y) { GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4ub( - (byte) reagent.getColourRed(), - (byte) reagent.getColourGreen(), - (byte) reagent.getColourBlue(), - (byte) 255); + (byte) reagent.red(), + (byte) reagent.green(), + (byte) reagent.blue(), + (byte) reagent.intensity()); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(arrowX, arrowY + ARROW_HEIGHT, 0, 0, 1); diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java index 3fab3ae6b9..6eae15b054 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java @@ -1,6 +1,6 @@ package WayofTime.alchemicalWizardry.client.nei; -import static WayofTime.alchemicalWizardry.client.ClientUtils.mc; +import static WayofTime.alchemicalWizardry.client.renderer.RenderHelper.mc; import java.awt.Point; import java.awt.Rectangle; @@ -142,7 +142,7 @@ private String getReagentStrings(MeteorComponent component) { ArrayList reagents = component.getRequiredReagents(); ArrayList reagentNames = new ArrayList<>(); for (Reagent r : reagents) { - reagentNames.add(r.name); + reagentNames.add(r.name()); } return Joiner.on(", ").join(reagentNames); } @@ -369,7 +369,7 @@ private void addMeteorReagentInfo(List list, CachedMeteorRecipe cachedRe } if (!l.isEmpty()) { - list.add(r.name + ":"); + list.add(r.name() + ":"); list.addAll(l); } } @@ -404,6 +404,6 @@ private String reagentFillerBlockNames(MeteorReagent mr) { private String requiredReagentsForFiller(MeteorComponent mc) { List reagents = mc.getRequiredReagents(); if (reagents.isEmpty()) return ""; - return " (" + reagents.stream().map(r -> r.name).collect(Collectors.joining(", ")) + ")"; + return " (" + reagents.stream().map(r -> r.name()).collect(Collectors.joining(", ")) + ")"; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/BMNEIWidget.java b/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/BMNEIWidget.java index b784989d9c..03393b33ae 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/BMNEIWidget.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/BMNEIWidget.java @@ -1,6 +1,6 @@ package WayofTime.alchemicalWizardry.client.nei.widgets; -import static WayofTime.alchemicalWizardry.client.ClientUtils.mc; +import static WayofTime.alchemicalWizardry.client.renderer.RenderHelper.mc; import java.awt.Rectangle; diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/CostInfo.java b/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/CostInfo.java index 3a2824c85d..1e529114ec 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/CostInfo.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/CostInfo.java @@ -1,6 +1,6 @@ package WayofTime.alchemicalWizardry.client.nei.widgets; -import static WayofTime.alchemicalWizardry.client.ClientUtils.mc; +import static WayofTime.alchemicalWizardry.client.renderer.RenderHelper.mc; import java.util.ArrayList; diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/RadiusInfo.java b/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/RadiusInfo.java index 3554e1cf6b..390e75bf13 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/RadiusInfo.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/RadiusInfo.java @@ -1,6 +1,6 @@ package WayofTime.alchemicalWizardry.client.nei.widgets; -import static WayofTime.alchemicalWizardry.client.ClientUtils.mc; +import static WayofTime.alchemicalWizardry.client.renderer.RenderHelper.mc; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.item.ItemStack; diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/ReagentInfo.java b/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/ReagentInfo.java index 25ae5812b2..dff41c9ea1 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/ReagentInfo.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/ReagentInfo.java @@ -1,6 +1,6 @@ package WayofTime.alchemicalWizardry.client.nei.widgets; -import static WayofTime.alchemicalWizardry.client.ClientUtils.mc; +import static WayofTime.alchemicalWizardry.client.renderer.RenderHelper.mc; import java.util.List; diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/RitualInfo.java b/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/RitualInfo.java index d3db14da19..895c7e157d 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/RitualInfo.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/nei/widgets/RitualInfo.java @@ -1,6 +1,6 @@ package WayofTime.alchemicalWizardry.client.nei.widgets; -import static WayofTime.alchemicalWizardry.client.ClientUtils.mc; +import static WayofTime.alchemicalWizardry.client.renderer.RenderHelper.mc; import java.util.List; diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/renderer/HUDElement.java b/src/main/java/WayofTime/alchemicalWizardry/client/renderer/HUDElement.java index 5855afcfb5..4189d02d2d 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/renderer/HUDElement.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/renderer/HUDElement.java @@ -4,6 +4,7 @@ import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; import org.lwjgl.opengl.GL11; @@ -22,7 +23,7 @@ public class HUDElement { private int itemNameW; private String itemDamage = ""; private int itemDamageW; - private Minecraft mc = Minecraft.getMinecraft(); + private final Minecraft mc = Minecraft.getMinecraft(); private static final int offset = 5; @@ -63,26 +64,9 @@ private void initSize() { maxDamage = itemStack.getMaxDamage() + 1; damage = maxDamage - itemStack.getItemDamageForDisplay(); - boolean showSpecialValue = true; - boolean showValue = false; - boolean showPercent = false; - - boolean showMaxDamage = true; - boolean thresholdPercent = true; - - if (showSpecialValue) { - itemDamage = "\247" + ColourThreshold.getColorCode( - BloodMagicConfiguration.colorList, - (thresholdPercent ? damage * 100 / maxDamage : damage)) + this.value; - } else if (showValue) itemDamage = "\247" - + ColourThreshold.getColorCode( - BloodMagicConfiguration.colorList, - (thresholdPercent ? damage * 100 / maxDamage : damage)) - + damage - + (showMaxDamage ? "/" + maxDamage : ""); - else if (showPercent) itemDamage = "\247" + ColourThreshold.getColorCode( - BloodMagicConfiguration.colorList, - (thresholdPercent ? damage * 100 / maxDamage : damage)) + (damage * 100 / maxDamage) + "%"; + itemDamage = "§" + + ColourThreshold.getColorCode(BloodMagicConfiguration.colorList, damage * 100 / maxDamage) + + this.value; } itemDamageW = mc.fontRenderer.getStringWidth(HUDUtils.stripCtrl(itemDamage)); @@ -106,49 +90,30 @@ public void renderToHud(int x, int y) { RenderHelper.enableGUIStandardItemLighting(); itemRenderer.zLevel = 200.0F; - // if (ArmorStatusHUD.alignMode.toLowerCase().contains("right")) - boolean toRight = true; - if (toRight) { - itemRenderer.renderItemAndEffectIntoGUI( - mc.fontRenderer, - mc.getTextureManager(), - itemStack, - x - (iconW + padW), - y); - HUDUtils.renderItemOverlayIntoGUI( - mc.fontRenderer, - itemStack, - x - (iconW + padW), - y, - showDamageOverlay, - showItemCount); - - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(32826 /* GL_RESCALE_NORMAL_EXT */); - GL11.glDisable(GL11.GL_BLEND); - - mc.fontRenderer - .drawStringWithShadow(itemName + "\247r", x - (padW + iconW + padW) - itemNameW, y, 0xffffff); - mc.fontRenderer.drawStringWithShadow( - itemDamage + "\247r", - x - (padW + iconW + padW) - itemDamageW, - y + (enableItemName ? elementH / 2 : elementH / 4), - 0xffffff); - } else { - itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), itemStack, x, y); - HUDUtils.renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, x, y, showDamageOverlay, showItemCount); - - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(32826 /* GL_RESCALE_NORMAL_EXT */); - GL11.glDisable(GL11.GL_BLEND); - - mc.fontRenderer.drawStringWithShadow(itemName + "\247r", x + iconW + padW, y, 0xffffff); - mc.fontRenderer.drawStringWithShadow( - itemDamage + "\247r", - x + iconW + padW, - y + (enableItemName ? elementH / 2 : elementH / 4), - 0xffffff); - } + itemRenderer + .renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), itemStack, x - (iconW + padW), y); + HUDUtils.renderItemOverlayIntoGUI( + mc.fontRenderer, + itemStack, + x - (iconW + padW), + y, + showDamageOverlay, + showItemCount); + + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(32826 /* GL_RESCALE_NORMAL_EXT */); + GL11.glDisable(GL11.GL_BLEND); + + mc.fontRenderer.drawStringWithShadow( + itemName + EnumChatFormatting.RESET, + x - (padW + iconW + padW) - itemNameW, + y, + 0xffffff); + mc.fontRenderer.drawStringWithShadow( + itemDamage + EnumChatFormatting.RESET, + x - (padW + iconW + padW) - itemDamageW, + y + (enableItemName ? elementH / 2 : elementH / 4), + 0xffffff); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/renderer/HUDUtils.java b/src/main/java/WayofTime/alchemicalWizardry/client/renderer/HUDUtils.java index 112c4b10c5..96463a4b79 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/renderer/HUDUtils.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/renderer/HUDUtils.java @@ -2,280 +2,20 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; /** * This class is a utility class that was created by bspkrs. - * https://github.com/bspkrs/bspkrsCore/blob/master/src/main/java/bspkrs/client/util/HUDUtils.java + * Source */ public final class HUDUtils { - private static int[] colorCodes = new int[] { 0, 170, 43520, 43690, 11141120, 11141290, 16755200, 11184810, 5592405, - 5592575, 5635925, 5636095, 16733525, 16733695, 16777045, 16777215, 0, 42, 10752, 10794, 2752512, 2752554, - 2763264, 2763306, 1381653, 1381695, 1392405, 1392447, 4134165, 4134207, 4144917, 4144959 }; - - public static int getColorCode(char c, boolean isLighter) { - return colorCodes[isLighter ? "0123456789abcdef".indexOf(c) : "0123456789abcdef".indexOf(c) + 16]; - } - - /** - * Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with - * continuous borders and filler. It is assumed that the desired texture ResourceLocation object has been bound - * using Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation). - * - * @param x x axis offset - * @param y y axis offset - * @param u bound resource location image x offset - * @param v bound resource location image y offset - * @param width the desired box width - * @param height the desired box height - * @param textureWidth the width of the box texture in the resource location image - * @param textureHeight the height of the box texture in the resource location image - * @param borderSize the size of the box's borders - * @param zLevel the zLevel to draw at - */ - public static void drawContinuousTexturedBox(int x, int y, int u, int v, int width, int height, int textureWidth, - int textureHeight, int borderSize, float zLevel) { - drawContinuousTexturedBox( - x, - y, - u, - v, - width, - height, - textureWidth, - textureHeight, - borderSize, - borderSize, - borderSize, - borderSize, - zLevel); - } - - /** - * Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with - * continuous borders and filler. The provided ResourceLocation object will be bound using - * Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation). - * - * @param res the ResourceLocation object that contains the desired image - * @param x x axis offset - * @param y y axis offset - * @param u bound resource location image x offset - * @param v bound resource location image y offset - * @param width the desired box width - * @param height the desired box height - * @param textureWidth the width of the box texture in the resource location image - * @param textureHeight the height of the box texture in the resource location image - * @param borderSize the size of the box's borders - * @param zLevel the zLevel to draw at - */ - public static void drawContinuousTexturedBox(ResourceLocation res, int x, int y, int u, int v, int width, - int height, int textureWidth, int textureHeight, int borderSize, float zLevel) { - drawContinuousTexturedBox( - res, - x, - y, - u, - v, - width, - height, - textureWidth, - textureHeight, - borderSize, - borderSize, - borderSize, - borderSize, - zLevel); - } - - /** - * Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with - * continuous borders and filler. The provided ResourceLocation object will be bound using - * Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation). - * - * @param res the ResourceLocation object that contains the desired image - * @param x x axis offset - * @param y y axis offset - * @param u bound resource location image x offset - * @param v bound resource location image y offset - * @param width the desired box width - * @param height the desired box height - * @param textureWidth the width of the box texture in the resource location image - * @param textureHeight the height of the box texture in the resource location image - * @param topBorder the size of the box's top border - * @param bottomBorder the size of the box's bottom border - * @param leftBorder the size of the box's left border - * @param rightBorder the size of the box's right border - * @param zLevel the zLevel to draw at - */ - public static void drawContinuousTexturedBox(ResourceLocation res, int x, int y, int u, int v, int width, - int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, - int rightBorder, float zLevel) { - Minecraft.getMinecraft().getTextureManager().bindTexture(res); - drawContinuousTexturedBox( - x, - y, - u, - v, - width, - height, - textureWidth, - textureHeight, - topBorder, - bottomBorder, - leftBorder, - rightBorder, - zLevel); - } - - /** - * Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with - * continuous borders and filler. It is assumed that the desired texture ResourceLocation object has been bound - * using Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation). - * - * @param x x axis offset - * @param y y axis offset - * @param u bound resource location image x offset - * @param v bound resource location image y offset - * @param width the desired box width - * @param height the desired box height - * @param textureWidth the width of the box texture in the resource location image - * @param textureHeight the height of the box texture in the resource location image - * @param topBorder the size of the box's top border - * @param bottomBorder the size of the box's bottom border - * @param leftBorder the size of the box's left border - * @param rightBorder the size of the box's right border - * @param zLevel the zLevel to draw at - */ - public static void drawContinuousTexturedBox(int x, int y, int u, int v, int width, int height, int textureWidth, - int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - int fillerWidth = textureWidth - leftBorder - rightBorder; - int fillerHeight = textureHeight - topBorder - bottomBorder; - int canvasWidth = width - leftBorder - rightBorder; - int canvasHeight = height - topBorder - bottomBorder; - int xPasses = canvasWidth / fillerWidth; - int remainderWidth = canvasWidth % fillerWidth; - int yPasses = canvasHeight / fillerHeight; - int remainderHeight = canvasHeight % fillerHeight; - - // Draw Border - // Top Left - drawTexturedModalRect(x, y, u, v, leftBorder, topBorder, zLevel); - // Top Right - drawTexturedModalRect( - x + leftBorder + canvasWidth, - y, - u + leftBorder + fillerWidth, - v, - rightBorder, - topBorder, - zLevel); - // Bottom Left - drawTexturedModalRect( - x, - y + topBorder + canvasHeight, - u, - v + topBorder + fillerHeight, - leftBorder, - bottomBorder, - zLevel); - // Bottom Right - drawTexturedModalRect( - x + leftBorder + canvasWidth, - y + topBorder + canvasHeight, - u + leftBorder + fillerWidth, - v + topBorder + fillerHeight, - rightBorder, - bottomBorder, - zLevel); - - for (int i = 0; i < xPasses + (remainderWidth > 0 ? 1 : 0); i++) { - // Top Border - drawTexturedModalRect( - x + leftBorder + (i * fillerWidth), - y, - u + leftBorder, - v, - (i == xPasses ? remainderWidth : fillerWidth), - topBorder, - zLevel); - // Bottom Border - drawTexturedModalRect( - x + leftBorder + (i * fillerWidth), - y + topBorder + canvasHeight, - u + leftBorder, - v + topBorder + fillerHeight, - (i == xPasses ? remainderWidth : fillerWidth), - bottomBorder, - zLevel); - - // Throw in some filler for good measure - for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++) drawTexturedModalRect( - x + leftBorder + (i * fillerWidth), - y + topBorder + (j * fillerHeight), - u + leftBorder, - v + topBorder, - (i == xPasses ? remainderWidth : fillerWidth), - (j == yPasses ? remainderHeight : fillerHeight), - zLevel); - } - - // Side Borders - for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++) { - // Left Border - drawTexturedModalRect( - x, - y + topBorder + (j * fillerHeight), - u, - v + topBorder, - leftBorder, - (j == yPasses ? remainderHeight : fillerHeight), - zLevel); - // Right Border - drawTexturedModalRect( - x + leftBorder + canvasWidth, - y + topBorder + (j * fillerHeight), - u + leftBorder + fillerWidth, - v + topBorder, - rightBorder, - (j == yPasses ? remainderHeight : fillerHeight), - zLevel); - } - } - - public static void drawTexturedModalRect(int x, int y, int u, int v, int width, int height, float zLevel) { - float var7 = 0.00390625F; - float var8 = 0.00390625F; - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV((x + 0), (y + height), zLevel, ((u + 0) * var7), ((v + height) * var8)); - tessellator.addVertexWithUV((x + width), (y + height), zLevel, ((u + width) * var7), ((v + height) * var8)); - tessellator.addVertexWithUV((x + width), (y + 0), zLevel, ((u + width) * var7), ((v + 0) * var8)); - tessellator.addVertexWithUV((x + 0), (y + 0), zLevel, ((u + 0) * var7), ((v + 0) * var8)); - tessellator.draw(); - } - - /** - * Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the - * specified position. - */ - public static void renderItemOverlayIntoGUI(FontRenderer fontRenderer, ItemStack itemStack, int x, int y) { - renderItemOverlayIntoGUI(fontRenderer, itemStack, x, y, true, true); - } - /** * Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the * specified position. @@ -310,7 +50,7 @@ public static void renderItemOverlayIntoGUI(FontRenderer fontRenderer, ItemStack Minecraft.getMinecraft().thePlayer, itemStack.getItem(), itemStack.getItemDamage()); - else if (itemStack.getItem().equals(Items.bow)) + else if (itemStack.getItem() != null && itemStack.getItem().equals(Items.bow)) count = HUDUtils.countInInventory(Minecraft.getMinecraft().thePlayer, Items.arrow); if (count > 1) { @@ -336,10 +76,10 @@ else if (itemStack.getItem().equals(Items.bow)) public static void renderQuad(Tessellator tessellator, int x, int y, int width, int height, int color) { tessellator.startDrawingQuads(); tessellator.setColorOpaque_I(color); - tessellator.addVertex((x + 0), (y + 0), 0.0D); - tessellator.addVertex((x + 0), (y + height), 0.0D); - tessellator.addVertex((x + width), (y + height), 0.0D); - tessellator.addVertex((x + width), (y + 0), 0.0D); + tessellator.addVertex(x, y, 0.0D); + tessellator.addVertex(x, y + height, 0.0D); + tessellator.addVertex(x + width, y + height, 0.0D); + tessellator.addVertex(x + width, y, 0.0D); tessellator.draw(); } @@ -357,6 +97,6 @@ public static int countInInventory(EntityPlayer player, Item item, int md) { } public static String stripCtrl(String s) { - return s.replaceAll("(?i)\247[0-9a-fklmnor]", ""); + return s.replaceAll("(?i)§[0-9a-fklmnor]", ""); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/renderer/RenderHelper.java b/src/main/java/WayofTime/alchemicalWizardry/client/renderer/RenderHelper.java index bad4d2f20e..612067c258 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/renderer/RenderHelper.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/renderer/RenderHelper.java @@ -10,7 +10,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; @@ -29,77 +28,67 @@ public class RenderHelper { - public static boolean enableItemName = false; - public static boolean enabled = true; - public static boolean showInChat = true; - public static int lpBarX = 12; public static int lpBarY = 75; public static int zLevel = 0; - private static int xOffsetDefault = +50; + private static final int xOffsetDefault = 50; public static int xOffset = xOffsetDefault; - private static int yOffsetDefault = 2; + private static final int yOffsetDefault = 2; public static int yOffset = yOffsetDefault; - private static int yOffsetBottomCenterDefault = 41; + private static final int yOffsetBottomCenterDefault = 41; public static int yOffsetBottomCenter = yOffsetBottomCenterDefault; - private static boolean applyXOffsetToCenterDefault = true; + private static final boolean applyXOffsetToCenterDefault = true; public static boolean applyXOffsetToCenter = applyXOffsetToCenterDefault; - private static boolean applyYOffsetToMiddleDefault = false; + private static final boolean applyYOffsetToMiddleDefault = false; public static boolean applyYOffsetToMiddle = applyYOffsetToMiddleDefault; public static String listMode = "horizontal"; public static String alignMode = "bottomcenter"; + public static Minecraft mc = Minecraft.getMinecraft(); private static ScaledResolution scaledResolution; - public static boolean onTickInGame(Minecraft mc) { - if (enabled - && (mc.inGameHasFocus || mc.currentScreen == null - || (mc.currentScreen instanceof GuiChat && showInChat)) - && !mc.gameSettings.showDebugInfo) { - EntityPlayer player = mc.thePlayer; - player.getEntityData(); - if (SpellHelper.canPlayerSeeAlchemy(player)) { - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - displayArmorStatus(mc); - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - } + public static void onTickInGame(Minecraft mc) { + if (!(mc.inGameHasFocus || mc.currentScreen == null || mc.currentScreen instanceof GuiChat) + || mc.gameSettings.showDebugInfo) { + return; + } + EntityPlayer player = mc.thePlayer; + if (SpellHelper.canPlayerSeeAlchemy(player)) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + displayArmorStatus(mc); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + } - ItemStack stack = player.inventory.armorItemInSlot(2); - if (stack != null && stack.getItem() instanceof OmegaArmour) { - int maxAmount = (int) APISpellHelper.getPlayerMaxReagentAmount(player); + ItemStack stack = player.inventory.armorItemInSlot(2); + if (stack != null && stack.getItem() instanceof OmegaArmour) { + int maxAmount = (int) APISpellHelper.getPlayerMaxReagentAmount(player); - if (maxAmount > 0) { - float val = APISpellHelper.getPlayerCurrentReagentAmount(player); - ReagentStack reagentStack = new ReagentStack( - APISpellHelper.getPlayerReagentType(player), - (int) val); + if (maxAmount > 0) { + float val = APISpellHelper.getPlayerCurrentReagentAmount(player); + ReagentStack reagentStack = new ReagentStack(APISpellHelper.getPlayerReagentType(player), (int) val); - if (reagentStack != null && reagentStack.amount > 0) { - renderTestHUD(mc, reagentStack, maxAmount); - } + if (reagentStack.amount > 0) { + renderOmegaReagentHUD(mc, reagentStack, maxAmount); } } + } - if (SpellHelper.canPlayerSeeLPBar(player)) { - int max = APISpellHelper.getPlayerMaxLPTag(player); - - if (max > 1) { - renderLPHUD(mc, APISpellHelper.getPlayerLPTag(player), max); - } - } + if (SpellHelper.canPlayerSeeLPBar(player)) { + int max = APISpellHelper.getPlayerMaxLPTag(player); - float maxHP = APISpellHelper.getCurrentAdditionalMaxHP(player); - // System.out.println("MaxHP: " + maxHP); - if (maxHP > 0) { - renderHPHUD(mc, APISpellHelper.getCurrentAdditionalHP(player), maxHP); + if (max > 1) { + renderLPHUD(mc, APISpellHelper.getPlayerLPTag(player), max); } } - return true; + float maxHP = APISpellHelper.getCurrentAdditionalMaxHP(player); + if (maxHP > 0) { + renderHPHUD(mc, APISpellHelper.getCurrentAdditionalHP(player), maxHP); + } } private static void renderLPHUD(Minecraft mc, int lpAmount, int maxAmount) { @@ -155,42 +144,41 @@ private static void renderHPHUD(Minecraft mc, float hpAmount, float maxAmount) { } private static List getHUDElements(Minecraft mc) { - List elements = new ArrayList(); + List elements = new ArrayList<>(); MovingObjectPosition movingobjectposition = mc.objectMouseOver; World world = mc.theWorld; if (movingobjectposition == null) { return elements; - } else { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - int x = movingobjectposition.blockX; - int y = movingobjectposition.blockY; - int z = movingobjectposition.blockZ; - - TileEntity tile = world.getTileEntity(x, y, z); + } + if (movingobjectposition.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { + return elements; + } + int x = movingobjectposition.blockX; + int y = movingobjectposition.blockY; + int z = movingobjectposition.blockZ; - if (!(tile instanceof IReagentHandler)) { - return elements; - } + TileEntity tile = world.getTileEntity(x, y, z); - IReagentHandler relay = (IReagentHandler) tile; + if (!(tile instanceof IReagentHandler relay)) { + return elements; + } - ReagentContainerInfo[] infos = relay - .getContainerInfo(ForgeDirection.getOrientation(movingobjectposition.sideHit)); + ReagentContainerInfo[] infos = relay + .getContainerInfo(ForgeDirection.getOrientation(movingobjectposition.sideHit)); - if (infos != null) { - for (ReagentContainerInfo info : infos) { - if (info == null || info.reagent == null || info.reagent.reagent == null) { - continue; - } + if (infos == null) { + return elements; + } + for (ReagentContainerInfo info : infos) { + if (info == null || info.reagent == null || info.reagent.reagent == null) { + continue; + } - ItemStack itemStack = ReagentRegistry.getItemForReagent(info.reagent.reagent); + ItemStack itemStack = ReagentRegistry.getItemForReagent(info.reagent.reagent); - if (itemStack != null) elements.add(new HUDElement(itemStack, 16, 16, 2, info.reagent.amount)); - } - } - } + if (itemStack != null) elements.add(new HUDElement(itemStack, 16, 16, 2, info.reagent.amount)); } return elements; @@ -221,40 +209,23 @@ private static int getElementsWidth(List elements) { return r; } - public static void drawTexturedModalRect(int p_73729_1_, int p_73729_2_, int p_73729_3_, int p_73729_4_, - double p_73729_5_, double p_73729_6_) { + public static void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height) { float f = 0.00390625F; - float f1 = 0.00390625F; Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(x, y + height, zLevel, (float) (textureX) * f, (float) (textureY + height) * f); tessellator.addVertexWithUV( - (double) p_73729_1_, - p_73729_2_ + p_73729_6_, - (double) zLevel, - (p_73729_3_ * f), - (p_73729_4_ + p_73729_6_) * f1); - tessellator.addVertexWithUV( - p_73729_1_ + p_73729_5_, - p_73729_2_ + p_73729_6_, - (double) zLevel, - (p_73729_3_ + p_73729_5_) * f, - (p_73729_4_ + p_73729_6_) * f1); - tessellator.addVertexWithUV( - p_73729_1_ + p_73729_5_, - (double) p_73729_2_, - (double) zLevel, - (p_73729_3_ + p_73729_5_) * f, - p_73729_4_ * f1); - tessellator.addVertexWithUV( - (double) p_73729_1_, - (double) p_73729_2_, - (double) zLevel, - (double) (p_73729_3_ * f), - p_73729_4_ * f1); + x + width, + y + height, + zLevel, + (float) (textureX + width) * f, + (float) (textureY + height) * f); + tessellator.addVertexWithUV(x + width, y, zLevel, (float) (textureX + width) * f, (float) (textureY) * f); + tessellator.addVertexWithUV(x, y, zLevel, (float) (textureX) * f, (float) (textureY) * f); tessellator.draw(); } - private static void renderTestHUD(Minecraft mc, ReagentStack reagentStack, int maxAmount) { + private static void renderOmegaReagentHUD(Minecraft mc, ReagentStack reagentStack, int maxAmount) { GL11.glPushMatrix(); Reagent reagent = reagentStack.reagent; int xSize = 32; @@ -268,11 +239,7 @@ private static void renderTestHUD(Minecraft mc, ReagentStack reagentStack, int m GL11.glScalef(1f / 8f, 1f / 8f, 1f / 8f); ResourceLocation test2 = new ResourceLocation("alchemicalwizardry", "textures/gui/container1.png"); - GL11.glColor4f( - reagent.getColourRed() / 255f, - reagent.getColourGreen() / 255f, - reagent.getColourBlue() / 255f, - 1.0F); + GL11.glColor4ub((byte) reagent.red(), (byte) reagent.green(), (byte) reagent.blue(), (byte) 255); mc.getTextureManager().bindTexture(test2); drawTexturedModalRect(x, y + amount, 0, amount, 256, 256 - amount); @@ -286,63 +253,34 @@ private static void renderTestHUD(Minecraft mc, ReagentStack reagentStack, int m GL11.glPopMatrix(); } - public static void renderIcon(int p_94149_1_, int p_94149_2_, IIcon p_94149_3_, int p_94149_4_, int p_94149_5_) { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV( - (double) p_94149_1_, - (double) (p_94149_2_ + p_94149_5_), - (double) zLevel, - (double) p_94149_3_.getMinU(), - (double) p_94149_3_.getMaxV()); - tessellator.addVertexWithUV( - (double) (p_94149_1_ + p_94149_4_), - (double) (p_94149_2_ + p_94149_5_), - (double) zLevel, - (double) p_94149_3_.getMaxU(), - (double) p_94149_3_.getMaxV()); - tessellator.addVertexWithUV( - (double) (p_94149_1_ + p_94149_4_), - (double) p_94149_2_, - (double) zLevel, - (double) p_94149_3_.getMaxU(), - (double) p_94149_3_.getMinV()); - tessellator.addVertexWithUV( - (double) p_94149_1_, - (double) p_94149_2_, - (double) zLevel, - (double) p_94149_3_.getMinU(), - (double) p_94149_3_.getMinV()); - tessellator.draw(); - } - private static void displayArmorStatus(Minecraft mc) { List elements = getHUDElements(mc); - if (elements.size() > 0) { - int yOffset = enableItemName ? 18 : 16; + if (elements.isEmpty()) { + return; + } + int yOffset = 16; - if (listMode.equalsIgnoreCase("vertical")) { - int yBase = getY(elements.size(), yOffset); + if (listMode.equalsIgnoreCase("vertical")) { + int yBase = getY(elements.size(), yOffset); - for (HUDElement e : elements) { - e.renderToHud((alignMode.toLowerCase().contains("right") ? getX(0) : getX(e.width())), yBase); - yBase += yOffset; - } - } else if (listMode.equalsIgnoreCase("horizontal")) { - int totalWidth = getElementsWidth(elements); - int yBase = getY(1, yOffset); - int xBase = getX(totalWidth); - int prevX = 0; - - for (HUDElement e : elements) { - e.renderToHud(xBase + prevX + (alignMode.toLowerCase().contains("right") ? e.width() : 0), yBase); - prevX += (e.width()); - } - } // else if (listMode.equalsIgnoreCase("compound")) - { - // TODO + for (HUDElement e : elements) { + e.renderToHud((alignMode.toLowerCase().contains("right") ? getX(0) : getX(e.width())), yBase); + yBase += yOffset; + } + } else if (listMode.equalsIgnoreCase("horizontal")) { + int totalWidth = getElementsWidth(elements); + int yBase = getY(1, yOffset); + int xBase = getX(totalWidth); + int prevX = 0; + + for (HUDElement e : elements) { + e.renderToHud(xBase + prevX + (alignMode.toLowerCase().contains("right") ? e.width() : 0), yBase); + prevX += (e.width()); } + } // else if (listMode.equalsIgnoreCase("compound")) + { + // TODO } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/renderer/RitualDivinerRender.java b/src/main/java/WayofTime/alchemicalWizardry/client/renderer/RitualDivinerRender.java index 6dc61649c2..5999fb8178 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/renderer/RitualDivinerRender.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/renderer/RitualDivinerRender.java @@ -55,8 +55,7 @@ public void render(RenderWorldLastEvent event) { double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.partialTicks; if (player.inventory.getCurrentItem() != null - && player.inventory.getCurrentItem().getItem() instanceof ItemRitualDiviner) { - ItemRitualDiviner ritualDiviner = (ItemRitualDiviner) player.inventory.getCurrentItem().getItem(); + && player.inventory.getCurrentItem().getItem() instanceof ItemRitualDiviner ritualDiviner) { int direction = ritualDiviner.getDirection(player.inventory.getCurrentItem()); RitualEffect ritualEffect = getEffectFromString( ritualDiviner.getCurrentRitual(player.inventory.getCurrentItem())); @@ -70,19 +69,16 @@ public void render(RenderWorldLastEvent event) { GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); for (RitualComponent ritualComponent : ritualEffect.getRitualComponentList()) { Vector3 vX = vec3.add( - new Vector3( - ritualComponent.getX(direction), - ritualComponent.getY(), - ritualComponent.getZ(direction))); - double minX = vX.x - posX; - double minY = vX.y - posY; - double minZ = vX.z - posZ; - - if (!world.getBlock(vX.x, vX.y, vX.z).isOpaqueCube()) { + new Vector3(ritualComponent.x(direction), ritualComponent.y(), ritualComponent.z(direction))); + double minX = vX.x() - posX; + double minY = vX.y() - posY; + double minZ = vX.z() - posZ; + + if (!world.getBlock(vX.x(), vX.y(), vX.z()).isOpaqueCube()) { RenderFakeBlocks.drawFakeBlock( vX, ModBlocks.ritualStone, - ritualComponent.getStoneType(), + ritualComponent.stoneType(), minX, minY, minZ, diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/AlchemicalWizardryEventHooks.java b/src/main/java/WayofTime/alchemicalWizardry/common/AlchemicalWizardryEventHooks.java index fde0d19cba..e6dd8ae814 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/AlchemicalWizardryEventHooks.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/AlchemicalWizardryEventHooks.java @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Random; @@ -62,12 +61,12 @@ public class AlchemicalWizardryEventHooks { - public static Map playerFlightBuff = new HashMap(); - public static List playersWith1Step = new ArrayList(); + public static Map playerFlightBuff = new HashMap<>(); + public static List playersWith1Step = new ArrayList<>(); - public static Map> respawnMap = new HashMap(); - public static Map> forceSpawnMap = new HashMap(); - public static ArrayList teleposerBlacklist = new ArrayList(); + public static Map> respawnMap = new HashMap<>(); + public static Map> forceSpawnMap = new HashMap<>(); + public static ArrayList teleposerBlacklist = new ArrayList<>(); public static Random rand = new Random(); @@ -81,10 +80,8 @@ public void onEntityInteractEvent(EntityInteractEvent event) { ItemStack heldItem = player.getHeldItem(); if (heldItem == null) { parad.onEmptyHandEntityInteract(player, event.target); - } else { - if (heldItem.getItem() instanceof EnergySword) { - parad.onBoundSwordInteractWithEntity(player, event.target); - } + } else if (heldItem.getItem() instanceof EnergySword) { + parad.onBoundSwordInteractWithEntity(player, event.target); } } @@ -99,15 +96,14 @@ public void onAnvilUpdateEvent(AnvilUpdateEvent event) { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onLivingHurtEvent(LivingHurtEvent event) { - if (!event.isCanceled() && event.entityLiving instanceof EntityPlayer + if (!event.isCanceled() && event.entityLiving instanceof EntityPlayerMP player && !event.entityLiving.worldObj.isRemote) { - EntityPlayer player = (EntityPlayer) event.entityLiving; if (APISpellHelper.getCurrentAdditionalMaxHP(player) > 0) { APISpellHelper.setPlayerReagentRegenCooldownTag(player, 20 * 20); } - float prevHp = APISpellHelper.getCurrentAdditionalHP((EntityPlayer) event.entityLiving); + float prevHp = APISpellHelper.getCurrentAdditionalHP(player); if (prevHp > 0) { float recalculatedAmount = ArmorProperties .ApplyArmor(player, player.inventory.armorInventory, event.source, event.ammount); @@ -141,17 +137,12 @@ public void onLivingHurtEvent(LivingHurtEvent event) { APISpellHelper.setCurrentAdditionalHP(player, hp); NewPacketHandler.INSTANCE.sendTo( NewPacketHandler.getAddedHPPacket(hp, APISpellHelper.getCurrentAdditionalMaxHP(player)), - (EntityPlayerMP) player); - - // if(event.ammount <= 0.3) - // { - // event.ammount++; - // } + player); } else { APISpellHelper.setCurrentAdditionalHP(player, 0); NewPacketHandler.INSTANCE.sendTo( NewPacketHandler.getAddedHPPacket(0, APISpellHelper.getCurrentAdditionalMaxHP(player)), - (EntityPlayerMP) player); + player); event.ammount -= prevHp / ratio; if (event.ammount < 0) { @@ -164,8 +155,7 @@ public void onLivingHurtEvent(LivingHurtEvent event) { @SubscribeEvent public void omegaUpdateReagentAndHpEvent(LivingUpdateEvent event) { - if (event.entityLiving instanceof EntityPlayer && !event.entityLiving.worldObj.isRemote) { - EntityPlayer player = (EntityPlayer) event.entityLiving; + if (event.entityLiving instanceof EntityPlayer player && !event.entityLiving.worldObj.isRemote) { Reagent reagent = APISpellHelper.getPlayerReagentType(player); float reagentAmount = APISpellHelper.getPlayerCurrentReagentAmount(player); @@ -222,10 +212,7 @@ public void omegaUpdateReagentAndHpEvent(LivingUpdateEvent event) { float drain = addedAmount * config.costPerPoint; reagentAmount -= drain; - hasReagentChanged = true; - health += addedAmount; - hasHealthChanged = true; } @@ -239,7 +226,6 @@ public void omegaUpdateReagentAndHpEvent(LivingUpdateEvent event) { } } } - } else { reagentAmount = 0; APISpellHelper.setPlayerMaxReagentAmount(player, 0); @@ -252,10 +238,8 @@ public void omegaUpdateReagentAndHpEvent(LivingUpdateEvent event) { float costPerTick = parad.getCostPerTickOfUse(player); if (parad.doDrainReagent(player)) { if (reagentAmount > costPerTick) { - hasReagentChanged = true; reagentAmount = Math.max(0, reagentAmount - costPerTick); } else { - hasReagentChanged = true; reagentAmount = 0; } } @@ -279,7 +263,7 @@ public void omegaUpdateReagentAndHpEvent(LivingUpdateEvent event) { } } - if (player instanceof EntityPlayerMP) { + if (player instanceof EntityPlayerMP p) { if (hasReagentChanged) { APISpellHelper.setPlayerCurrentReagentAmount(player, reagentAmount); NewPacketHandler.INSTANCE.sendTo( @@ -287,7 +271,7 @@ public void omegaUpdateReagentAndHpEvent(LivingUpdateEvent event) { reagent, reagentAmount, APISpellHelper.getPlayerMaxReagentAmount(player)), - (EntityPlayerMP) player); + p); } } } @@ -295,10 +279,9 @@ public void omegaUpdateReagentAndHpEvent(LivingUpdateEvent event) { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onPlayerDamageEvent(LivingAttackEvent event) { - if (event.source.isProjectile()) { - if (event.entityLiving.isPotionActive(AlchemicalWizardry.customPotionProjProt) && event.isCancelable()) { - event.setCanceled(true); - } + if (event.source.isProjectile() && event.entityLiving.isPotionActive(AlchemicalWizardry.customPotionProjProt) + && event.isCancelable()) { + event.setCanceled(true); } } @@ -318,30 +301,23 @@ public void onLivingSpawnEvent(CheckSpawn event) { for (CoordAndRange coords : list) { TileEntity tile = event.world.getTileEntity(coords.xCoord, coords.yCoord, coords.zCoord); - if (tile instanceof TEMasterStone && ((TEMasterStone) tile).isRunning - && ((TEMasterStone) tile).getCurrentRitual().equals(respawnRitual)) { - if (event.x > coords.xCoord - coords.horizRadius && event.x < coords.xCoord + coords.horizRadius - && event.z > coords.zCoord - coords.horizRadius - && event.z < coords.zCoord + coords.horizRadius - && event.y > coords.yCoord - coords.vertRadius - && event.y < coords.yCoord + coords.vertRadius) { - switch (event.getResult()) { - case ALLOW: - event.setResult(Result.DEFAULT); - break; - case DEFAULT: - event.setResult(Result.DENY); - break; - case DENY: - break; - default: - break; - } - break; - } - } else { + if (!(tile instanceof TEMasterStone masterStone) || !masterStone.isRunning + || !masterStone.getCurrentRitual().equals(respawnRitual)) { list.remove(coords); + continue; + } + if (event.x <= coords.xCoord - coords.horizRadius || !(event.x < coords.xCoord + coords.horizRadius) + || !(event.z > coords.zCoord - coords.horizRadius) + || !(event.z < coords.zCoord + coords.horizRadius) + || !(event.y > coords.yCoord - coords.vertRadius) + || !(event.y < coords.yCoord + coords.vertRadius)) { + continue; } + switch (event.getResult()) { + case ALLOW -> event.setResult(Result.DEFAULT); + case DEFAULT -> event.setResult(Result.DENY); + } + break; } } } @@ -359,30 +335,23 @@ public void onLivingSpawnEvent(CheckSpawn event) { for (CoordAndRange coords : list) { TileEntity tile = event.world.getTileEntity(coords.xCoord, coords.yCoord, coords.zCoord); - if (tile instanceof TEMasterStone && ((TEMasterStone) tile).isRunning - && ((TEMasterStone) tile).getCurrentRitual().equals(forceSpawnRitual)) { - if (event.x > coords.xCoord - coords.horizRadius && event.x < coords.xCoord + coords.horizRadius - && event.z > coords.zCoord - coords.horizRadius - && event.z < coords.zCoord + coords.horizRadius - && event.y > coords.yCoord - coords.vertRadius - && event.y < coords.yCoord + coords.vertRadius) { - switch (event.getResult()) { - case ALLOW: - break; - case DEFAULT: - event.setResult(Result.ALLOW); - break; - case DENY: - event.setResult(Result.DEFAULT); - break; - default: - break; - } - break; - } - } else { + if (!(tile instanceof TEMasterStone stone) || !stone.isRunning + || !stone.getCurrentRitual().equals(forceSpawnRitual)) { list.remove(coords); + continue; } + if (event.x <= coords.xCoord - coords.horizRadius || !(event.x < coords.xCoord + coords.horizRadius) + || !(event.z > coords.zCoord - coords.horizRadius) + || !(event.z < coords.zCoord + coords.horizRadius) + || !(event.y > coords.yCoord - coords.vertRadius) + || !(event.y < coords.yCoord + coords.vertRadius)) { + continue; + } + switch (event.getResult()) { + case DEFAULT -> event.setResult(Result.ALLOW); + case DENY -> event.setResult(Result.DEFAULT); + } + break; } } } @@ -397,11 +366,6 @@ public void onPlayerRespawnEvent(PlayerRespawnEvent event) { @SubscribeEvent public void onLivingJumpEvent(LivingJumpEvent event) { - // event.entityLiving.getEntityAttribute(SharedMonsterAttributes.maxHealth).removeModifier(new - // AttributeModifier(new UUID(493295, 1), "HealthModifier", 2, 0)); - // event.entityLiving.getEntityAttribute(SharedMonsterAttributes.maxHealth).applyModifier(new - // AttributeModifier(new UUID(493295, 1), "HealthModifier", 2, 0)); - if (event.entityLiving.isPotionActive(AlchemicalWizardry.customPotionBoost)) { int i = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionBoost).getAmplifier(); event.entityLiving.motionY += (0.1f) * (2 + i); @@ -426,7 +390,7 @@ public void onEntityDamaged(LivingAttackEvent event) { if (entityAttacked.isPotionActive(AlchemicalWizardry.customPotionReciprocation)) { Entity entityAttacking = event.source.getSourceOfDamage(); - if (entityAttacking != null && entityAttacking instanceof EntityLivingBase) { + if (entityAttacking instanceof EntityLivingBase) { int i = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionReciprocation) .getAmplifier(); float damageRecieve = event.ammount / 2 * (i + 1); @@ -439,30 +403,14 @@ public void onEntityDamaged(LivingAttackEvent event) { Entity entityAttacking = event.source.getSourceOfDamage(); - if (entityAttacking != null && entityAttacking instanceof EntityLivingBase - && !entityAttacking.isImmuneToFire() - && !((EntityLivingBase) entityAttacking).isPotionActive(Potion.fireResistance)) { + if (entityAttacking instanceof EntityLivingBase entity && !entityAttacking.isImmuneToFire() + && !entity.isPotionActive(Potion.fireResistance)) { entityAttacking.attackEntityFrom(DamageSource.inFire, 2 * i + 2); entityAttacking.setFire(3); } } } - // @SubscribeEvent - // public void onFOVUpdate(FOVUpdateEvent event) - // { - // event.setResult(Result.DENY); - // } - // @SubscribeEvent - // public void onPlayerTickEnd(PlayerTickEvent event) - // { - // if(event.type.equals(Type.PLAYER) && event.phase.equals(TickEvent.Phase.END)) - // { - // ObfuscationReflectionHelper.setPrivateValue(PlayerCapabilities.class, event.player.capabilities, - // Float.valueOf(0.1f), new String[]{"walkSpeed", "g", "field_75097_g"}); - // } - // } - @SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event) { EntityLivingBase entityLiving = event.entityLiving; @@ -475,23 +423,18 @@ public void onEntityUpdate(LivingUpdateEvent event) { int yPos = (int) (blockVector.yCoord); int zPos = (int) (blockVector.zCoord); - if (entityLiving instanceof EntityPlayer) { + if (entityLiving instanceof EntityPlayerMP player) { if (!entityLiving.worldObj.isRemote && entityLiving.worldObj.getTotalWorldTime() % 20 == 0) { - if (entityLiving instanceof EntityPlayerMP) { - String ownerName = SoulNetworkHandler.getUsername((EntityPlayer) entityLiving); - NewPacketHandler.INSTANCE.sendTo( - NewPacketHandler.getLPPacket( - SoulNetworkHandler.getCurrentEssence(ownerName), - SoulNetworkHandler.getMaxEssence(ownerName)), - (EntityPlayerMP) entityLiving); - } + String ownerName = SoulNetworkHandler.getUsername(player); + NewPacketHandler.INSTANCE.sendTo( + NewPacketHandler.getLPPacket( + SoulNetworkHandler.getCurrentEssence(ownerName), + SoulNetworkHandler.getMaxEssence(ownerName)), + player); } - // ObfuscationReflectionHelper.setPrivateValue(PlayerCapabilities.class, ((EntityPlayer) - // event.entityLiving).capabilities, 0.1F, "walkSpeed", "g", "field_75097_g"); } - if (entityLiving instanceof EntityPlayer && entityLiving.worldObj.isRemote) { - EntityPlayer entityPlayer = (EntityPlayer) entityLiving; + if (entityLiving instanceof EntityPlayer entityPlayer && entityLiving.worldObj.isRemote) { boolean highStepListed = playersWith1Step.contains(entityPlayer.getDisplayName()); boolean hasHighStep = entityPlayer.isPotionActive(AlchemicalWizardry.customPotionBoost); @@ -523,26 +466,15 @@ public void onEntityUpdate(LivingUpdateEvent event) { if (event.entityLiving.isPotionActive(AlchemicalWizardry.customPotionBoost)) { int i = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionBoost).getAmplifier(); - // if(!entity.isSneaking()) - { + if (!event.entityLiving.isSneaking() && event.entityLiving instanceof EntityPlayer entityPlayer) { float percentIncrease = (i + 1) * 0.05f; + entityPlayer.stepHeight = 1.0f; - // AttributeModifier speedModifier = new AttributeModifier(new UUID(213241, 3), "Potion Boost", - // percentIncrease, 0); - // - // - // event.entityLiving.getEntityAttribute(SharedMonsterAttributes.movementSpeed).applyModifier(speedModifier); - - if (event.entityLiving instanceof EntityPlayer) { - EntityPlayer entityPlayer = (EntityPlayer) event.entityLiving; - entityPlayer.stepHeight = 1.0f; - - if ((entityPlayer.onGround || entityPlayer.capabilities.isFlying) && entityPlayer.moveForward > 0F) - entityPlayer.moveFlying( - 0F, - 1F, - entityPlayer.capabilities.isFlying ? (percentIncrease / 2.0f) : percentIncrease); - } + if ((entityPlayer.onGround || entityPlayer.capabilities.isFlying) && entityPlayer.moveForward > 0F) + entityPlayer.moveFlying( + 0F, + 1F, + entityPlayer.capabilities.isFlying ? (percentIncrease / 2.0f) : percentIncrease); } } @@ -556,30 +488,20 @@ public void onEntityUpdate(LivingUpdateEvent event) { AxisAlignedBB axisalignedbb = AxisAlignedBB .getBoundingBox(posX - 0.5, posY - 0.5, posZ - 0.5, posX + 0.5, posY + 0.5, posZ + 0.5) .expand(d0, d0, d0); - List list = event.entityLiving.worldObj.getEntitiesWithinAABB(Entity.class, axisalignedbb); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - Entity projectile = (Entity) iterator.next(); - - if (projectile == null) { - continue; - } + List list = event.entityLiving.worldObj.getEntitiesWithinAABB(Entity.class, axisalignedbb); + for (Entity projectile : list) { if (!(projectile instanceof IProjectile) || (AlchemicalWizardry.isBotaniaLoaded && isManaBurst(projectile))) { continue; } - Entity throwingEntity = null; - - if (projectile instanceof EntityArrow) { - throwingEntity = ((EntityArrow) projectile).shootingEntity; - } else if (projectile instanceof EnergyBlastProjectile) { - throwingEntity = ((EnergyBlastProjectile) projectile).shootingEntity; - } else if (projectile instanceof EntityThrowable) { - throwingEntity = ((EntityThrowable) projectile).getThrower(); - } + Entity throwingEntity = switch (projectile) { + case EntityArrow entityArrow -> entityArrow.shootingEntity; + case EnergyBlastProjectile energyBlastProjectile -> energyBlastProjectile.shootingEntity; + case EntityThrowable entityThrowable -> entityThrowable.getThrower(); + default -> null; + }; if (throwingEntity != null && throwingEntity.equals(entity)) { continue; @@ -621,15 +543,13 @@ public void onEntityUpdate(LivingUpdateEvent event) { } if (event.entityLiving.isPotionActive(AlchemicalWizardry.customPotionFlight)) { - if (event.entityLiving instanceof EntityPlayer) { - EntityPlayer entityPlayer = (EntityPlayer) event.entityLiving; + if (event.entityLiving instanceof EntityPlayer entityPlayer) { String ownerName = SpellHelper.getUsername(entityPlayer); playerFlightBuff.put(ownerName, true); entityPlayer.capabilities.allowFlying = true; } } else { - if (event.entityLiving instanceof EntityPlayer) { - EntityPlayer entityPlayer = (EntityPlayer) event.entityLiving; + if (event.entityLiving instanceof EntityPlayer entityPlayer) { String ownerName = SpellHelper.getUsername(entityPlayer); if (!playerFlightBuff.containsKey(ownerName)) { @@ -685,12 +605,11 @@ public void onEntityUpdate(LivingUpdateEvent event) { int r = event.entityLiving.getActivePotionEffect(AlchemicalWizardry.customPotionIceCloak).getAmplifier(); int horizRange = r + 1; - int vertRange = 1; if (!entityLiving.worldObj.isRemote) { for (int i = -horizRange; i <= horizRange; i++) { for (int k = -horizRange; k <= horizRange; k++) { - for (int j = -vertRange - 1; j <= vertRange - 1; j++) { + for (int j = -2; j <= 0; j++) { SpellHelper.freezeWaterBlock(entityLiving.worldObj, xPos + i, yPos + j, zPos + k); } } @@ -743,56 +662,6 @@ public void onEntityUpdate(LivingUpdateEvent event) { } } - // @SubscribeEvent(priority = EventPriority.LOWEST) - // public void onTelepose(TeleposeEvent event) { - // - // AlchemicalWizardry.logger.info(event.initialBlock + ":" + event.initialMetadata); - // AlchemicalWizardry.logger.info(event.finalBlock + ":" + event.finalMetadata); - // - // for (int i = 0; i < BloodMagicConfiguration.teleposerBlacklist.length; i++) { - // String[] blockData = BloodMagicConfiguration.teleposerBlacklist[i].split(":"); - // - // // If the block follows full syntax: modid:blockname:meta - // if (blockData.length == 3) { - // - // Block block = GameRegistry.findBlock(blockData[0], blockData[1]); - // int meta; - // - // // Check if it's an int, if so, parse it. If not, set meta to 0 to avoid crashing. - // if (isInteger(blockData[2])) - // meta = Integer.parseInt(blockData[2]); - // else if (blockData[2].equals("*")) - // meta = OreDictionary.WILDCARD_VALUE; - // else - // meta = 0; - // - // AlchemicalWizardry.logger.info(block + ":" + meta); - // - // if (block != null) { - // if ((block == event.initialBlock || block == event.finalBlock) && (meta == event.initialMetadata || meta == - // event.finalMetadata || meta == OreDictionary.WILDCARD_VALUE)) { - // event.setCanceled(true); - // return; - // } - // } - // - // // If the block uses shorthand syntax: modid:blockname - // } else if (blockData.length == 2) { - // - // Block block = GameRegistry.findBlock(blockData[0], blockData[1]); - // int meta = 0; - // - // if (block != null) { - // if ((block == event.initialBlock && (meta == event.initialMetadata || meta == OreDictionary.WILDCARD_VALUE)) - // || (block == event.finalBlock && (meta == event.finalMetadata || meta == OreDictionary.WILDCARD_VALUE))) { - // event.setCanceled(true); - // return; - // } - // } - // } - // } - // } - @SubscribeEvent public void onTelepose(TeleposeEvent event) { BlockStack initialBlock = new BlockStack(event.initialBlock, event.initialMetadata); @@ -806,13 +675,11 @@ public void onTelepose(TeleposeEvent event) { public void onEntityDeath(LivingDeathEvent event) { EntityLivingBase entityLiving = event.entityLiving; - if (entityLiving instanceof IDemon && event.source.getEntity() instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.source.getEntity(); + if (entityLiving instanceof IDemon && event.source.getEntity() instanceof EntityPlayer player) { player.addStat(ModAchievements.demonSpawn, 1); } - if (entityLiving instanceof IHoardDemon && event.source.getEntity() instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.source.getEntity(); + if (entityLiving instanceof IHoardDemon && event.source.getEntity() instanceof EntityPlayer player) { player.addStat(ModAchievements.demons, 1); } @@ -828,9 +695,10 @@ public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { @Optional.Method(modid = "Botania") private boolean isManaBurst(Entity entity) { - if (entity instanceof IManaBurst) { - ItemStack lens = ((IManaBurst) entity).getSourceLens(); - return !(lens.getItemDamage() != 8 && lens.getItemDamage() != 11); - } else return false; + if (entity instanceof IManaBurst burst) { + ItemStack lens = burst.getSourceLens(); + return lens.getItemDamage() == 8 || lens.getItemDamage() == 11; + } + return false; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/ArmourComponent.java b/src/main/java/WayofTime/alchemicalWizardry/common/ArmourComponent.java index dd80448d95..d181a5389f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/ArmourComponent.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/ArmourComponent.java @@ -1,20 +1,3 @@ package WayofTime.alchemicalWizardry.common; -public class ArmourComponent { - - private int xOff; - private int zOff; - - public ArmourComponent(int xOff, int zOff) { - this.xOff = xOff; - this.zOff = zOff; - } - - public int getXOff() { - return xOff; - } - - public int getZOff() { - return zOff; - } -} +public record ArmourComponent(int xOff, int zOff) {} diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/EntityAITargetAggro.java b/src/main/java/WayofTime/alchemicalWizardry/common/EntityAITargetAggro.java index 4cec30e925..43a2697353 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/EntityAITargetAggro.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/EntityAITargetAggro.java @@ -1,16 +1,17 @@ package WayofTime.alchemicalWizardry.common; +import net.minecraft.entity.Entity; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import WayofTime.alchemicalWizardry.common.entity.mob.EntityDemon; public class EntityAITargetAggro extends EntityAINearestAttackableTarget { - private EntityDemon theCreature; + private final EntityDemon theCreature; - public EntityAITargetAggro(EntityDemon par1EntityDemon, Class par2Class, int par3, boolean par4) { - super(par1EntityDemon, par2Class, par3, par4); - this.theCreature = par1EntityDemon; + public EntityAITargetAggro(EntityDemon entityDemon, Class entityClass, int par3, boolean par4) { + super(entityDemon, entityClass, par3, par4); + this.theCreature = entityDemon; } /** diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/EntityAITargetAggroCloaking.java b/src/main/java/WayofTime/alchemicalWizardry/common/EntityAITargetAggroCloaking.java index d9c84d8c89..25ae6e9b86 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/EntityAITargetAggroCloaking.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/EntityAITargetAggroCloaking.java @@ -1,5 +1,6 @@ package WayofTime.alchemicalWizardry.common; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import WayofTime.alchemicalWizardry.AlchemicalWizardry; @@ -9,9 +10,9 @@ public class EntityAITargetAggroCloaking extends EntityAITargetAggro { int cloakLevel; // Level of cloaking that the owner demon is fooled by - public EntityAITargetAggroCloaking(EntityDemon par1EntityDemon, Class par2Class, int par3, boolean par4, - int cloak) { - super(par1EntityDemon, par2Class, par3, par4); + public EntityAITargetAggroCloaking(EntityDemon entityDemon, Class entityClass, int par3, + boolean par4, int cloak) { + super(entityDemon, entityClass, par3, par4); this.cloakLevel = cloak; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/NewPacketHandler.java b/src/main/java/WayofTime/alchemicalWizardry/common/NewPacketHandler.java index 7e1c2d7f3e..de84b3917f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/NewPacketHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/NewPacketHandler.java @@ -592,13 +592,13 @@ public void encodeInto(ChannelHandlerContext ctx, BMMessage msg, ByteBuf target) target.writeInt(list.size()); list.forEach(colourSet -> { - target.writeInt(colourSet.colourRed); - target.writeInt(colourSet.colourGreen); - target.writeInt(colourSet.colourBlue); - target.writeInt(colourSet.colourIntensity); - target.writeInt(colourSet.xCoord); - target.writeInt(colourSet.yCoord); - target.writeInt(colourSet.zCoord); + target.writeInt(colourSet.red()); + target.writeInt(colourSet.green()); + target.writeInt(colourSet.blue()); + target.writeInt(colourSet.intensity()); + target.writeInt(colourSet.x()); + target.writeInt(colourSet.y()); + target.writeInt(colourSet.z()); }); } case 11 -> { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/achievements/AchievementsMod.java b/src/main/java/WayofTime/alchemicalWizardry/common/achievements/AchievementsMod.java index 10aa9a5c01..d63cfafaa6 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/achievements/AchievementsMod.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/achievements/AchievementsMod.java @@ -10,7 +10,7 @@ public class AchievementsMod extends Achievement { - public static List achievements = new ArrayList(); + public static List achievements = new ArrayList<>(); public AchievementsMod(String name, int x, int y, ItemStack icon, Achievement parent) { super("achievement.alchemicalwizardry:" + name, "alchemicalwizardry:" + name, x, y, icon, parent); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/alchemy/CombinedPotionRegistry.java b/src/main/java/WayofTime/alchemicalWizardry/common/alchemy/CombinedPotionRegistry.java index f3b6efe88a..11cf78a14d 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/alchemy/CombinedPotionRegistry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/alchemy/CombinedPotionRegistry.java @@ -12,7 +12,7 @@ public class CombinedPotionRegistry { - public static List potionList = new ArrayList(); + public static List potionList = new ArrayList<>(); public static void registerCombinedPotionRecipe(Potion result, Potion pot1, Potion pot2) { potionList.add(new CombinedPotionComponent(result, pot1, pot2)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/ArmourForge.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/ArmourForge.java index 6d7366c4cd..3abb29099f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/ArmourForge.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/ArmourForge.java @@ -27,10 +27,10 @@ public class ArmourForge extends Block { - public static List helmetList = new ArrayList(); - public static List plateList = new ArrayList(); - public static List leggingsList = new ArrayList(); - public static List bootsList = new ArrayList(); + public static List helmetList = new ArrayList<>(); + public static List plateList = new ArrayList<>(); + public static List leggingsList = new ArrayList<>(); + public static List bootsList = new ArrayList<>(); public ArmourForge() { super(Material.iron); @@ -66,82 +66,53 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p } List list = null; - ItemStack armourPiece = null; - - switch (armourType) { - case 0: + ItemStack armourPiece = switch (armourType) { + case 0 -> { list = plateList; - armourPiece = new ItemStack(ModItems.boundPlate, 1, 0); - break; - - case 1: + yield new ItemStack(ModItems.boundPlate, 1, 0); + } + case 1 -> { list = leggingsList; - armourPiece = new ItemStack(ModItems.boundLeggings, 1, 0); - break; - - case 2: + yield new ItemStack(ModItems.boundLeggings, 1, 0); + } + case 2 -> { list = helmetList; - armourPiece = new ItemStack(ModItems.boundHelmet, 1, 0); - break; - - case 3: + yield new ItemStack(ModItems.boundHelmet, 1, 0); + } + case 3 -> { list = bootsList; - armourPiece = new ItemStack(ModItems.boundBoots, 1, 0); - break; - } + yield new ItemStack(ModItems.boundBoots, 1, 0); + } + default -> null; + }; if (list == null) { return false; } - if (armourPiece == null) { - return false; - } - if (armourPiece.getTagCompound() == null) { armourPiece.setTagCompound(new NBTTagCompound()); } for (ArmourComponent ac : list) { - int xOff = ac.getXOff(); - int zOff = ac.getZOff(); - TileEntity tileEntity; - - switch (direction) { - case 1: - tileEntity = world.getTileEntity(x + xOff, y, z - zOff); - break; - - case 2: - tileEntity = world.getTileEntity(x + zOff, y, z + xOff); - break; - - case 3: - tileEntity = world.getTileEntity(x - xOff, y, z + zOff); - break; - - case 4: - tileEntity = world.getTileEntity(x - zOff, y, z - xOff); - break; - - case 5: - tileEntity = world.getTileEntity(x + xOff, y + zOff, z); - break; - - case 6: - tileEntity = world.getTileEntity(x, y + zOff, z + xOff); - break; - - default: - tileEntity = null; - } - - if (tileEntity instanceof TESocket) { - ItemStack itemStack = ((TESocket) tileEntity).getStackInSlot(0); + int xOff = ac.xOff(); + int zOff = ac.zOff(); + TileEntity tileEntity = switch (direction) { + case 1 -> world.getTileEntity(x + xOff, y, z - zOff); + case 2 -> world.getTileEntity(x + zOff, y, z + xOff); + case 3 -> world.getTileEntity(x - xOff, y, z + zOff); + case 4 -> world.getTileEntity(x - zOff, y, z - xOff); + case 5 -> world.getTileEntity(x + xOff, y + zOff, z); + case 6 -> world.getTileEntity(x, y + zOff, z + xOff); + default -> null; + }; + + if (tileEntity instanceof TESocket socket) { + ItemStack itemStack = socket.getStackInSlot(0); int xCoord = tileEntity.xCoord; int yCoord = tileEntity.yCoord; int zCoord = tileEntity.zCoord; - ((TESocket) tileEntity).setInventorySlotContents(0, null); + socket.setInventorySlotContents(0, null); world.setBlockToAir(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); for (int i = 0; i < 8; i++) { @@ -158,23 +129,21 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p zCoord); } - if (itemStack != null) { + if (itemStack != null && armourPiece.getItem() instanceof BoundArmour armor) { Item item = itemStack.getItem(); if (item instanceof ArmourUpgrade) { - ((BoundArmour) armourPiece.getItem()).hasAddedToInventory(armourPiece, itemStack.copy()); - ((TESocket) tileEntity).setInventorySlotContents(0, null); + armor.hasAddedToInventory(armourPiece, itemStack.copy()); + socket.setInventorySlotContents(0, null); } } } } - if (armourPiece != null) { - int xOff = (world.rand.nextInt(11) - 5); - int zOff = (int) (Math.sqrt(25 - xOff * xOff) * (world.rand.nextInt(2) - 0.5) * 2); - world.addWeatherEffect(new EntityLightningBolt(world, x + xOff, y + 5, z + zOff)); - world.spawnEntityInWorld(new EntityItem(world, x, y + 1, z, armourPiece)); - } + int xOff = (world.rand.nextInt(11) - 5); + int zOff = (int) (Math.sqrt(25 - xOff * xOff) * (world.rand.nextInt(2) - 0.5) * 2); + world.addWeatherEffect(new EntityLightningBolt(world, x + xOff, y + 5, z + zOff)); + world.spawnEntityInWorld(new EntityItem(world, x, y + 1, z, armourPiece)); return true; } @@ -201,79 +170,56 @@ public int getDirectionForArmourType(World world, int x, int y, int z, int armou } public boolean isParadigmValid(int armourType, int direction, World world, int x, int y, int z) { - List list = null; - - switch (armourType) { - case 0: - list = plateList; - break; - - case 1: - list = leggingsList; - break; - - case 2: - list = helmetList; - break; - - case 3: - list = bootsList; - break; - } + List list = switch (armourType) { + case 0 -> plateList; + case 1 -> leggingsList; + case 2 -> helmetList; + case 3 -> bootsList; + default -> null; + }; if (list == null) { return false; } for (ArmourComponent ac : list) { - int xOff = ac.getXOff(); - int zOff = ac.getZOff(); + int xOff = ac.xOff(); + int zOff = ac.zOff(); switch (direction) { - case 1: + case 1 -> { if (!(world.getTileEntity(x + xOff, y, z - zOff) instanceof TESocket)) { return false; } - - break; - - case 2: + } + case 2 -> { if (!(world.getTileEntity(x + zOff, y, z + xOff) instanceof TESocket)) { return false; } - - break; - - case 3: + } + case 3 -> { if (!(world.getTileEntity(x - xOff, y, z + zOff) instanceof TESocket)) { return false; } - - break; - - case 4: + } + case 4 -> { if (!(world.getTileEntity(x - zOff, y, z - xOff) instanceof TESocket)) { return false; } - - break; - - case 5: + } + case 5 -> { if (!(world.getTileEntity(x + xOff, y + zOff, z) instanceof TESocket)) { return false; } - - break; - - case 6: + } + case 6 -> { if (!(world.getTileEntity(x, y + zOff, z + xOff) instanceof TESocket)) { return false; } - - break; - - default: + } + default -> { return false; + } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockAltar.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockAltar.java index 20345bb8af..730738017e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockAltar.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockAltar.java @@ -9,6 +9,7 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -106,57 +107,31 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p return false; } - ItemStack playerItem = player.getCurrentEquippedItem(); - - if (playerItem != null) { - if (playerItem.getItem().equals(ModItems.divinationSigil)) { - if (player.worldObj.isRemote) { - world.markBlockForUpdate(x, y, z); - } else { - tileEntity.sendChatInfoToPlayer(player); - } + ItemStack stack = player.getCurrentEquippedItem(); + if (stack != null && stack.getItem() != null) { + Item item = stack.getItem(); + if (showAltarInfo(world, x, y, z, player, item, tileEntity)) { return true; - } else if (playerItem.getItem().equals(ModItems.itemSeerSigil)) { - if (player.worldObj.isRemote) { - world.markBlockForUpdate(x, y, z); - } else { - tileEntity.sendMoreChatInfoToPlayer(player); - } - - return true; - } else if (playerItem.getItem() instanceof IAltarManipulator) { + } else if (item instanceof IAltarManipulator) { return false; - } else if (playerItem.getItem().equals(ModItems.sigilOfHolding)) { - ItemStack item = SigilOfHolding.getCurrentSigil(playerItem); - - if (item != null && item.getItem().equals(ModItems.divinationSigil)) { - if (player.worldObj.isRemote) { - world.markBlockForUpdate(x, y, z); - } else { - tileEntity.sendChatInfoToPlayer(player); - } - - return true; - } else if (item != null && item.getItem().equals(ModItems.itemSeerSigil)) { - if (player.worldObj.isRemote) { - world.markBlockForUpdate(x, y, z); - } else { - tileEntity.sendMoreChatInfoToPlayer(player); - } - - return true; + } else if (item == ModItems.sigilOfHolding) { + ItemStack sigilStack = SigilOfHolding.getCurrentSigil(stack); + + if (sigilStack != null) { + Item sigilItem = sigilStack.getItem(); + if (showAltarInfo(world, x, y, z, player, sigilItem, tileEntity)) return true; } } } - if (tileEntity.getStackInSlot(0) == null && playerItem != null) { - ItemStack newItem = playerItem.copy(); + if (tileEntity.getStackInSlot(0) == null && stack != null) { + ItemStack newItem = stack.copy(); newItem.stackSize = 1; - --playerItem.stackSize; + --stack.stackSize; tileEntity.setInventorySlotContents(0, newItem); tileEntity.startCycle(); - } else if (tileEntity.getStackInSlot(0) != null && playerItem == null) { + } else if (tileEntity.getStackInSlot(0) != null && stack == null) { player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(0)); tileEntity.setInventorySlotContents(0, null); tileEntity.setActive(); @@ -165,6 +140,22 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p return true; } + private static boolean showAltarInfo(World world, int x, int y, int z, EntityPlayer player, Item sigilItem, + TEAltar tileEntity) { + boolean sightSigil = sigilItem == ModItems.itemSeerSigil; + if (!sightSigil && sigilItem != ModItems.divinationSigil) { + return false; + } + if (world.isRemote) { + world.markBlockForUpdate(x, y, z); + } else if (sightSigil) { + tileEntity.sendMoreChatInfoToPlayer(player); + } else { + tileEntity.sendChatInfoToPlayer(player); + } + return true; + } + @Override public void breakBlock(World world, int x, int y, int z, Block par5, int par6) { dropItems(world, x, y, z); @@ -175,12 +166,10 @@ private void dropItems(World world, int x, int y, int z) { Random rand = new Random(); TileEntity tileEntity = world.getTileEntity(x, y, z); - if (!(tileEntity instanceof IInventory)) { + if (!(tileEntity instanceof IInventory inventory)) { return; } - IInventory inventory = (IInventory) tileEntity; - for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack item = inventory.getStackInSlot(i); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockBelljar.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockBelljar.java index 807fc232af..3aadea90b2 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockBelljar.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockBelljar.java @@ -61,13 +61,14 @@ public void registerBlockIcons(IIconRegister iconRegister) { this.otherIcon = iconRegister.registerIcon("minecraft:glass"); } + @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item item, CreativeTabs tab, List items) { if (this.equals(ModBlocks.blockCrystalBelljar)) { - par3List.add(new ItemStack(par1, 1, 0)); + items.add(new ItemStack(item, 1, 0)); for (Reagent reagent : ReagentRegistry.reagentList.values()) { - ItemStack stack = new ItemStack(par1, 1, 0); + ItemStack stack = new ItemStack(item, 1, 0); NBTTagCompound tag = new NBTTagCompound(); ReagentContainer[] tanks = new ReagentContainer[1]; @@ -76,19 +77,17 @@ public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List NBTTagList tagList = new NBTTagList(); NBTTagCompound savedTag = new NBTTagCompound(); - if (tanks[0] != null) { - tanks[0].writeToNBT(savedTag); - } + tanks[0].writeToNBT(savedTag); tagList.appendTag(savedTag); tag.setTag("reagentTanks", tagList); stack.setTagCompound(tag); - par3List.add(stack); + items.add(stack); } } else { - super.getSubBlocks(par1, par2CreativeTabs, par3List); + super.getSubBlocks(item, tab, items); } } @@ -151,14 +150,14 @@ public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityP @Override public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof TEBellJar) { + if (tile instanceof TEBellJar bellJar) { ItemStack drop = new ItemStack(this); NBTTagCompound tag = new NBTTagCompound(); - ((TEBellJar) tile).writeTankNBT(tag); + bellJar.writeTankNBT(tag); drop.setTagCompound(tag); list.add(drop); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockBloodLightSource.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockBloodLightSource.java index 240616f903..ba60a99e56 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockBloodLightSource.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockBloodLightSource.java @@ -61,11 +61,12 @@ public void randomDisplayTick(World world, int x, int y, int z, Random rand) { } @Override - public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, - List par6List, Entity par7Entity) { + public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB mask, List list, + Entity entity) { this.setBlockBounds(0.40F, 0.40F, 0.40F, 0.60F, 0.60F, 0.60F); } + @Override public int quantityDropped(Random par1Random) { return 0; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockCrucible.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockCrucible.java index 59a142db27..de0a4d82a5 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockCrucible.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockCrucible.java @@ -137,12 +137,10 @@ private void dropItems(World world, int x, int y, int z) { Random rand = new Random(); TileEntity tileEntity = world.getTileEntity(x, y, z); - if (!(tileEntity instanceof IInventory)) { + if (!(tileEntity instanceof IInventory inventory)) { return; } - IInventory inventory = (IInventory) tileEntity; - for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack item = inventory.getStackInSlot(i); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockCrystal.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockCrystal.java index d22bafa0a4..b240d6e773 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockCrystal.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockCrystal.java @@ -35,17 +35,14 @@ public void registerBlockIcons(IIconRegister iconRegister) { this.brickIcon = iconRegister.registerIcon("AlchemicalWizardry:ShardClusterBrick"); } + @Override @SideOnly(Side.CLIENT) - - /** - * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) - */ - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item item, CreativeTabs tab, List items) { if (this.equals(ModBlocks.blockCrystal)) { - par3List.add(new ItemStack(par1, 1, 0)); - par3List.add(new ItemStack(par1, 1, 1)); + items.add(new ItemStack(item, 1, 0)); + items.add(new ItemStack(item, 1, 1)); } else { - super.getSubBlocks(par1, par2CreativeTabs, par3List); + super.getSubBlocks(item, tab, items); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockEnchantmentGlyph.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockEnchantmentGlyph.java index f5da0e5ea8..00117eb7c2 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockEnchantmentGlyph.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockEnchantmentGlyph.java @@ -47,40 +47,33 @@ public IIcon getIcon(int side, int meta) { @Override public int getAdditionalStabilityForFaceCount(World world, int x, int y, int z, int meta, int faceCount) { - switch (meta) { - case 0: - return -faceCount * 10; - case 1: - return -faceCount * 20; - default: - return -faceCount * 20; + if (meta == 0) { + return -faceCount * 10; } + return -faceCount * 20; } @Override public int getEnchantability(World world, int x, int y, int z, int meta) { - switch (meta) { - case 0: - return 1; - default: - return 0; + if (meta == 0) { + return 1; } + return 0; } @Override public int getEnchantmentLevel(World world, int x, int y, int z, int meta) { - switch (meta) { - case 1: - return 1; - default: - return 0; + if (meta == 1) { + return 1; } + return 0; } + @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item item, CreativeTabs tab, List items) { for (int i = 0; i < 2; i++) { - par3List.add(new ItemStack(par1, 1, i)); + items.add(new ItemStack(item, 1, i)); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockMasterStone.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockMasterStone.java index f6476abdac..0864920ecd 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockMasterStone.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockMasterStone.java @@ -69,11 +69,10 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p Item item = playerItem.getItem(); - if (!(item instanceof ActivationCrystal)) { + if (!(item instanceof ActivationCrystal acItem)) { return false; } - ActivationCrystal acItem = (ActivationCrystal) item; // tileEntity.setOwner(acItem.getOwnerName(playerItem)); tileEntity.activateRitual( world, diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockOrientable.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockOrientable.java index e1634bbb75..a300b735b5 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockOrientable.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockOrientable.java @@ -34,8 +34,7 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof TEOrientable) { - TEOrientable newTile = (TEOrientable) tile; + if (tile instanceof TEOrientable newTile) { if (player.isSneaking()) { int nextSide = TEOrientable.getIntForForgeDirection(newTile.getInputDirection()) + 1; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockPedestal.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockPedestal.java index c0549eb103..ff8e9b781c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockPedestal.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockPedestal.java @@ -72,12 +72,10 @@ private void dropItems(World world, int x, int y, int z) { Random rand = new Random(); TileEntity tileEntity = world.getTileEntity(x, y, z); - if (!(tileEntity instanceof IInventory)) { + if (!(tileEntity instanceof IInventory inventory)) { return; } - IInventory inventory = (IInventory) tileEntity; - for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack item = inventory.getStackInSlot(i); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockPlinth.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockPlinth.java index 033ffd0efd..6740a71744 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockPlinth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockPlinth.java @@ -72,12 +72,10 @@ private void dropItems(World world, int x, int y, int z) { Random rand = new Random(); TileEntity tileEntity = world.getTileEntity(x, y, z); - if (!(tileEntity instanceof IInventory)) { + if (!(tileEntity instanceof IInventory inventory)) { return; } - IInventory inventory = (IInventory) tileEntity; - for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack item = inventory.getStackInSlot(i); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSocket.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSocket.java index 656467de49..7fddc4757f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSocket.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSocket.java @@ -77,12 +77,10 @@ private void dropItems(World world, int x, int y, int z) { Random rand = new Random(); TileEntity tileEntity = world.getTileEntity(x, y, z); - if (!(tileEntity instanceof IInventory)) { + if (!(tileEntity instanceof IInventory inventory)) { return; } - IInventory inventory = (IInventory) tileEntity; - for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack item = inventory.getStackInSlot(i); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpectralContainer.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpectralContainer.java index 3a7b90b7e0..dc4e417638 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpectralContainer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpectralContainer.java @@ -41,9 +41,10 @@ public boolean renderAsNormalBlock() { } @Override - public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, - List par6List, Entity par7Entity) {} + public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisAlignedBB, + List mask, Entity entity) {} + @Override public int quantityDropped(Random par1Random) { return 0; } @@ -59,7 +60,7 @@ public boolean isAir(IBlockAccess world, int x, int y, int z) { } @Override - public TileEntity createNewTileEntity(World var1, int var2) { + public TileEntity createNewTileEntity(World world, int meta) { return new TESpectralContainer(); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellEffect.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellEffect.java index f47a2ebfa7..4f40a17647 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellEffect.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellEffect.java @@ -40,14 +40,15 @@ public boolean isOpaqueCube() { return false; } + @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item item, CreativeTabs tab, List items) { if (this.equals(ModBlocks.blockSpellEffect)) { for (int i = 0; i < 4; i++) { - par3List.add(new ItemStack(par1, 1, i)); + items.add(new ItemStack(item, 1, i)); } } else { - super.getSubBlocks(par1, par2CreativeTabs, par3List); + super.getSubBlocks(item, tab, items); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellEnhancement.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellEnhancement.java index ea97bbb9f5..794da766ea 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellEnhancement.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellEnhancement.java @@ -40,14 +40,15 @@ public boolean isOpaqueCube() { return false; } + @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item item, CreativeTabs tab, List items) { if (this.equals(ModBlocks.blockSpellEnhancement)) { for (int i = 0; i < 15; i++) { - par3List.add(new ItemStack(par1, 1, i)); + items.add(new ItemStack(item, 1, i)); } } else { - super.getSubBlocks(par1, par2CreativeTabs, par3List); + super.getSubBlocks(item, tab, items); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellModifier.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellModifier.java index b4fd9f75fe..873733561d 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellModifier.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellModifier.java @@ -25,14 +25,15 @@ public TileEntity createNewTileEntity(World world, int meta) { return new TESpellModifierBlock(); } + @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item item, CreativeTabs tab, List items) { if (this.equals(ModBlocks.blockSpellModifier)) { for (int i = 0; i < 4; i++) { - par3List.add(new ItemStack(par1, 1, i)); + items.add(new ItemStack(item, 1, i)); } } else { - super.getSubBlocks(par1, par2CreativeTabs, par3List); + super.getSubBlocks(item, tab, items); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellParadigm.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellParadigm.java index 08c9b12388..b2c6051b23 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellParadigm.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpellParadigm.java @@ -28,19 +28,16 @@ public TileEntity createNewTileEntity(World world, int meta) { return new TESpellParadigmBlock(); } + @Override @SideOnly(Side.CLIENT) - - /** - * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) - */ - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item item, CreativeTabs tab, List items) { if (this.equals(ModBlocks.blockSpellParadigm)) { - par3List.add(new ItemStack(par1, 1, 0)); - par3List.add(new ItemStack(par1, 1, 1)); - par3List.add(new ItemStack(par1, 1, 2)); - par3List.add(new ItemStack(par1, 1, 3)); + items.add(new ItemStack(item, 1, 0)); + items.add(new ItemStack(item, 1, 1)); + items.add(new ItemStack(item, 1, 2)); + items.add(new ItemStack(item, 1, 3)); } else { - super.getSubBlocks(par1, par2CreativeTabs, par3List); + super.getSubBlocks(item, tab, items); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockStabilityGlyph.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockStabilityGlyph.java index 12c3ec715f..15f11be0b9 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockStabilityGlyph.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockStabilityGlyph.java @@ -33,18 +33,17 @@ public void registerBlockIcons(IIconRegister iconRegister) { @Override public int getAdditionalStabilityForFaceCount(World world, int x, int y, int z, int meta, int faceCount) { - switch (meta) { - case 0: - return faceCount * 2; - default: - return faceCount; + if (meta == 0) { + return faceCount * 2; } + return faceCount; } + @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item item, CreativeTabs tab, List items) { for (int i = 0; i < 1; i++) { - par3List.add(new ItemStack(par1, 1, i)); + items.add(new ItemStack(item, 1, i)); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockWritingTable.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockWritingTable.java index 89f6274534..ac568ca5a9 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockWritingTable.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockWritingTable.java @@ -62,12 +62,10 @@ private void dropItems(World world, int x, int y, int z) { Random rand = new Random(); TileEntity tileEntity = world.getTileEntity(x, y, z); - if (!(tileEntity instanceof IInventory)) { + if (!(tileEntity instanceof IInventory inventory)) { return; } - IInventory inventory = (IInventory) tileEntity; - for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack item = inventory.getStackInSlot(i); @@ -122,14 +120,15 @@ public boolean hasTileEntity() { } @Override - public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, - List par6List, Entity par7Entity) { + public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB mask, List list, + Entity entity) { this.setBlockBounds(0.4375F, 0.0F, 0.4375F, 0.5625F, 0.9375F, 0.5625F); - super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); + super.addCollisionBoxesToList(world, x, y, z, mask, list, entity); this.setBlockBoundsForItemRender(); - super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); + super.addCollisionBoxesToList(world, x, y, z, mask, list, entity); } + @Override public void setBlockBoundsForItemRender() { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/BloodRune.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/BloodRune.java index f2db6743ad..a09849ac3c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/BloodRune.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/BloodRune.java @@ -57,48 +57,26 @@ public void registerBlockIcons(IIconRegister iconRegister) { } public int getRuneEffect(int metaData) { - switch (metaData) { - case 0: - return 0; - - case 1: // Altar Capacity rune - return 5; - - case 2: // Filling/emptying rune - return 6; - - case 3: // Orb Capacity rune - return 7; - - case 4: // Better Capacity rune - return 8; - - case 5: // Acceleration rune - return 9; - - case 6: // Quickness Rune - return 10; - } - - return 0; + return switch (metaData) { + case 1 -> 5; // Altar Capacity rune + case 2 -> 6; // Filling/emptying rune + case 3 -> 7; // Orb Capacity rune + case 4 -> 8; // Better Capacity rune + case 5 -> 9; // Acceleration rune + case 6 -> 10; // Quickness Rune + default -> 0; + }; } + @Override @SideOnly(Side.CLIENT) - - /** - * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) - */ - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item item, CreativeTabs tab, List items) { if (this.equals(ModBlocks.bloodRune)) { - par3List.add(new ItemStack(par1, 1, 0)); - par3List.add(new ItemStack(par1, 1, 1)); - par3List.add(new ItemStack(par1, 1, 2)); - par3List.add(new ItemStack(par1, 1, 3)); - par3List.add(new ItemStack(par1, 1, 4)); - par3List.add(new ItemStack(par1, 1, 5)); - par3List.add(new ItemStack(par1, 1, 6)); + for (int i = 0; i < 7; i++) { + items.add(new ItemStack(item, 1, i)); + } } else { - super.getSubBlocks(par1, par2CreativeTabs, par3List); + super.getSubBlocks(item, tab, items); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/MimicBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/MimicBlock.java index f46d29300d..6fb4edf4a8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/MimicBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/MimicBlock.java @@ -9,7 +9,6 @@ import net.minecraft.client.particle.EntityDiggingFX; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; @@ -29,23 +28,22 @@ public MimicBlock() { setHardness(2.0F); setResistance(5.0F); this.setBlockName("blockMimic"); - // this.setBlockBounds(0, 0, 0, 0, 0, 0); } @Override @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { TileEntity TE = world.getTileEntity(x, y, z); - if (!(TE instanceof TEMimicBlock)) { + if (!(TE instanceof TEMimicBlock mimic)) { return true; } - TEMimicBlock mimic = (TEMimicBlock) TE; Block block = mimic.getBlock(); return block == null || block.shouldSideBeRendered(world, x, y, z, side); } + @Override @SideOnly(Side.CLIENT) public int getRenderBlockPass() { return 1; @@ -58,9 +56,6 @@ public boolean canCollideCheck(int meta, boolean bool) { @SideOnly(Side.CLIENT) @Override - /** - * Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side - */ public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { TileEntity TE = blockAccess.getTileEntity(x, y, z); TEMimicBlock mimic = (TEMimicBlock) TE; @@ -70,6 +65,7 @@ public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { return block != null ? block.getIcon(side, meta) : this.blockIcon; } + @Override public boolean isOpaqueCube() { return false; } @@ -105,53 +101,38 @@ public boolean isBlockSolid(IBlockAccess world, int x, int y, int z, int meta) { @Override public boolean addHitEffects(World world, MovingObjectPosition target, EffectRenderer effectRenderer) { - TileEntity tile = world.getTileEntity(target.blockX, target.blockY, target.blockZ); - - TEMimicBlock TE = (TEMimicBlock) tile; - - if (TE != null) { - Block block = TE.getBlock(); + TEMimicBlock tile = (TEMimicBlock) world.getTileEntity(target.blockX, target.blockY, target.blockZ); + if (tile == null) { + return super.addHitEffects(world, target, effectRenderer); + } + Block block = tile.getBlock(); - double xOffset = target.blockX - + world.rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - 0.1F * 2.0F) - + 0.1F - + block.getBlockBoundsMinX(); - double yOffset = target.blockY - + world.rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - 0.1F * 2.0F) - + 0.1F - + block.getBlockBoundsMinY(); - double zOffset = target.blockZ - + world.rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - 0.1F * 2.0F) - + 0.1F - + block.getBlockBoundsMinZ(); - - switch (target.sideHit) { - case 0: - yOffset = target.blockY + block.getBlockBoundsMinY() - 0.1D; - break; - case 1: - yOffset = target.blockY + block.getBlockBoundsMaxY() + 0.1D; - break; - case 2: - zOffset = target.blockZ + block.getBlockBoundsMinZ() - 0.1D; - break; - case 3: - zOffset = target.blockZ + block.getBlockBoundsMaxZ() + 0.1D; - break; - case 4: - xOffset = target.blockX + block.getBlockBoundsMinX() - 0.1D; - break; - case 5: - xOffset = target.blockX + block.getBlockBoundsMaxX() + 0.1D; - break; - } + double xOffset = target.blockX + + world.rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - 0.1F * 2.0F) + + 0.1F + + block.getBlockBoundsMinX(); + double yOffset = target.blockY + + world.rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - 0.1F * 2.0F) + + 0.1F + + block.getBlockBoundsMinY(); + double zOffset = target.blockZ + + world.rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - 0.1F * 2.0F) + + 0.1F + + block.getBlockBoundsMinZ(); + + switch (target.sideHit) { + case 0 -> yOffset = target.blockY + block.getBlockBoundsMinY() - 0.1D; + case 1 -> yOffset = target.blockY + block.getBlockBoundsMaxY() + 0.1D; + case 2 -> zOffset = target.blockZ + block.getBlockBoundsMinZ() - 0.1D; + case 3 -> zOffset = target.blockZ + block.getBlockBoundsMaxZ() + 0.1D; + case 4 -> xOffset = target.blockX + block.getBlockBoundsMinX() - 0.1D; + case 5 -> xOffset = target.blockX + block.getBlockBoundsMaxX() + 0.1D; + } - MimicBlock.addHitEffect(TE, target, xOffset, yOffset, zOffset, null, effectRenderer); + MimicBlock.addHitEffect(tile, target, xOffset, yOffset, zOffset, effectRenderer); - return true; - } + return true; - return super.addHitEffects(world, target, effectRenderer); } @Override @@ -179,9 +160,9 @@ public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z) { @Override public void velocityToAddToEntity(World world, int x, int y, int z, Entity entity, Vec3 vec) { - TEMimicBlock TE = (TEMimicBlock) world.getTileEntity(x, y, z); - if (TE != null) { - Block block = TE.getBlock(); + TEMimicBlock tile = (TEMimicBlock) world.getTileEntity(x, y, z); + if (tile != null) { + Block block = tile.getBlock(); if (block != null) { block.velocityToAddToEntity(world, x, y, z, entity, vec); } @@ -189,7 +170,7 @@ public void velocityToAddToEntity(World world, int x, int y, int z, Entity entit } public static void addHitEffect(TEMimicBlock TE, MovingObjectPosition target, double x, double y, double z, - ItemStack itemStack, EffectRenderer effectRenderer) { + EffectRenderer effectRenderer) { EntityDiggingFX particle = new EntityDiggingFX( TE.getWorldObj(), x, @@ -207,12 +188,12 @@ public static void addHitEffect(TEMimicBlock TE, MovingObjectPosition target, do @Override public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { - TEMimicBlock TE = (TEMimicBlock) world.getTileEntity(x, y, z); - if (TE != null) { - if (TE.getBlockEffectWhileInside(entity, x, y, z)) { + TEMimicBlock tile = (TEMimicBlock) world.getTileEntity(x, y, z); + if (tile != null) { + if (tile.getBlockEffectWhileInside(entity, x, y, z)) { return; } else { - Block block = TE.getBlock(); + Block block = tile.getBlock(); if (block != null) { block.onEntityCollidedWithBlock(world, x, y, z, entity); return; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/block/SpectralBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/block/SpectralBlock.java index e81b2b182d..bfae405733 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/block/SpectralBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/block/SpectralBlock.java @@ -42,6 +42,7 @@ public int quantityDropped(Random par1Random) { return 0; } + @Override @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { @@ -58,10 +59,10 @@ public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, i return false; } - return block != this - && super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); + return super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); } + @Override @SideOnly(Side.CLIENT) /** * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/AltarComponent.java b/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/AltarComponent.java index cdb6cb9c77..a957de6452 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/AltarComponent.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/AltarComponent.java @@ -1,6 +1,5 @@ package WayofTime.alchemicalWizardry.common.bloodAltarUpgrade; -import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; @@ -9,77 +8,28 @@ import WayofTime.alchemicalWizardry.api.BlockStack; -public class AltarComponent { - - private final int x, y, z; - private final List validBlocks; - - private final boolean isBloodRune, isUpgradeSlot; - - public AltarComponent(int x, int y, int z, Block block, int metadata, boolean isBloodRune, boolean isUpgradeSlot) { - this.x = x; - this.y = y; - this.z = z; - this.validBlocks = new ArrayList<>(); - this.validBlocks.add(new BlockStack(block, metadata)); - this.isBloodRune = isBloodRune; - this.isUpgradeSlot = isUpgradeSlot; - } - - public AltarComponent(int x, int y, int z, List validBlocks, boolean isBloodRune, - boolean isUpgradeSlot) { - this.x = x; - this.y = y; - this.z = z; - this.validBlocks = validBlocks; - this.isBloodRune = isBloodRune; - this.isUpgradeSlot = isUpgradeSlot; - } - - public int getX() { - return x; - } - - public int getY() { - return y; - } - - public int getZ() { - return z; - } +public record AltarComponent(int x, int y, int z, List validBlocks, boolean isBloodRune, + boolean isUpgradeSlot) { public Block getBlock() { if (anyBlockMatches()) { return Blocks.air; } - return validBlocks.get(0).getBlock(); + return validBlocks.getFirst().block(); } public int getMetadata() { if (anyBlockMatches()) { return OreDictionary.WILDCARD_VALUE; } - return validBlocks.get(0).getMeta(); - } - - public boolean isBloodRune() { - return isBloodRune; - } - - public boolean isUpgradeSlot() { - return isUpgradeSlot; - } - - public List getValidBlocks() { - return validBlocks; + return validBlocks.getFirst().meta(); } public boolean matches(Block block, int meta) { if (anyBlockMatches()) return true; for (BlockStack pair : validBlocks) { - if (pair.getBlock() == block - && (pair.getMeta() == meta || pair.getMeta() == OreDictionary.WILDCARD_VALUE)) { + if (pair.block() == block && (pair.meta() == meta || pair.meta() == OreDictionary.WILDCARD_VALUE)) { return true; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/AltarUpgradeComponent.java b/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/AltarUpgradeComponent.java index 3d5b59e15f..5f47cc893f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/AltarUpgradeComponent.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/AltarUpgradeComponent.java @@ -2,29 +2,16 @@ public class AltarUpgradeComponent { - private int speedUpgrades; - private int efficiencyUpgrades; - private int sacrificeUpgrades; - private int selfSacrificeUpgrades; - private int displacementUpgrades; - private int altarCapacitiveUpgrades; - private int orbCapacitiveUpgrades; - private int betterCapacitiveUpgrades; - private int accelerationUpgrades; - private int quicknessUpgrades; - - public AltarUpgradeComponent() { - speedUpgrades = 0; - efficiencyUpgrades = 0; - sacrificeUpgrades = 0; - selfSacrificeUpgrades = 0; - displacementUpgrades = 0; - altarCapacitiveUpgrades = 0; - orbCapacitiveUpgrades = 0; - betterCapacitiveUpgrades = 0; - accelerationUpgrades = 0; - quicknessUpgrades = 0; - } + private int speedUpgrades = 0; + private int efficiencyUpgrades = 0; + private int sacrificeUpgrades = 0; + private int selfSacrificeUpgrades = 0; + private int displacementUpgrades = 0; + private int altarCapacitiveUpgrades = 0; + private int orbCapacitiveUpgrades = 0; + private int betterCapacitiveUpgrades = 0; + private int accelerationUpgrades = 0; + private int quicknessUpgrades = 0; public void addSpeedUpgrade() { speedUpgrades++; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/CompatChecks.java b/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/CompatChecks.java index 75a9513ffd..6db3846ddb 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/CompatChecks.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/CompatChecks.java @@ -9,12 +9,11 @@ public class CompatChecks { public static boolean checkChiselBlock(BlockStack blockStack, String groupName) { - if (blockStack.getBlock() == null) return false; + if (blockStack.block() == null) return false; - ICarvingGroup group = CarvingUtils.getChiselRegistry().getGroup(blockStack.getBlock(), blockStack.getMeta()); + ICarvingGroup group = CarvingUtils.getChiselRegistry().getGroup(blockStack.block(), blockStack.meta()); if (group != null) { - String check = CarvingUtils.getChiselRegistry().getGroup(blockStack.getBlock(), blockStack.getMeta()) - .getName(); + String check = CarvingUtils.getChiselRegistry().getGroup(blockStack.block(), blockStack.meta()).getName(); if (Strings.isNullOrEmpty(check)) return false; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/UpgradedAltars.java b/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/UpgradedAltars.java index e5d5785858..c382710274 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/UpgradedAltars.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/bloodAltarUpgrade/UpgradedAltars.java @@ -58,9 +58,9 @@ private static List getRuneOverrides(int altarTier) { private static boolean checkAltarComponent(AltarComponent altarComponent, IBlockAccess world, int x, int y, int z, int altarTier) { - int compX = x + altarComponent.getX(); - int compY = y + altarComponent.getY(); - int compZ = z + altarComponent.getZ(); + int compX = x + altarComponent.x(); + int compY = y + altarComponent.y(); + int compZ = z + altarComponent.z(); if (altarComponent.anyBlockMatches()) { return !world.isAirBlock(compX, compY, compZ); } @@ -77,7 +77,7 @@ private static boolean checkAltarComponent(AltarComponent altarComponent, IBlock } for (BlockStack rune : runes) { - if (altarComponent.isUpgradeSlot() ? block == rune.getBlock() && meta == rune.getMeta() + if (altarComponent.isUpgradeSlot() ? block == rune.block() && meta == rune.meta() : altarComponent.matches(block, meta)) { return true; } @@ -101,10 +101,9 @@ public static AltarUpgradeComponent getUpgrades(World world, int x, int y, int z continue; } - Block block = world - .getBlock(x + altarComponent.getX(), y + altarComponent.getY(), z + altarComponent.getZ()); + Block block = world.getBlock(x + altarComponent.x(), y + altarComponent.y(), z + altarComponent.z()); int metadata = world - .getBlockMetadata(x + altarComponent.getX(), y + altarComponent.getY(), z + altarComponent.getZ()); + .getBlockMetadata(x + altarComponent.x(), y + altarComponent.y(), z + altarComponent.z()); BlockStack blockStack = new BlockStack(block, metadata); switch (runes.indexOf(blockStack)) { case 1 -> upgrades.addSpeedUpgrade(); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/book/BloodMagicGuide.java b/src/main/java/WayofTime/alchemicalWizardry/common/book/BloodMagicGuide.java index bab434e960..9ca0db83c4 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/book/BloodMagicGuide.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/book/BloodMagicGuide.java @@ -30,7 +30,7 @@ public class BloodMagicGuide { public static Book bloodMagicGuide; - public static List categories = new ArrayList(); + public static List categories = new ArrayList<>(); public static void registerGuide() { registerArchitectBook(); @@ -56,13 +56,13 @@ public static PageIRecipe getOrbPageForRecipe(IRecipe recipe) { } public static void registerArchitectBook() { - List entries = new ArrayList(); + List entries = new ArrayList<>(); - ArrayList introPages = new ArrayList(); + ArrayList introPages = new ArrayList<>(); introPages.addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.intro"))); entries.add(new EntryUniText(introPages, "guide.BloodMagic.entryName.architect.intro")); - ArrayList bloodAltarPages = new ArrayList(); + ArrayList bloodAltarPages = new ArrayList<>(); bloodAltarPages.add(new PageIRecipe(RecipeHolder.bloodAltarRecipe)); bloodAltarPages.add(new PageIRecipe(RecipeHolder.knifeRecipe)); bloodAltarPages.addAll( @@ -72,24 +72,24 @@ public static void registerArchitectBook() { PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.bloodAltar.2"))); entries.add(new EntryUniText(bloodAltarPages, "guide.BloodMagic.entryName.architect.bloodAltar")); - ArrayList soulNetworkPages = new ArrayList(); + ArrayList soulNetworkPages = new ArrayList<>(); soulNetworkPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.soulNetwork"))); entries.add(new EntryUniText(soulNetworkPages, "guide.BloodMagic.entryName.architect.soulNetwork")); - ArrayList blankSlatePages = new ArrayList(); + ArrayList blankSlatePages = new ArrayList<>(); blankSlatePages.add(new PageAltarRecipe(RecipeHolder.blankSlateRecipe)); blankSlatePages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.blankSlate"))); entries.add(new EntryUniText(blankSlatePages, "guide.BloodMagic.entryName.architect.blankSlate")); - ArrayList divinationSigilPages = new ArrayList(); + ArrayList divinationSigilPages = new ArrayList<>(); divinationSigilPages.add(getOrbPageForRecipe(RecipeHolder.divinationSigilRecipe)); divinationSigilPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.divination"))); entries.add(new EntryUniText(divinationSigilPages, "guide.BloodMagic.entryName.architect.divination")); - ArrayList waterSigilPages = new ArrayList(); + ArrayList waterSigilPages = new ArrayList<>(); waterSigilPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.waterSigil.1"))); waterSigilPages.add(getOrbPageForRecipe(RecipeHolder.waterSigilRecipe)); @@ -97,94 +97,94 @@ public static void registerArchitectBook() { PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.waterSigil.2"))); entries.add(new EntryUniText(waterSigilPages, "guide.BloodMagic.entryName.architect.waterSigil")); - ArrayList lavaCrystalPages = new ArrayList(); + ArrayList lavaCrystalPages = new ArrayList<>(); lavaCrystalPages.add(getOrbPageForRecipe(RecipeHolder.lavaCrystalRecipe)); lavaCrystalPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.lavaCrystal"))); entries.add(new EntryUniText(lavaCrystalPages, "guide.BloodMagic.entryName.architect.lavaCrystal")); - ArrayList hellHarvestPages = new ArrayList(); + ArrayList hellHarvestPages = new ArrayList<>(); hellHarvestPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.hellHarvest"))); entries.add(new EntryUniText(hellHarvestPages, "guide.BloodMagic.entryName.architect.hellHarvest")); - ArrayList lavaSigilPages = new ArrayList(); + ArrayList lavaSigilPages = new ArrayList<>(); lavaSigilPages.add(new PageIRecipe(RecipeHolder.lavaSigilRecipe)); lavaSigilPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.lavaSigil"))); entries.add(new EntryUniText(lavaSigilPages, "guide.BloodMagic.entryName.architect.lavaSigil")); - ArrayList blankRunePages = new ArrayList(); + ArrayList blankRunePages = new ArrayList<>(); blankRunePages.add(getOrbPageForRecipe(RecipeHolder.blankRuneRecipe)); blankRunePages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.blankRunes.1"))); blankRunePages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/altars/T2.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/altars/T2.png"), true)); blankRunePages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.blankRunes.2"))); entries.add(new EntryUniText(blankRunePages, "guide.BloodMagic.entryName.architect.blankRunes")); - ArrayList speedRunePages = new ArrayList(); + ArrayList speedRunePages = new ArrayList<>(); speedRunePages.add(new PageIRecipe(RecipeHolder.speedRuneRecipe)); speedRunePages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.speedRunes"))); entries.add(new EntryUniText(speedRunePages, "guide.BloodMagic.entryName.architect.speedRunes")); - ArrayList apprenticeOrbPages = new ArrayList(); + ArrayList apprenticeOrbPages = new ArrayList<>(); apprenticeOrbPages.add(new PageAltarRecipe(RecipeHolder.apprenticeBloodOrbRecipe)); apprenticeOrbPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.apprenticeOrb"))); entries.add(new EntryUniText(apprenticeOrbPages, "guide.BloodMagic.entryName.architect.apprenticeOrb")); - ArrayList voidSigilPages = new ArrayList(); + ArrayList voidSigilPages = new ArrayList<>(); voidSigilPages.add(getOrbPageForRecipe(RecipeHolder.voidSigilRecipe)); voidSigilPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.voidSigil"))); entries.add(new EntryUniText(voidSigilPages, "guide.BloodMagic.entryName.architect.voidSigil")); - ArrayList airSigilPages = new ArrayList(); + ArrayList airSigilPages = new ArrayList<>(); airSigilPages.add(getOrbPageForRecipe(RecipeHolder.airSigilRecipe)); airSigilPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.airSigil"))); entries.add(new EntryUniText(airSigilPages, "guide.BloodMagic.entryName.architect.airSigil")); - ArrayList sightSigilPages = new ArrayList(); + ArrayList sightSigilPages = new ArrayList<>(); sightSigilPages.add(getOrbPageForRecipe(RecipeHolder.sightSigilRecipe)); sightSigilPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.sightSigil"))); entries.add(new EntryUniText(sightSigilPages, "guide.BloodMagic.entryName.architect.sightSigil")); - ArrayList advancedAltarPages = new ArrayList(); + ArrayList advancedAltarPages = new ArrayList<>(); advancedAltarPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.advancedAltar"))); entries.add(new EntryUniText(advancedAltarPages, "guide.BloodMagic.entryName.architect.advancedAltar")); - ArrayList fastMinerPages = new ArrayList(); + ArrayList fastMinerPages = new ArrayList<>(); fastMinerPages.add(getOrbPageForRecipe(RecipeHolder.fastMinerRecipe)); fastMinerPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.fastMiner"))); entries.add(new EntryUniText(fastMinerPages, "guide.BloodMagic.entryName.architect.fastMiner")); - ArrayList soulFrayPages = new ArrayList(); + ArrayList soulFrayPages = new ArrayList<>(); soulFrayPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.soulFray"))); entries.add(new EntryUniText(soulFrayPages, "guide.BloodMagic.entryName.architect.soulFray")); - ArrayList greenGrovePages = new ArrayList(); + ArrayList greenGrovePages = new ArrayList<>(); greenGrovePages.add(getOrbPageForRecipe(RecipeHolder.greenGroveRecipe)); greenGrovePages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.greenGrove"))); entries.add(new EntryUniText(greenGrovePages, "guide.BloodMagic.entryName.architect.greenGrove")); - ArrayList daggerPages = new ArrayList(); + ArrayList daggerPages = new ArrayList<>(); daggerPages.add(new PageAltarRecipe(RecipeHolder.daggerRecipe)); daggerPages.addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.dagger"))); entries.add(new EntryUniText(daggerPages, "guide.BloodMagic.entryName.architect.dagger")); - ArrayList sacrificePages = new ArrayList(); + ArrayList sacrificePages = new ArrayList<>(); sacrificePages.add(getOrbPageForRecipe(RecipeHolder.selfSacrificeRuneRecipe)); sacrificePages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.sacrifice.1"))); @@ -193,33 +193,33 @@ public static void registerArchitectBook() { PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.sacrifice.2"))); entries.add(new EntryUniText(sacrificePages, "guide.BloodMagic.entryName.architect.sacrifice")); - ArrayList bloodPackPages = new ArrayList(); + ArrayList bloodPackPages = new ArrayList<>(); bloodPackPages.add(new PageIRecipe(RecipeHolder.bloodPackRecipe)); bloodPackPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.bloodPack"))); entries.add(new EntryUniText(bloodPackPages, "guide.BloodMagic.entryName.architect.bloodPack")); - ArrayList fivePeoplePages = new ArrayList(); + ArrayList fivePeoplePages = new ArrayList<>(); fivePeoplePages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.fivePeople"))); entries.add(new EntryUniText(fivePeoplePages, "guide.BloodMagic.entryName.architect.fivePeople")); - ArrayList tier3Pages = new ArrayList(); + ArrayList tier3Pages = new ArrayList<>(); tier3Pages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/altars/T3.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/altars/T3.png"), true)); tier3Pages.addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.tier3"))); entries.add(new EntryUniText(tier3Pages, "guide.BloodMagic.entryName.architect.tier3")); - ArrayList magicianOrbPages = new ArrayList(); + ArrayList magicianOrbPages = new ArrayList<>(); magicianOrbPages.add(new PageAltarRecipe(RecipeHolder.magicianBloodOrbRecipe)); magicianOrbPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.magicianOrb"))); entries.add(new EntryUniText(magicianOrbPages, "guide.BloodMagic.entryName.architect.magicianOrb")); - ArrayList newRunePages = new ArrayList(); + ArrayList newRunePages = new ArrayList<>(); newRunePages.add(getOrbPageForRecipe(RecipeHolder.capacityRuneRecipe)); newRunePages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.newRune.1"))); @@ -228,44 +228,44 @@ public static void registerArchitectBook() { .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.newRune.2"))); entries.add(new EntryUniText(newRunePages, "guide.BloodMagic.entryName.architect.newRune")); - ArrayList magnetismPages = new ArrayList(); + ArrayList magnetismPages = new ArrayList<>(); magnetismPages.add(getOrbPageForRecipe(RecipeHolder.magnetismSigilRecipe)); magnetismPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.magnetism"))); entries.add(new EntryUniText(magnetismPages, "guide.BloodMagic.entryName.architect.magnetism")); - ArrayList phantomBridgePages = new ArrayList(); + ArrayList phantomBridgePages = new ArrayList<>(); phantomBridgePages.add(getOrbPageForRecipe(RecipeHolder.phantomBridgeRecipe)); phantomBridgePages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.phantomBridge"))); entries.add(new EntryUniText(phantomBridgePages, "guide.BloodMagic.entryName.architect.phantomBridge")); - ArrayList holdingPages = new ArrayList(); + ArrayList holdingPages = new ArrayList<>(); holdingPages.add(getOrbPageForRecipe(RecipeHolder.holdingSigilRecipe)); holdingPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.holding"))); entries.add(new EntryUniText(holdingPages, "guide.BloodMagic.entryName.architect.holding")); - ArrayList elementalAffinityPages = new ArrayList(); + ArrayList elementalAffinityPages = new ArrayList<>(); elementalAffinityPages.add(getOrbPageForRecipe(RecipeHolder.affinitySigilRecipe)); elementalAffinityPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.elementalAffinity"))); entries.add(new EntryUniText(elementalAffinityPages, "guide.BloodMagic.entryName.architect.elementalAffinity")); - ArrayList ritualStonesPages = new ArrayList(); + ArrayList ritualStonesPages = new ArrayList<>(); ritualStonesPages.add(getOrbPageForRecipe(RecipeHolder.ritualStoneRecipe)); ritualStonesPages.add(getOrbPageForRecipe(RecipeHolder.masterStoneRecipe)); ritualStonesPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.ritualStones"))); entries.add(new EntryUniText(ritualStonesPages, "guide.BloodMagic.entryName.architect.ritualStones")); - ArrayList bloodLampPages = new ArrayList(); + ArrayList bloodLampPages = new ArrayList<>(); bloodLampPages.add(getOrbPageForRecipe(RecipeHolder.bloodLampRecipe)); bloodLampPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.bloodLamp"))); entries.add(new EntryUniText(bloodLampPages, "guide.BloodMagic.entryName.architect.bloodLamp")); - ArrayList boundArmourPages = new ArrayList(); + ArrayList boundArmourPages = new ArrayList<>(); boundArmourPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.boundArmour.1"))); boundArmourPages.add(new PageIRecipe(RecipeHolder.emptySocketRecipe)); @@ -276,7 +276,7 @@ public static void registerArchitectBook() { entries.add(new EntryUniText(boundArmourPages, "guide.BloodMagic.entryName.architect.boundArmour")); if (AlchemicalWizardry.isThaumcraftLoaded) { - ArrayList sanguineArmourPages = new ArrayList(); + ArrayList sanguineArmourPages = new ArrayList<>(); sanguineArmourPages.addAll( PageHelper.pagesForLongText( StatCollector.translateToLocal("aw.entries.architect.sanguineArmour"), @@ -284,13 +284,13 @@ public static void registerArchitectBook() { entries.add(new EntryUniText(sanguineArmourPages, "guide.BloodMagic.entryName.architect.sanguineArmour")); } - ArrayList soulSuppressPages = new ArrayList(); + ArrayList soulSuppressPages = new ArrayList<>(); soulSuppressPages.add(new PageIRecipe(RecipeHolder.inhibitorRecipe)); soulSuppressPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.soulSuppress"))); entries.add(new EntryUniText(soulSuppressPages, "guide.BloodMagic.entryName.architect.soulSuppress")); - ArrayList ritualDivinerPages = new ArrayList(); + ArrayList ritualDivinerPages = new ArrayList<>(); ritualDivinerPages.add(new PageIRecipe(RecipeHolder.ritualDiviner1Recipe)); ritualDivinerPages.add(new PageIRecipe(RecipeHolder.ritualDiviner2Recipe)); ritualDivinerPages.add(new PageIRecipe(RecipeHolder.ritualDiviner3Recipe)); @@ -298,140 +298,140 @@ public static void registerArchitectBook() { PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.ritualDiviner"))); entries.add(new EntryUniText(ritualDivinerPages, "guide.BloodMagic.entryName.architect.ritualDiviner")); - ArrayList bloodShardPages = new ArrayList(); + ArrayList bloodShardPages = new ArrayList<>(); bloodShardPages.addAll( PageHelper.pagesForLongText( StatCollector.translateToLocal("aw.entries.architect.bloodShard"), new ItemStack(ModItems.weakBloodShard))); entries.add(new EntryUniText(bloodShardPages, "guide.BloodMagic.entryName.architect.bloodShard")); - ArrayList tier4AltarPages = new ArrayList(); + ArrayList tier4AltarPages = new ArrayList<>(); tier4AltarPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.tier4Altar.1"))); tier4AltarPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/altars/T4.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/altars/T4.png"), true)); tier4AltarPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.tier4Altar.2"))); entries.add(new EntryUniText(tier4AltarPages, "guide.BloodMagic.entryName.architect.tier4Altar")); - ArrayList masterOrbPages = new ArrayList(); + ArrayList masterOrbPages = new ArrayList<>(); masterOrbPages.add(new PageAltarRecipe(RecipeHolder.masterBloodOrbRecipe)); masterOrbPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.masterOrb"))); entries.add(new EntryUniText(masterOrbPages, "guide.BloodMagic.entryName.architect.masterOrb")); - ArrayList whirlwindPages = new ArrayList(); + ArrayList whirlwindPages = new ArrayList<>(); whirlwindPages.add(getOrbPageForRecipe(RecipeHolder.whirlwindSigilRecipe)); whirlwindPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.whirlwind"))); entries.add(new EntryUniText(whirlwindPages, "guide.BloodMagic.entryName.architect.whirlwind")); - ArrayList compressionPages = new ArrayList(); + ArrayList compressionPages = new ArrayList<>(); compressionPages.add(getOrbPageForRecipe(RecipeHolder.compressionSigilRecipe)); compressionPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.compression"))); entries.add(new EntryUniText(compressionPages, "guide.BloodMagic.entryName.architect.compression")); - ArrayList severancePages = new ArrayList(); + ArrayList severancePages = new ArrayList<>(); severancePages.add(getOrbPageForRecipe(RecipeHolder.enderSeveranceSigilRecipe)); severancePages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.severance"))); entries.add(new EntryUniText(severancePages, "guide.BloodMagic.entryName.architect.severance")); - ArrayList teleposerPages = new ArrayList(); + ArrayList teleposerPages = new ArrayList<>(); teleposerPages.add(new PageAltarRecipe(RecipeHolder.teleposerFocusRecipe1)); teleposerPages.add(new PageIRecipe(RecipeHolder.teleposerRecipe)); teleposerPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.teleposer"))); entries.add(new EntryUniText(teleposerPages, "guide.BloodMagic.entryName.architect.teleposer")); - ArrayList suppressionPages = new ArrayList(); + ArrayList suppressionPages = new ArrayList<>(); suppressionPages.add(getOrbPageForRecipe(RecipeHolder.suppressionSigilRecipe)); suppressionPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.suppression"))); entries.add(new EntryUniText(suppressionPages, "guide.BloodMagic.entryName.architect.suppression")); - ArrayList superiorCapacityPages = new ArrayList(); + ArrayList superiorCapacityPages = new ArrayList<>(); superiorCapacityPages.add(getOrbPageForRecipe(RecipeHolder.superiorCapacityRecipe)); superiorCapacityPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.superiorCapacity"))); entries.add(new EntryUniText(superiorCapacityPages, "guide.BloodMagic.entryName.architect.superiorCapacity")); - ArrayList orbRunePages = new ArrayList(); + ArrayList orbRunePages = new ArrayList<>(); orbRunePages.add(getOrbPageForRecipe(RecipeHolder.orbRuneRecipe)); orbRunePages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.orbRune"))); entries.add(new EntryUniText(orbRunePages, "guide.BloodMagic.entryName.architect.orbRune")); - ArrayList fieldTripPages = new ArrayList(); + ArrayList fieldTripPages = new ArrayList<>(); fieldTripPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.fieldTrip"))); entries.add(new EntryUniText(fieldTripPages, "guide.BloodMagic.entryName.architect.fieldTrip")); - ArrayList bindingKeyPages = new ArrayList(); + ArrayList bindingKeyPages = new ArrayList<>(); bindingKeyPages.add(new PageIRecipe(RecipeHolder.keyOfBindingRecipe)); bindingKeyPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.bindingKey"))); entries.add(new EntryUniText(bindingKeyPages, "guide.BloodMagic.entryName.architect.bindingKey")); - ArrayList tier5AltarPages = new ArrayList(); + ArrayList tier5AltarPages = new ArrayList<>(); tier5AltarPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/altars/T5.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/altars/T5.png"), true)); tier5AltarPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.tier5Altar"))); entries.add(new EntryUniText(tier5AltarPages, "guide.BloodMagic.entryName.architect.tier5Altar")); - ArrayList priceOfPowerPages = new ArrayList(); + ArrayList priceOfPowerPages = new ArrayList<>(); priceOfPowerPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.priceOfPower"))); entries.add(new EntryUniText(priceOfPowerPages, "guide.BloodMagic.entryName.architect.priceOfPower")); - ArrayList demonicOrbPages = new ArrayList(); + ArrayList demonicOrbPages = new ArrayList<>(); demonicOrbPages.add(new PageAltarRecipe(RecipeHolder.archmageBloodOrbRecipe)); demonicOrbPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.demonicOrb"))); entries.add(new EntryUniText(demonicOrbPages, "guide.BloodMagic.entryName.architect.demonicOrb")); - ArrayList energyBazookaPages = new ArrayList(); + ArrayList energyBazookaPages = new ArrayList<>(); demonicOrbPages.add(getOrbPageForRecipe(RecipeHolder.energyBazookaRecipe)); energyBazookaPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.energyBazooka"))); entries.add(new EntryUniText(energyBazookaPages, "guide.BloodMagic.entryName.architect.energyBazooka")); - ArrayList accelerationRunePages = new ArrayList(); + ArrayList accelerationRunePages = new ArrayList<>(); demonicOrbPages.add(getOrbPageForRecipe(RecipeHolder.accelerationRuneRecipe)); accelerationRunePages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.accelerationRune"))); entries.add(new EntryUniText(accelerationRunePages, "guide.BloodMagic.entryName.architect.accelerationRune")); - ArrayList quicknessRuneRecipe = new ArrayList(); + ArrayList quicknessRuneRecipe = new ArrayList<>(); demonicOrbPages.add(getOrbPageForRecipe(RecipeHolder.quicknessRuneRecipe)); quicknessRuneRecipe.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.quicknessRune"))); entries.add(new EntryUniText(quicknessRuneRecipe, "guide.BloodMagic.entryName.architect.quicknessRune")); - ArrayList harvestPages = new ArrayList(); + ArrayList harvestPages = new ArrayList<>(); demonicOrbPages.add(getOrbPageForRecipe(RecipeHolder.harvestSigilRecipe)); harvestPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.harvest"))); entries.add(new EntryUniText(harvestPages, "guide.BloodMagic.entryName.architect.harvest")); - ArrayList demonProblemPages = new ArrayList(); + ArrayList demonProblemPages = new ArrayList<>(); demonProblemPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.demonProblem"))); entries.add(new EntryUniText(demonProblemPages, "guide.BloodMagic.entryName.architect.demonProblem")); - ArrayList tier6AltarPages = new ArrayList(); + ArrayList tier6AltarPages = new ArrayList<>(); tier6AltarPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/altars/T6.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/altars/T6.png"), true)); tier6AltarPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.tier6Altar"))); @@ -439,7 +439,7 @@ public static void registerArchitectBook() { tier6AltarPages.add(new PageAltarRecipe(RecipeHolder.transcendentBloodOrbRecipe)); entries.add(new EntryUniText(tier6AltarPages, "guide.BloodMagic.entryName.architect.tier6Altar")); - ArrayList moreThanHumanPages = new ArrayList(); + ArrayList moreThanHumanPages = new ArrayList<>(); moreThanHumanPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.architect.moreThanHuman"))); entries.add(new EntryUniText(moreThanHumanPages, "guide.BloodMagic.entryName.architect.moreThanHuman")); @@ -452,23 +452,23 @@ public static void registerArchitectBook() { } public static void registerRitualBook() { - List entries = new ArrayList(); + List entries = new ArrayList<>(); - // ArrayList testPages = new ArrayList(); + // ArrayList testPages = new ArrayList<>(); // testPages.add(PageRitualMultiBlock.getPageForRitual("AW031Convocation")); // entries.add(new EntryUniText(testPages, "Test page")); - ArrayList introPages = new ArrayList(); + ArrayList introPages = new ArrayList<>(); introPages.addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.intro"))); entries.add(new EntryUniText(introPages, "guide.BloodMagic.entryName.rituals.intro")); - ArrayList weakRitualPages = new ArrayList(); + ArrayList weakRitualPages = new ArrayList<>(); weakRitualPages.add(getOrbPageForRecipe(RecipeHolder.weakRitualStoneRecipe)); weakRitualPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.weakRitual"))); entries.add(new EntryUniText(weakRitualPages, "guide.BloodMagic.entryName.rituals.weakRitual")); - ArrayList ritualsPages = new ArrayList(); + ArrayList ritualsPages = new ArrayList<>(); ritualsPages.add(getOrbPageForRecipe(RecipeHolder.ritualStoneRecipe)); ritualsPages.add(getOrbPageForRecipe(RecipeHolder.masterStoneRecipe)); ritualsPages.add(new PageAltarRecipe(RecipeHolder.waterScribeTool)); @@ -480,147 +480,152 @@ public static void registerRitualBook() { ritualsPages.add(new PageAltarRecipe(RecipeHolder.weakActivationRecipe)); entries.add(new EntryUniText(ritualsPages, "guide.BloodMagic.entryName.rituals.rituals")); - ArrayList waterRitualPages = new ArrayList(); + ArrayList waterRitualPages = new ArrayList<>(); waterRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Water.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Water.png"), true)); waterRitualPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.waterRitual"))); entries.add(new EntryUniText(waterRitualPages, "guide.BloodMagic.entryName.rituals.waterRitual")); - ArrayList lavaRitualPages = new ArrayList(); + ArrayList lavaRitualPages = new ArrayList<>(); lavaRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Lava.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Lava.png"), true)); lavaRitualPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.lavaRitual"))); entries.add(new EntryUniText(lavaRitualPages, "guide.BloodMagic.entryName.rituals.lavaRitual")); - ArrayList groveRitualPages = new ArrayList(); + ArrayList groveRitualPages = new ArrayList<>(); groveRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/GreenGrove.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/GreenGrove.png"), true)); groveRitualPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.groveRitual"))); entries.add(new EntryUniText(groveRitualPages, "guide.BloodMagic.entryName.rituals.groveRitual")); - ArrayList interdictionRitualPages = new ArrayList(); + ArrayList interdictionRitualPages = new ArrayList<>(); interdictionRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Interdiction.png"), + new ResourceLocation( + "alchemicalwizardry", + "textures/misc/screenshots/rituals/Interdiction.png"), true)); interdictionRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.interdictionRitual"))); entries.add(new EntryUniText(interdictionRitualPages, "guide.BloodMagic.entryName.rituals.interdictionRitual")); - ArrayList containmentRitualPages = new ArrayList(); + ArrayList containmentRitualPages = new ArrayList<>(); containmentRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Containment.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Containment.png"), true)); containmentRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.containmentRitual"))); entries.add(new EntryUniText(containmentRitualPages, "guide.BloodMagic.entryName.rituals.containmentRitual")); - ArrayList bindingRitualPages = new ArrayList(); + ArrayList bindingRitualPages = new ArrayList<>(); bindingRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Binding.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Binding.png"), true)); bindingRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.bindingRitual"))); entries.add(new EntryUniText(bindingRitualPages, "guide.BloodMagic.entryName.rituals.bindingRitual")); - ArrayList beastModePages = new ArrayList(); + ArrayList beastModePages = new ArrayList<>(); beastModePages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.beastMode"))); entries.add(new EntryUniText(beastModePages, "guide.BloodMagic.entryName.rituals.beastMode")); - ArrayList unbindingRitualPages = new ArrayList(); + ArrayList unbindingRitualPages = new ArrayList<>(); unbindingRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Unbinding.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Unbinding.png"), true)); unbindingRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.unbindingRitual"))); entries.add(new EntryUniText(unbindingRitualPages, "guide.BloodMagic.entryName.rituals.unbindingRitual")); - ArrayList jumpRitualPages = new ArrayList(); + ArrayList jumpRitualPages = new ArrayList<>(); jumpRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Jump.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Jump.png"), true)); jumpRitualPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.jumpRitual"))); entries.add(new EntryUniText(jumpRitualPages, "guide.BloodMagic.entryName.rituals.jumpRitual")); - ArrayList duskInkPages = new ArrayList(); + ArrayList duskInkPages = new ArrayList<>(); duskInkPages.add(new PageAltarRecipe(RecipeHolder.duskRecipe)); duskInkPages.addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.duskInk"))); entries.add(new EntryUniText(duskInkPages, "guide.BloodMagic.entryName.rituals.duskInk")); - ArrayList magnetismRitualPages = new ArrayList(); + ArrayList magnetismRitualPages = new ArrayList<>(); magnetismRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Magnetism.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Magnetism.png"), true)); magnetismRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.magnetismRitual"))); entries.add(new EntryUniText(magnetismRitualPages, "guide.BloodMagic.entryName.rituals.magnetismRitual")); - ArrayList crusherRitualPages = new ArrayList(); + ArrayList crusherRitualPages = new ArrayList<>(); crusherRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Crusher.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Crusher.png"), true)); crusherRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.crusherRitual"))); entries.add(new EntryUniText(crusherRitualPages, "guide.BloodMagic.entryName.rituals.crusherRitual")); - ArrayList speedRitualPages = new ArrayList(); + ArrayList speedRitualPages = new ArrayList<>(); speedRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Speed.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Speed.png"), true)); speedRitualPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.speedRitual"))); entries.add(new EntryUniText(speedRitualPages, "guide.BloodMagic.entryName.rituals.speedRitual")); - ArrayList shepherdRitualPages = new ArrayList(); + ArrayList shepherdRitualPages = new ArrayList<>(); shepherdRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/AnimalGrowth.png"), + new ResourceLocation( + "alchemicalwizardry", + "textures/misc/screenshots/rituals/AnimalGrowth.png"), true)); shepherdRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.shepherdRitual"))); entries.add(new EntryUniText(shepherdRitualPages, "guide.BloodMagic.entryName.rituals.shepherdRitual")); - ArrayList darkMagicPages = new ArrayList(); + ArrayList darkMagicPages = new ArrayList<>(); darkMagicPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.darkMagic"))); entries.add(new EntryUniText(darkMagicPages, "guide.BloodMagic.entryName.rituals.darkMagic")); - ArrayList knifeAndSufferingRitualPages = new ArrayList(); + ArrayList knifeAndSufferingRitualPages = new ArrayList<>(); knifeAndSufferingRitualPages.add( new PageUnlocImage( "", new ResourceLocation( - "alchemicalwizardry:textures/misc/screenshots/rituals/WellOfSuffering.png"), + "alchemicalwizardry", + "textures/misc/screenshots/rituals/WellOfSuffering.png"), true)); knifeAndSufferingRitualPages.addAll( PageHelper.pagesForLongText( @@ -628,7 +633,9 @@ public static void registerRitualBook() { knifeAndSufferingRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/FeatheredKnife.png"), + new ResourceLocation( + "alchemicalwizardry", + "textures/misc/screenshots/rituals/FeatheredKnife.png"), true)); knifeAndSufferingRitualPages.addAll( PageHelper.pagesForLongText( @@ -638,191 +645,197 @@ public static void registerRitualBook() { knifeAndSufferingRitualPages, "guide.BloodMagic.entryName.rituals.knifeAndSufferingRitual")); - ArrayList regenerationRitualPages = new ArrayList(); + ArrayList regenerationRitualPages = new ArrayList<>(); regenerationRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Regeneration.png"), + new ResourceLocation( + "alchemicalwizardry", + "textures/misc/screenshots/rituals/Regeneration.png"), true)); regenerationRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.regenerationRitual"))); entries.add(new EntryUniText(regenerationRitualPages, "guide.BloodMagic.entryName.rituals.regenerationRitual")); - ArrayList harvestFestivalPages = new ArrayList(); + ArrayList harvestFestivalPages = new ArrayList<>(); harvestFestivalPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.harvestFestival"))); entries.add(new EntryUniText(harvestFestivalPages, "guide.BloodMagic.entryName.rituals.harvestFestival")); - ArrayList thenThereWereFivePages = new ArrayList(); + ArrayList thenThereWereFivePages = new ArrayList<>(); thenThereWereFivePages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.thenThereWereFive"))); entries.add(new EntryUniText(thenThereWereFivePages, "guide.BloodMagic.entryName.rituals.thenThereWereFive")); - ArrayList alchemyRitualPages = new ArrayList(); + ArrayList alchemyRitualPages = new ArrayList<>(); alchemyRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Alchemy.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Alchemy.png"), true)); alchemyRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.alchemyRitual"))); entries.add(new EntryUniText(alchemyRitualPages, "guide.BloodMagic.entryName.rituals.alchemyRitual")); - ArrayList domeRitualPages = new ArrayList(); + ArrayList domeRitualPages = new ArrayList<>(); domeRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Dome.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Dome.png"), true)); domeRitualPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.domeRitual"))); entries.add(new EntryUniText(domeRitualPages, "guide.BloodMagic.entryName.rituals.domeRitual")); - ArrayList awakenedCrystalPages = new ArrayList(); + ArrayList awakenedCrystalPages = new ArrayList<>(); awakenedCrystalPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.awakenedCrystal"))); entries.add(new EntryUniText(awakenedCrystalPages, "guide.BloodMagic.entryName.rituals.awakenedCrystal")); - ArrayList featheredEarthRitualPages = new ArrayList(); + ArrayList featheredEarthRitualPages = new ArrayList<>(); featheredEarthRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/FeatheredEarth.png"), + new ResourceLocation( + "alchemicalwizardry", + "textures/misc/screenshots/rituals/FeatheredEarth.png"), true)); featheredEarthRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.featheredEarthRitual"))); entries.add( new EntryUniText(featheredEarthRitualPages, "guide.BloodMagic.entryName.rituals.featheredEarthRitual")); - ArrayList gaiaRitualPages = new ArrayList(); + ArrayList gaiaRitualPages = new ArrayList<>(); gaiaRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Gaia.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Gaia.png"), true)); gaiaRitualPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.gaiaRitual"))); entries.add(new EntryUniText(gaiaRitualPages, "guide.BloodMagic.entryName.rituals.gaiaRitual")); - ArrayList condorRitualPages = new ArrayList(); + ArrayList condorRitualPages = new ArrayList<>(); condorRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Flight.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Flight.png"), true)); condorRitualPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.condorRitual"))); entries.add(new EntryUniText(condorRitualPages, "guide.BloodMagic.entryName.rituals.condorRitual")); - ArrayList meteorRitualPages = new ArrayList(); + ArrayList meteorRitualPages = new ArrayList<>(); meteorRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Meteor.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Meteor.png"), true)); meteorRitualPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.meteorRitual"))); entries.add(new EntryUniText(meteorRitualPages, "guide.BloodMagic.entryName.rituals.meteorRitual")); - ArrayList expulsionRitualPages = new ArrayList(); + ArrayList expulsionRitualPages = new ArrayList<>(); expulsionRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Expulsion.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Expulsion.png"), true)); expulsionRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.expulsionRitual"))); entries.add(new EntryUniText(expulsionRitualPages, "guide.BloodMagic.entryName.rituals.expulsionRitual")); - ArrayList costOfProgressPages = new ArrayList(); + ArrayList costOfProgressPages = new ArrayList<>(); costOfProgressPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.costOfProgress.1"))); costOfProgressPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.costOfProgress.2"))); entries.add(new EntryUniText(costOfProgressPages, "guide.BloodMagic.entryName.rituals.costOfProgress")); - ArrayList zephyrRitualPages = new ArrayList(); + ArrayList zephyrRitualPages = new ArrayList<>(); zephyrRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Zephyr.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Zephyr.png"), true)); zephyrRitualPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.zephyrRitual"))); entries.add(new EntryUniText(zephyrRitualPages, "guide.BloodMagic.entryName.rituals.zephyrRitual")); - ArrayList harvestRitualPages = new ArrayList(); + ArrayList harvestRitualPages = new ArrayList<>(); harvestRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Harvest.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Harvest.png"), true)); harvestRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.harvestRitual"))); entries.add(new EntryUniText(harvestRitualPages, "guide.BloodMagic.entryName.rituals.harvestRitual")); - ArrayList eternalSoulRitualPages = new ArrayList(); + ArrayList eternalSoulRitualPages = new ArrayList<>(); eternalSoulRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/EternalSoul.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/EternalSoul.png"), true)); eternalSoulRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.eternalSoulRitual"))); entries.add(new EntryUniText(eternalSoulRitualPages, "guide.BloodMagic.entryName.rituals.eternalSoulRitual")); - ArrayList ellipsoidRitualPages = new ArrayList(); + ArrayList ellipsoidRitualPages = new ArrayList<>(); ellipsoidRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Ellipsoid.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Ellipsoid.png"), true)); ellipsoidRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.ellipsoidRitual"))); entries.add(new EntryUniText(ellipsoidRitualPages, "guide.BloodMagic.entryName.rituals.ellipsoidRitual")); - ArrayList evaporationRitualPages = new ArrayList(); + ArrayList evaporationRitualPages = new ArrayList<>(); evaporationRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Evaporation.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Evaporation.png"), true)); evaporationRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.evaporationRitual"))); entries.add(new EntryUniText(evaporationRitualPages, "guide.BloodMagic.entryName.rituals.evaporationRitual")); - ArrayList sacrosanctityRitualPages = new ArrayList(); + ArrayList sacrosanctityRitualPages = new ArrayList<>(); sacrosanctityRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Sacrosanctity.png"), + new ResourceLocation( + "alchemicalwizardry", + "textures/misc/screenshots/rituals/Sacrosanctity.png"), true)); sacrosanctityRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.sacrosanctityRitual"))); entries.add( new EntryUniText(sacrosanctityRitualPages, "guide.BloodMagic.entryName.rituals.sacrosanctityRitual")); - ArrayList evilRitualPages = new ArrayList(); + ArrayList evilRitualPages = new ArrayList<>(); evilRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/VeilOfEvil.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/VeilOfEvil.png"), true)); evilRitualPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.evilRitual"))); entries.add(new EntryUniText(evilRitualPages, "guide.BloodMagic.entryName.rituals.evilRitual")); - ArrayList stomachRitualPages = new ArrayList(); + ArrayList stomachRitualPages = new ArrayList<>(); stomachRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Stomach.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Stomach.png"), true)); stomachRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.stomachRitual"))); entries.add(new EntryUniText(stomachRitualPages, "guide.BloodMagic.entryName.rituals.stomachRitual")); - ArrayList reagentEffectsRitualPages = new ArrayList(); + ArrayList reagentEffectsRitualPages = new ArrayList<>(); for (int i = 1; i <= 24; i++) { reagentEffectsRitualPages.addAll( PageHelper.pagesForLongText( @@ -830,77 +843,85 @@ public static void registerRitualBook() { } entries.add(new EntryUniText(reagentEffectsRitualPages, "guide.BloodMagic.entryName.rituals.reagentEffects")); - ArrayList conclaveOfMagesPages = new ArrayList(); + ArrayList conclaveOfMagesPages = new ArrayList<>(); conclaveOfMagesPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.conclaveOfMages"))); entries.add(new EntryUniText(conclaveOfMagesPages, "guide.BloodMagic.entryName.rituals.conclaveOfMages")); - ArrayList forbiddenParadisePages = new ArrayList(); + ArrayList forbiddenParadisePages = new ArrayList<>(); forbiddenParadisePages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.forbiddenParadise"))); entries.add(new EntryUniText(forbiddenParadisePages, "guide.BloodMagic.entryName.rituals.forbiddenParadise")); - ArrayList convocationRitualPages = new ArrayList(); + ArrayList convocationRitualPages = new ArrayList<>(); convocationRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/Convocation.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/rituals/Convocation.png"), true)); convocationRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.convocationRitual"))); entries.add(new EntryUniText(convocationRitualPages, "guide.BloodMagic.entryName.rituals.convocationRitual")); - ArrayList longHaulPages = new ArrayList(); + ArrayList longHaulPages = new ArrayList<>(); longHaulPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.longHaul"))); entries.add(new EntryUniText(longHaulPages, "guide.BloodMagic.entryName.rituals.longHaul")); - ArrayList phantomHandsRitualPages = new ArrayList(); + ArrayList phantomHandsRitualPages = new ArrayList<>(); phantomHandsRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/PhantomHands.png"), + new ResourceLocation( + "alchemicalwizardry", + "textures/misc/screenshots/rituals/PhantomHands.png"), true)); phantomHandsRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.phantomHandsRitual"))); entries.add(new EntryUniText(phantomHandsRitualPages, "guide.BloodMagic.entryName.rituals.phantomHandsRitual")); - ArrayList anvilRitualPages = new ArrayList(); + ArrayList anvilRitualPages = new ArrayList<>(); anvilRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/BeatingAnvil.png"), + new ResourceLocation( + "alchemicalwizardry", + "textures/misc/screenshots/rituals/BeatingAnvil.png"), true)); anvilRitualPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.anvilRitual"))); entries.add(new EntryUniText(anvilRitualPages, "guide.BloodMagic.entryName.rituals.anvilRitual")); - ArrayList dawnInkPages = new ArrayList(); + ArrayList dawnInkPages = new ArrayList<>(); dawnInkPages.add(new PageAltarRecipe(RecipeHolder.dawnRecipe)); dawnInkPages.addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.dawnInk"))); entries.add(new EntryUniText(dawnInkPages, "guide.BloodMagic.entryName.rituals.dawnInk")); - ArrayList symmetryRitualPages = new ArrayList(); + ArrayList symmetryRitualPages = new ArrayList<>(); symmetryRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/SymmetryOmega.png"), + new ResourceLocation( + "alchemicalwizardry", + "textures/misc/screenshots/rituals/SymmetryOmega.png"), true)); symmetryRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.symmetryRitual"))); entries.add(new EntryUniText(symmetryRitualPages, "guide.BloodMagic.entryName.rituals.symmetryRitual")); - ArrayList stallingRitualPages = new ArrayList(); + ArrayList stallingRitualPages = new ArrayList<>(); stallingRitualPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/rituals/StallingOmega.png"), + new ResourceLocation( + "alchemicalwizardry", + "textures/misc/screenshots/rituals/StallingOmega.png"), true)); stallingRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.stallingRitual"))); entries.add(new EntryUniText(stallingRitualPages, "guide.BloodMagic.entryName.rituals.stallingRitual")); - ArrayList newMoonRitualPages = new ArrayList(); + ArrayList newMoonRitualPages = new ArrayList<>(); newMoonRitualPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.rituals.newMoonRitual"))); entries.add(new EntryUniText(newMoonRitualPages, "guide.BloodMagic.entryName.rituals.newMoonRitual")); @@ -913,67 +934,67 @@ public static void registerRitualBook() { } public static void registerDemonBook() { - List entries = new ArrayList(); + List entries = new ArrayList<>(); - ArrayList ashesPages = new ArrayList(); + ArrayList ashesPages = new ArrayList<>(); ashesPages.addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.demons.ashes"))); entries.add(new EntryUniText(ashesPages, "guide.BloodMagic.entryName.demons.ashes")); - ArrayList tamedDemonPages = new ArrayList(); + ArrayList tamedDemonPages = new ArrayList<>(); tamedDemonPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.demons.tamedDemon"))); entries.add(new EntryUniText(tamedDemonPages, "guide.BloodMagic.entryName.demons.tamedDemon")); - ArrayList futurePages = new ArrayList(); + ArrayList futurePages = new ArrayList<>(); futurePages.addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.demons.future"))); entries.add(new EntryUniText(futurePages, "guide.BloodMagic.entryName.demons.future")); - ArrayList knightPages = new ArrayList(); + ArrayList knightPages = new ArrayList<>(); knightPages.addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.demons.knight"))); entries.add(new EntryUniText(knightPages, "guide.BloodMagic.entryName.demons.knight")); - ArrayList demonShardPages = new ArrayList(); + ArrayList demonShardPages = new ArrayList<>(); demonShardPages.addAll( PageHelper.pagesForLongText( (StatCollector.translateToLocal("aw.entries.demons.demonShard")), new ItemStack(ModItems.demonBloodShard))); entries.add(new EntryUniText(demonShardPages, "guide.BloodMagic.entryName.demons.demonShard")); - ArrayList demonSummoningPages = new ArrayList(); + ArrayList demonSummoningPages = new ArrayList<>(); demonSummoningPages.add(new PageIRecipe(RecipeHolder.arcanePedestalRecipe)); demonSummoningPages.add(new PageIRecipe(RecipeHolder.arcanePlinthRecipe)); demonSummoningPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/demons/Ring1.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/demons/Ring1.png"), true)); demonSummoningPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/demons/Ring2.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/demons/Ring2.png"), true)); demonSummoningPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.demons.demonSummoning"))); entries.add(new EntryUniText(demonSummoningPages, "guide.BloodMagic.entryName.demons.demonSummoning")); - ArrayList keysGatePages = new ArrayList(); + ArrayList keysGatePages = new ArrayList<>(); for (int i = 1; i <= 10; i++) { keysGatePages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.demons.keysGate." + i))); } entries.add(new EntryUniText(keysGatePages, "guide.BloodMagic.entryName.demons.keysGate")); - ArrayList futurePlansPages = new ArrayList(); + ArrayList futurePlansPages = new ArrayList<>(); futurePlansPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.demons.futurePlans"))); entries.add(new EntryUniText(futurePlansPages, "guide.BloodMagic.entryName.demons.futurePlans")); - ArrayList demonInvasionPages = new ArrayList(); + ArrayList demonInvasionPages = new ArrayList<>(); demonInvasionPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.demons.demonInvasion"))); entries.add(new EntryUniText(demonInvasionPages, "guide.BloodMagic.entryName.demons.demonInvasion")); - ArrayList observationsPages = new ArrayList(); + ArrayList observationsPages = new ArrayList<>(); observationsPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.demons.observations"))); entries.add(new EntryUniText(observationsPages, "guide.BloodMagic.entryName.demons.observations")); @@ -986,27 +1007,28 @@ public static void registerDemonBook() { } public static void registerSpellBook() { - List entries = new ArrayList(); + List entries = new ArrayList<>(); - ArrayList demonGirlPages = new ArrayList(); + ArrayList demonGirlPages = new ArrayList<>(); demonGirlPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.spells.demonGirl"))); entries.add(new EntryUniText(demonGirlPages, "guide.BloodMagic.entryName.spells.demonGirl")); - ArrayList spellTablePages = new ArrayList(); + ArrayList spellTablePages = new ArrayList<>(); spellTablePages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.spells.spellTable.1"))); spellTablePages.add( new PageUnlocImage( "", new ResourceLocation( - "alchemicalwizardry:textures/misc/screenshots/spells/SimpleSpellTable.png"), + "alchemicalwizardry", + "textures/misc/screenshots/spells/SimpleSpellTable.png"), true)); spellTablePages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.spells.spellTable.2"))); entries.add(new EntryUniText(spellTablePages, "guide.BloodMagic.entryName.spells.spellTable")); - ArrayList simpleEffectsPages = new ArrayList(); + ArrayList simpleEffectsPages = new ArrayList<>(); for (int i = 1; i <= 11; i++) { simpleEffectsPages.addAll( PageHelper @@ -1014,7 +1036,7 @@ public static void registerSpellBook() { } entries.add(new EntryUniText(simpleEffectsPages, "guide.BloodMagic.entryName.spells.simpleEffects")); - ArrayList tableAndSkullsPages = new ArrayList(); + ArrayList tableAndSkullsPages = new ArrayList<>(); tableAndSkullsPages.add(new PageAltarRecipe(RecipeHolder.blankSpellRecipe)); tableAndSkullsPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.spells.tableAndSkulls.1"))); @@ -1023,18 +1045,18 @@ public static void registerSpellBook() { PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.spells.tableAndSkulls.2"))); entries.add(new EntryUniText(tableAndSkullsPages, "guide.BloodMagic.entryName.spells.tableAndSkulls")); - ArrayList timePassesPages = new ArrayList(); + ArrayList timePassesPages = new ArrayList<>(); timePassesPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.spells.timePasses"))); entries.add(new EntryUniText(timePassesPages, "guide.BloodMagic.entryName.spells.timePasses")); - ArrayList complexSpellBasicsPages = new ArrayList(); + ArrayList complexSpellBasicsPages = new ArrayList<>(); complexSpellBasicsPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.spells.complexSpellBasics.1"))); complexSpellBasicsPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/spells/Paradigm.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/spells/Paradigm.png"), true)); for (int i = 2; i <= 6; i++) complexSpellBasicsPages.addAll( @@ -1044,14 +1066,14 @@ public static void registerSpellBook() { complexSpellBasicsPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/spells/Effect.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/spells/Effect.png"), true)); complexSpellBasicsPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.spells.complexSpellBasics.7"))); complexSpellBasicsPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/spells/Modifier.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/spells/Modifier.png"), true)); for (int i = 8; i <= 12; i++) complexSpellBasicsPages.addAll( @@ -1061,7 +1083,7 @@ public static void registerSpellBook() { complexSpellBasicsPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/spells/Enhancement.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/spells/Enhancement.png"), true)); for (int i = 13; i <= 16; i++) complexSpellBasicsPages.addAll( @@ -1071,25 +1093,25 @@ public static void registerSpellBook() { complexSpellBasicsPages.add( new PageUnlocImage( "", - new ResourceLocation("alchemicalwizardry:textures/misc/screenshots/spells/Conduit.png"), + new ResourceLocation("alchemicalwizardry", "textures/misc/screenshots/spells/Conduit.png"), true)); complexSpellBasicsPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.spells.complexSpellBasics.17"))); entries.add(new EntryUniText(complexSpellBasicsPages, "guide.BloodMagic.entryName.spells.complexSpellBasics")); - ArrayList complexSpellEffectsPages = new ArrayList(); + ArrayList complexSpellEffectsPages = new ArrayList<>(); for (int i = 1; i <= 17; i++) complexSpellEffectsPages.addAll( PageHelper.pagesForLongText( StatCollector.translateToLocal("aw.entries.spells.complexSpellEffects." + i))); entries.add( new EntryUniText(complexSpellEffectsPages, "guide.BloodMagic.entryName.spells.complexSpellEffects")); - ArrayList offTopicPages = new ArrayList(); + ArrayList offTopicPages = new ArrayList<>(); offTopicPages.addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.spells.offTopic"))); entries.add(new EntryUniText(offTopicPages, "guide.BloodMagic.entryName.spells.offTopic")); - ArrayList demonicPowerPages = new ArrayList(); + ArrayList demonicPowerPages = new ArrayList<>(); demonicPowerPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.spells.demonicPower"))); entries.add(new EntryUniText(demonicPowerPages, "guide.BloodMagic.entryName.spells.demonicPower")); @@ -1102,25 +1124,25 @@ public static void registerSpellBook() { } public static void registerAlchemyBook() { - List entries = new ArrayList(); + List entries = new ArrayList<>(); - ArrayList fatedMeetingPages = new ArrayList(); + ArrayList fatedMeetingPages = new ArrayList<>(); fatedMeetingPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.alchemy.fatedMeeting"))); entries.add(new EntryUniText(fatedMeetingPages, "guide.BloodMagic.entryName.alchemy.fatedMeeting")); - ArrayList firstStepsPages = new ArrayList(); + ArrayList firstStepsPages = new ArrayList<>(); firstStepsPages.add(getOrbPageForRecipe(RecipeHolder.alchemySetRecipe)); firstStepsPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.alchemy.firstSteps"))); entries.add(new EntryUniText(firstStepsPages, "guide.BloodMagic.entryName.alchemy.firstSteps")); - ArrayList chemistrySetPages = new ArrayList(); + ArrayList chemistrySetPages = new ArrayList<>(); for (int i = 1; i <= 10; i++) chemistrySetPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.alchemy.chemistrySet." + i))); entries.add(new EntryUniText(chemistrySetPages, "guide.BloodMagic.entryName.alchemy.chemistrySet")); - ArrayList incensePages = new ArrayList(); + ArrayList incensePages = new ArrayList<>(); incensePages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.alchemy.incense.1"))); incensePages.add(new PageIRecipe(RecipeHolder.crucibleRecipe)); @@ -1135,43 +1157,43 @@ public static void registerAlchemyBook() { .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.alchemy.incense.3"))); entries.add(new EntryUniText(incensePages, "guide.BloodMagic.entryName.alchemy.incense")); - ArrayList potionsPages = new ArrayList(); + ArrayList potionsPages = new ArrayList<>(); potionsPages.add(new PageAltarRecipe(RecipeHolder.flaskRecipe)); potionsPages.addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.alchemy.potions"))); entries.add(new EntryUniText(potionsPages, "guide.BloodMagic.entryName.alchemy.potions")); - ArrayList reagentRevolutionPages = new ArrayList(); + ArrayList reagentRevolutionPages = new ArrayList<>(); for (int i = 1; i <= 8; i++) reagentRevolutionPages.addAll( PageHelper .pagesForLongText(StatCollector.translateToLocal("aw.entries.alchemy.reagentRevolution." + i))); entries.add(new EntryUniText(reagentRevolutionPages, "guide.BloodMagic.entryName.alchemy.reagentRevolution")); - ArrayList newPotionsPages = new ArrayList(); + ArrayList newPotionsPages = new ArrayList<>(); newPotionsPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.alchemy.newPotions"))); entries.add(new EntryUniText(newPotionsPages, "guide.BloodMagic.entryName.alchemy.newPotions")); - ArrayList soulSandPages = new ArrayList(); + ArrayList soulSandPages = new ArrayList<>(); soulSandPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.alchemy.soulSand"))); entries.add(new EntryUniText(soulSandPages, "guide.BloodMagic.entryName.alchemy.soulSand")); - ArrayList timeGoesByPages = new ArrayList(); + ArrayList timeGoesByPages = new ArrayList<>(); timeGoesByPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.alchemy.timeGoesBy"))); entries.add(new EntryUniText(timeGoesByPages, "guide.BloodMagic.entryName.alchemy.timeGoesBy")); - ArrayList catalystsPages = new ArrayList(); + ArrayList catalystsPages = new ArrayList<>(); catalystsPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.alchemy.catalysts"))); entries.add(new EntryUniText(catalystsPages, "guide.BloodMagic.entryName.alchemy.catalysts")); - ArrayList activationCrystalPages = new ArrayList(); + ArrayList activationCrystalPages = new ArrayList<>(); activationCrystalPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.alchemy.activationCrystal"))); entries.add(new EntryUniText(activationCrystalPages, "guide.BloodMagic.entryName.alchemy.activationCrystal")); - ArrayList reagentSystemPages = new ArrayList(); + ArrayList reagentSystemPages = new ArrayList<>(); reagentSystemPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.alchemy.reagentSystem.1"))); reagentSystemPages.add(new PageIRecipe(RecipeHolder.calcinatorRecipe)); @@ -1196,12 +1218,12 @@ public static void registerAlchemyBook() { entries.add(new EntryUniText(reagentSystemPages, "guide.BloodMagic.entryName.alchemy.reagentSystem")); - ArrayList magusSecretPages = new ArrayList(); + ArrayList magusSecretPages = new ArrayList<>(); magusSecretPages .addAll(PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.alchemy.magusSecret"))); entries.add(new EntryUniText(magusSecretPages, "guide.BloodMagic.entryName.alchemy.magusSecret")); - ArrayList simpleCreationsPages = new ArrayList(); + ArrayList simpleCreationsPages = new ArrayList<>(); simpleCreationsPages.addAll( PageHelper.pagesForLongText(StatCollector.translateToLocal("aw.entries.alchemy.simpleCreations"))); entries.add(new EntryUniText(simpleCreationsPages, "guide.BloodMagic.entryName.alchemy.simpleCreations")); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandBind.java b/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandBind.java index bd9ae61897..67cfc6abd9 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandBind.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandBind.java @@ -32,10 +32,6 @@ public void processCommand(ICommandSender iCommandSender, String[] astring) { ItemStack item = entityplayermp.getCurrentEquippedItem(); EntityPlayerMP targetPlayer = getPlayer(iCommandSender, astring[0]); - if (targetPlayer == null) { - throw new CommandException("commands.bind.failed.noPlayer"); - } - if (item != null && item.getItem() instanceof IBindable) { if (IBindable.getOwnerName(item).isEmpty()) { IBindable.checkAndSetItemOwner(item, targetPlayer); @@ -48,7 +44,7 @@ public void processCommand(ICommandSender iCommandSender, String[] astring) { } } - public List addTabCompletionOptions(ICommandSender iCommandSender, String[] astring) { + public List addTabCompletionOptions(ICommandSender iCommandSender, String[] astring) { return getListOfStringsMatchingLastWord(astring, this.getPlayer()); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandBloodMagic.java b/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandBloodMagic.java index 356b1de529..7befd465b1 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandBloodMagic.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandBloodMagic.java @@ -20,10 +20,9 @@ public class CommandBloodMagic extends CommandBase { - private final List aliases = new ArrayList(); + private final List aliases = new ArrayList<>(); private final Map subCommands = new HashMap(); - @SuppressWarnings("unchecked") public CommandBloodMagic() { aliases.add("BloodMagic"); aliases.add("bloodmagic"); @@ -52,7 +51,7 @@ public String getCommandUsage(ICommandSender commandSender) { } @Override - public List getCommandAliases() { + public List getCommandAliases() { return aliases; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandSN.java b/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandSN.java index ea36253ef1..98c3eb277f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandSN.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandSN.java @@ -81,15 +81,13 @@ public void processCommand(ICommandSender icommandsender, String[] astring) { } else { throw new CommandException("commands.soulnetwork.notACommand"); } - } else if (astring.length == 0) { - throw new CommandException("commands.soulnetwork.noPlayer"); } else if (astring.length == 1) { throw new CommandException("commands.soulnetwork.noCommand"); } } @Override - public List addTabCompletionOptions(ICommandSender iCommandSender, String[] astring) { + public List addTabCompletionOptions(ICommandSender iCommandSender, String[] astring) { if (astring.length == 1) { return getListOfStringsMatchingLastWord(astring, this.getPlayer()); } else if (astring.length == 2) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandUnbind.java b/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandUnbind.java index 6a27ab914b..0d812e4ebf 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandUnbind.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandUnbind.java @@ -12,18 +12,22 @@ public class CommandUnbind extends CommandBase { public CommandUnbind() {} + @Override public String getCommandName() { return "unbind"; } + @Override public int getRequiredPermissionLevel() { return 2; } + @Override public String getCommandUsage(ICommandSender icommandsender) { return "commands.unbind.usage"; } + @Override public void processCommand(ICommandSender iCommandSender, String[] astring) { EntityPlayerMP entityplayermp = getCommandSenderAsPlayer(iCommandSender); ItemStack item = entityplayermp.getCurrentEquippedItem(); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/commands/sub/SubCommandNetwork.java b/src/main/java/WayofTime/alchemicalWizardry/common/commands/sub/SubCommandNetwork.java index c98123d91b..1fd084671f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/commands/sub/SubCommandNetwork.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/commands/sub/SubCommandNetwork.java @@ -52,7 +52,7 @@ public void processSubCommand(ICommandSender commandSender, String[] args) { try { switch (ValidCommands.valueOf(args[0].toUpperCase(Locale.ENGLISH))) { - case SYPHON: { + case SYPHON -> { if (displayHelp) { displayHelpString(commandSender, ValidCommands.SYPHON.help); break; @@ -74,9 +74,8 @@ public void processSubCommand(ICommandSender commandSender, String[] args) { displayErrorString(commandSender, "commands.error.arg.missing"); } - break; } - case ADD: { + case ADD -> { if (displayHelp) { displayHelpString(commandSender, ValidCommands.ADD.help); break; @@ -95,9 +94,8 @@ public void processSubCommand(ICommandSender commandSender, String[] args) { displayErrorString(commandSender, "commands.error.arg.missing"); } - break; } - case SET: { + case SET -> { if (displayHelp) { displayHelpString(commandSender, ValidCommands.SET.help); break; @@ -115,9 +113,8 @@ public void processSubCommand(ICommandSender commandSender, String[] args) { displayErrorString(commandSender, "commands.error.arg.missing"); } - break; } - case GET: { + case GET -> { if (displayHelp) { displayHelpString(commandSender, ValidCommands.GET.help); break; @@ -129,9 +126,8 @@ public void processSubCommand(ICommandSender commandSender, String[] args) { + SoulNetworkHandler.getCurrentEssence(givenName) + "LP")); - break; } - case FILL: { + case FILL -> { if (displayHelp) { displayHelpString(commandSender, ValidCommands.FILL.help, Integer.MAX_VALUE); break; @@ -142,9 +138,8 @@ public void processSubCommand(ICommandSender commandSender, String[] args) { displaySuccessString(commandSender, "commands.network.fill.success", givenName); } - break; } - case CAP: { + case CAP -> { if (displayHelp) { displayHelpString(commandSender, ValidCommands.CAP.help); break; @@ -156,7 +151,6 @@ public void processSubCommand(ICommandSender commandSender, String[] args) { displaySuccessString(commandSender, "commands.network.cap.success", givenName); } - break; } } } catch (IllegalArgumentException e) { @@ -174,20 +168,17 @@ private enum ValidCommands { FILL("commands.network.fill.help"), CAP("commands.network.cap.help"); - public String help; + public final String help; ValidCommands(String help) { this.help = help; } } - @SuppressWarnings("ResultOfMethodCallIgnored") private static boolean isInteger(String s) { try { Integer.parseInt(s); - } catch (NumberFormatException e) { - return false; - } catch (NullPointerException e) { + } catch (NumberFormatException | NullPointerException e) { return false; } // only got here if we didn't return false diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/commands/sub/SubCommandOrb.java b/src/main/java/WayofTime/alchemicalWizardry/common/commands/sub/SubCommandOrb.java index e953d32ac2..f2b99a12d9 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/commands/sub/SubCommandOrb.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/commands/sub/SubCommandOrb.java @@ -93,20 +93,17 @@ private enum ValidCommands { SET("commands.orb.set.help"), GET("commands.orb.get.help"); - public String help; + public final String help; ValidCommands(String help) { this.help = help; } } - @SuppressWarnings("ResultOfMethodCallIgnored") private static boolean isInteger(String s) { try { Integer.parseInt(s); - } catch (NumberFormatException e) { - return false; - } catch (NullPointerException e) { + } catch (NumberFormatException | NullPointerException e) { return false; } // only got here if we didn't return false diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/compress/AdvancedCompressionHandler.java b/src/main/java/WayofTime/alchemicalWizardry/common/compress/AdvancedCompressionHandler.java index 9745737c5e..07a1fef2af 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/compress/AdvancedCompressionHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/compress/AdvancedCompressionHandler.java @@ -94,6 +94,7 @@ public static boolean isResultStackReversible(ItemStack stack, int gridSize, Wor } InventoryCrafting inventory = new InventoryCrafting(new Container() { + @Override public boolean canInteractWith(EntityPlayer player) { return false; } @@ -106,15 +107,11 @@ public boolean canInteractWith(EntityPlayer player) { return false; } - ItemStack compressedStack = null; - switch (gridSize) { - case 2: - compressedStack = get22Recipe(returnStack, world); - break; - case 3: - compressedStack = get33Recipe(returnStack, world); - break; - } + ItemStack compressedStack = switch (gridSize) { + case 2 -> get22Recipe(returnStack, world); + case 3 -> get33Recipe(returnStack, world); + default -> null; + }; if (compressedStack == null) { return false; @@ -126,6 +123,7 @@ public boolean canInteractWith(EntityPlayer player) { public static ItemStack getRecipe(ItemStack stack, World world, int gridSize) { InventoryCrafting inventory = new InventoryCrafting(new Container() { + @Override public boolean canInteractWith(EntityPlayer player) { return false; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/compress/StorageBlockCraftingManager.java b/src/main/java/WayofTime/alchemicalWizardry/common/compress/StorageBlockCraftingManager.java index b88798afca..649751263a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/compress/StorageBlockCraftingManager.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/compress/StorageBlockCraftingManager.java @@ -12,12 +12,11 @@ import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class StorageBlockCraftingManager { private static final StorageBlockCraftingManager instance = new StorageBlockCraftingManager(); - private List recipes = new LinkedList(); + private List recipes = new LinkedList<>(); public static StorageBlockCraftingManager getInstance() { return instance; @@ -26,138 +25,13 @@ public static StorageBlockCraftingManager getInstance() { public void addStorageBlockRecipes() { this.recipes = new StorageBlockCraftingRecipeAssimilator().getPackingRecipes(); - AlchemicalWizardry.logger.info("Total number of compression recipes: " + this.recipes.size()); - // List tempRecipeList = new LinkedList(); - // - // World world = DimensionManager.getWorld(0); - // - // for(Object obj : this.recipes) - // { - // if(obj instanceof IRecipe) - // { - // IRecipe recipe = (IRecipe)obj; - // ItemStack outputStack = recipe.getRecipeOutput(); - // if(outputStack == null || outputStack.getItem() == null) - // { - // continue; - // } - // - // if(recipe instanceof ShapedRecipes) - // { - // ShapedRecipes sRecipe = (ShapedRecipes)recipe; - // ItemStack[] input = sRecipe.recipeItems; - // - // if(outputStack.stackSize == 1 && (input.length == 9 || input.length == 4)) - // { - // tempRecipeList.add(recipe); - // }else if((outputStack.stackSize == 9 || outputStack.stackSize == 4) && input.length == 1) - // { - // tempRecipeList.add(recipe); - // } - // } - // else if(recipe instanceof ShapelessRecipes) - // { - // ShapelessRecipes sRecipe = (ShapelessRecipes)recipe; - // List input = sRecipe.recipeItems; - // - // if(outputStack.stackSize == 1 && (input.size() == 9 || input.size() == 4)) - // { - // Object obj1 = input.get(0); - // if(obj1 != null) - // { - // boolean allMatch = true; - // for(Object obj2 : input) - // { - // if(obj2 == null || !obj2.equals(obj1)) - // { - // allMatch = false; - // break; - // } - // } - // if(allMatch) - // { - // tempRecipeList.add(recipe); - // } - // } - // - // }else if((outputStack.stackSize == 9 || outputStack.stackSize == 4) && input.size() == 1) - // { - // tempRecipeList.add(recipe); - // } - // } - // else if((outputStack.stackSize == 1 && (recipe.getRecipeSize() == 9 || recipe.getRecipeSize() == 4)) || - // ((outputStack.stackSize == 9 || outputStack.stackSize == 4) && recipe.getRecipeSize() == 1)) - // { - // tempRecipeList.add(recipe); - // continue; - // } - // } - // } - // - // List tempRecipeList2 = new LinkedList(); - // - // for(Object obj : tempRecipeList) - // { - // if(obj instanceof IRecipe) - // { - // IRecipe recipe = (IRecipe)obj; - // ItemStack outputStack = recipe.getRecipeOutput(); - // if(outputStack == null || outputStack.getItem() == null) - // { - // continue; - // } - // - // if(isResultStackReversible(outputStack, 2, world, tempRecipeList) || - // isResultStackReversible(outputStack, 3, world, tempRecipeList)) - // { - // tempRecipeList2.add(recipe); - // AlchemicalWizardry.logger.info("Now adding recipe for " + outputStack + " to the compression - // handler."); - // } - // } - // } - // - // this.recipes = tempRecipeList2; + AlchemicalWizardry.logger.info("Total number of compression recipes: {}", this.recipes.size()); } - private static boolean isResultStackReversible(ItemStack stack, int gridSize, World world, List list) { - if (stack == null) { - return false; - } - InventoryCrafting inventory = new InventoryCrafting(new Container() { - - public boolean canInteractWith(EntityPlayer player) { - return false; - } - }, 2, 2); - - inventory.setInventorySlotContents(0, stack); - - ItemStack returnStack = StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world, list); - if (returnStack == null || returnStack.getItem() == null) { - return false; - } - - ItemStack compressedStack = null; - switch (gridSize) { - case 2: - compressedStack = get22Recipe(returnStack, world, list); - break; - case 3: - compressedStack = get33Recipe(returnStack, world, list); - break; - } - - if (compressedStack == null) { - return false; - } else { - return SpellHelper.areItemStacksEqual(stack, compressedStack); - } - } - - private static ItemStack getRecipe(ItemStack stack, World world, int gridSize, List list) { + private static ItemStack getRecipe(ItemStack stack, World world, int gridSize, List list) { InventoryCrafting inventory = new InventoryCrafting(new Container() { + @Override public boolean canInteractWith(EntityPlayer player) { return false; } @@ -169,19 +43,19 @@ public boolean canInteractWith(EntityPlayer player) { return StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world, list); } - private static boolean has22Recipe(ItemStack stack, World world, List list) { + private static boolean has22Recipe(ItemStack stack, World world, List list) { return get22Recipe(stack, world, list) != null; } - private static ItemStack get22Recipe(ItemStack stack, World world, List list) { + private static ItemStack get22Recipe(ItemStack stack, World world, List list) { return getRecipe(stack, world, 2, list); } - private static boolean has33Recipe(ItemStack stack, World world, List list) { + private static boolean has33Recipe(ItemStack stack, World world, List list) { return get33Recipe(stack, world, list) != null; } - private static ItemStack get33Recipe(ItemStack stack, World world, List list) { + private static ItemStack get33Recipe(ItemStack stack, World world, List list) { return getRecipe(stack, world, 3, list); } @@ -189,7 +63,7 @@ public ItemStack findMatchingRecipe(InventoryCrafting p_82787_1_, World p_82787_ return this.findMatchingRecipe(p_82787_1_, p_82787_2_, this.recipes); } - private ItemStack findMatchingRecipe(InventoryCrafting p_82787_1_, World p_82787_2_, List list) { + private ItemStack findMatchingRecipe(InventoryCrafting p_82787_1_, World p_82787_2_, List list) { int i = 0; ItemStack itemstack = null; ItemStack itemstack1 = null; @@ -227,9 +101,7 @@ private ItemStack findMatchingRecipe(InventoryCrafting p_82787_1_, World p_82787 return new ItemStack(itemstack.getItem(), 1, i1); } else { - for (j = 0; j < list.size(); ++j) { - IRecipe irecipe = (IRecipe) list.get(j); - + for (IRecipe irecipe : list) { if (irecipe.matches(p_82787_1_, p_82787_2_)) { return irecipe.getCraftingResult(p_82787_1_); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/compress/StorageBlockCraftingRecipeAssimilator.java b/src/main/java/WayofTime/alchemicalWizardry/common/compress/StorageBlockCraftingRecipeAssimilator.java index 5ea6c7f6e6..e3c1812e24 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/compress/StorageBlockCraftingRecipeAssimilator.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/compress/StorageBlockCraftingRecipeAssimilator.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -14,7 +15,6 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.item.crafting.ShapelessRecipes; -import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; @@ -28,8 +28,8 @@ public class StorageBlockCraftingRecipeAssimilator { public List getPackingRecipes() { // grab all recipes potentially suitable for packing or unpacking - List packingRecipes = new LinkedList(); - List unpackingRecipes = new ArrayList(); + List packingRecipes = new LinkedList<>(); + List unpackingRecipes = new ArrayList<>(); for (IRecipe recipe : getCraftingRecipes()) { ItemStack output = recipe.getRecipeOutput(); @@ -52,9 +52,8 @@ public List getPackingRecipes() { InventoryCrafting inventoryUnpack = new InventoryCrafting(container, 2, 2); InventoryCrafting inventory2x2 = new InventoryCrafting(container, 2, 2); InventoryCrafting inventory3x3 = new InventoryCrafting(container, 3, 3); - World world = null; // TODO: use a proper dummy world? - List ret = new ArrayList(); + List ret = new ArrayList<>(); for (IRecipe recipeUnpack : unpackingRecipes) { ItemStack unpacked = recipeUnpack.getRecipeOutput(); @@ -102,7 +101,7 @@ public List getPackingRecipes() { // check if the packing recipe accepts the unpacked item stack - matched = recipePack.recipe.matches(inventory, world); + matched = recipePack.recipe.matches(inventory, null); } if (matched) { @@ -111,10 +110,10 @@ public List getPackingRecipes() { ItemStack packOutput = recipePack.recipe.getRecipeOutput(); inventoryUnpack.setInventorySlotContents(0, packOutput.copy()); - if (recipeUnpack.matches(inventoryUnpack, world)) { + if (recipeUnpack.matches(inventoryUnpack, null)) { ret.add(recipePack.recipe); AlchemicalWizardry.logger - .info("Adding the following recipe to the Compression Handler: " + packOutput); + .info("Adding the following recipe to the Compression Handler: {}", packOutput); it.remove(); } } @@ -124,7 +123,6 @@ public List getPackingRecipes() { return ret; } - @SuppressWarnings("unchecked") private List getCraftingRecipes() { return CraftingManager.getInstance().getRecipeList(); } @@ -144,14 +142,14 @@ private PackingRecipe getPackingRecipe(IRecipe recipe) { List inputs; - if (recipe instanceof ShapedRecipes) { - inputs = Arrays.asList(((ShapedRecipes) recipe).recipeItems); - } else if (recipe instanceof ShapelessRecipes) { - inputs = ((ShapelessRecipes) recipe).recipeItems; - } else if (recipe instanceof ShapedOreRecipe) { - inputs = Arrays.asList(((ShapedOreRecipe) recipe).getInput()); - } else if (recipe instanceof ShapelessOreRecipe) { - inputs = ((ShapelessOreRecipe) recipe).getInput(); + if (recipe instanceof ShapedRecipes shapedRecipes) { + inputs = Arrays.asList(shapedRecipes.recipeItems); + } else if (recipe instanceof ShapelessRecipes shapelessRecipes) { + inputs = shapelessRecipes.recipeItems; + } else if (recipe instanceof ShapedOreRecipe shapedOreRecipe) { + inputs = Arrays.asList(shapedOreRecipe.getInput()); + } else if (recipe instanceof ShapelessOreRecipe shapelessOreRecipe) { + inputs = shapelessOreRecipe.getInput(); } else { return new PackingRecipe(recipe, null, -1); } @@ -178,7 +176,7 @@ private PackingRecipe getPackingRecipe(IRecipe recipe) { * Determine the item stacks from the provided inputs which are suitable for every input element. * * @param inputs List of all inputs, null elements are being ignored. - * @return List List of all options. + * @return List of all options. */ @SuppressWarnings("unchecked") private List getIdenticalInputs(List inputs) { @@ -189,8 +187,8 @@ private List getIdenticalInputs(List inputs) { List offers; - if (input instanceof ItemStack) { - offers = Arrays.asList((ItemStack) input); + if (input instanceof ItemStack item) { + offers = Collections.singletonList(item); } else if (input instanceof List) { offers = (List) input; @@ -200,7 +198,7 @@ private List getIdenticalInputs(List inputs) { } if (options == null) { - options = new ArrayList(offers); + options = new ArrayList<>(offers); continue; } @@ -240,24 +238,13 @@ private boolean areInputsIdentical(ItemStack a, ItemStack b) { AlchemicalWizardry.logger .error("A mod in this instance has registered an item with a null input. Known problem mods are:"); - String err = ""; - for (String problem : problemMods) err += (err.length() > 0 ? ", " : "") + problem; - AlchemicalWizardry.logger.error(err); + StringBuilder err = new StringBuilder(); + for (String problem : problemMods) err.append(err.length() > 0 ? ", " : "").append(problem); + AlchemicalWizardry.logger.error(err.toString()); return false; } } - private static class PackingRecipe { - - PackingRecipe(IRecipe recipe, List possibleInputs, int inputCount) { - this.recipe = recipe; - this.possibleInputs = possibleInputs; - this.inputCount = inputCount; - } - - final IRecipe recipe; - final List possibleInputs; - final int inputCount; - } + private record PackingRecipe(IRecipe recipe, List possibleInputs, int inputCount) {} } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/BlockSet.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/BlockSet.java index bcd70d4bf9..adac08b6dc 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/BlockSet.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/BlockSet.java @@ -1,6 +1,7 @@ package WayofTime.alchemicalWizardry.common.demonVillage; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import net.minecraft.block.Block; @@ -38,7 +39,7 @@ public BlockSet() { public BlockSet(String blockid) { this.blockid = blockid; this.metadata = new int[4]; - positions = new ArrayList(); + positions = new ArrayList<>(); } public BlockSet(Block block) { @@ -47,170 +48,62 @@ public BlockSet(Block block) { public BlockSet(Block block, int meta) { this(block); - for (int i = 0; i < metadata.length; i++) { - metadata[i] = meta; - } + Arrays.fill(metadata, meta); if (block instanceof BlockStairs) { - int[] northSet = new int[] { 2, 3, 0, 1 }; - int[] eastSet = new int[] { 1, 0, 2, 3 }; - int[] southSet = new int[] { 3, 2, 1, 0 }; - int[] westSet = new int[] { 0, 1, 3, 2 }; - int[] northUpSet = new int[] { 6, 7, 4, 5 }; - int[] eastUpSet = new int[] { 5, 4, 6, 7 }; - int[] southUpSet = new int[] { 7, 6, 5, 4 }; - int[] westUpSet = new int[] { 4, 5, 7, 6 }; - switch (meta) { - case 0: - metadata = westSet; - break; - case 1: - metadata = eastSet; - break; - case 2: - metadata = northSet; - break; - case 3: - metadata = southSet; - break; - case 4: - metadata = westUpSet; - break; - case 5: - metadata = eastUpSet; - break; - case 6: - metadata = northUpSet; - break; - case 7: - metadata = southUpSet; - break; + case 0 -> metadata = new int[] { 0, 1, 3, 2 }; + case 1 -> metadata = new int[] { 1, 0, 2, 3 }; + case 2 -> metadata = new int[] { 2, 3, 0, 1 }; + case 3 -> metadata = new int[] { 3, 2, 1, 0 }; + case 4 -> metadata = new int[] { 4, 5, 7, 6 }; + case 5 -> metadata = new int[] { 5, 4, 6, 7 }; + case 6 -> metadata = new int[] { 6, 7, 4, 5 }; + case 7 -> metadata = new int[] { 7, 6, 5, 4 }; } } else if (block instanceof BlockLadder) { - int[] northSet = new int[] { 3, 2, 5, 4 }; - int[] eastSet = new int[] { 4, 5, 3, 2 }; - int[] southSet = new int[] { 2, 3, 4, 5 }; - int[] westSet = new int[] { 5, 4, 2, 3 }; - switch (meta) { - case 3: - metadata = northSet; - break; - case 4: - metadata = eastSet; - break; - case 2: - metadata = southSet; - break; - case 5: - metadata = westSet; - break; + case 2 -> metadata = new int[] { 2, 3, 4, 5 }; + case 3 -> metadata = new int[] { 3, 2, 5, 4 }; + case 4 -> metadata = new int[] { 4, 5, 3, 2 }; + case 5 -> metadata = new int[] { 5, 4, 2, 3 }; } } else if (block instanceof BlockTrapDoor) { int div = meta / 4; - int mod = meta % 4; - int[] northSet = new int[] { 1 + div * 4, div * 4, 3 + div * 4, 2 + div * 4 }; // Second one: 0 + - int[] eastSet = new int[] { 2 + div * 4, 3 + div * 4, 1 + div * 4, div * 4 }; // Last one: 0 + - int[] southSet = new int[] { div * 4, 1 + div * 4, 2 + div * 4, 3 + div * 4 }; // First one: 0 + - int[] westSet = new int[] { 3 + div * 4, 2 + div * 4, div * 4, 1 + div * 4 }; // Third one: 0 + - - switch (mod) { - case 0: - metadata = southSet; - break; - case 1: - metadata = northSet; - break; - case 2: - metadata = eastSet; - break; - case 3: - metadata = westSet; - break; + switch (meta % 4) { + case 0 -> metadata = new int[] { div * 4, 1 + div * 4, 2 + div * 4, 3 + div * 4 }; + case 1 -> metadata = new int[] { 1 + div * 4, div * 4, 3 + div * 4, 2 + div * 4 }; + case 2 -> metadata = new int[] { 2 + div * 4, 3 + div * 4, 1 + div * 4, div * 4 }; + case 3 -> metadata = new int[] { 3 + div * 4, 2 + div * 4, div * 4, 1 + div * 4 }; } } else if (block instanceof BlockTorch) { - int[] northSet = new int[] { 3, 4, 1, 2 }; - int[] eastSet = new int[] { 2, 1, 3, 4 }; - int[] southSet = new int[] { 4, 3, 2, 1 }; - int[] westSet = new int[] { 1, 2, 4, 3 }; - switch (meta) { - case 1: - metadata = westSet; - break; - case 2: - metadata = eastSet; - break; - case 3: - metadata = northSet; - break; - case 4: - metadata = southSet; - break; + case 1 -> metadata = new int[] { 1, 2, 4, 3 }; + case 2 -> metadata = new int[] { 2, 1, 3, 4 }; + case 3 -> metadata = new int[] { 3, 4, 1, 2 }; + case 4 -> metadata = new int[] { 4, 3, 2, 1 }; } } else if (block instanceof BlockDoor) { - int[] northSet = new int[] { 3, 1, 2, 0 }; - int[] eastSet = new int[] { 0, 2, 3, 1 }; - int[] southSet = new int[] { 1, 3, 0, 2 }; - int[] westSet = new int[] { 2, 0, 1, 3 }; - switch (meta) { - case 0: - metadata = eastSet; - break; - case 1: - metadata = southSet; - break; - case 2: - metadata = westSet; - break; - case 3: - metadata = northSet; - break; + case 0 -> metadata = new int[] { 0, 2, 3, 1 }; + case 1 -> metadata = new int[] { 1, 3, 0, 2 }; + case 2 -> metadata = new int[] { 2, 0, 1, 3 }; + case 3 -> metadata = new int[] { 3, 1, 2, 0 }; } } else if (block instanceof BlockRedstoneComparator) { int div = meta / 4; - int mod = meta % 4; - int[] northSet = new int[] { div * 4, 2 + div * 4, 3 + div * 4, 1 + div * 4 }; // First one: 0 + - int[] eastSet = new int[] { 1 + div * 4, 3 + div * 4, div * 4, 2 + div * 4 }; // Third one: 0 + - int[] southSet = new int[] { 2 + div * 4, div * 4, 1 + div * 4, 3 + div * 4 }; // Second one: 0 + - int[] westSet = new int[] { 3 + div * 4, 1 + div * 4, 2 + div * 4, div * 4 }; // Last one: 0 + - - switch (mod) { - case 0: - metadata = northSet; - break; - case 1: - metadata = eastSet; - break; - case 2: - metadata = southSet; - break; - case 3: - metadata = westSet; - break; + switch (meta % 4) { + case 0 -> metadata = new int[] { div * 4, 2 + div * 4, 3 + div * 4, 1 + div * 4 }; + case 1 -> metadata = new int[] { 1 + div * 4, 3 + div * 4, div * 4, 2 + div * 4 }; + case 2 -> metadata = new int[] { 2 + div * 4, div * 4, 1 + div * 4, 3 + div * 4 }; + case 3 -> metadata = new int[] { 3 + div * 4, 1 + div * 4, 2 + div * 4, div * 4 }; } } else if (block instanceof BlockRedstoneRepeater) { int div = meta / 4; - int mod = meta % 4; - int[] northSet = new int[] { div * 4, 2 + div * 4, 3 + div * 4, 1 + div * 4 }; // First one: 0 + - int[] eastSet = new int[] { 1 + div * 4, 3 + div * 4, div * 4, 2 + div * 4 }; // Third one: 0 + - int[] southSet = new int[] { 2 + div * 4, div * 4, 1 + div * 4, 3 + div * 4 }; // Second one: 0 + - int[] westSet = new int[] { 3 + div * 4, 1 + div * 4, 2 + div * 4, div * 4 }; // Last one: 0 + - - switch (mod) { - case 0: - metadata = northSet; - break; - case 1: - metadata = eastSet; - break; - case 2: - metadata = southSet; - break; - case 3: - metadata = westSet; - break; + switch (meta % 4) { + case 0 -> metadata = new int[] { div * 4, 2 + div * 4, 3 + div * 4, 1 + div * 4 }; + case 1 -> metadata = new int[] { 1 + div * 4, 3 + div * 4, div * 4, 2 + div * 4 }; + case 2 -> metadata = new int[] { 2 + div * 4, div * 4, 1 + div * 4, 3 + div * 4 }; + case 3 -> metadata = new int[] { 3 + div * 4, 1 + div * 4, 2 + div * 4, div * 4 }; } } } @@ -250,18 +143,13 @@ public int getMetaForDirection(ForgeDirection dir) { return 0; } - switch (dir) { - case NORTH: - return metadata[0]; - case SOUTH: - return metadata[1]; - case WEST: - return metadata[2]; - case EAST: - return metadata[3]; - default: - return 0; - } + return switch (dir) { + case NORTH -> metadata[0]; + case SOUTH -> metadata[1]; + case WEST -> metadata[2]; + case EAST -> metadata[3]; + default -> 0; + }; } public void buildAtIndex(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, @@ -272,29 +160,26 @@ public void buildAtIndex(TEDemonPortal teDemonPortal, World world, int xCoord, i } Int3 position = positions.get(index); - int xOff = position.xCoord; - int yOff = position.yCoord; - int zOff = position.zCoord; + int xOff = position.x(); + int yOff = position.y(); + int zOff = position.z(); int meta = this.getMetaForDirection(dir); switch (dir) { - case NORTH: - break; - case SOUTH: + case SOUTH -> { xOff *= -1; zOff *= -1; - break; - case WEST: + } + case WEST -> { int temp = zOff; zOff = xOff * -1; xOff = temp; - break; - case EAST: + } + case EAST -> { int temp2 = zOff * -1; zOff = xOff; xOff = temp2; - break; - default: + } } world.setBlock(xCoord + xOff, yCoord + yOff, zCoord + zOff, block, meta, 3); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/BuildingSchematic.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/BuildingSchematic.java index e6ba8fd735..c8a6a088ac 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/BuildingSchematic.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/BuildingSchematic.java @@ -13,13 +13,9 @@ public class BuildingSchematic { - public String name; - public int doorX; - public int doorZ; - public int doorY; - public int buildingTier; - public int buildingType; - public List blockList; + public final String name; + public final int buildingType = DemonBuilding.BUILDING_HOUSE; + public final List blockList = new ArrayList<>(); public BuildingSchematic() { this(""); @@ -27,12 +23,6 @@ public BuildingSchematic() { public BuildingSchematic(String name) { this.name = name; - blockList = new ArrayList(); - this.doorX = 0; - this.doorZ = 0; - this.doorY = 0; - this.buildingTier = 0; - this.buildingType = DemonBuilding.BUILDING_HOUSE; } public void addBlockWithMeta(Block block, int meta, int xOffset, int yOffset, int zOffset) { @@ -51,7 +41,7 @@ public void addBlockWithMeta(Block block, int meta, int xOffset, int yOffset, in public void buildAll(TEDemonPortal teDemonPortal, World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir, boolean populateInventories) { for (BlockSet set : blockList) { - set.buildAll(teDemonPortal, world, xCoord, yCoord, zCoord, dir, populateInventories, this.buildingTier); + set.buildAll(teDemonPortal, world, xCoord, yCoord, zCoord, dir, populateInventories, 0); } } @@ -60,8 +50,8 @@ public GridSpaceHolder createGSH() { for (BlockSet set : blockList) { for (Int3 coords : set.getPositions()) { - int gridX = (int) ((coords.xCoord + 2 * Math.signum(coords.xCoord)) / 5); - int gridZ = (int) ((coords.zCoord + 2 * Math.signum(coords.zCoord)) / 5); + int gridX = (int) ((coords.x() + 2 * Math.signum(coords.x())) / 5); + int gridZ = (int) ((coords.z() + 2 * Math.signum(coords.z())) / 5); holder.setGridSpace(gridX, gridZ, new GridSpace(GridSpace.HOUSE, 0)); } @@ -70,37 +60,29 @@ public GridSpaceHolder createGSH() { return holder; } - public Int3 getGridSpotOfDoor() { - int gridX = (int) ((doorX + 2 * Math.signum(doorX)) / 5); - int gridZ = (int) ((doorZ + 2 * Math.signum(doorZ)) / 5); - - return new Int3(gridX, doorY, gridZ); - } - public List getGriddedPositions(ForgeDirection dir) { - List positionList = new ArrayList(); + List positionList = new ArrayList<>(); for (BlockSet blockSet : blockList) { for (Int3 pos : blockSet.getPositions()) { - int xOff = pos.xCoord; - int zOff = pos.zCoord; + int xOff = pos.x(); + int zOff = pos.z(); switch (dir) { - case SOUTH: + case SOUTH -> { xOff *= -1; zOff *= -1; - break; - case WEST: + } + case WEST -> { int temp = zOff; zOff = xOff * -1; xOff = temp; - break; - case EAST: + } + case EAST -> { int temp2 = zOff * -1; zOff = xOff; xOff = temp2; - break; - default: + } } Int3 nextPos = new Int3(xOff, 0, zOff); @@ -121,9 +103,9 @@ public void destroyAllInField(World world, int xCoord, int yCoord, int zCoord, F for (int i = this.getMinY(); i <= this.getMaxY(); i++) { for (Int3 pos : positionList) { - Block block = world.getBlock(xCoord + pos.xCoord, yCoord + i, zCoord + pos.zCoord); + Block block = world.getBlock(xCoord + pos.x(), yCoord + i, zCoord + pos.z()); if (block != ModBlocks.blockDemonPortal) { - world.setBlockToAir(xCoord + pos.xCoord, yCoord + i, zCoord + pos.zCoord); + world.setBlockToAir(xCoord + pos.x(), yCoord + i, zCoord + pos.z()); } } } @@ -133,8 +115,8 @@ public int getMinY() { int min = 0; for (BlockSet set : blockList) { for (Int3 pos : set.getPositions()) { - if (pos.yCoord < min) { - min = pos.yCoord; + if (pos.y() < min) { + min = pos.y(); } } } @@ -146,8 +128,8 @@ public int getMaxY() { int max = 0; for (BlockSet set : blockList) { for (Int3 pos : set.getPositions()) { - if (pos.yCoord > max) { - max = pos.yCoord; + if (pos.y() > max) { + max = pos.y(); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/DemonBuilding.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/DemonBuilding.java index db85f532f2..a29f8233b9 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/DemonBuilding.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/DemonBuilding.java @@ -20,9 +20,9 @@ public class DemonBuilding { public DemonBuilding(BuildingSchematic schematic) { this.schematic = schematic; this.buildingType = schematic.buildingType; - this.buildingTier = schematic.buildingTier; + this.buildingTier = 0; this.area = this.createGSHForSchematic(schematic); - this.doorGridSpace = schematic.getGridSpotOfDoor(); + this.doorGridSpace = new Int3(0, 0, 0); } public String getName() { @@ -53,34 +53,18 @@ public GridSpaceHolder createGSHForSchematic(BuildingSchematic scheme) { } public Int3 getDoorSpace(ForgeDirection dir) { - int x; - int z; - switch (dir) { - case SOUTH: - x = -doorGridSpace.xCoord; - z = -doorGridSpace.zCoord; - break; - case WEST: - x = doorGridSpace.zCoord; - z = -doorGridSpace.xCoord; - break; - case EAST: - x = -doorGridSpace.zCoord; - z = doorGridSpace.xCoord; - break; - default: - x = doorGridSpace.xCoord; - z = doorGridSpace.zCoord; - break; - } - - return new Int3(x, doorGridSpace.yCoord, z); + return switch (dir) { + case SOUTH -> new Int3(-doorGridSpace.x(), doorGridSpace.y(), -doorGridSpace.z()); + case WEST -> new Int3(doorGridSpace.z(), doorGridSpace.y(), -doorGridSpace.x()); + case EAST -> new Int3(-doorGridSpace.z(), doorGridSpace.y(), doorGridSpace.x()); + default -> new Int3(doorGridSpace.x(), doorGridSpace.y(), doorGridSpace.z()); + }; } public Int3 getGridOffsetFromRoad(ForgeDirection sideOfRoad, int yLevel) { Int3 doorSpace = this.getDoorSpace(sideOfRoad); - int x = doorSpace.xCoord; - int z = doorSpace.zCoord; + int x = doorSpace.x(); + int z = doorSpace.z(); switch (sideOfRoad) { case SOUTH: diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/DemonCrosspath.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/DemonCrosspath.java index 09b1ed74b4..30a0c2e25c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/DemonCrosspath.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/DemonCrosspath.java @@ -2,17 +2,7 @@ import net.minecraft.world.World; -public class DemonCrosspath { - - private int xCoord; - private int yLevel; - private int zCoord; - - public DemonCrosspath(int xCoord, int yLevel, int zCoord) { - this.xCoord = xCoord; - this.yLevel = yLevel; - this.zCoord = zCoord; - } +public record DemonCrosspath(int xCoord, int yLevel, int zCoord) { public void createCrosspath(World world) {} } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/DemonVillagePath.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/DemonVillagePath.java index 5035069d32..53a4b37728 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/DemonVillagePath.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/DemonVillagePath.java @@ -1,5 +1,7 @@ package WayofTime.alchemicalWizardry.common.demonVillage; +import java.util.Objects; + import net.minecraft.block.Block; import net.minecraft.block.BlockFlower; import net.minecraft.block.material.Material; @@ -24,10 +26,10 @@ public class DemonVillagePath { public static boolean tunnelIfObstructed = false; public static boolean createBridgeInAirIfObstructed = false; - public DemonVillagePath(int xi, int yi, int zi, ForgeDirection dir, int length) { - this.xPos = xi; - this.yPos = yi; - this.zPos = zi; + public DemonVillagePath(int xPos, int yPos, int zPos, ForgeDirection dir, int length) { + this.xPos = xPos; + this.yPos = yPos; + this.zPos = zPos; this.dir = dir; this.length = length; } @@ -63,7 +65,7 @@ public Int3AndBool constructFullPath(TEDemonPortal portal, World world, int clea length + 2 * rad, true), value); - if (TEDemonPortal.printDebug) System.out.println("" + (length + 2 * rad) + ", " + value + ""); + if (TEDemonPortal.printDebug) System.out.println((length + 2 * rad) + ", " + value); } Int3 position = new Int3(xi, finalYPos, zi); @@ -73,7 +75,7 @@ public Int3AndBool constructFullPath(TEDemonPortal portal, World world, int clea return new Int3AndBool(position, bool); } - public class Int3AndBool { + public static class Int3AndBool { public Int3 coords; public boolean bool; @@ -84,20 +86,7 @@ public Int3AndBool(Int3 int3, boolean bool) { } } - /** - * - * @param portal - * @param world - * @param clearance - * @param xi - * @param yi - * @param zi - * @param dir - * @param length - * @param doConstruct - * @return length if doConstruct, yi if !doConstruct - */ - public int constructPartialPath(TEDemonPortal portal, World world, int clearance, int xi, int yi, int zi, + public int constructPartialPath(TEDemonPortal portal, World world, int clearance, int x, int y, int z, ForgeDirection dir, int length, boolean doConstruct) { for (int i = 0; i < length; i++) { int xOffset = i * dir.offsetX; @@ -108,46 +97,46 @@ public int constructPartialPath(TEDemonPortal portal, World world, int clearance for (int yOffset = 0; yOffset <= clearance; yOffset++) { int sign = 1; - Block block1 = world.getBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset); - Block highBlock1 = world.getBlock(xi + xOffset, yi + sign * yOffset + 1, zi + zOffset); + Block block1 = world.getBlock(x + xOffset, y + sign * yOffset, z + zOffset); + Block highBlock1 = world.getBlock(x + xOffset, y + sign * yOffset + 1, z + zOffset); if ((this.forceReplaceBlock(block1)) - || (!block1.isReplaceable(world, xi + xOffset, yi + sign * yOffset, zi + zOffset) + || (!block1.isReplaceable(world, x + xOffset, y + sign * yOffset, z + zOffset) && this.isBlockReplaceable(block1)) && (this.forceCanTunnelUnder(highBlock1) || highBlock1 - .isReplaceable(world, xi + xOffset, yi + sign * yOffset + 1, zi + zOffset))) { + .isReplaceable(world, x + xOffset, y + sign * yOffset + 1, z + zOffset))) { if (doConstruct) { world.setBlock( - xi + xOffset, - yi + sign * yOffset, - zi + zOffset, + x + xOffset, + y + sign * yOffset, + z + zOffset, portal.getRoadBlock(), portal.getRoadMeta(), 3); } - yi += sign * yOffset; + y += sign * yOffset; completed = true; break; } else if (canGoDown) { sign = -1; - Block block2 = world.getBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset); - Block highBlock2 = world.getBlock(xi + xOffset, yi + sign * yOffset + 1, zi + zOffset); - - if ((this.forceReplaceBlock(block2)) || (!block2 - .isReplaceable(world, xi + xOffset, yi + sign * yOffset, zi + zOffset) - && this.isBlockReplaceable(block2)) - && (this.forceCanTunnelUnder(highBlock2) || highBlock2 - .isReplaceable(world, xi + xOffset, yi + sign * yOffset + 1, zi + zOffset))) { + Block block2 = world.getBlock(x + xOffset, y + sign * yOffset, z + zOffset); + Block highBlock2 = world.getBlock(x + xOffset, y + sign * yOffset + 1, z + zOffset); + + if ((this.forceReplaceBlock(block2)) + || (!block2.isReplaceable(world, x + xOffset, y + sign * yOffset, z + zOffset) + && this.isBlockReplaceable(block2)) + && (this.forceCanTunnelUnder(highBlock2) || highBlock2 + .isReplaceable(world, x + xOffset, y + sign * yOffset + 1, z + zOffset))) { if (doConstruct) { world.setBlock( - xi + xOffset, - yi + sign * yOffset, - zi + zOffset, + x + xOffset, + y + sign * yOffset, + z + zOffset, portal.getRoadBlock(), portal.getRoadMeta(), 3); } - yi += sign * yOffset; + y += sign * yOffset; completed = true; break; } @@ -157,98 +146,40 @@ public int constructPartialPath(TEDemonPortal portal, World world, int clearance if (!completed) { boolean returnAmount = true; if (createBridgeInAirIfObstructed) { - Block block1 = world.getBlock(xi + xOffset, yi, zi + zOffset); + Block block1 = world.getBlock(x + xOffset, y, z + zOffset); - if (block1.isReplaceable(world, xi + xOffset, yi, zi + zOffset) || !this.isBlockReplaceable(block1) + if (block1.isReplaceable(world, x + xOffset, y, z + zOffset) || !this.isBlockReplaceable(block1) || !this.forceReplaceBlock(block1)) { returnAmount = false; if (doConstruct) { - world.setBlock( - xi + xOffset, - yi, - zi + zOffset, - portal.getRoadBlock(), - portal.getRoadMeta(), - 3); + world.setBlock(x + xOffset, y, z + zOffset, portal.getRoadBlock(), portal.getRoadMeta(), 3); } - } else { - returnAmount = true; } } else if (tunnelIfObstructed) { - Block block1 = world.getBlock(xi + xOffset, yi, zi + zOffset); + Block block1 = world.getBlock(x + xOffset, y, z + zOffset); - if (!block1.isReplaceable(world, xi + xOffset, yi, zi + zOffset) || this.isBlockReplaceable(block1) + if (!block1.isReplaceable(world, x + xOffset, y, z + zOffset) || this.isBlockReplaceable(block1) || !this.forceReplaceBlock(block1)) { returnAmount = false; if (doConstruct) { - world.setBlock( - xi + xOffset, - yi, - zi + zOffset, - portal.getRoadBlock(), - portal.getRoadMeta(), - 3); - world.setBlockToAir(xi + xOffset, yi + 1, zi + zOffset); - world.setBlockToAir(xi + xOffset, yi + 2, zi + zOffset); - world.setBlockToAir(xi + xOffset, yi + 3, zi + zOffset); + world.setBlock(x + xOffset, y, z + zOffset, portal.getRoadBlock(), portal.getRoadMeta(), 3); + world.setBlockToAir(x + xOffset, y + 1, z + zOffset); + world.setBlockToAir(x + xOffset, y + 2, z + zOffset); + world.setBlockToAir(x + xOffset, y + 3, z + zOffset); } - } else { - returnAmount = true; } } if (returnAmount) { - return doConstruct ? i : yi; - } - } - } - - return doConstruct ? length : yi; - } - - public Int3 getFinalLocation(World world, int clearance) { - int xi = xPos; - int yi = yPos; - int zi = zPos; - - for (int i = 0; i < length; i++) { - int xOffset = i * dir.offsetX; - int zOffset = i * dir.offsetZ; - - for (int yOffset = 0; yOffset <= clearance; yOffset++) { - int sign = 1; - - Block block1 = world.getBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset); - Block highBlock1 = world.getBlock(xi + xOffset, yi + sign * yOffset + 1, zi + zOffset); - - if ((this.forceReplaceBlock(block1)) - || (!block1.isReplaceable(world, xi + xOffset, yi + sign * yOffset, zi + zOffset) - && this.isBlockReplaceable(block1)) - && (this.forceCanTunnelUnder(highBlock1) || highBlock1 - .isReplaceable(world, xi + xOffset, yi + sign * yOffset + 1, zi + zOffset))) { - yi += sign * yOffset; - break; - } else { - sign = -1; - Block block2 = world.getBlock(xi + xOffset, yi + sign * yOffset, zi + zOffset); - Block highBlock2 = world.getBlock(xi + xOffset, yi + sign * yOffset + 1, zi + zOffset); - - if ((this.forceReplaceBlock(block2)) || (!block2 - .isReplaceable(world, xi + xOffset, yi + sign * yOffset, zi + zOffset) - && this.isBlockReplaceable(block2)) - && (this.forceCanTunnelUnder(highBlock2) || highBlock2 - .isReplaceable(world, xi + xOffset, yi + sign * yOffset + 1, zi + zOffset))) { - yi += sign * yOffset; - break; - } + return doConstruct ? i : y; } } } - return new Int3(xi, yi, zi); + return doConstruct ? length : y; } public int getRoadRadius() { @@ -267,4 +198,59 @@ public boolean forceReplaceBlock(Block block) { public boolean forceCanTunnelUnder(Block block) { return block instanceof BlockFlower || block == Blocks.double_plant; } + + public int xPos() { + return xPos; + } + + public int yPos() { + return yPos; + } + + public int zPos() { + return zPos; + } + + public ForgeDirection dir() { + return dir; + } + + public int length() { + return length; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) return true; + if (!(obj instanceof DemonVillagePath that)) return false; + return this.xPos == that.xPos && this.yPos == that.yPos + && this.zPos == that.zPos + && Objects.equals(this.dir, that.dir) + && this.length == that.length; + } + + @Override + public int hashCode() { + return Objects.hash(xPos, yPos, zPos, dir, length); + } + + @Override + public String toString() { + return "DemonVillagePath[" + "xPos=" + + xPos + + ", " + + "yPos=" + + yPos + + ", " + + "zPos=" + + zPos + + ", " + + "dir=" + + dir + + ", " + + "length=" + + length + + ']'; + } + } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/GridSpace.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/GridSpace.java index f3478d806a..9554dc3b65 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/GridSpace.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/GridSpace.java @@ -6,13 +6,12 @@ public class GridSpace { public static final int EMPTY = 0; public static final int MAIN_PORTAL = 1; - public static final int MINI_PORTAL = 2; public static final int ROAD = 3; public static final int CROSSROAD = 4; public static final int HOUSE = 5; - private int yLevel; - private int type; + private final int yLevel; + private final int type; public GridSpace() { this(EMPTY, -1); @@ -23,22 +22,10 @@ public GridSpace(int type, int yLevel) { this.yLevel = yLevel; } - public int getGridType() { - return this.type; - } - - public void setGridType(int type) { - this.type = type; - } - public int getYLevel() { return this.yLevel; } - public void setYLevel(int yLevel) { - this.yLevel = yLevel; - } - public boolean isEmpty() { return type == EMPTY; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/GridSpaceHolder.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/GridSpaceHolder.java index 1ca0269075..a3b53215f7 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/GridSpaceHolder.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/GridSpaceHolder.java @@ -28,9 +28,8 @@ public void expandAreaInNegX() { } for (int i = 0; i <= negXRadius + posXRadius; i++) { - for (int j = 0; j <= negZRadius + posZRadius; j++) { - newGrid[i + 1][j] = area[i][j]; - } + if (negZRadius + posZRadius + 1 >= 0) + System.arraycopy(area[i], 0, newGrid[i + 1], 0, negZRadius + posZRadius + 1); } area = newGrid; @@ -45,9 +44,8 @@ public void expandAreaInPosX() { } for (int i = 0; i <= negXRadius + posXRadius; i++) { - for (int j = 0; j <= negZRadius + posZRadius; j++) { - newGrid[i][j] = area[i][j]; - } + if (negZRadius + posZRadius + 1 >= 0) + System.arraycopy(area[i], 0, newGrid[i], 0, negZRadius + posZRadius + 1); } area = newGrid; @@ -62,9 +60,8 @@ public void expandAreaInNegZ() { } for (int i = 0; i <= negXRadius + posXRadius; i++) { - for (int j = 0; j <= negZRadius + posZRadius; j++) { - newGrid[i][j + 1] = area[i][j]; - } + if (negZRadius + posZRadius + 1 >= 0) + System.arraycopy(area[i], 0, newGrid[i], 1, negZRadius + posZRadius + 1); } area = newGrid; @@ -79,9 +76,8 @@ public void expandAreaInPosZ() { } for (int i = 0; i <= negXRadius + posXRadius; i++) { - for (int j = 0; j <= negZRadius + posZRadius; j++) { - newGrid[i][j] = area[i][j]; - } + if (negZRadius + posZRadius + 1 >= 0) + System.arraycopy(area[i], 0, newGrid[i], 0, negZRadius + posZRadius + 1); } area = newGrid; @@ -117,13 +113,11 @@ public void setGridSpace(int x, int z, GridSpace space) { public boolean doesContainAll(GridSpaceHolder master, int xInit, int zInit, ForgeDirection dir) { if (master != null) { if (TEDemonPortal.printDebug) AlchemicalWizardry.logger.info( - "negXRadius: " + negXRadius - + " posXRadius: " - + posXRadius - + " negZRadius: " - + negZRadius - + " posZRadius: " - + posZRadius); + "negXRadius: {} posXRadius: {} negZRadius: {} posZRadius: {}", + negXRadius, + posXRadius, + negZRadius, + posZRadius); for (int i = -negXRadius; i <= posXRadius; i++) { for (int j = -negZRadius; j <= posZRadius; j++) { GridSpace thisSpace = this.getGridSpace(i, j); @@ -131,29 +125,28 @@ public boolean doesContainAll(GridSpaceHolder master, int xInit, int zInit, Forg continue; } - if (TEDemonPortal.printDebug) AlchemicalWizardry.logger.info("x: " + i + " z: " + j); + if (TEDemonPortal.printDebug) AlchemicalWizardry.logger.info("x: {} z: {}", i, j); int xOff; - int zOff; - - switch (dir) { - case SOUTH: + int zOff = switch (dir) { + case SOUTH -> { xOff = -i; - zOff = -j; - break; - case WEST: + yield -j; + } + case WEST -> { xOff = j; - zOff = -i; - break; - case EAST: + yield -i; + } + case EAST -> { xOff = -j; - zOff = i; - break; - default: + yield i; + } + default -> { xOff = i; - zOff = j; - break; - } + yield j; + } + }; + if (!master.getGridSpace(xInit + xOff, zInit + zOff).isEmpty()) { return false; } @@ -166,8 +159,7 @@ public boolean doesContainAll(GridSpaceHolder master, int xInit, int zInit, Forg public void setAllGridSpaces(int xInit, int zInit, int yLevel, ForgeDirection dir, int type, GridSpaceHolder master) { - if (TEDemonPortal.printDebug) - AlchemicalWizardry.logger.info("Grid space selected: (" + xInit + "," + zInit + ")"); + if (TEDemonPortal.printDebug) AlchemicalWizardry.logger.info("Grid space selected: ({},{})", xInit, zInit); if (master != null) { for (int i = -negXRadius; i <= posXRadius; i++) { for (int j = -negZRadius; j <= posZRadius; j++) { @@ -177,29 +169,27 @@ public void setAllGridSpaces(int xInit, int zInit, int yLevel, ForgeDirection di } int xOff; - int zOff; - - switch (dir) { - case SOUTH: + int zOff = switch (dir) { + case SOUTH -> { xOff = -i; - zOff = -j; - break; - case WEST: + yield -j; + } + case WEST -> { xOff = j; - zOff = -i; - break; - case EAST: + yield -i; + } + case EAST -> { xOff = -j; - zOff = i; - break; - default: + yield i; + } + default -> { xOff = i; - zOff = j; - break; - } + yield j; + } + }; if (TEDemonPortal.printDebug) - AlchemicalWizardry.logger.info("Grid space (" + (xInit + xOff) + "," + (zInit + zOff) + ")"); + AlchemicalWizardry.logger.info("Grid space ({},{})", xInit + xOff, zInit + zOff); master.setGridSpace(xInit + xOff, zInit + zOff, new GridSpace(type, yLevel)); } @@ -216,26 +206,24 @@ public void destroyAllInGridSpaces(World world, int xCoord, int yCoord, int zCoo } int xOff; - int zOff; - - switch (dir) { - case SOUTH: + int zOff = switch (dir) { + case SOUTH -> { xOff = -i; - zOff = -j; - break; - case WEST: + yield -j; + } + case WEST -> { xOff = j; - zOff = -i; - break; - case EAST: + yield -i; + } + case EAST -> { xOff = -j; - zOff = i; - break; - default: + yield i; + } + default -> { xOff = i; - zOff = j; - break; - } + yield j; + } + }; for (int l = -2; l <= 2; l++) { for (int m = -2; m <= 2; m++) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/TileBlockSet.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/TileBlockSet.java deleted file mode 100644 index a529b67ed2..0000000000 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/TileBlockSet.java +++ /dev/null @@ -1,8 +0,0 @@ -package WayofTime.alchemicalWizardry.common.demonVillage; - -import net.minecraft.nbt.NBTTagCompound; - -public class TileBlockSet extends BlockSet { - - public NBTTagCompound tag; -} diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/ai/EntityAIOccasionalRangedAttack.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/ai/EntityAIOccasionalRangedAttack.java index d2dac20d87..10a95be77c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/ai/EntityAIOccasionalRangedAttack.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/ai/EntityAIOccasionalRangedAttack.java @@ -19,15 +19,15 @@ public class EntityAIOccasionalRangedAttack extends EntityAIBase { */ private int rangedAttackTime; - private double entityMoveSpeed; + private final double entityMoveSpeed; private int field_75318_f; - private int field_96561_g; + private final int field_96561_g; /** The maximum time the AI has to wait before peforming another ranged attack. */ - private int maxRangedAttackTime; + private final int maxRangedAttackTime; - private float field_96562_i; - private float field_82642_h; - private double range; + private final float field_96562_i; + private final float field_82642_h; + private final double range; public EntityAIOccasionalRangedAttack(IOccasionalRangedAttackMob p_i1649_1_, double p_i1649_2_, int p_i1649_4_, float p_i1649_5_, double range) { @@ -56,6 +56,7 @@ public EntityAIOccasionalRangedAttack(IOccasionalRangedAttackMob p_i1650_1_, dou /** * Returns whether the EntityAIBase should begin execution. */ + @Override public boolean shouldExecute() { EntityLivingBase entitylivingbase = this.entityHost.getAttackTarget(); @@ -72,6 +73,7 @@ public boolean shouldExecute() { /** * Returns whether an in-progress EntityAIBase should continue executing */ + @Override public boolean continueExecuting() { return this.shouldExecute() || !this.entityHost.getNavigator().noPath() && this.rangedAttackEntityHost.shouldUseRangedAttack(); @@ -91,6 +93,7 @@ public boolean isInRange(EntityLivingBase target) { /** * Resets the task */ + @Override public void resetTask() { this.attackTarget = null; this.field_75318_f = 0; @@ -100,6 +103,7 @@ public void resetTask() { /** * Updates the task */ + @Override public void updateTask() { double d0 = this.entityHost .getDistanceSq(this.attackTarget.posX, this.attackTarget.boundingBox.minY, this.attackTarget.posZ); @@ -126,15 +130,8 @@ public void updateTask() { } f = MathHelper.sqrt_double(d0) / this.field_96562_i; - float f1 = f; - if (f < 0.1F) { - f1 = 0.1F; - } - - if (f1 > 1.0F) { - f1 = 1.0F; - } + float f1 = Math.min(1.0F, Math.max(f, 0.1F)); this.rangedAttackEntityHost.attackEntityWithRangedAttack(this.attackTarget, f1); this.rangedAttackTime = MathHelper.floor_float( diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/ai/EntityDemonAIHurtByTarget.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/ai/EntityDemonAIHurtByTarget.java index c9b2db9371..b1083d1486 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/ai/EntityDemonAIHurtByTarget.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/ai/EntityDemonAIHurtByTarget.java @@ -26,7 +26,7 @@ public void startExecuting() { } TileEntity portal = this.taskOwner.worldObj - .getTileEntity(portalPosition.xCoord, portalPosition.yCoord, portalPosition.zCoord); + .getTileEntity(portalPosition.x(), portalPosition.y(), portalPosition.z()); if ((this.taskOwner.getAITarget() instanceof IHoardDemon && portalPosition.equals(((IHoardDemon) this.taskOwner.getAITarget()).getPortalLocation()))) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/DemonPacketMinorGrunt.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/DemonPacketMinorGrunt.java index afaf5b2788..e11219d7a9 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/DemonPacketMinorGrunt.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/DemonPacketMinorGrunt.java @@ -29,48 +29,43 @@ public float getRelativeChance(DemonType type, int tier, boolean spawnGuardian) @Override public int summonDemons(TEDemonPortal teDemonPortal, World world, int x, int y, int z, DemonType type, int tier, boolean spawnGuardian) { - EntityMinorDemonGrunt entity; - - { - switch (type) { - case FIRE: - if (spawnGuardian) { - entity = new EntityMinorDemonGruntGuardianFire(world); - } else { - entity = new EntityMinorDemonGruntFire(world); - } - break; - case ICE: - if (spawnGuardian) { - entity = new EntityMinorDemonGruntGuardianIce(world); - } else { - entity = new EntityMinorDemonGruntIce(world); - } - break; - case EARTH: - if (spawnGuardian) { - entity = new EntityMinorDemonGruntGuardianEarth(world); - } else { - entity = new EntityMinorDemonGruntEarth(world); - } - break; - case WIND: - if (spawnGuardian) { - entity = new EntityMinorDemonGruntGuardianWind(world); - } else { - entity = new EntityMinorDemonGruntWind(world); - } - break; - case NORMAL: - default: - if (spawnGuardian) { - entity = new EntityMinorDemonGruntGuardian(world); - } else { - entity = new EntityMinorDemonGrunt(world); - } - break; + EntityMinorDemonGrunt entity = switch (type) { + case FIRE -> { + if (spawnGuardian) { + yield new EntityMinorDemonGruntGuardianFire(world); + } else { + yield new EntityMinorDemonGruntFire(world); + } + } + case ICE -> { + if (spawnGuardian) { + yield new EntityMinorDemonGruntGuardianIce(world); + } else { + yield new EntityMinorDemonGruntIce(world); + } + } + case EARTH -> { + if (spawnGuardian) { + yield new EntityMinorDemonGruntGuardianEarth(world); + } else { + yield new EntityMinorDemonGruntEarth(world); + } + } + case WIND -> { + if (spawnGuardian) { + yield new EntityMinorDemonGruntGuardianWind(world); + } else { + yield new EntityMinorDemonGruntWind(world); + } + } + default -> { + if (spawnGuardian) { + yield new EntityMinorDemonGruntGuardian(world); + } else { + yield new EntityMinorDemonGrunt(world); + } } - } + }; entity.setPosition(x, y, z); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/DemonPacketRegistry.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/DemonPacketRegistry.java index 35d81669b5..5dec260a28 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/DemonPacketRegistry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/DemonPacketRegistry.java @@ -10,7 +10,7 @@ public class DemonPacketRegistry { - public static Map packetMap = new HashMap(); + public static Map packetMap = new HashMap<>(); public static boolean registerDemonPacket(String string, DemonHoardPacket packet) { if (!packetMap.containsValue(string) && packet != null) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGrunt.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGrunt.java index eeff9bf8c9..2dddf6489f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGrunt.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGrunt.java @@ -11,12 +11,8 @@ import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; -import net.minecraft.entity.monster.EntityCreeper; -import net.minecraft.entity.monster.EntityGhast; import net.minecraft.entity.passive.EntityAnimal; -import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -34,35 +30,33 @@ import WayofTime.alchemicalWizardry.common.demonVillage.ai.IOccasionalRangedAttackMob; import WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal; import WayofTime.alchemicalWizardry.common.entity.mob.EntityDemon; +import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile; import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile; import WayofTime.alchemicalWizardry.common.rituals.LocalStorageAlphaPact; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class EntityMinorDemonGrunt extends EntityDemon implements IOccasionalRangedAttackMob, IHoardDemon { - private EntityAIOccasionalRangedAttack aiArrowAttack = new EntityAIOccasionalRangedAttack( + private final EntityAIOccasionalRangedAttack aiArrowAttack = new EntityAIOccasionalRangedAttack( this, 1.0D, 40, 40, 15.0F, 5); - private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( + private final EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( this, EntityPlayer.class, 1.2D, false); - - private boolean isAngry = true; private Int3 demonPortal; - private static float maxTamedHealth = 200.0F; - private static float maxUntamedHealth = 200.0F; + private static final float maxTamedHealth = 200.0F; + private static final float maxUntamedHealth = 200.0F; private boolean enthralled = false; - public EntityMinorDemonGrunt(World par1World) { - super(par1World, AlchemicalWizardry.entityMinorDemonGruntID); + public EntityMinorDemonGrunt(World world) { + super(world, AlchemicalWizardry.entityMinorDemonGruntID); this.setSize(0.7F, 1.8F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(1, new EntityAISwimming(this)); @@ -80,50 +74,37 @@ public EntityMinorDemonGrunt(World par1World) { demonPortal = new Int3(0, 0, 0); - if (par1World != null && !par1World.isRemote) { + if (world != null && !world.isRemote) { this.setCombatTask(); } - - // this.isImmuneToFire = true; - } - - public boolean isTameable() { - return false; } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); - // This line affects the speed of the monster - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); - - if (this.isTamed()) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D); } @Override protected void dropFewItems(boolean par1, int par2) { - if (!this.getDoesDropCrystal()) { - ItemStack lifeShardStack = new ItemStack(ModItems.baseItems, 1, 28); - ItemStack soulShardStack = new ItemStack(ModItems.baseItems, 1, 29); + if (this.getDoesDropCrystal()) { + super.dropFewItems(par1, par2); + return; + } + ItemStack lifeShardStack = new ItemStack(ModItems.baseItems, 1, 28); + ItemStack soulShardStack = new ItemStack(ModItems.baseItems, 1, 29); - int dropAmount = 0; + int dropAmount = 0; - for (int i = 0; i <= par2; i++) { - dropAmount += this.worldObj.rand.nextFloat() < 0.6f ? 1 : 0; - } + for (int i = 0; i <= par2; i++) { + dropAmount += this.worldObj.rand.nextFloat() < 0.6f ? 1 : 0; + } - ItemStack drop = this.worldObj.rand.nextBoolean() ? lifeShardStack : soulShardStack; - drop.stackSize = dropAmount; + ItemStack drop = this.worldObj.rand.nextBoolean() ? lifeShardStack : soulShardStack; + drop.stackSize = dropAmount; - if (dropAmount > 0) { - this.entityDropItem(drop, 0.0f); - } - } else { - super.dropFewItems(par1, par2); + if (dropAmount > 0) { + this.entityDropItem(drop, 0.0f); } } @@ -140,52 +121,21 @@ public Int3 getPortalLocation() { /** * Returns true if the newer Entity AI code should be run */ + @Override public boolean isAIEnabled() { return true; } - /** - * Sets the active target the Task system uses for tracking - */ - public void setAttackTarget(EntityLivingBase par1EntityLivingBase) { - super.setAttackTarget(par1EntityLivingBase); - - if (par1EntityLivingBase == null) { - this.setAngry(false); - } else if (!this.isTamed()) { - this.setAngry(true); - } - } - - /** - * main AI tick function, replaces updateEntityActionState - */ - // @Override - // protected void updateAITick() - // { - // this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth())); - // } - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ @Override - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeEntityToNBT(par1NBTTagCompound); - par1NBTTagCompound.setBoolean("Angry", this.isAngry()); - - this.demonPortal.writeToNBT(par1NBTTagCompound); + public void writeEntityToNBT(NBTTagCompound tag) { + super.writeEntityToNBT(tag); + this.demonPortal.writeToNBT(tag); } - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ @Override - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readEntityFromNBT(par1NBTTagCompound); - this.setAngry(par1NBTTagCompound.getBoolean("Angry")); - this.demonPortal = Int3.readFromNBT(par1NBTTagCompound); - + public void readEntityFromNBT(NBTTagCompound tag) { + super.readEntityFromNBT(tag); + this.demonPortal = Int3.readFromNBT(tag); this.setCombatTask(); } @@ -238,16 +188,13 @@ public void onLivingUpdate() { public void onUpdate() { if (!this.enthralled) { TileEntity tile = this.worldObj - .getTileEntity(this.demonPortal.xCoord, this.demonPortal.yCoord, this.demonPortal.zCoord); - if (tile instanceof TEDemonPortal) { - ((TEDemonPortal) tile).enthrallDemon(this); + .getTileEntity(this.demonPortal.x(), this.demonPortal.y(), this.demonPortal.z()); + if (tile instanceof TEDemonPortal portal) { + portal.enthrallDemon(this); this.enthralled = true; - } else if (tile instanceof IMasterRitualStone) { - IMasterRitualStone stone = (IMasterRitualStone) tile; + } else if (tile instanceof IMasterRitualStone stone) { LocalRitualStorage stor = stone.getLocalStorage(); - if (stor instanceof LocalStorageAlphaPact) { - LocalStorageAlphaPact storage = (LocalStorageAlphaPact) stor; - + if (stor instanceof LocalStorageAlphaPact storage) { storage.thrallDemon(this); } } @@ -256,188 +203,45 @@ public void onUpdate() { } @Override - public float getEyeHeight() { - return this.height * 0.8F; - } - - /** - * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently - * use in wolves. - */ - @Override - public int getVerticalFaceSpeed() { - return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); - } - - @Override - public void setTamed(boolean par1) { - super.setTamed(par1); - - if (par1) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } - } - - /** - * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. - */ - @Override - public boolean interact(EntityPlayer par1EntityPlayer) { - ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); - - if (this.isTamed()) { - if (itemstack != null) { - if (itemstack.getItem() instanceof ItemFood) { - ItemFood itemfood = (ItemFood) itemstack.getItem(); - - if (itemfood.isWolfsFavoriteMeat() - && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - this.heal((float) itemfood.func_150905_g(itemstack)); - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory - .setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - return true; - } - } - } - - if (this.getOwner() instanceof EntityPlayer - && SpellHelper.getUsername(par1EntityPlayer) - .equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) - && !this.isBreedingItem(itemstack)) { - if (!this.worldObj.isRemote) { - this.aiSit.setSitting(!this.isSitting()); - this.isJumping = false; - this.setPathToEntity(null); - this.setTarget(null); - this.setAttackTarget(null); - } - - this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting()); - } - } else if (this.isTameable() && itemstack != null - && itemstack.getItem().equals(ModItems.weakBloodOrb) - && !this.isAngry()) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory - .setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - if (!this.worldObj.isRemote) { - if (this.rand.nextInt(1) == 0) { - this.setTamed(true); - this.setPathToEntity(null); - this.setAttackTarget(null); - this.aiSit.setSitting(true); - this.setHealth(maxTamedHealth); - this.func_152115_b(par1EntityPlayer.getUniqueID().toString()); - this.playTameEffect(true); - this.worldObj.setEntityState(this, (byte) 7); - } else { - this.playTameEffect(false); - this.worldObj.setEntityState(this, (byte) 6); - } - } - - return true; - } - - return super.interact(par1EntityPlayer); - } - - public boolean isBreedingItem(ItemStack par1ItemStack) { - return false; - } - - /** - * Determines whether this wolf is angry or not. - */ - public boolean isAngry() { - return this.isAngry; - } - - /** - * Sets whether this wolf is angry or not. - */ - public void setAngry(boolean angry) { - this.isAngry = angry; - } - - /** - * Returns true if the mob is currently able to mate with the specified mob. - */ - @Override - public boolean canMateWith(EntityAnimal par1EntityAnimal) { + public boolean canMateWith(EntityAnimal entityAnimal) { return false; } - /** - * Determines if an entity can be despawned, used on idle far away entities - */ @Override - protected boolean canDespawn() { - // return !this.isTamed() && this.ticksExisted > 2400; - return false; - } - - /** - * A call to determine if this entity should attack the other entity - */ - @Override - public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase) { - if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast)) { - if (par1EntityLivingBase instanceof EntityDemon) { - EntityDemon entitywolf = (EntityDemon) par1EntityLivingBase; - - if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase) { - return false; - } - } - - return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer - && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) - ? false - : !(par1EntityLivingBase instanceof EntityHorse) - || !((EntityHorse) par1EntityLivingBase).isTame(); - } else { + public boolean attackEntityAsMob(Entity entity) { + if (friendlyDemon(entity)) { return false; } + if (!entity.attackEntityFrom(DamageSource.causeMobDamage(this), meleeDamage())) { + return false; + } + causeEffect(entity); + return true; } - @Override - public boolean attackEntityAsMob(Entity par1Entity) { - int i = this.isTamed() ? 20 : 20; + protected void causeEffect(Entity entity) {} - if (par1Entity instanceof IHoardDemon && ((IHoardDemon) par1Entity).isSamePortal(this)) { - return false; - } + protected float meleeDamage() { + return 20f; + } - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); + protected boolean friendlyDemon(Entity entity) { + return entity instanceof IHoardDemon demon && demon.isSamePortal(this); } /** * Attack the specified entity using a ranged attack. */ @Override - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { - if (par1EntityLivingBase instanceof IHoardDemon && ((IHoardDemon) par1EntityLivingBase).isSamePortal(this)) { + public void attackEntityWithRangedAttack(EntityLivingBase entity, float par2) { + if (friendlyDemon(entity)) { return; } - HolyProjectile hol = new HolyProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 15, 600); - this.worldObj.spawnEntityInWorld(hol); + this.worldObj.spawnEntityInWorld(attackProjectile(entity)); + } + + protected EnergyBlastProjectile attackProjectile(EntityLivingBase entity) { + return new HolyProjectile(worldObj, this, entity, 1.8f, 0f, 15, 600); } /** @@ -464,11 +268,19 @@ public boolean thrallDemon(Int3 location) { @Override public boolean isSamePortal(IHoardDemon demon) { Int3 position = demon.getPortalLocation(); - TileEntity portal = worldObj - .getTileEntity(this.demonPortal.xCoord, this.demonPortal.yCoord, this.demonPortal.zCoord); + TileEntity portal = worldObj.getTileEntity(this.demonPortal.x(), this.demonPortal.y(), this.demonPortal.z()); return portal instanceof TEDemonPortal - ? portal == worldObj.getTileEntity(position.xCoord, position.yCoord, position.zCoord) - : false; + && portal == worldObj.getTileEntity(position.x(), position.y(), position.z()); + } + + @Override + protected float maxTamedHealth() { + return maxTamedHealth; + } + + @Override + protected float maxUntamedHealth() { + return maxUntamedHealth; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntEarth.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntEarth.java index 9a7b725d3e..bdf43866ef 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntEarth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntEarth.java @@ -2,49 +2,29 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; -import net.minecraft.util.DamageSource; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; +import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile; import WayofTime.alchemicalWizardry.common.entity.projectile.ExplosionProjectile; public class EntityMinorDemonGruntEarth extends EntityMinorDemonGrunt { - public EntityMinorDemonGruntEarth(World par1World) { - super(par1World); + public EntityMinorDemonGruntEarth(World world) { + super(world); this.setDemonID(AlchemicalWizardry.entityMinorDemonGruntEarthID); } @Override - public boolean attackEntityAsMob(Entity par1Entity) { - int i = this.isTamed() ? 20 : 20; - if (par1Entity instanceof IHoardDemon && ((IHoardDemon) par1Entity).isSamePortal(this)) { - return false; + public void causeEffect(Entity entity) { + if (entity instanceof EntityLivingBase e) { + e.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionHeavyHeartID, 200, 4)); } - - if (par1Entity instanceof EntityLivingBase) { - ((EntityLivingBase) par1Entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 2)); - } - - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } @Override - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { - if (par1EntityLivingBase instanceof IHoardDemon && ((IHoardDemon) par1EntityLivingBase).isSamePortal(this)) { - return; - } - ExplosionProjectile hol = new ExplosionProjectile( - worldObj, - this, - par1EntityLivingBase, - 1.8f, - 0f, - 15, - 600, - false); - this.worldObj.spawnEntityInWorld(hol); + protected EnergyBlastProjectile attackProjectile(EntityLivingBase target) { + return new ExplosionProjectile(worldObj, this, target, 1.8f, 0f, 15, 600, false); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntFire.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntFire.java index aa8bda72a2..1cd0003008 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntFire.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntFire.java @@ -2,38 +2,27 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.DamageSource; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; +import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile; import WayofTime.alchemicalWizardry.common.entity.projectile.FireProjectile; public class EntityMinorDemonGruntFire extends EntityMinorDemonGrunt { - public EntityMinorDemonGruntFire(World par1World) { - super(par1World); + public EntityMinorDemonGruntFire(World world) { + super(world); this.setDemonID(AlchemicalWizardry.entityMinorDemonGruntFireID); this.isImmuneToFire = true; } @Override - public boolean attackEntityAsMob(Entity par1Entity) { - int i = this.isTamed() ? 20 : 20; - if (par1Entity instanceof IHoardDemon && ((IHoardDemon) par1Entity).isSamePortal(this)) { - return false; - } - - par1Entity.setFire(10); - - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); + public void causeEffect(Entity entity) { + entity.setFire(10); } @Override - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { - if (par1EntityLivingBase instanceof IHoardDemon && ((IHoardDemon) par1EntityLivingBase).isSamePortal(this)) { - return; - } - FireProjectile hol = new FireProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 15, 600); - this.worldObj.spawnEntityInWorld(hol); + protected EnergyBlastProjectile attackProjectile(EntityLivingBase target) { + return new FireProjectile(worldObj, this, target, 1.8f, 0f, 15, 600); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardian.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardian.java index eb13bb1214..f7538254b6 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardian.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardian.java @@ -1,40 +1,26 @@ package WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon; -import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.DamageSource; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; +import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile; import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile; public class EntityMinorDemonGruntGuardian extends EntityMinorDemonGrunt { - public EntityMinorDemonGruntGuardian(World par1World) { - super(par1World); + public EntityMinorDemonGruntGuardian(World world) { + super(world); this.setDemonID(AlchemicalWizardry.entityMinorDemonGruntGuardianID); } @Override - public boolean attackEntityAsMob(Entity par1Entity) { - int i = this.isTamed() ? 25 : 25; - - if (par1Entity instanceof IHoardDemon && ((IHoardDemon) par1Entity).isSamePortal(this)) { - return false; - } - - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); + protected EnergyBlastProjectile attackProjectile(EntityLivingBase target) { + return new HolyProjectile(worldObj, this, target, 1.8f, 0f, 20, 600); } - /** - * Attack the specified entity using a ranged attack. - */ @Override - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { - if (par1EntityLivingBase instanceof IHoardDemon && ((IHoardDemon) par1EntityLivingBase).isSamePortal(this)) { - return; - } - HolyProjectile hol = new HolyProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 20, 600); - this.worldObj.spawnEntityInWorld(hol); + protected float meleeDamage() { + return 25f; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianEarth.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianEarth.java index 8469ac0d0f..22b9686686 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianEarth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianEarth.java @@ -2,53 +2,29 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; -import net.minecraft.util.DamageSource; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; +import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile; import WayofTime.alchemicalWizardry.common.entity.projectile.ExplosionProjectile; public class EntityMinorDemonGruntGuardianEarth extends EntityMinorDemonGruntGuardian { - public EntityMinorDemonGruntGuardianEarth(World par1World) { - super(par1World); + public EntityMinorDemonGruntGuardianEarth(World world) { + super(world); this.setDemonID(AlchemicalWizardry.entityMinorDemonGruntGuardianEarthID); } @Override - public boolean attackEntityAsMob(Entity par1Entity) { - int i = this.isTamed() ? 25 : 25; - - if (par1Entity instanceof IHoardDemon && ((IHoardDemon) par1Entity).isSamePortal(this)) { - return false; - } - - if (par1Entity instanceof EntityLivingBase) { - ((EntityLivingBase) par1Entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 4)); + public void causeEffect(Entity entity) { + if (entity instanceof EntityLivingBase e) { + e.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionHeavyHeartID, 200, 4)); } - - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } - /** - * Attack the specified entity using a ranged attack. - */ @Override - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { - if (par1EntityLivingBase instanceof IHoardDemon && ((IHoardDemon) par1EntityLivingBase).isSamePortal(this)) { - return; - } - ExplosionProjectile hol = new ExplosionProjectile( - worldObj, - this, - par1EntityLivingBase, - 1.8f, - 0f, - 20, - 600, - false); - this.worldObj.spawnEntityInWorld(hol); + protected EnergyBlastProjectile attackProjectile(EntityLivingBase target) { + return new ExplosionProjectile(worldObj, this, target, 1.8f, 0f, 20, 600, false); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianFire.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianFire.java index ec7293a3dd..9d8077cb47 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianFire.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianFire.java @@ -2,42 +2,27 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.DamageSource; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; +import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile; import WayofTime.alchemicalWizardry.common.entity.projectile.FireProjectile; public class EntityMinorDemonGruntGuardianFire extends EntityMinorDemonGruntGuardian { - public EntityMinorDemonGruntGuardianFire(World par1World) { - super(par1World); + public EntityMinorDemonGruntGuardianFire(World world) { + super(world); this.setDemonID(AlchemicalWizardry.entityMinorDemonGruntGuardianFireID); this.isImmuneToFire = true; } @Override - public boolean attackEntityAsMob(Entity par1Entity) { - int i = this.isTamed() ? 25 : 25; - - if (par1Entity instanceof IHoardDemon && ((IHoardDemon) par1Entity).isSamePortal(this)) { - return false; - } - - par1Entity.setFire(15); - - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); + public void causeEffect(Entity entity) { + entity.setFire(15); } - /** - * Attack the specified entity using a ranged attack. - */ @Override - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { - if (par1EntityLivingBase instanceof IHoardDemon && ((IHoardDemon) par1EntityLivingBase).isSamePortal(this)) { - return; - } - FireProjectile hol = new FireProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 20, 600); - this.worldObj.spawnEntityInWorld(hol); + protected EnergyBlastProjectile attackProjectile(EntityLivingBase target) { + return new FireProjectile(worldObj, this, target, 1.8f, 0f, 20, 600); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianIce.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianIce.java index 01953c5e57..a2918c9753 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianIce.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianIce.java @@ -2,39 +2,30 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.DamageSource; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; +import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile; import WayofTime.alchemicalWizardry.common.entity.projectile.IceProjectile; public class EntityMinorDemonGruntGuardianIce extends EntityMinorDemonGruntGuardian { - public EntityMinorDemonGruntGuardianIce(World par1World) { - super(par1World); + public EntityMinorDemonGruntGuardianIce(World world) { + super(world); this.setDemonID(AlchemicalWizardry.entityMinorDemonGruntGuardianIceID); } @Override - public boolean attackEntityAsMob(Entity par1Entity) { - int i = this.isTamed() ? 25 : 25; - - if (par1Entity instanceof IHoardDemon && ((IHoardDemon) par1Entity).isSamePortal(this)) { - return false; + public void causeEffect(Entity entity) { + if (entity instanceof EntityLivingBase e) { + e.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 4)); } - - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } - /** - * Attack the specified entity using a ranged attack. - */ @Override - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { - if (par1EntityLivingBase instanceof IHoardDemon && ((IHoardDemon) par1EntityLivingBase).isSamePortal(this)) { - return; - } - IceProjectile hol = new IceProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 20, 600); - this.worldObj.spawnEntityInWorld(hol); + protected EnergyBlastProjectile attackProjectile(EntityLivingBase target) { + return new IceProjectile(worldObj, this, target, 1.8f, 0f, 20, 600); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianWind.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianWind.java index 626c766608..4cb0aefa27 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianWind.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntGuardianWind.java @@ -3,39 +3,27 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.DamageSource; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; +import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile; import WayofTime.alchemicalWizardry.common.entity.projectile.WindGustProjectile; import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class EntityMinorDemonGruntGuardianWind extends EntityMinorDemonGruntGuardian { - public EntityMinorDemonGruntGuardianWind(World par1World) { - super(par1World); + public EntityMinorDemonGruntGuardianWind(World world) { + super(world); this.setDemonID(AlchemicalWizardry.entityMinorDemonGruntGuardianWindID); } @Override - public boolean attackEntityAsMob(Entity par1Entity) { - int i = this.isTamed() ? 25 : 25; - - if (par1Entity instanceof IHoardDemon && ((IHoardDemon) par1Entity).isSamePortal(this)) { - return false; - } - - if (par1Entity instanceof EntityPlayer) { - SpellHelper.setPlayerSpeedFromServer( - (EntityPlayer) par1Entity, - par1Entity.motionX, - par1Entity.motionY + 4, - par1Entity.motionZ); - } else if (par1Entity instanceof EntityLivingBase) { - ((EntityLivingBase) par1Entity).motionY += 4.0D; + public void causeEffect(Entity entity) { + if (entity instanceof EntityPlayer player) { + SpellHelper.setPlayerSpeedFromServer(player, entity.motionX, entity.motionY + 4, entity.motionZ); + } else if (entity instanceof EntityLivingBase) { + entity.motionY += 4.0D; } - - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } @Override @@ -44,15 +32,8 @@ public void onLivingUpdate() { this.fallDistance = 0; } - /** - * Attack the specified entity using a ranged attack. - */ @Override - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { - if (par1EntityLivingBase instanceof IHoardDemon && ((IHoardDemon) par1EntityLivingBase).isSamePortal(this)) { - return; - } - WindGustProjectile hol = new WindGustProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 20, 600); - this.worldObj.spawnEntityInWorld(hol); + protected EnergyBlastProjectile attackProjectile(EntityLivingBase target) { + return new WindGustProjectile(worldObj, this, target, 1.8f, 0f, 20, 600); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntIce.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntIce.java index 28b6d95830..7a89ed8258 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntIce.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntIce.java @@ -2,35 +2,30 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.DamageSource; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; +import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile; import WayofTime.alchemicalWizardry.common.entity.projectile.IceProjectile; public class EntityMinorDemonGruntIce extends EntityMinorDemonGrunt { - public EntityMinorDemonGruntIce(World par1World) { - super(par1World); + public EntityMinorDemonGruntIce(World world) { + super(world); this.setDemonID(AlchemicalWizardry.entityMinorDemonGruntIceID); } @Override - public boolean attackEntityAsMob(Entity par1Entity) { - int i = this.isTamed() ? 20 : 20; - if (par1Entity instanceof IHoardDemon && ((IHoardDemon) par1Entity).isSamePortal(this)) { - return false; + public void causeEffect(Entity entity) { + if (entity instanceof EntityLivingBase e) { + e.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 4)); } - - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } @Override - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { - if (par1EntityLivingBase instanceof IHoardDemon && ((IHoardDemon) par1EntityLivingBase).isSamePortal(this)) { - return; - } - IceProjectile hol = new IceProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 15, 600); - this.worldObj.spawnEntityInWorld(hol); + protected EnergyBlastProjectile attackProjectile(EntityLivingBase target) { + return new IceProjectile(worldObj, this, target, 1.8f, 0f, 15, 600); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntWind.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntWind.java index 5a28d996ac..b2e631ee5f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntWind.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/demonHoard/demon/EntityMinorDemonGruntWind.java @@ -3,38 +3,27 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.DamageSource; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; +import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile; import WayofTime.alchemicalWizardry.common.entity.projectile.WindGustProjectile; import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class EntityMinorDemonGruntWind extends EntityMinorDemonGrunt { - public EntityMinorDemonGruntWind(World par1World) { - super(par1World); + public EntityMinorDemonGruntWind(World world) { + super(world); this.setDemonID(AlchemicalWizardry.entityMinorDemonGruntWindID); } @Override - public boolean attackEntityAsMob(Entity par1Entity) { - int i = this.isTamed() ? 20 : 20; - if (par1Entity instanceof IHoardDemon && ((IHoardDemon) par1Entity).isSamePortal(this)) { - return false; + public void causeEffect(Entity entity) { + if (entity instanceof EntityPlayer player) { + SpellHelper.setPlayerSpeedFromServer(player, entity.motionX, entity.motionY + 3, entity.motionZ); + } else if (entity instanceof EntityLivingBase) { + entity.motionY += 3.0D; } - - if (par1Entity instanceof EntityPlayer) { - SpellHelper.setPlayerSpeedFromServer( - (EntityPlayer) par1Entity, - par1Entity.motionX, - par1Entity.motionY + 3, - par1Entity.motionZ); - } else if (par1Entity instanceof EntityLivingBase) { - ((EntityLivingBase) par1Entity).motionY += 3.0D; - } - - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } @Override @@ -44,11 +33,7 @@ public void onLivingUpdate() { } @Override - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { - if (par1EntityLivingBase instanceof IHoardDemon && ((IHoardDemon) par1EntityLivingBase).isSamePortal(this)) { - return; - } - WindGustProjectile hol = new WindGustProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 15, 600); - this.worldObj.spawnEntityInWorld(hol); + protected EnergyBlastProjectile attackProjectile(EntityLivingBase target) { + return new WindGustProjectile(worldObj, this, target, 1.8f, 0f, 15, 600); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/loot/DemonVillageLootRegistry.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/loot/DemonVillageLootRegistry.java index 7b4632a5a6..60515d919e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/loot/DemonVillageLootRegistry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/loot/DemonVillageLootRegistry.java @@ -12,7 +12,7 @@ public class DemonVillageLootRegistry { - public static ArrayList list1 = new ArrayList(); + public static ArrayList list1 = new ArrayList<>(); public static void init() { String[] tier1Strings = new String[] { ChestGenHooks.DUNGEON_CHEST, ChestGenHooks.PYRAMID_DESERT_CHEST }; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/tileEntity/BlockDemonChest.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/tileEntity/BlockDemonChest.java index ef6ae55b50..9d26bbddbe 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/tileEntity/BlockDemonChest.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/tileEntity/BlockDemonChest.java @@ -16,6 +16,7 @@ public BlockDemonChest() { this.setCreativeTab(AlchemicalWizardry.tabBloodMagic); } + @Override public IInventory func_149951_m(World world, int x, int y, int z) { return (IInventory) world.getTileEntity(x, y, z); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/tileEntity/TEDemonChest.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/tileEntity/TEDemonChest.java index 97d3f40253..44c200964b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/tileEntity/TEDemonChest.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/tileEntity/TEDemonChest.java @@ -47,9 +47,9 @@ public void setPortalLocation(TEDemonPortal teDemonPortal) { } public TEDemonPortal getDemonPortal() { - TileEntity tile = worldObj.getTileEntity(portalLocation.xCoord, portalLocation.yCoord, portalLocation.zCoord); - if (tile instanceof TEDemonPortal) { - return (TEDemonPortal) tile; + TileEntity tile = worldObj.getTileEntity(portalLocation.x(), portalLocation.y(), portalLocation.z()); + if (tile instanceof TEDemonPortal portal) { + return portal; } return null; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/tileEntity/TEDemonPortal.java b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/tileEntity/TEDemonPortal.java index 85daaa6606..10b2e18db3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/tileEntity/TEDemonPortal.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/demonVillage/tileEntity/TEDemonPortal.java @@ -64,9 +64,9 @@ public class TEDemonPortal extends TileEntity { public static int[] tierCostList = new int[] { 1500 }; - public Set hoardList = new HashSet(); + public Set hoardList = new HashSet<>(); - public static List buildingList = new ArrayList(); + public static List buildingList = new ArrayList<>(); public Random rand = new Random(); private GridSpace[][] area; @@ -152,7 +152,7 @@ public float getDemonHoardChance() { public boolean decreaseRandomCooldown(int amount) { float totalChance = 0; - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("roadChance", this.getRoadChance()); map.put("houseChance", this.getHouseChance()); map.put("demonPortalChance", this.getDemonPortalChance()); @@ -176,25 +176,28 @@ public boolean decreaseRandomCooldown(int amount) { } } - if (action.equals("roadChance")) { - if (roadCooldown > 0) { - roadCooldown -= amount; - } else { - return false; + switch (action) { + case "roadChance" -> { + if (roadCooldown > 0) { + roadCooldown -= amount; + } else { + return false; + } } - } else if (action.equals("houseChance")) { - if (houseCooldown > 0) { - houseCooldown -= amount; - } else { - return false; + case "houseChance" -> { + if (houseCooldown > 0) { + houseCooldown -= amount; + } else { + return false; + } } - } else if (action.equals("demonPortalChance")) { - demonHouseCooldown += amount; - } else if (action.equals("demonHoardChance")) { - if (demonHoardCooldown > 0) { - demonHoardCooldown -= amount; - } else { - return false; + case "demonPortalChance" -> demonHouseCooldown += amount; + case "demonHoardChance" -> { + if (demonHoardCooldown > 0) { + demonHoardCooldown -= amount; + } else { + return false; + } } } @@ -228,14 +231,14 @@ public void notifyDemons(EntityLivingBase demon, EntityLivingBase target, double public void notifyDemons(int xf, int yf, int zf, double radius) { for (IHoardDemon thrallDemon : this.hoardList) { - if (thrallDemon instanceof EntityCreature) { - if (((EntityCreature) thrallDemon).getAttackTarget() == null) { - double xi = ((EntityCreature) thrallDemon).posX; - double yi = ((EntityCreature) thrallDemon).posY; - double zi = ((EntityCreature) thrallDemon).posZ; + if (thrallDemon instanceof EntityCreature thrall) { + if (thrall.getAttackTarget() == null) { + double xi = thrall.posX; + double yi = thrall.posY; + double zi = thrall.posZ; if ((xi - xf) * (xi - xf) + (yi - yf) * (yi - yf) + (zi - zf) * (zi - zf) <= radius * radius) { - ((EntityCreature) thrallDemon).getNavigator().tryMoveToXYZ(xf, yf, zf, 1); + thrall.getNavigator().tryMoveToXYZ(xf, yf, zf, 1); } } } @@ -243,10 +246,10 @@ public void notifyDemons(int xf, int yf, int zf, double radius) { } public void enthrallDemon(EntityLivingBase demon) { - if (demon instanceof IHoardDemon) { - boolean enthrall = ((IHoardDemon) demon).thrallDemon(new Int3(this.xCoord, this.yCoord, this.zCoord)); + if (demon instanceof IHoardDemon hoardDemon) { + boolean enthrall = hoardDemon.thrallDemon(new Int3(this.xCoord, this.yCoord, this.zCoord)); if (enthrall) { - this.hoardList.add((IHoardDemon) demon); + this.hoardList.add(hoardDemon); } } } @@ -333,11 +336,11 @@ public void updateEntity() { this.assignPoints(); if (printDebug) AlchemicalWizardry.logger - .info("Roads: " + roadCooldown + " Buildings: " + houseCooldown + " Lockdown: " + lockdownTimer); + .info("Roads: {} Buildings: {} Lockdown: {}", roadCooldown, houseCooldown, lockdownTimer); if (buildingStage >= 0 && buildingStage <= 2) { - if (printDebug) AlchemicalWizardry.logger.info("BuildingStage = " + buildingStage); - if (printDebug) AlchemicalWizardry.logger.info("Tier = " + this.tier); + if (printDebug) AlchemicalWizardry.logger.info("BuildingStage = {}", buildingStage); + if (printDebug) AlchemicalWizardry.logger.info("Tier = {}", this.tier); this.createPortalBuilding(buildingStage, nextDemonPortalName, tier); buildingStage++; return; @@ -395,19 +398,19 @@ public void incrementPoints() { } @Override - public void readFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readFromNBT(par1NBTTagCompound); - this.negXRadius = par1NBTTagCompound.getInteger("negXRadius"); - this.negZRadius = par1NBTTagCompound.getInteger("negZRadius"); - this.posXRadius = par1NBTTagCompound.getInteger("posXRadius"); - this.posZRadius = par1NBTTagCompound.getInteger("posZRadius"); - this.houseCooldown = par1NBTTagCompound.getInteger("houseCooldown"); - this.roadCooldown = par1NBTTagCompound.getInteger("roadCooldown"); - this.demonHoardCooldown = par1NBTTagCompound.getInteger("demonHoardCooldown"); + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); + this.negXRadius = tag.getInteger("negXRadius"); + this.negZRadius = tag.getInteger("negZRadius"); + this.posXRadius = tag.getInteger("posXRadius"); + this.posZRadius = tag.getInteger("posZRadius"); + this.houseCooldown = tag.getInteger("houseCooldown"); + this.roadCooldown = tag.getInteger("roadCooldown"); + this.demonHoardCooldown = tag.getInteger("demonHoardCooldown"); area = new GridSpace[negXRadius + posXRadius + 1][negZRadius + posZRadius + 1]; - NBTTagList tagList = par1NBTTagCompound.getTagList("Grid", Constants.NBT.TAG_COMPOUND); + NBTTagList tagList = tag.getTagList("Grid", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < tagList.tagCount(); i++) { int length = (negZRadius + posZRadius + 1); @@ -415,39 +418,54 @@ public void readFromNBT(NBTTagCompound par1NBTTagCompound) { int x = i / length; int z = i % length; - NBTTagCompound tag = tagList.getCompoundTagAt(i); - GridSpace space = GridSpace.getGridFromTag(tag); + GridSpace space = GridSpace.getGridFromTag(tagList.getCompoundTagAt(i)); area[x][z] = space; } - this.isInitialized = par1NBTTagCompound.getBoolean("init"); + this.isInitialized = tag.getBoolean("init"); - this.tier = par1NBTTagCompound.getInteger("tier"); - this.demonHouseCooldown = par1NBTTagCompound.getInteger("demonHouseCooldown"); + this.tier = tag.getInteger("tier"); + this.demonHouseCooldown = tag.getInteger("demonHouseCooldown"); - this.nextDemonPortalName = par1NBTTagCompound.getString("nextDemonPortalName"); - this.buildingStage = par1NBTTagCompound.getInteger("buildingStage"); - this.nextDemonPortalDirection = ForgeDirection - .getOrientation(par1NBTTagCompound.getInteger("nextDemonPortalDirection")); + this.nextDemonPortalName = tag.getString("nextDemonPortalName"); + this.buildingStage = tag.getInteger("buildingStage"); + this.nextDemonPortalDirection = ForgeDirection.getOrientation(tag.getInteger("nextDemonPortalDirection")); - this.pointPool = par1NBTTagCompound.getFloat("pointPool"); - this.lockdownTimer = par1NBTTagCompound.getInteger("lockdownTimer"); - this.delayBeforeParty = par1NBTTagCompound.getInteger("delayBeforeParty"); - this.type = DemonType.valueOf(par1NBTTagCompound.getString("demonType")); + this.pointPool = tag.getFloat("pointPool"); + this.lockdownTimer = tag.getInteger("lockdownTimer"); + this.delayBeforeParty = tag.getInteger("delayBeforeParty"); + this.type = DemonType.valueOf(tag.getString("demonType")); } @Override - public void writeToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeToNBT(par1NBTTagCompound); - par1NBTTagCompound.setInteger("negXRadius", negXRadius); - par1NBTTagCompound.setInteger("negZRadius", negZRadius); - par1NBTTagCompound.setInteger("posXRadius", posXRadius); - par1NBTTagCompound.setInteger("posZRadius", posZRadius); - par1NBTTagCompound.setInteger("houseCooldown", houseCooldown); - par1NBTTagCompound.setInteger("roadCooldown", roadCooldown); - par1NBTTagCompound.setInteger("demonHoardCooldown", demonHoardCooldown); + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); + tag.setInteger("negXRadius", negXRadius); + tag.setInteger("negZRadius", negZRadius); + tag.setInteger("posXRadius", posXRadius); + tag.setInteger("posZRadius", posZRadius); + tag.setInteger("houseCooldown", houseCooldown); + tag.setInteger("roadCooldown", roadCooldown); + tag.setInteger("demonHoardCooldown", demonHoardCooldown); + + tag.setTag("Grid", getGridList()); + + tag.setBoolean("init", this.isInitialized); + tag.setInteger("tier", this.tier); + tag.setInteger("demonHouseCooldown", this.demonHouseCooldown); + + tag.setString("nextDemonPortalName", nextDemonPortalName); + tag.setInteger("buildingStage", buildingStage); + + tag.setInteger("nextDemonPortalDirection", this.nextDemonPortalDirection.ordinal()); + tag.setFloat("pointPool", pointPool); + tag.setInteger("lockdownTimer", this.lockdownTimer); + tag.setInteger("delayBeforeParty", delayBeforeParty); + tag.setString("demonType", this.type.toString()); + } + private NBTTagList getGridList() { NBTTagList gridList = new NBTTagList(); for (int i = 0; i <= negXRadius + posXRadius; i++) { @@ -464,43 +482,17 @@ public void writeToNBT(NBTTagCompound par1NBTTagCompound) { gridList.appendTag(nextTag); } } - - par1NBTTagCompound.setTag("Grid", gridList); - - par1NBTTagCompound.setBoolean("init", this.isInitialized); - par1NBTTagCompound.setInteger("tier", this.tier); - par1NBTTagCompound.setInteger("demonHouseCooldown", this.demonHouseCooldown); - - par1NBTTagCompound.setString("nextDemonPortalName", nextDemonPortalName); - par1NBTTagCompound.setInteger("buildingStage", buildingStage); - - par1NBTTagCompound.setInteger("nextDemonPortalDirection", this.nextDemonPortalDirection.ordinal()); - par1NBTTagCompound.setFloat("pointPool", pointPool); - par1NBTTagCompound.setInteger("lockdownTimer", this.lockdownTimer); - par1NBTTagCompound.setInteger("delayBeforeParty", delayBeforeParty); - par1NBTTagCompound.setString("demonType", this.type.toString()); + return gridList; } public int createRandomDemonHoard(TEDemonPortal teDemonPortal, int tier, DemonType type, boolean spawnGuardian) { int next = rand.nextInt(4); - ForgeDirection dir; - - switch (next) { - case 0: - dir = ForgeDirection.NORTH; - break; - case 1: - dir = ForgeDirection.SOUTH; - break; - case 2: - dir = ForgeDirection.EAST; - break; - case 3: - dir = ForgeDirection.WEST; - break; - default: - dir = ForgeDirection.NORTH; - } + ForgeDirection dir = switch (next) { + case 1 -> ForgeDirection.SOUTH; + case 2 -> ForgeDirection.EAST; + case 3 -> ForgeDirection.WEST; + default -> ForgeDirection.NORTH; + }; Int3 road = findRoadSpaceFromDirection( dir, @@ -514,9 +506,9 @@ public int createRandomDemonHoard(TEDemonPortal teDemonPortal, int tier, DemonTy return DemonPacketRegistry.spawnDemons( teDemonPortal, worldObj, - xCoord + road.xCoord * 5, - road.yCoord + 1, - zCoord + road.zCoord * 5, + xCoord + road.x() * 5, + road.y() + 1, + zCoord + road.z() * 5, type, tier, spawnGuardian); @@ -525,34 +517,22 @@ public int createRandomDemonHoard(TEDemonPortal teDemonPortal, int tier, DemonTy public int createRandomRoad() // Return the number of road spaces { int next = rand.nextInt(4); - ForgeDirection dir; - - switch (next) { - case 0: - dir = ForgeDirection.NORTH; - break; - case 1: - dir = ForgeDirection.SOUTH; - break; - case 2: - dir = ForgeDirection.EAST; - break; - case 3: - dir = ForgeDirection.WEST; - break; - default: - dir = ForgeDirection.NORTH; - } + ForgeDirection dir = switch (next) { + case 1 -> ForgeDirection.SOUTH; + case 2 -> ForgeDirection.EAST; + case 3 -> ForgeDirection.WEST; + default -> ForgeDirection.NORTH; + }; Int3 road = findRoadSpaceFromDirection( dir, (rand.nextInt(negXRadius + negZRadius + posXRadius + posZRadius)) + 1); - int x = road.xCoord; - int yLevel = road.yCoord; - int z = road.zCoord; + int x = road.x(); + int yLevel = road.y(); + int z = road.z(); - if (printDebug) AlchemicalWizardry.logger.info("X: " + x + " Z: " + z + " Direction: " + dir.toString()); + if (printDebug) AlchemicalWizardry.logger.info("X: {} Z: {} Direction: {}", x, z, dir); List directions = this.findValidExtentionDirection(x, z); @@ -580,7 +560,7 @@ public int createRandomRoad() // Return the number of road spaces } if (printDebug) AlchemicalWizardry.logger.info("I got here!"); if (printDebug) AlchemicalWizardry.logger - .info("Distance: " + distance + " Direction: " + dominantDirection.toString() + " yLevel: " + yLevel); + .info("Distance: {} Direction: {} yLevel: {}", distance, dominantDirection, yLevel); this.createGriddedRoad(x, yLevel, z, dominantDirection, distance + 1, true); @@ -588,7 +568,7 @@ public int createRandomRoad() // Return the number of road spaces } public List findValidExtentionDirection(int x, int z) { - List directions = new LinkedList(); + List directions = new LinkedList<>(); if (this.getGridSpace(x, z) == null || !this.getGridSpace(x, z).isRoadSegment()) { return directions; @@ -854,8 +834,8 @@ public int createGriddedRoad(int gridXi, int yi, int gridZi, ForgeDirection dir, Int3 next = temp.coords; if (next != null) { - initY = next.yCoord; - if (printDebug) AlchemicalWizardry.logger.info("" + initY); + initY = next.y(); + if (printDebug) AlchemicalWizardry.logger.info("{}", initY); } if (!temp.bool) { @@ -880,9 +860,8 @@ public void expandAreaInNegX() { } for (int i = 0; i <= negXRadius + posXRadius; i++) { - for (int j = 0; j <= negZRadius + posZRadius; j++) { - newGrid[i + 1][j] = area[i][j]; - } + if (negZRadius + posZRadius + 1 >= 0) + System.arraycopy(area[i], 0, newGrid[i + 1], 0, negZRadius + posZRadius + 1); } area = newGrid; @@ -897,9 +876,8 @@ public void expandAreaInPosX() { } for (int i = 0; i <= negXRadius + posXRadius; i++) { - for (int j = 0; j <= negZRadius + posZRadius; j++) { - newGrid[i][j] = area[i][j]; - } + if (negZRadius + posZRadius + 1 >= 0) + System.arraycopy(area[i], 0, newGrid[i], 0, negZRadius + posZRadius + 1); } area = newGrid; @@ -909,16 +887,15 @@ public void expandAreaInPosX() { public void expandAreaInNegZ() { GridSpace[][] newGrid = new GridSpace[negXRadius + posXRadius + 1][negZRadius + posZRadius + 2]; - if (printDebug) AlchemicalWizardry.logger.info("x " + newGrid.length + "z " + newGrid[0].length); + if (printDebug) AlchemicalWizardry.logger.info("x {}z {}", newGrid.length, newGrid[0].length); for (int i = 0; i <= negXRadius + posXRadius; i++) { newGrid[i][0] = new GridSpace(); } for (int i = 0; i <= negXRadius + posXRadius; i++) { - for (int j = 0; j <= negZRadius + posZRadius; j++) { - newGrid[i][j + 1] = area[i][j]; - } + if (negZRadius + posZRadius + 1 >= 0) + System.arraycopy(area[i], 0, newGrid[i], 1, negZRadius + posZRadius + 1); } area = newGrid; @@ -933,9 +910,8 @@ public void expandAreaInPosZ() { } for (int i = 0; i <= negXRadius + posXRadius; i++) { - for (int j = 0; j <= negZRadius + posZRadius; j++) { - newGrid[i][j] = area[i][j]; - } + if (negZRadius + posZRadius + 1 >= 0) + System.arraycopy(area[i], 0, newGrid[i], 0, negZRadius + posZRadius + 1); } area = newGrid; @@ -989,14 +965,12 @@ public void rightClickBlock(EntityPlayer player, int side) { } public int createRandomBuilding(int type, int tier) { - switch (type) { - case DemonBuilding.BUILDING_HOUSE: - return this.createRandomHouse(tier); - case DemonBuilding.BUILDING_PORTAL: - return this.createPortalBuilding(tier); - } + return switch (type) { + case DemonBuilding.BUILDING_HOUSE -> this.createRandomHouse(tier); + case DemonBuilding.BUILDING_PORTAL -> this.createPortalBuilding(tier); + default -> 0; + }; - return 0; } public int createPortalBuilding(int buildingTier) // TODO Telepose block next time, then build the new building. @@ -1010,7 +984,7 @@ public int createPortalBuilding(int buildingTier) // TODO Telepose block next ti // GridSpaceHolder grid = this.createGSH(); - List directions = new ArrayList(); + List directions = new ArrayList<>(); for (int i = 2; i < 6; i++) { ForgeDirection testDir = ForgeDirection.getOrientation(i); @@ -1021,7 +995,7 @@ public int createPortalBuilding(int buildingTier) // TODO Telepose block next ti return 0; } - HashMap> schemMap = new HashMap(); + HashMap> schemMap = new HashMap<>(); for (ForgeDirection nextDir : directions) { for (DemonBuilding build : TEDemonPortal.buildingList) { @@ -1032,18 +1006,18 @@ public int createPortalBuilding(int buildingTier) // TODO Telepose block next ti if (schemMap.containsKey(nextDir)) { schemMap.get(nextDir).add(build); } else { - schemMap.put(nextDir, new ArrayList()); + schemMap.put(nextDir, new ArrayList<>()); schemMap.get(nextDir).add(build); } } } - if (schemMap.keySet().isEmpty()) { + if (schemMap.isEmpty()) { return 0; } ForgeDirection chosenDirection = (ForgeDirection) schemMap.keySet().toArray()[new Random() - .nextInt(schemMap.keySet().size())]; + .nextInt(schemMap.size())]; DemonBuilding build = schemMap.get(chosenDirection) .get(new Random().nextInt(schemMap.get(chosenDirection).size())); // Int3 portalSpace = build.getDoorSpace(chosenDirection); @@ -1084,13 +1058,10 @@ public void createPortalBuilding(int stage, String name, int tier) { ForgeDirection chosenDirection = this.nextDemonPortalDirection; Int3 portalSpace = build.getDoorSpace(chosenDirection); - int yOffset = portalSpace.yCoord; + int yOffset = portalSpace.y(); switch (stage) { - case 0: - break; - - case 1: + case 1 -> { int yDestination = yLevel + yOffset; if (yCoord != yDestination) { BlockTeleposer.swapBlocks( @@ -1103,27 +1074,12 @@ public void createPortalBuilding(int stage, String name, int tier) { xCoord, yDestination, zCoord); - } else { - // Nuthin - just as a reminder that we can now increment properly } - break; - - case 2: - build.destroyAllInField( - worldObj, - xCoord + (x) * 5, - yLevel, - zCoord + (z) * 5, - chosenDirection.getOpposite()); + } + case 2 -> { + build.destroyAllInField(worldObj, xCoord, yLevel, zCoord, chosenDirection.getOpposite()); - build.buildAll( - this, - worldObj, - xCoord + (x) * 5, - yLevel, - zCoord + (z) * 5, - chosenDirection.getOpposite(), - true); + build.buildAll(this, worldObj, xCoord, yLevel, zCoord, chosenDirection.getOpposite(), true); build.setAllGridSpaces( x, z, @@ -1132,7 +1088,7 @@ public void createPortalBuilding(int stage, String name, int tier) { GridSpace.MAIN_PORTAL, grid); this.loadGSH(grid); - break; + } } return; @@ -1142,35 +1098,23 @@ public void createPortalBuilding(int stage, String name, int tier) { public int createRandomHouse(int buildingTier) { int next = rand.nextInt(4); - ForgeDirection dir; - - switch (next) { - case 0: - dir = ForgeDirection.NORTH; - break; - case 1: - dir = ForgeDirection.SOUTH; - break; - case 2: - dir = ForgeDirection.EAST; - break; - case 3: - dir = ForgeDirection.WEST; - break; - default: - dir = ForgeDirection.NORTH; - } + ForgeDirection dir = switch (next) { + case 1 -> ForgeDirection.SOUTH; + case 2 -> ForgeDirection.EAST; + case 3 -> ForgeDirection.WEST; + default -> ForgeDirection.NORTH; + }; Int3 space = this .findRoadSpaceFromDirection(dir, (rand.nextInt(negXRadius + negZRadius + posXRadius + posZRadius)) + 1); // Second: // 1 // * - int x = space.xCoord; - int z = space.zCoord; - int yLevel = space.yCoord; + int x = space.x(); + int z = space.z(); + int yLevel = space.y(); - if (printDebug) AlchemicalWizardry.logger.info("Road space - x: " + x + " z: " + z); + if (printDebug) AlchemicalWizardry.logger.info("Road space - x: {} z: {}", x, z); GridSpaceHolder grid = this.createGSH(); @@ -1178,7 +1122,7 @@ public int createRandomHouse(int buildingTier) { return 0; } - List directions = new ArrayList(); + List directions = new ArrayList<>(); for (int i = 2; i < 6; i++) { ForgeDirection testDir = ForgeDirection.getOrientation(i); @@ -1191,7 +1135,7 @@ public int createRandomHouse(int buildingTier) { return 0; } - HashMap> schemMap = new HashMap(); + HashMap> schemMap = new HashMap<>(); for (ForgeDirection nextDir : directions) { for (DemonBuilding build : TEDemonPortal.buildingList) { @@ -1199,14 +1143,14 @@ public int createRandomHouse(int buildingTier) { continue; } Int3 offsetSpace = build.getGridOffsetFromRoad(nextDir, yLevel); - int xOff = offsetSpace.xCoord; - int zOff = offsetSpace.zCoord; + int xOff = offsetSpace.x(); + int zOff = offsetSpace.z(); if (build.isValid(grid, x + xOff, z + zOff, nextDir.getOpposite())) { if (schemMap.containsKey(nextDir)) { schemMap.get(nextDir).add(build); } else { - schemMap.put(nextDir, new ArrayList()); + schemMap.put(nextDir, new ArrayList<>()); schemMap.get(nextDir).add(build); } } else { @@ -1215,18 +1159,18 @@ public int createRandomHouse(int buildingTier) { } } - if (schemMap.keySet().isEmpty()) { + if (schemMap.isEmpty()) { return 0; } ForgeDirection chosenDirection = (ForgeDirection) schemMap.keySet().toArray()[new Random() - .nextInt(schemMap.keySet().size())]; + .nextInt(schemMap.size())]; DemonBuilding build = schemMap.get(chosenDirection) .get(new Random().nextInt(schemMap.get(chosenDirection).size())); Int3 offsetSpace = build.getGridOffsetFromRoad(chosenDirection, yLevel); - int xOff = offsetSpace.xCoord; - int zOff = offsetSpace.zCoord; + int xOff = offsetSpace.x(); + int zOff = offsetSpace.z(); build.destroyAllInField( worldObj, @@ -1294,20 +1238,16 @@ public int getRoadRadius() { } public Block getRoadBlock() { - switch (this.tier) { - case 0: - return rand.nextFloat() < 0.6 ? Blocks.cobblestone : Blocks.mossy_cobblestone; - case 1: - return Blocks.stonebrick; - default: - return Blocks.nether_brick; - } + return switch (this.tier) { + case 0 -> rand.nextFloat() < 0.6 ? Blocks.cobblestone : Blocks.mossy_cobblestone; + case 1 -> Blocks.stonebrick; + default -> Blocks.nether_brick; + }; } public int getRoadMeta() { - switch (this.tier) { - case 1: - return rand.nextFloat() < 0.6 ? 1 : 0; + if (this.tier == 1) { + return rand.nextFloat() < 0.6 ? 1 : 0; } return 0; } @@ -1345,6 +1285,7 @@ public static void loadBuildingList() { File file = new File(folder); File[] files = file.listFiles(); + if (files == null) return; BufferedReader br; try { @@ -1354,7 +1295,8 @@ public static void loadBuildingList() { TEDemonPortal.buildingList.add(new DemonBuilding(schema)); } } catch (FileNotFoundException e) { - e.printStackTrace(); + AlchemicalWizardry.logger.error("Failed to load schematics for demon portal buildings."); + AlchemicalWizardry.logger.error(e); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/BookEntityItem.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/BookEntityItem.java index a2faa27f72..6d8b98ac2b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/BookEntityItem.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/BookEntityItem.java @@ -8,17 +8,16 @@ public class BookEntityItem extends EntityItem { - public BookEntityItem(World par1World, double par2, double par4, double par6) { - super(par1World, par2, par4, par6); + public BookEntityItem(World world, double par2, double par4, double par6) { + super(world, par2, par4, par6); this.isImmuneToFire = true; this.lifespan = 72000; } - public BookEntityItem(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack) { - this(par1World, par2, par4, par6); - this.setEntityItemStack(par8ItemStack); - this.lifespan = (par8ItemStack.getItem() == null ? 6000 - : par8ItemStack.getItem().getEntityLifespan(par8ItemStack, par1World)); + public BookEntityItem(World world, double x, double y, double z, ItemStack item) { + this(world, x, y, z); + this.setEntityItemStack(item); + this.lifespan = (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, world)); this.isImmuneToFire = true; } @@ -43,7 +42,6 @@ public void onUpdate() { @Override public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - if (par1DamageSource.getDamageType().equals("outOfWorld")) return true; - return false; + return par1DamageSource.getDamageType().equals("outOfWorld"); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityAirElemental.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityAirElemental.java index 07b9d1b2c1..088c2af5db 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityAirElemental.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityAirElemental.java @@ -16,19 +16,14 @@ public EntityAirElemental(World world) { super(world, AlchemicalWizardry.entityAirElementalID); } + @Override public void inflictEffectOnEntity(Entity target) { - if (target instanceof EntityPlayer) { - SpellHelper.setPlayerSpeedFromServer( - (EntityPlayer) target, - target.motionX, - target.motionY + 3, - target.motionZ); - ((EntityLivingBase) target) - .addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 150, 0)); - } else if (target instanceof EntityLivingBase) { - ((EntityLivingBase) target).motionY += 3.0D; - ((EntityLivingBase) target) - .addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 150, 0)); + if (target instanceof EntityPlayer p) { + SpellHelper.setPlayerSpeedFromServer(p, target.motionX, target.motionY + 3, target.motionZ); + p.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 150, 0)); + } else if (target instanceof EntityLivingBase t) { + target.motionY += 3.0D; + t.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 150, 0)); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityBileDemon.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityBileDemon.java index 310b81c3a0..825eab32dd 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityBileDemon.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityBileDemon.java @@ -1,7 +1,6 @@ package WayofTime.alchemicalWizardry.common.entity.mob; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIFollowOwner; @@ -12,29 +11,21 @@ import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; -import net.minecraft.entity.monster.EntityCreeper; -import net.minecraft.entity.monster.EntityGhast; -import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; -import WayofTime.alchemicalWizardry.ModItems; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class EntityBileDemon extends EntityDemon { - private static float maxTamedHealth = 100.0F; - private static float maxUntamedHealth = 200.0F; + protected float maxTamedHealth = 100.0F; + protected float maxUntamedHealth = 200.0F; private int attackTimer; - public EntityBileDemon(World par1World) { - super(par1World, AlchemicalWizardry.entityBileDemonID); + public EntityBileDemon(World world) { + super(world, AlchemicalWizardry.entityBileDemonID); this.setSize(1.3F, 2.0F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(1, new EntityAISwimming(this)); @@ -54,110 +45,68 @@ public EntityBileDemon(World par1World) { @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); - // This line affects the speed of the monster - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.20000001192092896D); - - // My guess is that this will alter the max health - if (this.isTamed()) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } - - // this.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(10.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.20D); } /** * Returns true if the newer Entity AI code should be run */ + @Override public boolean isAIEnabled() { return true; } - /** - * Sets the active target the Task system uses for tracking - */ - public void setAttackTarget(EntityLivingBase par1EntityLivingBase) { - super.setAttackTarget(par1EntityLivingBase); - - if (par1EntityLivingBase == null) { - this.setAngry(false); - } else if (!this.isTamed()) { - this.setAngry(true); - } - } - /** * main AI tick function, replaces updateEntityActionState */ + @Override protected void updateAITick() { this.dataWatcher.updateObject(18, this.getHealth()); } + @Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, this.getHealth()); // this.dataWatcher.addObject(20, new Byte((byte) BlockColored.getBlockFromDye(1))); } - /** - * Plays step sound at given x, y, z for the entity - */ protected void playStepSound(int par1, int par2, int par3, int par4) { this.playSound("mob.zombie.step", 0.15F, 1.0F); } - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeEntityToNBT(par1NBTTagCompound); - par1NBTTagCompound.setBoolean("Angry", this.isAngry()); - par1NBTTagCompound.setByte("attackTimer", (byte) attackTimer); + @Override + public void writeEntityToNBT(NBTTagCompound tag) { + super.writeEntityToNBT(tag); + tag.setByte("attackTimer", (byte) attackTimer); } - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readEntityFromNBT(par1NBTTagCompound); - this.setAngry(par1NBTTagCompound.getBoolean("Angry")); - - attackTimer = par1NBTTagCompound.getByte("attackTimer"); + @Override + public void readEntityFromNBT(NBTTagCompound tag) { + super.readEntityFromNBT(tag); + attackTimer = tag.getByte("attackTimer"); } - /** - * Returns the sound this mob makes while it's alive. - */ + @Override protected String getLivingSound() { return "none"; } - /** - * Returns the sound this mob makes when it is hurt. - */ + @Override protected String getHurtSound() { return "mob.irongolem.hit"; } - /** - * Returns the sound this mob makes on death. - */ + @Override protected String getDeathSound() { return "mob.irongolem.death"; } - /** - * Returns the volume for the sounds this mob makes. - */ - protected float getSoundVolume() { - return 1.0F; - } - /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ + @Override public void onLivingUpdate() { super.onLivingUpdate(); @@ -166,195 +115,27 @@ public void onLivingUpdate() { } } - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() { - super.onUpdate(); - } - - public float getEyeHeight() { - return this.height * 0.8F; - } - - /** - * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently - * use in wolves. - */ - public int getVerticalFaceSpeed() { - return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); - } - - /** - * Called when the entity is attacked. - */ - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - if (this.isEntityInvulnerable()) { - return false; - } else { - Entity entity = par1DamageSource.getEntity(); - this.aiSit.setSitting(false); - - if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { - par2 = (par2 + 1.0F) / 2.0F; - } - - return super.attackEntityFrom(par1DamageSource, par2); - } - } - - public boolean attackEntityAsMob(Entity par1Entity) { + @Override + public boolean attackEntityAsMob(Entity entity) { this.attackTimer = 10; this.worldObj.setEntityState(this, (byte) 4); - boolean flag = par1Entity - .attackEntityFrom(DamageSource.causeMobDamage(this), (float) (7 + this.rand.nextInt(15))); + boolean flag = entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) (7 + this.rand.nextInt(15))); if (flag) { - par1Entity.motionY += 0.4000000059604645D; + entity.motionY += 0.4D; } this.playSound("mob.irongolem.throw", 1.0F, 1.0F); return flag; } - public void setTamed(boolean par1) { - super.setTamed(par1); - - if (par1) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } - } - - /** - * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. - */ @Override - public boolean interact(EntityPlayer par1EntityPlayer) { - ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); - - if (this.isTamed()) { - if (itemstack != null) { - if (itemstack.getItem() instanceof ItemFood) { - ItemFood itemfood = (ItemFood) itemstack.getItem(); - - if (itemfood.isWolfsFavoriteMeat() - && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - this.heal((float) itemfood.func_150905_g(itemstack)); - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory - .setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - return true; - } - } - } - - if (this.getOwner() instanceof EntityPlayer - && SpellHelper.getUsername(par1EntityPlayer) - .equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) - && !this.isBreedingItem(itemstack)) { - if (!this.worldObj.isRemote) { - this.aiSit.setSitting(!this.isSitting()); - this.isJumping = false; - this.setPathToEntity(null); - this.setTarget(null); - this.setAttackTarget(null); - } - - this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting()); - } - } else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry()) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - if (!this.worldObj.isRemote) { - if (this.rand.nextInt(1) == 0) { - this.setTamed(true); - this.setPathToEntity(null); - this.setAttackTarget(null); - this.aiSit.setSitting(true); - this.setHealth(maxTamedHealth); - this.func_152115_b(par1EntityPlayer.getUniqueID().toString()); - this.playTameEffect(true); - this.worldObj.setEntityState(this, (byte) 7); - } else { - this.playTameEffect(false); - this.worldObj.setEntityState(this, (byte) 6); - } - } - - return true; - } - - return super.interact(par1EntityPlayer); - } - - /** - * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on - * the animal type) - */ - public boolean isBreedingItem(ItemStack par1ItemStack) { - return false; - } - - /** - * Determines whether this wolf is angry or not. - */ - public boolean isAngry() { - return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0; - } - - /** - * Sets whether this wolf is angry or not. - */ - public void setAngry(boolean par1) { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - - if (par1) { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2))); - } else { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3))); - } - } - - /** - * Determines if an entity can be despawned, used on idle far away entities - */ - protected boolean canDespawn() { - return false; + protected float maxTamedHealth() { + return maxTamedHealth; } @Override - public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase) { - if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast)) { - if (par1EntityLivingBase instanceof EntityBileDemon) { - EntityBileDemon entitywolf = (EntityBileDemon) par1EntityLivingBase; - - if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase) { - return false; - } - } - - return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer - && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) - ? false - : !(par1EntityLivingBase instanceof EntityHorse) - || !((EntityHorse) par1EntityLivingBase).isTame(); - } else { - return false; - } + protected float maxUntamedHealth() { + return maxUntamedHealth; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityBoulderFist.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityBoulderFist.java index 58de9760c6..1da509335a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityBoulderFist.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityBoulderFist.java @@ -13,36 +13,27 @@ import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; -import net.minecraft.entity.monster.EntityCreeper; -import net.minecraft.entity.monster.EntityGhast; -import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; -import WayofTime.alchemicalWizardry.ModItems; import WayofTime.alchemicalWizardry.common.EntityAITargetAggro; import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class EntityBoulderFist extends EntityDemon { - private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( + private final EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( this, EntityPlayer.class, 1.2D, false); - private static float maxTamedHealth = 60.0F; - private static float maxUntamedHealth = 50.0F; + private static final float maxTamedHealth = 60.0F; + private static final float maxUntamedHealth = 50.0F; - public EntityBoulderFist(World par1World) { - super(par1World, AlchemicalWizardry.entityBoulderFistID); + public EntityBoulderFist(World world) { + super(world, AlchemicalWizardry.entityBoulderFistID); this.setSize(0.8F, 1.2F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(1, new EntityAISwimming(this)); @@ -60,7 +51,7 @@ public EntityBoulderFist(World par1World) { this.setAggro(false); this.setTamed(false); - if (par1World != null && !par1World.isRemote) { + if (world != null && !world.isRemote) { this.setCombatTask(); } } @@ -68,76 +59,37 @@ public EntityBoulderFist(World par1World) { @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); - // This line affects the speed of the monster - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); - - // My guess is that this will alter the max health - if (this.isTamed()) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D); } /** * Returns true if the newer Entity AI code should be run */ + @Override public boolean isAIEnabled() { return true; } - /** - * Sets the active target the Task system uses for tracking - */ - public void setAttackTarget(EntityLivingBase par1EntityLivingBase) { - super.setAttackTarget(par1EntityLivingBase); - - if (par1EntityLivingBase == null) { - this.setAngry(false); - } else if (!this.isTamed()) { - this.setAngry(true); - } - } - /** * main AI tick function, replaces updateEntityActionState */ + @Override protected void updateAITick() { this.dataWatcher.updateObject(18, this.getHealth()); } + @Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, this.getHealth()); + this.setCombatTask(); } - /** - * Plays step sound at given x, y, z for the entity - */ protected void playStepSound(int par1, int par2, int par3, int par4) { this.playSound("mob.zombie.step", 0.15F, 1.0F); } - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeEntityToNBT(par1NBTTagCompound); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readEntityFromNBT(par1NBTTagCompound); - this.setAngry(par1NBTTagCompound.getBoolean("Angry")); - - this.setCombatTask(); - } - - /** - * Returns the sound this mob makes while it's alive. - */ + @Override protected String getLivingSound() { // TODO change sounds return this.isAngry() ? "mob.wolf.growl" @@ -147,223 +99,29 @@ protected String getLivingSound() { : "mob.wolf.bark"); } - /** - * Returns the sound this mob makes when it is hurt. - */ + @Override protected String getHurtSound() { return "mob.wolf.hurt"; } - /** - * Returns the sound this mob makes on death. - */ + @Override protected String getDeathSound() { return "mob.wolf.death"; } - /** - * Returns the volume for the sounds this mob makes. - */ + @Override protected float getSoundVolume() { return 0.4F; } - /** - * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons - * use this to react to sunlight and start to burn. - */ - public void onLivingUpdate() { - super.onLivingUpdate(); - } - - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() { - super.onUpdate(); - } - - public float getEyeHeight() { - return this.height * 0.8F; - } - - /** - * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently - * use in wolves. - */ - public int getVerticalFaceSpeed() { - return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); - } - - /** - * Called when the entity is attacked. - */ - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - if (this.isEntityInvulnerable()) { - return false; - } else { - Entity entity = par1DamageSource.getEntity(); - this.aiSit.setSitting(false); - - if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { - par2 = (par2 + 1.0F) / 2.0F; - } - - return super.attackEntityFrom(par1DamageSource, par2); - } - } - - public boolean attackEntityAsMob(Entity par1Entity) { - int i = this.isTamed() ? 6 : 7; - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); - } - - public void setTamed(boolean par1) { - super.setTamed(par1); - - if (par1) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } - } - - /** - * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. - */ @Override - public boolean interact(EntityPlayer par1EntityPlayer) { - ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); - - if (this.isTamed()) { - if (itemstack != null) { - if (itemstack.getItem() instanceof ItemFood) { - ItemFood itemfood = (ItemFood) itemstack.getItem(); - - if (itemfood.isWolfsFavoriteMeat() - && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - this.heal((float) itemfood.func_150905_g(itemstack)); - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory - .setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - return true; - } - } - } - - if (this.getOwner() instanceof EntityPlayer - && SpellHelper.getUsername(par1EntityPlayer) - .equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) - && !this.isBreedingItem(itemstack)) { - if (!this.worldObj.isRemote) { - this.aiSit.setSitting(!this.isSitting()); - this.isJumping = false; - this.setPathToEntity(null); - this.setTarget(null); - this.setAttackTarget(null); - } - - this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting()); - } - } else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry()) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - if (!this.worldObj.isRemote) { - if (this.rand.nextInt(1) == 0) { - this.setTamed(true); - this.setPathToEntity(null); - this.setAttackTarget(null); - this.aiSit.setSitting(true); - this.setHealth(maxTamedHealth); - this.func_152115_b(par1EntityPlayer.getUniqueID().toString()); - this.playTameEffect(true); - this.worldObj.setEntityState(this, (byte) 7); - } else { - this.playTameEffect(false); - this.worldObj.setEntityState(this, (byte) 6); - } - } - - return true; - } - - return super.interact(par1EntityPlayer); - } - - /** - * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on - * the animal type) - */ - public boolean isBreedingItem(ItemStack par1ItemStack) { - return false; - } - - /** - * Determines whether this wolf is angry or not. - */ - public boolean isAngry() { - return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0; - } - - /** - * Sets whether this wolf is angry or not. - */ - public void setAngry(boolean par1) { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - - if (par1) { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2))); - } else { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3))); - } - } - - /** - * Determines if an entity can be despawned, used on idle far away entities - */ - protected boolean canDespawn() { - return false; - } - - @Override - public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase) { - if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast)) { - if (par1EntityLivingBase instanceof EntityBoulderFist) { - EntityBoulderFist entitywolf = (EntityBoulderFist) par1EntityLivingBase; - - if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase) { - return false; - } - } - - return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer - && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) - ? false - : !(par1EntityLivingBase instanceof EntityHorse) - || !((EntityHorse) par1EntityLivingBase).isTame(); - } else { - return false; - } + public boolean attackEntityAsMob(Entity entity) { + int i = this.isTamed() ? 6 : 7; + return entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } - /** - * Attack the specified entity using a ranged attack. - */ - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { - HolyProjectile hol = new HolyProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 5, 600); + public void attackEntityWithRangedAttack(EntityLivingBase entityLivingBase, float par2) { + HolyProjectile hol = new HolyProjectile(worldObj, this, entityLivingBase, 1.8f, 0f, 5, 600); this.worldObj.spawnEntityInWorld(hol); } @@ -375,4 +133,14 @@ public void setCombatTask() { // this.tasks.removeTask(this.aiArrowAttack); this.tasks.addTask(4, this.aiAttackOnCollide); } + + @Override + protected float maxTamedHealth() { + return maxTamedHealth; + } + + @Override + protected float maxUntamedHealth() { + return maxUntamedHealth; + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityDemon.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityDemon.java index 9e759117d1..3617989450 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityDemon.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityDemon.java @@ -1,11 +1,20 @@ package WayofTime.alchemicalWizardry.common.entity.mob; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntityGhast; +import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.DamageSource; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.ModItems; @@ -20,11 +29,21 @@ public class EntityDemon extends EntityTameable implements IDemon { protected boolean dropCrystal = true; - public EntityDemon(World par1World, String demonID) { - super(par1World); + public EntityDemon(World world, String demonID) { + super(world); this.demonID = demonID; } + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + if (this.isTamed()) { + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth()); + } else { + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth()); + } + } + @Override public boolean getDoesDropCrystal() { return dropCrystal; @@ -59,36 +78,36 @@ public EntityAgeable createChild(EntityAgeable entityageable) { @Override public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); - tag.setBoolean("dropCrystal", this.getDoesDropCrystal()); } @Override public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); - this.setDropCrystal(tag.getBoolean("dropCrystal")); } @Override protected void dropFewItems(boolean par1, int par2) { - if (this.getDoesDropCrystal()) { - ItemStack drop = new ItemStack(ModItems.demonPlacer); + if (!this.getDoesDropCrystal()) { + return; + } + ItemStack drop = new ItemStack(ModItems.demonPlacer); - DemonPlacer.setDemonString(drop, this.getDemonID()); + DemonPlacer.setDemonString(drop, this.getDemonID()); - if ((this.getOwner() instanceof EntityPlayer)) { - DemonPlacer.setOwnerName(drop, SpellHelper.getUsername((EntityPlayer) this.getOwner())); - } - - if (this.hasCustomNameTag()) { - drop.setStackDisplayName(this.getCustomNameTag()); - } + if ((this.getOwner() instanceof EntityPlayer)) { + DemonPlacer.setOwnerName(drop, SpellHelper.getUsername((EntityPlayer) this.getOwner())); + } - this.entityDropItem(drop, 0.0f); + if (this.hasCustomNameTag()) { + drop.setStackDisplayName(this.getCustomNameTag()); } + + this.entityDropItem(drop, 0.0f); } + @Override public void onLivingUpdate() { super.onLivingUpdate(); @@ -111,6 +130,168 @@ public void sendSittingMessageToPlayer(EntityPlayer owner, boolean isSitting) { } } + @Override + public boolean interact(EntityPlayer player) { + ItemStack item = player.inventory.getCurrentItem(); + + if (this.isTamed()) { + if (item != null) { + if (item.getItem() instanceof ItemFood itemfood) { + + if (itemfood.isWolfsFavoriteMeat() + && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth()) { + if (!player.capabilities.isCreativeMode) { + --item.stackSize; + } + + this.heal((float) itemfood.func_150905_g(item)); + + if (item.stackSize <= 0) { + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + + return true; + } + } + } + + if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(player).equalsIgnoreCase( + SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(item)) { + if (!this.worldObj.isRemote) { + this.aiSit.setSitting(!this.isSitting()); + this.isJumping = false; + this.setPathToEntity(null); + this.setTarget(null); + this.setAttackTarget(null); + } + + this.sendSittingMessageToPlayer(player, !this.isSitting()); + } + } else if (item != null && item.getItem() != null + && item.getItem().equals(ModItems.weakBloodOrb) + && !this.isAngry()) { + if (!player.capabilities.isCreativeMode) { + --item.stackSize; + } + + if (item.stackSize <= 0) { + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + + if (!this.worldObj.isRemote) { + this.rand.nextInt(1); + this.setTamed(true); + this.setPathToEntity(null); + this.setAttackTarget(null); + this.aiSit.setSitting(true); + this.setHealth(maxTamedHealth()); + this.func_152115_b(player.getUniqueID().toString()); + this.playTameEffect(true); + this.worldObj.setEntityState(this, (byte) 7); + } + + return true; + } + + return super.interact(player); + } + + protected float maxTamedHealth() { + return 1; + } + + protected float maxUntamedHealth() { + return 1; + } + + @Override + public boolean func_142018_a(EntityLivingBase target, EntityLivingBase owner) { // shouldAttackEntity + if (target instanceof EntityCreeper || target instanceof EntityGhast) { + return false; + } + if (target instanceof EntityTameable tameable) { + if (tameable.isTamed() && tameable.getOwner() == owner) { + return false; + } + } + + return (!(target instanceof EntityPlayer tPlayer) || !(owner instanceof EntityPlayer oPlayer) + || oPlayer.canAttackPlayer(tPlayer)) + && (!(target instanceof EntityHorse) || !((EntityHorse) target).isTame()); + } + + public boolean isAngry() { + return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0; + } + + public void setAngry(boolean par1) { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + + if (par1) { + this.dataWatcher.updateObject(16, (byte) (b0 | 2)); + } else { + this.dataWatcher.updateObject(16, (byte) (b0 & -3)); + } + } + + /** + * Called when the entity is attacked. + */ + @Override + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { + if (this.isEntityInvulnerable()) { + return false; + } else { + Entity entity = par1DamageSource.getEntity(); + this.aiSit.setSitting(false); + + if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { + par2 = (par2 + 1.0F) / 2.0F; + } + + return super.attackEntityFrom(par1DamageSource, par2); + } + } + + @Override + public void setTamed(boolean par1) { + super.setTamed(par1); + + if (par1) { + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth()); + } else { + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth()); + } + } + + /** + * Sets the active target the Task system uses for tracking + */ + @Override + public void setAttackTarget(EntityLivingBase entityLivingBase) { + super.setAttackTarget(entityLivingBase); + + if (entityLivingBase == null) { + this.setAngry(false); + } else if (!this.isTamed()) { + this.setAngry(true); + } + } + + @Override + public boolean isBreedingItem(ItemStack item) { + return false; + } + + /** + * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently + * use in wolves. + */ + @Override + public int getVerticalFaceSpeed() { + return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); + } + public String getDemonID() { return this.demonID; } @@ -118,4 +299,21 @@ public String getDemonID() { protected void setDemonID(String id) { this.demonID = id; } + + @Override + public void writeEntityToNBT(NBTTagCompound tag) { + super.writeEntityToNBT(tag); + tag.setBoolean("Angry", this.isAngry()); + } + + @Override + public void readEntityFromNBT(NBTTagCompound tag) { + super.readEntityFromNBT(tag); + this.setAngry(tag.getBoolean("Angry")); + } + + @Override + public float getEyeHeight() { + return this.height * 0.8F; + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityEarthElemental.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityEarthElemental.java index 10791f9714..a0382354d1 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityEarthElemental.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityEarthElemental.java @@ -16,6 +16,7 @@ public EntityEarthElemental(World world) { super(world, AlchemicalWizardry.entityEarthElementalID); } + @Override public void inflictEffectOnEntity(Entity target) { if (target instanceof EntityLivingBase) { target.attackEntityFrom(DamageSource.causeMobDamage(this), 10); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityElemental.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityElemental.java index 6d2d2c4366..e68ef83da8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityElemental.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityElemental.java @@ -7,11 +7,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; -import net.minecraft.entity.monster.EntityCreeper; -import net.minecraft.entity.monster.EntityGhast; -import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; @@ -25,22 +21,22 @@ public class EntityElemental extends EntityDemon { - private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( + private final EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( this, EntityPlayer.class, 1.2D, false); - private static float maxTamedHealth = 100.0F; - private static float maxUntamedHealth = 100.0F; + private static final float maxTamedHealth = 100.0F; + private static final float maxUntamedHealth = 100.0F; - public EntityElemental(World par1World, String entityAirElementalID) { - super(par1World, entityAirElementalID); + public EntityElemental(World world, String entityAirElementalID) { + super(world, entityAirElementalID); this.setSize(0.5F, 1.0F); this.setAggro(false); this.setTamed(false); - if (par1World != null && !par1World.isRemote) { + if (world != null && !world.isRemote) { this.setCombatTask(); } } @@ -59,33 +55,31 @@ public EntityElemental(World par1World, String entityAirElementalID) { public int prevAttackCounter; public int attackCounter; - /** - * The explosion radius of spawned fireballs. - */ + @Override protected void dropFewItems(boolean par1, int par2) { if (worldObj.rand.nextFloat() < (1 - Math.pow(0.6f, par2 + 1))) { this.entityDropItem(new ItemStack(ModItems.demonBloodShard, 1, 0), 0.0f); } } + @Override protected void fall(float par1) {} /** * Takes in the distance the entity has fallen this tick and whether its on the ground to update the fall distance * and deal fall damage if landing on the ground. Args: distanceFallenThisTick, onGround */ + @Override protected void updateFallState(double par1, boolean par3) {} - /** - * Moves the entity based on the specified heading. Args: strafe, forward - */ + @Override public void moveEntityWithHeading(float par1, float par2) { if (this.isInWater()) { this.moveFlying(par1, par2, 0.02F); this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.800000011920929D; - this.motionY *= 0.800000011920929D; - this.motionZ *= 0.800000011920929D; + this.motionX *= 0.8D; + this.motionY *= 0.8D; + this.motionZ *= 0.8D; } else if (this.handleLavaMovement()) { this.moveFlying(par1, par2, 0.02F); this.moveEntity(this.motionX, this.motionY, this.motionZ); @@ -96,7 +90,7 @@ public void moveEntityWithHeading(float par1, float par2) { float f2 = 0.91F; if (this.onGround) { - f2 = 0.54600006F; + f2 = 0.546F; Block i = this.worldObj.getBlock( MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, @@ -112,7 +106,7 @@ public void moveEntityWithHeading(float par1, float par2) { f2 = 0.91F; if (this.onGround) { - f2 = 0.54600006F; + f2 = 0.546F; Block j = this.worldObj.getBlock( MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, @@ -124,31 +118,33 @@ public void moveEntityWithHeading(float par1, float par2) { } this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= (double) f2; - this.motionY *= (double) f2; - this.motionZ *= (double) f2; + this.motionX *= f2; + this.motionY *= f2; + this.motionZ *= f2; } } /** * returns true if this entity is by a ladder, false otherwise */ + @Override public boolean isOnLadder() { return false; } + @Override protected void updateEntityActionState() { if (this.getHealth() <= this.getMaxHealth() / 2.0f && worldObj.rand.nextInt(200) == 0) { this.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionReciprocation.id, 100, 1)); } this.prevAttackCounter = this.attackCounter; - double d0 = this.waypointX - this.posX; - double d1 = this.waypointY - this.posY; - double d2 = this.waypointZ - this.posZ; - double d3 = d0 * d0 + d1 * d1 + d2 * d2; + double dx = this.waypointX - this.posX; + double dy = this.waypointY - this.posY; + double dz = this.waypointZ - this.posZ; + double dist = dx * dx + dy * dy + dz * dz; - if (d3 < 1.0D || d3 > 3600.0D) { + if (dist < 1.0D || dist > 3600.0D) { this.waypointX = this.posX + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); this.waypointY = this.posY + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); this.waypointZ = this.posZ + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); @@ -156,12 +152,12 @@ protected void updateEntityActionState() { if (this.courseChangeCooldown-- <= 0) { this.courseChangeCooldown += this.rand.nextInt(5) + 2; - d3 = (double) MathHelper.sqrt_double(d3); + dist = MathHelper.sqrt_double(dist); - if (this.isCourseTraversable(this.waypointX, this.waypointY, this.waypointZ, d3)) { - this.motionX += d0 / d3 * 0.1D; - this.motionY += d1 / d3 * 0.1D; - this.motionZ += d2 / d3 * 0.1D; + if (this.isCourseTraversable(dist)) { + this.motionX += dx / dist * 0.1D; + this.motionY += dy / dist * 0.1D; + this.motionZ += dz / dist * 0.1D; } else { this.waypointX = this.posX + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); this.waypointY = this.posY + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); @@ -181,39 +177,31 @@ protected void updateEntityActionState() { } } - double d4 = 64.0D; - - if (this.targetedEntity != null && this.targetedEntity.getDistanceSqToEntity(this) < d4 * d4) { - double d5 = this.targetedEntity.posX - this.posX; - double d6 = this.targetedEntity.boundingBox.minY + (double) (this.targetedEntity.height / 2.0F) + if (this.targetedEntity != null && this.targetedEntity.getDistanceSqToEntity(this) < 4096D) { + double x = this.targetedEntity.posX - this.posX; + double y = this.targetedEntity.boundingBox.minY + (double) (this.targetedEntity.height / 2.0F) - (this.posY + (double) (this.height / 2.0F)); - double d7 = this.targetedEntity.posZ - this.posZ; - this.renderYawOffset = this.rotationYaw = -((float) Math.atan2(d5, d7)) * 180.0F / (float) Math.PI; + double z = this.targetedEntity.posZ - this.posZ; + this.renderYawOffset = this.rotationYaw = -((float) Math.atan2(x, z)) * 180.0F / (float) Math.PI; + double distance = Math.sqrt(x * x + y * y + z * z); if (this.courseChangeCooldown <= 0) { - if (isCourseTraversable( - this.targetedEntity.posX, - this.targetedEntity.posY, - this.targetedEntity.posZ, - Math.sqrt(d5 * d5 + d6 * d6 + d7 * d7))) { + if (isCourseTraversable(distance)) { this.waypointX = this.targetedEntity.posX; this.waypointY = this.targetedEntity.posY; this.waypointZ = this.targetedEntity.posZ; - this.motionX += d5 / d3 * 0.1D; - this.motionY += d6 / d3 * 0.1D; - this.motionZ += d7 / d3 * 0.1D; } else { this.waypointX = this.posX + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); this.waypointY = this.posY + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); this.waypointZ = this.posZ + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); - this.motionX += d5 / d3 * 0.1D; - this.motionY += d6 / d3 * 0.1D; - this.motionZ += d7 / d3 * 0.1D; } + this.motionX += x / dist * 0.1D; + this.motionY += y / dist * 0.1D; + this.motionZ += z / dist * 0.1D; } if (this.canEntityBeSeen(this.targetedEntity)) { - if (Math.sqrt(d5 * d5 + d6 * d6 + d7 * d7) < 4) { + if (distance < 4) { ++this.attackCounter; if (this.attackCounter >= 10) { @@ -239,7 +227,7 @@ protected void updateEntityActionState() { /** * True if the ghast has an unobstructed line of travel to the waypoint. */ - private boolean isCourseTraversable(double par1, double par3, double par5, double par7) { + private boolean isCourseTraversable(double par7) { double d4 = (this.waypointX - this.posX) / par7; double d5 = (this.waypointY - this.posY) / par7; double d6 = (this.waypointZ - this.posZ) / par7; @@ -256,46 +244,27 @@ private boolean isCourseTraversable(double par1, double par3, double par5, doubl return true; } - /** - * Will return how many at most can spawn in a chunk at once. - */ + @Override public int getMaxSpawnedInChunk() { return 1; } - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeEntityToNBT(par1NBTTagCompound); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readEntityFromNBT(par1NBTTagCompound); - + @Override + public void readEntityFromNBT(NBTTagCompound tag) { + super.readEntityFromNBT(tag); this.setCombatTask(); } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); - // This line affects the speed of the monster - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); - - // My guess is that this will alter the max health - if (this.isTamed()) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D); } /** * Returns true if the newer Entity AI code should be run */ + @Override public boolean isAIEnabled() { return false; } @@ -303,157 +272,55 @@ public boolean isAIEnabled() { /** * Sets the active target the Task system uses for tracking */ - public void setAttackTarget(EntityLivingBase par1EntityLivingBase) { - super.setAttackTarget(par1EntityLivingBase); + @Override + public void setAttackTarget(EntityLivingBase entityLivingBase) { + super.setAttackTarget(entityLivingBase); } /** * main AI tick function, replaces updateEntityActionState */ + @Override protected void updateAITick() { this.dataWatcher.updateObject(18, this.getHealth()); } + @Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, this.getHealth()); this.dataWatcher.addObject(19, 0); } - /** - * Plays step sound at given x, y, z for the entity - */ protected void playStepSound(int par1, int par2, int par3, int par4) { this.playSound("mob.zombie.step", 0.15F, 1.0F); } - /** - * Returns the sound this mob makes while it's alive. - */ + @Override protected String getLivingSound() { // TODO change sounds return "none"; } - /** - * Returns the sound this mob makes when it is hurt. - */ + @Override protected String getHurtSound() { return "none"; } - /** - * Returns the sound this mob makes on death. - */ + @Override protected String getDeathSound() { return "none"; } - /** - * Returns the volume for the sounds this mob makes. - */ + @Override protected float getSoundVolume() { return 0.4F; } - /** - * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons - * use this to react to sunlight and start to burn. - */ - public void onLivingUpdate() { - super.onLivingUpdate(); - } - - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() { - super.onUpdate(); - } - - public float getEyeHeight() { - return this.height * 0.8F; - } - - /** - * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently - * use in wolves. - */ - public int getVerticalFaceSpeed() { - return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); - } - - /** - * Called when the entity is attacked. - */ - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - if (this.isEntityInvulnerable()) { - return false; - } else { - Entity entity = par1DamageSource.getEntity(); - this.aiSit.setSitting(false); - - if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { - par2 = (par2 + 1.0F) / 2.0F; - } - - return super.attackEntityFrom(par1DamageSource, par2); - } - } - - public boolean attackEntityAsMob(Entity par1Entity) { - int i = this.isTamed() ? 6 : 7; - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); - } - - public void setTamed(boolean par1) { - super.setTamed(par1); - - if (par1) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } - } - - /** - * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. - */ - - /** - * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on - * the animal type) - */ - public boolean isBreedingItem(ItemStack par1ItemStack) { - return false; - } - - /** - * Determines if an entity can be despawned, used on idle far away entities - */ - protected boolean canDespawn() { - return false; - } - @Override - public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase) { - if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast)) { - if (par1EntityLivingBase instanceof EntityBoulderFist) { - EntityBoulderFist entitywolf = (EntityBoulderFist) par1EntityLivingBase; - - if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase) { - return false; - } - } - - return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer - && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) - ? false - : !(par1EntityLivingBase instanceof EntityHorse) - || !((EntityHorse) par1EntityLivingBase).isTame(); - } else { - return false; - } + public boolean attackEntityAsMob(Entity entity) { + int i = this.isTamed() ? 6 : 7; + return entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } /** @@ -471,14 +338,14 @@ public void inflictEffectOnEntity(Entity target) { } } - public static Entity getClosestVulnerableMonsterToEntity(Entity par1Entity, double par2) { + public static Entity getClosestVulnerableMonsterToEntity(Entity entity, double par2) { double d4 = -1.0D; - double par1 = par1Entity.posX; - double par3 = par1Entity.posY; - double par5 = par1Entity.posZ; + double par1 = entity.posX; + double par3 = entity.posY; + double par5 = entity.posZ; EntityLivingBase entityLiving = null; - World world = par1Entity.worldObj; + World world = entity.worldObj; double range = Math.sqrt(par2); double verticalRange = Math.sqrt(par2); @@ -491,16 +358,14 @@ public static Entity getClosestVulnerableMonsterToEntity(Entity par1Entity, doub return null; } - for (int i = 0; i < entities.size(); ++i) { - EntityLivingBase entityLiving1 = entities.get(i); - - if (!(entityLiving1 instanceof EntityPlayer && ((EntityPlayer) entityLiving1).capabilities.disableDamage) + for (EntityLivingBase entityLiving1 : entities) { + if (!(entityLiving1 instanceof EntityPlayer player && player.capabilities.disableDamage) && entityLiving1.isEntityAlive()) { double d5 = entityLiving1.getDistanceSq(par1, par3, par5); double d6 = par2; if (entityLiving1.isSneaking()) { - d6 = par2 * 0.800000011920929D; + d6 = par2 * 0.8D; } if (entityLiving1.isInvisible()) { @@ -512,11 +377,11 @@ public static Entity getClosestVulnerableMonsterToEntity(Entity par1Entity, doub f = 0.1F; } - d6 *= (double) (0.7F * f); + d6 *= 0.7F * f; } if ((par2 < 0.0D || d5 < d6 * d6) && (d4 == -1.0D || d5 < d4)) { - if (par1Entity != entityLiving1) { + if (entity != entityLiving1) { d4 = d5; entityLiving = entityLiving1; } @@ -531,4 +396,14 @@ public static Entity getClosestVulnerableMonsterToEntity(Entity par1Entity, doub public int getTotalArmorValue() { return 10; } + + @Override + protected float maxTamedHealth() { + return maxTamedHealth; + } + + @Override + protected float maxUntamedHealth() { + return maxUntamedHealth; + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityFallenAngel.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityFallenAngel.java index f057f34819..67414dde42 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityFallenAngel.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityFallenAngel.java @@ -14,37 +14,29 @@ import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; -import net.minecraft.entity.monster.EntityCreeper; -import net.minecraft.entity.monster.EntityGhast; -import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; -import WayofTime.alchemicalWizardry.ModItems; import WayofTime.alchemicalWizardry.common.EntityAITargetAggro; import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class EntityFallenAngel extends EntityDemon implements IRangedAttackMob { - private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 40, 40, 15.0F); - private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( + private final EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 40, 40, 15.0F); + private final EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( this, EntityPlayer.class, 1.2D, false); - private static float maxTamedHealth = 50.0F; - private static float maxUntamedHealth = 50.0F; + private static final float maxTamedHealth = 50.0F; + private static final float maxUntamedHealth = 50.0F; - public EntityFallenAngel(World par1World) { - super(par1World, AlchemicalWizardry.entityFallenAngelID); + public EntityFallenAngel(World world) { + super(world, AlchemicalWizardry.entityFallenAngelID); this.setSize(0.7F, 1.8F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(1, new EntityAISwimming(this)); @@ -60,312 +52,79 @@ public EntityFallenAngel(World par1World) { this.setAggro(false); this.setTamed(false); - if (par1World != null && !par1World.isRemote) { + if (world != null && !world.isRemote) { this.setCombatTask(); } - - // this.isImmuneToFire = true; } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); - // This line affects the speed of the monster - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); - - // My guess is that this will alter the max health - if (this.isTamed()) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D); } /** * Returns true if the newer Entity AI code should be run */ + @Override public boolean isAIEnabled() { return true; } - /** - * Sets the active target the Task system uses for tracking - */ - public void setAttackTarget(EntityLivingBase par1EntityLivingBase) { - super.setAttackTarget(par1EntityLivingBase); - - if (par1EntityLivingBase == null) { - this.setAngry(false); - } else if (!this.isTamed()) { - this.setAngry(true); - } - } - /** * main AI tick function, replaces updateEntityActionState */ + @Override protected void updateAITick() { this.dataWatcher.updateObject(18, this.getHealth()); } + @Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, this.getHealth()); } - /** - * Plays step sound at given x, y, z for the entity - */ protected void playStepSound(int par1, int par2, int par3, int par4) { this.playSound("mob.zombie.step", 0.15F, 1.0F); } - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeEntityToNBT(par1NBTTagCompound); - par1NBTTagCompound.setBoolean("Angry", this.isAngry()); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readEntityFromNBT(par1NBTTagCompound); - this.setAngry(par1NBTTagCompound.getBoolean("Angry")); - + @Override + public void readEntityFromNBT(NBTTagCompound tag) { + super.readEntityFromNBT(tag); this.setCombatTask(); } - /** - * Returns the sound this mob makes while it's alive. - */ + @Override protected String getLivingSound() { // TODO change sounds return "none"; } - /** - * Returns the sound this mob makes when it is hurt. - */ + @Override protected String getHurtSound() { return "none"; } - /** - * Returns the sound this mob makes on death. - */ + @Override protected String getDeathSound() { return "mob.wolf.death"; } - /** - * Returns the volume for the sounds this mob makes. - */ + @Override protected float getSoundVolume() { return 0.4F; } - /** - * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons - * use this to react to sunlight and start to burn. - */ - public void onLivingUpdate() { - super.onLivingUpdate(); - } - - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() { - super.onUpdate(); - } - - public float getEyeHeight() { - return this.height * 0.8F; - } - - /** - * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently - * use in wolves. - */ - public int getVerticalFaceSpeed() { - return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); - } - - /** - * Called when the entity is attacked. - */ - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - if (this.isEntityInvulnerable()) { - return false; - } else { - Entity entity = par1DamageSource.getEntity(); - this.aiSit.setSitting(false); - - if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { - par2 = (par2 + 1.0F) / 2.0F; - } - - return super.attackEntityFrom(par1DamageSource, par2); - } - } - - public boolean attackEntityAsMob(Entity par1Entity) { + @Override + public boolean attackEntityAsMob(Entity entity) { int i = this.isTamed() ? 4 : 2; - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); + return entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } - public void setTamed(boolean par1) { - super.setTamed(par1); - - if (par1) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } - } - - /** - * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. - */ @Override - public boolean interact(EntityPlayer par1EntityPlayer) { - ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); - - if (this.isTamed()) { - if (itemstack != null) { - if (itemstack.getItem() instanceof ItemFood) { - ItemFood itemfood = (ItemFood) itemstack.getItem(); - - if (itemfood.isWolfsFavoriteMeat() - && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - this.heal((float) itemfood.func_150905_g(itemstack)); - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory - .setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - return true; - } - } - } - - if (this.getOwner() instanceof EntityPlayer - && SpellHelper.getUsername(par1EntityPlayer) - .equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) - && !this.isBreedingItem(itemstack)) { - if (!this.worldObj.isRemote) { - this.aiSit.setSitting(!this.isSitting()); - this.isJumping = false; - this.setPathToEntity(null); - this.setTarget(null); - this.setAttackTarget(null); - } - - this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting()); - } - } else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry()) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - if (!this.worldObj.isRemote) { - if (this.rand.nextInt(1) == 0) { - this.setTamed(true); - this.setPathToEntity(null); - this.setAttackTarget(null); - this.aiSit.setSitting(true); - this.setHealth(maxTamedHealth); - this.func_152115_b(par1EntityPlayer.getUniqueID().toString()); - this.playTameEffect(true); - this.worldObj.setEntityState(this, (byte) 7); - } else { - this.playTameEffect(false); - this.worldObj.setEntityState(this, (byte) 6); - } - } - - return true; - } - - return super.interact(par1EntityPlayer); - } - - /** - * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on - * the animal type) - */ - public boolean isBreedingItem(ItemStack par1ItemStack) { - return false; - // return par1ItemStack == null ? false : (!(Item.itemsList[par1ItemStack.itemID] instanceof ItemFood) ? false : - // ((ItemFood)Item.itemsList[par1ItemStack.itemID]).isWolfsFavoriteMeat()); - } - - /** - * Determines whether this wolf is angry or not. - */ - public boolean isAngry() { - return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0; - } - - /** - * Sets whether this wolf is angry or not. - */ - public void setAngry(boolean par1) { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - - if (par1) { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2))); - } else { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3))); - } - } - - /** - * Determines if an entity can be despawned, used on idle far away entities - */ - protected boolean canDespawn() { - // return !this.isTamed() && this.ticksExisted > 2400; - return false; - } - - public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase) { - if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast)) { - if (par1EntityLivingBase instanceof EntityFallenAngel) { - EntityFallenAngel entitywolf = (EntityFallenAngel) par1EntityLivingBase; - - if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase) { - return false; - } - } - - return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer - && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) - ? false - : !(par1EntityLivingBase instanceof EntityHorse) - || !((EntityHorse) par1EntityLivingBase).isTame(); - } else { - return false; - } - } - - /** - * Attack the specified entity using a ranged attack. - */ - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { - HolyProjectile hol = new HolyProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 5, 600); - this.worldObj.spawnEntityInWorld(hol); + public void attackEntityWithRangedAttack(EntityLivingBase entityLivingBase, float par2) { + this.worldObj.spawnEntityInWorld(new HolyProjectile(worldObj, this, entityLivingBase, 1.8f, 0f, 5, 600)); } /** @@ -376,4 +135,14 @@ public void setCombatTask() { this.tasks.removeTask(this.aiArrowAttack); this.tasks.addTask(4, this.aiArrowAttack); } + + @Override + protected float maxTamedHealth() { + return maxTamedHealth; + } + + @Override + protected float maxUntamedHealth() { + return maxUntamedHealth; + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityFireElemental.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityFireElemental.java index fc29aa186c..a58a5ac0ef 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityFireElemental.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityFireElemental.java @@ -15,11 +15,11 @@ public EntityFireElemental(World world) { this.isImmuneToFire = true; } + @Override public void inflictEffectOnEntity(Entity target) { - if (target instanceof EntityLivingBase) { + if (target instanceof EntityLivingBase t) { target.setFire(10); - ((EntityLivingBase) target) - .addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 150, 0)); + t.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 150, 0)); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityHolyElemental.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityHolyElemental.java index 0b48fa70c4..95575f082f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityHolyElemental.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityHolyElemental.java @@ -16,12 +16,12 @@ public EntityHolyElemental(World world) { super(world, AlchemicalWizardry.entityHolyElementalID); } + @Override public void inflictEffectOnEntity(Entity target) { - if (target instanceof EntityLivingBase) { + if (target instanceof EntityLivingBase t) { target.attackEntityFrom(DamageSource.causeMobDamage(this), 15); - ((EntityLivingBase) target) - .addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 150, 0)); - ((EntityLivingBase) target).addPotionEffect(new PotionEffect(Potion.poison.id, 100, 1)); + t.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 150, 0)); + t.addPotionEffect(new PotionEffect(Potion.poison.id, 100, 1)); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityIceDemon.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityIceDemon.java index 8d3a33ca44..6686c58c43 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityIceDemon.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityIceDemon.java @@ -14,38 +14,31 @@ import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; -import net.minecraft.entity.monster.EntityCreeper; -import net.minecraft.entity.monster.EntityGhast; -import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.util.Vec3; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; -import WayofTime.alchemicalWizardry.ModItems; import WayofTime.alchemicalWizardry.common.EntityAITargetAggro; import WayofTime.alchemicalWizardry.common.entity.projectile.IceProjectile; import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class EntityIceDemon extends EntityDemon implements IRangedAttackMob { - private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 30, 50, 15.0F); - private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( + private final EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 30, 50, 15.0F); + private final EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( this, EntityPlayer.class, 1.2D, false); - private static float maxTamedHealth = 50.0F; - private static float maxUntamedHealth = 30.0F; + private static final float maxTamedHealth = 50.0F; + private static final float maxUntamedHealth = 30.0F; - public EntityIceDemon(World par1World) { - super(par1World, AlchemicalWizardry.entityIceDemonID); + public EntityIceDemon(World world) { + super(world, AlchemicalWizardry.entityIceDemonID); this.setSize(0.5F, 2.0F); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, this.aiSit); @@ -60,7 +53,7 @@ public EntityIceDemon(World par1World) { this.setAggro(false); this.setTamed(false); - if (par1World != null && !par1World.isRemote) { + if (world != null && !world.isRemote) { this.setCombatTask(); } } @@ -68,20 +61,13 @@ public EntityIceDemon(World par1World) { @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); - // This line affects the speed of the monster - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.40000001192092896D); - - // My guess is that this will alter the max health - if (this.isTamed()) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.4D); } /** * Returns true if the newer Entity AI code should be run */ + @Override public boolean isAIEnabled() { return true; } @@ -89,10 +75,11 @@ public boolean isAIEnabled() { /** * Sets the active target the Task system uses for tracking */ - public void setAttackTarget(EntityLivingBase par1EntityLivingBase) { - super.setAttackTarget(par1EntityLivingBase); + @Override + public void setAttackTarget(EntityLivingBase entityLivingBase) { + super.setAttackTarget(entityLivingBase); - if (par1EntityLivingBase == null) { + if (entityLivingBase == null) { this.setAngry(false); } else if (!this.isTamed()) { this.setAngry(true); @@ -102,72 +89,48 @@ public void setAttackTarget(EntityLivingBase par1EntityLivingBase) { /** * main AI tick function, replaces updateEntityActionState */ + @Override protected void updateAITick() { this.dataWatcher.updateObject(18, this.getHealth()); } + @Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, this.getHealth()); } - /** - * Plays step sound at given x, y, z for the entity - */ protected void playStepSound(int par1, int par2, int par3, int par4) { this.playSound("mob.zombie.step", 0.15F, 1.0F); } - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeEntityToNBT(par1NBTTagCompound); - par1NBTTagCompound.setBoolean("Angry", this.isAngry()); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readEntityFromNBT(par1NBTTagCompound); - this.setAngry(par1NBTTagCompound.getBoolean("Angry")); - + @Override + public void readEntityFromNBT(NBTTagCompound tag) { + super.readEntityFromNBT(tag); this.setCombatTask(); } - /** - * Returns the sound this mob makes while it's alive. - */ + @Override protected String getLivingSound() { return "none"; } - /** - * Returns the sound this mob makes when it is hurt. - */ + @Override protected String getHurtSound() { return "mob.irongolem.hit"; } - /** - * Returns the sound this mob makes on death. - */ + @Override protected String getDeathSound() { return "mob.irongolem.death"; } - /** - * Returns the volume for the sounds this mob makes. - */ + @Override protected float getSoundVolume() { return 0.4F; } - /** - * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons - * use this to react to sunlight and start to burn. - */ + @Override public void onLivingUpdate() { super.onLivingUpdate(); int range = 2; @@ -189,193 +152,15 @@ public void onLivingUpdate() { } } - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() { - super.onUpdate(); - } - - public float getEyeHeight() { - return this.height * 0.8F; - } - - /** - * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently - * use in wolves. - */ - public int getVerticalFaceSpeed() { - return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); - } - - /** - * Called when the entity is attacked. - */ - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - if (this.isEntityInvulnerable()) { - return false; - } else { - Entity entity = par1DamageSource.getEntity(); - this.aiSit.setSitting(false); - - if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { - par2 = (par2 + 1.0F) / 2.0F; - } - - return super.attackEntityFrom(par1DamageSource, par2); - } - } - - public boolean attackEntityAsMob(Entity par1Entity) { + @Override + public boolean attackEntityAsMob(Entity entity) { int i = this.isTamed() ? 4 : 2; - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); + return entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } - public void setTamed(boolean par1) { - super.setTamed(par1); - - if (par1) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } - } - - /** - * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. - */ @Override - public boolean interact(EntityPlayer par1EntityPlayer) { - ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); - - if (this.isTamed()) { - if (itemstack != null) { - if (itemstack.getItem() instanceof ItemFood) { - ItemFood itemfood = (ItemFood) itemstack.getItem(); - - if (itemfood.isWolfsFavoriteMeat() - && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - this.heal((float) itemfood.func_150905_g(itemstack)); - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory - .setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - return true; - } - } - } - - if (this.getOwner() instanceof EntityPlayer - && SpellHelper.getUsername(par1EntityPlayer) - .equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) - && !this.isBreedingItem(itemstack)) { - if (!this.worldObj.isRemote) { - this.aiSit.setSitting(!this.isSitting()); - this.isJumping = false; - this.setPathToEntity(null); - this.setTarget(null); - this.setAttackTarget(null); - } - - this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting()); - } - } else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry()) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - if (!this.worldObj.isRemote) { - if (this.rand.nextInt(1) == 0) { - this.setTamed(true); - this.setPathToEntity(null); - this.setAttackTarget(null); - this.aiSit.setSitting(true); - this.setHealth(maxTamedHealth); - this.func_152115_b(par1EntityPlayer.getUniqueID().toString()); - this.playTameEffect(true); - this.worldObj.setEntityState(this, (byte) 7); - } else { - this.playTameEffect(false); - this.worldObj.setEntityState(this, (byte) 6); - } - } - - return true; - } - - return super.interact(par1EntityPlayer); - } - - /** - * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on - * the animal type) - */ - public boolean isBreedingItem(ItemStack par1ItemStack) { - return false; - } - - /** - * Determines whether this wolf is angry or not. - */ - public boolean isAngry() { - return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0; - } - - /** - * Sets whether this wolf is angry or not. - */ - public void setAngry(boolean par1) { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - - if (par1) { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2))); - } else { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3))); - } - } - - /** - * Determines if an entity can be despawned, used on idle far away entities - */ - protected boolean canDespawn() { - return false; - } - - public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase) { - if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast)) { - if (par1EntityLivingBase instanceof EntityIceDemon) { - EntityIceDemon entitywolf = (EntityIceDemon) par1EntityLivingBase; - - if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase) { - return false; - } - } - - return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer - && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) - ? false - : !(par1EntityLivingBase instanceof EntityHorse) - || !((EntityHorse) par1EntityLivingBase).isTame(); - } else { - return false; - } - } - - /** - * Attack the specified entity using a ranged attack. - */ - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { - IceProjectile hol = new IceProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 3, 600); + public void attackEntityWithRangedAttack(EntityLivingBase entityLivingBase, float par2) { + IceProjectile hol = new IceProjectile(worldObj, this, entityLivingBase, 1.8f, 0f, 3, 600); this.worldObj.spawnEntityInWorld(hol); } @@ -387,4 +172,14 @@ public void setCombatTask() { this.tasks.removeTask(this.aiArrowAttack); this.tasks.addTask(4, this.aiArrowAttack); } + + @Override + protected float maxTamedHealth() { + return maxTamedHealth; + } + + @Override + protected float maxUntamedHealth() { + return maxUntamedHealth; + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityLowerGuardian.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityLowerGuardian.java index e09d300af9..e4dc0ab032 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityLowerGuardian.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityLowerGuardian.java @@ -1,7 +1,6 @@ package WayofTime.alchemicalWizardry.common.entity.mob; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIFollowOwner; @@ -12,30 +11,22 @@ import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; -import net.minecraft.entity.monster.EntityCreeper; -import net.minecraft.entity.monster.EntityGhast; -import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; -import WayofTime.alchemicalWizardry.ModItems; import WayofTime.alchemicalWizardry.common.EntityAITargetAggro; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class EntityLowerGuardian extends EntityDemon { - private static float maxTamedHealth = 50.0F; - private static float maxUntamedHealth = 30.0F; + private static final float maxTamedHealth = 50.0F; + private static final float maxUntamedHealth = 30.0F; private int attackTimer; - public EntityLowerGuardian(World par1World) { - super(par1World, AlchemicalWizardry.entityLowerGuardianID); + public EntityLowerGuardian(World world) { + super(world, AlchemicalWizardry.entityLowerGuardianID); this.setSize(0.7F, 1.8F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(1, new EntityAISwimming(this)); @@ -57,108 +48,69 @@ public EntityLowerGuardian(World par1World) { @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); - // This line affects the speed of the monster - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); - - // My guess is that this will alter the max health - if (this.isTamed()) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D); } /** * Returns true if the newer Entity AI code should be run */ + @Override public boolean isAIEnabled() { return true; } - /** - * Sets the active target the Task system uses for tracking - */ - public void setAttackTarget(EntityLivingBase par1EntityLivingBase) { - super.setAttackTarget(par1EntityLivingBase); - - if (par1EntityLivingBase == null) { - this.setAngry(false); - } else if (!this.isTamed()) { - this.setAngry(true); - } - } - /** * main AI tick function, replaces updateEntityActionState */ + @Override protected void updateAITick() { this.dataWatcher.updateObject(18, this.getHealth()); } + @Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, this.getHealth()); } - /** - * Plays step sound at given x, y, z for the entity - */ protected void playStepSound(int par1, int par2, int par3, int par4) { this.playSound("mob.zombie.step", 0.15F, 1.0F); } - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeEntityToNBT(par1NBTTagCompound); - par1NBTTagCompound.setBoolean("Angry", this.isAngry()); - par1NBTTagCompound.setByte("attackTimer", (byte) attackTimer); - par1NBTTagCompound.setBoolean("isAggro", this.isAggro()); + @Override + public void writeEntityToNBT(NBTTagCompound tag) { + super.writeEntityToNBT(tag); + tag.setByte("attackTimer", (byte) attackTimer); + tag.setBoolean("isAggro", this.isAggro()); } - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readEntityFromNBT(par1NBTTagCompound); - this.setAngry(par1NBTTagCompound.getBoolean("Angry")); + @Override + public void readEntityFromNBT(NBTTagCompound tag) { + super.readEntityFromNBT(tag); - attackTimer = par1NBTTagCompound.getByte("attackTimer"); + attackTimer = tag.getByte("attackTimer"); } - /** - * Returns the sound this mob makes while it's alive. - */ + @Override protected String getLivingSound() { return "none"; } - /** - * Returns the sound this mob makes when it is hurt. - */ + @Override protected String getHurtSound() { return "mob.irongolem.hit"; } - /** - * Returns the sound this mob makes on death. - */ + @Override protected String getDeathSound() { return "mob.irongolem.death"; } - /** - * Returns the volume for the sounds this mob makes. - */ - protected float getSoundVolume() { - return 1.0F; - } - /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ + @Override public void onLivingUpdate() { super.onLivingUpdate(); @@ -174,191 +126,32 @@ public int getAttackTimer() { /** * Called to update the entity's position/logic. */ + @Override public void onUpdate() { super.onUpdate(); } - public float getEyeHeight() { - return this.height * 0.8F; - } - - /** - * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently - * use in wolves. - */ - public int getVerticalFaceSpeed() { - return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); - } - - /** - * Called when the entity is attacked. - */ - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - if (this.isEntityInvulnerable()) { - return false; - } else { - Entity entity = par1DamageSource.getEntity(); - this.aiSit.setSitting(false); - - if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { - par2 = (par2 + 1.0F) / 2.0F; - } - - return super.attackEntityFrom(par1DamageSource, par2); - } - } - - public boolean attackEntityAsMob(Entity par1Entity) { + @Override + public boolean attackEntityAsMob(Entity entity) { this.attackTimer = 10; this.worldObj.setEntityState(this, (byte) 4); - boolean flag = par1Entity - .attackEntityFrom(DamageSource.causeMobDamage(this), (float) (7 + this.rand.nextInt(15))); + boolean flag = entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) (7 + this.rand.nextInt(15))); if (flag) { - par1Entity.motionY += 0.4000000059604645D; + entity.motionY += 0.4D; } this.playSound("mob.irongolem.throw", 1.0F, 1.0F); return flag; } - public void setTamed(boolean par1) { - super.setTamed(par1); - - if (par1) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } - } - - /** - * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. - */ @Override - public boolean interact(EntityPlayer par1EntityPlayer) { - ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); - - if (this.isTamed()) { - if (itemstack != null) { - if (itemstack.getItem() instanceof ItemFood) { - ItemFood itemfood = (ItemFood) itemstack.getItem(); - - if (itemfood.isWolfsFavoriteMeat() - && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - this.heal((float) itemfood.func_150905_g(itemstack)); - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory - .setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - return true; - } - } - } - - if (this.getOwner() instanceof EntityPlayer - && SpellHelper.getUsername(par1EntityPlayer) - .equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) - && !this.isBreedingItem(itemstack)) { - if (!this.worldObj.isRemote) { - this.aiSit.setSitting(!this.isSitting()); - this.isJumping = false; - this.setPathToEntity(null); - this.setTarget(null); - this.setAttackTarget(null); - } - - this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting()); - } - } else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry()) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - if (!this.worldObj.isRemote) { - if (this.rand.nextInt(1) == 0) { - this.setTamed(true); - this.setPathToEntity(null); - this.setAttackTarget(null); - this.aiSit.setSitting(true); - this.setHealth(maxTamedHealth); - this.func_152115_b(par1EntityPlayer.getUniqueID().toString()); - this.playTameEffect(true); - this.worldObj.setEntityState(this, (byte) 7); - } else { - this.playTameEffect(false); - this.worldObj.setEntityState(this, (byte) 6); - } - } - - return true; - } - - return super.interact(par1EntityPlayer); + protected float maxTamedHealth() { + return maxTamedHealth; } - /** - * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on - * the animal type) - */ - public boolean isBreedingItem(ItemStack par1ItemStack) { - return false; - } - - /** - * Determines whether this wolf is angry or not. - */ - public boolean isAngry() { - return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0; - } - - /** - * Sets whether this wolf is angry or not. - */ - public void setAngry(boolean par1) { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - - if (par1) { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2))); - } else { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3))); - } - } - - /** - * Determines if an entity can be despawned, used on idle far away entities - */ - protected boolean canDespawn() { - return false; - } - - public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase) { - if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast)) { - if (par1EntityLivingBase instanceof EntityLowerGuardian) { - EntityLowerGuardian entitywolf = (EntityLowerGuardian) par1EntityLivingBase; - - if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase) { - return false; - } - } - - return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer - && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) - ? false - : !(par1EntityLivingBase instanceof EntityHorse) - || !((EntityHorse) par1EntityLivingBase).isTame(); - } else { - return false; - } + @Override + protected float maxUntamedHealth() { + return maxUntamedHealth; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityShade.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityShade.java index 79f056965e..cee82981e6 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityShade.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityShade.java @@ -12,36 +12,28 @@ import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; -import net.minecraft.entity.monster.EntityCreeper; -import net.minecraft.entity.monster.EntityGhast; -import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; -import WayofTime.alchemicalWizardry.ModItems; import WayofTime.alchemicalWizardry.common.EntityAITargetAggro; import WayofTime.alchemicalWizardry.common.entity.projectile.HolyProjectile; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class EntityShade extends EntityDemon { - private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( + private final EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( this, EntityPlayer.class, 1.2D, false); - private static float maxTamedHealth = 50.0F; - private static float maxUntamedHealth = 100.0F; + private static final float maxTamedHealth = 50.0F; + private static final float maxUntamedHealth = 100.0F; - public EntityShade(World par1World) { - super(par1World, AlchemicalWizardry.entityShadeID); + public EntityShade(World world) { + super(world, AlchemicalWizardry.entityShadeID); this.setSize(0.8F, 2.0F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(1, new EntityAISwimming(this)); @@ -58,7 +50,7 @@ public EntityShade(World par1World) { this.setAggro(false); this.setTamed(false); - if (par1World != null && !par1World.isRemote) { + if (world != null && !world.isRemote) { this.setCombatTask(); } } @@ -66,299 +58,77 @@ public EntityShade(World par1World) { @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); - // This line affects the speed of the monster - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); - - // My guess is that this will alter the max health - if (this.isTamed()) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D); } /** * Returns true if the newer Entity AI code should be run */ + @Override public boolean isAIEnabled() { return true; } - /** - * Sets the active target the Task system uses for tracking - */ - public void setAttackTarget(EntityLivingBase par1EntityLivingBase) { - super.setAttackTarget(par1EntityLivingBase); - - if (par1EntityLivingBase == null) { - this.setAngry(false); - } else if (!this.isTamed()) { - this.setAngry(true); - } - } - /** * main AI tick function, replaces updateEntityActionState */ + @Override protected void updateAITick() { this.dataWatcher.updateObject(18, this.getHealth()); } + @Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, this.getHealth()); } - /** - * Plays step sound at given x, y, z for the entity - */ protected void playStepSound(int par1, int par2, int par3, int par4) { this.playSound("mob.zombie.step", 0.15F, 1.0F); } - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeEntityToNBT(par1NBTTagCompound); - par1NBTTagCompound.setBoolean("Angry", this.isAngry()); + @Override + public void writeEntityToNBT(NBTTagCompound tag) { + super.writeEntityToNBT(tag); + tag.setBoolean("Angry", this.isAngry()); } - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readEntityFromNBT(par1NBTTagCompound); - this.setAngry(par1NBTTagCompound.getBoolean("Angry")); - + @Override + public void readEntityFromNBT(NBTTagCompound tag) { + super.readEntityFromNBT(tag); + this.setAngry(tag.getBoolean("Angry")); this.setCombatTask(); } - /** - * Returns the sound this mob makes while it's alive. - */ + @Override protected String getLivingSound() { // TODO change sounds return "none"; } - /** - * Returns the sound this mob makes when it is hurt. - */ + @Override protected String getHurtSound() { return "none"; } - /** - * Returns the sound this mob makes on death. - */ + @Override protected String getDeathSound() { return "none"; } - /** - * Returns the volume for the sounds this mob makes. - */ + @Override protected float getSoundVolume() { return 0.4F; } - /** - * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons - * use this to react to sunlight and start to burn. - */ - public void onLivingUpdate() { - super.onLivingUpdate(); - } - - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() { - super.onUpdate(); - } - - public float getEyeHeight() { - return this.height * 0.8F; - } - - /** - * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently - * use in wolves. - */ - public int getVerticalFaceSpeed() { - return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); - } - - /** - * Called when the entity is attacked. - */ - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - if (this.isEntityInvulnerable()) { - return false; - } else { - Entity entity = par1DamageSource.getEntity(); - this.aiSit.setSitting(false); - - if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { - par2 = (par2 + 1.0F) / 2.0F; - } - - return super.attackEntityFrom(par1DamageSource, par2); - } - } - - public boolean attackEntityAsMob(Entity par1Entity) { - int i = this.isTamed() ? 6 : 7; - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); - } - - public void setTamed(boolean par1) { - super.setTamed(par1); - - if (par1) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } - } - - /** - * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. - */ @Override - public boolean interact(EntityPlayer par1EntityPlayer) { - ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); - - if (this.isTamed()) { - if (itemstack != null) { - if (itemstack.getItem() instanceof ItemFood) { - ItemFood itemfood = (ItemFood) itemstack.getItem(); - - if (itemfood.isWolfsFavoriteMeat() - && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - this.heal((float) itemfood.func_150905_g(itemstack)); - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory - .setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - return true; - } - } - } - - if (this.getOwner() instanceof EntityPlayer - && SpellHelper.getUsername(par1EntityPlayer) - .equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) - && !this.isBreedingItem(itemstack)) { - if (!this.worldObj.isRemote) { - this.aiSit.setSitting(!this.isSitting()); - this.isJumping = false; - this.setPathToEntity(null); - this.setTarget(null); - this.setAttackTarget(null); - } - - this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting()); - } - } else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry()) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory - .setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null); - } - - if (!this.worldObj.isRemote) { - if (this.rand.nextInt(1) == 0) { - this.setTamed(true); - this.setPathToEntity(null); - this.setAttackTarget(null); - this.aiSit.setSitting(true); - this.setHealth(maxTamedHealth); - this.func_152115_b(par1EntityPlayer.getUniqueID().toString()); - this.playTameEffect(true); - this.worldObj.setEntityState(this, (byte) 7); - } else { - this.playTameEffect(false); - this.worldObj.setEntityState(this, (byte) 6); - } - } - - return true; - } - - return super.interact(par1EntityPlayer); - } - - /** - * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on - * the animal type) - */ - public boolean isBreedingItem(ItemStack par1ItemStack) { - return false; - } - - /** - * Determines whether this wolf is angry or not. - */ - public boolean isAngry() { - return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0; - } - - /** - * Sets whether this wolf is angry or not. - */ - public void setAngry(boolean par1) { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - - if (par1) { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2))); - } else { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3))); - } - } - - /** - * Determines if an entity can be despawned, used on idle far away entities - */ - protected boolean canDespawn() { - return false; - } - - public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase) { - if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast)) { - if (par1EntityLivingBase instanceof EntityBoulderFist) { - EntityBoulderFist entitywolf = (EntityBoulderFist) par1EntityLivingBase; - - if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase) { - return false; - } - } - - return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer - && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) - ? false - : !(par1EntityLivingBase instanceof EntityHorse) - || !((EntityHorse) par1EntityLivingBase).isTame(); - } else { - return false; - } + public boolean attackEntityAsMob(Entity entity) { + int i = this.isTamed() ? 6 : 7; + return entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } - /** - * Attack the specified entity using a ranged attack. - */ - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { - HolyProjectile hol = new HolyProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 5, 600); + public void attackEntityWithRangedAttack(EntityLivingBase entityLivingBase, float par2) { + HolyProjectile hol = new HolyProjectile(worldObj, this, entityLivingBase, 1.8f, 0f, 5, 600); this.worldObj.spawnEntityInWorld(hol); } @@ -370,4 +140,14 @@ public void setCombatTask() { // this.tasks.removeTask(this.aiArrowAttack); this.tasks.addTask(4, this.aiAttackOnCollide); } + + @Override + protected float maxTamedHealth() { + return maxTamedHealth; + } + + @Override + protected float maxUntamedHealth() { + return maxUntamedHealth; + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityShadeElemental.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityShadeElemental.java index 374869d656..623a2cc8d8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityShadeElemental.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityShadeElemental.java @@ -15,6 +15,7 @@ public EntityShadeElemental(World world) { super(world, AlchemicalWizardry.entityShadeElementalID); } + @Override public void inflictEffectOnEntity(Entity target) { if (target instanceof EntityLivingBase) { ((EntityLivingBase) target).addPotionEffect(new PotionEffect(Potion.blindness.id, 100, 1)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntitySmallEarthGolem.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntitySmallEarthGolem.java index ff055c247a..df40a840ec 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntitySmallEarthGolem.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntitySmallEarthGolem.java @@ -14,37 +14,28 @@ import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; -import net.minecraft.entity.monster.EntityCreeper; -import net.minecraft.entity.monster.EntityGhast; -import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; -import WayofTime.alchemicalWizardry.ModItems; import WayofTime.alchemicalWizardry.common.EntityAITargetAggro; import WayofTime.alchemicalWizardry.common.entity.projectile.MudProjectile; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class EntitySmallEarthGolem extends EntityDemon implements IRangedAttackMob { - private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 25, 25, 15.0F); - private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( + private final EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 25, 25, 15.0F); + private final EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( this, EntityPlayer.class, 1.2D, false); - private static float maxTamedHealth = 20.0F; - private static float maxUntamedHealth = 10.0F; + private static final float maxTamedHealth = 20.0F; + private static final float maxUntamedHealth = 10.0F; - public EntitySmallEarthGolem(World par1World) { - super(par1World, AlchemicalWizardry.entitySmallEarthGolemID); + public EntitySmallEarthGolem(World world) { + super(world, AlchemicalWizardry.entitySmallEarthGolemID); this.setSize(0.2F, 1.0F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(1, new EntityAISwimming(this)); @@ -60,7 +51,7 @@ public EntitySmallEarthGolem(World par1World) { this.setAggro(false); this.setTamed(false); - if (par1World != null && !par1World.isRemote) { + if (world != null && !world.isRemote) { this.setCombatTask(); } } @@ -68,298 +59,65 @@ public EntitySmallEarthGolem(World par1World) { @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); - // This line affects the speed of the monster - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.40000001192092896D); - - // My guess is that this will alter the max health - if (this.isTamed()) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.4D); } /** * Returns true if the newer Entity AI code should be run */ + @Override public boolean isAIEnabled() { return true; } - /** - * Sets the active target the Task system uses for tracking - */ - public void setAttackTarget(EntityLivingBase par1EntityLivingBase) { - super.setAttackTarget(par1EntityLivingBase); - - if (par1EntityLivingBase == null) { - this.setAngry(false); - } else if (!this.isTamed()) { - this.setAngry(true); - } - } - /** * main AI tick function, replaces updateEntityActionState */ + @Override protected void updateAITick() { this.dataWatcher.updateObject(18, this.getHealth()); } + @Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, this.getHealth()); + this.setCombatTask(); } - /** - * Plays step sound at given x, y, z for the entity - */ protected void playStepSound(int par1, int par2, int par3, int par4) { this.playSound("mob.zombie.step", 0.15F, 1.0F); } - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeEntityToNBT(par1NBTTagCompound); - par1NBTTagCompound.setBoolean("Angry", this.isAngry()); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readEntityFromNBT(par1NBTTagCompound); - this.setAngry(par1NBTTagCompound.getBoolean("Angry")); - - this.setCombatTask(); - } - - /** - * Returns the sound this mob makes while it's alive. - */ + @Override protected String getLivingSound() { return "none"; } - /** - * Returns the sound this mob makes when it is hurt. - */ + @Override protected String getHurtSound() { return "mob.irongolem.hit"; } - /** - * Returns the sound this mob makes on death. - */ + @Override protected String getDeathSound() { return "mob.irongolem.death"; } - /** - * Returns the volume for the sounds this mob makes. - */ + @Override protected float getSoundVolume() { return 0.4F; } - /** - * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons - * use this to react to sunlight and start to burn. - */ - public void onLivingUpdate() { - super.onLivingUpdate(); - } - - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() { - super.onUpdate(); - } - - public float getEyeHeight() { - return this.height * 0.8F; - } - - /** - * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently - * use in wolves. - */ - public int getVerticalFaceSpeed() { - return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); - } - - /** - * Called when the entity is attacked. - */ - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - if (this.isEntityInvulnerable()) { - return false; - } else { - Entity entity = par1DamageSource.getEntity(); - this.aiSit.setSitting(false); - - if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { - par2 = (par2 + 1.0F) / 2.0F; - } - - return super.attackEntityFrom(par1DamageSource, par2); - } - } - - public boolean attackEntityAsMob(Entity par1Entity) { + @Override + public boolean attackEntityAsMob(Entity entity) { int i = this.isTamed() ? 4 : 2; - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); - } - - public void setTamed(boolean par1) { - super.setTamed(par1); - - if (par1) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } + return entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } - /** - * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. - */ @Override - public boolean interact(EntityPlayer par1EntityPlayer) { - ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); - - if (this.isTamed()) { - if (itemstack != null) { - if (itemstack.getItem() instanceof ItemFood) { - ItemFood itemfood = (ItemFood) itemstack.getItem(); - - if (itemfood.isWolfsFavoriteMeat() - && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - this.heal((float) itemfood.func_150905_g(itemstack)); - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory - .setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - return true; - } - } - } - - if (this.getOwner() instanceof EntityPlayer - && SpellHelper.getUsername(par1EntityPlayer) - .equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) - && !this.isBreedingItem(itemstack)) { - if (!this.worldObj.isRemote) { - this.aiSit.setSitting(!this.isSitting()); - this.isJumping = false; - this.setPathToEntity(null); - this.setTarget(null); - this.setAttackTarget(null); - } - - this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting()); - } - } else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry()) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory - .setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null); - } - - if (!this.worldObj.isRemote) { - if (this.rand.nextInt(1) == 0) { - this.setTamed(true); - this.setPathToEntity(null); - this.setAttackTarget(null); - this.aiSit.setSitting(true); - this.setHealth(maxTamedHealth); - this.func_152115_b(par1EntityPlayer.getUniqueID().toString()); - this.playTameEffect(true); - this.worldObj.setEntityState(this, (byte) 7); - } else { - this.playTameEffect(false); - this.worldObj.setEntityState(this, (byte) 6); - } - } - - return true; - } - - return super.interact(par1EntityPlayer); - } - - /** - * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on - * the animal type) - */ - public boolean isBreedingItem(ItemStack par1ItemStack) { - return false; - } - - /** - * Determines whether this wolf is angry or not. - */ - public boolean isAngry() { - return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0; - } - - /** - * Sets whether this wolf is angry or not. - */ - public void setAngry(boolean par1) { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - - if (par1) { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2))); - } else { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3))); - } - } - - /** - * Determines if an entity can be despawned, used on idle far away entities - */ - protected boolean canDespawn() { - return false; - } - - public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase) { - if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast)) { - if (par1EntityLivingBase instanceof EntitySmallEarthGolem) { - EntitySmallEarthGolem entitywolf = (EntitySmallEarthGolem) par1EntityLivingBase; - - if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase) { - return false; - } - } - - return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer - && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) - ? false - : !(par1EntityLivingBase instanceof EntityHorse) - || !((EntityHorse) par1EntityLivingBase).isTame(); - } else { - return false; - } - } - - /** - * Attack the specified entity using a ranged attack. - */ - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { - MudProjectile hol = new MudProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 3, 600, false); + public void attackEntityWithRangedAttack(EntityLivingBase entityLivingBase, float par2) { + MudProjectile hol = new MudProjectile(worldObj, this, entityLivingBase, 1.8f, 0f, 3, 600, false); this.worldObj.spawnEntityInWorld(hol); } @@ -371,4 +129,14 @@ public void setCombatTask() { this.tasks.removeTask(this.aiArrowAttack); this.tasks.addTask(4, this.aiArrowAttack); } + + @Override + protected float maxTamedHealth() { + return maxTamedHealth; + } + + @Override + protected float maxUntamedHealth() { + return maxUntamedHealth; + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityWaterElemental.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityWaterElemental.java index 151a738963..d7ef053e4b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityWaterElemental.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityWaterElemental.java @@ -14,6 +14,7 @@ public EntityWaterElemental(World world) { super(world, AlchemicalWizardry.entityWaterElementalID); } + @Override public void inflictEffectOnEntity(Entity target) { if (target instanceof EntityLivingBase) { ((EntityLivingBase) target) diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityWingedFireDemon.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityWingedFireDemon.java index ceb703a982..c9fa6bd27b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityWingedFireDemon.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/EntityWingedFireDemon.java @@ -14,37 +14,28 @@ import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; -import net.minecraft.entity.monster.EntityCreeper; -import net.minecraft.entity.monster.EntityGhast; -import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; -import WayofTime.alchemicalWizardry.ModItems; import WayofTime.alchemicalWizardry.common.EntityAITargetAggro; import WayofTime.alchemicalWizardry.common.entity.projectile.FireProjectile; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class EntityWingedFireDemon extends EntityDemon implements IRangedAttackMob { - private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 40, 40, 15.0F); - private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( + private final EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 40, 40, 15.0F); + private final EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( this, EntityPlayer.class, 1.2D, false); - private static float maxTamedHealth = 100.0F; - private static float maxUntamedHealth = 200.0F; + private static final float maxTamedHealth = 100.0F; + private static final float maxUntamedHealth = 200.0F; - public EntityWingedFireDemon(World par1World) { - super(par1World, AlchemicalWizardry.entityWingedFireDemonID); + public EntityWingedFireDemon(World world) { + super(world, AlchemicalWizardry.entityWingedFireDemonID); this.setSize(0.7F, 1.8F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(1, new EntityAISwimming(this)); @@ -60,7 +51,7 @@ public EntityWingedFireDemon(World par1World) { this.setAggro(false); this.setTamed(false); - if (par1World != null && !par1World.isRemote) { + if (world != null && !world.isRemote) { this.setCombatTask(); } @@ -70,308 +61,66 @@ public EntityWingedFireDemon(World par1World) { @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); - // This line affects the speed of the monster - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); - - // My guess is that this will alter the max health - if (this.isTamed()) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } - - // this.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(10.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D); } /** * Returns true if the newer Entity AI code should be run */ + @Override public boolean isAIEnabled() { return true; } - /** - * Sets the active target the Task system uses for tracking - */ - public void setAttackTarget(EntityLivingBase par1EntityLivingBase) { - super.setAttackTarget(par1EntityLivingBase); - - if (par1EntityLivingBase == null) { - this.setAngry(false); - } else if (!this.isTamed()) { - this.setAngry(true); - } - } - /** * main AI tick function, replaces updateEntityActionState */ + @Override protected void updateAITick() { this.dataWatcher.updateObject(18, this.getHealth()); } + @Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, this.getHealth()); + this.setCombatTask(); } - /** - * Plays step sound at given x, y, z for the entity - */ protected void playStepSound(int par1, int par2, int par3, int par4) { this.playSound("mob.zombie.step", 0.15F, 1.0F); } - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeEntityToNBT(par1NBTTagCompound); - par1NBTTagCompound.setBoolean("Angry", this.isAngry()); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readEntityFromNBT(par1NBTTagCompound); - this.setAngry(par1NBTTagCompound.getBoolean("Angry")); - - this.setCombatTask(); - } - - /** - * Returns the sound this mob makes while it's alive. - */ + @Override protected String getLivingSound() { return "mob.blaze.breathe"; } - /** - * Returns the sound this mob makes when it is hurt. - */ + @Override protected String getHurtSound() { return "mob.blaze.hit"; } - /** - * Returns the sound this mob makes on death. - */ + @Override protected String getDeathSound() { return "mob.blaze.death"; } - /** - * Returns the volume for the sounds this mob makes. - */ + @Override protected float getSoundVolume() { return 0.4F; } - /** - * Returns the item ID for the item the mob drops on death. - */ - protected int getDropItemId() { - return -1; - } - - /** - * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons - * use this to react to sunlight and start to burn. - */ - public void onLivingUpdate() { - super.onLivingUpdate(); - } - - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() { - super.onUpdate(); - } - - public float getEyeHeight() { - return this.height * 0.8F; - } - - /** - * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently - * use in wolves. - */ - public int getVerticalFaceSpeed() { - return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); - } - - /** - * Called when the entity is attacked. - */ - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { - if (this.isEntityInvulnerable()) { - return false; - } else { - Entity entity = par1DamageSource.getEntity(); - this.aiSit.setSitting(false); - - if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { - par2 = (par2 + 1.0F) / 2.0F; - } - - return super.attackEntityFrom(par1DamageSource, par2); - } - } - - public boolean attackEntityAsMob(Entity par1Entity) { + @Override + public boolean attackEntityAsMob(Entity entity) { int i = this.isTamed() ? 4 : 2; - return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); + return entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i); } - public void setTamed(boolean par1) { - super.setTamed(par1); - - if (par1) { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxTamedHealth); - } else { - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxUntamedHealth); - } - } - - /** - * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. - */ @Override - public boolean interact(EntityPlayer par1EntityPlayer) { - ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); - - if (this.isTamed()) { - if (itemstack != null) { - if (itemstack.getItem() instanceof ItemFood) { - ItemFood itemfood = (ItemFood) itemstack.getItem(); - - if (itemfood.isWolfsFavoriteMeat() - && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - this.heal((float) itemfood.func_150905_g(itemstack)); - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory - .setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - return true; - } - } - } - - if (this.getOwner() instanceof EntityPlayer - && SpellHelper.getUsername(par1EntityPlayer) - .equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) - && !this.isBreedingItem(itemstack)) { - if (!this.worldObj.isRemote) { - this.aiSit.setSitting(!this.isSitting()); - this.isJumping = false; - this.setPathToEntity(null); - this.setTarget(null); - this.setAttackTarget(null); - } - - this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting()); - } - } else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry()) { - if (!par1EntityPlayer.capabilities.isCreativeMode) { - --itemstack.stackSize; - } - - if (itemstack.stackSize <= 0) { - par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); - } - - if (!this.worldObj.isRemote) { - if (this.rand.nextInt(1) == 0) { - this.setTamed(true); - this.setPathToEntity(null); - this.setAttackTarget(null); - this.aiSit.setSitting(true); - this.setHealth(maxTamedHealth); - this.func_152115_b(par1EntityPlayer.getUniqueID().toString()); - this.playTameEffect(true); - this.worldObj.setEntityState(this, (byte) 7); - } else { - this.playTameEffect(false); - this.worldObj.setEntityState(this, (byte) 6); - } - } - - return true; - } - - return super.interact(par1EntityPlayer); - } - - /** - * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on - * the animal type) - */ - public boolean isBreedingItem(ItemStack par1ItemStack) { - return false; - } - - /** - * Determines whether this wolf is angry or not. - */ - public boolean isAngry() { - return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0; - } - - /** - * Sets whether this wolf is angry or not. - */ - public void setAngry(boolean par1) { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - - if (par1) { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2))); - } else { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3))); - } - } - - /** - * Determines if an entity can be despawned, used on idle far away entities - */ - protected boolean canDespawn() { - return false; - } - - public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase) { - if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast)) { - if (par1EntityLivingBase instanceof EntityWingedFireDemon) { - EntityWingedFireDemon entitywolf = (EntityWingedFireDemon) par1EntityLivingBase; - - if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase) { - return false; - } - } - - return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer - && !((EntityPlayer) par2EntityLivingBase).canAttackPlayer((EntityPlayer) par1EntityLivingBase) - ? false - : !(par1EntityLivingBase instanceof EntityHorse) - || !((EntityHorse) par1EntityLivingBase).isTame(); - } else { - return false; - } - } - - /** - * Attack the specified entity using a ranged attack. - */ - public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { + public void attackEntityWithRangedAttack(EntityLivingBase entityLivingBase, float par2) { this.worldObj.playAuxSFXAtEntity(null, 1009, (int) this.posX, (int) this.posY, (int) this.posZ, 0); - FireProjectile hol = new FireProjectile(worldObj, this, par1EntityLivingBase, 1.8f, 0f, 20, 600); - this.worldObj.spawnEntityInWorld(hol); + this.worldObj.spawnEntityInWorld(new FireProjectile(worldObj, this, entityLivingBase, 1.8f, 0f, 20, 600)); } /** @@ -382,4 +131,14 @@ public void setCombatTask() { this.tasks.removeTask(this.aiArrowAttack); this.tasks.addTask(4, this.aiArrowAttack); } + + @Override + protected float maxTamedHealth() { + return maxTamedHealth; + } + + @Override + protected float maxUntamedHealth() { + return maxUntamedHealth; + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/MailOrderEntityItem.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/MailOrderEntityItem.java index 80580f24a5..84b958d489 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/MailOrderEntityItem.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/mob/MailOrderEntityItem.java @@ -11,18 +11,17 @@ public class MailOrderEntityItem extends EntityItem { - public MailOrderEntityItem(World par1World, double par2, double par4, double par6) { - super(par1World, par2, par4, par6); + public MailOrderEntityItem(World world, double x, double y, double z) { + super(world, x, y, z); this.isImmuneToFire = true; this.lifespan = 72000; } - public MailOrderEntityItem(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack) { - this(par1World, par2, par4, par6); - this.setEntityItemStack(par8ItemStack); + public MailOrderEntityItem(World world, double x, double y, double z, ItemStack item) { + this(world, x, y, z); + this.setEntityItemStack(item); this.isImmuneToFire = true; - this.lifespan = (par8ItemStack.getItem() == null ? 6000 - : par8ItemStack.getItem().getEntityLifespan(par8ItemStack, par1World)); + this.lifespan = (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, world)); } public MailOrderEntityItem(World world, Entity original, ItemStack stack) { @@ -35,10 +34,11 @@ public MailOrderEntityItem(World world, Entity original, ItemStack stack) { this.isImmuneToFire = true; } - public MailOrderEntityItem(World par1world) { - super(par1world); + public MailOrderEntityItem(World world) { + super(world); } + @Override public void onUpdate() { super.onUpdate(); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EnergyBlastProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EnergyBlastProjectile.java index a7962ab1ee..344780d74c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EnergyBlastProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EnergyBlastProjectile.java @@ -1,6 +1,5 @@ package WayofTime.alchemicalWizardry.common.entity.projectile; -import java.util.Iterator; import java.util.List; import net.minecraft.block.Block; @@ -39,35 +38,35 @@ public class EnergyBlastProjectile extends Entity implements IProjectile, IThrow protected int ticksInAir = 0; protected int maxTicksInAir = 600; - private int ricochetCounter = 0; - private boolean scheduledForDeath = false; + protected int ricochetCounter = 0; + protected boolean scheduledForDeath = false; protected int projectileDamage; - public EnergyBlastProjectile(World par1World) { - super(par1World); + public EnergyBlastProjectile(World world) { + super(world); this.setSize(0.5F, 0.5F); this.maxTicksInAir = 600; } - public EnergyBlastProjectile(World par1World, double par2, double par4, double par6) { - super(par1World); + public EnergyBlastProjectile(World world, double x, double y, double z) { + super(world); this.setSize(0.5F, 0.5F); - this.setPosition(par2, par4, par6); + this.setPosition(x, y, z); yOffset = 0.0F; this.maxTicksInAir = 600; } - public EnergyBlastProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage) { - super(par1World); - shootingEntity = par2EntityPlayer; + public EnergyBlastProjectile(World world, EntityLivingBase player, int damage) { + super(world); + shootingEntity = player; float par3 = 0.8F; this.setSize(0.5F, 0.5F); this.setLocationAndAngles( - par2EntityPlayer.posX, - par2EntityPlayer.posY + par2EntityPlayer.getEyeHeight(), - par2EntityPlayer.posZ, - par2EntityPlayer.rotationYaw, - par2EntityPlayer.rotationPitch); + player.posX, + player.posY + player.getEyeHeight(), + player.posZ, + player.rotationYaw, + player.rotationPitch); posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; posY -= 0.2D; posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; @@ -83,11 +82,10 @@ public EnergyBlastProjectile(World par1World, EntityLivingBase par2EntityPlayer, this.maxTicksInAir = 600; } - public EnergyBlastProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, - double posX, double posY, double posZ, float rotationYaw, float rotationPitch) { - super(par1World); - shootingEntity = par2EntityPlayer; - float par3 = 0.8F; + public EnergyBlastProjectile(World world, EntityLivingBase player, int damage, int maxTicksInAir, double posX, + double posY, double posZ, float rotationYaw, float rotationPitch) { + super(world); + shootingEntity = player; this.setSize(0.5F, 0.5F); this.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch); posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; @@ -100,36 +98,29 @@ public EnergyBlastProjectile(World par1World, EntityLivingBase par2EntityPlayer, motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI); motionY = -MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI); - this.setThrowableHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F); + this.setThrowableHeading(motionX, motionY, motionZ, 1.2f, 1.0F); this.projectileDamage = damage; this.maxTicksInAir = maxTicksInAir; } - public EnergyBlastProjectile(World par1World, EntityLivingBase par2EntityLivingBase, - EntityLivingBase par3EntityLivingBase, float par4, float par5, int damage, int maxTicksInAir) { - super(par1World); + public EnergyBlastProjectile(World world, EntityLivingBase shooter, EntityLivingBase target, float velocity, + float inaccuracy, int damage, int maxTicksInAir) { + super(world); this.renderDistanceWeight = 10.0D; - this.shootingEntity = par2EntityLivingBase; - this.posY = par2EntityLivingBase.posY + (double) par2EntityLivingBase.getEyeHeight() - 0.10000000149011612D; - double d0 = par3EntityLivingBase.posX - par2EntityLivingBase.posX; - double d1 = par3EntityLivingBase.boundingBox.minY + (double) (par3EntityLivingBase.height / 1.5F) - this.posY; - double d2 = par3EntityLivingBase.posZ - par2EntityLivingBase.posZ; - double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2); - - if (d3 >= 1.0E-7D) { - float f2 = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; - float f3 = (float) (-(Math.atan2(d1, d3) * 180.0D / Math.PI)); - double d4 = d0 / d3; - double d5 = d2 / d3; - this.setLocationAndAngles( - par2EntityLivingBase.posX + d4, - this.posY, - par2EntityLivingBase.posZ + d5, - f2, - f3); + this.shootingEntity = shooter; + this.posY = shooter.posY + (double) shooter.getEyeHeight() - 0.1D; + double deltaX = target.posX - shooter.posX; + double deltaY = target.boundingBox.minY + (double) (target.height / 1.5F) - this.posY; + double deltaZ = target.posZ - shooter.posZ; + double horizontalDistance = MathHelper.sqrt_double(deltaX * deltaX + deltaZ * deltaZ); + if (horizontalDistance >= 1.0E-7D) { + float yaw = (float) (Math.atan2(deltaZ, deltaX) * 180.0D / Math.PI) - 90.0F; + float pitch = (float) (-(Math.atan2(deltaY, horizontalDistance) * 180.0D / Math.PI)); + double normalizedX = deltaX / horizontalDistance; + double normalizedZ = deltaZ / horizontalDistance; + this.setLocationAndAngles(shooter.posX + normalizedX, this.posY, shooter.posZ + normalizedZ, yaw, pitch); this.yOffset = 0.0F; - float f4 = (float) d3 * 0.2F; - this.setThrowableHeading(d0, d1, d2, par4, par5); + this.setThrowableHeading(deltaX, deltaY, deltaZ, velocity, inaccuracy); } this.projectileDamage = damage; @@ -138,58 +129,56 @@ public EnergyBlastProjectile(World par1World, EntityLivingBase par2EntityLivingB @Override protected void entityInit() { - dataWatcher.addObject(16, Byte.valueOf((byte) 0)); + dataWatcher.addObject(16, (byte) 0); } /** * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. */ @Override - public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8) { - float var9 = MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5); - var1 /= var9; - var3 /= var9; - var5 /= var9; - var1 += rand.nextGaussian() * 0.007499999832361937D * var8; - var3 += rand.nextGaussian() * 0.007499999832361937D * var8; - var5 += rand.nextGaussian() * 0.007499999832361937D * var8; - var1 *= var7; - var3 *= var7; - var5 *= var7; - motionX = var1; - motionY = var3; - motionZ = var5; - float var10 = MathHelper.sqrt_double(var1 * var1 + var5 * var5); - prevRotationYaw = rotationYaw = (float) (Math.atan2(var1, var5) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float) (Math.atan2(var3, var10) * 180.0D / Math.PI); + public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) { + float magnitude = MathHelper.sqrt_double(x * x + y * y + z * z); + x /= magnitude; + y /= magnitude; + z /= magnitude; + + double spread = 0.0075D; + x += rand.nextGaussian() * spread * inaccuracy; + y += rand.nextGaussian() * spread * inaccuracy; + z += rand.nextGaussian() * spread * inaccuracy; + + x *= velocity; + y *= velocity; + z *= velocity; + + motionX = x; + motionY = y; + motionZ = z; + + float horizontalSpeed = MathHelper.sqrt_double(x * x + z * z); + + prevRotationYaw = rotationYaw = (float) (Math.atan2(x, z) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch = (float) (Math.atan2(y, horizontalSpeed) * 180.0D / Math.PI); } @Override @SideOnly(Side.CLIENT) - /** - * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX, - * posY, posZ, yaw, pitch - */ - public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) { - this.setPosition(par1, par3, par5); - this.setRotation(par7, par8); + public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int rotationIncrements) { + this.setPosition(x, y, z); + this.setRotation(yaw, pitch); } @Override @SideOnly(Side.CLIENT) - /** - * Sets the velocity to the args. Args: x, y, z - */ - public void setVelocity(double par1, double par3, double par5) { - motionX = par1; - motionY = par3; - motionZ = par5; + public void setVelocity(double x, double y, double z) { + motionX = x; + motionY = y; + motionZ = z; if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) { - float var7 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); - prevRotationYaw = rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float) (Math.atan2(par3, var7) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch; + prevRotationYaw = rotationYaw = (float) (Math.atan2(x, z) * 180.0D / Math.PI); + float horizontalSpeed = MathHelper.sqrt_double(x * x + z * z); + prevRotationPitch = rotationPitch = (float) (Math.atan2(y, horizontalSpeed) * 180.0D / Math.PI); prevRotationYaw = rotationYaw; this.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch); } @@ -207,19 +196,19 @@ public void onUpdate() { } if (shootingEntity == null) { - List players = worldObj.getEntitiesWithinAABB( + List players = worldObj.getEntitiesWithinAABB( EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1)); - Iterator i = players.iterator(); + double closestDistance = Double.MAX_VALUE; EntityPlayer closestPlayer = null; - while (i.hasNext()) { - EntityPlayer e = (EntityPlayer) i.next(); - double distance = e.getDistanceToEntity(this); + for (EntityPlayer player : players) { + double distance = player.getDistanceToEntity(this); if (distance < closestDistance) { - closestPlayer = e; + closestPlayer = player; + closestDistance = distance; } } @@ -229,79 +218,71 @@ public void onUpdate() { } if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) { - float var1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); + float horizontalSpeed = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); prevRotationYaw = rotationYaw = (float) (Math.atan2(motionX, motionZ) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float) (Math.atan2(motionY, var1) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch = (float) (Math.atan2(motionY, horizontalSpeed) * 180.0D / Math.PI); } - Block var16 = worldObj.getBlock(xTile, yTile, zTile); + Block block = worldObj.getBlock(xTile, yTile, zTile); - if (var16 != null) { - var16.setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile); - AxisAlignedBB var2 = var16.getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile); + if (block != null) { + block.setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile); + AxisAlignedBB collisionBox = block.getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile); - if (var2 != null && var2.isVecInside(SpellHelper.createVec3(posX, posY, posZ))) { + if (collisionBox != null && collisionBox.isVecInside(SpellHelper.createVec3(posX, posY, posZ))) { inGround = true; } } - if (inGround) { - Block var18 = worldObj.getBlock(xTile, yTile, zTile); - int var19 = worldObj.getBlockMetadata(xTile, yTile, zTile); - - if (var18.equals(Block.getBlockById(inTile)) && var19 == inData) {} - } else { + if (!inGround) { ++ticksInAir; - if (ticksInAir > 1 && ticksInAir < 3) { - for (int particles = 0; particles < 3; particles++) { + if (ticksInAir == 2) { + for (int i = 0; i < 3; i++) { this.doFiringParticles(); } } - Vec3 var17 = SpellHelper.createVec3(posX, posY, posZ); - Vec3 var3 = SpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ); - MovingObjectPosition var4 = worldObj.func_147447_a(var17, var3, true, false, false); - var17 = SpellHelper.createVec3(posX, posY, posZ); - var3 = SpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ); + Vec3 startVec = SpellHelper.createVec3(posX, posY, posZ); + Vec3 endVec = SpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ); + MovingObjectPosition blockHit = worldObj.func_147447_a(startVec, endVec, true, false, false); + startVec = SpellHelper.createVec3(posX, posY, posZ); + endVec = SpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ); - if (var4 != null) { - var3 = SpellHelper.createVec3(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord); + if (blockHit != null) { + endVec = SpellHelper.createVec3(blockHit.hitVec.xCoord, blockHit.hitVec.yCoord, blockHit.hitVec.zCoord); } - Entity var5 = null; - List var6 = worldObj.getEntitiesWithinAABBExcludingEntity( + Entity closestHitEntity = null; + List nearbyEntities = worldObj.getEntitiesWithinAABBExcludingEntity( this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); - double var7 = 0.0D; - Iterator var9 = var6.iterator(); - float var11; - while (var9.hasNext()) { - Entity var10 = (Entity) var9.next(); + double closestHitDistance = 0.0D; - if (var10.canBeCollidedWith() && (var10 != shootingEntity || ticksInAir >= 5)) { - var11 = 0.3F; - AxisAlignedBB var12 = var10.boundingBox.expand(var11, var11, var11); - MovingObjectPosition var13 = var12.calculateIntercept(var17, var3); + for (Entity entity : nearbyEntities) { + if (!entity.canBeCollidedWith() || (entity == shootingEntity && ticksInAir < 5)) { + continue; + } - if (var13 != null) { - double var14 = var17.distanceTo(var13.hitVec); + AxisAlignedBB expandedBoundingBox = entity.boundingBox.expand(0.3F, 0.3F, 0.3F); - if (var14 < var7 || var7 == 0.0D) { - var5 = var10; - var7 = var14; - } + MovingObjectPosition entityIntercept = expandedBoundingBox.calculateIntercept(startVec, endVec); + if (entityIntercept != null) { + double hitDistance = startVec.distanceTo(entityIntercept.hitVec); + if (hitDistance < closestHitDistance || closestHitDistance == 0.0D) { + closestHitEntity = entity; + closestHitDistance = hitDistance; } } } - if (var5 != null) { - var4 = new MovingObjectPosition(var5); + if (closestHitEntity != null) { + blockHit = new MovingObjectPosition(closestHitEntity); } - if (var4 != null) { - this.onImpact(var4); + if (blockHit != null) { + this.onImpact(blockHit); if (scheduledForDeath) { this.setDead(); @@ -311,7 +292,6 @@ public void onUpdate() { posX += motionX; posY += motionY; posZ += motionZ; - MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); this.setPosition(posX, posY, posZ); } } @@ -328,36 +308,32 @@ public void doFiringParticles() { worldObj.spawnParticle("flame", posX, posY, posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ)); } - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ @Override - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - par1NBTTagCompound.setShort("xTile", (short) xTile); - par1NBTTagCompound.setShort("yTile", (short) yTile); - par1NBTTagCompound.setShort("zTile", (short) zTile); - par1NBTTagCompound.setByte("inTile", (byte) inTile); - par1NBTTagCompound.setByte("inData", (byte) inData); - par1NBTTagCompound.setByte("inGround", (byte) (inGround ? 1 : 0)); - par1NBTTagCompound.setInteger("ticksInAir", ticksInAir); - par1NBTTagCompound.setInteger("maxTicksInAir", maxTicksInAir); - par1NBTTagCompound.setInteger("projectileDamage", this.projectileDamage); + public void writeEntityToNBT(NBTTagCompound tag) { + tag.setShort("xTile", (short) xTile); + tag.setShort("yTile", (short) yTile); + tag.setShort("zTile", (short) zTile); + tag.setByte("inTile", (byte) inTile); + tag.setByte("inData", (byte) inData); + tag.setByte("inGround", (byte) (inGround ? 1 : 0)); + tag.setInteger("ticksInAir", ticksInAir); + tag.setInteger("maxTicksInAir", maxTicksInAir); + tag.setInteger("projectileDamage", this.projectileDamage); + tag.setInteger("ricochetCounter", this.ricochetCounter); } - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ @Override - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - xTile = par1NBTTagCompound.getShort("xTile"); - yTile = par1NBTTagCompound.getShort("yTile"); - zTile = par1NBTTagCompound.getShort("zTile"); - inTile = par1NBTTagCompound.getByte("inTile") & 255; - inData = par1NBTTagCompound.getByte("inData") & 255; - inGround = par1NBTTagCompound.getByte("inGround") == 1; - ticksInAir = par1NBTTagCompound.getInteger("ticksInAir"); - maxTicksInAir = par1NBTTagCompound.getInteger("maxTicksInAir"); - projectileDamage = par1NBTTagCompound.getInteger("projectileDamage"); + public void readEntityFromNBT(NBTTagCompound tag) { + xTile = tag.getShort("xTile"); + yTile = tag.getShort("yTile"); + zTile = tag.getShort("zTile"); + inTile = tag.getByte("inTile") & 255; + inData = tag.getByte("inData") & 255; + inGround = tag.getByte("inGround") == 1; + ticksInAir = tag.getInteger("ticksInAir"); + maxTicksInAir = tag.getInteger("maxTicksInAir"); + projectileDamage = tag.getInteger("projectileDamage"); + ricochetCounter = tag.getInteger("ricochetCounter"); } /** @@ -375,11 +351,6 @@ public float getShadowSize() { return 0.0F; } - /** - * Sets the amount of knockback the arrow applies when it hits a mob. - */ - public void setKnockbackStrength(int par1) {} - /** * If returns false, the item will not inflict any damage against entities. */ @@ -388,27 +359,6 @@ public boolean canAttackWithItem() { return false; } - /** - * Whether the arrow has a stream of critical hit particles flying behind it. - */ - public void setIsCritical(boolean par1) { - byte var2 = dataWatcher.getWatchableObjectByte(16); - - if (par1) { - dataWatcher.updateObject(16, Byte.valueOf((byte) (var2 | 1))); - } else { - dataWatcher.updateObject(16, Byte.valueOf((byte) (var2 & -2))); - } - } - - /** - * Whether the arrow has a stream of critical hit particles flying behind it. - */ - public boolean getIsCritical() { - byte var1 = dataWatcher.getWatchableObjectByte(16); - return (var1 & 1) != 0; - } - public void onImpact(MovingObjectPosition mop) { if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null) { if (mop.entityHit == shootingEntity) { @@ -422,15 +372,15 @@ public void onImpact(MovingObjectPosition mop) { } } - public void onImpact(Entity mop) { - if (mop == shootingEntity && ticksInAir > 3) { + public void onImpact(Entity target) { + if (target == shootingEntity && ticksInAir > 3) { shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1); this.setDead(); } else { - if (mop instanceof EntityLivingBase) { - ((EntityLivingBase) mop).addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 2)); + if (target instanceof EntityLivingBase entity) { + entity.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 2)); } - doDamage(projectileDamage, mop); + doDamage(projectileDamage, target); worldObj.createExplosion(shootingEntity, this.posX, this.posY, this.posZ, (float) (0.1), true); } @@ -438,16 +388,12 @@ public void onImpact(Entity mop) { this.setDead(); } - private int d6() { - return rand.nextInt(6) + 1; - } - - protected void spawnHitParticles(String string, int i) { - for (int particles = 0; particles < i; particles++) { + protected void spawnHitParticles(String string, int particleCount) { + for (int i = 0; i < particleCount; i++) { worldObj.spawnParticle( string, posX, - posY - (string == "portal" ? 1 : 0), + posY - (string.equals("portal") ? 1 : 0), posZ, gaussian(motionX), gaussian(motionY), @@ -471,18 +417,13 @@ public double gaussian(double d) { return d + d * ((rand.nextFloat() - 0.5D) / 4); } - private int getRicochetMax() { - return 0; - } - @Override public Entity getThrower() { - // TODO Auto-generated method stub return this.shootingEntity; } @Override public void setThrower(Entity entity) { - if (entity instanceof EntityLivingBase) this.shootingEntity = (EntityLivingBase) entity; + if (entity instanceof EntityLivingBase e) this.shootingEntity = e; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityBloodLightProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityBloodLightProjectile.java index 81e15fc5b9..f992bb220b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityBloodLightProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityBloodLightProjectile.java @@ -11,31 +11,12 @@ public class EntityBloodLightProjectile extends EnergyBlastProjectile { - public EntityBloodLightProjectile(World par1World) { - super(par1World); + public EntityBloodLightProjectile(World world) { + super(world); } - public EntityBloodLightProjectile(World par1World, double par2, double par4, double par6) { - super(par1World, par2, par4, par6); - } - - public EntityBloodLightProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage) { - super(par1World, par2EntityPlayer, damage); - } - - public EntityBloodLightProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, - double posX, double posY, double posZ, float rotationYaw, float rotationPitch) { - super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); - } - - public EntityBloodLightProjectile(World par1World, EntityLivingBase par2EntityLivingBase, - EntityLivingBase par3EntityLivingBase, float par4, float par5, int damage, int maxTicksInAir) { - super(par1World, par2EntityLivingBase, par3EntityLivingBase, par4, par5, damage, maxTicksInAir); - } - - @Override - public DamageSource getDamageSource() { - return DamageSource.causeMobDamage(shootingEntity); + public EntityBloodLightProjectile(World world, EntityLivingBase player, int damage) { + super(world, player, damage); } @Override @@ -81,15 +62,13 @@ public void onImpact(MovingObjectPosition mop) { } @Override - public void onImpact(Entity mop) { - if (mop == shootingEntity && ticksInAir > 3) { + public void onImpact(Entity target) { + if (target == shootingEntity && ticksInAir > 3) { shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1); this.setDead(); - } else { - if (mop instanceof EntityLivingBase) { - ((EntityLivingBase) mop).setRevengeTarget(shootingEntity); - doDamage(1, mop); - } + } else if (target instanceof EntityLivingBase entity) { + entity.setRevengeTarget(shootingEntity); + doDamage(1, target); } if (worldObj.isAirBlock((int) this.posX, (int) this.posY, (int) this.posZ)) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityEnergyBazookaMainProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityEnergyBazookaMainProjectile.java index 61774ab5a5..619bdd1a0e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityEnergyBazookaMainProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityEnergyBazookaMainProjectile.java @@ -10,31 +10,12 @@ public class EntityEnergyBazookaMainProjectile extends EnergyBlastProjectile { - public EntityEnergyBazookaMainProjectile(World par1World) { - super(par1World); + public EntityEnergyBazookaMainProjectile(World world) { + super(world); } - public EntityEnergyBazookaMainProjectile(World par1World, double par2, double par4, double par6) { - super(par1World, par2, par4, par6); - } - - public EntityEnergyBazookaMainProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage) { - super(par1World, par2EntityPlayer, damage); - } - - public EntityEnergyBazookaMainProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, - int maxTicksInAir, double posX, double posY, double posZ, float rotationYaw, float rotationPitch) { - super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); - } - - public EntityEnergyBazookaMainProjectile(World par1World, EntityLivingBase par2EntityLivingBase, - EntityLivingBase par3EntityLivingBase, float par4, float par5, int damage, int maxTicksInAir) { - super(par1World, par2EntityLivingBase, par3EntityLivingBase, par4, par5, damage, maxTicksInAir); - } - - @Override - public DamageSource getDamageSource() { - return DamageSource.causeMobDamage(shootingEntity); + public EntityEnergyBazookaMainProjectile(World world, EntityLivingBase player, int damage) { + super(world, player, damage); } @Override @@ -46,7 +27,7 @@ public void onImpact(MovingObjectPosition mop) { this.onImpact(mop.entityHit); } else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - worldObj.createExplosion(this.shootingEntity, this.posX, this.posY, this.posZ, (float) (5.0f), false); + worldObj.createExplosion(this.shootingEntity, this.posX, this.posY, this.posZ, 5.0f, false); this.spawnSecondaryProjectiles(); } @@ -54,16 +35,16 @@ public void onImpact(MovingObjectPosition mop) { } @Override - public void onImpact(Entity mop) { - if (mop == shootingEntity && ticksInAir > 3) { + public void onImpact(Entity target) { + if (target == shootingEntity && ticksInAir > 3) { shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1); this.setDead(); } else { - if (mop instanceof EntityLivingBase) { + if (target instanceof EntityLivingBase) { spawnSecondaryProjectiles(); } - worldObj.createExplosion(this.shootingEntity, this.posX, this.posY, this.posZ, (float) (5.0f), false); + worldObj.createExplosion(this.shootingEntity, this.posX, this.posY, this.posZ, 5.0f, false); } spawnHitParticles("magicCrit", 8); @@ -71,16 +52,7 @@ public void onImpact(Entity mop) { } public void spawnSecondaryProjectiles() { - int secondaryDamage = 0; - if (this.projectileDamage == AlchemicalWizardry.energyBazookaDamage) { - secondaryDamage = AlchemicalWizardry.energyBazookaSecondaryDamage; - } - if (this.projectileDamage == AlchemicalWizardry.energyBazookaSecondTierDamage) { - secondaryDamage = AlchemicalWizardry.energyBazookaSecondTierSecondaryDamage; - } - if (this.projectileDamage == AlchemicalWizardry.energyBazookaThirdTierDamage) { - secondaryDamage = AlchemicalWizardry.energyBazookaThirdTierSecondaryDamage; - } + int secondaryDamage = getSecondaryDamage(); for (int i = 0; i < 20; i++) { EntityEnergyBazookaSecondaryProjectile secProj = new EntityEnergyBazookaSecondaryProjectile( worldObj, @@ -99,4 +71,17 @@ public void spawnSecondaryProjectiles() { worldObj.spawnEntityInWorld(secProj); } } + + private int getSecondaryDamage() { + if (this.projectileDamage == AlchemicalWizardry.energyBazookaDamage) { + return AlchemicalWizardry.energyBazookaSecondaryDamage; + } + if (this.projectileDamage == AlchemicalWizardry.energyBazookaSecondTierDamage) { + return AlchemicalWizardry.energyBazookaSecondTierSecondaryDamage; + } + if (this.projectileDamage == AlchemicalWizardry.energyBazookaThirdTierDamage) { + return AlchemicalWizardry.energyBazookaThirdTierSecondaryDamage; + } + return 0; + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityEnergyBazookaSecondaryProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityEnergyBazookaSecondaryProjectile.java index 235745eabb..bd95ceb43b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityEnergyBazookaSecondaryProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityEnergyBazookaSecondaryProjectile.java @@ -1,349 +1,33 @@ package WayofTime.alchemicalWizardry.common.entity.projectile; -import java.util.Iterator; -import java.util.List; - -import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IProjectile; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; -import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; import net.minecraft.world.World; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - public class EntityEnergyBazookaSecondaryProjectile extends EnergyBlastProjectile implements IProjectile { - private int xTile = -1; - private int yTile = -1; - private int zTile = -1; - private int inTile = 0; - private int inData = 0; - private boolean inGround = false; - /** - * The owner of this arrow. - */ public EntityLivingBase shootingEntity; - private int ticksInAir = 0; - private int ricochetCounter = 0; - private boolean scheduledForDeath = false; public int damage; - public EntityEnergyBazookaSecondaryProjectile(World par1World) { - super(par1World); + public EntityEnergyBazookaSecondaryProjectile(World world) { + super(world); this.setSize(0.5F, 0.5F); damage = 5; } - public EntityEnergyBazookaSecondaryProjectile(World par1World, double par2, double par4, double par6, int damage) { - super(par1World); + public EntityEnergyBazookaSecondaryProjectile(World world, double x, double y, double z, int damage) { + super(world); this.setSize(0.5F, 0.5F); - this.setPosition(par2, par4, par6); + this.setPosition(x, y, z); yOffset = 0.0F; this.damage = damage; } - public EntityEnergyBazookaSecondaryProjectile(World par1World, EntityPlayer par2EntityPlayer, int damage) { - super(par1World); - shootingEntity = par2EntityPlayer; - float par3 = 0.8F; - this.setSize(0.1F, 0.1F); - this.setLocationAndAngles( - par2EntityPlayer.posX, - par2EntityPlayer.posY + par2EntityPlayer.getEyeHeight(), - par2EntityPlayer.posZ, - par2EntityPlayer.rotationYaw, - par2EntityPlayer.rotationPitch); - posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; - posY -= 0.2D; - posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; - this.setPosition(posX, posY, posZ); - yOffset = 0.0F; - motionX = -MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI); - motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI); - motionY = -MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI); - this.setThrowableHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F); - this.damage = damage; - } - - @Override - protected void entityInit() { - dataWatcher.addObject(16, Byte.valueOf((byte) 0)); - } - - /** - * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. - */ - @Override - public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8) { - float var9 = MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5); - var1 /= var9; - var3 /= var9; - var5 /= var9; - var1 += rand.nextGaussian() * 0.007499999832361937D * var8; - var3 += rand.nextGaussian() * 0.007499999832361937D * var8; - var5 += rand.nextGaussian() * 0.007499999832361937D * var8; - var1 *= var7; - var3 *= var7; - var5 *= var7; - motionX = var1; - motionY = var3; - motionZ = var5; - float var10 = MathHelper.sqrt_double(var1 * var1 + var5 * var5); - prevRotationYaw = rotationYaw = (float) (Math.atan2(var1, var5) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float) (Math.atan2(var3, var10) * 180.0D / Math.PI); - } - - @Override - @SideOnly(Side.CLIENT) - /** - * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX, - * posY, posZ, yaw, pitch - */ - public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) { - this.setPosition(par1, par3, par5); - this.setRotation(par7, par8); - } - - @Override - @SideOnly(Side.CLIENT) - /** - * Sets the velocity to the args. Args: x, y, z - */ - public void setVelocity(double par1, double par3, double par5) { - motionX = par1; - motionY = par3; - motionZ = par5; - - if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) { - float var7 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); - prevRotationYaw = rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float) (Math.atan2(par3, var7) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch; - prevRotationYaw = rotationYaw; - this.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch); - } - } - - /** - * Called to update the entity's position/logic. - */ - @Override - public void onUpdate() { - super.onUpdate(); - - if (ticksInAir > maxTicksInAir) { - this.setDead(); - } - - if (shootingEntity == null) { - List players = worldObj.getEntitiesWithinAABB( - EntityPlayer.class, - AxisAlignedBB.getBoundingBox(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1)); - Iterator i = players.iterator(); - double closestDistance = Double.MAX_VALUE; - EntityPlayer closestPlayer = null; - - while (i.hasNext()) { - EntityPlayer e = (EntityPlayer) i.next(); - double distance = e.getDistanceToEntity(this); - - if (distance < closestDistance) { - closestPlayer = e; - } - } - - if (closestPlayer != null) { - shootingEntity = closestPlayer; - } - } - - if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) { - float var1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); - prevRotationYaw = rotationYaw = (float) (Math.atan2(motionX, motionZ) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float) (Math.atan2(motionY, var1) * 180.0D / Math.PI); - } - - Block var16 = worldObj.getBlock(xTile, yTile, zTile); - - if (var16 != null) { - var16.setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile); - AxisAlignedBB var2 = var16.getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile); - - if (var2 != null && var2.isVecInside(SpellHelper.createVec3(posX, posY, posZ))) { - inGround = true; - } - } - - if (inGround) { - Block var18 = worldObj.getBlock(xTile, yTile, zTile); - int var19 = worldObj.getBlockMetadata(xTile, yTile, zTile); - - if (var18.equals(Block.getBlockById(inTile)) && var19 == inData) {} - } else { - ++ticksInAir; - - if (ticksInAir > 1 && ticksInAir < 3) { - for (int particles = 0; particles < 3; particles++) { - this.doFiringParticles(); - } - } - - Vec3 var17 = SpellHelper.createVec3(posX, posY, posZ); - Vec3 var3 = SpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ); - MovingObjectPosition var4 = worldObj.func_147447_a(var17, var3, true, false, false); - var17 = SpellHelper.createVec3(posX, posY, posZ); - var3 = SpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ); - - if (var4 != null) { - var3 = SpellHelper.createVec3(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord); - } - - Entity var5 = null; - List var6 = worldObj.getEntitiesWithinAABBExcludingEntity( - this, - boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); - double var7 = 0.0D; - Iterator var9 = var6.iterator(); - float var11; - - while (var9.hasNext()) { - Entity var10 = (Entity) var9.next(); - - if (var10.canBeCollidedWith() && (var10 != shootingEntity || ticksInAir >= 5)) { - var11 = 0.3F; - AxisAlignedBB var12 = var10.boundingBox.expand(var11, var11, var11); - MovingObjectPosition var13 = var12.calculateIntercept(var17, var3); - - if (var13 != null) { - double var14 = var17.distanceTo(var13.hitVec); - - if (var14 < var7 || var7 == 0.0D) { - var5 = var10; - var7 = var14; - } - } - } - } - - if (var5 != null) { - var4 = new MovingObjectPosition(var5); - } - - if (var4 != null) { - this.onImpact(var4); - - if (scheduledForDeath) { - this.setDead(); - } - } - - posX += motionX; - posY += motionY; - posZ += motionZ; - MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); - this.setPosition(posX, posY, posZ); - } - } - - public void doFiringParticles() { - worldObj.spawnParticle( - "mobSpellAmbient", - posX + smallGauss(0.1D), - posY + smallGauss(0.1D), - posZ + smallGauss(0.1D), - 0.5D, - 0.5D, - 0.5D); - worldObj.spawnParticle("flame", posX, posY, posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ)); - } - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - @Override - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - par1NBTTagCompound.setShort("xTile", (short) xTile); - par1NBTTagCompound.setShort("yTile", (short) yTile); - par1NBTTagCompound.setShort("zTile", (short) zTile); - par1NBTTagCompound.setByte("inTile", (byte) inTile); - par1NBTTagCompound.setByte("inData", (byte) inData); - par1NBTTagCompound.setByte("inGround", (byte) (inGround ? 1 : 0)); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - @Override - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - xTile = par1NBTTagCompound.getShort("xTile"); - yTile = par1NBTTagCompound.getShort("yTile"); - zTile = par1NBTTagCompound.getShort("zTile"); - inTile = par1NBTTagCompound.getByte("inTile") & 255; - inData = par1NBTTagCompound.getByte("inData") & 255; - inGround = par1NBTTagCompound.getByte("inGround") == 1; - } - - /** - * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to - * prevent them from trampling crops - */ - @Override - protected boolean canTriggerWalking() { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public float getShadowSize() { - return 0.0F; - } - - /** - * Sets the amount of knockback the arrow applies when it hits a mob. - */ - public void setKnockbackStrength(int par1) {} - - /** - * If returns false, the item will not inflict any damage against entities. - */ @Override - public boolean canAttackWithItem() { - return false; - } - - /** - * Whether the arrow has a stream of critical hit particles flying behind it. - */ - public void setIsCritical(boolean par1) { - byte var2 = dataWatcher.getWatchableObjectByte(16); - - if (par1) { - dataWatcher.updateObject(16, Byte.valueOf((byte) (var2 | 1))); - } else { - dataWatcher.updateObject(16, Byte.valueOf((byte) (var2 & -2))); - } - } - - /** - * Whether the arrow has a stream of critical hit particles flying behind it. - */ - public boolean getIsCritical() { - byte var1 = dataWatcher.getWatchableObjectByte(16); - return (var1 & 1) != 0; - } - public void onImpact(MovingObjectPosition mop) { if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null) { if (mop.entityHit == shootingEntity) { @@ -357,12 +41,13 @@ public void onImpact(MovingObjectPosition mop) { } } - public void onImpact(Entity mop) { - if (mop == shootingEntity && ticksInAir > 3) { + @Override + public void onImpact(Entity target) { + if (target == shootingEntity && ticksInAir > 3) { shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1); this.setDead(); } else { - doDamage(this.damage + d6(), mop); + doDamage(this.damage + d6(), target); worldObj.createExplosion(shootingEntity, posX, posY, posZ, 2, false); } @@ -374,12 +59,13 @@ private int d6() { return rand.nextInt(6) + 1; } - public void spawnHitParticles(String string, int i) { - for (int particles = 0; particles < i; particles++) { + @Override + public void spawnHitParticles(String string, int particleCount) { + for (int particles = 0; particles < particleCount; particles++) { worldObj.spawnParticle( string, posX, - posY - (string == "portal" ? 1 : 0), + posY - (string.equals("portal") ? 1 : 0), posZ, gaussian(motionX), gaussian(motionY), @@ -387,10 +73,12 @@ public void spawnHitParticles(String string, int i) { } } + @Override public void doDamage(int i, Entity mop) { mop.attackEntityFrom(this.getDamageSource(), i); } + @Override public DamageSource getDamageSource() { return DamageSource.causeMobDamage(shootingEntity); } @@ -399,33 +87,11 @@ public void groundImpact(int sideHit) { this.ricochet(sideHit); } - public double smallGauss(double d) { - return (worldObj.rand.nextFloat() - 0.5D) * d; - } - - public double gaussian(double d) { - return d + d * ((rand.nextFloat() - 0.5D) / 4); - } - private void ricochet(int sideHit) { switch (sideHit) { - case 0: - case 1: - // topHit, bottomHit, reflect Y - motionY = motionY * -1; - break; - - case 2: - case 3: - // westHit, eastHit, reflect Z - motionZ = motionZ * -1; - break; - - case 4: - case 5: - // southHit, northHit, reflect X - motionX = motionX * -1; - break; + case 0, 1 -> motionY = motionY * -1; // topHit, bottomHit, reflect Y + case 2, 3 -> motionZ = motionZ * -1; // westHit, eastHit, reflect Z + case 4, 5 -> motionX = motionX * -1; // southHit, northHit, reflect X } ricochetCounter++; @@ -435,71 +101,14 @@ private void ricochet(int sideHit) { for (int particles = 0; particles < 4; particles++) { switch (sideHit) { - case 0: - worldObj.spawnParticle( - "smoke", - posX, - posY, - posZ, - gaussian(0.1D), - -gaussian(0.1D), - gaussian(0.1D)); - break; - - case 1: - worldObj.spawnParticle( - "smoke", - posX, - posY, - posZ, - gaussian(0.1D), - gaussian(0.1D), - gaussian(0.1D)); - break; - - case 2: - worldObj.spawnParticle( - "smoke", - posX, - posY, - posZ, - gaussian(0.1D), - gaussian(0.1D), - -gaussian(0.1D)); - break; - - case 3: - worldObj.spawnParticle( - "smoke", - posX, - posY, - posZ, - gaussian(0.1D), - gaussian(0.1D), - gaussian(0.1D)); - break; - - case 4: - worldObj.spawnParticle( - "smoke", - posX, - posY, - posZ, - -gaussian(0.1D), - gaussian(0.1D), - gaussian(0.1D)); - break; - - case 5: - worldObj.spawnParticle( - "smoke", - posX, - posY, - posZ, - gaussian(0.1D), - gaussian(0.1D), - gaussian(0.1D)); - break; + case 0 -> worldObj + .spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), -gaussian(0.1D), gaussian(0.1D)); + case 1, 3, 5 -> worldObj + .spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D)); + case 2 -> worldObj + .spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), -gaussian(0.1D)); + case 4 -> worldObj + .spawnParticle("smoke", posX, posY, posZ, -gaussian(0.1D), gaussian(0.1D), gaussian(0.1D)); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityMeteor.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityMeteor.java index 27948564c4..a1edbb4bb5 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityMeteor.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityMeteor.java @@ -18,35 +18,35 @@ public class EntityMeteor extends EnergyBlastProjectile { public ArrayList reagentList = new ArrayList<>(); - public EntityMeteor(World par1World) { - super(par1World); + public EntityMeteor(World world) { + super(world); this.meteorID = 0; } - public EntityMeteor(World par1World, double par2, double par4, double par6, int meteorID) { - super(par1World, par2, par4, par6); + public EntityMeteor(World world, double x, double y, double z, int meteorID) { + super(world, x, y, z); this.meteorID = meteorID; } @Override - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeEntityToNBT(par1NBTTagCompound); + public void writeEntityToNBT(NBTTagCompound tag) { + super.writeEntityToNBT(tag); - par1NBTTagCompound.setInteger("meteorID", meteorID); + tag.setInteger("meteorID", meteorID); for (Reagent r : reagentList) { - par1NBTTagCompound.setBoolean("reagent." + r.name, true); + tag.setBoolean("reagent." + r.name(), true); } } @Override - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readEntityFromNBT(par1NBTTagCompound); + public void readEntityFromNBT(NBTTagCompound tag) { + super.readEntityFromNBT(tag); - meteorID = par1NBTTagCompound.getInteger("meteorID"); + meteorID = tag.getInteger("meteorID"); for (Reagent r : ReagentRegistry.reagentList.values()) { - if (par1NBTTagCompound.getBoolean("reagent." + r.name)) { + if (tag.getBoolean("reagent." + r.name())) { reagentList.add(r); } } @@ -73,7 +73,7 @@ public void onImpact(MovingObjectPosition mop) { } @Override - public void onImpact(Entity mop) { + public void onImpact(Entity target) { MeteorRegistry .createMeteorImpact(worldObj, (int) this.posX, (int) this.posY, (int) this.posZ, meteorID, reagentList); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityParticleBeam.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityParticleBeam.java index f897609199..2d0a750229 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityParticleBeam.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/EntityParticleBeam.java @@ -37,157 +37,69 @@ public class EntityParticleBeam extends Entity implements IProjectile, IThrowabl protected int ticksInAir = 0; protected int maxTicksInAir = 600; - private int ricochetCounter = 0; private boolean scheduledForDeath = false; protected int projectileDamage; - public EntityParticleBeam(World par1World) { - super(par1World); + public EntityParticleBeam(World world) { + super(world); this.setSize(0.5F, 0.5F); this.maxTicksInAir = 600; } - public EntityParticleBeam(World par1World, double par2, double par4, double par6) { - super(par1World); + public EntityParticleBeam(World world, double x, double y, double z) { + super(world); this.setSize(0.5F, 0.5F); - this.setPosition(par2, par4, par6); + this.setPosition(x, y, z); yOffset = 0.0F; this.maxTicksInAir = 600; } - public EntityParticleBeam(World par1World, EntityLivingBase par2EntityPlayer, int damage) { - super(par1World); - shootingEntity = par2EntityPlayer; - float par3 = 0.8F; - this.setSize(0.5F, 0.5F); - this.setLocationAndAngles( - par2EntityPlayer.posX, - par2EntityPlayer.posY + par2EntityPlayer.getEyeHeight(), - par2EntityPlayer.posZ, - par2EntityPlayer.rotationYaw, - par2EntityPlayer.rotationPitch); - posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; - posY -= 0.2D; - posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; - this.setPosition(posX, posY, posZ); - yOffset = 0.0F; - motionX = -MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI); - motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI); - motionY = -MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI); - this.setThrowableHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F); - this.projectileDamage = damage; - this.maxTicksInAir = 600; - } - - public EntityParticleBeam(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, - double posX, double posY, double posZ, float rotationYaw, float rotationPitch) { - super(par1World); - shootingEntity = par2EntityPlayer; - float par3 = 0.8F; - this.setSize(0.5F, 0.5F); - this.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch); - posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; - posY -= 0.2D; - posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; - this.setPosition(posX, posY, posZ); - yOffset = 0.0F; - motionX = -MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI); - motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI); - motionY = -MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI); - this.setThrowableHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F); - this.projectileDamage = damage; - this.maxTicksInAir = maxTicksInAir; - } - - public EntityParticleBeam(World par1World, EntityLivingBase par2EntityLivingBase, - EntityLivingBase par3EntityLivingBase, float par4, float par5, int damage, int maxTicksInAir) { - super(par1World); - this.renderDistanceWeight = 10.0D; - this.shootingEntity = par2EntityLivingBase; - this.posY = par2EntityLivingBase.posY + (double) par2EntityLivingBase.getEyeHeight() - 0.10000000149011612D; - double d0 = par3EntityLivingBase.posX - par2EntityLivingBase.posX; - double d1 = par3EntityLivingBase.boundingBox.minY + (double) (par3EntityLivingBase.height / 1.5F) - this.posY; - double d2 = par3EntityLivingBase.posZ - par2EntityLivingBase.posZ; - double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2); - - if (d3 >= 1.0E-7D) { - float f2 = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; - float f3 = (float) (-(Math.atan2(d1, d3) * 180.0D / Math.PI)); - double d4 = d0 / d3; - double d5 = d2 / d3; - this.setLocationAndAngles( - par2EntityLivingBase.posX + d4, - this.posY, - par2EntityLivingBase.posZ + d5, - f2, - f3); - this.yOffset = 0.0F; - float f4 = (float) d3 * 0.2F; - this.setThrowableHeading(d0, d1, d2, par4, par5); - } - - this.projectileDamage = damage; - this.maxTicksInAir = maxTicksInAir; - } - @Override protected void entityInit() { - dataWatcher.addObject(16, Byte.valueOf((byte) 0)); + dataWatcher.addObject(16, (byte) 0); } /** * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. */ @Override - public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8) { - float var9 = MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5); - var1 /= var9; - var3 /= var9; - var5 /= var9; - var1 += rand.nextGaussian() * 0.007499999832361937D * var8; - var3 += rand.nextGaussian() * 0.007499999832361937D * var8; - var5 += rand.nextGaussian() * 0.007499999832361937D * var8; - var1 *= var7; - var3 *= var7; - var5 *= var7; - motionX = var1; - motionY = var3; - motionZ = var5; - float var10 = MathHelper.sqrt_double(var1 * var1 + var5 * var5); - prevRotationYaw = rotationYaw = (float) (Math.atan2(var1, var5) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float) (Math.atan2(var3, var10) * 180.0D / Math.PI); + public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) { + float var9 = MathHelper.sqrt_double(x * x + y * y + z * z); + x /= var9; + y /= var9; + z /= var9; + x += rand.nextGaussian() * 0.0075D * inaccuracy; + y += rand.nextGaussian() * 0.0075D * inaccuracy; + z += rand.nextGaussian() * 0.0075D * inaccuracy; + x *= velocity; + y *= velocity; + z *= velocity; + motionX = x; + motionY = y; + motionZ = z; + float horizontalDistance = MathHelper.sqrt_double(x * x + z * z); + prevRotationYaw = rotationYaw = (float) (Math.atan2(x, z) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch = (float) (Math.atan2(y, horizontalDistance) * 180.0D / Math.PI); } @Override @SideOnly(Side.CLIENT) - /** - * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX, - * posY, posZ, yaw, pitch - */ - public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) { - this.setPosition(par1, par3, par5); - this.setRotation(par7, par8); + public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int rotationIncrements) { + this.setPosition(x, y, z); + this.setRotation(yaw, pitch); } @Override @SideOnly(Side.CLIENT) - /** - * Sets the velocity to the args. Args: x, y, z - */ - public void setVelocity(double par1, double par3, double par5) { - motionX = par1; - motionY = par3; - motionZ = par5; + public void setVelocity(double x, double y, double z) { + motionX = x; + motionY = y; + motionZ = z; if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) { - float var7 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); - prevRotationYaw = rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float) (Math.atan2(par3, var7) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch; + float horizontalDistance = MathHelper.sqrt_double(x * x + z * z); + prevRotationYaw = rotationYaw = (float) (Math.atan2(x, z) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch = (float) (Math.atan2(y, horizontalDistance) * 180.0D / Math.PI); prevRotationYaw = rotationYaw; this.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch); } @@ -207,7 +119,6 @@ public void onUpdate() { posX += motionX; posY += motionY; posZ += motionZ; - MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); this.setPosition(posX, posY, posZ); this.doFiringParticles(); @@ -233,48 +144,42 @@ public void doFiringParticles() { FMLClientHandler.instance().getClient().effectRenderer.addEffect(particle); } - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ @Override - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - par1NBTTagCompound.setShort("xTile", (short) xTile); - par1NBTTagCompound.setShort("yTile", (short) yTile); - par1NBTTagCompound.setShort("zTile", (short) zTile); - par1NBTTagCompound.setByte("inTile", (byte) inTile); - par1NBTTagCompound.setByte("inData", (byte) inData); - par1NBTTagCompound.setByte("inGround", (byte) (inGround ? 1 : 0)); - par1NBTTagCompound.setInteger("ticksInAir", ticksInAir); - par1NBTTagCompound.setInteger("maxTicksInAir", maxTicksInAir); - par1NBTTagCompound.setInteger("projectileDamage", this.projectileDamage); - par1NBTTagCompound.setFloat("colourRed", colourRed); - par1NBTTagCompound.setFloat("colourGreen", colourGreen); - par1NBTTagCompound.setFloat("colourBlue", colourBlue); - par1NBTTagCompound.setInteger("xDest", xDest); - par1NBTTagCompound.setInteger("yDest", yDest); - par1NBTTagCompound.setInteger("zDest", zDest); + public void writeEntityToNBT(NBTTagCompound tag) { + tag.setShort("xTile", (short) xTile); + tag.setShort("yTile", (short) yTile); + tag.setShort("zTile", (short) zTile); + tag.setByte("inTile", (byte) inTile); + tag.setByte("inData", (byte) inData); + tag.setByte("inGround", (byte) (inGround ? 1 : 0)); + tag.setInteger("ticksInAir", ticksInAir); + tag.setInteger("maxTicksInAir", maxTicksInAir); + tag.setInteger("projectileDamage", this.projectileDamage); + tag.setFloat("colourRed", colourRed); + tag.setFloat("colourGreen", colourGreen); + tag.setFloat("colourBlue", colourBlue); + tag.setInteger("xDest", xDest); + tag.setInteger("yDest", yDest); + tag.setInteger("zDest", zDest); } - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ @Override - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - xTile = par1NBTTagCompound.getShort("xTile"); - yTile = par1NBTTagCompound.getShort("yTile"); - zTile = par1NBTTagCompound.getShort("zTile"); - inTile = par1NBTTagCompound.getByte("inTile") & 255; - inData = par1NBTTagCompound.getByte("inData") & 255; - inGround = par1NBTTagCompound.getByte("inGround") == 1; - ticksInAir = par1NBTTagCompound.getInteger("ticksInAir"); - maxTicksInAir = par1NBTTagCompound.getInteger("maxTicksInAir"); - projectileDamage = par1NBTTagCompound.getInteger("projectileDamage"); - colourRed = par1NBTTagCompound.getFloat("colourRed"); - colourGreen = par1NBTTagCompound.getFloat("colourGreen"); - colourBlue = par1NBTTagCompound.getFloat("colourBlue"); - xDest = par1NBTTagCompound.getInteger("xDest"); - yDest = par1NBTTagCompound.getInteger("yDest"); - zDest = par1NBTTagCompound.getInteger("zDest"); + public void readEntityFromNBT(NBTTagCompound tag) { + xTile = tag.getShort("xTile"); + yTile = tag.getShort("yTile"); + zTile = tag.getShort("zTile"); + inTile = tag.getByte("inTile") & 255; + inData = tag.getByte("inData") & 255; + inGround = tag.getByte("inGround") == 1; + ticksInAir = tag.getInteger("ticksInAir"); + maxTicksInAir = tag.getInteger("maxTicksInAir"); + projectileDamage = tag.getInteger("projectileDamage"); + colourRed = tag.getFloat("colourRed"); + colourGreen = tag.getFloat("colourGreen"); + colourBlue = tag.getFloat("colourBlue"); + xDest = tag.getInteger("xDest"); + yDest = tag.getInteger("yDest"); + zDest = tag.getInteger("zDest"); } @Override @@ -293,7 +198,7 @@ protected void spawnHitParticles(String string, int i) { worldObj.spawnParticle( string, posX, - posY - (string == "portal" ? 1 : 0), + posY - (string.equals("portal") ? 1 : 0), posZ, gaussian(motionX), gaussian(motionY), @@ -313,10 +218,6 @@ public double gaussian(double d) { return d + d * ((rand.nextFloat() - 0.5D) / 4); } - private int getRicochetMax() { - return 0; - } - @Override public Entity getThrower() { // TODO Auto-generated method stub diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/ExplosionProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/ExplosionProjectile.java index 23b6919df6..90698d9b15 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/ExplosionProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/ExplosionProjectile.java @@ -11,37 +11,21 @@ public class ExplosionProjectile extends EnergyBlastProjectile { protected boolean causesEnvDamage; - public ExplosionProjectile(World par1World) { - super(par1World); + public ExplosionProjectile(World world) { + super(world); } - public ExplosionProjectile(World par1World, double par2, double par4, double par6) { - super(par1World, par2, par4, par6); - } - - public ExplosionProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, boolean flag) { - super(par1World, par2EntityPlayer, damage); - causesEnvDamage = flag; - } - - public ExplosionProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, - double posX, double posY, double posZ, float rotationYaw, float rotationPitch, boolean flag) { - super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); + public ExplosionProjectile(World world, EntityLivingBase player, int damage, boolean flag) { + super(world, player, damage); causesEnvDamage = flag; } - public ExplosionProjectile(World par1World, EntityLivingBase par2EntityLivingBase, - EntityLivingBase par3EntityLivingBase, float par4, float par5, int damage, int maxTicksInAir, - boolean flag) { - super(par1World, par2EntityLivingBase, par3EntityLivingBase, par4, par5, damage, maxTicksInAir); + public ExplosionProjectile(World world, EntityLivingBase shooter, EntityLivingBase target, float par4, float par5, + int damage, int maxTicksInAir, boolean flag) { + super(world, shooter, target, par4, par5, damage, maxTicksInAir); causesEnvDamage = flag; } - @Override - public DamageSource getDamageSource() { - return DamageSource.causeMobDamage(shootingEntity); - } - @Override public void onImpact(MovingObjectPosition mop) { if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null) { @@ -60,13 +44,13 @@ public void onImpact(MovingObjectPosition mop) { } @Override - public void onImpact(Entity mop) { - if (mop == shootingEntity && ticksInAir > 3) { + public void onImpact(Entity target) { + if (target == shootingEntity && ticksInAir > 3) { shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1); this.setDead(); } else { - if (mop instanceof EntityLivingBase) { - doDamage(projectileDamage, mop); + if (target instanceof EntityLivingBase) { + doDamage(projectileDamage, target); } } @@ -88,17 +72,14 @@ public void doFiringParticles() { } @Override - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeEntityToNBT(par1NBTTagCompound); - par1NBTTagCompound.setBoolean("causesEnvDamage", causesEnvDamage); + public void writeEntityToNBT(NBTTagCompound tag) { + super.writeEntityToNBT(tag); + tag.setBoolean("causesEnvDamage", causesEnvDamage); } - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ @Override - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readEntityFromNBT(par1NBTTagCompound); - causesEnvDamage = par1NBTTagCompound.getBoolean("causesEnvDamage"); + public void readEntityFromNBT(NBTTagCompound tag) { + super.readEntityFromNBT(tag); + causesEnvDamage = tag.getBoolean("causesEnvDamage"); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/FireProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/FireProjectile.java index 7bb0e16e27..7370115787 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/FireProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/FireProjectile.java @@ -10,31 +10,22 @@ public class FireProjectile extends EnergyBlastProjectile { - public FireProjectile(World par1World) { - super(par1World); + public FireProjectile(World world) { + super(world); } - public FireProjectile(World par1World, double par2, double par4, double par6) { - super(par1World, par2, par4, par6); + public FireProjectile(World world, EntityLivingBase player, int damage) { + super(world, player, damage); } - public FireProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage) { - super(par1World, par2EntityPlayer, damage); + public FireProjectile(World world, EntityLivingBase player, int damage, int maxTicksInAir, double posX, double posY, + double posZ, float rotationYaw, float rotationPitch) { + super(world, player, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); } - public FireProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, - double posX, double posY, double posZ, float rotationYaw, float rotationPitch) { - super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); - } - - public FireProjectile(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, - float par4, float par5, int damage, int maxTicksInAir) { - super(par1World, par2EntityLivingBase, par3EntityLivingBase, par4, par5, damage, maxTicksInAir); - } - - @Override - public DamageSource getDamageSource() { - return DamageSource.causeMobDamage(shootingEntity); + public FireProjectile(World world, EntityLivingBase shooter, EntityLivingBase target, float velocity, + float inaccuracy, int damage, int maxTicksInAir) { + super(world, shooter, target, velocity, inaccuracy, damage, maxTicksInAir); } @Override @@ -65,22 +56,19 @@ public void onImpact(MovingObjectPosition mop) { } @Override - public void onImpact(Entity mop) { - if (mop == shootingEntity && ticksInAir > 3) { + public void onImpact(Entity target) { + if (target == shootingEntity && ticksInAir > 3) { shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1); this.setDead(); - } else { - if (mop instanceof EntityLivingBase) { - ((EntityLivingBase) mop).setFire(10 * this.projectileDamage); - ((EntityLivingBase) mop).setRevengeTarget(shootingEntity); + } else if (target instanceof EntityLivingBase entity) { + target.setFire(10 * this.projectileDamage); + entity.setRevengeTarget(shootingEntity); - if (((EntityLivingBase) mop).isPotionActive(Potion.fireResistance) - || ((EntityLivingBase) mop).isImmuneToFire()) { - ((EntityLivingBase) mop).attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1); - } else { - doDamage(projectileDamage, mop); - ((EntityLivingBase) mop).hurtResistantTime = 0; - } + if (entity.isPotionActive(Potion.fireResistance) || target.isImmuneToFire()) { + target.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1); + } else { + doDamage(projectileDamage, target); + target.hurtResistantTime = 0; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/HolyProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/HolyProjectile.java index 091b8d9559..a7522a3b31 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/HolyProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/HolyProjectile.java @@ -10,31 +10,22 @@ public class HolyProjectile extends EnergyBlastProjectile { - public HolyProjectile(World par1World) { - super(par1World); + public HolyProjectile(World world) { + super(world); } - public HolyProjectile(World par1World, double par2, double par4, double par6) { - super(par1World, par2, par4, par6); + public HolyProjectile(World world, EntityLivingBase player, int damage) { + super(world, player, damage); } - public HolyProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage) { - super(par1World, par2EntityPlayer, damage); + public HolyProjectile(World world, EntityLivingBase player, int damage, int maxTicksInAir, double posX, double posY, + double posZ, float rotationYaw, float rotationPitch) { + super(world, player, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); } - public HolyProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, - double posX, double posY, double posZ, float rotationYaw, float rotationPitch) { - super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); - } - - public HolyProjectile(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, - float par4, float par5, int damage, int maxTicksInAir) { - super(par1World, par2EntityLivingBase, par3EntityLivingBase, par4, par5, damage, maxTicksInAir); - } - - @Override - public DamageSource getDamageSource() { - return DamageSource.causeMobDamage(shootingEntity); + public HolyProjectile(World world, EntityLivingBase shooter, EntityLivingBase target, float par4, float par5, + int damage, int maxTicksInAir) { + super(world, shooter, target, par4, par5, damage, maxTicksInAir); } @Override @@ -45,28 +36,24 @@ public void onImpact(MovingObjectPosition mop) { } this.onImpact(mop.entityHit); - } else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {} + } this.setDead(); } @Override - public void onImpact(Entity mop) { - if (mop == shootingEntity && ticksInAir > 3) { + public void onImpact(Entity target) { + if (target == shootingEntity && ticksInAir > 3) { shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1); this.setDead(); - } else { - if (mop instanceof EntityLivingBase) { - if (((EntityLivingBase) mop).isEntityUndead()) { - doDamage((int) (projectileDamage * 2), mop); - } else { - doDamage(projectileDamage, mop); - } + } else if (target instanceof EntityLivingBase entity) { + if (entity.isEntityUndead()) { + doDamage(projectileDamage * 2, target); + } else { + doDamage(projectileDamage, target); } } - if (worldObj.isAirBlock((int) this.posX, (int) this.posY, (int) this.posZ)) {} - spawnHitParticles("magicCrit", 8); this.setDead(); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/IceProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/IceProjectile.java index 93935d0d4d..80851b4269 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/IceProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/IceProjectile.java @@ -12,31 +12,22 @@ public class IceProjectile extends EnergyBlastProjectile { - public IceProjectile(World par1World) { - super(par1World); + public IceProjectile(World world) { + super(world); } - public IceProjectile(World par1World, double par2, double par4, double par6) { - super(par1World, par2, par4, par6); + public IceProjectile(World world, EntityLivingBase player, int damage) { + super(world, player, damage); } - public IceProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage) { - super(par1World, par2EntityPlayer, damage); + public IceProjectile(World world, EntityLivingBase player, int damage, int maxTicksInAir, double posX, double posY, + double posZ, float rotationYaw, float rotationPitch) { + super(world, player, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); } - public IceProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, double posX, - double posY, double posZ, float rotationYaw, float rotationPitch) { - super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); - } - - public IceProjectile(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, - float par4, float par5, int damage, int maxTicksInAir) { - super(par1World, par2EntityLivingBase, par3EntityLivingBase, par4, par5, damage, maxTicksInAir); - } - - @Override - public DamageSource getDamageSource() { - return DamageSource.causeMobDamage(shootingEntity); + public IceProjectile(World world, EntityLivingBase shooter, EntityLivingBase target, float velocity, + float inaccuracy, int damage, int maxTicksInAir) { + super(world, shooter, target, velocity, inaccuracy, damage, maxTicksInAir); } @Override @@ -47,31 +38,25 @@ public void onImpact(MovingObjectPosition mop) { } this.onImpact(mop.entityHit); - } else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {} + } this.setDead(); } @Override - public void onImpact(Entity mop) { - if (mop == shootingEntity && ticksInAir > 3) { + public void onImpact(Entity target) { + if (target == shootingEntity && ticksInAir > 3) { shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1); this.setDead(); - } else { - if (mop instanceof EntityLivingBase) { - if (((EntityLivingBase) mop).isImmuneToFire()) { - doDamage((int) (projectileDamage * 2), mop); - ((EntityLivingBase) mop).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 2)); - } else { - doDamage(projectileDamage, mop); - ((EntityLivingBase) mop).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 1)); - } + } else if (target instanceof EntityLivingBase entity) { + if (target.isImmuneToFire()) { + doDamage(projectileDamage * 2, target); + entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200, 2)); + } else { + doDamage(projectileDamage, target); + entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 1)); } } - if (worldObj.isAirBlock((int) this.posX, (int) this.posY, (int) this.posZ)) { - // worldObj.setBlock((int)this.posX, (int)this.posY, (int)this.posZ,Block.fire.blockID); - } - spawnHitParticles("magicCrit", 8); this.setDead(); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/LightningBoltProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/LightningBoltProjectile.java index 0a33c2a3e7..beaf52dc78 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/LightningBoltProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/LightningBoltProjectile.java @@ -4,7 +4,6 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; @@ -14,28 +13,13 @@ public class LightningBoltProjectile extends EnergyBlastProjectile { private boolean causeLightning; - public LightningBoltProjectile(World par1World) { - super(par1World); + public LightningBoltProjectile(World world) { + super(world); } - public LightningBoltProjectile(World par1World, double par2, double par4, double par6) { - super(par1World, par2, par4, par6); - } - - public LightningBoltProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, boolean flag) { - super(par1World, par2EntityPlayer, damage); - causeLightning = flag; - } - - public LightningBoltProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, - double posX, double posY, double posZ, float rotationYaw, float rotationPitch, boolean flag) { - super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); - causeLightning = flag; - } - - @Override - public DamageSource getDamageSource() { - return DamageSource.causeMobDamage(shootingEntity); + public LightningBoltProjectile(World world, EntityLivingBase player, int damage, boolean causeLightning) { + super(world, player, damage); + this.causeLightning = causeLightning; } @Override @@ -56,21 +40,15 @@ public void onImpact(MovingObjectPosition mop) { } @Override - public void onImpact(Entity mop) { - if (mop == shootingEntity && ticksInAir > 3) { + public void onImpact(Entity target) { + if (target == shootingEntity && ticksInAir > 3) { this.setDead(); - } else { - if (mop instanceof EntityLivingBase) { - if (causeLightning) { - this.worldObj.addWeatherEffect( - new EntityLightningBolt( - this.worldObj, - ((EntityLivingBase) mop).posX, - ((EntityLivingBase) mop).posY, - ((EntityLivingBase) mop).posZ)); - } else { - doDamage(projectileDamage, mop); - } + } else if (target instanceof EntityLivingBase) { + if (causeLightning) { + this.worldObj.addWeatherEffect( + new EntityLightningBolt(this.worldObj, target.posX, target.posY, target.posZ)); + } else { + doDamage(projectileDamage, target); } } @@ -111,14 +89,14 @@ public void doFiringParticles() { } @Override - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeEntityToNBT(par1NBTTagCompound); - par1NBTTagCompound.setBoolean("causeLightning", causeLightning); + public void writeEntityToNBT(NBTTagCompound tag) { + super.writeEntityToNBT(tag); + tag.setBoolean("causeLightning", causeLightning); } @Override - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readEntityFromNBT(par1NBTTagCompound); - causeLightning = par1NBTTagCompound.getBoolean("causeLightning"); + public void readEntityFromNBT(NBTTagCompound tag) { + super.readEntityFromNBT(tag); + causeLightning = tag.getBoolean("causeLightning"); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/MudProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/MudProjectile.java index d6dddd344d..b86b509292 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/MudProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/MudProjectile.java @@ -5,7 +5,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; -import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; @@ -15,36 +14,27 @@ public class MudProjectile extends EnergyBlastProjectile { private boolean doesBlindness; // True for when it applies blindness, false for slowness - public MudProjectile(World par1World) { - super(par1World); + public MudProjectile(World world) { + super(world); } - public MudProjectile(World par1World, double par2, double par4, double par6) { - super(par1World, par2, par4, par6); + public MudProjectile(World world, EntityLivingBase player, int damage, boolean doesBlindness) { + super(world, player, damage); + this.doesBlindness = doesBlindness; } - public MudProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, boolean flag) { - super(par1World, par2EntityPlayer, damage); + public MudProjectile(World world, EntityLivingBase player, int damage, int maxTicksInAir, double posX, double posY, + double posZ, float rotationYaw, float rotationPitch, boolean flag) { + super(world, player, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); doesBlindness = flag; } - public MudProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, double posX, - double posY, double posZ, float rotationYaw, float rotationPitch, boolean flag) { - super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); - doesBlindness = flag; - } - - public MudProjectile(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, - float par4, float par5, int damage, int maxTicksInAir, boolean flag) { - super(par1World, par2EntityLivingBase, par3EntityLivingBase, par4, par5, damage, maxTicksInAir); + public MudProjectile(World world, EntityLivingBase shooter, EntityLivingBase target, float par4, float par5, + int damage, int maxTicksInAir, boolean flag) { + super(world, shooter, target, par4, par5, damage, maxTicksInAir); doesBlindness = flag; } - @Override - public DamageSource getDamageSource() { - return DamageSource.causeMobDamage(shootingEntity); - } - @Override public void onImpact(MovingObjectPosition mop) { if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null) { @@ -53,24 +43,22 @@ public void onImpact(MovingObjectPosition mop) { } this.onImpact(mop.entityHit); - } else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {} + } this.setDead(); } @Override - public void onImpact(Entity mop) { - if (mop == shootingEntity && ticksInAir > 3) { + public void onImpact(Entity target) { + if (target == shootingEntity && ticksInAir > 3) { this.setDead(); - } else { - if (mop instanceof EntityLivingBase) { - if (doesBlindness) { - ((EntityLivingBase) mop).addPotionEffect(new PotionEffect(Potion.blindness.id, 100, 0)); - } else { - ((EntityLivingBase) mop).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 2)); - } - doDamage(projectileDamage, mop); + } else if (target instanceof EntityLivingBase entity) { + if (doesBlindness) { + entity.addPotionEffect(new PotionEffect(Potion.blindness.id, 100, 0)); + } else { + entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 2)); } + doDamage(projectileDamage, target); } spawnHitParticles("magicCrit", 8); @@ -110,14 +98,14 @@ public void doFiringParticles() { } @Override - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeEntityToNBT(par1NBTTagCompound); - par1NBTTagCompound.setBoolean("doesBlindness", doesBlindness); + public void writeEntityToNBT(NBTTagCompound tag) { + super.writeEntityToNBT(tag); + tag.setBoolean("doesBlindness", doesBlindness); } @Override - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readEntityFromNBT(par1NBTTagCompound); - doesBlindness = par1NBTTagCompound.getBoolean("doesBlindness"); + public void readEntityFromNBT(NBTTagCompound tag) { + super.readEntityFromNBT(tag); + doesBlindness = tag.getBoolean("doesBlindness"); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/TeleportProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/TeleportProjectile.java index 80a0f139bc..e198fa3d4c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/TeleportProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/TeleportProjectile.java @@ -4,7 +4,6 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; @@ -17,42 +16,21 @@ public class TeleportProjectile extends EnergyBlastProjectile { private boolean isEntityTeleport; - public TeleportProjectile(World par1World) { - super(par1World); + public TeleportProjectile(World world) { + super(world); this.motionX *= 3; this.motionY *= 3; this.motionZ *= 3; } - public TeleportProjectile(World par1World, double par2, double par4, double par6) { - super(par1World, par2, par4, par6); - this.motionX *= 3; - this.motionY *= 3; - this.motionZ *= 3; - } - - public TeleportProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, boolean flag) { - super(par1World, par2EntityPlayer, damage); - isEntityTeleport = flag; - this.motionX *= 3; - this.motionY *= 3; - this.motionZ *= 3; - } - - public TeleportProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, - double posX, double posY, double posZ, float rotationYaw, float rotationPitch, boolean flag) { - super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); - isEntityTeleport = flag; + public TeleportProjectile(World world, EntityLivingBase player, int damage, boolean isEntityTeleport) { + super(world, player, damage); + this.isEntityTeleport = isEntityTeleport; this.motionX *= 3; this.motionY *= 3; this.motionZ *= 3; } - @Override - public DamageSource getDamageSource() { - return DamageSource.causeMobDamage(shootingEntity); - } - @Override public void onImpact(MovingObjectPosition mop) { if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null) { @@ -62,25 +40,20 @@ public void onImpact(MovingObjectPosition mop) { this.onImpact(mop.entityHit); } else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - if (isEntityTeleport) { - if (shootingEntity != null && shootingEntity instanceof EntityPlayerMP) { - EntityPlayerMP entityplayermp = (EntityPlayerMP) shootingEntity; - - if (entityplayermp.worldObj == this.worldObj) { - EnderTeleportEvent event = new EnderTeleportEvent( - entityplayermp, - this.posX, - this.posY, - this.posZ, - 5.0F); - - if (!MinecraftForge.EVENT_BUS.post(event)) { - if (shootingEntity.isRiding()) { - shootingEntity.mountEntity((Entity) null); - } - shootingEntity.setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); - } + if (isEntityTeleport && shootingEntity instanceof EntityPlayerMP entityplayermp + && entityplayermp.worldObj == this.worldObj) { + EnderTeleportEvent event = new EnderTeleportEvent( + entityplayermp, + this.posX, + this.posY, + this.posZ, + 5.0F); + + if (!MinecraftForge.EVENT_BUS.post(event)) { + if (shootingEntity.isRiding()) { + shootingEntity.mountEntity(null); } + shootingEntity.setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); } } } @@ -89,33 +62,27 @@ public void onImpact(MovingObjectPosition mop) { } @Override - public void onImpact(Entity mop) { - if (mop == shootingEntity && ticksInAir > 3) { + public void onImpact(Entity target) { + if (target == shootingEntity && ticksInAir > 3) { this.setDead(); - } else { - if (mop instanceof EntityLivingBase) { - if (isEntityTeleport) { - if (shootingEntity != null && shootingEntity instanceof EntityPlayerMP) { - EntityPlayerMP entityplayermp = (EntityPlayerMP) shootingEntity; - if (entityplayermp.worldObj == this.worldObj) { - EnderTeleportEvent event = new EnderTeleportEvent( - entityplayermp, - this.posX, - this.posY, - this.posZ, - 5.0F); - if (!MinecraftForge.EVENT_BUS.post(event)) { - if (shootingEntity.isRiding()) { - shootingEntity.mountEntity((Entity) null); - } - - shootingEntity.setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); - } + spawnHitParticles("magicCrit", 8); + return; + } + if (target instanceof EntityLivingBase entity) { + if (isEntityTeleport) { + if (shootingEntity != null && shootingEntity instanceof EntityPlayerMP player + && player.worldObj == this.worldObj) { + EnderTeleportEvent event = new EnderTeleportEvent(player, this.posX, this.posY, this.posZ, 5.0F); + if (!MinecraftForge.EVENT_BUS.post(event)) { + if (shootingEntity.isRiding()) { + shootingEntity.mountEntity(null); } + + shootingEntity.setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); } - } else { - SpellTeleport.teleportRandomly((EntityLivingBase) mop, 64); } + } else { + SpellTeleport.teleportRandomly(entity, 64); } } @@ -156,14 +123,14 @@ public void doFiringParticles() { } @Override - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeEntityToNBT(par1NBTTagCompound); - par1NBTTagCompound.setBoolean("isEntityTeleport", isEntityTeleport); + public void writeEntityToNBT(NBTTagCompound tag) { + super.writeEntityToNBT(tag); + tag.setBoolean("isEntityTeleport", isEntityTeleport); } @Override - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readEntityFromNBT(par1NBTTagCompound); - isEntityTeleport = par1NBTTagCompound.getBoolean("isEntityTeleport"); + public void readEntityFromNBT(NBTTagCompound tag) { + super.readEntityFromNBT(tag); + isEntityTeleport = tag.getBoolean("isEntityTeleport"); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/WaterProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/WaterProjectile.java index dac1b204e2..150d4c63bd 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/WaterProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/WaterProjectile.java @@ -3,7 +3,6 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.potion.PotionEffect; -import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; @@ -12,26 +11,17 @@ public class WaterProjectile extends EnergyBlastProjectile { - public WaterProjectile(World par1World) { - super(par1World); + public WaterProjectile(World world) { + super(world); } - public WaterProjectile(World par1World, double par2, double par4, double par6) { - super(par1World, par2, par4, par6); + public WaterProjectile(World world, EntityLivingBase player, int damage) { + super(world, player, damage); } - public WaterProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage) { - super(par1World, par2EntityPlayer, damage); - } - - public WaterProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, - double posX, double posY, double posZ, float rotationYaw, float rotationPitch) { - super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); - } - - @Override - public DamageSource getDamageSource() { - return DamageSource.causeMobDamage(shootingEntity); + public WaterProjectile(World world, EntityLivingBase player, int damage, int maxTicksInAir, double posX, + double posY, double posZ, float rotationYaw, float rotationPitch) { + super(world, player, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); } @Override @@ -42,26 +32,22 @@ public void onImpact(MovingObjectPosition mop) { } this.onImpact(mop.entityHit); - } else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {} + } this.setDead(); } @Override - public void onImpact(Entity mop) { - if (mop == shootingEntity && ticksInAir > 3) { + public void onImpact(Entity target) { + if (target == shootingEntity && ticksInAir > 3) { this.setDead(); - } else { - if (mop instanceof EntityLivingBase) { - if (((EntityLivingBase) mop).isImmuneToFire()) { - doDamage(projectileDamage * 2, mop); - ((EntityLivingBase) mop) - .addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionDrowning.id, 80, 1)); - } else { - doDamage(projectileDamage, mop); - ((EntityLivingBase) mop) - .addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionDrowning.id, 80, 0)); - } + } else if (target instanceof EntityLivingBase entity) { + if (target.isImmuneToFire()) { + doDamage(projectileDamage * 2, target); + entity.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionDrowning.id, 80, 1)); + } else { + doDamage(projectileDamage, target); + entity.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionDrowning.id, 80, 0)); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/WindGustProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/WindGustProjectile.java index 3d009d50a9..fb59256e63 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/WindGustProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/entity/projectile/WindGustProjectile.java @@ -2,7 +2,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.DamageSource; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; @@ -10,31 +10,17 @@ public class WindGustProjectile extends EnergyBlastProjectile { - public WindGustProjectile(World par1World) { - super(par1World); + public WindGustProjectile(World world) { + super(world); } - public WindGustProjectile(World par1World, double par2, double par4, double par6) { - super(par1World, par2, par4, par6); + public WindGustProjectile(World world, EntityLivingBase player, int damage) { + super(world, player, damage); } - public WindGustProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage) { - super(par1World, par2EntityPlayer, damage); - } - - public WindGustProjectile(World par1World, EntityLivingBase par2EntityPlayer, int damage, int maxTicksInAir, - double posX, double posY, double posZ, float rotationYaw, float rotationPitch) { - super(par1World, par2EntityPlayer, damage, maxTicksInAir, posX, posY, posZ, rotationYaw, rotationPitch); - } - - public WindGustProjectile(World par1World, EntityLivingBase par2EntityLivingBase, - EntityLivingBase par3EntityLivingBase, float par4, float par5, int damage, int maxTicksInAir) { - super(par1World, par2EntityLivingBase, par3EntityLivingBase, par4, par5, damage, maxTicksInAir); - } - - @Override - public DamageSource getDamageSource() { - return DamageSource.causeMobDamage(shootingEntity); + public WindGustProjectile(World world, EntityLivingBase shooter, EntityLivingBase target, float par4, float par5, + int damage, int maxTicksInAir) { + super(world, shooter, target, par4, par5, damage, maxTicksInAir); } @Override @@ -45,21 +31,25 @@ public void onImpact(MovingObjectPosition mop) { } this.onImpact(mop.entityHit); - } else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {} + } this.setDead(); } @Override - public void onImpact(Entity mop) { - if (mop == shootingEntity && ticksInAir > 3) { + public void onImpact(Entity target) { + if (target == shootingEntity && ticksInAir > 3 || target == this.shootingEntity) { this.setDead(); - } else { - if (mop instanceof EntityLivingBase) { - ((EntityLivingBase) mop).motionX = this.motionX * 0.25 * this.projectileDamage; - ((EntityLivingBase) mop).motionY = 1.5; - ((EntityLivingBase) mop).motionZ = this.motionZ * 0.25 * this.projectileDamage; - } + } else if (target instanceof EntityPlayer player) { + SpellHelper.setPlayerSpeedFromServer( + player, + this.motionX * 0.25 * this.projectileDamage, + 1.5, + this.motionZ * 0.25 * this.projectileDamage); + } else if (target instanceof EntityLivingBase) { + target.motionX += this.motionX * 0.25 * this.projectileDamage; + target.motionY += 1.5; + target.motionZ += this.motionZ * 0.25 * this.projectileDamage; } spawnHitParticles("magicCrit", 8); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/harvest/AgriCraftCropHarvestHandler.java b/src/main/java/WayofTime/alchemicalWizardry/common/harvest/AgriCraftCropHarvestHandler.java index 5c311e69da..49aad58327 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/harvest/AgriCraftCropHarvestHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/harvest/AgriCraftCropHarvestHandler.java @@ -6,6 +6,7 @@ import net.minecraft.block.Block; import net.minecraft.world.World; +import WayofTime.alchemicalWizardry.AlchemicalWizardry; import WayofTime.alchemicalWizardry.api.harvest.IHarvestHandler; import cpw.mods.fml.common.registry.GameRegistry; @@ -19,20 +20,11 @@ public AgriCraftCropHarvestHandler() { this.harvestBlock = getBlockForString("AgriCraft:crops"); if (this.harvestBlock != null) { try { - Class clazz = Class.forName("com.InfinityRaider.AgriCraft.blocks.BlockCrop"); - if (clazz != null) { - isMature = clazz.getMethod("isMature", World.class, int.class, int.class, int.class); - harvest = clazz.getMethod("harvest", World.class, int.class, int.class, int.class); - } - } catch (ClassNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (NoSuchMethodException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + Class clazz = Class.forName("com.InfinityRaider.AgriCraft.blocks.BlockCrop"); + isMature = clazz.getMethod("isMature", World.class, int.class, int.class, int.class); + harvest = clazz.getMethod("harvest", World.class, int.class, int.class, int.class); + } catch (ClassNotFoundException | NoSuchMethodException | SecurityException e) { + AlchemicalWizardry.logger.error(e); } } } @@ -61,15 +53,8 @@ public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, try { return (Boolean) (isMature.invoke(block, world, xCoord, yCoord, zCoord)) && (Boolean) (harvest.invoke(block, world, xCoord, yCoord, zCoord)); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + AlchemicalWizardry.logger.error(e); } return false; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/AWBaseItems.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/AWBaseItems.java index 8fbf63899d..c31797b34a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/AWBaseItems.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/AWBaseItems.java @@ -19,6 +19,7 @@ public AWBaseItems() { setCreativeTab(AlchemicalWizardry.tabBloodMagic); } + @Override public void registerIcons(IIconRegister iconRegister) { if (this.equals(ModItems.blankSlate)) { this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BlankSlate"); @@ -32,8 +33,8 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.infusedstone.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.infusedstone.desc2")); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.infusedstone.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.infusedstone.desc2")); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ActivationCrystal.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ActivationCrystal.java index f407420c14..270541df9c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ActivationCrystal.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ActivationCrystal.java @@ -44,20 +44,19 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, - boolean par4) { - switch (par1ItemStack.getItemDamage()) { - case 0 -> par3List.add(StatCollector.translateToLocal("tooltip.activationcrystal.lowlevelrituals")); - case 1 -> par3List.add(StatCollector.translateToLocal("tooltip.activationcrystal.powerfulrituals")); - case 2 -> par3List.add(StatCollector.translateToLocal("tooltip.activationcrystal.creativeonly")); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + switch (item.getItemDamage()) { + case 0 -> tooltip.add(StatCollector.translateToLocal("tooltip.activationcrystal.lowlevelrituals")); + case 1 -> tooltip.add(StatCollector.translateToLocal("tooltip.activationcrystal.powerfulrituals")); + case 2 -> tooltip.add(StatCollector.translateToLocal("tooltip.activationcrystal.creativeonly")); } - addBindingInformation(par1ItemStack, par3List); + addBindingInformation(item, tooltip); } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer); - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + IBindable.checkAndSetItemOwner(item, player); + return item; } public int getCrystalLevel(ItemStack itemStack) { @@ -80,7 +79,7 @@ public IIcon getIconFromDamage(int meta) { @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) { + public void getSubItems(Item id, CreativeTabs creativeTab, List list) { for (int meta = 0; meta < ACTIVATION_CRYSTAL_NAMES.length; ++meta) { list.add(new ItemStack(id, 1, meta)); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ArmourInhibitor.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ArmourInhibitor.java index e001678791..711412a00a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ArmourInhibitor.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ArmourInhibitor.java @@ -32,10 +32,10 @@ public ArmourInhibitor() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.armorinhibitor.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.armorinhibitor.desc2")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.armorinhibitor.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.armorinhibitor.desc2")); + addBindingInformation(item, tooltip); } @Override @@ -57,8 +57,8 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - if (par1 == 1) { + public IIcon getIconFromDamage(int meta) { + if (meta == 1) { return this.activeIcon; } else { return this.passiveIcon; @@ -66,33 +66,31 @@ public IIcon getIconFromDamage(int par1) { } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - IBindable.setActive(par1ItemStack, !IBindable.isActive(par1ItemStack)); + IBindable.setActive(item, !IBindable.isActive(item)); - if (IBindable.isActive(par1ItemStack)) { - par1ItemStack.setItemDamage(1); - this.setDrainTick(par1ItemStack, par2World); + if (IBindable.isActive(item)) { + item.setItemDamage(1); + this.setDrainTick(item, world); } else { - par1ItemStack.setItemDamage(par1ItemStack.getMaxDamage()); + item.setItemDamage(item.getMaxDamage()); } - return par1ItemStack; + return item; } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer)) { + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if (!(entity instanceof EntityPlayer player)) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; - - if (IBindable.isActive(par1ItemStack)) { - par3EntityPlayer.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 2, 0)); + if (IBindable.isActive(item)) { + player.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 2, 0)); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/BlankSpell.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/BlankSpell.java index 58e2578638..bd564f0fdc 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/BlankSpell.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/BlankSpell.java @@ -32,65 +32,55 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.blankspell.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.blankspell.desc")); + addBindingInformation(item, tooltip); - if (!(par1ItemStack.getTagCompound() == null)) { - NBTTagCompound itemTag = par1ItemStack.getTagCompound(); + if (!(item.getTagCompound() == null)) { + NBTTagCompound itemTag = item.getTagCompound(); - par3List.add( + tooltip.add( StatCollector.translateToLocal("tooltip.alchemy.coords") + " " + itemTag.getInteger("xCoord") + ", " + itemTag.getInteger("yCoord") + ", " + itemTag.getInteger("zCoord")); - par3List.add( - StatCollector.translateToLocal("tooltip.alchemy.dimension") + " " + getDimensionID(par1ItemStack)); + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.dimension") + " " + getDimensionID(item)); } } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par2World.isRemote) { - World world = DimensionManager.getWorld(getDimensionID(par1ItemStack)); - - if (world != null) { - NBTTagCompound itemTag = par1ItemStack.getTagCompound(); - TileEntity tileEntity = world.getTileEntity( - itemTag.getInteger("xCoord"), - itemTag.getInteger("yCoord"), - itemTag.getInteger("zCoord")); - - if (tileEntity instanceof TEHomHeart) { - TEHomHeart homHeart = (TEHomHeart) tileEntity; + if (world.isRemote) { + return item; + } + World dim = DimensionManager.getWorld(getDimensionID(item)); - if (homHeart.canCastSpell(par1ItemStack, par2World, par3EntityPlayer)) { - if (EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, homHeart.getCostForSpell())) { - EnergyItems.syphonBatteries( - par1ItemStack, - par3EntityPlayer, - homHeart.castSpell(par1ItemStack, par2World, par3EntityPlayer)); - } - } else { - return par1ItemStack; - } - } else { - return par1ItemStack; - } - } else { - return par1ItemStack; - } - } else { - return par1ItemStack; + if (dim == null) { + return item; + } + NBTTagCompound itemTag = item.getTagCompound(); + TileEntity tileEntity = dim.getTileEntity( + itemTag.getInteger("xCoord"), + itemTag.getInteger("yCoord"), + itemTag.getInteger("zCoord")); + + if (!(tileEntity instanceof TEHomHeart homHeart)) { + return item; + } + if (!homHeart.canCastSpell(item, world, player)) { + return item; + } + if (EnergyItems.syphonBatteries(item, player, homHeart.getCostForSpell())) { + EnergyItems.syphonBatteries(item, player, homHeart.castSpell(item, world, player)); } - par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - return par1ItemStack; + world.playSoundAtEntity(player, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + return item; } public int getDimensionID(ItemStack itemStack) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundAxe.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundAxe.java index 79300148a3..75a1c57d74 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundAxe.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundAxe.java @@ -12,7 +12,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemAxe; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraft.util.Vec3; @@ -31,7 +30,6 @@ public class BoundAxe extends ItemAxe implements IBindable { public float efficiencyOnProperMaterial = 12.0F; - public float damageVsEntity; public int rightClickCost = 10000; @SideOnly(Side.CLIENT) @@ -45,8 +43,6 @@ public class BoundAxe extends ItemAxe implements IBindable { public BoundAxe() { super(AlchemicalWizardry.bloodBoundToolMaterial); this.maxStackSize = 1; - this.efficiencyOnProperMaterial = 12.0F; - this.damageVsEntity = 5; setCreativeTab(AlchemicalWizardry.tabBloodMagic); setEnergyUsed(5); this.setHarvestLevel("axe", 7); @@ -56,19 +52,15 @@ public void setEnergyUsed(int i) { energyUsed = i; } - public int getEnergyUsed() { - return this.energyUsed; - } - @Override public int drainCost() { return this.energyUsed; } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.boundaxe.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.boundaxe.desc")); + addBindingInformation(item, tooltip); } @Override @@ -89,70 +81,68 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (checkRightClick(par1ItemStack, par2World, par3EntityPlayer)) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (checkRightClick(item, world, player)) { + return item; } - Vec3 blockVec = SpellHelper.getEntityBlockVector(par3EntityPlayer); + Vec3 blockVec = SpellHelper.getEntityBlockVector(player); int posX = (int) (blockVec.xCoord); int posY = (int) (blockVec.yCoord); int posZ = (int) (blockVec.zCoord); - boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(par3EntityPlayer); - int fortuneLvl = EnchantmentHelper.getFortuneModifier(par3EntityPlayer); + boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(player); + int fortuneLvl = EnchantmentHelper.getFortuneModifier(player); HashMultiset dropMultiset = HashMultiset.create(); for (int i = -5; i <= 5; i++) { for (int j = 0; j <= 10; j++) { for (int k = -5; k <= 5; k++) { - Block block = par2World.getBlock(posX + i, posY + j, posZ + k); - int meta = par2World.getBlockMetadata(posX + i, posY + j, posZ + k); - - if (block != null) { - float str = func_150893_a(par1ItemStack, block); - - if (str > 1.1f || block instanceof BlockLeavesBase - && par2World.canMineBlock(par3EntityPlayer, posX + i, posY + j, posZ + k)) { - if (silkTouch && block - .canSilkHarvest(par2World, par3EntityPlayer, posX + i, posY + j, posZ + k, meta)) { - dropMultiset.add(new ItemType(block, meta)); - } else { - ArrayList itemDropList = block - .getDrops(par2World, posX + i, posY + j, posZ + k, meta, fortuneLvl); - - if (itemDropList != null) { - for (ItemStack stack : itemDropList) - dropMultiset.add(ItemType.fromStack(stack), stack.stackSize); - } - } - - par2World.setBlockToAir(posX + i, posY + j, posZ + k); + int x = posX + i; + int y = posY + j; + int z = posZ + k; + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + if (BoundPickaxe.checkPermissions(world, x, y, z, block, meta, player)) continue; + + if (block == null || block.getBlockHardness(world, x, y, z) == -1 + || !world.canMineBlock(player, x, y, z)) { + continue; + } + + // getStrVsBlock + if (func_150893_a(item, block) <= 1f && !(block instanceof BlockLeavesBase)) { + continue; + } + if (silkTouch && block.canSilkHarvest(world, player, x, y, z, meta)) { + dropMultiset.add(new ItemType(block, meta)); + } else { + ArrayList itemDropList = block.getDrops(world, x, y, z, meta, fortuneLvl); + + if (itemDropList != null) { + for (ItemStack stack : itemDropList) + dropMultiset.add(ItemType.fromStack(stack), stack.stackSize); } } + + world.setBlockToAir(x, y, z); } } } - BoundPickaxe.dropMultisetStacks(dropMultiset, par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ); + BoundPickaxe.dropMultisetStacks(dropMultiset, world, posX, posY + player.getEyeHeight(), posZ); - return par1ItemStack; + return item; } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer)) { + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if (!(entity instanceof EntityPlayer player)) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; - - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); - } - checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer); - - par1ItemStack.setItemDamage(0); + checkPassiveDrain(item, world, player); + item.setItemDamage(0); } /** @@ -160,48 +150,40 @@ public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity * sword */ @Override - public float func_150893_a(ItemStack par1ItemStack, Block par2Block) { - if (!IBindable.isActive(par1ItemStack)) { + public float func_150893_a(ItemStack item, Block block) { + if (!IBindable.isActive(item)) { return 0.0F; } - return super.func_150893_a(par1ItemStack, par2Block); + return super.func_150893_a(item, block); } /** * Current implementations of this method in child classes do not use the entry argument beside ev. They just raise * the damage on the stack. */ - public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, - EntityLivingBase par3EntityLivingBase) { - return IBindable.isActive(par1ItemStack); + @Override + public boolean hitEntity(ItemStack item, EntityLivingBase target, EntityLivingBase attacker) { + return IBindable.isActive(item); } - public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, Block par3, int par4, int par5, int par6, - EntityLivingBase par7EntityLivingBase) { + @Override + public boolean onBlockDestroyed(ItemStack item, World world, Block block, int x, int y, int z, + EntityLivingBase user) { return true; } + @Override @SideOnly(Side.CLIENT) - - /** - * Returns True is the item is renderer in full 3D when hold. - */ public boolean isFull3D() { return true; } - /** - * Return the enchantability factor of the item, most of the time is based on material. - */ @Override public int getItemEnchantability() { return 30; } - /** - * FORGE: Overridden to allow custom tool effectiveness - */ @Override public float getDigSpeed(ItemStack stack, Block block, int meta) { if (!IBindable.isActive(stack)) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundPickaxe.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundPickaxe.java index d27f05c4bb..7f20a7f105 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundPickaxe.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundPickaxe.java @@ -12,12 +12,13 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.BlockEvent; import com.google.common.collect.HashMultiset; import com.google.common.collect.Multiset; @@ -33,7 +34,6 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable { public float efficiencyOnProperMaterial = 12.0F; - public float damageVsEntity; public int rightClickCost = 10000; @SideOnly(Side.CLIENT) @@ -47,8 +47,6 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable { public BoundPickaxe() { super(AlchemicalWizardry.bloodBoundToolMaterial); this.maxStackSize = 1; - this.efficiencyOnProperMaterial = 12.0F; - this.damageVsEntity = 5; setCreativeTab(AlchemicalWizardry.tabBloodMagic); this.setEnergyUsed(5); setHarvestLevel("pickaxe", 7); @@ -68,10 +66,10 @@ public int drainCost() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.boundpickaxe.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.boundpickaxe.desc2")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.boundpickaxe.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.boundpickaxe.desc2")); + addBindingInformation(stack, tooltip); } @Override @@ -92,64 +90,68 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (checkRightClick(par1ItemStack, par2World, par3EntityPlayer)) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (checkRightClick(item, world, player)) { + return item; } - Vec3 blockVec = SpellHelper.getEntityBlockVector(par3EntityPlayer); + Vec3 blockVec = SpellHelper.getEntityBlockVector(player); int posX = (int) (blockVec.xCoord); int posY = (int) (blockVec.yCoord); int posZ = (int) (blockVec.zCoord); - boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(par3EntityPlayer); - int fortuneLvl = EnchantmentHelper.getFortuneModifier(par3EntityPlayer); + boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(player); + int fortuneLvl = EnchantmentHelper.getFortuneModifier(player); HashMultiset dropMultiset = HashMultiset.create(); for (int i = -5; i <= 5; i++) { for (int j = -5; j <= 5; j++) { for (int k = -5; k <= 5; k++) { - Block block = par2World.getBlock(posX + i, posY + j, posZ + k); - int meta = par2World.getBlockMetadata(posX + i, posY + j, posZ + k); - - if (block != null && block.getBlockHardness(par2World, posX + i, posY + j, posZ + k) != -1) { - float str = func_150893_a(par1ItemStack, block); - - if (str > 1.1f && par2World.canMineBlock(par3EntityPlayer, posX + i, posY + j, posZ + k)) { - if (silkTouch && block - .canSilkHarvest(par2World, par3EntityPlayer, posX + i, posY + j, posZ + k, meta)) { - dropMultiset.add(new ItemType(block, meta)); - } else { - ArrayList itemDropList; - if (AlchemicalWizardry.isGregTechLoaded && block instanceof GTBlockOre) { - itemDropList = ((GTBlockOre) block).getDropsForPlayer( - par2World, - posX + i, - posY + j, - posZ + k, - meta, - fortuneLvl, - par3EntityPlayer); - } else { - itemDropList = block - .getDrops(par2World, posX + i, posY + j, posZ + k, meta, fortuneLvl); - } - - if (itemDropList != null) { - for (ItemStack stack : itemDropList) - dropMultiset.add(ItemType.fromStack(stack), stack.stackSize); - } - } - - par2World.setBlockToAir(posX + i, posY + j, posZ + k); + int x = posX + i; + int y = posY + j; + int z = posZ + k; + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + if (checkPermissions(world, x, y, z, block, meta, player)) continue; + + if (block == null || block.getBlockHardness(world, x, y, z) == -1 + || !world.canMineBlock(player, x, y, z)) { + continue; + } + + // getStrVsBlock + if (func_150893_a(item, block) <= 1f) { + continue; + } + if (silkTouch && block.canSilkHarvest(world, player, x, y, z, meta)) { + dropMultiset.add(new ItemType(block, meta)); + } else { + ArrayList itemDropList; + if (AlchemicalWizardry.isGregTechLoaded && block instanceof GTBlockOre ore) { + itemDropList = ore.getDropsForPlayer(world, x, y, z, meta, fortuneLvl, player); + } else { + itemDropList = block.getDrops(world, x, y, z, meta, fortuneLvl); + } + + if (itemDropList != null) { + for (ItemStack stack : itemDropList) + dropMultiset.add(ItemType.fromStack(stack), stack.stackSize); } } + + world.setBlockToAir(x, y, z); } } } - dropMultisetStacks(dropMultiset, par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ); + dropMultisetStacks(dropMultiset, world, posX, posY + player.getEyeHeight(), posZ); - return par1ItemStack; + return item; + } + + public static boolean checkPermissions(World world, int x, int y, int z, Block block, int meta, + EntityPlayer player) { + final BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(x, y, z, world, block, meta, player); + return MinecraftForge.EVENT_BUS.post(event); } public static void dropMultisetStacks(Multiset dropMultiset, World world, double x, double y, double z) { @@ -169,20 +171,13 @@ public static void dropMultisetStacks(Multiset dropMultiset, World wor } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer)) { + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if (!(entity instanceof EntityPlayer player)) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; - - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); - } - - checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer); - - par1ItemStack.setItemDamage(0); + checkPassiveDrain(item, world, player); + item.setItemDamage(0); } /** @@ -190,55 +185,35 @@ public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity * sword */ @Override - public float func_150893_a(ItemStack par1ItemStack, Block par2Block) // getStrVsBlock - { - if (!IBindable.isActive(par1ItemStack)) { - return 0.0F; - } - - return super.func_150893_a(par1ItemStack, par2Block); + public float func_150893_a(ItemStack item, Block block) { // getStrVsBlock + return !IBindable.isActive(item) ? 0.0F : super.func_150893_a(item, block); } - /** - * Current implementations of this method in child classes do not use the entry argument beside ev. They just raise - * the damage on the stack. - */ @Override - public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, - EntityLivingBase par3EntityLivingBase) { - return IBindable.isActive(par1ItemStack); + public boolean hitEntity(ItemStack item, EntityLivingBase target, EntityLivingBase attacker) { + return IBindable.isActive(item); } @Override - public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, Block par3, int par4, int par5, int par6, - EntityLivingBase par7EntityLivingBase) { - - if (par7EntityLivingBase instanceof EntityPlayer) { - EnergyItems.syphonBatteries(par1ItemStack, (EntityPlayer) par7EntityLivingBase, drainCost()); + public boolean onBlockDestroyed(ItemStack item, World world, Block block, int x, int y, int z, + EntityLivingBase user) { + if (user instanceof EntityPlayer player) { + EnergyItems.syphonBatteries(item, player, drainCost()); } return true; } + @Override @SideOnly(Side.CLIENT) - - /** - * Returns True is the item is renderer in full 3D when hold. - */ public boolean isFull3D() { return true; } - /** - * Return the enchantability factor of the item, most of the time is based on material. - */ @Override public int getItemEnchantability() { return 30; } - /** - * FORGE: Overridden to allow custom tool effectiveness - */ @Override public float getDigSpeed(ItemStack stack, Block block, int meta) { if (!IBindable.isActive(stack)) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundShovel.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundShovel.java index 591100266a..80a4f7b2a0 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundShovel.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundShovel.java @@ -8,8 +8,6 @@ import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemSpade; import net.minecraft.item.ItemStack; @@ -21,7 +19,6 @@ import net.minecraftforge.common.ForgeHooks; import com.google.common.collect.HashMultiset; -import com.google.common.collect.Multimap; import WayofTime.alchemicalWizardry.AlchemicalWizardry; import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable; @@ -33,7 +30,6 @@ public class BoundShovel extends ItemSpade implements IBindable { public float efficiencyOnProperMaterial = 12.0F; - public float damageVsEntity; public int rightClickCost = 10000; @SideOnly(Side.CLIENT) @@ -47,8 +43,6 @@ public class BoundShovel extends ItemSpade implements IBindable { public BoundShovel() { super(AlchemicalWizardry.bloodBoundToolMaterial); this.maxStackSize = 1; - this.efficiencyOnProperMaterial = 12.0F; - this.damageVsEntity = 5; setCreativeTab(AlchemicalWizardry.tabBloodMagic); setEnergyUsed(5); setHarvestLevel("shovel", 7); @@ -68,9 +62,9 @@ public int drainCost() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.boundshovel.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.boundshovel.desc")); + addBindingInformation(item, tooltip); } @Override @@ -91,70 +85,72 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (checkRightClick(par1ItemStack, par2World, par3EntityPlayer)) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (checkRightClick(item, world, player)) { + return item; } - Vec3 blockVec = SpellHelper.getEntityBlockVector(par3EntityPlayer); + Vec3 blockVec = SpellHelper.getEntityBlockVector(player); int posX = (int) (blockVec.xCoord); int posY = (int) (blockVec.yCoord); int posZ = (int) (blockVec.zCoord); - boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(par3EntityPlayer); - int fortuneLvl = EnchantmentHelper.getFortuneModifier(par3EntityPlayer); + boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(player); + int fortuneLvl = EnchantmentHelper.getFortuneModifier(player); HashMultiset dropMultiset = HashMultiset.create(); for (int i = -5; i <= 5; i++) { for (int j = 0; j <= 10; j++) { for (int k = -5; k <= 5; k++) { - Block block = par2World.getBlock(posX + i, posY + j, posZ + k); - int meta = par2World.getBlockMetadata(posX + i, posY + j, posZ + k); - - if (block != null) { - float str = func_150893_a(par1ItemStack, block); - - if (str > 1.1f && par2World.canMineBlock(par3EntityPlayer, posX + i, posY + j, posZ + k)) { - if (silkTouch && block - .canSilkHarvest(par2World, par3EntityPlayer, posX + i, posY + j, posZ + k, meta)) { - dropMultiset.add(new ItemType(block, meta)); - } else { - ArrayList itemDropList = block - .getDrops(par2World, posX + i, posY + j, posZ + k, meta, fortuneLvl); - - if (itemDropList != null) { - for (ItemStack stack : itemDropList) - dropMultiset.add(ItemType.fromStack(stack), stack.stackSize); - } - } - - par2World.setBlockToAir(posX + i, posY + j, posZ + k); + int x = posX + i; + int y = posY + j; + int z = posZ + k; + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + if (block == null || block.getBlockHardness(world, x, y, z) == -1 + || !world.canMineBlock(player, x, y, z)) { + continue; + } + + // getStrVsBlock + if (func_150893_a(item, block) <= 1f) { + continue; + } + if (silkTouch && block.canSilkHarvest(world, player, x, y, z, meta)) { + dropMultiset.add(new ItemType(block, meta)); + } else { + ArrayList itemDropList = block.getDrops(world, x, y, z, meta, fortuneLvl); + + if (itemDropList != null) { + for (ItemStack stack : itemDropList) + dropMultiset.add(ItemType.fromStack(stack), stack.stackSize); } } + + world.setBlockToAir(x, y, z); } } } - BoundPickaxe.dropMultisetStacks(dropMultiset, par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ); + BoundPickaxe.dropMultisetStacks(dropMultiset, world, posX, posY + player.getEyeHeight(), posZ); - return par1ItemStack; + return item; } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer)) { + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if (!(entity instanceof EntityPlayer player)) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; - - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); + if (item.getTagCompound() == null) { + item.setTagCompound(new NBTTagCompound()); } - checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer); + checkPassiveDrain(item, world, player); - par1ItemStack.setItemDamage(0); + item.setItemDamage(0); } /** @@ -162,56 +158,41 @@ public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity * sword */ @Override - public float func_150893_a(ItemStack par1ItemStack, Block par2Block) { - if (!IBindable.isActive(par1ItemStack)) { + public float func_150893_a(ItemStack item, Block block) { + if (!IBindable.isActive(item)) { return 0.0F; } - return super.func_150893_a(par1ItemStack, par2Block); + return super.func_150893_a(item, block); } /** * Current implementations of this method in child classes do not use the entry argument beside ev. They just raise * the damage on the stack. */ - public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, - EntityLivingBase par3EntityLivingBase) { - return IBindable.isActive(par1ItemStack); + @Override + public boolean hitEntity(ItemStack item, EntityLivingBase target, EntityLivingBase attacker) { + return IBindable.isActive(item); } - public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, - EntityLivingBase par7EntityLivingBase) { + @Override + public boolean onBlockDestroyed(ItemStack item, World world, Block block, int x, int y, int z, + EntityLivingBase user) { return true; } + @Override @SideOnly(Side.CLIENT) - /** - * Returns True is the item is renderer in full 3D when hold. - */ public boolean isFull3D() { return true; } - /** - * Return the enchantability factor of the item, most of the time is based on material. - */ + @Override public int getItemEnchantability() { return 30; } - @Override - public Multimap getItemAttributeModifiers() { - Multimap multimap = super.getItemAttributeModifiers(); - multimap.put( - SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), - new AttributeModifier(field_111210_e, "Tool modifier", (double) this.damageVsEntity, 0)); - return multimap; - } - - /** - * FORGE: Overridden to allow custom tool effectiveness - */ @Override public float getDigSpeed(ItemStack stack, Block block, int meta) { if (!IBindable.isActive(stack)) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/CheatyItem.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/CheatyItem.java index aa4be358f5..bfd78692d8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/CheatyItem.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/CheatyItem.java @@ -35,29 +35,27 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.mode.creative")); - par3List.add(StatCollector.translateToLocal("tooltip.cheatyitem.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.cheatyitem.desc2")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.mode.creative")); + tooltip.add(StatCollector.translateToLocal("tooltip.cheatyitem.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.cheatyitem.desc2")); + addBindingInformation(item, tooltip); } - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - World world = par3EntityPlayer.worldObj; - - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) - || par3EntityPlayer instanceof FakePlayer) { - return par1ItemStack; + @Override + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player instanceof FakePlayer) { + return item; } if (world != null) { - double posX = par3EntityPlayer.posX; - double posY = par3EntityPlayer.posY; - double posZ = par3EntityPlayer.posZ; + double posX = player.posX; + double posY = player.posY; + double posZ = player.posZ; world.playSoundEffect( - (double) ((float) posX + 0.5F), - (double) ((float) posY + 0.5F), - (double) ((float) posZ + 0.5F), + (float) posX + 0.5F, + (float) posY + 0.5F, + (float) posZ + 0.5F, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); @@ -74,75 +72,22 @@ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, Enti posZ); } - if (par3EntityPlayer.worldObj.isRemote) { - return par1ItemStack; + if (player.worldObj.isRemote) { + return item; } - NBTTagCompound itemTag = par1ItemStack.getTagCompound(); + NBTTagCompound itemTag = item.getTagCompound(); - if (itemTag == null || itemTag.getString("ownerName").equals("")) { - return par1ItemStack; + if (itemTag == null || itemTag.getString("ownerName").isEmpty()) { + return item; } - if (par3EntityPlayer.isSneaking()) { + if (player.isSneaking()) { SoulNetworkHandler.setCurrentEssence(itemTag.getString("ownerName"), 0); } else { SoulNetworkHandler.addCurrentEssenceToMaximum(itemTag.getString("ownerName"), 1000000, Integer.MAX_VALUE); } - return par1ItemStack; - } - - /* - * @return the damage that was not deducted - */ - public int damageItem(ItemStack par1ItemStack, int par2int) { - if (par2int == 0) { - return 0; - } - - int before = this.getDamage(par1ItemStack); - this.setDamage(par1ItemStack, this.getDamage(par1ItemStack) + par2int); - return par2int - (this.getDamage(par1ItemStack) - before); - } - - protected void damagePlayer(World world, EntityPlayer player, int damage) { - if (world != null) { - double posX = player.posX; - double posY = player.posY; - double posZ = player.posZ; - world.playSoundEffect( - (double) ((float) posX + 0.5F), - (double) ((float) posY + 0.5F), - (double) ((float) posZ + 0.5F), - "random.fizz", - 0.5F, - 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); - float f = 1.0F; - float f1 = f * 0.6F + 0.4F; - float f2 = f * f * 0.7F - 0.5F; - float f3 = f * f * 0.6F - 0.7F; - - for (int l = 0; l < 8; ++l) { - world.spawnParticle( - "reddust", - posX + Math.random() - Math.random(), - posY + Math.random() - Math.random(), - posZ + Math.random() - Math.random(), - f1, - f2, - f3); - } - } - - if (!player.capabilities.isCreativeMode) { - for (int i = 0; i < damage; i++) { - player.setHealth((player.getHealth() - 1)); - } - } - - if (player.getHealth() <= 0) { - player.inventory.dropAllItems(); - } + return item; } @Override @@ -155,14 +100,14 @@ public boolean hasContainerItem(ItemStack itemStack) { return true; } - public int getCurrentEssence(ItemStack par1ItemStack) { - if (par1ItemStack == null) { + public int getCurrentEssence(ItemStack item) { + if (item == null) { return 0; } - NBTTagCompound itemTag = par1ItemStack.getTagCompound(); + NBTTagCompound itemTag = item.getTagCompound(); - if (itemTag == null || itemTag.getString("ownerName").equals("")) { + if (itemTag == null || itemTag.getString("ownerName").isEmpty()) { return 0; } @@ -175,8 +120,7 @@ public int getCurrentEssence(ItemStack par1ItemStack) { worldSave.setItemData(owner, data); } - int currentEssence = data.currentEssence; - return (currentEssence); + return (data.currentEssence); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/CreativeDagger.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/CreativeDagger.java index 7d5a50b835..7a57573180 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/CreativeDagger.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/CreativeDagger.java @@ -26,6 +26,7 @@ public CreativeDagger() { setFull3D(); } + @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { if (this.canUseForSacrifice(stack)) { player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); @@ -55,9 +56,9 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla double posY = player.posY; double posZ = player.posZ; world.playSoundEffect( - (double) ((float) posX + 0.5F), - (double) ((float) posY + 0.5F), - (double) ((float) posZ + 0.5F), + (float) posX + 0.5F, + (float) posY + 0.5F, + (float) posZ + 0.5F, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/DaggerOfSacrifice.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/DaggerOfSacrifice.java index f574432a3b..5839a6db95 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/DaggerOfSacrifice.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/DaggerOfSacrifice.java @@ -9,8 +9,10 @@ import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.boss.IBossDisplayData; +import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.DamageSource; @@ -27,15 +29,13 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class DaggerOfSacrifice extends EnergyItems { +public class DaggerOfSacrifice extends Item { public DaggerOfSacrifice() { super(); this.maxStackSize = 1; setCreativeTab(AlchemicalWizardry.tabBloodMagic); - setEnergyUsed(100); setFull3D(); - setMaxDamage(100); } @Override @@ -45,43 +45,39 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, - EntityLivingBase par3EntityLivingBase) { - if (par3EntityLivingBase == null || par2EntityLivingBase == null - || par3EntityLivingBase.worldObj.isRemote - || (par3EntityLivingBase instanceof EntityPlayer && SpellHelper - .isFakePlayer(par3EntityLivingBase.worldObj, (EntityPlayer) par3EntityLivingBase))) { + public boolean hitEntity(ItemStack item, EntityLivingBase target, EntityLivingBase attacker) { + if (attacker == null || target == null + || attacker.worldObj.isRemote + || (attacker instanceof EntityPlayer + && SpellHelper.isFakePlayer(attacker.worldObj, (EntityPlayer) attacker))) { return false; } - if (par2EntityLivingBase instanceof IHoardDemon) { + if ((!(target instanceof EntityMob) && target.isChild()) || target instanceof EntityPlayer + || target instanceof IBossDisplayData + || target instanceof IHoardDemon) { return false; } - if (par2EntityLivingBase.isChild() || par2EntityLivingBase instanceof EntityPlayer - || par2EntityLivingBase instanceof IBossDisplayData) { - return false; - } - - World world = par2EntityLivingBase.worldObj; + World world = target.worldObj; - if (par2EntityLivingBase.isDead || par2EntityLivingBase.getHealth() < 0.5f) { + if (target.isDead || target.getHealth() < 0.5f) { return false; } - if (par2EntityLivingBase instanceof IDemon) { - ((IDemon) par2EntityLivingBase).setDropCrystal(false); - this.findAndNotifyAltarOfDemon(world, par2EntityLivingBase); + if (target instanceof IDemon demon) { + demon.setDropCrystal(false); + this.findAndNotifyAltarOfDemon(world, target); } - int lifeEssence = AlchemicalWizardry.lpPerSactificeCustom.containsKey(par2EntityLivingBase.getClass()) - ? AlchemicalWizardry.lpPerSactificeCustom.get(par2EntityLivingBase.getClass()) + int lifeEssence = AlchemicalWizardry.lpPerSactificeCustom.containsKey(target.getClass()) + ? AlchemicalWizardry.lpPerSactificeCustom.get(target.getClass()) : AlchemicalWizardry.lpPerSacrificeBase; - if (findAndFillAltar(par2EntityLivingBase.worldObj, par2EntityLivingBase, lifeEssence)) { - double posX = par2EntityLivingBase.posX; - double posY = par2EntityLivingBase.posY; - double posZ = par2EntityLivingBase.posZ; + if (findAndFillAltar(target.worldObj, target, lifeEssence)) { + double posX = target.posX; + double posY = target.posY; + double posZ = target.posZ; for (int i = 0; i < 8; i++) { SpellHelper.sendIndexedParticleToAllAround( @@ -97,29 +93,25 @@ public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLiv posZ); } - par2EntityLivingBase.setHealth(-1); - par2EntityLivingBase.onDeath(DamageSource.generic); + target.setHealth(-1); + target.onDeath(DamageSource.generic); } return false; } - public float func_82803_g() { - return 4.0F; - } - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.caution.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.caution.desc2")); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.caution.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.caution.desc2")); } @Override - public float func_150893_a(ItemStack par1ItemStack, Block par2Block) { - if (par2Block == Blocks.web) { + public float func_150893_a(ItemStack item, Block block) { + if (block == Blocks.web) { return 15.0F; } else { - Material material = par2Block.getMaterial(); + Material material = block.getMaterial(); return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves @@ -128,13 +120,8 @@ public float func_150893_a(ItemStack par1ItemStack, Block par2Block) { } @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return false; - } - - @Override - public Multimap getItemAttributeModifiers() { - Multimap multimap = super.getItemAttributeModifiers(); + public Multimap getItemAttributeModifiers() { + Multimap multimap = super.getItemAttributeModifiers(); multimap.put( SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Tool modifier", 1.0d, 0)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/DemonPlacer.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/DemonPlacer.java index ccc5da9822..074184d5a9 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/DemonPlacer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/DemonPlacer.java @@ -36,106 +36,99 @@ public DemonPlacer() { this.maxStackSize = 1; } + @Override @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - EntityEggInfo entityegginfo = (EntityEggInfo) EntityList.entityEggs - .get(Integer.valueOf(par1ItemStack.getItemDamage())); + public int getColorFromItemStack(ItemStack item, int par2) { + EntityEggInfo entityegginfo = EntityList.entityEggs.get(item.getItemDamage()); return entityegginfo != null ? (par2 == 0 ? entityegginfo.primaryColor : entityegginfo.secondaryColor) - : 16777215; + : 0xffffff; } /** * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return * True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, - int par5, int par6, int par7, float par8, float par9, float par10) { - if (par3World.isRemote) { + @Override + public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int par4, int par5, int par6, int par7, + float par8, float par9, float par10) { + if (world.isRemote) { return true; - } else { - Block i1 = par3World.getBlock(par4, par5, par6); - par4 += Facing.offsetsXForSide[par7]; - par5 += Facing.offsetsYForSide[par7]; - par6 += Facing.offsetsZForSide[par7]; - double d0 = 0.0D; - - if (par7 == 1 && i1 != null && i1.getRenderType() == 11) { - d0 = 0.5D; - } - - String demonName = DemonPlacer.getDemonString(par1ItemStack); - Entity entity = spawnCreature( - par3World, - demonName, - (double) par4 + 0.5D, - (double) par5 + d0, - (double) par6 + 0.5D, - par1ItemStack); - - if (entity != null) { - if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName()) { - ((EntityLiving) entity).setCustomNameTag(par1ItemStack.getDisplayName()); - } + } + Block i1 = world.getBlock(par4, par5, par6); + par4 += Facing.offsetsXForSide[par7]; + par5 += Facing.offsetsYForSide[par7]; + par6 += Facing.offsetsZForSide[par7]; + double d0 = 0.0D; + + if (par7 == 1 && i1 != null && i1.getRenderType() == 11) { + d0 = 0.5D; + } - if (!par2EntityPlayer.capabilities.isCreativeMode) { - --par1ItemStack.stackSize; - } + String demonName = DemonPlacer.getDemonString(item); + Entity entity = spawnCreature( + world, + demonName, + (double) par4 + 0.5D, + (double) par5 + d0, + (double) par6 + 0.5D, + item); + + if (entity != null) { + if (entity instanceof EntityLivingBase && item.hasDisplayName()) { + ((EntityLiving) entity).setCustomNameTag(item.getDisplayName()); } - return true; + if (!player.capabilities.isCreativeMode) { + --item.stackSize; + } } + + return true; } /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (par2World.isRemote) { - return par1ItemStack; + @Override + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (world.isRemote) { + return item; + } + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true); + + if (movingobjectposition == null) { + return item; } else { - MovingObjectPosition movingobjectposition = this - .getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); - - if (movingobjectposition == null) { - return par1ItemStack; - } else { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - int i = movingobjectposition.blockX; - int j = movingobjectposition.blockY; - int k = movingobjectposition.blockZ; - - if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) { - return par1ItemStack; - } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; - if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) { - return par1ItemStack; - } + if (!world.canMineBlock(player, i, j, k)) { + return item; + } + + if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, item)) { + return item; + } + + if (world.getBlock(i, j, k).getMaterial() == Material.water) { + String demonName = DemonPlacer.getDemonString(item); + Entity entity = spawnCreature(world, demonName, i, j, k, item); + + if (entity != null) { + if (entity instanceof EntityLivingBase && item.hasDisplayName()) { + ((EntityLiving) entity).setCustomNameTag(item.getDisplayName()); + } - if (par2World.getBlock(i, j, k).getMaterial() == Material.water) { - String demonName = DemonPlacer.getDemonString(par1ItemStack); - Entity entity = spawnCreature( - par2World, - demonName, - (double) i, - (double) j, - (double) k, - par1ItemStack); - - if (entity != null) { - if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName()) { - ((EntityLiving) entity).setCustomNameTag(par1ItemStack.getDisplayName()); - } - - if (!par3EntityPlayer.capabilities.isCreativeMode) { - --par1ItemStack.stackSize; - } + if (!player.capabilities.isCreativeMode) { + --item.stackSize; } } } - - return par1ItemStack; } + + return item; } } @@ -143,20 +136,20 @@ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, Enti * Spawns the creature specified by the egg's type in the location specified by the last three parameters. * Parameters: world, entityID, x, y, z. */ - public static Entity spawnCreature(World par0World, String par1, double par2, double par4, double par6, + public static Entity spawnCreature(World world, String par1, double par2, double par4, double par6, ItemStack itemStack) { Entity entity = null; for (int j = 0; j < 1; ++j) { - entity = SummoningRegistry.getEntityWithID(par0World, par1); + entity = SummoningRegistry.getEntityWithID(world, par1); - if (entity != null && entity instanceof EntityLivingBase) { + if (entity instanceof EntityLivingBase) { EntityLiving entityliving = (EntityLiving) entity; entity.setLocationAndAngles( par2, par4, par6, - MathHelper.wrapAngleTo180_float(par0World.rand.nextFloat() * 360.0F), + MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F); entityliving.rotationYawHead = entityliving.rotationYaw; entityliving.renderYawOffset = entityliving.rotationYaw; @@ -165,33 +158,33 @@ public static Entity spawnCreature(World par0World, String par1, double par2, do if (owner != null) { ((EntityDemon) entityliving).func_152115_b(owner.getPersistentID().toString()); - if (!DemonPlacer.getOwnerName(itemStack).equals("")) { + if (!DemonPlacer.getOwnerName(itemStack).isEmpty()) { ((EntityDemon) entityliving).setTamed(true); } } } - par0World.spawnEntityInWorld(entity); + world.spawnEntityInWorld(entity); entityliving.playLivingSound(); } } return entity; } - public static void setOwnerName(ItemStack par1ItemStack, String ownerName) { - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); + public static void setOwnerName(ItemStack item, String ownerName) { + if (item.getTagCompound() == null) { + item.setTagCompound(new NBTTagCompound()); } - par1ItemStack.getTagCompound().setString("ownerName", ownerName); + item.getTagCompound().setString("ownerName", ownerName); } - public static String getOwnerName(ItemStack par1ItemStack) { - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); + public static String getOwnerName(ItemStack item) { + if (item.getTagCompound() == null) { + item.setTagCompound(new NBTTagCompound()); } - return par1ItemStack.getTagCompound().getString("ownerName"); + return item.getTagCompound().getString("ownerName"); } public static void setDemonString(ItemStack itemStack, String demonName) { @@ -211,14 +204,14 @@ public static String getDemonString(ItemStack itemStack) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.demonplacer.desc")); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.demonplacer.desc")); - if (!(par1ItemStack.getTagCompound() == null)) { - if (!par1ItemStack.getTagCompound().getString("ownerName").equals("")) { - par3List.add( + if (!(item.getTagCompound() == null)) { + if (!item.getTagCompound().getString("ownerName").isEmpty()) { + tooltip.add( StatCollector.translateToLocal("tooltip.owner.demonsowner") + " " - + par1ItemStack.getTagCompound().getString("ownerName")); + + item.getTagCompound().getString("ownerName")); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/DemonicTelepositionFocus.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/DemonicTelepositionFocus.java index 94488d8036..f90527a93b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/DemonicTelepositionFocus.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/DemonicTelepositionFocus.java @@ -25,19 +25,19 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.demonictelepfocus.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.demonictelepfocus.desc2")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.demonictelepfocus.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.demonictelepfocus.desc2")); + addBindingInformation(item, tooltip); - NBTTagCompound itemTag = IBindable.getTag(par1ItemStack); - par3List.add( + NBTTagCompound itemTag = IBindable.getTag(item); + tooltip.add( StatCollector.translateToLocal("tooltip.alchemy.coords") + " " + itemTag.getInteger("xCoord") + ", " + itemTag.getInteger("yCoord") + ", " + itemTag.getInteger("zCoord")); - par3List.add(StatCollector.translateToLocal("tooltip.alchemy.dimension") + " " + getDimensionID(par1ItemStack)); + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.dimension") + " " + getDimensionID(item)); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyBattery.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyBattery.java index dcffcf0b15..5adaa903d6 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyBattery.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyBattery.java @@ -23,7 +23,7 @@ public class EnergyBattery extends Item implements ArmourUpgrade, IBindable, IBloodOrb { - private int maxEssence; + private final int maxEssence; protected int orbLevel; public EnergyBattery(int damage) { @@ -41,27 +41,26 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.energybattery.desc")); - par3List.add(StatCollector.translateToLocalFormatted("tooltip.energybattery.capacity", this.getMaxEssence())); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.energybattery.desc")); + tooltip.add(StatCollector.translateToLocalFormatted("tooltip.energybattery.capacity", this.getMaxEssence())); + addBindingInformation(item, tooltip); } - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer)) { - return par1ItemStack; + @Override + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player)) { + return item; } - World world = par3EntityPlayer.worldObj; - if (world != null) { - double posX = par3EntityPlayer.posX; - double posY = par3EntityPlayer.posY; - double posZ = par3EntityPlayer.posZ; + double posX = player.posX; + double posY = player.posY; + double posZ = player.posZ; world.playSoundEffect( - (double) ((float) posX + 0.5F), - (double) ((float) posY + 0.5F), - (double) ((float) posZ + 0.5F), + (float) posX + 0.5F, + (float) posY + 0.5F, + (float) posZ + 0.5F, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); @@ -77,40 +76,40 @@ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, Enti posY, posZ); } - NBTTagCompound itemTag = par1ItemStack.getTagCompound(); + NBTTagCompound itemTag = item.getTagCompound(); - if (SpellHelper.isFakePlayer(par2World, par3EntityPlayer)) { - return par1ItemStack; + if (SpellHelper.isFakePlayer(world, player)) { + return item; } - if (itemTag == null || itemTag.getString("ownerName").equals("")) { - return par1ItemStack; + if (itemTag == null || itemTag.getString("ownerName").isEmpty()) { + return item; } if (world.isRemote) { - return par1ItemStack; + return item; } - if (itemTag.getString("ownerName").equals(SpellHelper.getUsername(par3EntityPlayer))) { + if (itemTag.getString("ownerName").equals(SpellHelper.getUsername(player))) { SoulNetworkHandler.setMaxOrbToMax(itemTag.getString("ownerName"), this.orbLevel); } SoulNetworkHandler.addCurrentEssenceToMaximum(itemTag.getString("ownerName"), 200, this.getMaxEssence()); - EnergyItems.hurtPlayer(par3EntityPlayer, 200); - return par1ItemStack; + EnergyItems.hurtPlayer(player, 200); + return item; } /* * @return the damage that was not deducted */ - public int damageItem(ItemStack par1ItemStack, int par2int) { + public int damageItem(ItemStack item, int par2int) { if (par2int == 0) { return 0; } - int before = this.getDamage(par1ItemStack); - this.setDamage(par1ItemStack, this.getDamage(par1ItemStack) + par2int); - return par2int - (this.getDamage(par1ItemStack) - before); + int before = this.getDamage(item); + this.setDamage(item, this.getDamage(item) + par2int); + return par2int - (this.getDamage(item) - before); } protected void damagePlayer(World world, EntityPlayer player, int damage) { @@ -119,9 +118,9 @@ protected void damagePlayer(World world, EntityPlayer player, int damage) { double posY = player.posY; double posZ = player.posZ; world.playSoundEffect( - (double) ((float) posX + 0.5F), - (double) ((float) posY + 0.5F), - (double) ((float) posZ + 0.5F), + (float) posX + 0.5F, + (float) posY + 0.5F, + (float) posZ + 0.5F, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); @@ -153,10 +152,12 @@ protected void damagePlayer(World world, EntityPlayer player, int damage) { } } + @Override public int getMaxEssence() { return this.maxEssence; } + @Override public int getOrbLevel() { return orbLevel; } @@ -186,14 +187,14 @@ public boolean hasContainerItem(ItemStack itemStack) { // @SideOnly(Side.SERVER) @Deprecated - public int getCurrentEssence(ItemStack par1ItemStack) { - if (par1ItemStack == null) { + public int getCurrentEssence(ItemStack item) { + if (item == null) { return 0; } - NBTTagCompound itemTag = par1ItemStack.getTagCompound(); + NBTTagCompound itemTag = item.getTagCompound(); - if (itemTag == null || itemTag.getString("ownerName").equals("")) { + if (itemTag == null || itemTag.getString("ownerName").isEmpty()) { return 0; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyBazooka.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyBazooka.java index c1e70d4b6d..4e1d7401fd 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyBazooka.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyBazooka.java @@ -19,18 +19,18 @@ public class EnergyBazooka extends EnergyBlast { public EnergyBazooka(int tier) { super(tier); switch (this.tier) { - case 1: + case 1 -> { this.setEnergyUsed(AlchemicalWizardry.energyBazookaLPPerShot); this.damage = AlchemicalWizardry.energyBazookaDamage; - break; - case 2: + } + case 2 -> { this.setEnergyUsed(AlchemicalWizardry.energyBazookaSecondTierLPPerShot); this.damage = AlchemicalWizardry.energyBazookaSecondTierDamage; - break; - case 3: + } + case 3 -> { this.setEnergyUsed(AlchemicalWizardry.energyBazookaThirdTierLPPerShot); this.damage = AlchemicalWizardry.energyBazookaThirdTierDamage; - break; + } } } @@ -45,69 +45,59 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void shoot(World par2World, EntityPlayer par3EntityPlayer) { - par2World.spawnEntityInWorld(new EntityEnergyBazookaMainProjectile(par2World, par3EntityPlayer, this.damage)); + public void shoot(World world, EntityPlayer player) { + world.spawnEntityInWorld(new EntityEnergyBazookaMainProjectile(world, player, this.damage)); - Vec3 vec = par3EntityPlayer.getLookVec(); + Vec3 vec = player.getLookVec(); double wantedVelocity = this.tier * 2.0D; - par3EntityPlayer.motionX = -vec.xCoord * wantedVelocity; - par3EntityPlayer.motionY = -vec.yCoord * wantedVelocity; - par3EntityPlayer.motionZ = -vec.zCoord * wantedVelocity; - par2World.playSoundEffect( - par3EntityPlayer.posX + 0.5F, - par3EntityPlayer.posY + 0.5F, - par3EntityPlayer.posZ + 0.5F, + player.motionX = -vec.xCoord * wantedVelocity; + player.motionY = -vec.yCoord * wantedVelocity; + player.motionZ = -vec.zCoord * wantedVelocity; + world.playSoundEffect( + player.posX + 0.5F, + player.posY + 0.5F, + player.posZ + 0.5F, "random.fizz", 0.5F, - 2.6F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.8F); - par3EntityPlayer.fallDistance = 0; + 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + player.fallDistance = 0; } @Override public int getShotDelay() { - switch (this.tier) { - case 1: - return AlchemicalWizardry.energyBazookaMaxDelay; - case 2: - return AlchemicalWizardry.energyBazookaSecondTierMaxDelay; - case 3: - return AlchemicalWizardry.energyBazookaThirdTierMaxDelay; - } - return 1; + return switch (this.tier) { + case 1 -> AlchemicalWizardry.energyBazookaMaxDelay; + case 2 -> AlchemicalWizardry.energyBazookaSecondTierMaxDelay; + case 3 -> AlchemicalWizardry.energyBazookaThirdTierMaxDelay; + default -> 1; + }; } @Override public int drainTicks() { - switch (this.tier) { - case 1: - return AlchemicalWizardry.energyBazookaMaxDelayAfterActivation; - case 2: - return AlchemicalWizardry.energyBazookaSecondTierMaxDelayAfterActivation; - case 3: - return AlchemicalWizardry.energyBazookaThirdTierMaxDelayAfterActivation; - } - return 1; + return switch (this.tier) { + case 1 -> AlchemicalWizardry.energyBazookaMaxDelayAfterActivation; + case 2 -> AlchemicalWizardry.energyBazookaSecondTierMaxDelayAfterActivation; + case 3 -> AlchemicalWizardry.energyBazookaThirdTierMaxDelayAfterActivation; + default -> 1; + }; } @Override public int drainCost() { - switch (this.tier) { - case 1: - return AlchemicalWizardry.energyBazookaLPPerActivation; - case 2: - return AlchemicalWizardry.energyBazookaSecondTierLPPerActivation; - case 3: - return AlchemicalWizardry.energyBazookaThirdTierLPPerActivation; - } - return 0; + return switch (this.tier) { + case 1 -> AlchemicalWizardry.energyBazookaLPPerActivation; + case 2 -> AlchemicalWizardry.energyBazookaSecondTierLPPerActivation; + case 3 -> AlchemicalWizardry.energyBazookaThirdTierLPPerActivation; + default -> 0; + }; } @Override @SideOnly(Side.CLIENT) - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.energybazooka.desc")); - par3List.add(StatCollector.translateToLocal("tooltip.alchemy.damage") + " " + this.damage); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.energybazooka.desc")); + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.damage") + " " + this.damage); + addBindingInformation(item, tooltip); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyBlast.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyBlast.java index f33b31f8c4..95734c6456 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyBlast.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyBlast.java @@ -82,61 +82,57 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (getDelay(par1ItemStack) > 0 && IBindable.isActive(par1ItemStack) && !par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (getDelay(item) > 0 && IBindable.isActive(item) && !player.isSneaking()) { + return item; } - if (checkRightClick(par1ItemStack, par2World, par3EntityPlayer)) { - setDelay(par1ItemStack, drainTicks()); - return par1ItemStack; + if (checkRightClick(item, world, player)) { + setDelay(item, drainTicks()); + return item; } - par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - if (!par2World.isRemote) { - shoot(par2World, par3EntityPlayer); - this.setDelay(par1ItemStack, getShotDelay()); + if (!world.isRemote) { + shoot(world, player); + this.setDelay(item, getShotDelay()); } - return par1ItemStack; + return item; } - public void shoot(World par2World, EntityPlayer par3EntityPlayer) { - par2World.spawnEntityInWorld(new EnergyBlastProjectile(par2World, par3EntityPlayer, this.damage)); + public void shoot(World world, EntityPlayer player) { + world.spawnEntityInWorld(new EnergyBlastProjectile(world, player, this.damage)); } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer)) { + public void onUpdate(ItemStack item, World world, Entity entity, int par4, boolean par5) { + if (!(entity instanceof EntityPlayer player)) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; - int delay = this.getDelay(par1ItemStack); + int delay = this.getDelay(item); - if (!par2World.isRemote && delay > 0) { - this.setDelay(par1ItemStack, delay - 1); + if (!world.isRemote && delay > 0) { + this.setDelay(item, delay - 1); } - checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer); + checkPassiveDrain(item, world, player); - par1ItemStack.setItemDamage(0); + item.setItemDamage(0); } /** * The delay between firing multiple shots. */ public int getShotDelay() { - switch (this.tier) { - case 1: - return AlchemicalWizardry.energyBlastMaxDelay; - case 2: - return AlchemicalWizardry.energyBlastSecondTierMaxDelay; - case 3: - return AlchemicalWizardry.energyBlastThirdTierMaxDelay; - } - return 1; + return switch (this.tier) { + case 1 -> AlchemicalWizardry.energyBlastMaxDelay; + case 2 -> AlchemicalWizardry.energyBlastSecondTierMaxDelay; + case 3 -> AlchemicalWizardry.energyBlastThirdTierMaxDelay; + default -> 1; + }; } /** @@ -144,28 +140,22 @@ public int getShotDelay() { */ @Override public int drainTicks() { - switch (this.tier) { - case 1: - return AlchemicalWizardry.energyBlastMaxDelayAfterActivation; - case 2: - return AlchemicalWizardry.energyBlastSecondTierMaxDelayAfterActivation; - case 3: - return AlchemicalWizardry.energyBlastThirdTierMaxDelayAfterActivation; - } - return 1; + return switch (this.tier) { + case 1 -> AlchemicalWizardry.energyBlastMaxDelayAfterActivation; + case 2 -> AlchemicalWizardry.energyBlastSecondTierMaxDelayAfterActivation; + case 3 -> AlchemicalWizardry.energyBlastThirdTierMaxDelayAfterActivation; + default -> 1; + }; } @Override public int drainCost() { - switch (this.tier) { - case 1: - return AlchemicalWizardry.energyBlastLPPerActivation; - case 2: - return AlchemicalWizardry.energyBlastSecondTierLPPerActivation; - case 3: - return AlchemicalWizardry.energyBlastThirdTierLPPerActivation; - } - return 0; + return switch (this.tier) { + case 1 -> AlchemicalWizardry.energyBlastLPPerActivation; + case 2 -> AlchemicalWizardry.energyBlastSecondTierLPPerActivation; + case 3 -> AlchemicalWizardry.energyBlastThirdTierLPPerActivation; + default -> 0; + }; } @Override @@ -175,19 +165,18 @@ public int rightClickCost() { @Override @SideOnly(Side.CLIENT) - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.energyblast.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.energyblast.desc2")); - par3List.add(StatCollector.translateToLocal("tooltip.alchemy.damage") + " " + this.damage); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.energyblast.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.energyblast.desc2")); + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.damage") + " " + this.damage); + addBindingInformation(item, tooltip); } - public void setDelay(ItemStack par1ItemStack, int delay) { - IBindable.getTag(par1ItemStack).setInteger("delay", delay); + public void setDelay(ItemStack item, int delay) { + IBindable.getTag(item).setInteger("delay", delay); } - public int getDelay(ItemStack par1ItemStack) { - return IBindable.getTag(par1ItemStack).getInteger("delay"); + public int getDelay(ItemStack item) { + return IBindable.getTag(item).getInteger("delay"); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyItems.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyItems.java index a58f08f786..793b2ab2c9 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyItems.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergyItems.java @@ -41,9 +41,9 @@ protected void damagePlayer(World world, EntityPlayer player, int damage) { double posY = player.posY; double posZ = player.posZ; world.playSoundEffect( - (double) ((float) posX + 0.5F), - (double) ((float) posY + 0.5F), - (double) ((float) posZ + 0.5F), + (float) posX + 0.5F, + (float) posY + 0.5F, + (float) posZ + 0.5F, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); @@ -75,39 +75,36 @@ protected void damagePlayer(World world, EntityPlayer player, int damage) { public static boolean syphonBatteries(ItemStack ist, EntityPlayer player, int damageToBeDone) { if (!player.worldObj.isRemote) { return SoulNetworkHandler.syphonAndDamageFromNetwork(ist, player, damageToBeDone); - } else { - World world = player.worldObj; - if (world != null) { - double posX = player.posX; - double posY = player.posY; - double posZ = player.posZ; - - SpellHelper.sendIndexedParticleToAllAround( - world, - posX, - posY, - posZ, - 20, - world.provider.dimensionId, - 4, - posX, - posY, - posZ); - world.playSoundEffect( - ((float) player.posX + 0.5F), - ((float) player.posY + 0.5F), - ((float) player.posZ + 0.5F), - "random.fizz", - 0.5F, - 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); - } } + World world = player.worldObj; + double posX = player.posX; + double posY = player.posY; + double posZ = player.posZ; + + SpellHelper.sendIndexedParticleToAllAround( + world, + posX, + posY, + posZ, + 20, + world.provider.dimensionId, + 4, + posX, + posY, + posZ); + world.playSoundEffect( + ((float) player.posX + 0.5F), + ((float) player.posY + 0.5F), + ((float) player.posZ + 0.5F), + "random.fizz", + 0.5F, + 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); return true; } @Deprecated public static boolean syphonWhileInContainer(ItemStack ist, int damageToBeDone) { - if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals(""))) { + if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").isEmpty())) { String ownerName = ist.getTagCompound().getString("ownerName"); if (MinecraftServer.getServer() == null) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergySword.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergySword.java index 33370f7f10..ca7cc9ef1c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergySword.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/EnergySword.java @@ -2,16 +2,12 @@ import java.util.List; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.IIcon; @@ -84,36 +80,32 @@ public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity en if (isActive && !player.worldObj.isRemote) { OmegaParadigm parad = this.getOmegaParadigmOfWeilder(player); - if (parad != null && parad.isPlayerWearingFullSet(player)) { - if (!parad.onBoundSwordLeftClickEntity(stack, player, entity)) { - return true; - } + if (parad != null && parad.isPlayerWearingFullSet(player) + && !parad.onBoundSwordLeftClickEntity(stack, player, entity)) { + return true; } } return !isActive; } @Override - public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, - EntityLivingBase par3EntityLivingBase) { - if (par3EntityLivingBase instanceof EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, (EntityPlayer) par3EntityLivingBase) || !EnergyItems - .syphonBatteries(par1ItemStack, (EntityPlayer) par3EntityLivingBase, this.drainCost())) { - return false; - } + public boolean hitEntity(ItemStack item, EntityLivingBase target, EntityLivingBase attacker) { + if (attacker instanceof EntityPlayer player && (!IBindable.checkAndSetItemOwner(item, player) + || !EnergyItems.syphonBatteries(item, player, this.drainCost()))) { + return false; } - par2EntityLivingBase.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 2)); + target.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 2)); return true; } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer); + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + super.onItemRightClick(item, world, player); - this.toggle(par1ItemStack, par2World, par3EntityPlayer); + this.toggle(item, world, player); - return par1ItemStack; + return item; } @Override @@ -122,43 +114,19 @@ public int getItemEnchantability() { } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer)) { + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if (!(entity instanceof EntityPlayer player)) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; - - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); - } - - checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer); - - par1ItemStack.setItemDamage(0); - } - - public float func_82803_g() { - return 4.0F; - } - - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.caution.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.caution.desc2")); - addBindingInformation(par1ItemStack, par3List); + checkPassiveDrain(item, world, player); + item.setItemDamage(0); } @Override - public float func_150893_a(ItemStack par1ItemStack, Block par2Block) { - if (par2Block == Blocks.web) { - return 15.0F; - } else { - Material material = par2Block.getMaterial(); - return material != Material.plants && material != Material.vine - && material != Material.coral - && material != Material.leaves - && material != Material.gourd ? 1.0F : 1.5F; - } + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.caution.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.caution.desc2")); + addBindingInformation(item, tooltip); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/EnhancedTelepositionFocus.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/EnhancedTelepositionFocus.java index 2a9bbd4ae4..71cf43683d 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/EnhancedTelepositionFocus.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/EnhancedTelepositionFocus.java @@ -25,18 +25,18 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.enhancedtelepfocus.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.enhancedtelepfocus.desc")); + addBindingInformation(item, tooltip); - NBTTagCompound itemTag = IBindable.getTag(par1ItemStack); - par3List.add( + NBTTagCompound itemTag = IBindable.getTag(item); + tooltip.add( StatCollector.translateToLocal("tooltip.alchemy.coords") + " " + itemTag.getInteger("xCoord") + ", " + itemTag.getInteger("yCoord") + ", " + itemTag.getInteger("zCoord")); - par3List.add(StatCollector.translateToLocal("tooltip.alchemy.dimension") + " " + getDimensionID(par1ItemStack)); + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.dimension") + " " + getDimensionID(item)); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemAlchemyBase.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemAlchemyBase.java index 39be93e5d1..348cb45208 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemAlchemyBase.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemAlchemyBase.java @@ -41,9 +41,8 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, - boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.alchemy.usedinalchemy")); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.usedinalchemy")); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemBlockCrystalBelljar.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemBlockCrystalBelljar.java index fba2315852..b7100779fa 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemBlockCrystalBelljar.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemBlockCrystalBelljar.java @@ -9,7 +9,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.StatCollector; -import net.minecraft.world.World; import net.minecraftforge.common.util.Constants; import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer; @@ -24,6 +23,7 @@ public ItemBlockCrystalBelljar(Block par1) { this.setMaxStackSize(16); } + @Override public int getMetadata(int par1) { return par1; } @@ -48,42 +48,27 @@ public ReagentContainer[] getReagentContainers(ItemStack stack) { } @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean adv) { ReagentContainer[] tanks = this.getReagentContainers(stack); if (tanks == null) { - list.add(StatCollector.translateToLocal("tooltip.crystalbelljar.empty")); + tooltip.add(StatCollector.translateToLocal("tooltip.crystalbelljar.empty")); } else { - list.add(StatCollector.translateToLocal("tooltip.crystalbelljar.contents")); - for (int i = 0; i < tanks.length; i++) { - if (tanks[i] == null || tanks[i].getReagent() == null || tanks[i].getReagent().reagent == null) { - list.add("- Empty"); + tooltip.add(StatCollector.translateToLocal("tooltip.crystalbelljar.contents")); + for (ReagentContainer tank : tanks) { + if (tank == null || tank.getReagent() == null || tank.getReagent().reagent == null) { + tooltip.add("- Empty"); } else { - ReagentStack reagentStack = tanks[i].getReagent(); - list.add( - "- " + reagentStack.reagent.name + ReagentStack reagentStack = tank.getReagent(); + tooltip.add( + "- " + reagentStack.reagent.name() + ": " + reagentStack.amount + "/" - + tanks[i].getCapacity() / 1000 + + tank.getCapacity() / 1000 + "k AR"); } } } } - - @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, - float hitX, float hitY, float hitZ, int metadata) { - if (!world.setBlock(x, y, z, field_150939_a, metadata, 3)) { - return false; - } - - if (world.getBlock(x, y, z) == field_150939_a) { - field_150939_a.onBlockPlacedBy(world, x, y, z, player, stack); - field_150939_a.onPostBlockPlaced(world, x, y, z, metadata); - } - - return true; - } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemBloodLetterPack.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemBloodLetterPack.java index af826e9214..ec2a0979a0 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemBloodLetterPack.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemBloodLetterPack.java @@ -44,16 +44,17 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.bloodletterpack.desc")); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.bloodletterpack.desc")); - if (!(par1ItemStack.getTagCompound() == null)) { - par3List.add(StatCollector.translateToLocal("tooltip.lp.storedlp") + " " + this.getStoredLP(par1ItemStack)); + if (!(item.getTagCompound() == null)) { + tooltip.add(StatCollector.translateToLocal("tooltip.lp.storedlp") + " " + this.getStoredLP(item)); } } + @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { + public IIcon getIconFromDamage(int meta) { return this.plateIcon; } @@ -80,12 +81,10 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TEAltar)) { + if (!(tile instanceof TEAltar altar)) { return super.onItemRightClick(itemStack, world, player); } - TEAltar altar = (TEAltar) tile; - if (!altar.isActive()) { int amount = this.getStoredLP(itemStack); if (amount > 0) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemBloodRuneBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemBloodRuneBlock.java index a3034c18d6..87b2c22fc1 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemBloodRuneBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemBloodRuneBlock.java @@ -11,6 +11,7 @@ public ItemBloodRuneBlock(Block block) { setHasSubtypes(true); } + @Override public String getUnlocalizedName(ItemStack itemstack) { String name; @@ -52,6 +53,7 @@ public String getUnlocalizedName(ItemStack itemstack) { return getUnlocalizedName() + "." + name; } + @Override public int getMetadata(int par1) { return par1; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemComplexSpellCrystal.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemComplexSpellCrystal.java index 732778f5ec..37227957a4 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemComplexSpellCrystal.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemComplexSpellCrystal.java @@ -32,56 +32,51 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.complexspellcrystal.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.complexspellcrystal.desc")); + addBindingInformation(item, tooltip); - if (!(par1ItemStack.getTagCompound() == null)) { - NBTTagCompound itemTag = par1ItemStack.getTagCompound(); - - par3List.add( - StatCollector.translateToLocal("tooltip.alchemy.coords") + " " - + itemTag.getInteger("xCoord") - + ", " - + itemTag.getInteger("yCoord") - + ", " - + itemTag.getInteger("zCoord")); - par3List.add( - StatCollector.translateToLocal("tooltip.alchemy.dimension") + " " + getDimensionID(par1ItemStack)); + if (item.getTagCompound() == null) { + return; } + NBTTagCompound itemTag = item.getTagCompound(); + + tooltip.add( + StatCollector.translateToLocal("tooltip.alchemy.coords") + " " + + itemTag.getInteger("xCoord") + + ", " + + itemTag.getInteger("yCoord") + + ", " + + itemTag.getInteger("zCoord")); + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.dimension") + " " + getDimensionID(item)); } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par2World.isRemote) { - World world = DimensionManager.getWorld(getDimensionID(par1ItemStack)); - - if (world != null) { - NBTTagCompound itemTag = par1ItemStack.getTagCompound(); - TileEntity tileEntity = world.getTileEntity( - itemTag.getInteger("xCoord"), - itemTag.getInteger("yCoord"), - itemTag.getInteger("zCoord")); - - if (tileEntity instanceof TESpellParadigmBlock) { - TESpellParadigmBlock tileParad = (TESpellParadigmBlock) tileEntity; - - tileParad.castSpell(par2World, par3EntityPlayer, par1ItemStack); - } else { - return par1ItemStack; - } - } else { - return par1ItemStack; - } + if (world.isRemote) { + return item; + } + World dim = DimensionManager.getWorld(getDimensionID(item)); + if (dim == null) { + return item; + } + NBTTagCompound itemTag = item.getTagCompound(); + TileEntity tileEntity = dim.getTileEntity( + itemTag.getInteger("xCoord"), + itemTag.getInteger("yCoord"), + itemTag.getInteger("zCoord")); + + if (tileEntity instanceof TESpellParadigmBlock tileParad) { + tileParad.castSpell(world, player, item); } else { - return par1ItemStack; + return item; } - par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - return par1ItemStack; + world.playSoundAtEntity(player, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + return item; } public int getDimensionID(ItemStack itemStack) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemComponents.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemComponents.java index d11ca0a495..613ead296b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemComponents.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemComponents.java @@ -4,12 +4,10 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; -import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; import cpw.mods.fml.relauncher.Side; @@ -44,16 +42,11 @@ public void registerIcons(IIconRegister iconRegister) { } } - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - return par1ItemStack; - } - @Override public String getUnlocalizedName(ItemStack itemStack) { // This is what will do all the localisation things on the alchemy components so you dont have to set it :D int meta = MathHelper.clamp_int(itemStack.getItemDamage(), 0, ITEM_NAMES.length - 1); - return ("" + "item.bloodMagicBaseItem." + ITEM_NAMES[meta]); + return ("item.bloodMagicBaseItem." + ITEM_NAMES[meta]); } @Override @@ -65,7 +58,7 @@ public IIcon getIconFromDamage(int meta) { @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) { + public void getSubItems(Item id, CreativeTabs creativeTab, List list) { for (int meta = 0; meta < ITEM_NAMES.length; ++meta) { list.add(new ItemStack(id, 1, meta)); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemCrystalBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemCrystalBlock.java index 2707efd835..8acb5e3e63 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemCrystalBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemCrystalBlock.java @@ -11,29 +11,17 @@ public ItemCrystalBlock(Block par1) { setHasSubtypes(true); } + @Override public String getUnlocalizedName(ItemStack itemstack) { - String name; - - switch (itemstack.getItemDamage()) { - case 0: { - name = "fullCrystal"; - break; - } - - case 1: { - name = "crystalBrick"; - break; - } - - default: - name = "broken"; - } - - return getUnlocalizedName() + "." + name; + return getUnlocalizedName() + "." + switch (itemstack.getItemDamage()) { + case 0 -> "fullCrystal"; + case 1 -> "crystalBrick"; + default -> "broken"; + }; } + @Override public int getMetadata(int par1) { - return par1; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemDiabloKey.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemDiabloKey.java index 7b8eecbce2..9a1b7efc44 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemDiabloKey.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemDiabloKey.java @@ -36,26 +36,25 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.diablokey.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.diablokey.desc")); + addBindingInformation(item, tooltip); } - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - World world = par3EntityPlayer.worldObj; - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) - || par3EntityPlayer instanceof FakePlayer) { - return par1ItemStack; + @Override + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player instanceof FakePlayer) { + return item; } if (world != null) { - double posX = par3EntityPlayer.posX; - double posY = par3EntityPlayer.posY; - double posZ = par3EntityPlayer.posZ; + double posX = player.posX; + double posY = player.posY; + double posZ = player.posZ; world.playSoundEffect( - (double) ((float) posX + 0.5F), - (double) ((float) posY + 0.5F), - (double) ((float) posZ + 0.5F), + (float) posX + 0.5F, + (float) posY + 0.5F, + (float) posZ + 0.5F, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); @@ -72,46 +71,46 @@ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, Enti posZ); } - if (par3EntityPlayer.worldObj.isRemote) { - return par1ItemStack; + if (player.worldObj.isRemote) { + return item; } - if (par3EntityPlayer.isSneaking()) { - return par1ItemStack; + if (player.isSneaking()) { + return item; } - NBTTagCompound itemTag = par1ItemStack.getTagCompound(); + NBTTagCompound itemTag = item.getTagCompound(); - if (itemTag == null || itemTag.getString("ownerName").equals("")) { - return par1ItemStack; + if (itemTag == null || itemTag.getString("ownerName").isEmpty()) { + return item; } String ownerName = itemTag.getString("ownerName"); - ItemStack[] inv = par3EntityPlayer.inventory.mainInventory; + ItemStack[] inv = player.inventory.mainInventory; for (ItemStack itemStack : inv) { if (itemStack == null) { continue; } - Item item = itemStack.getItem(); + Item i = itemStack.getItem(); - if (item instanceof ItemDiabloKey) { + if (i instanceof ItemDiabloKey) { continue; } - if (item instanceof IBindable) { + if (i instanceof IBindable) { IBindable.checkAndSetItemOwner(itemStack, ownerName); } } - par3EntityPlayer.inventoryContainer.detectAndSendChanges(); + player.inventoryContainer.detectAndSendChanges(); - return par1ItemStack; + return item; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) { + public void getSubItems(Item id, CreativeTabs creativeTab, List list) { list.add(new ItemStack(ModItems.itemKeyOfDiablo)); ItemStack boundKey = new ItemStack(ModItems.itemKeyOfDiablo); IBindable.checkAndSetItemOwner(boundKey, "Server-wide Soul Network"); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemEnchantmentGlyphBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemEnchantmentGlyphBlock.java index 2eed72ff82..66ac432300 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemEnchantmentGlyphBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemEnchantmentGlyphBlock.java @@ -13,22 +13,11 @@ public ItemEnchantmentGlyphBlock(Block block) { @Override public String getUnlocalizedName(ItemStack itemstack) { - String name; - - switch (itemstack.getItemDamage()) { - case 0: - name = "enchantability"; - break; - - case 1: - name = "enchantmentLevel"; - break; - - default: - name = "broken"; - } - - return getUnlocalizedName() + "." + name; + return getUnlocalizedName() + "." + switch (itemstack.getItemDamage()) { + case 0 -> "enchantability"; + case 1 -> "enchantmentLevel"; + default -> "broken"; + }; } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemIncense.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemIncense.java index becf7a504e..ea3fd79869 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemIncense.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemIncense.java @@ -53,14 +53,14 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { - list.add(StatCollector.translateToLocal("tooltip.alchemy.usedinincense")); + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.usedinincense")); } @Override public String getUnlocalizedName(ItemStack itemStack) { int meta = MathHelper.clamp_int(itemStack.getItemDamage(), 0, ITEM_NAMES.length - 1); - return ("" + "item.bloodMagicIncenseItem." + ITEM_NAMES[meta]); + return ("item.bloodMagicIncenseItem." + ITEM_NAMES[meta]); } @Override @@ -72,7 +72,7 @@ public IIcon getIconFromDamage(int meta) { @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) { + public void getSubItems(Item id, CreativeTabs creativeTab, List list) { for (int meta = 0; meta < ITEM_NAMES.length; ++meta) { list.add(new ItemStack(id, 1, meta)); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemRitualDismantler.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemRitualDismantler.java index 2669fa7a09..52c7582edd 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemRitualDismantler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemRitualDismantler.java @@ -35,9 +35,9 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack stack, EntityPlayer player, List par3List, boolean x) { - par3List.add(StatCollector.translateToLocal("tooltip.dismantler.desc")); - addBindingInformation(stack, par3List); + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.dismantler.desc")); + addBindingInformation(stack, tooltip); } @Override @@ -51,42 +51,38 @@ public boolean breakRitualStoneAtMasterStone(ItemStack stack, EntityPlayer playe int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity instanceof TEMasterStone) { - TEMasterStone masterStone = (TEMasterStone) tileEntity; - int direction = masterStone.getDirection(); + if (!(tileEntity instanceof TEMasterStone masterStone)) { + return false; + } + int direction = masterStone.getDirection(); - String ritualName = Rituals.checkValidRitual(world, x, y, z); - List ritualList = Rituals.getRitualList(ritualName); - if (ritualList == null) { - return false; - } + String ritualName = Rituals.checkValidRitual(world, x, y, z); + List ritualList = Rituals.getRitualList(ritualName); + if (ritualList == null) { + return false; + } - for (RitualComponent rc : ritualList) { - if (!world.isAirBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)) && world.getBlock( - x + rc.getX(direction), - y + rc.getY(), - z + rc.getZ(direction)) instanceof RitualStone) { - if (EnergyItems.syphonBatteries(stack, player, getEnergyUsed()) - || player.capabilities.isCreativeMode) { - world.setBlockToAir(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)); - EntityItem entityItem = new EntityItem( - world, - player.posX, - player.posY, - player.posZ, - new ItemStack(ModBlocks.ritualStone)); - if (world.isRemote) { - world.playAuxSFX(2005, x, y + 1, z, 0); - } else { - world.spawnEntityInWorld(entityItem); - } - } - } + for (RitualComponent rc : ritualList) { + if (world.isAirBlock(x + rc.x(direction), y + rc.y(), z + rc.z(direction)) + || !(world.getBlock(x + rc.x(direction), y + rc.y(), z + rc.z(direction)) instanceof RitualStone) + || (!player.capabilities.isCreativeMode + && !EnergyItems.syphonBatteries(stack, player, getEnergyUsed()))) { + continue; + } + world.setBlockToAir(x + rc.x(direction), y + rc.y(), z + rc.z(direction)); + EntityItem entityItem = new EntityItem( + world, + player.posX, + player.posY, + player.posZ, + new ItemStack(ModBlocks.ritualStone)); + if (world.isRemote) { + world.playAuxSFX(2005, x, y + 1, z, 0); + } else { + world.spawnEntityInWorld(entityItem); } - - return true; } - return false; + return true; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemRitualDiviner.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemRitualDiviner.java index 9555fdbe5f..75b7c3c331 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemRitualDiviner.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemRitualDiviner.java @@ -35,7 +35,7 @@ public class ItemRitualDiviner extends EnergyItems implements IRitualDiviner { - private int maxMetaData; + private final int maxMetaData; public ItemRitualDiviner() { super(); @@ -53,19 +53,19 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack stack, EntityPlayer player, List par3List, boolean x) { - par3List.add(StatCollector.translateToLocal("tooltip.ritualdiviner.desc")); + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.ritualdiviner.desc")); if (this.getMaxRuneDisplacement(stack) == 1) { - par3List.add(StatCollector.translateToLocal("tooltip.ritualdiviner.canplace")); + tooltip.add(StatCollector.translateToLocal("tooltip.ritualdiviner.canplace")); } else if (this.getMaxRuneDisplacement(stack) >= 2) { - par3List.add(StatCollector.translateToLocal("tooltip.ritualdiviner.canplacedawn")); + tooltip.add(StatCollector.translateToLocal("tooltip.ritualdiviner.canplacedawn")); } else { - par3List.add(StatCollector.translateToLocal("tooltip.ritualdiviner.cannotplace")); + tooltip.add(StatCollector.translateToLocal("tooltip.ritualdiviner.cannotplace")); } - par3List.add( + tooltip.add( StatCollector.translateToLocal("tooltip.ritualdiviner.ritualtunedto") + " " + this.getNameForDirection(this.getDirection(stack))); @@ -75,8 +75,8 @@ public void addInformation(ItemStack stack, EntityPlayer player, List par3List, if (!(stack.getTagCompound() == null)) { String ritualID = this.getCurrentRitual(stack); // TODO - addBindingInformation(stack, par3List); - par3List.add(StatCollector.translateToLocal("tooltip.alchemy.ritualid") + " " + ritualID); + addBindingInformation(stack, tooltip); + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.ritualid") + " " + ritualID); List ritualList = Rituals.getRitualList(this.getCurrentRitual(stack)); if (ritualList == null) { return; @@ -91,34 +91,14 @@ public void addInformation(ItemStack stack, EntityPlayer player, List par3List, int dawnStones = 0; for (RitualComponent rc : ritualList) { - switch (rc.getStoneType()) { - case RitualComponent.BLANK: - blankStones++; - break; - - case RitualComponent.AIR: - airStones++; - break; - - case RitualComponent.WATER: - waterStones++; - break; - - case RitualComponent.FIRE: - fireStones++; - break; - - case RitualComponent.EARTH: - earthStones++; - break; - - case RitualComponent.DUSK: - duskStones++; - break; - - case RitualComponent.DAWN: - dawnStones++; - break; + switch (rc.stoneType()) { + case RitualComponent.BLANK -> blankStones++; + case RitualComponent.AIR -> airStones++; + case RitualComponent.WATER -> waterStones++; + case RitualComponent.FIRE -> fireStones++; + case RitualComponent.EARTH -> earthStones++; + case RitualComponent.DUSK -> duskStones++; + case RitualComponent.DAWN -> dawnStones++; } } @@ -129,44 +109,44 @@ public void addInformation(ItemStack stack, EntityPlayer player, List par3List, + duskStones + dawnStones; - par3List.add( + tooltip.add( EnumChatFormatting.WHITE + StatCollector.translateToLocal("tooltip.ritualdiviner.blankstones") + " " + blankStones); - par3List.add( + tooltip.add( EnumChatFormatting.AQUA + StatCollector.translateToLocal("tooltip.ritualdiviner.airstones") + " " + airStones); - par3List.add( + tooltip.add( EnumChatFormatting.BLUE + StatCollector.translateToLocal("tooltip.ritualdiviner.waterstones") + " " + waterStones); - par3List.add( + tooltip.add( EnumChatFormatting.RED + StatCollector.translateToLocal("tooltip.ritualdiviner.firestones") + " " + fireStones); - par3List.add( + tooltip.add( EnumChatFormatting.DARK_GREEN + StatCollector.translateToLocal("tooltip.ritualdiviner.earthstones") + " " + earthStones); - par3List.add( + tooltip.add( EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("tooltip.ritualdiviner.duskstones") + " " + duskStones); - par3List.add( + tooltip.add( EnumChatFormatting.GOLD + StatCollector.translateToLocal("tooltip.ritualdiviner.dawnstones") + " " + dawnStones); - par3List.add( + tooltip.add( EnumChatFormatting.UNDERLINE + StatCollector.translateToLocal("tooltip.ritualdiviner.totalStones") + " " + totalStones); } } else { - par3List.add( + tooltip.add( EnumChatFormatting.AQUA + "-" + StatCollector.translateToLocal("tooltip.ritualdiviner.moreinfo") + "-"); @@ -175,16 +155,15 @@ public void addInformation(ItemStack stack, EntityPlayer player, List par3List, @Override public String getItemStackDisplayName(ItemStack stack) { - if (!(stack.getTagCompound() == null)) { - String ritualID = this.getCurrentRitual(stack); - if (ritualID.equals("")) { - return super.getItemStackDisplayName(stack); - } - return StatCollector - .translateToLocalFormatted("bm.string.ritualDiviner", Rituals.getLocalizedNameOfRitual(ritualID)); - } else { + if (stack.getTagCompound() == null) { return super.getItemStackDisplayName(stack); } + String ritualID = this.getCurrentRitual(stack); + if (ritualID.isEmpty()) { + return super.getItemStackDisplayName(stack); + } + return StatCollector + .translateToLocalFormatted("bm.string.ritualDiviner", Rituals.getLocalizedNameOfRitual(ritualID)); } @Override @@ -238,9 +217,9 @@ public boolean placeRitualStoneAtMasterStone(ItemStack stack, EntityPlayer playe } for (RitualComponent rc : ritualList) { - if (world.isAirBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction))) { + if (world.isAirBlock(x + rc.x(direction), y + rc.y(), z + rc.z(direction))) { if (playerInvRitualStoneLocation >= 0 || player.capabilities.isCreativeMode) { - if (rc.getStoneType() > this.maxMetaData + this.getMaxRuneDisplacement(stack)) { + if (rc.stoneType() > this.maxMetaData + this.getMaxRuneDisplacement(stack)) { world.playAuxSFX(200, x, y + 1, z, 0); return true; } @@ -251,11 +230,11 @@ public boolean placeRitualStoneAtMasterStone(ItemStack stack, EntityPlayer playe if (EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) { world.setBlock( - x + rc.getX(direction), - y + rc.getY(), - z + rc.getZ(direction), + x + rc.x(direction), + y + rc.y(), + z + rc.z(direction), ModBlocks.ritualStone, - rc.getStoneType(), + rc.stoneType(), 3); if (world.isRemote) { @@ -268,27 +247,24 @@ public boolean placeRitualStoneAtMasterStone(ItemStack stack, EntityPlayer playe return true; } } else { - Block block = world.getBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)); + Block block = world.getBlock(x + rc.x(direction), y + rc.y(), z + rc.z(direction)); if (block == ModBlocks.ritualStone) { - int metadata = world - .getBlockMetadata(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)); - - if (metadata != rc.getStoneType()) { - if (EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) { - if (rc.getStoneType() > this.maxMetaData + this.getMaxRuneDisplacement(stack)) { - world.playAuxSFX(200, x, y + 1, z, 0); - return true; - } - - world.setBlockMetadataWithNotify( - x + rc.getX(direction), - y + rc.getY(), - z + rc.getZ(direction), - rc.getStoneType(), - 3); + int metadata = world.getBlockMetadata(x + rc.x(direction), y + rc.y(), z + rc.z(direction)); + + if (metadata != rc.stoneType() && EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) { + if (rc.stoneType() > this.maxMetaData + this.getMaxRuneDisplacement(stack)) { + world.playAuxSFX(200, x, y + 1, z, 0); return true; } + + world.setBlockMetadataWithNotify( + x + rc.x(direction), + y + rc.y(), + z + rc.z(direction), + rc.stoneType(), + 3); + return true; } } else { world.playAuxSFX(0, x, y + 1, z, 0); @@ -306,9 +282,9 @@ public void onUpdate(ItemStack stack, World world, Entity entity, int par4, bool if (entity instanceof EntityPlayer && hasStoredLocation(stack) && world.getTotalWorldTime() % 5 == 0) { Int3 loc = getStoredLocation(stack); - int x = loc.xCoord; - int y = loc.yCoord; - int z = loc.zCoord; + int x = loc.x(); + int y = loc.y(); + int z = loc.z(); if (!this.placeRitualStoneAtMasterStone(stack, (EntityPlayer) entity, world, x, y, z)) { this.voidStoredLocation(stack); @@ -332,8 +308,6 @@ public void setStoredLocation(ItemStack stack, Int3 location) { public void voidStoredLocation(ItemStack stack) { NBTTagCompound tag = stack.getTagCompound(); if (tag == null || !tag.hasKey("location")) { - // tag = new NBTTagCompound(); - // stack.setTagCompound(tag); this.setStoredLocation(stack, new Int3(0, 0, 0)); return; } @@ -367,9 +341,9 @@ public boolean hasStoredLocation(ItemStack stack) { } @Override - public ItemStack onItemRightClick(ItemStack stack, World par2World, EntityPlayer par3EntityPlayer) { - if (IBindable.checkAndSetItemOwner(stack, par3EntityPlayer) && par3EntityPlayer.isSneaking()) { - rotateRituals(par2World, par3EntityPlayer, stack, true); + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (IBindable.checkAndSetItemOwner(stack, player) && player.isSneaking()) { + rotateRituals(world, player, stack, true); } return stack; @@ -377,27 +351,10 @@ public ItemStack onItemRightClick(ItemStack stack, World par2World, EntityPlayer @Override public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) { - if (entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) entityLiving; - + if (entityLiving instanceof EntityPlayer player) { if (!IBindable.checkAndSetItemOwner(stack, player)) return true; - - if (!player.isSwingInProgress) { - if (player.isSneaking()) { - rotateRituals(player.worldObj, player, stack, false); - } - // else - // { - // if (!player.worldObj.isRemote) - // { - // int direction = this.getDirection(stack) - 1; - // if (direction == 0) direction = 4; - // this.setDirection(stack, direction); - // player.addChatComponentMessage(new - // ChatComponentText(StatCollector.translateToLocal("tooltip.ritualdiviner.ritualtunedto") + " " + - // this.getNameForDirection(direction))); - // } - // } + if (!player.isSwingInProgress && player.isSneaking()) { + rotateRituals(player.worldObj, player, stack, false); } } @@ -438,13 +395,18 @@ public void setCurrentRitual(ItemStack stack, String ritualID) { stack.getTagCompound().setString("ritualID", ritualID); } + /** + * @return 0 if it can place the 4 elemental runes, 1 if it can also place dusk, 2 if it can also place dawn + */ @Override - public int getMaxRuneDisplacement(ItemStack stack) // 0 indicates the starting 4 runes, 1 indicates it can use Dusk - // runes - { + public int getMaxRuneDisplacement(ItemStack stack) { return stack.getItemDamage(); } + /** + * @param displacement 0 if it can place the 4 elemental runes, 1 if it can also place dusk, 2 if it can also place + * dawn + */ @Override public void setMaxRuneDisplacement(ItemStack stack, int displacement) { stack.setItemDamage(displacement); @@ -452,7 +414,7 @@ public void setMaxRuneDisplacement(ItemStack stack, int displacement) { @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) { + public void getSubItems(Item id, CreativeTabs creativeTab, List list) { list.add(new ItemStack(id)); ItemStack duskRitualDivinerStack = new ItemStack(id); @@ -500,22 +462,12 @@ public int cycleDirection(ItemStack itemStack) { @Override public String getNameForDirection(int direction) { - String dir = ""; - switch (direction) { - case 0: - case 1: - dir = StatCollector.translateToLocal("message.ritual.side.north"); - break; - case 2: - dir = StatCollector.translateToLocal("message.ritual.side.east"); - break; - case 3: - dir = StatCollector.translateToLocal("message.ritual.side.south"); - break; - case 4: - dir = StatCollector.translateToLocal("message.ritual.side.west"); - } - - return dir; + return switch (direction) { + case 1 -> StatCollector.translateToLocal("message.ritual.side.north"); + case 2 -> StatCollector.translateToLocal("message.ritual.side.east"); + case 3 -> StatCollector.translateToLocal("message.ritual.side.south"); + case 4 -> StatCollector.translateToLocal("message.ritual.side.west"); + default -> ""; + }; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellEffectBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellEffectBlock.java index 5cf1a63769..6d03b307a5 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellEffectBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellEffectBlock.java @@ -11,37 +11,21 @@ public ItemSpellEffectBlock(Block par1) { setHasSubtypes(true); } + @Override public String getUnlocalizedName(ItemStack itemstack) { - String name; - - switch (itemstack.getItemDamage()) { - case 0: { - name = "fire"; - break; - } - - case 1: { - name = "ice"; - break; - } - - case 2: - name = "wind"; - break; - - case 3: - name = "earth"; - break; - - default: - name = "broken"; - } + String name = switch (itemstack.getItemDamage()) { + case 0 -> "fire"; + case 1 -> "ice"; + case 2 -> "wind"; + case 3 -> "earth"; + default -> "broken"; + }; return getUnlocalizedName() + "." + name; } - public int getMetadata(int par1) { - - return par1; + @Override + public int getMetadata(int meta) { + return meta; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellEnhancementBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellEnhancementBlock.java index f782005eab..300b38e7f8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellEnhancementBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellEnhancementBlock.java @@ -11,77 +11,31 @@ public ItemSpellEnhancementBlock(Block par1) { setHasSubtypes(true); } + @Override public String getUnlocalizedName(ItemStack itemstack) { - String name; - - switch (itemstack.getItemDamage()) { - case 0: - name = "power1"; - break; - - case 1: - name = "power2"; - break; - - case 2: - name = "power3"; - break; - - case 3: - name = "power4"; - break; - - case 4: - name = "power5"; - break; - - case 5: - name = "cost1"; - break; - - case 6: - name = "cost2"; - break; - - case 7: - name = "cost3"; - break; - - case 8: - name = "cost4"; - break; - - case 9: - name = "cost5"; - break; - - case 10: - name = "potency1"; - break; - - case 11: - name = "potency2"; - break; - - case 12: - name = "potency3"; - break; - - case 13: - name = "potency4"; - break; - - case 14: - name = "potency5"; - break; - - default: - name = "broken"; - } + String name = switch (itemstack.getItemDamage()) { + case 0 -> "power1"; + case 1 -> "power2"; + case 2 -> "power3"; + case 3 -> "power4"; + case 4 -> "power5"; + case 5 -> "cost1"; + case 6 -> "cost2"; + case 7 -> "cost3"; + case 8 -> "cost4"; + case 9 -> "cost5"; + case 10 -> "potency1"; + case 11 -> "potency2"; + case 12 -> "potency3"; + case 13 -> "potency4"; + case 14 -> "potency5"; + default -> "broken"; + }; return getUnlocalizedName() + "." + name; } + @Override public int getMetadata(int par1) { return par1; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellModifierBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellModifierBlock.java index 5fd5712de5..a68a32cd56 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellModifierBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellModifierBlock.java @@ -11,35 +11,20 @@ public ItemSpellModifierBlock(Block par1) { setHasSubtypes(true); } + @Override public String getUnlocalizedName(ItemStack itemstack) { - String name; - - switch (itemstack.getItemDamage()) { - case 0: { - name = "default"; - break; - } - - case 1: { - name = "offensive"; - break; - } - - case 2: - name = "defensive"; - break; - - case 3: - name = "environmental"; - break; - - default: - name = "broken"; - } + String name = switch (itemstack.getItemDamage()) { + case 0 -> "default"; + case 1 -> "offensive"; + case 2 -> "defensive"; + case 3 -> "environmental"; + default -> "broken"; + }; return getUnlocalizedName() + "." + name; } + @Override public int getMetadata(int par1) { return par1; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellParadigmBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellParadigmBlock.java index e2a0a87978..aecc6f9d80 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellParadigmBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemSpellParadigmBlock.java @@ -13,30 +13,13 @@ public ItemSpellParadigmBlock(Block par1) { @Override public String getUnlocalizedName(ItemStack itemstack) { - String name; - - switch (itemstack.getItemDamage()) { - case 0: { - name = "projectile"; - break; - } - - case 1: { - name = "self"; - break; - } - - case 2: - name = "melee"; - break; - - case 3: - name = "tool"; - break; - - default: - name = "broken"; - } + String name = switch (itemstack.getItemDamage()) { + case 0 -> "projectile"; + case 1 -> "self"; + case 2 -> "melee"; + case 3 -> "tool"; + default -> "broken"; + }; return getUnlocalizedName() + "." + name; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemStabilityGlyphBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemStabilityGlyphBlock.java index c42b930be4..310c8beeb5 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemStabilityGlyphBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ItemStabilityGlyphBlock.java @@ -14,14 +14,10 @@ public ItemStabilityGlyphBlock(Block block) { @Override public String getUnlocalizedName(ItemStack itemstack) { String name; - - switch (itemstack.getItemDamage()) { - case 0: - name = "stability1"; - break; - - default: - name = "broken"; + if (itemstack.getItemDamage() == 0) { + name = "stability1"; + } else { + name = "broken"; } return getUnlocalizedName() + "." + name; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/LavaCrystal.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/LavaCrystal.java index c5dacc04a5..202dc2772b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/LavaCrystal.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/LavaCrystal.java @@ -38,13 +38,11 @@ public void registerIcons(IIconRegister iconRegister) { */ @Override public ItemStack getContainerItem(ItemStack itemStack) { - { - syphonWhileInContainer(itemStack, this.getEnergyUsed()); - ItemStack copiedStack = itemStack.copy(); - copiedStack.setItemDamage(copiedStack.getItemDamage()); - copiedStack.stackSize = 1; - return copiedStack; - } + syphonWhileInContainer(itemStack, this.getEnergyUsed()); + ItemStack copiedStack = itemStack.copy(); + copiedStack.setItemDamage(copiedStack.getItemDamage()); + copiedStack.stackSize = 1; + return copiedStack; } @Override @@ -52,27 +50,27 @@ public boolean hasContainerItem() { return true; } - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer); - return par1ItemStack; + @Override + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + IBindable.checkAndSetItemOwner(item, player); + return item; } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.lavacrystal.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.lavacrystal.desc2")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.lavacrystal.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.lavacrystal.desc2")); + addBindingInformation(item, tooltip); } public boolean hasEnoughEssence(ItemStack itemStack) { - if (itemStack.getTagCompound() != null && !(itemStack.getTagCompound().getString("ownerName").equals(""))) { + if (itemStack.getTagCompound() != null && !(itemStack.getTagCompound().getString("ownerName").isEmpty())) { String ownerName = itemStack.getTagCompound().getString("ownerName"); if (FMLCommonHandler.instance().getMinecraftServerInstance() == null) { return false; } - // World world = MinecraftServer.getServer().worldServers[0]; WorldProvider provider = DimensionManager.getProvider(0); if (provider == null || provider.worldObj == null) { return false; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/OrbOfTesting.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/OrbOfTesting.java index 3f4aca3b1d..db068a103f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/OrbOfTesting.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/OrbOfTesting.java @@ -27,15 +27,16 @@ public void registerIcons(IIconRegister iconRegister) { this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:Untitled"); } - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!par3EntityPlayer.shouldHeal()) { - return par1ItemStack; + @Override + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!player.shouldHeal()) { + return item; } - if (syphonBatteries(par1ItemStack, par3EntityPlayer, this.getEnergyUsed())) { - par3EntityPlayer.heal(1); + if (syphonBatteries(item, player, this.getEnergyUsed())) { + player.heal(1); } - return par1ItemStack; + return item; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/ReinforcedTelepositionFocus.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/ReinforcedTelepositionFocus.java index 3550911459..67236c2df4 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/ReinforcedTelepositionFocus.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/ReinforcedTelepositionFocus.java @@ -25,19 +25,19 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.reinforcedtelepfocus.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.reinforcedtelepfocus.desc2")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.reinforcedtelepfocus.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.reinforcedtelepfocus.desc2")); + addBindingInformation(item, tooltip); - NBTTagCompound itemTag = IBindable.getTag(par1ItemStack); - par3List.add( + NBTTagCompound itemTag = IBindable.getTag(item); + tooltip.add( StatCollector.translateToLocal("tooltip.alchemy.coords") + " " + itemTag.getInteger("xCoord") + ", " + itemTag.getInteger("yCoord") + ", " + itemTag.getInteger("zCoord")); - par3List.add(StatCollector.translateToLocal("tooltip.alchemy.dimension") + " " + getDimensionID(par1ItemStack)); + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.dimension") + " " + getDimensionID(item)); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/SacrificialDagger.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/SacrificialDagger.java index 72ceadc4fa..a217218bf9 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/SacrificialDagger.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/SacrificialDagger.java @@ -44,12 +44,12 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean adv) { if (AlchemicalWizardry.wimpySettings) { - par3List.add(StatCollector.translateToLocal("tooltip.sacrificialdagger.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.sacrificialdagger.desc1")); } else { - par3List.add(StatCollector.translateToLocal("tooltip.sacrificialdagger.desc2")); - par3List.add(StatCollector.translateToLocal("tooltip.sacrificialdagger.desc3")); + tooltip.add(StatCollector.translateToLocal("tooltip.sacrificialdagger.desc2")); + tooltip.add(StatCollector.translateToLocal("tooltip.sacrificialdagger.desc3")); } } @@ -58,11 +58,6 @@ public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List */ @Override public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int itemInUseCount) { - // if(itemInUseCount < 32) - // { - // return; - // } - PlayerSacrificeHandler.sacrificePlayerHealth(player); } @@ -109,9 +104,9 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla double posY = player.posY; double posZ = player.posZ; world.playSoundEffect( - (double) ((float) posX + 0.5F), - (double) ((float) posY + 0.5F), - (double) ((float) posZ + 0.5F), + (float) posX + 0.5F, + (float) posY + 0.5F, + (float) posZ + 0.5F, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); @@ -170,8 +165,8 @@ public IBloodAltar getAltar(World world, int x, int y, int z) { for (int k = -2; k <= 1; k++) { tileEntity = world.getTileEntity(i + x, k + y, j + z); - if (tileEntity instanceof IBloodAltar) { - return (IBloodAltar) tileEntity; + if (tileEntity instanceof IBloodAltar altar) { + return altar; } } } @@ -182,8 +177,8 @@ public IBloodAltar getAltar(World world, int x, int y, int z) { @Override public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { - if (!world.isRemote && entity instanceof EntityPlayer) { - this.setUseForSacrifice(stack, this.isPlayerPreparedForSacrifice(world, (EntityPlayer) entity)); + if (!world.isRemote && entity instanceof EntityPlayer player) { + this.setUseForSacrifice(stack, this.isPlayerPreparedForSacrifice(world, player)); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/TelepositionFocus.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/TelepositionFocus.java index 1ae450723c..652ec9f7b4 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/TelepositionFocus.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/TelepositionFocus.java @@ -33,26 +33,25 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, - boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.telepositionfocus.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.telepositionfocus.desc")); + addBindingInformation(item, tooltip); - NBTTagCompound itemTag = IBindable.getTag(par1ItemStack); - par3List.add( + NBTTagCompound itemTag = IBindable.getTag(item); + tooltip.add( StatCollector.translateToLocal("tooltip.alchemy.coords") + " " + itemTag.getInteger("xCoord") + ", " + itemTag.getInteger("yCoord") + ", " + itemTag.getInteger("zCoord")); - par3List.add(StatCollector.translateToLocal("tooltip.alchemy.dimension") + " " + getDimensionID(par1ItemStack)); + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.dimension") + " " + getDimensionID(item)); } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer); - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + IBindable.checkAndSetItemOwner(item, player); + return item; } public int getDimensionID(ItemStack itemStack) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/BoundArmour.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/BoundArmour.java index facb9b5e56..92668511e3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/BoundArmour.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/BoundArmour.java @@ -48,7 +48,7 @@ public class BoundArmour extends ItemArmor implements IAlchemyGoggles, ISpecialArmor, IBindable, IRevealer, IGoggles, IRunicArmor, ILPGauge, IHazardProtector { - private static int invSize = 9; + private static final int invSize = 9; @SideOnly(Side.CLIENT) private IIcon helmetIcon; @@ -82,8 +82,8 @@ public boolean isItemTool(ItemStack stack) { @Override @SideOnly(Side.CLIENT) public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { - if (tryComplexRendering) { - int type = ((ItemArmor) itemStack.getItem()).armorType; + if (tryComplexRendering && itemStack.getItem() instanceof ItemArmor armor) { + int type = armor.armorType; if (this.model1 == null) { this.model1 = new ModelOmegaArmour(1.0f, true, true, false, true); } @@ -144,7 +144,7 @@ public void registerIcons(IIconRegister iconRegister) { @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { + public IIcon getIconFromDamage(int meta) { if (this.equals(ModItems.boundHelmet)) { return this.helmetIcon; } @@ -165,7 +165,7 @@ public IIcon getIconFromDamage(int par1) { } @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + public boolean getIsRepairable(ItemStack item, ItemStack par2ItemStack) { return false; } @@ -277,12 +277,12 @@ public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource s } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.boundarmor.devprotect")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.boundarmor.devprotect")); + addBindingInformation(item, tooltip); - if (!(par1ItemStack.getTagCompound() == null)) { - ItemStack[] inv = getInternalInventory(par1ItemStack); + if (!(item.getTagCompound() == null)) { + ItemStack[] inv = getInternalInventory(item); if (inv == null) { return; @@ -290,7 +290,7 @@ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlaye for (int i = 0; i < invSize; i++) { if (inv[i] != null) { - par3List.add( + tooltip.add( StatCollector.translateToLocal("tooltip.item.iteminslot") + " " + i + ": " @@ -330,9 +330,9 @@ public String getArmorTexture(ItemStack stack, Entity entity, int slot, String t } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer); - return super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer); + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + IBindable.checkAndSetItemOwner(item, player); + return super.onItemRightClick(item, world, player); } @Override @@ -342,7 +342,7 @@ public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { } if (!player.isPotionActive(AlchemicalWizardry.customPotionInhibit)) { - tickInternalInventory(itemStack, world, player, 0, false); + tickInternalInventory(itemStack, world, player); } this.setIsInvisible(itemStack, player.isPotionActive(Potion.invisibility.id)); @@ -362,33 +362,31 @@ public void repairArmour(World world, EntityPlayer player, ItemStack itemStack) } } - public void tickInternalInventory(ItemStack par1ItemStack, World par2World, EntityPlayer par3Entity, int par4, - boolean par5) { - ItemStack[] inv = getInternalInventory(par1ItemStack); + public void tickInternalInventory(ItemStack item, World world, EntityPlayer player) { + ItemStack[] inv = getInternalInventory(item); if (inv == null) { return; } - int blood = getMaxBloodShardLevel(par1ItemStack); + int blood = getMaxBloodShardLevel(item); for (int i = 0; i < invSize; i++) { if (inv[i] == null) { continue; } - if (inv[i].getItem() instanceof ArmourUpgrade && blood > 0) { - if (((ArmourUpgrade) inv[i].getItem()).isUpgrade()) { - ((ArmourUpgrade) inv[i].getItem()).onArmourUpdate(par2World, par3Entity, inv[i]); + if (inv[i].getItem() instanceof ArmourUpgrade upgrade && blood > 0) { + if (upgrade.isUpgrade()) { + upgrade.onArmourUpdate(world, player, inv[i]); blood--; } - if (par2World.getTotalWorldTime() % 200 == 0) { - if (getUpgradeCostMultiplier(par1ItemStack) > 0.02f) { + if (world.getTotalWorldTime() % 200 == 0) { + if (getUpgradeCostMultiplier(item) > 0.02f) { EnergyItems.syphonBatteries( - par1ItemStack, - par3Entity, - (int) (((ArmourUpgrade) inv[i].getItem()).getEnergyForTenSeconds() - * getUpgradeCostMultiplier(par1ItemStack))); + item, + player, + (int) (upgrade.getEnergyForTenSeconds() * getUpgradeCostMultiplier(item))); } } } @@ -407,13 +405,13 @@ public int getMaxBloodShardLevel(ItemStack armourStack) { for (int i = 0; i < invSize; i++) { ItemStack itemStack = inv[i]; - if (itemStack != null) { + if (itemStack != null && itemStack.getItem() != null) { if (itemStack.getItem().equals(ModItems.weakBloodShard)) { max = Math.max(max, 1); } if (itemStack.getItem().equals(ModItems.demonBloodShard)) { - max = Math.max(max, 2); + max = 2; } } } @@ -439,7 +437,6 @@ public boolean hasAddedToInventory(ItemStack sigilItemStack, ItemStack addedItem if (nextItem == null) { candidateSlot = i; - continue; } } @@ -484,12 +481,6 @@ public ItemStack[] getInternalInventory(ItemStack itemStack) { } public void saveInternalInventory(ItemStack itemStack, ItemStack[] inventory) { - NBTTagCompound itemTag = itemStack.getTagCompound(); - - if (itemTag == null) { - itemStack.setTagCompound(new NBTTagCompound()); - } - NBTTagList itemList = new NBTTagList(); for (int i = 0; i < invSize; i++) { @@ -501,7 +492,7 @@ public void saveInternalInventory(ItemStack itemStack, ItemStack[] inventory) { } } - itemTag.setTag("Inventory", itemList); + IBindable.getTag(itemStack).setTag("Inventory", itemList); } public boolean isImmuneToVoid(ItemStack itemStack) { @@ -512,7 +503,7 @@ public boolean isImmuneToVoid(ItemStack itemStack) { } for (ItemStack item : inv) { - if (item == null) { + if (item == null || item.getItem() == null) { continue; } @@ -625,6 +616,7 @@ public float getUpgradeCostMultiplier(ItemStack itemStack) { return 1.0f; } + @Override public int getItemEnchantability(ItemStack stack) { NBTTagCompound tag = stack.getTagCompound(); if (tag != null) { @@ -635,18 +627,11 @@ public int getItemEnchantability(ItemStack stack) { } public void setItemEnchantability(ItemStack stack, int enchantability) { - NBTTagCompound tag = stack.getTagCompound(); - - if (tag == null) { - stack.setTagCompound(new NBTTagCompound()); - tag = stack.getTagCompound(); - } - - tag.setInteger("enchantability", enchantability); + IBindable.getTag(stack).setInteger("enchantability", enchantability); } - public boolean getIsInvisible(ItemStack armourStack) { - NBTTagCompound tag = armourStack.getTagCompound(); + public boolean getIsInvisible(ItemStack stack) { + NBTTagCompound tag = stack.getTagCompound(); if (tag != null) { return tag.getBoolean("invisible"); } @@ -654,15 +639,8 @@ public boolean getIsInvisible(ItemStack armourStack) { return false; } - public void setIsInvisible(ItemStack armourStack, boolean invisible) { - NBTTagCompound tag = armourStack.getTagCompound(); - - if (tag == null) { - armourStack.setTagCompound(new NBTTagCompound()); - tag = armourStack.getTagCompound(); - } - - tag.setBoolean("invisible", invisible); + public void setIsInvisible(ItemStack stack, boolean invisible) { + IBindable.getTag(stack).setBoolean("invisible", invisible); } @Override @@ -732,7 +710,7 @@ public boolean showIngameHUD(World world, ItemStack stack, EntityPlayer player) } for (ItemStack item : inv) { - if (item == null) { + if (item == null || item.getItem() == null) { continue; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmour.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmour.java index d2b36b2231..0b59b929b6 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmour.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmour.java @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -41,7 +40,7 @@ public abstract class OmegaArmour extends BoundArmour { protected boolean storeYLevel = false; protected boolean storeSeesSky = false; - protected List illegalEnchantmentList = new LinkedList(); + protected List illegalEnchantmentList = new LinkedList<>(); public float reagentDrainPerDamage = 0.1f; @@ -66,11 +65,6 @@ public boolean isAffectedBySoulHarden() { return false; } - @Override - public double getBaseArmourReduction() { - return 0.9; - } - @Override public double getArmourPenetrationReduction() { return 0.5; @@ -138,30 +132,29 @@ public ItemStack getSubstituteStack(ItemStack boundStack, int stability, int aff omegaStack.setTagCompound(tag); } this.setContainedArmourStack(omegaStack, boundStack); + assert boundStack != null; IBindable.checkAndSetItemOwner(omegaStack, SoulNetworkHandler.getOwnerName(boundStack)); this.setItemEnchantability(omegaStack, Math.min(enchantability, 70)); - EnchantmentHelper.setEnchantments(new HashMap(), omegaStack); + EnchantmentHelper.setEnchantments(new HashMap<>(), omegaStack); - List enchantList = new ArrayList(); + List enchantList = new ArrayList<>(); int adjustedEnchantLevel = Math.min(enchantmentLevel, 30); int additionalPasses = enchantmentLevel - adjustedEnchantLevel; for (int i = 0; i < 1 + additionalPasses; i++) { - List lst = EnchantmentHelper.buildEnchantmentList(rand, omegaStack, adjustedEnchantLevel); + List lst = EnchantmentHelper.buildEnchantmentList(rand, omegaStack, adjustedEnchantLevel); if (lst != null) { enchantList.addAll(lst); } } - Map> map = new HashMap(); - - for (Object obj : enchantList) { - EnchantmentData enchantmentdata = (EnchantmentData) obj; + Map> map = new HashMap<>(); + for (EnchantmentData enchantmentdata : enchantList) { if (!map.containsKey(enchantmentdata.enchantmentobj)) { - map.put(enchantmentdata.enchantmentobj, new HashMap()); + map.put(enchantmentdata.enchantmentobj, new HashMap<>()); } Map numMap = map.get(enchantmentdata.enchantmentobj); @@ -173,12 +166,10 @@ public ItemStack getSubstituteStack(ItemStack boundStack, int stability, int aff } for (Enchantment ench : this.illegalEnchantmentList) { - if (map.containsKey(ench)) { - map.remove(ench); - } + map.remove(ench); } - List newEnchantList = new ArrayList(); + List newEnchantList = new ArrayList<>(); for (Entry> entry : map.entrySet()) { Enchantment ench = entry.getKey(); @@ -196,9 +187,7 @@ public ItemStack getSubstituteStack(ItemStack boundStack, int stability, int aff if (enchantLevel >= enchantValues.length) { int[] newEnchantValues = new int[enchantLevel + 1]; - for (int i = 0; i < enchantValues.length; i++) { - newEnchantValues[i] = enchantValues[i]; - } + System.arraycopy(enchantValues, 0, newEnchantValues, 0, enchantValues.length); enchantValues = newEnchantValues; } @@ -212,9 +201,7 @@ public ItemStack getSubstituteStack(ItemStack boundStack, int stability, int aff int number = enchantValues[i]; if (number >= 2 && i + 1 >= size) { int[] newEnchantValues = new int[i + 2]; - for (int z = 0; z < enchantValues.length; z++) { - newEnchantValues[z] = enchantValues[z]; - } + System.arraycopy(enchantValues, 0, newEnchantValues, 0, enchantValues.length); enchantValues = newEnchantValues; enchantValues[i + 1] += number / 2; @@ -226,18 +213,8 @@ public ItemStack getSubstituteStack(ItemStack boundStack, int stability, int aff newEnchantList.add(new EnchantmentData(ench, enchantValues.length - 1)); } - Iterator iterator = newEnchantList.iterator(); - - while (iterator.hasNext()) { - EnchantmentData enchantmentdata = (EnchantmentData) iterator.next(); - - { - omegaStack.addEnchantment(enchantmentdata.enchantmentobj, enchantmentdata.enchantmentLevel); - } - } - - for (int i = 0; i < 1; i++) { - // omegaStack = EnchantmentHelper.addRandomEnchantment(new Random(), omegaStack, 30); + for (EnchantmentData enchantmentdata : newEnchantList) { + omegaStack.addEnchantment(enchantmentdata.enchantmentobj, enchantmentdata.enchantmentLevel); } return omegaStack; } @@ -266,9 +243,8 @@ public ItemStack getContainedArmourStack(ItemStack omegaStack) { } NBTTagCompound tag = omegaTag.getCompoundTag("armour"); - ItemStack armourStack = ItemStack.loadItemStackFromNBT(tag); - return armourStack; + return ItemStack.loadItemStackFromNBT(tag); } @Override @@ -294,54 +270,55 @@ public String getArmorTexture(ItemStack stack, Entity entity, int slot, String t @Override @SideOnly(Side.CLIENT) public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { - if (tryComplexRendering) { - int type = ((ItemArmor) itemStack.getItem()).armorType; - if (this.model1 == null) { - this.model1 = getChestModel(); - } - if (this.model2 == null) { - this.model2 = getLegsModel(); - } + ItemArmor item = (ItemArmor) itemStack.getItem(); + if (!tryComplexRendering || item == null) { + return super.getArmorModel(entityLiving, itemStack, armorSlot); + } + int type = item.armorType; + if (this.model1 == null) { + this.model1 = getChestModel(); + } + if (this.model2 == null) { + this.model2 = getLegsModel(); + } - if (type == 1 || type == 3 || type == 0) { - this.model = model1; - } else { - this.model = model2; - } + if (type == 1 || type == 3 || type == 0) { + this.model = model1; + } else { + this.model = model2; + } - if (this.model != null) { - this.model.bipedHead.showModel = (type == 0); - this.model.bipedHeadwear.showModel = (type == 0); - this.model.bipedBody.showModel = ((type == 1) || (type == 2)); - this.model.bipedLeftArm.showModel = (type == 1); - this.model.bipedRightArm.showModel = (type == 1); - this.model.bipedLeftLeg.showModel = (type == 2 || type == 3); - this.model.bipedRightLeg.showModel = (type == 2 || type == 3); - this.model.isSneak = entityLiving.isSneaking(); - - this.model.isRiding = entityLiving.isRiding(); - this.model.isChild = entityLiving.isChild(); - - this.model.aimedBow = false; - this.model.heldItemRight = (entityLiving.getHeldItem() != null ? 1 : 0); - - if ((entityLiving instanceof EntityPlayer)) { - if (((EntityPlayer) entityLiving).getItemInUseDuration() > 0) { - EnumAction enumaction = ((EntityPlayer) entityLiving).getItemInUse().getItemUseAction(); - if (enumaction == EnumAction.block) { - this.model.heldItemRight = 3; - } else if (enumaction == EnumAction.bow) { - this.model.aimedBow = true; - } - } + if (this.model == null) { + return model; + } + this.model.bipedHead.showModel = (type == 0); + this.model.bipedHeadwear.showModel = (type == 0); + this.model.bipedBody.showModel = ((type == 1) || (type == 2)); + this.model.bipedLeftArm.showModel = (type == 1); + this.model.bipedRightArm.showModel = (type == 1); + this.model.bipedLeftLeg.showModel = (type == 2 || type == 3); + this.model.bipedRightLeg.showModel = (type == 2 || type == 3); + this.model.isSneak = entityLiving.isSneaking(); + + this.model.isRiding = entityLiving.isRiding(); + this.model.isChild = entityLiving.isChild(); + + this.model.aimedBow = false; + this.model.heldItemRight = (entityLiving.getHeldItem() != null ? 1 : 0); + + if ((entityLiving instanceof EntityPlayer player)) { + if (player.getItemInUseDuration() > 0) { + EnumAction enumaction = player.getItemInUse().getItemUseAction(); + if (enumaction == EnumAction.block) { + this.model.heldItemRight = 3; + } else if (enumaction == EnumAction.bow) { + this.model.aimedBow = true; } } + } - return model; + return model; - } else { - return super.getArmorModel(entityLiving, itemStack, armorSlot); - } } public void onOmegaKeyPressed(EntityPlayer player, ItemStack stack) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourEarth.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourEarth.java index cd4a8daedb..ba89847572 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourEarth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourEarth.java @@ -66,7 +66,7 @@ public void registerIcons(IIconRegister iconRegister) { @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { + public IIcon getIconFromDamage(int meta) { if (this.equals(ModItems.boundHelmetEarth)) { return this.helmetIcon; } @@ -87,26 +87,30 @@ public IIcon getIconFromDamage(int par1) { } @Override - public Multimap getAttributeModifiers(ItemStack stack) { - Multimap map = HashMultimap.create(); + public Multimap getAttributeModifiers(ItemStack stack) { + Multimap map = HashMultimap.create(); int yLevel = this.getYLevelStored(stack); map.put( SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), - new AttributeModifier(new UUID(179618 - /** Random number **/ - , armorType), "Knockback modifier" + armorType, getKnockbackResist(), 0)); - map.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(80532 - /** Random number **/ - , armorType), - "Health modifier" + armorType, - getDefaultArmourBoost() * getHealthBoostModifierForLevel(yLevel), - 1)); - map.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(85112 - /** Random number **/ - , armorType), - "Damage modifier" + armorType, - getDefaultArmourBoost() * getDamageModifierForLevel(yLevel), - 2)); + new AttributeModifier( + new UUID(179618, armorType), // Random number + "Knockback modifier" + armorType, + getKnockbackResist(), + 0)); + map.put( + SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), + new AttributeModifier( + new UUID(80532, armorType), // Random number + "Health modifier" + armorType, + getDefaultArmourBoost() * getHealthBoostModifierForLevel(yLevel), + 1)); + map.put( + SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), + new AttributeModifier( + new UUID(85112, armorType), // Random number + "Damage modifier" + armorType, + getDefaultArmourBoost() * getDamageModifierForLevel(yLevel), + 2)); return map; } @@ -116,17 +120,13 @@ public float getKnockbackResist() { } public float getDefaultArmourBoost() { - switch (this.armorType) { - case 0: - return 2.5f; - case 1: - return 4; - case 2: - return 3.5f; - case 3: - return 2; - } - return 0.25f; + return switch (this.armorType) { + case 0 -> 2.5f; + case 1 -> 4; + case 2 -> 3.5f; + case 3 -> 2; + default -> 0.25f; + }; } public float getHealthBoostModifierForLevel(int yLevel) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourFire.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourFire.java index ad36eccf21..12e8ecaa7a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourFire.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourFire.java @@ -69,7 +69,7 @@ public void registerIcons(IIconRegister iconRegister) { @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { + public IIcon getIconFromDamage(int meta) { if (this.equals(ModItems.boundHelmetFire)) { return this.helmetIcon; } @@ -90,24 +90,22 @@ public IIcon getIconFromDamage(int par1) { } @Override - public Multimap getAttributeModifiers(ItemStack stack) { - Multimap map = HashMultimap.create(); + public Multimap getAttributeModifiers(ItemStack stack) { + Multimap map = HashMultimap.create(); int biomeID = this.getBiomeIDStored(stack); BiomeGenBase biome = BiomeGenBase.getBiome(biomeID); if (biome != null) { map.put( SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), - new AttributeModifier(new UUID(895132 - /** Random number **/ - , armorType), + new AttributeModifier( + new UUID(895132, armorType), // Random number "Health modifier" + armorType, getDefaultArmourBoost() * getHealthBoostModifierForBiome(biome), 1)); map.put( SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), - new AttributeModifier(new UUID(196312 - /** Random number **/ - , armorType), + new AttributeModifier( + new UUID(196312, armorType), // Random number "Damage modifier" + armorType, getDefaultArmourBoost() * getDamageModifierForBiome(biome), 1)); @@ -116,17 +114,13 @@ public Multimap getAttributeModifiers(ItemStack stack) { } public float getDefaultArmourBoost() { - switch (this.armorType) { - case 0: - return 2.5f; - case 1: - return 4; - case 2: - return 3.5f; - case 3: - return 2; - } - return 0.25f; + return switch (this.armorType) { + case 0 -> 2.5f; + case 1 -> 4; + case 2 -> 3.5f; + case 3 -> 2; + default -> 0.25f; + }; } public float getHealthBoostModifierForBiome(BiomeGenBase biome) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWater.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWater.java index 02030b0b0a..67dda4322b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWater.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWater.java @@ -4,7 +4,6 @@ import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.item.ItemStack; @@ -38,11 +37,6 @@ public OmegaArmourWater(int armorType) { this.storeBiomeID = true; } - @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { - return "alchemicalwizardry:models/armor/OmegaWater.png"; - } - @Override @SideOnly(Side.CLIENT) public ModelBiped getChestModel() { @@ -67,7 +61,7 @@ public void registerIcons(IIconRegister iconRegister) { @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { + public IIcon getIconFromDamage(int meta) { if (this.equals(ModItems.boundHelmetWater)) { return this.helmetIcon; } @@ -88,24 +82,22 @@ public IIcon getIconFromDamage(int par1) { } @Override - public Multimap getAttributeModifiers(ItemStack stack) { - Multimap map = HashMultimap.create(); + public Multimap getAttributeModifiers(ItemStack stack) { + Multimap map = HashMultimap.create(); int biomeID = this.getBiomeIDStored(stack); BiomeGenBase biome = BiomeGenBase.getBiome(biomeID); if (biome != null) { map.put( SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), - new AttributeModifier(new UUID(85312 - /** Random number **/ - , armorType), + new AttributeModifier( + new UUID(85312, armorType), // Random number "Health modifier" + armorType, getDefaultArmourBoost() * getHealthBoostModifierForBiome(biome), 2)); map.put( SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), - new AttributeModifier(new UUID(85432 - /** Random number **/ - , armorType), + new AttributeModifier( + new UUID(85432, armorType), // Random number "Damage modifier" + armorType, getDefaultArmourBoost() * getDamageModifierForBiome(biome), 2)); @@ -114,17 +106,13 @@ public Multimap getAttributeModifiers(ItemStack stack) { } public float getDefaultArmourBoost() { - switch (this.armorType) { - case 0: - return 2.5f; - case 1: - return 4; - case 2: - return 3.5f; - case 3: - return 2; - } - return 0.25f; + return switch (this.armorType) { + case 0 -> 2.5f; + case 1 -> 4; + case 2 -> 3.5f; + case 3 -> 2; + default -> 0.25f; + }; } public float getHealthBoostModifierForBiome(BiomeGenBase biome) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWind.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWind.java index 8a5d26043b..74ec58a905 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWind.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/armour/OmegaArmourWind.java @@ -66,7 +66,7 @@ public void registerIcons(IIconRegister iconRegister) { @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { + public IIcon getIconFromDamage(int meta) { if (this.equals(ModItems.boundHelmetWind)) { return this.helmetIcon; } @@ -87,37 +87,35 @@ public IIcon getIconFromDamage(int par1) { } @Override - public Multimap getAttributeModifiers(ItemStack stack) { - Multimap map = HashMultimap.create(); + public Multimap getAttributeModifiers(ItemStack stack) { + Multimap map = HashMultimap.create(); int yLevel = this.getYLevelStored(stack); - map.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(85212 - /** Random number **/ - , armorType), - "Health modifier" + armorType, - getDefaultArmourBoost() * getHealthBoostModifierForLevel(yLevel), - 1)); - map.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(86212 - /** Random number **/ - , armorType), - "Damage modifier" + armorType, - getDefaultArmourBoost() * getDamageModifierForLevel(yLevel), - 2)); + map.put( + SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), + new AttributeModifier( + new UUID(85212, armorType), // Random number + "Health modifier" + armorType, + getDefaultArmourBoost() * getHealthBoostModifierForLevel(yLevel), + 1)); + map.put( + SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), + new AttributeModifier( + new UUID(86212, armorType), // Random number + "Damage modifier" + armorType, + getDefaultArmourBoost() * getDamageModifierForLevel(yLevel), + 2)); return map; } public float getDefaultArmourBoost() { - switch (this.armorType) { - case 0: - return 2.5f; - case 1: - return 4; - case 2: - return 3.5f; - case 3: - return 2; - } - return 0.25f; + return switch (this.armorType) { + case 0 -> 2.5f; + case 1 -> 4; + case 2 -> 3.5f; + case 3 -> 2; + default -> 0.25f; + }; } public float getHealthBoostModifierForLevel(int yLevel) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/energy/ItemAttunedCrystal.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/energy/ItemAttunedCrystal.java index 05bec57464..12bb3b580c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/energy/ItemAttunedCrystal.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/energy/ItemAttunedCrystal.java @@ -50,37 +50,32 @@ public String getItemStackDisplayName(ItemStack stack) { String name = super.getItemStackDisplayName(stack); if (reagent != null) { - name = name + " (" + reagent.name + ")"; + name = name + " (" + reagent.name() + ")"; } return name; } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.attunedcrystal.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.attunedcrystal.desc2")); - - if (!(par1ItemStack.getTagCompound() == null)) { - Reagent reagent = this.getReagent(par1ItemStack); - if (reagent != null) { - par3List.add(StatCollector.translateToLocal("tooltip.reagent.selectedreagent") + " " + reagent.name); - } + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.attunedcrystal.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.attunedcrystal.desc2")); - if (this.getHasSavedCoordinates(par1ItemStack)) { - par3List.add(""); - Int3 coords = this.getCoordinates(par1ItemStack); - par3List.add( - StatCollector.translateToLocal("tooltip.alchemy.coords") + " " - + coords.xCoord - + ", " - + coords.yCoord - + ", " - + coords.zCoord); - par3List.add( - StatCollector.translateToLocal("tooltip.alchemy.dimension") + " " - + getDimension(par1ItemStack)); - } + if (item.getTagCompound() == null) { + return; + } + Reagent reagent = this.getReagent(item); + if (reagent != null) { + tooltip.add(StatCollector.translateToLocal("tooltip.reagent.selectedreagent") + " " + reagent.name()); + } + + if (this.getHasSavedCoordinates(item)) { + tooltip.add(""); + Int3 coords = this.getCoordinates(item); + tooltip.add( + StatCollector.translateToLocal( + "tooltip.alchemy.coords") + " " + coords.x() + ", " + coords.y() + ", " + coords.z()); + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.dimension") + " " + getDimension(item)); } } @@ -100,8 +95,7 @@ public int getColorFromItemStack(ItemStack stack, int pass) { case 1: Reagent reagent = this.getReagent(stack); if (reagent != null) { - return (reagent.getColourRed() * 256 * 256 + reagent.getColourGreen() * 256 - + reagent.getColourBlue()); + return (reagent.red() * 256 * 256 + reagent.green() * 256 + reagent.blue()); } break; } @@ -154,31 +148,18 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof IReagentHandler)) { + if (!(tile instanceof IReagentHandler relay)) { return itemStack; } - IReagentHandler relay = (IReagentHandler) tile; - if (player.isSneaking()) { ReagentContainerInfo[] infos = relay.getContainerInfo(ForgeDirection.UNKNOWN); if (infos != null) { - List reagentList = new LinkedList(); - for (ReagentContainerInfo info : infos) { - if (info != null) { - ReagentStack reagentStack = info.reagent; - if (reagentStack != null) { - Reagent reagent = reagentStack.reagent; - if (reagent != null) { - reagentList.add(reagent); - } - } - } - } + List reagentList = getReagents(infos); Reagent pastReagent = this.getReagent(itemStack); - if (reagentList.size() <= 0) { + if (reagentList.isEmpty()) { return itemStack; } @@ -187,7 +168,7 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer reagentLocation = reagentList.indexOf(pastReagent); if (reagentLocation == -1 || reagentLocation + 1 >= reagentList.size()) { - this.setReagentWithNotification(itemStack, reagentList.get(0), player); + this.setReagentWithNotification(itemStack, reagentList.getFirst(), player); } else { this.setReagentWithNotification(itemStack, reagentList.get(reagentLocation + 1), player); } @@ -201,16 +182,16 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer return itemStack; } - if (dimension != world.provider.dimensionId || Math.abs(coords.xCoord - x) > maxDistance - || Math.abs(coords.yCoord - y) > maxDistance - || Math.abs(coords.zCoord - z) > maxDistance) { + if (dimension != world.provider.dimensionId || Math.abs(coords.x() - x) > maxDistance + || Math.abs(coords.y() - y) > maxDistance + || Math.abs(coords.z() - z) > maxDistance) { player.addChatComponentMessage( new ChatComponentTranslation("message.attunedcrystal.error.toofar")); return itemStack; } - TileEntity pastTile = world.getTileEntity(coords.xCoord, coords.yCoord, coords.zCoord); - if (!(pastTile instanceof TEReagentConduit)) { + TileEntity pastTile = world.getTileEntity(coords.x(), coords.y(), coords.z()); + if (!(pastTile instanceof TEReagentConduit pastRelay)) { player.addChatComponentMessage( new ChatComponentTranslation("message.attunedcrystal.error.cannotfind")); return itemStack; @@ -222,8 +203,6 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer return itemStack; } - TEReagentConduit pastRelay = (TEReagentConduit) pastTile; - if (player.isSneaking()) { pastRelay.removeReagentDestinationViaActual(reagent, x, y, z); } else { @@ -231,13 +210,13 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player.addChatComponentMessage( new ChatComponentText( StatCollector.translateToLocal("message.attunedcrystal.linked") + " " - + reagent.name)); + + reagent.name())); } else { player.addChatComponentMessage( new ChatComponentTranslation("message.attunedcrystal.error.noconnections")); } } - world.markBlockForUpdate(coords.xCoord, coords.yCoord, coords.zCoord); + world.markBlockForUpdate(coords.x(), coords.y(), coords.z()); } else { int dimension = world.provider.dimensionId; @@ -253,6 +232,22 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer return itemStack; } + public static List getReagents(ReagentContainerInfo[] infos) { + List reagentList = new LinkedList<>(); + for (ReagentContainerInfo info : infos) { + if (info != null) { + ReagentStack reagentStack = info.reagent; + if (reagentStack != null) { + Reagent reagent = reagentStack.reagent; + if (reagent != null) { + reagentList.add(reagent); + } + } + } + } + return reagentList; + } + public void setCoordinates(ItemStack stack, Int3 coords) { if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); @@ -341,7 +336,7 @@ public void setReagentWithNotification(ItemStack stack, Reagent reagent, EntityP if (reagent != null) { player.addChatComponentMessage( new ChatComponentText( - StatCollector.translateToLocal("message.attunedcrystal.setto") + " " + reagent.name)); + StatCollector.translateToLocal("message.attunedcrystal.setto") + " " + reagent.name())); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/energy/ItemDestinationClearer.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/energy/ItemDestinationClearer.java index 7f80604b12..94bb4981ea 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/energy/ItemDestinationClearer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/energy/ItemDestinationClearer.java @@ -33,9 +33,9 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.destclearer.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.destclearer.desc2")); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.destclearer.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.destclearer.desc2")); } @Override @@ -48,24 +48,21 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer if (movingobjectposition == null) { return itemStack; - } else { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - int x = movingobjectposition.blockX; - int y = movingobjectposition.blockY; - int z = movingobjectposition.blockZ; - - TileEntity tile = world.getTileEntity(x, y, z); + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int x = movingobjectposition.blockX; + int y = movingobjectposition.blockY; + int z = movingobjectposition.blockZ; - if (!(tile instanceof TEReagentConduit)) { - return itemStack; - } + TileEntity tile = world.getTileEntity(x, y, z); - TEReagentConduit relay = (TEReagentConduit) tile; + if (!(tile instanceof TEReagentConduit relay)) { + return itemStack; + } - relay.reagentTargetList.clear(); + relay.reagentTargetList.clear(); - player.addChatComponentMessage(new ChatComponentTranslation("message.destinationclearer.cleared")); - } + player.addChatComponentMessage(new ChatComponentTranslation("message.destinationclearer.cleared")); } return itemStack; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/energy/ItemTankSegmenter.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/energy/ItemTankSegmenter.java index 88c81296b1..5cd5e2ee77 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/energy/ItemTankSegmenter.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/energy/ItemTankSegmenter.java @@ -1,6 +1,5 @@ package WayofTime.alchemicalWizardry.common.items.energy; -import java.util.LinkedList; import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; @@ -21,7 +20,6 @@ import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent; import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo; import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry; -import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack; import WayofTime.alchemicalWizardry.api.items.interfaces.IReagentManipulator; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -46,20 +44,20 @@ public String getItemStackDisplayName(ItemStack stack) { Reagent reagent = this.getReagent(stack); String name = super.getItemStackDisplayName(stack); if (reagent != null) { - name = name + " (" + reagent.name + ")"; + name += " (" + reagent.name() + ")"; } return name; } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.tanksegmenter.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.tanksegmenter.desc2")); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.tanksegmenter.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.tanksegmenter.desc2")); - if (!(par1ItemStack.getTagCompound() == null)) { - Reagent reagent = this.getReagent(par1ItemStack); + if (item.getTagCompound() != null) { + Reagent reagent = this.getReagent(item); if (reagent != null) { - par3List.add(StatCollector.translateToLocal("tooltip.reagent.selectedreagent") + " " + reagent.name); + tooltip.add(StatCollector.translateToLocal("tooltip.reagent.selectedreagent") + " " + reagent.name()); } } } @@ -80,8 +78,7 @@ public int getColorFromItemStack(ItemStack stack, int pass) { case 1: Reagent reagent = this.getReagent(stack); if (reagent != null) { - return (reagent.getColourRed() * 256 * 256 + reagent.getColourGreen() * 256 - + reagent.getColourBlue()); + return (reagent.red() * 256 * 256 + reagent.green() * 256 + reagent.blue()); } break; } @@ -126,26 +123,14 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer int y = movingobjectposition.blockY; int z = movingobjectposition.blockZ; TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof ISegmentedReagentHandler)) { + if (!(tile instanceof ISegmentedReagentHandler reagentHandler)) { return itemStack; } - ISegmentedReagentHandler reagentHandler = (ISegmentedReagentHandler) tile; if (player.isSneaking()) { ReagentContainerInfo[] infos = reagentHandler.getContainerInfo(ForgeDirection.UNKNOWN); if (infos != null) { - List reagentList = new LinkedList(); - for (ReagentContainerInfo info : infos) { - if (info != null) { - ReagentStack reagentStack = info.reagent; - if (reagentStack != null) { - Reagent reagent = reagentStack.reagent; - if (reagent != null) { - reagentList.add(reagent); - } - } - } - } + List reagentList = ItemAttunedCrystal.getReagents(infos); Reagent pastReagent = this.getReagent(itemStack); boolean goForNext = false; boolean hasFound = false; @@ -165,7 +150,7 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer this.setReagentWithNotification(itemStack, reagentList.get(0), player); } } else { - if (reagentList.size() >= 1) { + if (!reagentList.isEmpty()) { this.setReagentWithNotification(itemStack, reagentList.get(0), player); } } @@ -191,7 +176,7 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer + " " + StatCollector.translateToLocal("message.tanksegmenter.tankssetto") + " " - + reagent.name)); + + reagent.name())); reagentHandler.setTanksTunedToReagent(reagent, numberAssigned); } @@ -229,7 +214,7 @@ public void setReagentWithNotification(ItemStack stack, Reagent reagent, EntityP if (reagent != null) { player.addChatComponentMessage( new ChatComponentText( - StatCollector.translateToLocal("message.tanksegmenter.setto") + " " + reagent.name)); + StatCollector.translateToLocal("message.tanksegmenter.setto") + " " + reagent.name())); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/AlchemyFlask.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/AlchemyFlask.java index 3349aa4d66..d9d90d157a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/AlchemyFlask.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/AlchemyFlask.java @@ -3,7 +3,6 @@ import static WayofTime.alchemicalWizardry.AlchemicalWizardry.allowPotionRepair; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -49,43 +48,40 @@ public void registerIcons(IIconRegister iconRegister) { this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:PotionFlask"); } - public static ArrayList getEffects(ItemStack par1ItemStack) { - if (par1ItemStack.hasTagCompound() && par1ItemStack.getTagCompound().hasKey("CustomFlaskEffects")) { - ArrayList arraylist = new ArrayList(); - NBTTagList nbttaglist = par1ItemStack.getTagCompound() - .getTagList("CustomFlaskEffects", Constants.NBT.TAG_COMPOUND); - - for (int i = 0; i < nbttaglist.tagCount(); ++i) { - NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); - arraylist.add(AlchemyPotionHelper.readEffectFromNBT(nbttagcompound)); - } - return arraylist; - } else { + public static ArrayList getEffects(ItemStack item) { + if (!item.hasTagCompound() || !item.getTagCompound().hasKey("CustomFlaskEffects")) { return null; } - } + ArrayList arraylist = new ArrayList<>(); + NBTTagList nbttaglist = item.getTagCompound().getTagList("CustomFlaskEffects", Constants.NBT.TAG_COMPOUND); - public static ArrayList getPotionEffects(ItemStack par1ItemStack) { - ArrayList list = AlchemyFlask.getEffects(par1ItemStack); + for (int i = 0; i < nbttaglist.tagCount(); ++i) { + NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); + arraylist.add(AlchemyPotionHelper.readEffectFromNBT(nbttagcompound)); + } + return arraylist; + } - if (list != null) { - ArrayList newList = new ArrayList(); + public static ArrayList getPotionEffects(ItemStack item) { + ArrayList list = AlchemyFlask.getEffects(item); - for (AlchemyPotionHelper aph : list) { - newList.add(aph.getPotionEffect()); - } - - return newList; - } else { + if (list == null) { return null; } + ArrayList newList = new ArrayList<>(); + + for (AlchemyPotionHelper aph : list) { + newList.add(aph.getPotionEffect()); + } + + return newList; } - public static void setEffects(ItemStack par1ItemStack, List list) { - NBTTagCompound itemTag = par1ItemStack.getTagCompound(); + public static void setEffects(ItemStack item, List list) { + NBTTagCompound itemTag = item.getTagCompound(); if (itemTag == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); + item.setTagCompound(new NBTTagCompound()); } NBTTagList nbttaglist = new NBTTagList(); @@ -94,44 +90,48 @@ public static void setEffects(ItemStack par1ItemStack, List nbttaglist.appendTag(AlchemyPotionHelper.setEffectToNBT(aph)); } - par1ItemStack.getTagCompound().setTag("CustomFlaskEffects", nbttaglist); + item.getTagCompound().setTag("CustomFlaskEffects", nbttaglist); } - public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!par3EntityPlayer.capabilities.isCreativeMode) { - par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() + 1); + @Override + public ItemStack onEaten(ItemStack item, World world, EntityPlayer player) { + if (!player.capabilities.isCreativeMode) { + item.setItemDamage(item.getItemDamage() + 1); } - if (!par2World.isRemote) { - ArrayList list = getEffects(par1ItemStack); + if (world.isRemote) { + return item; + } - if (list != null) { - for (AlchemyPotionHelper aph : list) { - PotionEffect pe = aph.getPotionEffect(); + ArrayList list = getEffects(item); + if (list == null) { + return item; + } + for (AlchemyPotionHelper aph : list) { + PotionEffect pe = aph.getPotionEffect(); - if (pe != null) { - // if(pe.get) - par3EntityPlayer.addPotionEffect(pe); - } - } + if (pe != null) { + player.addPotionEffect(pe); } } - return par1ItemStack; + return item; } /** * How long it takes to use or consume an item */ - public int getMaxItemUseDuration(ItemStack par1ItemStack) { + @Override + public int getMaxItemUseDuration(ItemStack item) { return 32; } /** * returns the action that specifies what animation to play when the items is being used */ - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - if (this.isPotionThrowable(par1ItemStack)) { + @Override + public EnumAction getItemUseAction(ItemStack item) { + if (this.isPotionThrowable(item)) { return EnumAction.none; } @@ -141,32 +141,33 @@ public EnumAction getItemUseAction(ItemStack par1ItemStack) { /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (par1ItemStack.getItemDamage() < par1ItemStack.getMaxDamage()) { - if (this.isPotionThrowable(par1ItemStack)) { - if (!par2World.isRemote) { - EntityPotion entityPotion = this.getEntityPotion(par1ItemStack, par2World, par3EntityPlayer); + @Override + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (item.getItemDamage() < item.getMaxDamage()) { + if (this.isPotionThrowable(item)) { + if (!world.isRemote) { + EntityPotion entityPotion = this.getEntityPotion(item, world, player); if (entityPotion != null) { float velocityChange = 2.0f; entityPotion.motionX *= velocityChange; entityPotion.motionY *= velocityChange; entityPotion.motionZ *= velocityChange; - par2World.spawnEntityInWorld(entityPotion); - par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() + 1); + world.spawnEntityInWorld(entityPotion); + item.setItemDamage(item.getItemDamage() + 1); } } - return par1ItemStack; + return item; } - par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); + player.setItemInUse(item, this.getMaxItemUseDuration(item)); } - return par1ItemStack; + return item; } - public void setConcentrationOfPotion(ItemStack par1ItemStack, int potionID, int concentration) { - ArrayList list = getEffects(par1ItemStack); + public void setConcentrationOfPotion(ItemStack item, int potionID, int concentration) { + ArrayList list = getEffects(item); if (list != null) { for (AlchemyPotionHelper aph : list) { if (aph.getPotionID() == potionID) { @@ -174,12 +175,12 @@ public void setConcentrationOfPotion(ItemStack par1ItemStack, int potionID, int break; } } - setEffects(par1ItemStack, list); + setEffects(item, list); } } - public void setDurationFactorOfPotion(ItemStack par1ItemStack, int potionID, int durationFactor) { - ArrayList list = getEffects(par1ItemStack); + public void setDurationFactorOfPotion(ItemStack item, int potionID, int durationFactor) { + ArrayList list = getEffects(item); if (list != null) { for (AlchemyPotionHelper aph : list) { if (aph.getPotionID() == potionID) { @@ -187,78 +188,65 @@ public void setDurationFactorOfPotion(ItemStack par1ItemStack, int potionID, int break; } } - setEffects(par1ItemStack, list); + setEffects(item, list); } } - public boolean hasPotionEffect(ItemStack par1ItemStack, int potionID) { - return false; - } - - public int getNumberOfPotionEffects(ItemStack par1ItemStack) { - if (getEffects(par1ItemStack) != null) { - return getEffects(par1ItemStack).size(); + public int getNumberOfPotionEffects(ItemStack item) { + ArrayList effects = getEffects(item); + if (effects != null) { + return effects.size(); } else { return 0; } } - public boolean addPotionEffect(ItemStack par1ItemStack, int potionID, int tickDuration) { - ArrayList list = getEffects(par1ItemStack); + public boolean addPotionEffect(ItemStack item, int potionID, int tickDuration) { + ArrayList list = getEffects(item); if (list != null) { for (AlchemyPotionHelper aph : list) { if (aph.getPotionID() == potionID) { return false; } } - list.add(new AlchemyPotionHelper(potionID, tickDuration, 0, 0)); - setEffects(par1ItemStack, list); - return true; } else { - list = new ArrayList(); - list.add(new AlchemyPotionHelper(potionID, tickDuration, 0, 0)); - setEffects(par1ItemStack, list); - return true; + list = new ArrayList<>(); } + list.add(new AlchemyPotionHelper(potionID, tickDuration, 0, 0)); + setEffects(item, list); + return true; } - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add( + @Override + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add( EnumChatFormatting.BLUE + StatCollector.translateToLocal("tooltip.alchemyflask.swigsleft") + " " - + (par1ItemStack.getMaxDamage() - par1ItemStack.getItemDamage()) + + (item.getMaxDamage() - item.getItemDamage()) + "/" - + par1ItemStack.getMaxDamage()); + + item.getMaxDamage()); - if (this.isPotionThrowable(par1ItemStack)) { - par3List.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal("tooltip.alchemyflask.caution")); + if (this.isPotionThrowable(item)) { + tooltip.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal("tooltip.alchemyflask.caution")); } - List list1 = AlchemyFlask.getPotionEffects(par1ItemStack); - HashMultimap hashmultimap = HashMultimap.create(); - Iterator iterator; - - if (list1 != null && !list1.isEmpty()) { - iterator = list1.iterator(); + List effects = AlchemyFlask.getPotionEffects(item); + HashMultimap hashmultimap = HashMultimap.create(); - while (iterator.hasNext()) { - PotionEffect potioneffect = (PotionEffect) iterator.next(); + if (effects != null && !effects.isEmpty()) { + for (PotionEffect potioneffect : effects) { String s = StatCollector.translateToLocal(potioneffect.getEffectName()).trim(); Potion potion = Potion.potionTypes[potioneffect.getPotionID()]; - Map map = potion.func_111186_k(); - - if (map != null && map.size() > 0) { - Iterator iterator1 = map.entrySet().iterator(); + Map map = potion.func_111186_k(); - while (iterator1.hasNext()) { - Entry entry = (Entry) iterator1.next(); - AttributeModifier attributemodifier = (AttributeModifier) entry.getValue(); + if (map != null && !map.isEmpty()) { + for (Entry entry : map.entrySet()) { + AttributeModifier attributemodifier = entry.getValue(); AttributeModifier attributemodifier1 = new AttributeModifier( attributemodifier.getName(), potion.func_111183_a(potioneffect.getAmplifier(), attributemodifier), attributemodifier.getOperation()); - hashmultimap - .put(((IAttribute) entry.getKey()).getAttributeUnlocalizedName(), attributemodifier1); + hashmultimap.put(entry.getKey().getAttributeUnlocalizedName(), attributemodifier1); } } @@ -272,24 +260,22 @@ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlaye } if (potion.isBadEffect()) { - par3List.add(EnumChatFormatting.RED + s); + tooltip.add(EnumChatFormatting.RED + s); } else { - par3List.add(EnumChatFormatting.GRAY + s); + tooltip.add(EnumChatFormatting.GRAY + s); } } } else { String s1 = StatCollector.translateToLocal("potion.empty").trim(); - par3List.add(EnumChatFormatting.GRAY + s1); + tooltip.add(EnumChatFormatting.GRAY + s1); } if (!hashmultimap.isEmpty()) { - par3List.add(""); - par3List.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("potion.effects.whenDrank")); - iterator = hashmultimap.entries().iterator(); + tooltip.add(""); + tooltip.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("potion.effects.whenDrank")); - while (iterator.hasNext()) { - Entry entry1 = (Entry) iterator.next(); - AttributeModifier attributemodifier2 = (AttributeModifier) entry1.getValue(); + for (Entry stringAttributeModifierEntry : hashmultimap.entries()) { + AttributeModifier attributemodifier2 = stringAttributeModifierEntry.getValue(); double d0 = attributemodifier2.getAmount(); double d1; @@ -300,39 +286,39 @@ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlaye } if (d0 > 0.0D) { - par3List.add( + tooltip.add( EnumChatFormatting.BLUE + StatCollector.translateToLocalFormatted( "attribute.modifier.plus." + attributemodifier2.getOperation(), - new Object[] { ItemStack.field_111284_a.format(d1), StatCollector - .translateToLocal("attribute.name." + (String) entry1.getKey()) })); + new Object[] { ItemStack.field_111284_a.format(d1), StatCollector.translateToLocal( + "attribute.name." + stringAttributeModifierEntry.getKey()) })); } else if (d0 < 0.0D) { d1 *= -1.0D; - par3List.add( + tooltip.add( EnumChatFormatting.RED + StatCollector.translateToLocalFormatted( "attribute.modifier.take." + attributemodifier2.getOperation(), - new Object[] { ItemStack.field_111284_a.format(d1), StatCollector - .translateToLocal("attribute.name." + (String) entry1.getKey()) })); + new Object[] { ItemStack.field_111284_a.format(d1), StatCollector.translateToLocal( + "attribute.name." + stringAttributeModifierEntry.getKey()) })); } } } } - public boolean isPotionThrowable(ItemStack par1ItemStack) { - return par1ItemStack.hasTagCompound() && par1ItemStack.getTagCompound().getBoolean("throwable"); + public boolean isPotionThrowable(ItemStack item) { + return item.hasTagCompound() && item.getTagCompound().getBoolean("throwable"); } - public void setIsPotionThrowable(boolean flag, ItemStack par1ItemStack) { - if (!par1ItemStack.hasTagCompound()) { - par1ItemStack.setTagCompound(new NBTTagCompound()); + public void setIsPotionThrowable(boolean flag, ItemStack item) { + if (!item.hasTagCompound()) { + item.setTagCompound(new NBTTagCompound()); } - par1ItemStack.getTagCompound().setBoolean("throwable", flag); + item.getTagCompound().setBoolean("throwable", flag); } - public EntityPotion getEntityPotion(ItemStack par1ItemStack, World worldObj, EntityLivingBase entityLivingBase) { + public EntityPotion getEntityPotion(ItemStack item, World worldObj, EntityLivingBase entityLivingBase) { ItemStack potionStack = new ItemStack(Items.potionitem, 1, 0); potionStack.setTagCompound(new NBTTagCompound()); - ArrayList potionList = getPotionEffects(par1ItemStack); + ArrayList potionList = getPotionEffects(item); if (potionList == null) { return null; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/AlchemyReagent.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/AlchemyReagent.java index 39071670f8..a44e329493 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/AlchemyReagent.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/AlchemyReagent.java @@ -66,8 +66,7 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, - boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.alchemy.usedinalchemy")); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.usedinalchemy")); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/EnhancedFillingAgent.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/EnhancedFillingAgent.java index ad0a988eaa..df0250c5b6 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/EnhancedFillingAgent.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/EnhancedFillingAgent.java @@ -29,10 +29,7 @@ public int getFilledAmountForPotionNumber(int potionEffects) { case 3: return 3; - case 4: - return 2; - - case 5: + case 4, 5: return 2; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/LengtheningCatalyst.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/LengtheningCatalyst.java index 298066183d..d831a35004 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/LengtheningCatalyst.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/LengtheningCatalyst.java @@ -12,7 +12,7 @@ public class LengtheningCatalyst extends Item implements ICatalyst { - private int catalystStrength; + private final int catalystStrength; public LengtheningCatalyst(int catalystStrength) { this.catalystStrength = catalystStrength; @@ -30,8 +30,7 @@ public boolean isConcentration() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, - boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.alchemy.usedinalchemy")); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.usedinalchemy")); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/PowerCatalyst.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/PowerCatalyst.java index dc9e34d4ed..34df4ea792 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/PowerCatalyst.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/PowerCatalyst.java @@ -12,7 +12,7 @@ public class PowerCatalyst extends Item implements ICatalyst { - private int catalystStrength; + private final int catalystStrength; public PowerCatalyst(int catalystStrength) { super(); @@ -31,8 +31,7 @@ public boolean isConcentration() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, - boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.alchemy.usedinalchemy")); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.usedinalchemy")); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/StandardBindingAgent.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/StandardBindingAgent.java index c359624e2a..dc691b61a0 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/StandardBindingAgent.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/StandardBindingAgent.java @@ -32,8 +32,7 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, - boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.alchemy.usedinalchemy")); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.usedinalchemy")); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/WeakFillingAgent.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/WeakFillingAgent.java index c334bb8a75..19c6b145a3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/WeakFillingAgent.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/potion/WeakFillingAgent.java @@ -47,8 +47,7 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, - boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.alchemy.usedinalchemy")); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.alchemy.usedinalchemy")); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/routing/OutputRoutingFocus.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/routing/OutputRoutingFocus.java index ef63cbe562..16b9b899a7 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/routing/OutputRoutingFocus.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/routing/OutputRoutingFocus.java @@ -32,16 +32,15 @@ public OutputRoutingFocus() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, - boolean par4) { - super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); - if (!(par1ItemStack.getItem() instanceof OutputRoutingFocus focus)) return; - par3List.addAll(focus.getLogic(par1ItemStack).getDescription()); - - if (!(par1ItemStack.getTagCompound() == null)) { - int limit = this.getRoutingFocusLimit(par1ItemStack); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + super.addInformation(item, player, tooltip, adv); + if (!(item.getItem() instanceof OutputRoutingFocus focus)) return; + tooltip.addAll(focus.getLogic(item).getDescription()); + + if (item.getTagCompound() != null) { + int limit = this.getRoutingFocusLimit(item); if (limit > 0) { - par3List.add(StatCollector.translateToLocal("tooltip.routingFocus.limit") + " " + limit); + tooltip.add(StatCollector.translateToLocal("tooltip.routingFocus.limit") + " " + limit); } } } @@ -56,6 +55,7 @@ public void registerIcons(IIconRegister iconRegister) { this.globalIcon = iconRegister.registerIcon("AlchemicalWizardry:OutputRoutingFocusGlobal"); } + @Override @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int damage) { return switch (damage) { @@ -95,6 +95,7 @@ public int getDefaultStackLimit(int damage) { return 0; } + @Override public int getRoutingFocusLimit(ItemStack itemStack) { if (!(itemStack.getTagCompound() == null)) { return itemStack.getTagCompound().getInteger("stackLimit"); @@ -103,6 +104,7 @@ public int getRoutingFocusLimit(ItemStack itemStack) { } } + @Override public void setRoutingFocusLimit(ItemStack itemStack, int amt) { if ((itemStack.getTagCompound() == null)) { itemStack.setTagCompound(new NBTTagCompound()); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/routing/RoutingFocus.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/routing/RoutingFocus.java index 5638605486..5bac710828 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/routing/RoutingFocus.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/routing/RoutingFocus.java @@ -74,25 +74,23 @@ public void setSetDirection(ItemStack itemStack, ForgeDirection dir) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, - boolean par4) { - par3List.add(StatCollector.translateToLocal(this.getFocusDescription())); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal(this.getFocusDescription())); - if (!(par1ItemStack.getTagCompound() == null)) { - NBTTagCompound itemTag = par1ItemStack.getTagCompound(); + if (item.getTagCompound() != null) { + NBTTagCompound itemTag = item.getTagCompound(); - par3List.add( + tooltip.add( StatCollector.translateToLocal("tooltip.alchemy.coords") + " " + itemTag.getInteger("xCoord") + ", " + itemTag.getInteger("yCoord") + ", " + itemTag.getInteger("zCoord")); - par3List.add( + tooltip.add( StatCollector.translateToLocal("tooltip.alchemy.direction") + " " + StatCollector.translateToLocal( - "message.ritual.side." - + this.getSetDirection(par1ItemStack).toString().toLowerCase())); + "message.ritual.side." + this.getSetDirection(item).toString().toLowerCase())); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilAir.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilAir.java index 103af65a14..870c35ec18 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilAir.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilAir.java @@ -23,15 +23,14 @@ public class SigilAir extends EnergyItems implements ArmourUpgrade, ISigil { public SigilAir() { super(); this.maxStackSize = 1; - // setMaxDamage(1000); setEnergyUsed(AlchemicalWizardry.sigilAirCost); setCreativeTab(AlchemicalWizardry.tabBloodMagic); } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.airsigil.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.airsigil.desc")); + addBindingInformation(item, tooltip); } @Override @@ -41,50 +40,50 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (par2World.isRemote && this.isItemUnusable(par1ItemStack)) { - return par1ItemStack; + if (world.isRemote && this.isItemUnusable(item)) { + return item; } - Vec3 vec = par3EntityPlayer.getLookVec(); + Vec3 vec = player.getLookVec(); double wantedVelocity = 1.7; - if (par3EntityPlayer.isPotionActive(AlchemicalWizardry.customPotionBoost)) { - int i = par3EntityPlayer.getActivePotionEffect(AlchemicalWizardry.customPotionBoost).getAmplifier(); + if (player.isPotionActive(AlchemicalWizardry.customPotionBoost)) { + int i = player.getActivePotionEffect(AlchemicalWizardry.customPotionBoost).getAmplifier(); wantedVelocity += (1 + i) * (0.35); } - par3EntityPlayer.motionX = vec.xCoord * wantedVelocity; - par3EntityPlayer.motionY = vec.yCoord * wantedVelocity; - par3EntityPlayer.motionZ = vec.zCoord * wantedVelocity; - par2World.playSoundEffect( - (double) ((float) par3EntityPlayer.posX + 0.5F), - (double) ((float) par3EntityPlayer.posY + 0.5F), - (double) ((float) par3EntityPlayer.posZ + 0.5F), + player.motionX = vec.xCoord * wantedVelocity; + player.motionY = vec.yCoord * wantedVelocity; + player.motionZ = vec.zCoord * wantedVelocity; + world.playSoundEffect( + (float) player.posX + 0.5F, + (float) player.posY + 0.5F, + (float) player.posZ + 0.5F, "random.fizz", 0.5F, - 2.6F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.8F); - par3EntityPlayer.fallDistance = 0; + 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + player.fallDistance = 0; - if (!par3EntityPlayer.capabilities.isCreativeMode) { - if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed())) { - if (!par2World.isRemote) { - this.setIsItemUnusable(par1ItemStack, true); + if (!player.capabilities.isCreativeMode) { + if (!EnergyItems.syphonBatteries(item, player, getEnergyUsed())) { + if (!world.isRemote) { + this.setIsItemUnusable(item, true); } } else { - if (!par2World.isRemote) { - this.setIsItemUnusable(par1ItemStack, false); + if (!world.isRemote) { + this.setIsItemUnusable(item, false); } } } else { - return par1ItemStack; + return item; } - return par1ItemStack; + return item; } public boolean isItemUnusable(ItemStack stack) { @@ -109,19 +108,16 @@ public void setIsItemUnusable(ItemStack stack, boolean bool) { @Override public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack) { - // TODO Auto-generated method stub player.fallDistance = 0; } @Override public boolean isUpgrade() { - // TODO Auto-generated method stub return true; } @Override public int getEnergyForTenSeconds() { - // TODO Auto-generated method stub return 50; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilBloodLight.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilBloodLight.java index f314cfdb78..f4a04db925 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilBloodLight.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilBloodLight.java @@ -5,7 +5,6 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.StatCollector; @@ -32,9 +31,9 @@ public SigilBloodLight() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.bloodlightsigil.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.bloodlightsigil.desc")); + addBindingInformation(item, tooltip); } @Override @@ -44,63 +43,59 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, - int par5, int par6, int par7, float par8, float par9, float par10) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par2EntityPlayer) - || !EnergyItems.syphonBatteries(par1ItemStack, par2EntityPlayer, getEnergyUsed())) { + public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int par4, int par5, int par6, int par7, + float par8, float par9, float par10) { + if (!IBindable.checkAndSetItemOwner(item, player) + || !EnergyItems.syphonBatteries(item, player, getEnergyUsed())) { return true; } - if (par3World.isRemote) { + if (world.isRemote) { return true; } - if (par7 == 0 && par3World.isAirBlock(par4, par5 - 1, par6)) { - par3World.setBlock(par4, par5 - 1, par6, ModBlocks.blockBloodLight); + if (par7 == 0 && world.isAirBlock(par4, par5 - 1, par6)) { + world.setBlock(par4, par5 - 1, par6, ModBlocks.blockBloodLight); } - if (par7 == 1 && par3World.isAirBlock(par4, par5 + 1, par6)) { - par3World.setBlock(par4, par5 + 1, par6, ModBlocks.blockBloodLight); + if (par7 == 1 && world.isAirBlock(par4, par5 + 1, par6)) { + world.setBlock(par4, par5 + 1, par6, ModBlocks.blockBloodLight); } - if (par7 == 2 && par3World.isAirBlock(par4, par5, par6 - 1)) { - par3World.setBlock(par4, par5, par6 - 1, ModBlocks.blockBloodLight); + if (par7 == 2 && world.isAirBlock(par4, par5, par6 - 1)) { + world.setBlock(par4, par5, par6 - 1, ModBlocks.blockBloodLight); } - if (par7 == 3 && par3World.isAirBlock(par4, par5, par6 + 1)) { - par3World.setBlock(par4, par5, par6 + 1, ModBlocks.blockBloodLight); + if (par7 == 3 && world.isAirBlock(par4, par5, par6 + 1)) { + world.setBlock(par4, par5, par6 + 1, ModBlocks.blockBloodLight); } - if (par7 == 4 && par3World.isAirBlock(par4 - 1, par5, par6)) { - par3World.setBlock(par4 - 1, par5, par6, ModBlocks.blockBloodLight); + if (par7 == 4 && world.isAirBlock(par4 - 1, par5, par6)) { + world.setBlock(par4 - 1, par5, par6, ModBlocks.blockBloodLight); } - if (par7 == 5 && par3World.isAirBlock(par4 + 1, par5, par6)) { - par3World.setBlock(par4 + 1, par5, par6, ModBlocks.blockBloodLight); + if (par7 == 5 && world.isAirBlock(par4 + 1, par5, par6)) { + world.setBlock(par4 + 1, par5, par6, ModBlocks.blockBloodLight); } return true; } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); + if (!EnergyItems.syphonBatteries(item, player, getEnergyUsed() * 5)) { + return item; } - if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed() * 5)) { - return par1ItemStack; + if (!world.isRemote) { + world.spawnEntityInWorld(new EntityBloodLightProjectile(world, player, 10)); } - if (!par2World.isRemote) { - par2World.spawnEntityInWorld(new EntityBloodLightProjectile(par2World, par3EntityPlayer, 10)); - } - - return par1ItemStack; + return item; } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilDivination.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilDivination.java index 66fe55e7b4..1a952200e9 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilDivination.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilDivination.java @@ -41,75 +41,71 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.divinationsigil.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.divinationsigil.desc2")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.divinationsigil.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.divinationsigil.desc2")); + addBindingInformation(item, tooltip); } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer); + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + IBindable.checkAndSetItemOwner(item, player); - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.worldObj.isRemote) { - return par1ItemStack; + if (!IBindable.checkAndSetItemOwner(item, player) || player.worldObj.isRemote) { + return item; } - if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 0)) { - return par1ItemStack; + if (!EnergyItems.syphonBatteries(item, player, 0)) { + return item; } - String ownerName = IBindable.getOwnerName(par1ItemStack); + String ownerName = IBindable.getOwnerName(item); - MovingObjectPosition movingobjectposition = this - .getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, false); + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, false); if (movingobjectposition == null) { - tellEssence(par3EntityPlayer, ownerName); - return par1ItemStack; - } else { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - int x = movingobjectposition.blockX; - int y = movingobjectposition.blockY; - int z = movingobjectposition.blockZ; - - TileEntity tile = par2World.getTileEntity(x, y, z); - - if (!(tile instanceof IReagentHandler)) { - tellEssence(par3EntityPlayer, ownerName); - return par1ItemStack; - } + tellEssence(player, ownerName); + return item; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int x = movingobjectposition.blockX; + int y = movingobjectposition.blockY; + int z = movingobjectposition.blockZ; - IReagentHandler relay = (IReagentHandler) tile; + TileEntity tile = world.getTileEntity(x, y, z); + + if (!(tile instanceof IReagentHandler relay)) { + tellEssence(player, ownerName); + return item; + } - ReagentContainerInfo[] infoList = relay.getContainerInfo(ForgeDirection.UNKNOWN); - if (infoList != null) { - for (ReagentContainerInfo info : infoList) { - if (info != null && info.reagent != null && info.reagent.reagent != null) { - tellReagent(par3EntityPlayer, info); - } + ReagentContainerInfo[] infoList = relay.getContainerInfo(ForgeDirection.UNKNOWN); + if (infoList != null) { + for (ReagentContainerInfo info : infoList) { + if (info != null && info.reagent != null && info.reagent.reagent != null) { + tellReagent(player, info); } } } } - return par1ItemStack; + return item; } - private static void tellReagent(EntityPlayer par3EntityPlayer, ReagentContainerInfo info) { - par3EntityPlayer.addChatComponentMessage( + private static void tellReagent(EntityPlayer player, ReagentContainerInfo info) { + player.addChatComponentMessage( new ChatComponentText( StatCollector.translateToLocalFormatted( "message.divinationsigil.reagent", ReagentRegistry.getKeyForReagent(info.reagent.reagent)))); - par3EntityPlayer.addChatComponentMessage( + player.addChatComponentMessage( new ChatComponentText( StatCollector .translateToLocalFormatted("message.divinationsigil.amount", info.reagent.amount))); } - private static void tellEssence(EntityPlayer par3EntityPlayer, String ownerName) { - par3EntityPlayer.addChatMessage( + private static void tellEssence(EntityPlayer player, String ownerName) { + player.addChatMessage( new ChatComponentText( StatCollector.translateToLocalFormatted( "message.divinationsigil.currentessence", diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilFluid.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilFluid.java index 448c7a67ea..88b6fb52fe 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilFluid.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilFluid.java @@ -31,7 +31,7 @@ public class SigilFluid extends Item implements IFluidContainerItem, ISigil { - private int capacity = 128 * 1000; + private final int capacity = 128 * 1000; private static final int STATE_SYPHON = 0; private static final int STATE_FORCE_SYPHON = 1; private static final int STATE_PLACE = 2; @@ -48,40 +48,30 @@ public SigilFluid() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.fluidsigil.desc")); - - if (!(par1ItemStack.getTagCompound() == null)) { - switch (this.getActionState(par1ItemStack)) { - case STATE_SYPHON: - par3List.add(StatCollector.translateToLocal("tooltip.fluidsigil.syphoningmode")); - break; - case STATE_FORCE_SYPHON: - par3List.add(StatCollector.translateToLocal("tooltip.fluidsigil.forcesyphonmode")); - break; - case STATE_PLACE: - par3List.add(StatCollector.translateToLocal("tooltip.fluidsigil.fluidplacementmode")); - break; - case STATE_INPUT_TANK: - par3List.add(StatCollector.translateToLocal("tooltip.fluidsigil.filltankmode")); - break; - case STATE_DRAIN_TANK: - par3List.add(StatCollector.translateToLocal("tooltip.fluidsigil.draintankmode")); - break; - case STATE_BEAST_DRAIN: - par3List.add(StatCollector.translateToLocal("tooltip.fluidsigil.beastmode")); - break; - } + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.fluidsigil.desc")); - FluidStack fluid = this.getFluid(par1ItemStack); - if (fluid != null && fluid.amount > 0) { - String str = fluid.getFluid().getName(); - int amount = fluid.amount; + if (item.getTagCompound() == null) { + return; + } + switch (this.getActionState(item)) { + case STATE_SYPHON -> tooltip.add(StatCollector.translateToLocal("tooltip.fluidsigil.syphoningmode")); + case STATE_FORCE_SYPHON -> tooltip + .add(StatCollector.translateToLocal("tooltip.fluidsigil.forcesyphonmode")); + case STATE_PLACE -> tooltip.add(StatCollector.translateToLocal("tooltip.fluidsigil.fluidplacementmode")); + case STATE_INPUT_TANK -> tooltip.add(StatCollector.translateToLocal("tooltip.fluidsigil.filltankmode")); + case STATE_DRAIN_TANK -> tooltip.add(StatCollector.translateToLocal("tooltip.fluidsigil.draintankmode")); + case STATE_BEAST_DRAIN -> tooltip.add(StatCollector.translateToLocal("tooltip.fluidsigil.beastmode")); + } - par3List.add("" + amount + "mB of " + str); - } else { - par3List.add("Empty"); - } + FluidStack fluid = this.getFluid(item); + if (fluid != null && fluid.amount > 0) { + String str = fluid.getFluid().getName(); + int amount = fluid.amount; + + tooltip.add(amount + "mB of " + str); + } else { + tooltip.add("Empty"); } } @@ -92,29 +82,23 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (par3EntityPlayer.isSneaking()) { - int curState = this.cycleActionState(par1ItemStack); - this.sendMessageViaState(curState, par3EntityPlayer); - return par1ItemStack; - } - - switch (this.getActionState(par1ItemStack)) { - case STATE_SYPHON: - return this.fillItemFromWorld(par1ItemStack, par2World, par3EntityPlayer, false); - case STATE_FORCE_SYPHON: - return this.fillItemFromWorld(par1ItemStack, par2World, par3EntityPlayer, true); - case STATE_PLACE: - return this.emptyItemToWorld(par1ItemStack, par2World, par3EntityPlayer); - case STATE_INPUT_TANK: - return this.fillSelectedTank(par1ItemStack, par2World, par3EntityPlayer); - case STATE_DRAIN_TANK: - return this.drainSelectedTank(par1ItemStack, par2World, par3EntityPlayer); - case STATE_BEAST_DRAIN: - return this.fillItemFromBeastWorld(par1ItemStack, par2World, par3EntityPlayer, true); - } - - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (player.isSneaking()) { + int curState = this.cycleActionState(item); + this.sendMessageViaState(curState, player); + return item; + } + + return switch (this.getActionState(item)) { + case STATE_SYPHON -> this.fillItemFromWorld(item, world, player, false); + case STATE_FORCE_SYPHON -> this.fillItemFromWorld(item, world, player, true); + case STATE_PLACE -> this.emptyItemToWorld(item, world, player); + case STATE_INPUT_TANK -> this.fillSelectedTank(item, world, player); + case STATE_DRAIN_TANK -> this.drainSelectedTank(item, world, player); + case STATE_BEAST_DRAIN -> this.fillItemFromBeastWorld(item, world, player, true); + default -> item; + }; + } public int getActionState(ItemStack item) { @@ -151,24 +135,12 @@ public void sendMessageViaState(int state, EntityPlayer player) { if (player.worldObj.isRemote) { ChatComponentText cmc = new ChatComponentText(""); switch (state) { - case STATE_SYPHON: - cmc.appendText("Now in Syphoning Mode"); - break; - case STATE_FORCE_SYPHON: - cmc.appendText("Now in Force-syphon Mode"); - break; - case STATE_PLACE: - cmc.appendText("Now in Fluid Placement Mode"); - break; - case STATE_INPUT_TANK: - cmc.appendText("Now in Fill Tank Mode"); - break; - case STATE_DRAIN_TANK: - cmc.appendText("Now in Drain Tank Mode"); - break; - case STATE_BEAST_DRAIN: - cmc.appendText("Now in Beast Mode"); - break; + case STATE_SYPHON -> cmc.appendText("Now in Syphoning Mode"); + case STATE_FORCE_SYPHON -> cmc.appendText("Now in Force-syphon Mode"); + case STATE_PLACE -> cmc.appendText("Now in Fluid Placement Mode"); + case STATE_INPUT_TANK -> cmc.appendText("Now in Fill Tank Mode"); + case STATE_DRAIN_TANK -> cmc.appendText("Now in Drain Tank Mode"); + case STATE_BEAST_DRAIN -> cmc.appendText("Now in Beast Mode"); } player.addChatComponentMessage(cmc); } @@ -180,319 +152,305 @@ public ItemStack fillItemFromBeastWorld(ItemStack container, World world, Entity } int range = 5; - float f = 1.0F; boolean flag = true; MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, flag); - if (movingobjectposition == null) { + if (movingobjectposition == null + || movingobjectposition.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { return container; - } else { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - int x = movingobjectposition.blockX; - int y = movingobjectposition.blockY; - int z = movingobjectposition.blockZ; + } + int x = movingobjectposition.blockX; + int y = movingobjectposition.blockY; + int z = movingobjectposition.blockZ; - if (!world.canMineBlock(player, x, y, z)) { - return container; - } + if (!world.canMineBlock(player, x, y, z)) { + return container; + } - if (!player.canPlayerEdit(x, y, z, movingobjectposition.sideHit, container)) { - return container; - } + if (!player.canPlayerEdit(x, y, z, movingobjectposition.sideHit, container)) { + return container; + } - boolean[][][] boolList = new boolean[range * 2 + 1][range * 2 + 1][range * 2 + 1]; + boolean[][][] boolList = new boolean[range * 2 + 1][range * 2 + 1][range * 2 + 1]; - for (int i = 0; i < 2 * range + 1; i++) { - for (int j = 0; j < 2 * range + 1; j++) { - for (int k = 0; k < 2 * range + 1; k++) { - boolList[i][j][k] = false; - } - } + for (int i = 0; i < 2 * range + 1; i++) { + for (int j = 0; j < 2 * range + 1; j++) { + for (int k = 0; k < 2 * range + 1; k++) { + boolList[i][j][k] = false; } + } + } + + List positionList = new ArrayList<>(); + + boolList[range][range][range] = true; + positionList.add(new Int3(range, range, range)); + boolean isReady = false; + + while (!isReady) { + isReady = true; + + for (int i = 0; i < 2 * range + 1; i++) { + for (int j = 0; j < 2 * range + 1; j++) { + for (int k = 0; k < 2 * range + 1; k++) { + if (boolList[i][j][k]) { + if (i - 1 >= 0 && !boolList[i - 1][j][k]) { + Block block = world.getBlock(x - range + i - 1, y - range + j, z - range + k); + Fluid fluid = FluidRegistry.lookupFluidForBlock(block); - List positionList = new ArrayList(); - - boolList[range][range][range] = true; - positionList.add(new Int3(range, range, range)); - boolean isReady = false; - - while (!isReady) { - isReady = true; - - for (int i = 0; i < 2 * range + 1; i++) { - for (int j = 0; j < 2 * range + 1; j++) { - for (int k = 0; k < 2 * range + 1; k++) { - if (boolList[i][j][k]) { - if (i - 1 >= 0 && !boolList[i - 1][j][k]) { - Block block = world.getBlock(x - range + i - 1, y - range + j, z - range + k); - Fluid fluid = FluidRegistry.lookupFluidForBlock(block); - - if (fluid != null) { - boolList[i - 1][j][k] = true; - positionList.add(new Int3(i - 1, j, k)); - isReady = false; - } - } - - if (j - 1 >= 0 && !boolList[i][j - 1][k]) { - Block block = world.getBlock(x - range + i, y - range + j - 1, z - range + k); - Fluid fluid = FluidRegistry.lookupFluidForBlock(block); - - if (fluid != null) { - boolList[i][j - 1][k] = true; - positionList.add(new Int3(i, j - 1, k)); - isReady = false; - } - } - - if (k - 1 >= 0 && !boolList[i][j][k - 1]) { - Block block = world.getBlock(x - range + i, y - range + j, z - range + k - 1); - Fluid fluid = FluidRegistry.lookupFluidForBlock(block); - - if (fluid != null) { - boolList[i][j][k - 1] = true; - positionList.add(new Int3(i, j, k - 1)); - isReady = false; - } - } - - if (i + 1 <= 2 * range && !boolList[i + 1][j][k]) { - Block block = world.getBlock(x - range + i + 1, y - range + j, z - range + k); - Fluid fluid = FluidRegistry.lookupFluidForBlock(block); - - if (fluid != null) { - boolList[i + 1][j][k] = true; - positionList.add(new Int3(i + 1, j, k)); - isReady = false; - } - } - - if (j + 1 <= 2 * range && !boolList[i][j + 1][k]) { - Block block = world.getBlock(x - range + i, y - range + j + 1, z - range + k); - Fluid fluid = FluidRegistry.lookupFluidForBlock(block); - - if (fluid != null) { - boolList[i][j + 1][k] = true; - positionList.add(new Int3(i, j + 1, k)); - isReady = false; - } - } - - if (k + 1 <= 2 * range && !boolList[i][j][k + 1]) { - Block block = world.getBlock(x - range + i, y - range + j, z - range + k + 1); - Fluid fluid = FluidRegistry.lookupFluidForBlock(block); - - if (fluid != null) { - boolList[i][j][k + 1] = true; - positionList.add(new Int3(i, j, k + 1)); - isReady = false; - } - } + if (fluid != null) { + boolList[i - 1][j][k] = true; + positionList.add(new Int3(i - 1, j, k)); + isReady = false; } } - } - } - } - for (Int3 pos : positionList) { - int i = pos.xCoord; - int j = pos.yCoord; - int k = pos.zCoord; + if (j - 1 >= 0 && !boolList[i][j - 1][k]) { + Block block = world.getBlock(x - range + i, y - range + j - 1, z - range + k); + Fluid fluid = FluidRegistry.lookupFluidForBlock(block); - if (!boolList[i][j][k]) { - continue; - } - if (world.getBlock(x + i - range, y + j - range, z + k - range) != null - && world.getBlock(x + i - range, y + j - range, z + k - range) - .getMaterial() instanceof MaterialLiquid) { - // world.setBlockToAir(x+i-range, y+j-range, z+k-range); - Block block = world.getBlock(x + i - range, y + j - range, z + k - range); - if (block == null) { - continue; - } - Fluid fluid = FluidRegistry.lookupFluidForBlock(block); + if (fluid != null) { + boolList[i][j - 1][k] = true; + positionList.add(new Int3(i, j - 1, k)); + isReady = false; + } + } - AlchemicalWizardry.logger - .info("x: " + (i - range) + " y: " + (j - range) + " z: " + (k - range)); + if (k - 1 >= 0 && !boolList[i][j][k - 1]) { + Block block = world.getBlock(x - range + i, y - range + j, z - range + k - 1); + Fluid fluid = FluidRegistry.lookupFluidForBlock(block); - if (fluid == null || world.getBlockMetadata(x + i - range, y + j - range, z + k - range) != 0) { - continue; - } + if (fluid != null) { + boolList[i][j][k - 1] = true; + positionList.add(new Int3(i, j, k - 1)); + isReady = false; + } + } - FluidStack fillStack = new FluidStack(fluid, 1000); + if (i + 1 <= 2 * range && !boolList[i + 1][j][k]) { + Block block = world.getBlock(x - range + i + 1, y - range + j, z - range + k); + Fluid fluid = FluidRegistry.lookupFluidForBlock(block); - int amount = this.fill(container, fillStack, false); + if (fluid != null) { + boolList[i + 1][j][k] = true; + positionList.add(new Int3(i + 1, j, k)); + isReady = false; + } + } - if ((amount > 0 && forceFill) || (amount >= 1000 && !forceFill)) { - { - world.setBlockToAir(x + i - range, y + j - range, z + k - range); + if (j + 1 <= 2 * range && !boolList[i][j + 1][k]) { + Block block = world.getBlock(x - range + i, y - range + j + 1, z - range + k); + Fluid fluid = FluidRegistry.lookupFluidForBlock(block); + + if (fluid != null) { + boolList[i][j + 1][k] = true; + positionList.add(new Int3(i, j + 1, k)); + isReady = false; + } } - this.fill(container, new FluidStack(fluid, 1000), true); + if (k + 1 <= 2 * range && !boolList[i][j][k + 1]) { + Block block = world.getBlock(x - range + i, y - range + j, z - range + k + 1); + Fluid fluid = FluidRegistry.lookupFluidForBlock(block); + + if (fluid != null) { + boolList[i][j][k + 1] = true; + positionList.add(new Int3(i, j, k + 1)); + isReady = false; + } + } } } } } + } - return container; + for (Int3 pos : positionList) { + int i = pos.x(); + int j = pos.y(); + int k = pos.z(); + + if (!boolList[i][j][k]) { + continue; + } + if (world.getBlock(x + i - range, y + j - range, z + k - range) != null && world + .getBlock(x + i - range, y + j - range, z + k - range).getMaterial() instanceof MaterialLiquid) { + // world.setBlockToAir(x+i-range, y+j-range, z+k-range); + Block block = world.getBlock(x + i - range, y + j - range, z + k - range); + if (block == null) { + continue; + } + Fluid fluid = FluidRegistry.lookupFluidForBlock(block); + + AlchemicalWizardry.logger.info("x: {} y: {} z: {}", i - range, j - range, k - range); + + if (fluid == null || world.getBlockMetadata(x + i - range, y + j - range, z + k - range) != 0) { + continue; + } + + FluidStack fillStack = new FluidStack(fluid, 1000); + + int amount = this.fill(container, fillStack, false); + + if (amount > 0 && forceFill || amount >= 1000) { + world.setBlockToAir(x + i - range, y + j - range, z + k - range); + + this.fill(container, new FluidStack(fluid, 1000), true); + } + } } + + return container; } public ItemStack fillItemFromWorld(ItemStack container, World world, EntityPlayer player, boolean forceFill) { - float f = 1.0F; - boolean flag = true; - MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, flag); + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true); - if (movingobjectposition == null) { + if (movingobjectposition == null + || movingobjectposition.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { return container; - } else { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - int i = movingobjectposition.blockX; - int j = movingobjectposition.blockY; - int k = movingobjectposition.blockZ; + } + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; - if (!world.canMineBlock(player, i, j, k)) { - return container; - } + if (!world.canMineBlock(player, i, j, k)) { + return container; + } - if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, container)) { - return container; - } + if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, container)) { + return container; + } - if (world.getBlock(i, j, k) != null - && world.getBlock(i, j, k).getMaterial() instanceof MaterialLiquid) { - Block block = world.getBlock(i, j, k); - Fluid fluid = FluidRegistry.lookupFluidForBlock(block); + if (world.getBlock(i, j, k) == null || !(world.getBlock(i, j, k).getMaterial() instanceof MaterialLiquid)) { + return container; + } + Block block = world.getBlock(i, j, k); + Fluid fluid = FluidRegistry.lookupFluidForBlock(block); - if (fluid == null) { - return container; - } + if (fluid == null) { + return container; + } - FluidStack fillStack = new FluidStack(fluid, 1000); + FluidStack fillStack = new FluidStack(fluid, 1000); - int amount = this.fill(container, fillStack, false); + int amount = this.fill(container, fillStack, false); - if ((amount > 0 && forceFill) || (amount >= 1000 && !forceFill)) { - if (!player.capabilities.isCreativeMode) { - world.setBlockToAir(i, j, k); - } + if (amount > 0 && forceFill || amount >= 1000) { + if (!player.capabilities.isCreativeMode) { + world.setBlockToAir(i, j, k); + } - this.fill(container, new FluidStack(fluid, 1000), true); + this.fill(container, new FluidStack(fluid, 1000), true); - if (!player.capabilities.isCreativeMode) {} else { - return container; - } - } - } + if (player.capabilities.isCreativeMode) { + return container; } - - return container; } + + return container; } public ItemStack emptyItemToWorld(ItemStack container, World world, EntityPlayer player) { FluidStack simStack = this.drain(container, 1000, false); - if (simStack != null && simStack.amount >= 1000) { - Block fluidBlock = simStack.getFluid().getBlock(); + if (simStack == null || simStack.amount < 1000) { + return container; + } + Block fluidBlock = simStack.getFluid().getBlock(); - float f = 1.0F; - double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f; - double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f - + 1.62D - - (double) player.yOffset; - double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f; - boolean flag = false; - MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, flag); + float f = 1.0F; + double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f; + double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f + 1.62D - (double) player.yOffset; + double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f; + boolean flag = false; + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, flag); - if (movingobjectposition == null) { - return container; - } else { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - int i = movingobjectposition.blockX; - int j = movingobjectposition.blockY; - int k = movingobjectposition.blockZ; - - if (!world.canMineBlock(player, i, j, k)) { - return container; - } + if (movingobjectposition == null) { + return container; + } + if (movingobjectposition.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { + return container; + } + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; - if (movingobjectposition.sideHit == 0) { - --j; - } + if (!world.canMineBlock(player, i, j, k)) { + return container; + } - if (movingobjectposition.sideHit == 1) { - ++j; - } + if (movingobjectposition.sideHit == 0) { + --j; + } - if (movingobjectposition.sideHit == 2) { - --k; - } + if (movingobjectposition.sideHit == 1) { + ++j; + } - if (movingobjectposition.sideHit == 3) { - ++k; - } + if (movingobjectposition.sideHit == 2) { + --k; + } - if (movingobjectposition.sideHit == 4) { - --i; - } + if (movingobjectposition.sideHit == 3) { + ++k; + } - if (movingobjectposition.sideHit == 5) { - ++i; - } + if (movingobjectposition.sideHit == 4) { + --i; + } - if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, container)) { - return container; - } + if (movingobjectposition.sideHit == 5) { + ++i; + } - if (this.tryPlaceContainedLiquid(world, fluidBlock, d0, d1, d2, i, j, k) - && !player.capabilities.isCreativeMode) { - this.drain(container, 1000, true); + if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, container)) { + return container; + } - return container; - } - } + if (this.tryPlaceContainedLiquid(world, fluidBlock, d0, d1, d2, i, j, k) + && !player.capabilities.isCreativeMode) { + this.drain(container, 1000, true); - return container; - } + return container; } return container; } - public boolean tryPlaceContainedLiquid(World par1World, Block block, double par2, double par4, double par6, - int par8, int par9, int par10) { - if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlock(par8, par9, par10).func_149730_j()) { + public boolean tryPlaceContainedLiquid(World world, Block block, double par2, double par4, double par6, int par8, + int par9, int par10) { + if (!world.isAirBlock(par8, par9, par10) && world.getBlock(par8, par9, par10).func_149730_j()) { return false; - } else if ((par1World.getBlock(par8, par9, par10).getMaterial() instanceof MaterialLiquid - && (par1World.getBlockMetadata(par8, par9, par10) == 0))) { - return false; - } else { - if ((block == Blocks.water || block == Blocks.flowing_water) && par1World.provider.isHellWorld) { - par1World.playSoundEffect( - par2 + 0.5D, - par4 + 0.5D, - par6 + 0.5D, - "random.fizz", - 0.5F, - 2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F); - - for (int l = 0; l < 8; ++l) { - par1World.spawnParticle( - "largesmoke", - (double) par8 + Math.random(), - (double) par9 + Math.random(), - (double) par10 + Math.random(), - 0.0D, - 0.0D, - 0.0D); - } - } else { - par1World.setBlock(par8, par9, par10, block, 0, 3); - } + } + if ((world.getBlock(par8, par9, par10).getMaterial() instanceof MaterialLiquid + && (world.getBlockMetadata(par8, par9, par10) == 0))) { + return false; + } + if ((block != Blocks.water && block != Blocks.flowing_water) || !world.provider.isHellWorld) { + world.setBlock(par8, par9, par10, block, 0, 3); + } else { + world.playSoundEffect( + par2 + 0.5D, + par4 + 0.5D, + par6 + 0.5D, + "random.fizz", + 0.5F, + 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + + for (int l = 0; l < 8; ++l) { + world.spawnParticle( + "largesmoke", + (double) par8 + Math.random(), + (double) par9 + Math.random(), + (double) par10 + Math.random(), + 0.0D, + 0.0D, + 0.0D); + } + } - return true; - } + return true; } public ItemStack fillSelectedTank(ItemStack container, World world, EntityPlayer player) { @@ -502,26 +460,22 @@ public ItemStack fillSelectedTank(ItemStack container, World world, EntityPlayer return container; } - float f = 1.0F; - boolean flag = false; - MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, flag); + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, false); if (movingobjectposition == null) { return container; - } else { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - int i = movingobjectposition.blockX; - int j = movingobjectposition.blockY; - int k = movingobjectposition.blockZ; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; - TileEntity tile = world.getTileEntity(i, j, k); + TileEntity tile = world.getTileEntity(i, j, k); - if (tile instanceof IFluidHandler) { - int amount = ((IFluidHandler) tile) - .fill(ForgeDirection.getOrientation(movingobjectposition.sideHit), fluid, true); + if (tile instanceof IFluidHandler handler) { + int amount = handler.fill(ForgeDirection.getOrientation(movingobjectposition.sideHit), fluid, true); - this.drain(container, amount, true); - } + this.drain(container, amount, true); } } @@ -529,36 +483,33 @@ public ItemStack fillSelectedTank(ItemStack container, World world, EntityPlayer } public ItemStack drainSelectedTank(ItemStack container, World world, EntityPlayer player) { - float f = 1.0F; - boolean flag = false; - MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, flag); + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, false); if (movingobjectposition == null) { return container; - } else { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - int i = movingobjectposition.blockX; - int j = movingobjectposition.blockY; - int k = movingobjectposition.blockZ; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; - TileEntity tile = world.getTileEntity(i, j, k); + TileEntity tile = world.getTileEntity(i, j, k); - if (tile instanceof IFluidHandler) { - FluidStack fluidAmount = ((IFluidHandler) tile).drain( - ForgeDirection.getOrientation(movingobjectposition.sideHit), - this.getCapacity(container), - false); + if (tile instanceof IFluidHandler) { + FluidStack fluidAmount = ((IFluidHandler) tile).drain( + ForgeDirection.getOrientation(movingobjectposition.sideHit), + this.getCapacity(container), + false); - int amount = this.fill(container, fluidAmount, false); + int amount = this.fill(container, fluidAmount, false); - if (amount > 0) { - ((IFluidHandler) tile).drain( - ForgeDirection.getOrientation(movingobjectposition.sideHit), - this.getCapacity(container), - true); + if (amount > 0) { + ((IFluidHandler) tile).drain( + ForgeDirection.getOrientation(movingobjectposition.sideHit), + this.getCapacity(container), + true); - this.fill(container, fluidAmount, true); - } + this.fill(container, fluidAmount, true); } } } @@ -566,7 +517,6 @@ public ItemStack drainSelectedTank(ItemStack container, World world, EntityPlaye return container; } - /* IFluidContainerItem */ @Override public FluidStack getFluid(ItemStack container) { if (container.getTagCompound() == null || !container.getTagCompound().hasKey("Fluid")) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilHarvest.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilHarvest.java index 375479ceff..20878ac89e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilHarvest.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilHarvest.java @@ -6,7 +6,6 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraft.world.World; @@ -37,9 +36,9 @@ public SigilHarvest() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.harvestsigil.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.harvestsigil.desc")); + addBindingInformation(item, tooltip); } @Override @@ -61,8 +60,8 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - if (par1 == 1) { + public IIcon getIconFromDamage(int meta) { + if (meta == 1) { return this.activeIcon; } else { return this.passiveIcon; @@ -70,45 +69,39 @@ public IIcon getIconFromDamage(int par1) { } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - toggleSigil(par1ItemStack, par2World, par3EntityPlayer); + toggleSigil(item, world, player); - return par1ItemStack; + return item; } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if ((!(par3Entity instanceof EntityPlayer)) || par2World.isRemote) { + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if ((!(entity instanceof EntityPlayer player)) || world.isRemote) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; - - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); - } - - if (IBindable.isActive(par1ItemStack)) { + if (IBindable.isActive(item)) { int range = 3; int verticalRange = 1; - int posX = (int) Math.round(par3Entity.posX - 0.5f); - int posY = (int) par3Entity.posY; - int posZ = (int) Math.round(par3Entity.posZ - 0.5f); - - for (int ix = posX - range; ix <= posX + range; ix++) { - for (int iz = posZ - range; iz <= posZ + range; iz++) { - for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++) { - HarvestRegistry.harvestBlock(par2World, ix, iy, iz); + int posX = (int) Math.round(player.posX - 0.5f); + int posY = (int) player.posY; + int posZ = (int) Math.round(player.posZ - 0.5f); + + for (int x = posX - range; x <= posX + range; x++) { + for (int z = posZ - range; z <= posZ + range; z++) { + for (int y = posY - verticalRange; y <= posY + verticalRange; y++) { + HarvestRegistry.harvestBlock(world, x, y, z); } } } } - checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer); + checkPassiveDrain(item, world, player); } @Override @@ -122,10 +115,10 @@ public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemS int posY = (int) player.posY; int posZ = (int) Math.round(player.posZ - 0.5f); - for (int ix = posX - range; ix <= posX + range; ix++) { - for (int iz = posZ - range; iz <= posZ + range; iz++) { - for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++) { - HarvestRegistry.harvestBlock(world, ix, iy, iz); + for (int x = posX - range; x <= posX + range; x++) { + for (int z = posZ - range; z <= posZ + range; z++) { + for (int y = posY - verticalRange; y <= posY + verticalRange; y++) { + HarvestRegistry.harvestBlock(world, x, y, z); } } } @@ -133,13 +126,11 @@ public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemS @Override public boolean isUpgrade() { - // TODO Auto-generated method stub return true; } @Override public int getEnergyForTenSeconds() { - // TODO Auto-generated method stub return 500; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilLava.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilLava.java index 02ca043f71..61056e0e37 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilLava.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilLava.java @@ -6,7 +6,6 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemBucket; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; @@ -23,7 +22,6 @@ import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade; import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable; import WayofTime.alchemicalWizardry.api.items.interfaces.ISigil; -import WayofTime.alchemicalWizardry.common.items.EnergyBattery; import WayofTime.alchemicalWizardry.common.items.EnergyItems; import WayofTime.alchemicalWizardry.common.tileEntity.TESocket; import cpw.mods.fml.relauncher.Side; @@ -31,11 +29,6 @@ public class SigilLava extends ItemBucket implements ArmourUpgrade, ISigil { - /** - * field for checking if the bucket has been filled. - */ - private Block isFull = Blocks.lava; - private int energyUsed; public SigilLava() { @@ -57,15 +50,16 @@ public ItemStack getContainerItem(ItemStack itemStack) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.lavasigil.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.lavasigil.desc2")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.lavasigil.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.lavasigil.desc2")); + addBindingInformation(item, tooltip); } /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ + @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { return stack; } @@ -82,12 +76,12 @@ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, } TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof IFluidHandler) { + if (tile instanceof IFluidHandler handler) { FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000); - int amount = ((IFluidHandler) tile).fill(ForgeDirection.getOrientation(side), fluid, false); + int amount = handler.fill(ForgeDirection.getOrientation(side), fluid, false); if (amount > 0 && EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) { - ((IFluidHandler) tile).fill(ForgeDirection.getOrientation(side), fluid, true); + handler.fill(ForgeDirection.getOrientation(side), fluid, true); } return false; @@ -95,39 +89,22 @@ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, return false; } - { - if (side == 0) { - --y; - } - - if (side == 1) { - ++y; - } - - if (side == 2) { - --z; - } - - if (side == 3) { - ++z; - } - - if (side == 4) { - --x; - } - - if (side == 5) { - ++x; - } + switch (side) { + case 0 -> --y; + case 1 -> ++y; + case 2 -> --z; + case 3 -> ++z; + case 4 -> --x; + case 5 -> ++x; + } - if (!player.canPlayerEdit(x, y, z, side, stack)) { - return false; - } + if (!player.canPlayerEdit(x, y, z, side, stack)) { + return false; + } - if (this.canPlaceContainedLiquid(world, x, y, z, x, y, z) - && EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) { - return this.tryPlaceContainedLiquid(world, x, y, z, x, y, z); - } + if (this.canPlaceContainedLiquid(world, x, y, z) + && EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) { + return this.tryPlaceContainedLiquid(world, x, y, z); } return false; @@ -136,66 +113,28 @@ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, /** * Attempts to place the liquid contained inside the bucket. */ - public boolean tryPlaceContainedLiquid(World par1World, double par2, double par4, double par6, int par8, int par9, - int par10) { - if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlock(par8, par9, par10).getMaterial().isSolid()) { - return false; - } else if ((par1World.getBlock(par8, par9, par10) == Blocks.lava - || par1World.getBlock(par8, par9, par10) == Blocks.flowing_lava) - && par1World.getBlockMetadata(par8, par9, par10) == 0) { - return false; - } else { - par1World.setBlock(par8, par9, par10, this.isFull, 0, 3); - return true; - } + @Override + public boolean tryPlaceContainedLiquid(World world, int x, int y, int z) { + world.setBlock(x, y, z, Blocks.lava, 0, 3); + return true; } - public boolean canPlaceContainedLiquid(World par1World, double par2, double par4, double par6, int par8, int par9, - int par10) { - if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlock(par8, par9, par10).getMaterial().isSolid()) { + public boolean canPlaceContainedLiquid(World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + if (!world.isAirBlock(x, y, z) && block.getMaterial().isSolid()) { return false; - } else if ((par1World.getBlock(par8, par9, par10) == Blocks.lava - || par1World.getBlock(par8, par9, par10) == Blocks.flowing_lava) - && par1World.getBlockMetadata(par8, par9, par10) == 0) { - return false; - } else { - return true; - } + } + return (block != Blocks.lava && block != Blocks.flowing_lava) || world.getBlockMetadata(x, y, z) != 0; } - protected void setEnergyUsed(int par1int) { - this.energyUsed = par1int; + protected void setEnergyUsed(int energy) { + this.energyUsed = energy; } protected int getEnergyUsed() { return this.energyUsed; } - protected boolean syphonBatteries(ItemStack ist, EntityPlayer player, int damageToBeDone) { - if (!player.capabilities.isCreativeMode) { - boolean usedBattery = false; - IInventory inventory = player.inventory; - - for (int slot = 0; slot < inventory.getSizeInventory(); slot++) { - ItemStack stack = inventory.getStackInSlot(slot); - - if (stack == null) { - continue; - } - if (stack.getItem() instanceof EnergyBattery && !usedBattery) { - if (stack.getItemDamage() <= stack.getMaxDamage() - damageToBeDone) { - stack.setItemDamage(stack.getItemDamage() + damageToBeDone); - usedBattery = true; - } - } - } - - return usedBattery; - } else { - return true; - } - } - @Override public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack) { player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 2, 9, true)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfElementalAffinity.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfElementalAffinity.java index 9ac6ab049d..eeb3e53fe8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfElementalAffinity.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfElementalAffinity.java @@ -6,7 +6,6 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.IIcon; @@ -36,10 +35,10 @@ public SigilOfElementalAffinity() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.sigilofelementalaffinity.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.sigilofelementalaffinity.desc2")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.sigilofelementalaffinity.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.sigilofelementalaffinity.desc2")); + addBindingInformation(item, tooltip); } @Override @@ -61,8 +60,8 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - if (par1 == 1) { + public IIcon getIconFromDamage(int meta) { + if (meta == 1) { return this.activeIcon; } else { return this.passiveIcon; @@ -70,37 +69,31 @@ public IIcon getIconFromDamage(int par1) { } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (toggleSigil(par1ItemStack, par2World, par3EntityPlayer)) { - par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 2, 0, true)); - par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 2, 0, true)); + if (toggleSigil(item, world, player)) { + player.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 2, 0, true)); + player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 2, 0, true)); } - return par1ItemStack; + return item; } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer)) { + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if (!(entity instanceof EntityPlayer player)) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; - - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); - } - - if (IBindable.isActive(par1ItemStack)) { - par3EntityPlayer.fallDistance = 0; - par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 2, 0, true)); - par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 2, 0, true)); + if (IBindable.isActive(item)) { + player.fallDistance = 0; + player.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 2, 0, true)); + player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 2, 0, true)); } - checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer); + checkPassiveDrain(item, world, player); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfEnderSeverance.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfEnderSeverance.java index 645289acee..ec76208db3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfEnderSeverance.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfEnderSeverance.java @@ -7,7 +7,6 @@ import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; @@ -38,9 +37,9 @@ public SigilOfEnderSeverance() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.sigilofenderseverance.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.sigilofenderseverance.desc")); + addBindingInformation(item, tooltip); } @Override @@ -62,8 +61,8 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - if (par1 == 1) { + public IIcon getIconFromDamage(int meta) { + if (meta == 1) { return this.activeIcon; } else { return this.passiveIcon; @@ -71,39 +70,31 @@ public IIcon getIconFromDamage(int par1) { } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - toggleSigil(par1ItemStack, par2World, par3EntityPlayer); + toggleSigil(item, world, player); - return par1ItemStack; + return item; } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer)) { + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if (!(entity instanceof EntityPlayer player)) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; - - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); - } - - if (IBindable.isActive(par1ItemStack)) { - List list = SpellHelper - .getEntitiesInRange(par2World, par3Entity.posX, par3Entity.posY, par3Entity.posZ, 4.5, 4.5); - for (Entity entity : list) { - if (!entity.equals(par3Entity) && entity instanceof EntityLiving) { - ((EntityLiving) entity) - .addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionPlanarBinding.id, 5, 0)); + if (IBindable.isActive(item)) { + List list = SpellHelper.getEntitiesInRange(world, entity.posX, entity.posY, entity.posZ, 4.5, 4.5); + for (Entity e : list) { + if (!e.equals(entity) && e instanceof EntityLiving living) { + living.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionPlanarBinding.id, 5, 0)); } } } - checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer); + checkPassiveDrain(item, world, player); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfGrowth.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfGrowth.java index b85bcf984d..bf86f08ba2 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfGrowth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfGrowth.java @@ -8,7 +8,6 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraft.world.World; @@ -41,10 +40,10 @@ public SigilOfGrowth() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.sigilofgrowth.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.sigilofgrowth.desc2")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.sigilofgrowth.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.sigilofgrowth.desc2")); + addBindingInformation(item, tooltip); } @Override @@ -66,8 +65,8 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - if (par1 == 1) { + public IIcon getIconFromDamage(int meta) { + if (meta == 1) { return this.activeIcon; } else { return this.passiveIcon; @@ -75,78 +74,70 @@ public IIcon getIconFromDamage(int par1) { } @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, - int par5, int par6, int par7, float par8, float par9, float par10) { - if (IBindable.checkAndSetItemOwner(par1ItemStack, par2EntityPlayer)) { - if (applyBonemeal(par1ItemStack, par3World, par4, par5, par6, par2EntityPlayer)) { - EnergyItems.syphonBatteries(par1ItemStack, par2EntityPlayer, getEnergyUsed()); - - if (par3World.isRemote) { - par3World.playAuxSFX(2005, par4, par5, par6, 0); - return true; - } + public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int par7, + float par8, float par9, float par10) { + if (IBindable.checkAndSetItemOwner(item, player) && applyBonemeal(world, x, y, z, player)) { + EnergyItems.syphonBatteries(item, player, getEnergyUsed()); + if (world.isRemote) { + world.playAuxSFX(2005, x, y, z, 0); return true; } + + return true; } return false; } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (par2World.isRemote) { - return par1ItemStack; + if (world.isRemote) { + return item; } - toggleSigil(par1ItemStack, par2World, par3EntityPlayer); + toggleSigil(item, world, player); - return par1ItemStack; + return item; } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer) || par2World.isRemote) { + public void onUpdate(ItemStack item, World world, Entity entity, int par4, boolean par5) { + if (!(entity instanceof EntityPlayer player) || world.isRemote) { return; } - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); + if (!IBindable.isActive(item)) { + return; } - if (IBindable.isActive(par1ItemStack)) { - - checkPassiveDrain(par1ItemStack, par2World, (EntityPlayer) par3Entity); - int range = 3; - int verticalRange = 2; - int posX = (int) Math.round(par3Entity.posX - 0.5f); - int posY = (int) par3Entity.posY; - int posZ = (int) Math.round(par3Entity.posZ - 0.5f); - - for (int ix = posX - range; ix <= posX + range; ix++) { - for (int iz = posZ - range; iz <= posZ + range; iz++) { - for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++) { - Block block = par2World.getBlock(ix, iy, iz); - - if (block instanceof IPlantable || block instanceof IGrowable) { - if (par2World.rand.nextInt(50) == 0) { - block.updateTick(par2World, ix, iy, iz, par2World.rand); - } - } + checkPassiveDrain(item, world, player); + int range = 3; + int verticalRange = 2; + int posX = (int) Math.round(entity.posX - 0.5f); + int posY = (int) entity.posY; + int posZ = (int) Math.round(entity.posZ - 0.5f); + + for (int x = posX - range; x <= posX + range; x++) { + for (int z = posZ - range; z <= posZ + range; z++) { + for (int y = posY - verticalRange; y <= posY + verticalRange; y++) { + Block block = world.getBlock(x, y, z); + + if ((block instanceof IPlantable || block instanceof IGrowable) && world.rand.nextInt(50) == 0) { + block.updateTick(world, x, y, z, world.rand); } } } } } - public static boolean applyBonemeal(ItemStack p_150919_0_, World p_150919_1_, int p_150919_2_, int p_150919_3_, - int p_150919_4_, EntityPlayer player) { - Block block = p_150919_1_.getBlock(p_150919_2_, p_150919_3_, p_150919_4_); + public static boolean applyBonemeal(World world, int x, int y, int z, EntityPlayer player) { + Block block = world.getBlock(x, y, z); - BonemealEvent event = new BonemealEvent(player, p_150919_1_, block, p_150919_2_, p_150919_3_, p_150919_4_); + BonemealEvent event = new BonemealEvent(player, world, block, x, y, z); if (MinecraftForge.EVENT_BUS.post(event)) { return false; } @@ -155,18 +146,12 @@ public static boolean applyBonemeal(ItemStack p_150919_0_, World p_150919_1_, in return true; } - if (block instanceof IGrowable) { - IGrowable igrowable = (IGrowable) block; - - if (igrowable.func_149851_a(p_150919_1_, p_150919_2_, p_150919_3_, p_150919_4_, p_150919_1_.isRemote)) { - if (!p_150919_1_.isRemote) { - if (igrowable.func_149852_a(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_)) { - igrowable.func_149853_b(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_); - } - } - - return true; + if (block instanceof IGrowable igrowable && igrowable.func_149851_a(world, x, y, z, world.isRemote)) { + if (!world.isRemote && igrowable.func_149852_a(world, world.rand, x, y, z)) { + igrowable.func_149853_b(world, world.rand, x, y, z); } + + return true; } return false; @@ -189,15 +174,13 @@ public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemS int posY = (int) player.posY; int posZ = (int) Math.round(player.posZ - 0.5f); - for (int ix = posX - range; ix <= posX + range; ix++) { - for (int iz = posZ - range; iz <= posZ + range; iz++) { - for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++) { - Block block = world.getBlock(ix, iy, iz); + for (int x = posX - range; x <= posX + range; x++) { + for (int z = posZ - range; z <= posZ + range; z++) { + for (int y = posY - verticalRange; y <= posY + verticalRange; y++) { + Block block = world.getBlock(x, y, z); - if (block instanceof IPlantable) { - if (world.rand.nextInt(100) == 0) { - block.updateTick(world, ix, iy, iz, world.rand); - } + if (block instanceof IPlantable && world.rand.nextInt(100) == 0) { + block.updateTick(world, x, y, z, world.rand); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfHaste.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfHaste.java index 62ecd01ccc..1486cfc6c2 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfHaste.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfHaste.java @@ -36,9 +36,9 @@ public SigilOfHaste() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.sigilofhaste.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.sigilofhaste.desc")); + addBindingInformation(item, tooltip); } @Override @@ -60,8 +60,8 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - if (par1 == 1) { + public IIcon getIconFromDamage(int meta) { + if (meta == 1) { return this.activeIcon; } else { return this.passiveIcon; @@ -69,35 +69,29 @@ public IIcon getIconFromDamage(int par1) { } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (toggleSigil(par1ItemStack, par2World, par3EntityPlayer)) { - par3EntityPlayer.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionBoost.id, 3, 1)); + if (toggleSigil(item, world, player)) { + player.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionBoost.id, 3, 1)); } - return par1ItemStack; + return item; } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer)) { + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if (!(entity instanceof EntityPlayer player)) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; - - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); - } - - if (IBindable.isActive(par1ItemStack)) { - par3EntityPlayer.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionBoost.id, 3, 1)); + if (IBindable.isActive(item)) { + player.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionBoost.id, 3, 1)); } - checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer); + checkPassiveDrain(item, world, player); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfMagnetism.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfMagnetism.java index ad2d2388b9..4b663675e7 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfMagnetism.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfMagnetism.java @@ -8,7 +8,6 @@ import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; @@ -39,9 +38,9 @@ public SigilOfMagnetism() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.sigilofmagnetism.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.sigilofmagnetism.desc")); + addBindingInformation(item, tooltip); } @Override @@ -63,8 +62,8 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - if (par1 == 1) { + public IIcon getIconFromDamage(int meta) { + if (meta == 1) { return this.activeIcon; } else { return this.passiveIcon; @@ -72,66 +71,53 @@ public IIcon getIconFromDamage(int par1) { } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - toggleSigil(par1ItemStack, par2World, par3EntityPlayer); + toggleSigil(item, world, player); - return par1ItemStack; + return item; } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer)) { + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if (!(entity instanceof EntityPlayer player)) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; - - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); + if (!IBindable.isActive(item)) { + return; } - if (IBindable.isActive(par1ItemStack)) { - - checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer); - - int range = 5; - int verticalRange = 5; - float posX = Math.round(par3Entity.posX); - float posY = (float) (par3Entity.posY - par3Entity.getEyeHeight()); - float posZ = Math.round(par3Entity.posZ); - List entities = par3EntityPlayer.worldObj.getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox( - posX - 0.5f, - posY - 0.5f, - posZ - 0.5f, - posX + 0.5f, - posY + 0.5f, - posZ + 0.5f).expand(range, verticalRange, range)); - List xpOrbs = par3EntityPlayer.worldObj.getEntitiesWithinAABB( - EntityXPOrb.class, - AxisAlignedBB.getBoundingBox( - posX - 0.5f, - posY - 0.5f, - posZ - 0.5f, - posX + 0.5f, - posY + 0.5f, - posZ + 0.5f).expand(range, verticalRange, range)); - - for (EntityItem entity : entities) { - if (entity != null && !par2World.isRemote) { - entity.onCollideWithPlayer(par3EntityPlayer); - } + checkPassiveDrain(item, world, player); + + int range = 5; + int verticalRange = 5; + float posX = Math.round(player.posX); + float posY = (float) (player.posY - player.getEyeHeight()); + float posZ = Math.round(player.posZ); + List entities = player.worldObj.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB + .getBoundingBox(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f) + .expand(range, verticalRange, range)); + List xpOrbs = player.worldObj.getEntitiesWithinAABB( + EntityXPOrb.class, + AxisAlignedBB + .getBoundingBox(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f) + .expand(range, verticalRange, range)); + + for (EntityItem entityItem : entities) { + if (entityItem != null && !world.isRemote) { + entityItem.onCollideWithPlayer(player); } + } - for (EntityXPOrb xpOrb : xpOrbs) { - if (xpOrb != null && !par2World.isRemote) { - xpOrb.onCollideWithPlayer(par3EntityPlayer); - } + for (EntityXPOrb xpOrb : xpOrbs) { + if (xpOrb != null && !world.isRemote) { + xpOrb.onCollideWithPlayer(player); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfSupression.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfSupression.java index 9e27dd8929..73f90596c4 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfSupression.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfSupression.java @@ -7,7 +7,6 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; @@ -32,8 +31,8 @@ public class SigilOfSupression extends EnergyItems implements ArmourUpgrade, ISi @SideOnly(Side.CLIENT) private IIcon passiveIcon; - private int radius = 5; - private int refresh = 100; + private final int radius = 5; + private final int refresh = 100; public SigilOfSupression() { super(); @@ -43,9 +42,9 @@ public SigilOfSupression() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.sigilofsupression.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.sigilofsupression.desc")); + addBindingInformation(item, tooltip); } @Override @@ -67,8 +66,8 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - if (par1 == 1) { + public IIcon getIconFromDamage(int meta) { + if (meta == 1) { return activeIcon; } else { return passiveIcon; @@ -76,68 +75,62 @@ public IIcon getIconFromDamage(int par1) { } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) - || SpellHelper.isFakePlayer(par2World, par3EntityPlayer)) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || SpellHelper.isFakePlayer(world, player)) { + return item; } - if (par3EntityPlayer.isSneaking()) { - return par1ItemStack; + if (player.isSneaking()) { + return item; } - toggleSigil(par1ItemStack, par2World, par3EntityPlayer); + toggleSigil(item, world, player); - return par1ItemStack; + return item; } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer)) { + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if (!(entity instanceof EntityPlayer player)) { return; } - if (SpellHelper.isFakePlayer(par2World, (EntityPlayer) par3Entity)) { + if (SpellHelper.isFakePlayer(world, player)) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; - - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); + if (!IBindable.isActive(item) || (world.isRemote)) { + return; } + Vec3 blockVec = SpellHelper.getEntityBlockVector(player); + int x = (int) blockVec.xCoord; + int y = (int) blockVec.yCoord; + int z = (int) blockVec.zCoord; - if (IBindable.isActive(par1ItemStack) && (!par2World.isRemote)) { - Vec3 blockVec = SpellHelper.getEntityBlockVector(par3EntityPlayer); - int x = (int) blockVec.xCoord; - int y = (int) blockVec.yCoord; - int z = (int) blockVec.zCoord; - - for (int i = -radius; i <= radius; i++) { - for (int j = -radius; j <= radius; j++) { - for (int k = -radius; k <= radius; k++) { - if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f)) { - continue; - } + for (int i = -radius; i <= radius; i++) { + for (int j = -radius; j <= radius; j++) { + for (int k = -radius; k <= radius; k++) { + if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f)) { + continue; + } + + Block block = world.getBlock(x + i, y + j, z + k); - Block block = par2World.getBlock(x + i, y + j, z + k); - - if (SpellHelper.isBlockFluid(block)) { - if (par2World.getTileEntity(x + i, y + j, z + k) != null) { - par2World.setBlockToAir(x + i, y + j, z + k); - } - TESpectralContainer.createSpectralBlockAtLocation(par2World, x + i, y + j, z + k, refresh); - } else { - TileEntity tile = par2World.getTileEntity(x + i, y + j, z + k); - if (tile instanceof TESpectralContainer) { - ((TESpectralContainer) tile).resetDuration(refresh); - } + if (SpellHelper.isBlockFluid(block)) { + if (world.getTileEntity(x + i, y + j, z + k) != null) { + world.setBlockToAir(x + i, y + j, z + k); + } + TESpectralContainer.createSpectralBlockAtLocation(world, x + i, y + j, z + k, refresh); + } else { + TileEntity tile = world.getTileEntity(x + i, y + j, z + k); + if (tile instanceof TESpectralContainer container) { + container.resetDuration(refresh); } } } } } - checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer); + checkPassiveDrain(item, world, player); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfTheAssassin.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfTheAssassin.java index cb2f96ca42..7a49e469ef 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfTheAssassin.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfTheAssassin.java @@ -40,9 +40,9 @@ public SigilOfTheAssassin() { } @Override - public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); + public void onCreated(ItemStack item, World world, EntityPlayer player) { + if (item.getTagCompound() == null) { + item.setTagCompound(new NBTTagCompound()); } } @@ -61,29 +61,28 @@ public ItemStack getContainerItem(ItemStack itemStack) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.sigiloftheassassin.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.sigiloftheassassin.desc")); + addBindingInformation(item, tooltip); } /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + @Override + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } float f = 10.0F; - MovingObjectPosition movingobjectposition = SpellHelper - .raytraceFromEntity(par2World, par3EntityPlayer, false, f); + MovingObjectPosition movingobjectposition = SpellHelper.raytraceFromEntity(world, player, false, f); if (movingobjectposition == null) { AlchemicalWizardry.logger.info("I saw nothing."); - return par1ItemStack; } else { - AlchemicalWizardry.logger.info("Got something! Type of hit: " + movingobjectposition.typeOfHit); + AlchemicalWizardry.logger.info("Got something! Type of hit: {}", movingobjectposition.typeOfHit); if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) { Entity hitEntity = movingobjectposition.entityHit; @@ -94,19 +93,12 @@ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, Enti if (hitEntity instanceof EntityLivingBase) { AlchemicalWizardry.logger.info("It's a living entity!"); - teleportTo( - par3EntityPlayer, - x, - y, - z, - par3EntityPlayer.posX, - par3EntityPlayer.posY, - par3EntityPlayer.posZ); + teleportTo(player, x, y, z, player.posX, player.posY, player.posZ); } } - return par1ItemStack; } + return item; } protected static boolean teleportTo(EntityLivingBase entityLiving, double par1, double par3, double par5, @@ -117,9 +109,6 @@ protected static boolean teleportTo(EntityLivingBase entityLiving, double par1, return false; } - double d3 = lastX; - double d4 = lastY; - double d5 = lastZ; SpellTeleport.moveEntityViaTeleport(entityLiving, event.targetX, event.targetY, event.targetZ); boolean flag = false; int i = MathHelper.floor_double(entityLiving.posX); @@ -153,7 +142,7 @@ protected static boolean teleportTo(EntityLivingBase entityLiving, double par1, } if (!flag) { - SpellTeleport.moveEntityViaTeleport(entityLiving, d3, d4, d5); + SpellTeleport.moveEntityViaTeleport(entityLiving, lastX, lastY, lastZ); return false; } else { short short1 = 128; @@ -163,13 +152,13 @@ protected static boolean teleportTo(EntityLivingBase entityLiving, double par1, float f = (entityLiving.worldObj.rand.nextFloat() - 0.5F) * 0.2F; float f1 = (entityLiving.worldObj.rand.nextFloat() - 0.5F) * 0.2F; float f2 = (entityLiving.worldObj.rand.nextFloat() - 0.5F) * 0.2F; - double d7 = d3 + (entityLiving.posX - d3) * d6 + double d7 = lastX + (entityLiving.posX - lastX) * d6 + (entityLiving.worldObj.rand.nextDouble() - 0.5D) * (double) entityLiving.width * 2.0D; - double d8 = d4 + (entityLiving.posY - d4) * d6 + double d8 = lastY + (entityLiving.posY - lastY) * d6 + entityLiving.worldObj.rand.nextDouble() * (double) entityLiving.height; - double d9 = d5 + (entityLiving.posZ - d5) * d6 + double d9 = lastZ + (entityLiving.posZ - lastZ) * d6 + (entityLiving.worldObj.rand.nextDouble() - 0.5D) * (double) entityLiving.width * 2.0D; - entityLiving.worldObj.spawnParticle("portal", d7, d8, d9, (double) f, (double) f1, (double) f2); + entityLiving.worldObj.spawnParticle("portal", d7, d8, d9, f, f1, f2); } return true; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfTheBridge.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfTheBridge.java index 23f6457b5d..dcc5a185b3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfTheBridge.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfTheBridge.java @@ -7,7 +7,6 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; @@ -39,10 +38,10 @@ public SigilOfTheBridge() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.sigilofthebridge.desc1")); - par3List.add(StatCollector.translateToLocal("tooltip.sigilofthebridge.desc2")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.sigilofthebridge.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.sigilofthebridge.desc2")); + addBindingInformation(item, tooltip); } @Override @@ -64,8 +63,8 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - if (par1 == 1) { + public IIcon getIconFromDamage(int meta) { + if (meta == 1) { return this.activeIcon; } else { return this.passiveIcon; @@ -73,103 +72,66 @@ public IIcon getIconFromDamage(int par1) { } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - toggleSigil(par1ItemStack, par2World, par3EntityPlayer); + toggleSigil(item, world, player); - return par1ItemStack; + return item; } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer)) { + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if (!(entity instanceof EntityPlayer player)) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; + if (!IBindable.isActive(item)) { + return; + } + checkPassiveDrain(item, world, player); + if (!player.onGround && !player.isSneaking()) { + return; + } - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); + int range = 2; + int verticalOffset = -1; + + if (player.isSneaking()) { + verticalOffset--; } - if (IBindable.isActive(par1ItemStack)) { - checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer); - if (!par3EntityPlayer.onGround && !par3EntityPlayer.isSneaking()) { - return; - } + if (world.isRemote) { + verticalOffset--; + } - int range = 2; - int verticalOffset = -1; + int posX = (int) Math.round(player.posX - 0.5f); + int posY = (int) player.posY; + int posZ = (int) Math.round(player.posZ - 0.5f); - if (par3EntityPlayer.isSneaking()) { - verticalOffset--; - } + for (int ix = posX - range; ix <= posX + range; ix++) { + for (int iz = posZ - range; iz <= posZ + range; iz++) { + { + Block block = world.getBlock(ix, posY + verticalOffset, iz); - if (par2World.isRemote) { - verticalOffset--; - } + if (world.isAirBlock(ix, posY + verticalOffset, iz)) { + world.setBlock(ix, posY + verticalOffset, iz, ModBlocks.spectralBlock, 0, 3); - int posX = (int) Math.round(par3Entity.posX - 0.5f); - int posY = (int) par3Entity.posY; - int posZ = (int) Math.round(par3Entity.posZ - 0.5f); - int incremented = 0; - - for (int ix = posX - range; ix <= posX + range; ix++) { - for (int iz = posZ - range; iz <= posZ + range; iz++) { - { - Block block = par2World.getBlock(ix, posY + verticalOffset, iz); - - if (par2World.isAirBlock(ix, posY + verticalOffset, iz)) { - par2World.setBlock(ix, posY + verticalOffset, iz, ModBlocks.spectralBlock, 0, 3); - - TileEntity tile = par2World.getTileEntity(ix, posY + verticalOffset, iz); - if (tile instanceof TESpectralBlock) { - ((TESpectralBlock) tile).setDuration(100); - } - - if (par2World.rand.nextInt(2) == 0) { - incremented++; - } - } else if (block == ModBlocks.spectralBlock) { - TileEntity tile = par2World.getTileEntity(ix, posY + verticalOffset, iz); - if (tile instanceof TESpectralBlock) { - ((TESpectralBlock) tile).setDuration(100); - } + TileEntity tile = world.getTileEntity(ix, posY + verticalOffset, iz); + if (tile instanceof TESpectralBlock) { + ((TESpectralBlock) tile).setDuration(100); + } + } else if (block == ModBlocks.spectralBlock) { + TileEntity tile = world.getTileEntity(ix, posY + verticalOffset, iz); + if (tile instanceof TESpectralBlock) { + ((TESpectralBlock) tile).setDuration(100); } } } } - - this.incrimentLPUSed(par1ItemStack, incremented); - } - } - - public int getLPUsed(ItemStack par1ItemStack) { - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); } - - return par1ItemStack.getTagCompound().getInteger("LPUsed"); - } - - public void incrimentLPUSed(ItemStack par1ItemStack, int addedLP) { - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); - } - - par1ItemStack.getTagCompound() - .setInteger("LPUsed", par1ItemStack.getTagCompound().getInteger("LPUsed") + addedLP); - } - - public void setLPUsed(ItemStack par1ItemStack, int newLP) { - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); - } - - par1ItemStack.getTagCompound().setInteger("LPUsed", newLP); } @Override @@ -188,21 +150,17 @@ public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemS int posX = (int) Math.round(player.posX - 0.5f); int posY = (int) player.posY; int posZ = (int) Math.round(player.posZ - 0.5f); - for (int ix = posX - range; ix <= posX + range; ix++) { - for (int iz = posZ - range; iz <= posZ + range; iz++) { - Block block = world.getBlock(ix, posY + verticalOffset, iz); - - if (world.isAirBlock(ix, posY + verticalOffset, iz)) { - world.setBlock(ix, posY + verticalOffset, iz, ModBlocks.spectralBlock, 0, 3); + for (int x = posX - range; x <= posX + range; x++) { + for (int z = posZ - range; z <= posZ + range; z++) { + Block block = world.getBlock(x, posY + verticalOffset, z); - TileEntity tile = world.getTileEntity(ix, posY + verticalOffset, iz); - if (tile instanceof TESpectralBlock) { - ((TESpectralBlock) tile).setDuration(100); - } - } else if (block == ModBlocks.spectralBlock) { - TileEntity tile = world.getTileEntity(ix, posY + verticalOffset, iz); - if (tile instanceof TESpectralBlock) { - ((TESpectralBlock) tile).setDuration(100); + if (world.isAirBlock(x, posY + verticalOffset, z)) { + world.setBlock(x, posY + verticalOffset, z, ModBlocks.spectralBlock, 0, 3); + } + if (block == ModBlocks.spectralBlock) { + TileEntity tile = world.getTileEntity(x, posY + verticalOffset, z); + if (tile instanceof TESpectralBlock b) { + b.setDuration(100); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfTheFastMiner.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfTheFastMiner.java index 46acaee9df..e05acf5347 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfTheFastMiner.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfTheFastMiner.java @@ -37,9 +37,9 @@ public SigilOfTheFastMiner() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.sigilofthefastminer.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.sigilofthefastminer.desc")); + addBindingInformation(item, tooltip); } @Override @@ -61,8 +61,8 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - if (par1 == 1) { + public IIcon getIconFromDamage(int meta) { + if (meta == 1) { return this.activeIcon; } else { return this.passiveIcon; @@ -70,35 +70,29 @@ public IIcon getIconFromDamage(int par1) { } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (toggleSigil(par1ItemStack, par2World, par3EntityPlayer)) { - par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 2, 1, true)); + if (toggleSigil(item, world, player)) { + player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 2, 1, true)); } - return par1ItemStack; + return item; } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer)) { + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if (!(entity instanceof EntityPlayer player)) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; - - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); - } - - if (IBindable.isActive(par1ItemStack)) { - par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 2, 1, true)); + if (IBindable.isActive(item)) { + player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 2, 1, true)); } - checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer); + checkPassiveDrain(item, world, player); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfWind.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfWind.java index 8ed414e595..e853d276c2 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfWind.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilOfWind.java @@ -36,9 +36,9 @@ public SigilOfWind() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.sigilofwind.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.sigilofwind.desc")); + addBindingInformation(item, tooltip); } @Override @@ -60,8 +60,8 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - if (par1 == 1) { + public IIcon getIconFromDamage(int meta) { + if (meta == 1) { return this.activeIcon; } else { return this.passiveIcon; @@ -69,35 +69,29 @@ public IIcon getIconFromDamage(int par1) { } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (toggleSigil(par1ItemStack, par2World, par3EntityPlayer)) { - par3EntityPlayer.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionProjProt.id, 2, 1)); + if (toggleSigil(item, world, player)) { + player.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionProjProt.id, 2, 1)); } - return par1ItemStack; + return item; } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer)) { + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if (!(entity instanceof EntityPlayer player)) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; - - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); - } - - if (IBindable.isActive(par1ItemStack)) { - par3EntityPlayer.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionProjProt.id, 2, 1)); + if (IBindable.isActive(item)) { + player.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionProjProt.id, 2, 1)); } - checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer); + checkPassiveDrain(item, world, player); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilPackRat.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilPackRat.java index b4017a6f63..b0fab27cbc 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilPackRat.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilPackRat.java @@ -7,7 +7,6 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraft.world.World; @@ -38,9 +37,9 @@ public SigilPackRat() { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.packratsigil.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.packratsigil.desc")); + addBindingInformation(item, tooltip); } @Override @@ -62,8 +61,8 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - if (par1 == 1) { + public IIcon getIconFromDamage(int meta) { + if (meta == 1) { return this.activeIcon; } else { return this.passiveIcon; @@ -71,43 +70,31 @@ public IIcon getIconFromDamage(int par1) { } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - toggleSigil(par1ItemStack, par2World, par3EntityPlayer); + toggleSigil(item, world, player); - return par1ItemStack; + return item; } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par3Entity instanceof EntityPlayer) || par2World.isRemote) { + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if (!(entity instanceof EntityPlayer player) || world.isRemote) { return; } - EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity; - - if (par1ItemStack.getTagCompound() == null) { - par1ItemStack.setTagCompound(new NBTTagCompound()); - } - - if (IBindable.isActive(par1ItemStack)) { - ItemStack stack = CompressionRegistry - .compressInventory(par3EntityPlayer.inventory.mainInventory, par2World); + if (IBindable.isActive(item)) { + ItemStack stack = CompressionRegistry.compressInventory(player.inventory.mainInventory, world); if (stack != null) { - EntityItem entityItem = new EntityItem( - par2World, - par3EntityPlayer.posX, - par3EntityPlayer.posY, - par3EntityPlayer.posZ, - stack); - par2World.spawnEntityInWorld(entityItem); + EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, stack); + world.spawnEntityInWorld(entityItem); } } - checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer); + checkPassiveDrain(item, world, player); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilSeer.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilSeer.java index 32f1bb59f1..39b2b3a8eb 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilSeer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilSeer.java @@ -6,7 +6,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraft.world.World; @@ -33,24 +32,15 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.seersigil.desc")); - addBindingInformation(par1ItemStack, par3List); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.seersigil.desc")); + addBindingInformation(item, tooltip); } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.worldObj.isRemote) { - return par1ItemStack; - } - - NBTTagCompound itemTag = par1ItemStack.getTagCompound(); - - if (itemTag == null || itemTag.getString("ownerName").equals("")) { - return par1ItemStack; - } - - return par1ItemStack; + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + IBindable.checkAndSetItemOwner(item, player); + return item; } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilVoid.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilVoid.java index 85ac31b2c8..ae4f56c02c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilVoid.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilVoid.java @@ -24,14 +24,12 @@ public class SigilVoid extends ItemBucket implements ArmourUpgrade, ISigil { - private int isFull; private int energyUsed; public SigilVoid() { super(null); this.maxStackSize = 1; setEnergyUsed(AlchemicalWizardry.sigilVoidCost); - isFull = 0; setCreativeTab(AlchemicalWizardry.tabBloodMagic); } @@ -42,9 +40,9 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.voidsigil.desc")); - addBindingInformation(stack, par3List); + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.voidsigil.desc")); + addBindingInformation(stack, tooltip); } @Override @@ -63,6 +61,7 @@ protected int getEnergyUsed() { return this.energyUsed; } + @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { return stack; } @@ -129,14 +128,6 @@ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, return false; } - /** - * Attempts to place the liquid contained inside the bucket. - */ - public boolean tryPlaceContainedLiquid(World par1World, double par2, double par4, double par6, int par8, int par9, - int par10) { - return false; - } - @Override public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack) {} diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilWater.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilWater.java index 4e658b914b..9196025e71 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilWater.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/SigilWater.java @@ -30,7 +30,6 @@ public class SigilWater extends ItemBucket implements ArmourUpgrade, ISigil { - private Block isFull = Blocks.water; private int energyUsed; public SigilWater() { @@ -59,14 +58,12 @@ public ItemStack getContainerItem(ItemStack itemStack) { } @Override - public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.watersigil.desc")); - addBindingInformation(stack, par3List); + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.watersigil.desc")); + addBindingInformation(stack, tooltip); } - /** - * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer - */ + @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { return stack; } @@ -96,95 +93,61 @@ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, return false; } - { - if (side == 0) { - --y; - } - - if (side == 1) { - ++y; - } - - if (side == 2) { - --z; - } - - if (side == 3) { - ++z; - } - - if (side == 4) { - --x; - } - - if (side == 5) { - ++x; - } + switch (side) { + case 0 -> --y; + case 1 -> ++y; + case 2 -> --z; + case 3 -> ++z; + case 4 -> --x; + case 5 -> ++x; + } - if (!player.canPlayerEdit(x, y, z, side, stack)) { - return false; - } + if (!player.canPlayerEdit(x, y, z, side, stack)) { + return false; + } - if (this.canPlaceContainedLiquid(world, x, y, z, x, y, z) - && EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) { - return this.tryPlaceContainedLiquid(world, x, y, z, x, y, z); - } + if (this.canPlaceContainedLiquid(world, x, y, z) + && EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) { + return this.tryPlaceContainedLiquid(world, x, y, z); } return false; } - /** - * Attempts to place the liquid contained inside the bucket. - */ - public boolean tryPlaceContainedLiquid(World par1World, double par2, double par4, double par6, int par8, int par9, - int par10) { - if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlock(par8, par9, par10).getMaterial().isSolid()) { - return false; - } else if ((par1World.getBlock(par8, par9, par10) == Blocks.water - || par1World.getBlock(par8, par9, par10) == Blocks.flowing_water) - && par1World.getBlockMetadata(par8, par9, par10) == 0) { - return false; - } else { - if (par1World.provider.isHellWorld) { - par1World.playSoundEffect( - par2 + 0.5D, - par4 + 0.5D, - par6 + 0.5D, - "random.fizz", - 0.5F, - 2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F); - - for (int l = 0; l < 8; ++l) { - par1World.spawnParticle( - "largesmoke", - (double) par8 + Math.random(), - (double) par9 + Math.random(), - (double) par10 + Math.random(), - 0.0D, - 0.0D, - 0.0D); - } - } else { - par1World.setBlock(par8, par9, par10, this.isFull, 0, 3); - par1World.markBlockForUpdate(par8, par9, par10); - } - - return true; - } + public boolean tryPlaceContainedLiquid(World world, int x, int y, int z) { + if (world.provider.isHellWorld) { + world.playSoundEffect( + x + 0.5D, + y + 0.5D, + z + 0.5D, + "random.fizz", + 0.5F, + 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + + for (int l = 0; l < 8; ++l) { + world.spawnParticle( + "largesmoke", + (double) x + Math.random(), + (double) y + Math.random(), + (double) z + Math.random(), + 0.0D, + 0.0D, + 0.0D); + } + } else { + world.setBlock(x, y, z, Blocks.water, 0, 3); + world.markBlockForUpdate(x, y, z); + } + + return true; } - public boolean canPlaceContainedLiquid(World par1World, double par2, double par4, double par6, int par8, int par9, - int par10) { - if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlock(par8, par9, par10).getMaterial().isSolid()) { + public boolean canPlaceContainedLiquid(World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + if (!world.isAirBlock(x, y, z) && block.getMaterial().isSolid()) { return false; - } else if ((par1World.getBlock(par8, par9, par10) == Blocks.water - || par1World.getBlock(par8, par9, par10) == Blocks.flowing_water) - && par1World.getBlockMetadata(par8, par9, par10) == 0) { - return false; - } else { - return true; - } + } + return (block != Blocks.water && block != Blocks.flowing_water) || world.getBlockMetadata(x, y, z) != 0; } protected void setEnergyUsed(int par1int) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/holding/ContainerHolding.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/holding/ContainerHolding.java index 3c18a3fd06..dee42a27dd 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/holding/ContainerHolding.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/holding/ContainerHolding.java @@ -14,7 +14,7 @@ public class ContainerHolding extends Container { protected final int PLAYER_INVENTORY_ROWS = 3; protected final int PLAYER_INVENTORY_COLUMNS = 9; - private int inventoryColumns = 5; + private final int inventoryColumns = 5; private final EntityPlayer player; public final InventoryHolding inventoryHolding; @@ -76,52 +76,53 @@ public void detectAndSendChanges() { @Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { ItemStack stack = null; - Slot slotObject = (Slot) inventorySlots.get(slotIndex); + Slot slotObject = inventorySlots.get(slotIndex); int slots = inventorySlots.size(); - if (slotObject != null && slotObject.getHasStack()) { - ItemStack stackInSlot = slotObject.getStack(); - stack = stackInSlot.copy(); + if (slotObject == null || !slotObject.getHasStack()) { + return null; + } + ItemStack stackInSlot = slotObject.getStack(); + stack = stackInSlot.copy(); - if (stack.getItem() instanceof ISigil) { - if (slotIndex < inventoryColumns) { - if (!this.mergeItemStack(stackInSlot, inventoryColumns, slots, false)) { - return null; - } - } else if (!this.mergeItemStack(stackInSlot, 0, inventoryColumns, false)) { + if (stack.getItem() instanceof ISigil) { + if (slotIndex < inventoryColumns) { + if (!this.mergeItemStack(stackInSlot, inventoryColumns, slots, false)) { return null; } - } else if (stack.getItem() instanceof SigilOfHolding) { - if (slotIndex < inventoryColumns + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS)) { - if (!this.mergeItemStack( - stackInSlot, - inventoryColumns + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), - inventorySlots.size(), - false)) { - return null; - } - } else if (!this.mergeItemStack( + } else if (!this.mergeItemStack(stackInSlot, 0, inventoryColumns, false)) { + return null; + } + } else if (stack.getItem() instanceof SigilOfHolding) { + if (slotIndex < inventoryColumns + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS)) { + if (!this.mergeItemStack( stackInSlot, - inventoryColumns, inventoryColumns + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), + inventorySlots.size(), false)) { - return null; - } - } - - if (stackInSlot.stackSize == 0) { - slotObject.putStack(null); - } else { - slotObject.onSlotChanged(); - } + return null; + } + } else if (!this.mergeItemStack( + stackInSlot, + inventoryColumns, + inventoryColumns + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), + false)) { + return null; + } + } - if (stackInSlot.stackSize == stack.stackSize) { - return null; - } + if (stackInSlot.stackSize == 0) { + slotObject.putStack(null); + } else { + slotObject.onSlotChanged(); + } - slotObject.onPickupFromSlot(player, stackInSlot); + if (stackInSlot.stackSize == stack.stackSize) { + return null; } + slotObject.onPickupFromSlot(player, stackInSlot); + return stack; } @@ -129,10 +130,10 @@ public void saveInventory(EntityPlayer entityPlayer) { inventoryHolding.onGuiSaved(entityPlayer); } - private class SlotHolding extends Slot { + private static class SlotHolding extends Slot { private final EntityPlayer player; - private ContainerHolding containerHolding; + private final ContainerHolding containerHolding; public SlotHolding(ContainerHolding containerHolding, IInventory inventory, EntityPlayer player, int slotIndex, int x, int y) { @@ -156,7 +157,7 @@ public boolean isItemValid(ItemStack itemStack) { } } - private class SlotDisabled extends Slot { + private static class SlotDisabled extends Slot { public SlotDisabled(IInventory inventory, int slotIndex, int x, int y) { super(inventory, slotIndex, x, y); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/holding/GuiHolding.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/holding/GuiHolding.java index a4b340e0f0..6647e6aea3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/holding/GuiHolding.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/holding/GuiHolding.java @@ -20,8 +20,7 @@ public GuiHolding(EntityPlayer player, InventoryHolding inventoryHolding) { @Override protected void drawGuiContainerForegroundLayer(int param1, int param2) { - // the parameters for drawString are: string, x, y, color - fontRendererObj.drawString("Sigil of Holding", 52, 4, 4210752); + fontRendererObj.drawString("Sigil of Holding", 52, 4, 0x404040); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/holding/SigilOfHolding.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/holding/SigilOfHolding.java index 387432a53b..2656710dfe 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/holding/SigilOfHolding.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/sigil/holding/SigilOfHolding.java @@ -22,7 +22,7 @@ public class SigilOfHolding extends EnergyItems implements ISigil { - private static int invSize = 5; + private static final int invSize = 5; private static final String NBT_CURRENT_SIGIL = "CurrentSigil"; @@ -40,142 +40,142 @@ public void registerIcons(IIconRegister iconRegister) { @Override public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { - if (!(stack.getTagCompound() == null)) { - ItemStack[] inv = getInternalInventory(stack); + if (stack.getTagCompound() == null) { + return this.itemIcon; + } + ItemStack[] inv = getInternalInventory(stack); - if (inv == null) { - return this.itemIcon; - } + if (inv == null) { + return this.itemIcon; + } - ItemStack item = getCurrentSigil(stack); + ItemStack item = getCurrentSigil(stack); - if (item != null) { - return item.getIconIndex(); - } + if (item != null) { + return item.getIconIndex(); } return this.itemIcon; } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(StatCollector.translateToLocal("tooltip.sigilofholding.desc")); + public void addInformation(ItemStack item, EntityPlayer player, List tooltip, boolean adv) { + tooltip.add(StatCollector.translateToLocal("tooltip.sigilofholding.desc")); - if (!(par1ItemStack.getTagCompound() == null)) { - addBindingInformation(par1ItemStack, par3List); + if (item.getTagCompound() == null) { + return; + } + addBindingInformation(item, tooltip); - ItemStack[] inv = getInternalInventory(par1ItemStack); + ItemStack[] inv = getInternalInventory(item); - if (inv == null) { - return; - } + if (inv == null) { + return; + } - int currentSlot = getCurrentItem(par1ItemStack); - ItemStack item = inv[currentSlot]; + int currentSlot = getCurrentItem(item); + ItemStack stack = inv[currentSlot]; - if (item != null) { - par3List.add(StatCollector.translateToLocal("tooltip.item.currentitem") + " " + item.getDisplayName()); - } + if (stack != null) { + tooltip.add(StatCollector.translateToLocal("tooltip.item.currentitem") + " " + stack.getDisplayName()); + } - for (int i = 0; i < invSize; i++) { - if (inv[i] != null) { - par3List.add( - StatCollector.translateToLocal("tooltip.item.iteminslot") + " " - + (i + 1) - + ": " - + inv[i].getDisplayName()); - } + for (int i = 0; i < invSize; i++) { + if (inv[i] != null) { + tooltip.add( + StatCollector.translateToLocal("tooltip.item.iteminslot") + " " + + (i + 1) + + ": " + + inv[i].getDisplayName()); } } } @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, - int par5, int par6, int par7, float par8, float par9, float par10) { - if (IBindable.checkAndSetItemOwner(par1ItemStack, par2EntityPlayer)) { - int currentSlot = getCurrentItem(par1ItemStack); - ItemStack[] inv = getInternalInventory(par1ItemStack); - - if (inv == null) { - return false; - } + public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int par4, int par5, int par6, int par7, + float par8, float par9, float par10) { + if (!IBindable.checkAndSetItemOwner(item, player)) { + return false; + } + int currentSlot = getCurrentItem(item); + ItemStack[] inv = getInternalInventory(item); - ItemStack itemUsed = inv[currentSlot]; + if (inv == null) { + return false; + } - if (itemUsed == null) { - return false; - } + ItemStack itemUsed = inv[currentSlot]; - boolean bool = itemUsed.getItem() - .onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); + if (itemUsed == null || itemUsed.getItem() == null) { + return false; + } - saveInventory(par1ItemStack, inv); + boolean result = itemUsed.getItem().onItemUse(item, player, world, par4, par5, par6, par7, par8, par9, par10); - return bool; - } + saveInventory(item, inv); - return false; + return result; } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer)) { - if (par3EntityPlayer.isSneaking()) { - InventoryHolding.setUUID(par1ItemStack); - par3EntityPlayer.openGui( + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (IBindable.checkAndSetItemOwner(item, player)) { + if (player.isSneaking()) { + InventoryHolding.setUUID(item); + player.openGui( AlchemicalWizardry.instance, 3, - par3EntityPlayer.worldObj, - (int) par3EntityPlayer.posX, - (int) par3EntityPlayer.posY, - (int) par3EntityPlayer.posZ); - return par1ItemStack; + player.worldObj, + (int) player.posX, + (int) player.posY, + (int) player.posZ); + return item; } - int currentSlot = getCurrentItem(par1ItemStack); - ItemStack[] inv = getInternalInventory(par1ItemStack); + int currentSlot = getCurrentItem(item); + ItemStack[] inv = getInternalInventory(item); if (inv == null) { - return par1ItemStack; + return item; } ItemStack itemUsed = inv[currentSlot]; - if (itemUsed == null) { - return par1ItemStack; + if (itemUsed == null || itemUsed.getItem() == null) { + return item; } - itemUsed.getItem().onItemRightClick(itemUsed, par2World, par3EntityPlayer); - saveInventory(par1ItemStack, inv); + itemUsed.getItem().onItemRightClick(itemUsed, world, player); + saveInventory(item, inv); } - return par1ItemStack; + return item; } @Override public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { - if (IBindable.checkAndSetItemOwner(stack, player)) { - int currentSlot = getCurrentItem(stack); - ItemStack[] inv = getInternalInventory(stack); + if (!IBindable.checkAndSetItemOwner(stack, player)) { + return false; + } + int currentSlot = getCurrentItem(stack); + ItemStack[] inv = getInternalInventory(stack); - if (inv == null) { - return false; - } + if (inv == null) { + return false; + } - ItemStack itemUsed = inv[currentSlot]; + ItemStack itemUsed = inv[currentSlot]; - if (itemUsed == null) { - return false; - } + if (itemUsed == null || itemUsed.getItem() == null) { + return false; + } - boolean bool = itemUsed.getItem().onItemUseFirst(stack, player, world, x, y, z, side, hitX, hitY, hitZ); + boolean bool = itemUsed.getItem().onItemUseFirst(stack, player, world, x, y, z, side, hitX, hitY, hitZ); - saveInventory(stack, inv); + saveInventory(stack, inv); - return bool; - } + return bool; - return false; } public static int next(int mode) { @@ -256,12 +256,6 @@ public static ItemStack[] getInternalInventory(ItemStack itemStack) { } public void saveInventory(ItemStack itemStack, ItemStack[] inventory) { - NBTTagCompound itemTag = itemStack.getTagCompound(); - - if (itemTag == null) { - itemStack.setTagCompound(new NBTTagCompound()); - } - NBTTagList itemList = new NBTTagList(); for (int i = 0; i < invSize; i++) { @@ -273,7 +267,7 @@ public void saveInventory(ItemStack itemStack, ItemStack[] inventory) { } } - itemTag.setTag(InventoryHolding.NBT_ITEMS, itemList); + IBindable.getTag(itemStack).setTag(InventoryHolding.NBT_ITEMS, itemList); } public static void cycleSigil(ItemStack itemStack, int mode) { @@ -284,26 +278,26 @@ public static void cycleSigil(ItemStack itemStack, int mode) { } @Override - public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - if (!(par1ItemStack.getTagCompound() == null)) { - this.tickInternalInventory(par1ItemStack, par2World, par3Entity, par4, par5); + public void onUpdate(ItemStack item, World world, Entity entity, int slot, boolean held) { + if (!(item.getTagCompound() == null)) { + this.tickInternalInventory(item, world, entity, slot, held); } } - public void tickInternalInventory(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, - boolean par5) { - ItemStack[] inv = getInternalInventory(par1ItemStack); + public void tickInternalInventory(ItemStack item, World world, Entity entity, int par4, boolean par5) { + ItemStack[] inv = getInternalInventory(item); if (inv == null) { return; } for (int i = 0; i < invSize; i++) { - if (inv[i] == null) { + ItemStack stack = inv[i]; + if (stack == null || stack.getItem() == null) { continue; } - inv[i].getItem().onUpdate(inv[i], par2World, par3Entity, par4, par5); + stack.getItem().onUpdate(stack, world, entity, par4, par5); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/thaumcraft/ItemSanguineArmour.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/thaumcraft/ItemSanguineArmour.java index b0deb94885..2f8de7d37f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/thaumcraft/ItemSanguineArmour.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/thaumcraft/ItemSanguineArmour.java @@ -56,8 +56,9 @@ public void registerIcons(IIconRegister iconRegister) { this.bootsIcon = iconRegister.registerIcon("AlchemicalWizardry:SanguineBoots"); } + @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { + public IIcon getIconFromDamage(int meta) { if (this.equals(ModItems.sanguineHelmet)) { return this.helmetIcon; } @@ -95,14 +96,14 @@ public String getArmorTexture(ItemStack stack, Entity entity, int slot, String t } @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean adv) { if (this.armorType == 0) { - list.add(StatCollector.translateToLocal("tooltip.sanguinearmor.desc1")); + tooltip.add(StatCollector.translateToLocal("tooltip.sanguinearmor.desc1")); } else { - list.add(StatCollector.translateToLocal("tooltip.sanguinearmor.desc2")); + tooltip.add(StatCollector.translateToLocal("tooltip.sanguinearmor.desc2")); } - list.add( + tooltip.add( EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocalFormatted( "tooltip.sanguinearmor.visdisc", getVisDiscount(stack, player, null))); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigm.java b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigm.java index 909e26d4ba..39a702fa2b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigm.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigm.java @@ -57,12 +57,12 @@ public boolean convertPlayerArmour(EntityPlayer player, int x, int y, int z, int && bootsStack.getItem() == ModItems.boundBoots) { long worldSeed = player.worldObj.getSeed(); Random rand = new Random( - worldSeed + stability * (affinity + 7) * 94 - + 84321 * x - - 17423 * y - + 76 * z - - 1623451 * enchantability - + 2 * enchantmentLevel); + worldSeed + (long) stability * (affinity + 7) * 94 + + 84321L * x + - 17423L * y + + 76L * z + - 1623451L * enchantability + + 2L * enchantmentLevel); ItemStack omegaHelmetStack = helmet .getSubstituteStack(helmetStack, stability, affinity, enchantability, enchantmentLevel, rand); ItemStack omegaChestStack = chestPiece @@ -96,8 +96,9 @@ public boolean setOmegaStalling(EntityPlayer player, int duration) { ItemStack chestStack = armours[2]; - if (chestStack != null && chestStack.getItem() == this.chestPiece) { - ((OmegaArmour) chestStack.getItem()).setOmegaStallingDuration(chestStack, duration); + if (chestStack != null && chestStack.getItem() == this.chestPiece + && chestStack.getItem() instanceof OmegaArmour armor) { + armor.setOmegaStallingDuration(chestStack, duration); return true; } @@ -113,8 +114,9 @@ public boolean doDrainReagent(EntityPlayer player) { ItemStack chestStack = armours[2]; - if (chestStack != null && chestStack.getItem() == this.chestPiece) { - return !((OmegaArmour) chestStack.getItem()).hasOmegaStalling(chestStack); + if (chestStack != null && chestStack.getItem() == this.chestPiece + && chestStack.getItem() instanceof OmegaArmour armor) { + return !armor.hasOmegaStalling(chestStack); } return true; } @@ -148,13 +150,6 @@ public boolean onHPBarDepleted(EntityPlayer player, ItemStack stack) { return false; } - /** - * - * @param stack - * @param player - * @param entity - * @return False if it does not do damage - */ public boolean onBoundSwordLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { return true; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigmEarth.java b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigmEarth.java index a931df4a36..60ac68f834 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigmEarth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigmEarth.java @@ -23,15 +23,6 @@ public OmegaParadigmEarth(OmegaArmour helmet, OmegaArmour chestPiece, OmegaArmou new ReagentRegenConfiguration(50, 1, 10)); } - @Override - public float getCostPerTickOfUse(EntityPlayer player) { - // if(player.isBurning()) - // { - // return 0.5f; - // } - return 1; - } - @Override public void onUpdate(World world, EntityPlayer player, ItemStack stack) { if (world.getWorldTime() % 100 == 0 && !world.isRemote) { @@ -50,6 +41,4 @@ public boolean getBlockEffectWhileInside(Entity entity, int x, int y, int z) { return true; } - @Override - public void onOmegaKeyPressed(EntityPlayer player, ItemStack stack) {} } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigmFire.java b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigmFire.java index fbbd57e8dd..b0bb4095ab 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigmFire.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigmFire.java @@ -61,6 +61,4 @@ public boolean getBlockEffectWhileInside(Entity entity, int x, int y, int z) { return true; } - @Override - public void onOmegaKeyPressed(EntityPlayer player, ItemStack stack) {} } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigmWind.java b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigmWind.java index 8d851e8250..a92e2b2967 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigmWind.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaParadigmWind.java @@ -47,6 +47,4 @@ public boolean getBlockEffectWhileInside(Entity entity, int x, int y, int z) { return true; } - @Override - public void onOmegaKeyPressed(EntityPlayer player, ItemStack stack) {} } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaRegistry.java b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaRegistry.java index 20c0432b4a..9b8a8f2f97 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaRegistry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaRegistry.java @@ -10,7 +10,7 @@ public class OmegaRegistry { - public static HashMap omegaList = new HashMap(); + public static HashMap omegaList = new HashMap<>(); public static void registerParadigm(Reagent reagent, OmegaParadigm parad) { omegaList.put(reagent, parad); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaStructureHandler.java b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaStructureHandler.java index d7dcb8d7af..5ae0a56e8c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaStructureHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaStructureHandler.java @@ -16,39 +16,36 @@ public static boolean isStructureIntact(World world, int x, int y, int z) { public static OmegaStructureParameters getStructureStabilityFactor(World world, int x, int y, int z, int expLim, Int3 offset) { - int range = expLim; - int[][][] boolList = new int[range * 2 + 1][range * 2 + 1][range * 2 + 1]; // 0 indicates unchecked, 1 indicates - // checked and is air, -1 indicates - // checked to be right + // 0 indicates unchecked, 1 indicates checked and is air, -1 indicates checked to be right // next to air blocks in question but is NOT air + int[][][] boolList = new int[expLim * 2 + 1][expLim * 2 + 1][expLim * 2 + 1]; - for (int i = 0; i < 2 * range + 1; i++) { - for (int j = 0; j < 2 * range + 1; j++) { - for (int k = 0; k < 2 * range + 1; k++) { + for (int i = 0; i < 2 * expLim + 1; i++) { + for (int j = 0; j < 2 * expLim + 1; j++) { + for (int k = 0; k < 2 * expLim + 1; k++) { boolList[i][j][k] = 0; } } } - boolList[range + offset.xCoord][range + offset.yCoord][range + offset.zCoord] = 1; + boolList[expLim + offset.x()][expLim + offset.y()][expLim + offset.z()] = 1; boolean isReady = false; while (!isReady) { isReady = true; - for (int i = 0; i < 2 * range + 1; i++) { - for (int j = 0; j < 2 * range + 1; j++) { - for (int k = 0; k < 2 * range + 1; k++) { + for (int i = 0; i < 2 * expLim + 1; i++) { + for (int j = 0; j < 2 * expLim + 1; j++) { + for (int k = 0; k < 2 * expLim + 1; k++) { if (boolList[i][j][k] == 1) { if (i - 1 >= 0 && !(boolList[i - 1][j][k] == 1 || boolList[i - 1][j][k] == -1)) { - Block block = world.getBlock(x - range + i - 1, y - range + j, z - range + k); - if (world.isAirBlock(x - range + i - 1, y - range + j, z - range + k) + Block block = world.getBlock(x - expLim + i - 1, y - expLim + j, z - expLim + k); + if (world.isAirBlock(x - expLim + i - 1, y - expLim + j, z - expLim + k) || block == ModBlocks.blockSpectralContainer) { - if (i - 1 == 0) // One of the found air blocks is at the range boundary, and thus - // the - // container is incomplete - { + // One of the found air blocks is at the range boundary, and thus + // the container is incomplete + if (i - 1 == 0) { return emptyParam; } boolList[i - 1][j][k] = 1; @@ -59,8 +56,8 @@ public static OmegaStructureParameters getStructureStabilityFactor(World world, } if (j - 1 >= 0 && !(boolList[i][j - 1][k] == 1 || boolList[i][j - 1][k] == -1)) { - Block block = world.getBlock(x - range + i, y - range + j - 1, z - range + k); - if (world.isAirBlock(x - range + i, y - range + j - 1, z - range + k) + Block block = world.getBlock(x - expLim + i, y - expLim + j - 1, z - expLim + k); + if (world.isAirBlock(x - expLim + i, y - expLim + j - 1, z - expLim + k) || block == ModBlocks.blockSpectralContainer) { if (j - 1 == 0) { return emptyParam; @@ -73,8 +70,8 @@ public static OmegaStructureParameters getStructureStabilityFactor(World world, } if (k - 1 >= 0 && !(boolList[i][j][k - 1] == 1 || boolList[i][j][k - 1] == -1)) { - Block block = world.getBlock(x - range + i, y - range + j, z - range + k - 1); - if (world.isAirBlock(x - range + i, y - range + j, z - range + k - 1) + Block block = world.getBlock(x - expLim + i, y - expLim + j, z - expLim + k - 1); + if (world.isAirBlock(x - expLim + i, y - expLim + j, z - expLim + k - 1) || block == ModBlocks.blockSpectralContainer) { if (k - 1 == 0) { return emptyParam; @@ -86,11 +83,11 @@ public static OmegaStructureParameters getStructureStabilityFactor(World world, } } - if (i + 1 <= 2 * range && !(boolList[i + 1][j][k] == 1 || boolList[i + 1][j][k] == -1)) { - Block block = world.getBlock(x - range + i + 1, y - range + j, z - range + k); - if (world.isAirBlock(x - range + i + 1, y - range + j, z - range + k) + if (i + 1 <= 2 * expLim && !(boolList[i + 1][j][k] == 1 || boolList[i + 1][j][k] == -1)) { + Block block = world.getBlock(x - expLim + i + 1, y - expLim + j, z - expLim + k); + if (world.isAirBlock(x - expLim + i + 1, y - expLim + j, z - expLim + k) || block == ModBlocks.blockSpectralContainer) { - if (i + 1 == range * 2) { + if (i + 1 == expLim * 2) { return emptyParam; } boolList[i + 1][j][k] = 1; @@ -100,11 +97,11 @@ public static OmegaStructureParameters getStructureStabilityFactor(World world, } } - if (j + 1 <= 2 * range && !(boolList[i][j + 1][k] == 1 || boolList[i][j + 1][k] == -1)) { - Block block = world.getBlock(x - range + i, y - range + j + 1, z - range + k); - if (world.isAirBlock(x - range + i, y - range + j + 1, z - range + k) + if (j + 1 <= 2 * expLim && !(boolList[i][j + 1][k] == 1 || boolList[i][j + 1][k] == -1)) { + Block block = world.getBlock(x - expLim + i, y - expLim + j + 1, z - expLim + k); + if (world.isAirBlock(x - expLim + i, y - expLim + j + 1, z - expLim + k) || block == ModBlocks.blockSpectralContainer) { - if (j + 1 == range * 2) { + if (j + 1 == expLim * 2) { return emptyParam; } boolList[i][j + 1][k] = 1; @@ -114,11 +111,11 @@ public static OmegaStructureParameters getStructureStabilityFactor(World world, } } - if (k + 1 <= 2 * range && !(boolList[i][j][k + 1] == 1 || boolList[i][j][k + 1] == -1)) { - Block block = world.getBlock(x - range + i, y - range + j, z - range + k + 1); - if (world.isAirBlock(x - range + i, y - range + j, z - range + k + 1) + if (k + 1 <= 2 * expLim && !(boolList[i][j][k + 1] == 1 || boolList[i][j][k + 1] == -1)) { + Block block = world.getBlock(x - expLim + i, y - expLim + j, z - expLim + k + 1); + if (world.isAirBlock(x - expLim + i, y - expLim + j, z - expLim + k + 1) || block == ModBlocks.blockSpectralContainer) { - if (k + 1 == range * 2) { + if (k + 1 == expLim * 2) { return emptyParam; } boolList[i][j][k + 1] = 1; @@ -137,9 +134,9 @@ public static OmegaStructureParameters getStructureStabilityFactor(World world, int enchantability = 0; int enchantmentLevel = 0; - for (int i = 0; i < 2 * range + 1; i++) { - for (int j = 0; j < 2 * range + 1; j++) { - for (int k = 0; k < 2 * range + 1; k++) { + for (int i = 0; i < 2 * expLim + 1; i++) { + for (int j = 0; j < 2 * expLim + 1; j++) { + for (int k = 0; k < 2 * expLim + 1; k++) { if (boolList[i][j][k] != -1) { continue; } @@ -158,39 +155,39 @@ public static OmegaStructureParameters getStructureStabilityFactor(World world, indTally++; } - if (i + 1 <= 2 * range && boolList[i + 1][j][k] == 1) { + if (i + 1 <= 2 * expLim && boolList[i + 1][j][k] == 1) { indTally++; } - if (j + 1 <= 2 * range && boolList[i][j + 1][k] == 1) { + if (j + 1 <= 2 * expLim && boolList[i][j + 1][k] == 1) { indTally++; } - if (k + 1 <= 2 * range && boolList[i][j][k + 1] == 1) { + if (k + 1 <= 2 * expLim && boolList[i][j][k + 1] == 1) { indTally++; } - Block block = world.getBlock(x - range + i, y - range + j, z - range + k); - int meta = world.getBlockMetadata(x - range + i, y - range + j, z - range + k); + Block block = world.getBlock(x - expLim + i, y - expLim + j, z - expLim + k); + int meta = world.getBlockMetadata(x - expLim + i, y - expLim + j, z - expLim + k); - if (block instanceof IEnchantmentGlyph) { - tally += ((IEnchantmentGlyph) block).getAdditionalStabilityForFaceCount( + if (block instanceof IEnchantmentGlyph glyph) { + tally += glyph.getAdditionalStabilityForFaceCount( world, - x - range + i, - y - range + j, - z - range + k, + x - expLim + i, + y - expLim + j, + z - expLim + k, meta, indTally); - enchantability += ((IEnchantmentGlyph) block) - .getEnchantability(world, x - range + i, y - range + j, z - range + k, meta); - enchantmentLevel += ((IEnchantmentGlyph) block) - .getEnchantmentLevel(world, x - range + i, y - range + j, z - range + k, meta); + enchantability += glyph + .getEnchantability(world, x - expLim + i, y - expLim + j, z - expLim + k, meta); + enchantmentLevel += glyph + .getEnchantmentLevel(world, x - expLim + i, y - expLim + j, z - expLim + k, meta); } else if (block instanceof IStabilityGlyph) { tally += ((IStabilityGlyph) block).getAdditionalStabilityForFaceCount( world, - x - range + i, - y - range + j, - z - range + k, + x - expLim + i, + y - expLim + j, + z - expLim + k, meta, indTally); } else { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/AlchemyCircleRenderer.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/AlchemyCircleRenderer.java index 10d25843d3..1b72180fab 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/AlchemyCircleRenderer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/AlchemyCircleRenderer.java @@ -11,18 +11,17 @@ public class AlchemyCircleRenderer extends MRSRenderer { - private ResourceLocation resourceLocation = new ResourceLocation( - "alchemicalwizardry:textures/models/TransCircle.png"); - private int colourRed; - private int colourGreen; - private int colourBlue; - private int colourIntensity; - private double xOffset; - private double yOffset; - private double zOffset; - private double radius; - private double initialY; - private boolean renderWithoutReagents; + private final ResourceLocation resourceLocation; + private final int colourRed; + private final int colourGreen; + private final int colourBlue; + private final int colourIntensity; + private final double xOffset; + private final double yOffset; + private final double zOffset; + private final double radius; + private final double initialY; + private final boolean renderWithoutReagents; public AlchemyCircleRenderer(ResourceLocation resource, int red, int green, int blue, int intensity, double xOff, double initialY, double yOff, double zOff, double radius, boolean renderWithoutReagents) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/BeamRenderer.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/BeamRenderer.java deleted file mode 100644 index 07f9b127c7..0000000000 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/BeamRenderer.java +++ /dev/null @@ -1,141 +0,0 @@ -package WayofTime.alchemicalWizardry.common.renderer; - -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; - -import WayofTime.alchemicalWizardry.api.ColourAndCoords; - -public class BeamRenderer { - - private static final ResourceLocation field_110629_a = new ResourceLocation("textures/entity/beacon_beam.png"); - - public int xInit; - public int yInit; - public int zInit; - - public int xFinal; - public int yFinal; - public int zFinal; - - public int colourRed; - public int colourGreen; - public int colourBlue; - public int colourIntensity; - - public double size; - - public void setInitialPosition(int x, int y, int z) { - this.xInit = x; - this.yInit = y; - this.zInit = z; - } - - public void setColourAndFinalPosition(ColourAndCoords col) { - this.colourRed = col.colourRed; - this.colourGreen = col.colourGreen; - this.colourBlue = col.colourBlue; - this.colourIntensity = col.colourIntensity; - - this.xFinal = col.xCoord; - this.yFinal = col.yCoord; - this.zFinal = col.zCoord; - } - - public void setSize(double size) { - this.size = size; - } - - protected static void bindTexture(ResourceLocation p_147499_1_) { - TextureManager texturemanager = TileEntityRendererDispatcher.instance.field_147553_e; - - if (texturemanager != null) { - texturemanager.bindTexture(p_147499_1_); - } - } - - public void render(double d0, double d1, double d2) { - int xDiff = this.xFinal - this.xInit; - int yDiff = this.yFinal - this.yInit; - int zDiff = this.zFinal - this.zInit; - - float planarAngle = (float) (Math.atan2(-zDiff, xDiff) * 180d / Math.PI); // Radians - float verticalAngle = (float) (Math.atan2(yDiff, Math.sqrt(xDiff * xDiff + zDiff + zDiff)) * 180d / Math.PI); - - float distance = (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff + zDiff * zDiff); // Total distance - - GL11.glPushMatrix(); - float f1 = 1.0f; - Tessellator tessellator = Tessellator.instance; - BeamRenderer.bindTexture(field_110629_a); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_CULL_FACE); - float f2 = 0; - float f3 = -f2 * 0.2F - (float) MathHelper.floor_float(-f2 * 0.1F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - GL11.glDepthMask(false); - - tessellator.startDrawingQuads(); - tessellator.setColorRGBA(colourRed, colourGreen, colourBlue, colourIntensity); - - double inside = -(this.size / 2d); - double outside = 1.0d - (0.50d - this.size / 2d) - 0.5d; - - double d18 = inside; - double d19 = inside; - double d20 = outside; - double d21 = inside; - double d22 = inside; - double d23 = outside; - double d24 = outside; - double d25 = outside; - double d26 = (double) (distance * f1); // + 0.2; - double d27 = 0.0D; - double d28 = 1.0D; - double d29 = (double) (-1.0F + f3); - double d30 = (double) (distance * f1) + d29; - - GL11.glTranslated(d0 + 0.5, d1 + 0.5, d2 + 0.5); - - GL11.glRotatef(planarAngle, 0F, 1F, 0F); // Rotate on planar axis - GL11.glRotatef(verticalAngle, 0F, 0F, 1F); // Rotate vertical axis - // GL11.glRotatef(tileAltar.getWorldObj().getWorldTime()*2f, 1F, 0F, 0F); //Rotate cylindrically - - double offset = 0; - - tessellator.setBrightness(240); - float s = 1F / 16F; - tessellator.addVertexWithUV(d26, d18, d19, d28, d30); - tessellator.addVertexWithUV(offset, d18, d19, d28, d29); - tessellator.addVertexWithUV(offset, d20, d21, d27, d29); - tessellator.addVertexWithUV(d26, d20, d21, d27, d30); - tessellator.addVertexWithUV(d26, d24, d25, d28, d30); - tessellator.addVertexWithUV(offset, d24, d25, d28, d29); - tessellator.addVertexWithUV(offset, d22, d23, d27, d29); - tessellator.addVertexWithUV(d26, d22, d23, d27, d30); - tessellator.addVertexWithUV(d26, d20, d21, d28, d30); - tessellator.addVertexWithUV(offset, d20, d21, d28, d29); - tessellator.addVertexWithUV(offset, d24, d25, d27, d29); - tessellator.addVertexWithUV(d26, d24, d25, d27, d30); - tessellator.addVertexWithUV(d26, d22, d23, d28, d30); - tessellator.addVertexWithUV(offset, d22, d23, d28, d29); - tessellator.addVertexWithUV(offset, d18, d19, d27, d29); - tessellator.addVertexWithUV(d26, d18, d19, d27, d30); - - tessellator.draw(); - GL11.glDepthMask(true); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glPopMatrix(); - } -} diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderAlchemicCalcinator.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderAlchemicCalcinator.java index 4eb57df5bf..8b548e1dd7 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderAlchemicCalcinator.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderAlchemicCalcinator.java @@ -2,8 +2,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemBlock; @@ -23,117 +21,103 @@ public class RenderAlchemicCalcinator extends TileEntitySpecialRenderer { - private final RenderItem customRenderItem; - private ModelAlchemicalCalcinator modelConduit = new ModelAlchemicalCalcinator(); - - private ResourceLocation resourceLocation = new ResourceLocation("alchemicalwizardry:textures/models/Reagent.png"); - - public RenderAlchemicCalcinator() { - customRenderItem = new RenderItem() { - - @Override - public boolean shouldBob() { - return false; - } - }; - customRenderItem.setRenderManager(RenderManager.instance); - } + private final ModelAlchemicalCalcinator CALCINATOR_MODEL = new ModelAlchemicalCalcinator(); + private final ResourceLocation REAGENT_TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/Reagent.png"); + private static final ResourceLocation CALCINATOR_TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/AlchemicalCalcinator.png"); @Override public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) { - if (tileEntity instanceof TEAlchemicCalcinator) { - TEAlchemicCalcinator tileAltar = (TEAlchemicCalcinator) tileEntity; + if (!(tileEntity instanceof TEAlchemicCalcinator calcinator)) { + return; + } - GL11.glPushMatrix(); - GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); - ResourceLocation test = new ResourceLocation("alchemicalwizardry:textures/models/AlchemicalCalcinator.png"); - FMLClientHandler.instance().getClient().renderEngine.bindTexture(test); - GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.modelConduit.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); - GL11.glPopMatrix(); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(CALCINATOR_TEXTURE); + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + this.CALCINATOR_MODEL.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + if (calcinator.getStackInSlot(1) != null) { GL11.glPushMatrix(); + boolean fancySaved = Minecraft.isFancyGraphicsEnabled(); + Minecraft.getMinecraft().gameSettings.fancyGraphics = true; - if (tileAltar.getStackInSlot(1) != null) { - - boolean fancySaved = Minecraft.isFancyGraphicsEnabled(); - Minecraft.getMinecraft().gameSettings.fancyGraphics = true; - - float scaleFactor = getGhostItemScaleFactor(tileAltar.getStackInSlot(1)); - EntityItem ghostEntityItem = new EntityItem(tileAltar.getWorldObj()); - ghostEntityItem.hoverStart = 0.0F; - ghostEntityItem.setEntityItemStack(tileAltar.getStackInSlot(1)); - float displacement = 0.2F; + float scaleFactor = getGhostItemScaleFactor(calcinator.getStackInSlot(1)); + EntityItem ghostEntityItem = new EntityItem(calcinator.getWorldObj()); + ghostEntityItem.hoverStart = 0.0F; + ghostEntityItem.setEntityItemStack(calcinator.getStackInSlot(1)); + float displacement = 0.2F; - if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock) { - GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.7F, (float) d2 + 0.5F); - } else { - GL11.glTranslatef( - (float) d0 + 0.5F, - (float) d1 + displacement + 10.4f / 16.0f, - (float) d2 + 0.5F - 0.0625f * 2f); - } - GL11.glScalef(scaleFactor, scaleFactor, scaleFactor); - - if (!(ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock)) { - GL11.glRotatef(90f, 1.0f, 0.0f, 0.0F); - } + if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock) { + GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.7F, (float) d2 + 0.5F); + } else { + GL11.glTranslatef( + (float) d0 + 0.5F, + (float) d1 + displacement + 10.4f / 16.0f, + (float) d2 + 0.5F - 0.0625f * 2f); + } + GL11.glScalef(scaleFactor, scaleFactor, scaleFactor); - customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0); - Minecraft.getMinecraft().gameSettings.fancyGraphics = fancySaved; + if (!(ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock)) { + GL11.glRotatef(90f, 1.0f, 0.0f, 0.0F); } + TEAltarRenderer.customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0); + Minecraft.getMinecraft().gameSettings.fancyGraphics = fancySaved; GL11.glPopMatrix(); - GL11.glPushMatrix(); - - if (tileAltar.getStackInSlot(0) != null) { - - boolean fancySaved = Minecraft.isFancyGraphicsEnabled(); - Minecraft.getMinecraft().gameSettings.fancyGraphics = true; + } - float scaleFactor = getGhostItemScaleFactor(tileAltar.getStackInSlot(0)); - EntityItem ghostEntityItem = new EntityItem(tileAltar.getWorldObj()); - ghostEntityItem.hoverStart = 0.0F; - ghostEntityItem.setEntityItemStack(tileAltar.getStackInSlot(0)); - float displacement = -0.5F; + if (calcinator.getStackInSlot(0) != null) { + GL11.glPushMatrix(); + boolean fancySaved = Minecraft.isFancyGraphicsEnabled(); + Minecraft.getMinecraft().gameSettings.fancyGraphics = true; - if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock) { - GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.7F, (float) d2 + 0.5F); - } else { - GL11.glTranslatef( - (float) d0 + 0.5F, - (float) d1 + displacement + 10.4f / 16.0f, - (float) d2 + 0.5F - 0.0625f * 2f); - } - GL11.glScalef(scaleFactor, scaleFactor, scaleFactor); + float scaleFactor = getGhostItemScaleFactor(calcinator.getStackInSlot(0)); + EntityItem ghostEntityItem = new EntityItem(calcinator.getWorldObj()); + ghostEntityItem.hoverStart = 0.0F; + ghostEntityItem.setEntityItemStack(calcinator.getStackInSlot(0)); + float displacement = -0.5F; - if (!(ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock)) { - GL11.glRotatef(90f, 1.0f, 0.0f, 0.0F); - } + if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock) { + GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.7F, (float) d2 + 0.5F); + } else { + GL11.glTranslatef( + (float) d0 + 0.5F, + (float) d1 + displacement + 10.4f / 16.0f, + (float) d2 + 0.5F - 0.0625f * 2f); + } + GL11.glScalef(scaleFactor, scaleFactor, scaleFactor); - customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0); - Minecraft.getMinecraft().gameSettings.fancyGraphics = fancySaved; + if (!(ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock)) { + GL11.glRotatef(90f, 1.0f, 0.0f, 0.0F); } + TEAltarRenderer.customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0); + Minecraft.getMinecraft().gameSettings.fancyGraphics = fancySaved; GL11.glPopMatrix(); + } - ReagentContainerInfo[] info = tileAltar.getContainerInfo(ForgeDirection.UNKNOWN); - if (info.length >= 1 && info[0] != null) { - ReagentStack reagentStack = info[0].reagent; - int capacity = info[0].capacity; - if (reagentStack != null && reagentStack.reagent != null) { - Reagent reagent = reagentStack.reagent; - this.renderTankContents( - d0, - d1, - d2, - reagent.getColourRed(), - reagent.getColourGreen(), - reagent.getColourBlue(), - 200 * reagentStack.amount / capacity); - } + ReagentContainerInfo[] info = calcinator.getContainerInfo(ForgeDirection.UNKNOWN); + if (info.length >= 1 && info[0] != null) { + ReagentStack reagentStack = info[0].reagent; + int capacity = info[0].capacity; + if (reagentStack != null && reagentStack.reagent != null) { + Reagent reagent = reagentStack.reagent; + this.renderTankContents( + d0, + d1, + d2, + reagent.red(), + reagent.green(), + reagent.blue(), + 200 * reagentStack.amount / capacity); } } } @@ -142,7 +126,7 @@ private void renderTankContents(double x, double y, double z, int colourRed, int int colourIntensity) { GL11.glPushMatrix(); Tessellator tessellator = Tessellator.instance; - this.bindTexture(resourceLocation); + this.bindTexture(REAGENT_TEXTURE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); GL11.glDisable(GL11.GL_LIGHTING); @@ -200,194 +184,16 @@ private float getGhostItemScaleFactor(ItemStack itemStack) { if (itemStack != null) { if (itemStack.getItem() instanceof ItemBlock) { - switch (customRenderItem.getMiniBlockCount(itemStack, (byte) 1)) { - case 1: - return 0.90F * scaleFactor; - - case 2: - return 0.90F * scaleFactor; - - case 3: - return 0.90F * scaleFactor; - - case 4: - return 0.90F * scaleFactor; - - case 5: - return 0.80F * scaleFactor; - - default: - return 0.90F * scaleFactor; + if (TEAltarRenderer.customRenderItem.getMiniBlockCount(itemStack, (byte) 1) == 5) { + return 0.80F * scaleFactor; } + return 0.90F * scaleFactor; } else { - switch (customRenderItem.getMiniItemCount(itemStack, (byte) 1)) { - case 1: - return 0.65F * scaleFactor; - - case 2: - return 0.65F * scaleFactor; - - case 3: - return 0.65F * scaleFactor; - - case 4: - return 0.65F * scaleFactor; - - default: - return 0.65F * scaleFactor; - } + return 0.65F * scaleFactor; } } return scaleFactor; } - private float getXDisplacementForSlot(int slot) { - switch (slot) { - case 0: - return 0.0f; - - case 1: - return -0.375f; - - case 2: - return -0.125f; - - case 3: - return 0.3125f; - - case 4: - return 0.3125f; - - case 5: - return -0.125f; - - default: - return 0.0f; - } - } - - private float getYDisplacementForSlot(int slot) { - switch (slot) { - case 0: - return 0.4f; - - case 1: - return -0.35f; - - case 6: - return 0.4f; - - default: - return -0.35f; - } - } - - private float getZDisplacementForSlot(int slot) { - switch (slot) { - case 0: - return 0.0f; - - case 1: - return 0.0f; - - case 2: - return 0.375f; - - case 3: - return 0.25f; - - case 4: - return -0.25f; - - case 5: - return -0.375f; - - default: - return 0.0f; - } - } - - private void translateGhostItemByOrientation(ItemStack ghostItemStack, double x, double y, double z, - ForgeDirection forgeDirection) { - if (ghostItemStack != null) { - if (ghostItemStack.getItem() instanceof ItemBlock) { - switch (forgeDirection) { - case DOWN: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 2.7F, (float) z + 0.5F); - return; - } - - case UP: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.25F, (float) z + 0.5F); - return; - } - - case NORTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.7F); - return; - } - - case SOUTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.3F); - return; - } - - case EAST: { - GL11.glTranslatef((float) x + 0.3F, (float) y + 0.5F, (float) z + 0.5F); - return; - } - - case WEST: { - GL11.glTranslatef((float) x + 0.70F, (float) y + 0.5F, (float) z + 0.5F); - return; - } - - case UNKNOWN: { - return; - } - - default: {} - } - } else { - switch (forgeDirection) { - case DOWN: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.6F, (float) z + 0.5F); - return; - } - - case UP: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.20F, (float) z + 0.5F); - return; - } - - case NORTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.7F); - return; - } - - case SOUTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.3F); - return; - } - - case EAST: { - GL11.glTranslatef((float) x + 0.3F, (float) y + 0.4F, (float) z + 0.5F); - return; - } - - case WEST: { - GL11.glTranslatef((float) x + 0.70F, (float) y + 0.4F, (float) z + 0.5F); - return; - } - - case UNKNOWN: { - return; - } - - default: {} - } - } - } - } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderConduit.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderConduit.java index 89909139ce..e99d6b8251 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderConduit.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderConduit.java @@ -1,7 +1,6 @@ package WayofTime.alchemicalWizardry.common.renderer.block; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; @@ -13,20 +12,21 @@ public class RenderConduit extends TileEntitySpecialRenderer { - private ModelConduit modelConduit = new ModelConduit(); + public static final ResourceLocation TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/Conduit.png"); + private final ModelConduit MODEL = new ModelConduit(); @Override public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) { - if (tileEntity instanceof TEConduit) { - TEConduit tileConduit = (TEConduit) tileEntity; + if (tileEntity instanceof TEConduit tileConduit) { GL11.glPushMatrix(); GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); - ResourceLocation test = new ResourceLocation("alchemicalwizardry:textures/models/Conduit.png"); - FMLClientHandler.instance().getClient().renderEngine.bindTexture(test); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.modelConduit.render( - (Entity) null, + this.MODEL.render( + null, 0.0F, 0.0F, 0.0F, diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderCrystalBelljar.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderCrystalBelljar.java index 36f605d065..2c1b7525b9 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderCrystalBelljar.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderCrystalBelljar.java @@ -3,7 +3,6 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.ForgeDirection; @@ -18,60 +17,59 @@ public class RenderCrystalBelljar extends TileEntitySpecialRenderer { - private ModelCrystalBelljar modelConduit = new ModelCrystalBelljar(); - - private ResourceLocation resourceLocation = new ResourceLocation("alchemicalwizardry:textures/models/Reagent.png"); + private final ModelCrystalBelljar MODEL = new ModelCrystalBelljar(); + public static final ResourceLocation BELLJAR_TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/CrystalBelljar.png"); + private final ResourceLocation REAGENT_TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/Reagent.png"); @Override public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) { - if (tileEntity instanceof TEBellJar) { - TEBellJar tileAltar = (TEBellJar) tileEntity; - GL11.glPushMatrix(); - GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); - ResourceLocation test = new ResourceLocation("alchemicalwizardry:textures/models/CrystalBelljar.png"); - FMLClientHandler.instance().getClient().renderEngine.bindTexture(test); - GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.modelConduit.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); - GL11.glPopMatrix(); - GL11.glPopMatrix(); + if (!(tileEntity instanceof TEBellJar tileAltar)) { + return; + } + GL11.glPushMatrix(); + GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(BELLJAR_TEXTURE); + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + this.MODEL.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); + GL11.glPopMatrix(); + GL11.glPopMatrix(); - ReagentContainerInfo[] info = tileAltar.getContainerInfo(ForgeDirection.UNKNOWN); - if (info.length >= 1 && info[0] != null) { - ReagentStack reagentStack = info[0].reagent; - int capacity = info[0].capacity; - if (reagentStack != null && reagentStack.reagent != null) { - Reagent reagent = reagentStack.reagent; - this.renderTankContents( - d0, - d1, - d2, - reagent.getColourRed(), - reagent.getColourGreen(), - reagent.getColourBlue(), - 200 * reagentStack.amount / capacity); - } + ReagentContainerInfo[] info = tileAltar.getContainerInfo(ForgeDirection.UNKNOWN); + if (info.length >= 1 && info[0] != null) { + ReagentStack reagentStack = info[0].reagent; + int capacity = info[0].capacity; + if (reagentStack != null && reagentStack.reagent != null) { + Reagent reagent = reagentStack.reagent; + this.renderTankContents( + d0, + d1, + d2, + reagent.red(), + reagent.green(), + reagent.blue(), + 200 * reagentStack.amount / capacity); } } } - private void renderTankContents(double x, double y, double z, int colourRed, int colourGreen, int colourBlue, - int colourIntensity) { + private void renderTankContents(double x, double y, double z, int red, int green, int blue, int intensity) { GL11.glPushMatrix(); - float f1 = 1.0f; Tessellator tessellator = Tessellator.instance; - this.bindTexture(resourceLocation); + this.bindTexture(REAGENT_TEXTURE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_CULL_FACE); - float f2 = 0; - float f3 = -f2 * 0.2F - (float) MathHelper.floor_float(-f2 * 0.1F); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDepthMask(false); tessellator.startDrawingQuads(); - tessellator.setColorRGBA(colourRed, colourGreen, colourBlue, colourIntensity); + tessellator.setColorRGBA(red, green, blue, intensity); GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); tessellator.setBrightness(240); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderMasterStone.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderMasterStone.java index ad9e2f7894..31040c44d1 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderMasterStone.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderMasterStone.java @@ -11,12 +11,12 @@ public class RenderMasterStone extends TileEntitySpecialRenderer { @Override public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) { - if (tileEntity instanceof TEMasterStone) { - String str = ((TEMasterStone) tileEntity).getCurrentRitual(); + if (tileEntity instanceof TEMasterStone stone) { + String str = stone.getCurrentRitual(); MRSRenderer renderer = Rituals.getRendererForKey(str); if (renderer != null) { - renderer.renderAt(((TEMasterStone) tileEntity), d0, d1, d2); + renderer.renderAt(stone, d0, d1, d2); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderPedestal.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderPedestal.java index 64f32baaf3..c69307a942 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderPedestal.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderPedestal.java @@ -1,15 +1,12 @@ package WayofTime.alchemicalWizardry.common.renderer.block; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; @@ -19,196 +16,59 @@ public class RenderPedestal extends TileEntitySpecialRenderer { - private ModelPedestal modelPedestal = new ModelPedestal(); - private final RenderItem customRenderItem; - - public RenderPedestal() { - customRenderItem = new RenderItem() { - - @Override - public boolean shouldBob() { - return false; - } - }; - customRenderItem.setRenderManager(RenderManager.instance); - } + private static final ResourceLocation TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/Pedestal.png"); + private static final ModelPedestal MODEL = new ModelPedestal(); @Override public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) { - if (tileEntity instanceof TEPedestal) { - TEPedestal tileAltar = (TEPedestal) tileEntity; - GL11.glPushMatrix(); - GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); - ResourceLocation test = new ResourceLocation("alchemicalwizardry:textures/models/Pedestal.png"); - FMLClientHandler.instance().getClient().renderEngine.bindTexture(test); - GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.modelPedestal.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - - if (tileAltar.getStackInSlot(0) != null) { - float scaleFactor = getGhostItemScaleFactor(tileAltar.getStackInSlot(0)); - float rotationAngle = Minecraft.isFancyGraphicsEnabled() - ? (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL) - : 0; - - EntityItem ghostEntityItem = new EntityItem(tileAltar.getWorldObj()); - ghostEntityItem.hoverStart = 0.0F; - ghostEntityItem.setEntityItemStack(tileAltar.getStackInSlot(0)); - float displacement = 0.2F; - - if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock) { - GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.7F, (float) d2 + 0.5F); - } else { - GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.6F, (float) d2 + 0.5F); - } - GL11.glScalef(scaleFactor, scaleFactor, scaleFactor); - GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F); - customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0); - } - - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); - - FMLClientHandler.instance().getClient().renderEngine.bindTexture(test); - GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glPopMatrix(); - GL11.glPopMatrix(); + if (!(tileEntity instanceof TEPedestal tileAltar)) { + return; } - } - - private float getGhostItemScaleFactor(ItemStack itemStack) { - float scaleFactor = 1.0F; - - if (itemStack != null) { - if (itemStack.getItem() instanceof ItemBlock) { - switch (customRenderItem.getMiniBlockCount(itemStack, (byte) 1)) { - case 1: - return 0.90F; - - case 2: - return 0.90F; - - case 3: - return 0.90F; - - case 4: - return 0.90F; - - case 5: - return 0.80F; - - default: - return 0.90F; - } + GL11.glPushMatrix(); + GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE); + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + MODEL.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + + if (tileAltar.getStackInSlot(0) != null) { + float scaleFactor = getGhostItemScaleFactor(tileAltar.getStackInSlot(0)); + float rotationAngle = Minecraft.isFancyGraphicsEnabled() + ? (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL) + : 0; + + EntityItem ghostEntityItem = new EntityItem(tileAltar.getWorldObj()); + ghostEntityItem.hoverStart = 0.0F; + ghostEntityItem.setEntityItemStack(tileAltar.getStackInSlot(0)); + float displacement = 0.2F; + + if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock) { + GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.7F, (float) d2 + 0.5F); } else { - switch (customRenderItem.getMiniItemCount(itemStack, (byte) 1)) { - case 1: - return 0.65F; - - case 2: - return 0.65F; - - case 3: - return 0.65F; - - case 4: - return 0.65F; - - default: - return 0.65F; - } + GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.6F, (float) d2 + 0.5F); } + GL11.glScalef(scaleFactor, scaleFactor, scaleFactor); + GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F); + TEAltarRenderer.customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0); } - - return scaleFactor; + GL11.glPopMatrix(); } - private void translateGhostItemByOrientation(ItemStack ghostItemStack, double x, double y, double z, - ForgeDirection forgeDirection) { - if (ghostItemStack != null) { - if (ghostItemStack.getItem() instanceof ItemBlock) { - switch (forgeDirection) { - case DOWN: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 2.7F, (float) z + 0.5F); - return; - } - - case UP: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.25F, (float) z + 0.5F); - return; - } - - case NORTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.7F); - return; - } - - case SOUTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.3F); - return; - } - - case EAST: { - GL11.glTranslatef((float) x + 0.3F, (float) y + 0.5F, (float) z + 0.5F); - return; - } - - case WEST: { - GL11.glTranslatef((float) x + 0.70F, (float) y + 0.5F, (float) z + 0.5F); - return; - } - - case UNKNOWN: { - return; - } - - default: {} - } - } else { - switch (forgeDirection) { - case DOWN: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.6F, (float) z + 0.5F); - return; - } - - case UP: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.20F, (float) z + 0.5F); - return; - } - - case NORTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.7F); - return; - } - - case SOUTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.3F); - return; - } - - case EAST: { - GL11.glTranslatef((float) x + 0.3F, (float) y + 0.4F, (float) z + 0.5F); - return; - } - - case WEST: { - GL11.glTranslatef((float) x + 0.70F, (float) y + 0.4F, (float) z + 0.5F); - return; - } - - case UNKNOWN: { - return; - } - - default: {} - } - } + private float getGhostItemScaleFactor(ItemStack itemStack) { + if (itemStack == null) { + return 1.0F; + } + if (!(itemStack.getItem() instanceof ItemBlock)) { + return 0.65F; + } + if (TEAltarRenderer.customRenderItem.getMiniBlockCount(itemStack, (byte) 1) == 5) { + return 0.80F; } + return 0.90F; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderPlinth.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderPlinth.java index 63b4371cbb..a15be8e23f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderPlinth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderPlinth.java @@ -1,15 +1,12 @@ package WayofTime.alchemicalWizardry.common.renderer.block; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; @@ -19,196 +16,69 @@ public class RenderPlinth extends TileEntitySpecialRenderer { - private ModelPlinth modelPlinth = new ModelPlinth(); - private final RenderItem customRenderItem; - - public RenderPlinth() { - customRenderItem = new RenderItem() { - - @Override - public boolean shouldBob() { - return false; - } - }; - customRenderItem.setRenderManager(RenderManager.instance); - } + private static final ResourceLocation TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/Plinth.png"); + private static final ModelPlinth MODEL = new ModelPlinth(); @Override - public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) { - if (tileEntity instanceof TEPlinth) { - TEPlinth tilePlinth = (TEPlinth) tileEntity; - GL11.glPushMatrix(); - GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); - ResourceLocation test = new ResourceLocation("alchemicalwizardry:textures/models/Plinth.png"); - FMLClientHandler.instance().getClient().renderEngine.bindTexture(test); - GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.modelPlinth.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - - if (tilePlinth.getStackInSlot(0) != null) { - - boolean fancySaved = Minecraft.isFancyGraphicsEnabled(); - Minecraft.getMinecraft().gameSettings.fancyGraphics = true; - - float scaleFactor = getGhostItemScaleFactor(tilePlinth.getStackInSlot(0)); - EntityItem ghostEntityItem = new EntityItem(tilePlinth.getWorldObj()); - ghostEntityItem.hoverStart = 0.0F; - ghostEntityItem.setEntityItemStack(tilePlinth.getStackInSlot(0)); - float displacement = 0.2F; - - if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock) { - GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.7F, (float) d2 + 0.5F); - } else { - GL11.glTranslatef( - (float) d0 + 0.5F, - (float) d1 + displacement + 10.4f / 16.0f, - (float) d2 + 0.5F - 0.1875f); - } - GL11.glScalef(scaleFactor, scaleFactor, scaleFactor); - - if (!(ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock)) { - GL11.glRotatef(90f, 1.0f, 0.0f, 0.0F); - } - - customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0); - - Minecraft.getMinecraft().gameSettings.fancyGraphics = fancySaved; - } - - GL11.glPopMatrix(); + public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { + if (!(tileEntity instanceof TEPlinth tilePlinth)) { + return; } - } - - private float getGhostItemScaleFactor(ItemStack itemStack) { - float scaleFactor = 2.0F / 0.9F; - - if (itemStack != null) { - if (itemStack.getItem() instanceof ItemBlock) { - switch (customRenderItem.getMiniBlockCount(itemStack, (byte) 1)) { - case 1: - return 0.90F * scaleFactor / 2; - - case 2: - return 0.90F * scaleFactor / 2; - - case 3: - return 0.90F * scaleFactor / 2; - - case 4: - return 0.90F * scaleFactor / 2; - - case 5: - return 0.80F * scaleFactor / 2; - - default: - return 0.90F * scaleFactor / 2; - } + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE); + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + MODEL.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + + if (tilePlinth.getStackInSlot(0) != null) { + boolean fancySaved = Minecraft.isFancyGraphicsEnabled(); + Minecraft.getMinecraft().gameSettings.fancyGraphics = true; + + float scaleFactor = getGhostItemScaleFactor(tilePlinth.getStackInSlot(0)); + EntityItem ghostEntityItem = new EntityItem(tilePlinth.getWorldObj()); + ghostEntityItem.hoverStart = 0.0F; + ghostEntityItem.setEntityItemStack(tilePlinth.getStackInSlot(0)); + float displacement = 0.2F; + + if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock) { + GL11.glTranslatef((float) x + 0.5F, (float) y + displacement + 0.7F, (float) z + 0.5F); } else { - switch (customRenderItem.getMiniItemCount(itemStack, (byte) 1)) { - case 1: - return 0.65F * scaleFactor; - - case 2: - return 0.65F * scaleFactor; + GL11.glTranslatef( + (float) x + 0.5F, + (float) y + displacement + 10.4f / 16.0f, + (float) z + 0.5F - 0.1875f); + } + GL11.glScalef(scaleFactor, scaleFactor, scaleFactor); - case 3: - return 0.65F * scaleFactor; + if (!(ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock)) { + GL11.glRotatef(90f, 1.0f, 0.0f, 0.0F); + } - case 4: - return 0.65F * scaleFactor; + TEAltarRenderer.customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0); - default: - return 0.65F * scaleFactor; - } - } + Minecraft.getMinecraft().gameSettings.fancyGraphics = fancySaved; } - return scaleFactor; + GL11.glPopMatrix(); } - private void translateGhostItemByOrientation(ItemStack ghostItemStack, double x, double y, double z, - ForgeDirection forgeDirection) { - if (ghostItemStack != null) { - if (ghostItemStack.getItem() instanceof ItemBlock) { - switch (forgeDirection) { - case DOWN: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 2.7F, (float) z + 0.5F); - return; - } - - case UP: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.25F, (float) z + 0.5F); - return; - } - - case NORTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.7F); - return; - } - - case SOUTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.3F); - return; - } - - case EAST: { - GL11.glTranslatef((float) x + 0.3F, (float) y + 0.5F, (float) z + 0.5F); - return; - } - - case WEST: { - GL11.glTranslatef((float) x + 0.70F, (float) y + 0.5F, (float) z + 0.5F); - return; - } - - case UNKNOWN: { - return; - } - - default: {} - } - } else { - switch (forgeDirection) { - case DOWN: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.6F, (float) z + 0.5F); - return; - } - - case UP: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.20F, (float) z + 0.5F); - return; - } - - case NORTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.7F); - return; - } - - case SOUTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.3F); - return; - } - - case EAST: { - GL11.glTranslatef((float) x + 0.3F, (float) y + 0.4F, (float) z + 0.5F); - return; - } - - case WEST: { - GL11.glTranslatef((float) x + 0.70F, (float) y + 0.4F, (float) z + 0.5F); - return; - } - - case UNKNOWN: { - return; - } - - default: {} - } - } + private float getGhostItemScaleFactor(ItemStack itemStack) { + if (itemStack == null) { + return 2.22f; + } + if (!(itemStack.getItem() instanceof ItemBlock)) { + return 1.44f; } + if (TEAltarRenderer.customRenderItem.getMiniBlockCount(itemStack, (byte) 1) == 5) { + return 0.89f; + } + return 1.0f; } + } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderReagentConduit.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderReagentConduit.java index 0c8f9ccc74..426b3b6f19 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderReagentConduit.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderReagentConduit.java @@ -12,46 +12,48 @@ public class RenderReagentConduit extends TileEntitySpecialRenderer { - private static final ResourceLocation field_110629_a = new ResourceLocation( - "alchemicalwizardry:textures/models/SimpleTransCircle.png"); + private static final ResourceLocation TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SimpleTransCircle.png"); @Override public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) { - if (tileEntity instanceof TEReagentConduit) { - int renderCount = ((TEReagentConduit) tileEntity).renderCount; - float key1 = (tileEntity.xCoord * 54f - tileEntity.yCoord * 38.72f + tileEntity.zCoord * 10.432f); - float key2 = (tileEntity.xCoord * 21.43f - tileEntity.yCoord * 9.96f + tileEntity.zCoord * 12.8f); - Int3 colourMap = ((TEReagentConduit) tileEntity).getColour(); - GL11.glPushMatrix(); - Tessellator tessellator = Tessellator.instance; - this.bindTexture(field_110629_a); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDepthMask(false); - tessellator.startDrawingQuads(); - tessellator.setColorRGBA(colourMap.xCoord, colourMap.yCoord, colourMap.zCoord, 200); - GL11.glTranslated(d0 + 0.5, d1 + 0.5, d2 + 0.5); - GL11.glRotatef(tileEntity.getWorldObj().getWorldTime() / 3.0f, 0F, 1F, 0F); // Rotate on planar axis - GL11.glRotatef(renderCount + key1, 0F, 0F, 1F); // Rotate vertical axis - GL11.glRotatef(renderCount * 2f + key2, 1F, 0F, 0F); // Rotate cylindrically - tessellator.setBrightness(240); - tessellator.addVertexWithUV(-0.5d, 0, -0.5d, 0.0d, 0.0d); - tessellator.addVertexWithUV(0.5d, 0, -0.5d, 1.0d, 0.0d); - tessellator.addVertexWithUV(0.5d, 0, 0.5d, 1.0d, 1.0d); - tessellator.addVertexWithUV(-0.5d, 0, 0.5d, 0.0d, 1.0d); - - tessellator.draw(); - - GL11.glDepthMask(true); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glPopMatrix(); + if (!(tileEntity instanceof TEReagentConduit conduit)) { + return; } + int renderCount = conduit.renderCount; + float key1 = tileEntity.xCoord * 54f - tileEntity.yCoord * 38.72f + tileEntity.zCoord * 10.432f; + float key2 = tileEntity.xCoord * 21.43f - tileEntity.yCoord * 9.96f + tileEntity.zCoord * 12.8f; + Int3 colourMap = conduit.getColour(); + GL11.glPushMatrix(); + Tessellator tessellator = Tessellator.instance; + this.bindTexture(TEXTURE); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDepthMask(false); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA(colourMap.x(), colourMap.y(), colourMap.z(), 200); + GL11.glTranslated(d0 + 0.5, d1 + 0.5, d2 + 0.5); + GL11.glRotatef(tileEntity.getWorldObj().getWorldTime() / 3.0f, 0F, 1F, 0F); // Rotate on planar axis + GL11.glRotatef(renderCount + key1, 0F, 0F, 1F); // Rotate vertical axis + GL11.glRotatef(renderCount * 2f + key2, 1F, 0F, 0F); // Rotate cylindrically + tessellator.setBrightness(240); + tessellator.addVertexWithUV(-0.5d, 0, -0.5d, 0.0d, 0.0d); + tessellator.addVertexWithUV(0.5d, 0, -0.5d, 1.0d, 0.0d); + tessellator.addVertexWithUV(0.5d, 0, 0.5d, 1.0d, 1.0d); + tessellator.addVertexWithUV(-0.5d, 0, 0.5d, 0.0d, 1.0d); + + tessellator.draw(); + + GL11.glDepthMask(true); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glPopMatrix(); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellEffectBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellEffectBlock.java index b3ed37a7f3..81f5ad2e3b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellEffectBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellEffectBlock.java @@ -12,12 +12,11 @@ public class RenderSpellEffectBlock extends TileEntitySpecialRenderer { - private ModelSpellEffectBlock modelSpellEffectBlock = new ModelSpellEffectBlock(); + private final ModelSpellEffectBlock modelSpellEffectBlock = new ModelSpellEffectBlock(); @Override public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) { - if (tileEntity instanceof TESpellEffectBlock) { - TESpellEffectBlock tileSpellBlock = (TESpellEffectBlock) tileEntity; + if (tileEntity instanceof TESpellEffectBlock tileSpellBlock) { GL11.glPushMatrix(); GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); ResourceLocation test; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellEnhancementBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellEnhancementBlock.java index 6cbaa4feac..bcee99a6fe 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellEnhancementBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellEnhancementBlock.java @@ -12,12 +12,11 @@ public class RenderSpellEnhancementBlock extends TileEntitySpecialRenderer { - private ModelSpellEnhancementBlock modelSpellEnhancementBlock = new ModelSpellEnhancementBlock(); + private final ModelSpellEnhancementBlock modelSpellEnhancementBlock = new ModelSpellEnhancementBlock(); @Override public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) { - if (tileEntity instanceof TESpellEnhancementBlock) { - TESpellEnhancementBlock tileSpellBlock = (TESpellEnhancementBlock) tileEntity; + if (tileEntity instanceof TESpellEnhancementBlock tileSpellBlock) { GL11.glPushMatrix(); GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); ResourceLocation test; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellModifierBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellModifierBlock.java index a5bc2cc923..7af4e011d8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellModifierBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellModifierBlock.java @@ -12,12 +12,11 @@ public class RenderSpellModifierBlock extends TileEntitySpecialRenderer { - private ModelSpellModifierBlock modelSpellModifierBlock = new ModelSpellModifierBlock(); + private final ModelSpellModifierBlock modelSpellModifierBlock = new ModelSpellModifierBlock(); @Override public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) { - if (tileEntity instanceof TESpellModifierBlock) { - TESpellModifierBlock tileSpellBlock = (TESpellModifierBlock) tileEntity; + if (tileEntity instanceof TESpellModifierBlock tileSpellBlock) { GL11.glPushMatrix(); GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); ResourceLocation test; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellParadigmBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellParadigmBlock.java index e7892f55c8..9c793f75ff 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellParadigmBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderSpellParadigmBlock.java @@ -12,12 +12,11 @@ public class RenderSpellParadigmBlock extends TileEntitySpecialRenderer { - private ModelSpellParadigmBlock modelSpellParadigmBlock = new ModelSpellParadigmBlock(); + private final ModelSpellParadigmBlock modelSpellParadigmBlock = new ModelSpellParadigmBlock(); @Override public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) { - if (tileEntity instanceof TESpellParadigmBlock) { - TESpellParadigmBlock tileSpellBlock = (TESpellParadigmBlock) tileEntity; + if (tileEntity instanceof TESpellParadigmBlock tileSpellBlock) { GL11.glPushMatrix(); GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); ResourceLocation test; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderWritingTable.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderWritingTable.java index 47dd41e4da..706ffe364a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderWritingTable.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/RenderWritingTable.java @@ -1,15 +1,12 @@ package WayofTime.alchemicalWizardry.common.renderer.block; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; @@ -19,68 +16,58 @@ public class RenderWritingTable extends TileEntitySpecialRenderer { - private ModelWritingTable modelWritingTable = new ModelWritingTable(); - private final RenderItem customRenderItem; - - public RenderWritingTable() { - customRenderItem = new RenderItem() { - - @Override - public boolean shouldBob() { - return false; - } - }; - customRenderItem.setRenderManager(RenderManager.instance); - } + private static final ResourceLocation TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/WritingTable.png"); + private static final ModelWritingTable MODEL = new ModelWritingTable(); @Override public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) { - if (tileEntity instanceof TEWritingTable) { - TEWritingTable tileAltar = (TEWritingTable) tileEntity; - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPushMatrix(); - GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); - ResourceLocation test = new ResourceLocation("alchemicalwizardry:textures/models/WritingTable.png"); - FMLClientHandler.instance().getClient().renderEngine.bindTexture(test); + if (!(tileEntity instanceof TEWritingTable chemistrySet)) { + return; + } + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPushMatrix(); + GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE); + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + MODEL.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + + for (int i = 1; i <= 6; i++) { + if (chemistrySet.getStackInSlot(i) == null) { + continue; + } GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.modelWritingTable.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - - for (int i = 1; i <= 6; i++) { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - if (tileAltar.getStackInSlot(i) != null) { - float scaleFactor = getGhostItemScaleFactor(tileAltar.getStackInSlot(i)); - float rotationAngle = Minecraft.getMinecraft().gameSettings.fancyGraphics - ? (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL) - : 0; - EntityItem ghostEntityItem = new EntityItem(tileAltar.getWorldObj()); - ghostEntityItem.hoverStart = 0.0F; - ghostEntityItem.setEntityItemStack(tileAltar.getStackInSlot(i)); - float displacementX = getXDisplacementForSlot(i); - float displacementY = getYDisplacementForSlot(i); - float displacementZ = getZDisplacementForSlot(i); - - if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock) { - GL11.glTranslatef( - (float) d0 + 0.5F + displacementX, - (float) d1 + displacementY + 0.7F, - (float) d2 + 0.5F + displacementZ); - } else { - GL11.glTranslatef( - (float) d0 + 0.5F + displacementX, - (float) d1 + displacementY + 0.6F, - (float) d2 + 0.5F + displacementZ); - } - GL11.glScalef(scaleFactor, scaleFactor, scaleFactor); - GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F); - customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0); - } - - GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + float scaleFactor = getGhostItemScaleFactor(chemistrySet.getStackInSlot(i)); + float rotationAngle = Minecraft.getMinecraft().gameSettings.fancyGraphics + ? (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL) + : 0; + EntityItem ghostEntityItem = new EntityItem(chemistrySet.getWorldObj()); + ghostEntityItem.hoverStart = 0.0F; + ghostEntityItem.setEntityItemStack(chemistrySet.getStackInSlot(i)); + float displacementX = getXDisplacementForSlot(i); + float displacementY = getYDisplacementForSlot(i); + float displacementZ = getZDisplacementForSlot(i); + + if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock) { + GL11.glTranslatef( + (float) d0 + 0.5F + displacementX, + (float) d1 + displacementY + 0.7F, + (float) d2 + 0.5F + displacementZ); + } else { + GL11.glTranslatef( + (float) d0 + 0.5F + displacementX, + (float) d1 + displacementY + 0.6F, + (float) d2 + 0.5F + displacementZ); } + GL11.glScalef(scaleFactor, scaleFactor, scaleFactor); + GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F); + TEAltarRenderer.customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0); + GL11.glPopMatrix(); } } @@ -89,42 +76,12 @@ private float getGhostItemScaleFactor(ItemStack itemStack) { if (itemStack != null) { if (itemStack.getItem() instanceof ItemBlock) { - switch (customRenderItem.getMiniBlockCount(itemStack, (byte) 1)) { - case 1: - return 0.90F * scaleFactor; - - case 2: - return 0.90F * scaleFactor; - - case 3: - return 0.90F * scaleFactor; - - case 4: - return 0.90F * scaleFactor; - - case 5: - return 0.80F * scaleFactor; - - default: - return 0.90F * scaleFactor; + if (TEAltarRenderer.customRenderItem.getMiniBlockCount(itemStack, (byte) 1) == 5) { + return 0.80F * scaleFactor; } + return 0.90F * scaleFactor; } else { - switch (customRenderItem.getMiniItemCount(itemStack, (byte) 1)) { - case 1: - return 0.65F * scaleFactor; - - case 2: - return 0.65F * scaleFactor; - - case 3: - return 0.65F * scaleFactor; - - case 4: - return 0.65F * scaleFactor; - - default: - return 0.65F * scaleFactor; - } + return 0.65F * scaleFactor; } } @@ -132,151 +89,29 @@ private float getGhostItemScaleFactor(ItemStack itemStack) { } private float getXDisplacementForSlot(int slot) { - switch (slot) { - case 0: - return 0.0f; - - case 1: - return -0.375f; - - case 2: - return -0.125f; - - case 3: - return 0.3125f; - - case 4: - return 0.3125f; - - case 5: - return -0.125f; - - default: - return 0.0f; - } + return switch (slot) { + case 1 -> -0.375f; + case 2, 5 -> -0.125f; + case 3, 4 -> 0.3125f; + default -> 0.0f; + }; } private float getYDisplacementForSlot(int slot) { - switch (slot) { - case 0: - return 0.4f; - - case 1: - return -0.35f; - - case 6: - return 0.4f; - - default: - return -0.35f; - } + return switch (slot) { + case 0, 6 -> 0.4f; + default -> -0.35f; + }; } private float getZDisplacementForSlot(int slot) { - switch (slot) { - case 0: - return 0.0f; - - case 1: - return 0.0f; - - case 2: - return 0.375f; - - case 3: - return 0.25f; - - case 4: - return -0.25f; - - case 5: - return -0.375f; - - default: - return 0.0f; - } + return switch (slot) { + case 2 -> 0.375f; + case 3 -> 0.25f; + case 4 -> -0.25f; + case 5 -> -0.375f; + default -> 0.0f; + }; } - private void translateGhostItemByOrientation(ItemStack ghostItemStack, double x, double y, double z, - ForgeDirection forgeDirection) { - if (ghostItemStack != null) { - if (ghostItemStack.getItem() instanceof ItemBlock) { - switch (forgeDirection) { - case DOWN: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 2.7F, (float) z + 0.5F); - return; - } - - case UP: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.25F, (float) z + 0.5F); - return; - } - - case NORTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.7F); - return; - } - - case SOUTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.3F); - return; - } - - case EAST: { - GL11.glTranslatef((float) x + 0.3F, (float) y + 0.5F, (float) z + 0.5F); - return; - } - - case WEST: { - GL11.glTranslatef((float) x + 0.70F, (float) y + 0.5F, (float) z + 0.5F); - return; - } - - case UNKNOWN: { - return; - } - - default: {} - } - } else { - switch (forgeDirection) { - case DOWN: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.6F, (float) z + 0.5F); - return; - } - - case UP: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.20F, (float) z + 0.5F); - return; - } - - case NORTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.7F); - return; - } - - case SOUTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.3F); - return; - } - - case EAST: { - GL11.glTranslatef((float) x + 0.3F, (float) y + 0.4F, (float) z + 0.5F); - return; - } - - case WEST: { - GL11.glTranslatef((float) x + 0.70F, (float) y + 0.4F, (float) z + 0.5F); - return; - } - - case UNKNOWN: { - return; - } - - default: {} - } - } - } - } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/TEAltarRenderer.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/TEAltarRenderer.java index d9132aecc2..d40f2b1ac8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/TEAltarRenderer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/TEAltarRenderer.java @@ -8,7 +8,6 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; @@ -17,187 +16,63 @@ public class TEAltarRenderer extends TileEntitySpecialRenderer { - private ModelBloodAltar modelBloodAltar = new ModelBloodAltar(); - private final RenderItem customRenderItem; + private static final ModelBloodAltar MODEL = new ModelBloodAltar(); + public static final RenderItem customRenderItem = new RenderItem() { - public TEAltarRenderer() { - customRenderItem = new RenderItem() { - - @Override - public boolean shouldBob() { - return false; - } - }; + @Override + public boolean shouldBob() { + return false; + } + }; + static { customRenderItem.setRenderManager(RenderManager.instance); } @Override public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) { - if (tileEntity instanceof TEAltar) { - - modelBloodAltar.renderBloodAltar((TEAltar) tileEntity, d0, d1, d2); - - if (((TEAltar) tileEntity).getCurrentBlood() > 0) - modelBloodAltar.renderBloodLevel((TEAltar) tileEntity, d0, d1, d2); - - TEAltar tileAltar = (TEAltar) tileEntity; - GL11.glPushMatrix(); + if (!(tileEntity instanceof TEAltar tileAltar)) { + return; + } - if (tileAltar.getStackInSlot(0) != null) { - float scaleFactor = getGhostItemScaleFactor(tileAltar.getStackInSlot(0)); - float rotationAngle = Minecraft.getMinecraft().gameSettings.fancyGraphics - ? (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL) - : 0; - EntityItem ghostEntityItem = new EntityItem(tileAltar.getWorldObj()); - ghostEntityItem.hoverStart = 0.0F; - ghostEntityItem.setEntityItemStack(tileAltar.getStackInSlot(0)); - float displacement = 0.2F; + MODEL.renderBloodAltar(tileAltar, d0, d1, d2); - if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock) { - GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.7F, (float) d2 + 0.5F); - } else { - GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.6F, (float) d2 + 0.5F); - } - GL11.glScalef(scaleFactor, scaleFactor, scaleFactor); - GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F); - customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0); - } + if (tileAltar.getCurrentBlood() > 0) MODEL.renderBloodLevel(tileAltar, d0, d1, d2); - GL11.glPopMatrix(); + if (tileAltar.getStackInSlot(0) == null) { + return; + } + GL11.glPushMatrix(); + float scaleFactor = getGhostItemScaleFactor(tileAltar.getStackInSlot(0)); + float rotationAngle = Minecraft.getMinecraft().gameSettings.fancyGraphics + ? (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL) + : 0; + EntityItem ghostEntityItem = new EntityItem(tileAltar.getWorldObj()); + ghostEntityItem.hoverStart = 0.0F; + ghostEntityItem.setEntityItemStack(tileAltar.getStackInSlot(0)); + float displacement = 0.2F; + + if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock) { + GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.7F, (float) d2 + 0.5F); + } else { + GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.6F, (float) d2 + 0.5F); } + GL11.glScalef(scaleFactor, scaleFactor, scaleFactor); + GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F); + customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0); + GL11.glPopMatrix(); } private float getGhostItemScaleFactor(ItemStack itemStack) { - float scaleFactor = 1.0F; - - if (itemStack != null) { - if (itemStack.getItem() instanceof ItemBlock) { - switch (customRenderItem.getMiniBlockCount(itemStack, (byte) 1)) { - case 1: - return 0.90F; - - case 2: - return 0.90F; - - case 3: - return 0.90F; - - case 4: - return 0.90F; - - case 5: - return 0.80F; - - default: - return 0.90F; - } - } else { - switch (customRenderItem.getMiniItemCount(itemStack, (byte) 1)) { - case 1: - return 0.65F; - - case 2: - return 0.65F; - - case 3: - return 0.65F; - - case 4: - return 0.65F; - - default: - return 0.65F; - } - } + if (itemStack == null) { + return 1.0F; } - - return scaleFactor; - } - - private void translateGhostItemByOrientation(ItemStack ghostItemStack, double x, double y, double z, - ForgeDirection forgeDirection) { - if (ghostItemStack != null) { - if (ghostItemStack.getItem() instanceof ItemBlock) { - switch (forgeDirection) { - case DOWN: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 2.7F, (float) z + 0.5F); - return; - } - - case UP: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.25F, (float) z + 0.5F); - return; - } - - case NORTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.7F); - return; - } - - case SOUTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.3F); - return; - } - - case EAST: { - GL11.glTranslatef((float) x + 0.3F, (float) y + 0.5F, (float) z + 0.5F); - return; - } - - case WEST: { - GL11.glTranslatef((float) x + 0.70F, (float) y + 0.5F, (float) z + 0.5F); - return; - } - - case UNKNOWN: { - return; - } - - default: { - return; - } - } - } else { - switch (forgeDirection) { - case DOWN: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.6F, (float) z + 0.5F); - return; - } - - case UP: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.20F, (float) z + 0.5F); - return; - } - - case NORTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.7F); - return; - } - - case SOUTH: { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.3F); - return; - } - - case EAST: { - GL11.glTranslatef((float) x + 0.3F, (float) y + 0.4F, (float) z + 0.5F); - return; - } - - case WEST: { - GL11.glTranslatef((float) x + 0.70F, (float) y + 0.4F, (float) z + 0.5F); - return; - } - - case UNKNOWN: { - return; - } - - default: { - return; - } - } - } + if (!(itemStack.getItem() instanceof ItemBlock)) { + return 0.65F; } + if (customRenderItem.getMiniBlockCount(itemStack, (byte) 1) == 5) { + return 0.80F; + } + return 0.90F; } + } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEAlchemicalCalcinatorItemRenderer.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEAlchemicalCalcinatorItemRenderer.java index 6342b8943d..6a5414d26e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEAlchemicalCalcinatorItemRenderer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEAlchemicalCalcinatorItemRenderer.java @@ -1,6 +1,5 @@ package WayofTime.alchemicalWizardry.common.renderer.block.itemRender; -import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; @@ -12,17 +11,18 @@ public class TEAlchemicalCalcinatorItemRenderer implements IItemRenderer { - private ModelAlchemicalCalcinator modelConduit = new ModelAlchemicalCalcinator(); + private static final ResourceLocation TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/AlchemicalCalcinator.png"); + private static final ModelAlchemicalCalcinator MODEL = new ModelAlchemicalCalcinator(); - private void renderConduitItem(RenderBlocks render, ItemStack item, float translateX, float translateY, - float translateZ) { + private void renderCalcinator(float translateX, float translateY, float translateZ) { GL11.glPushMatrix(); GL11.glTranslatef(translateX + 0.5F, translateY + 1.5F, translateZ + 0.5F); - ResourceLocation test = new ResourceLocation("alchemicalwizardry:textures/models/AlchemicalCalcinator.png"); - FMLClientHandler.instance().getClient().renderEngine.bindTexture(test); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.modelConduit.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); + MODEL.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); GL11.glPopMatrix(); } @@ -32,18 +32,7 @@ private void renderConduitItem(RenderBlocks render, ItemStack item, float transl */ @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { - switch (type) { - case ENTITY: - return true; - case EQUIPPED: - return true; - case EQUIPPED_FIRST_PERSON: - return true; - case INVENTORY: - return true; - default: - return false; - } + return type != ItemRenderType.FIRST_PERSON_MAP; } @Override @@ -54,19 +43,9 @@ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRe @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { switch (type) { - case ENTITY: - renderConduitItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - case EQUIPPED: - renderConduitItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f); - break; - case EQUIPPED_FIRST_PERSON: - renderConduitItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f); - break; - case INVENTORY: - renderConduitItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - default: + case ENTITY, INVENTORY -> renderCalcinator(-0.5f, -0.5f, -0.5f); + case EQUIPPED, EQUIPPED_FIRST_PERSON -> renderCalcinator(-0.4f, 0.50f, 0.35f); + default -> {} } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEAltarItemRenderer.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEAltarItemRenderer.java index d5a04fdd16..8b527987e1 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEAltarItemRenderer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEAltarItemRenderer.java @@ -1,6 +1,5 @@ package WayofTime.alchemicalWizardry.common.renderer.block.itemRender; -import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; @@ -12,11 +11,10 @@ public class TEAltarItemRenderer implements IItemRenderer { - private ModelBloodAltar modelBloodAltar; - - public TEAltarItemRenderer() { - modelBloodAltar = new ModelBloodAltar(); - } + private static final ResourceLocation TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/altar.png"); + private static final ModelBloodAltar MODEL = new ModelBloodAltar(); @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { @@ -32,32 +30,21 @@ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRe public void renderItem(ItemRenderType type, ItemStack item, Object... data) { float scale = 0.08f; switch (type) { - case ENTITY: - renderBloodAltar((RenderBlocks) data[0], item, 0, 0, 0, scale); - break; - case EQUIPPED: - renderBloodAltar((RenderBlocks) data[0], item, 0, 0, 0.5f, scale); - break; - case EQUIPPED_FIRST_PERSON: - renderBloodAltar((RenderBlocks) data[0], item, +0.5f, 0.5f, +0.5f, scale); - break; - case INVENTORY: - renderBloodAltar((RenderBlocks) data[0], item, -0.5f, -0.75f, -0.5f, scale); - break; - - default: - return; + case ENTITY -> renderBloodAltar(0, 0, 0, scale); + case EQUIPPED -> renderBloodAltar(0, 0, 0.5f, scale); + case EQUIPPED_FIRST_PERSON -> renderBloodAltar(+0.5f, 0.5f, +0.5f, scale); + case INVENTORY -> renderBloodAltar(-0.5f, -0.75f, -0.5f, scale); + default -> {} } } - private void renderBloodAltar(RenderBlocks render, ItemStack item, float x, float y, float z, float scale) { + private void renderBloodAltar(float x, float y, float z, float scale) { GL11.glPushMatrix(); GL11.glTranslatef(x, y, z); GL11.glScalef(scale, scale, scale); GL11.glRotatef(180f, 0f, 1f, 0f); - ResourceLocation test = new ResourceLocation("alchemicalwizardry:textures/models/altar.png"); - FMLClientHandler.instance().getClient().renderEngine.bindTexture(test); - modelBloodAltar.renderBloodAltar(); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE); + MODEL.renderBloodAltar(); GL11.glPopMatrix(); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEBellJarItemRenderer.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEBellJarItemRenderer.java index 60be3cdfa6..df6694e3d3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEBellJarItemRenderer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEBellJarItemRenderer.java @@ -1,9 +1,6 @@ package WayofTime.alchemicalWizardry.common.renderer.block.itemRender; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; @@ -19,20 +16,21 @@ public class TEBellJarItemRenderer implements IItemRenderer { - ItemRenderer d; - private ModelCrystalBelljar modelConduit = new ModelCrystalBelljar(); - private ResourceLocation mainResource = new ResourceLocation( - "alchemicalwizardry:textures/models/CrystalBelljar.png"); - private ResourceLocation resourceLocation = new ResourceLocation("alchemicalwizardry:textures/models/Reagent.png"); + private final ResourceLocation BELLJAR_TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/CrystalBelljar.png"); + private final ResourceLocation REAGENT_TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/Reagent.png"); + private final ModelCrystalBelljar MODEL = new ModelCrystalBelljar(); - private void renderConduitItem(RenderBlocks render, ItemStack item, float translateX, float translateY, - float translateZ) { + private void renderBelljar(ItemStack item, float translateX, float translateY, float translateZ) { GL11.glPushMatrix(); - GL11.glTranslatef((float) translateX + 0.5F, (float) translateY + 1.5F, (float) translateZ + 0.5F); - FMLClientHandler.instance().getClient().renderEngine.bindTexture(mainResource); + GL11.glTranslatef(translateX + 0.5F, translateY + 1.5F, translateZ + 0.5F); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(BELLJAR_TEXTURE); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.modelConduit.renderSpecialItem((Entity) null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, 0); + this.MODEL.renderSpecialItem(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, 0); GL11.glPopMatrix(); GL11.glPopMatrix(); @@ -46,9 +44,9 @@ private void renderConduitItem(RenderBlocks render, ItemStack item, float transl translateX, translateY, translateZ, - reagent.getColourRed(), - reagent.getColourGreen(), - reagent.getColourBlue(), + reagent.red(), + reagent.green(), + reagent.blue(), 200 * reagentStack.amount / capacity); } } @@ -58,11 +56,11 @@ private void renderConduitItem(RenderBlocks render, ItemStack item, float transl GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glPushMatrix(); - GL11.glTranslatef((float) translateX + 0.5F, (float) translateY + 1.5F, (float) translateZ + 0.5F); - FMLClientHandler.instance().getClient().renderEngine.bindTexture(mainResource); + GL11.glTranslatef(translateX + 0.5F, translateY + 1.5F, translateZ + 0.5F); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(BELLJAR_TEXTURE); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.modelConduit.renderSpecialItem((Entity) null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, 1); + this.MODEL.renderSpecialItem(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, 1); GL11.glPopMatrix(); GL11.glPopMatrix(); @@ -74,7 +72,7 @@ private void renderTankContents(double x, double y, double z, int colourRed, int int colourIntensity) { GL11.glPushMatrix(); Tessellator tessellator = Tessellator.instance; - FMLClientHandler.instance().getClient().renderEngine.bindTexture(resourceLocation); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(REAGENT_TEXTURE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); GL11.glDisable(GL11.GL_LIGHTING); @@ -140,18 +138,7 @@ private void renderTankContents(double x, double y, double z, int colourRed, int */ @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { - switch (type) { - case ENTITY: - return true; - case EQUIPPED: - return true; - case EQUIPPED_FIRST_PERSON: - return true; - case INVENTORY: - return true; - default: - return false; - } + return type != ItemRenderType.FIRST_PERSON_MAP; } @Override @@ -162,19 +149,9 @@ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRe @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { switch (type) { - case ENTITY: - renderConduitItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - case EQUIPPED: - renderConduitItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f); - break; - case EQUIPPED_FIRST_PERSON: - renderConduitItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f); - break; - case INVENTORY: - renderConduitItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - default: + case ENTITY, INVENTORY -> renderBelljar(item, -0.5f, -0.5f, -0.5f); + case EQUIPPED, EQUIPPED_FIRST_PERSON -> renderBelljar(item, -0.4f, 0.50f, 0.35f); + default -> {} } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEConduitItemRenderer.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEConduitItemRenderer.java index 12ed671d1a..16a5e04fad 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEConduitItemRenderer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEConduitItemRenderer.java @@ -1,7 +1,5 @@ package WayofTime.alchemicalWizardry.common.renderer.block.itemRender; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; @@ -14,18 +12,18 @@ public class TEConduitItemRenderer implements IItemRenderer { - private ModelConduit modelConduit = new ModelConduit(); + private static final ResourceLocation TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/Conduit.png"); + private static final ModelConduit MODEL = new ModelConduit(); - private void renderConduitItem(RenderBlocks render, ItemStack item, float translateX, float translateY, - float translateZ) { + private void renderConduit(float translateX, float translateY, float translateZ) { GL11.glPushMatrix(); - GL11.glTranslatef((float) translateX + 0.5F, (float) translateY + 1.5F, (float) translateZ + 0.5F); - ResourceLocation test = new ResourceLocation("alchemicalwizardry:textures/models/Conduit.png"); - FMLClientHandler.instance().getClient().renderEngine.bindTexture(test); + GL11.glTranslatef(translateX + 0.5F, translateY + 1.5F, translateZ + 0.5F); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.modelConduit - .render((Entity) null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, ForgeDirection.DOWN, ForgeDirection.UP); + MODEL.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, ForgeDirection.DOWN, ForgeDirection.UP); GL11.glPopMatrix(); GL11.glPopMatrix(); } @@ -35,18 +33,7 @@ private void renderConduitItem(RenderBlocks render, ItemStack item, float transl */ @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { - switch (type) { - case ENTITY: - return true; - case EQUIPPED: - return true; - case EQUIPPED_FIRST_PERSON: - return true; - case INVENTORY: - return true; - default: - return false; - } + return type != ItemRenderType.FIRST_PERSON_MAP; } @Override @@ -57,19 +44,9 @@ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRe @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { switch (type) { - case ENTITY: - renderConduitItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - case EQUIPPED: - renderConduitItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f); - break; - case EQUIPPED_FIRST_PERSON: - renderConduitItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f); - break; - case INVENTORY: - renderConduitItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - default: + case ENTITY, INVENTORY -> renderConduit(-0.5f, -0.5f, -0.5f); + case EQUIPPED, EQUIPPED_FIRST_PERSON -> renderConduit(-0.4f, 0.50f, 0.35f); + default -> {} } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellEffectBlockItemRenderer.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellEffectBlockItemRenderer.java index e29ef41f47..d38d0297a6 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellEffectBlockItemRenderer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellEffectBlockItemRenderer.java @@ -1,7 +1,5 @@ package WayofTime.alchemicalWizardry.common.renderer.block.itemRender; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; @@ -14,19 +12,28 @@ public class TESpellEffectBlockItemRenderer implements IItemRenderer { - private ModelSpellEffectBlock modelSpellBlock = new ModelSpellEffectBlock(); + private static final ResourceLocation TEXTURE_FIRE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEffectFire.png"); + private static final ResourceLocation TEXTURE_ICE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEffectIce.png"); + private static final ResourceLocation TEXTURE_WIND = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEffectWind.png"); + private static final ResourceLocation TEXTURE_EARTH = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEffectEarth.png"); + private static final ModelSpellEffectBlock MODEL = new ModelSpellEffectBlock(); - private void renderConduitItem(RenderBlocks render, ItemStack item, float translateX, float translateY, - float translateZ) { + private void renderSpellBlock(ItemStack item, float translateX, float translateY, float translateZ) { GL11.glPushMatrix(); - GL11.glTranslatef((float) translateX + 0.5F, (float) translateY + 1.5F, (float) translateZ + 0.5F); - ResourceLocation test = new ResourceLocation(this.getResourceLocationForMeta(item.getItemDamage())); - - FMLClientHandler.instance().getClient().renderEngine.bindTexture(test); + GL11.glTranslatef(translateX + 0.5F, translateY + 1.5F, translateZ + 0.5F); + FMLClientHandler.instance().getClient().renderEngine + .bindTexture(this.getResourceLocationForMeta(item.getItemDamage())); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.modelSpellBlock - .render((Entity) null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, ForgeDirection.DOWN, ForgeDirection.UP); + MODEL.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, ForgeDirection.DOWN, ForgeDirection.UP); GL11.glPopMatrix(); GL11.glPopMatrix(); } @@ -36,18 +43,7 @@ private void renderConduitItem(RenderBlocks render, ItemStack item, float transl */ @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { - switch (type) { - case ENTITY: - return true; - case EQUIPPED: - return true; - case EQUIPPED_FIRST_PERSON: - return true; - case INVENTORY: - return true; - default: - return false; - } + return type != ItemRenderType.FIRST_PERSON_MAP; } @Override @@ -58,33 +54,18 @@ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRe @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { switch (type) { - case ENTITY: - renderConduitItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - case EQUIPPED: - renderConduitItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f); - break; - case EQUIPPED_FIRST_PERSON: - renderConduitItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f); - break; - case INVENTORY: - renderConduitItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - default: + case ENTITY, INVENTORY -> renderSpellBlock(item, -0.5f, -0.5f, -0.5f); + case EQUIPPED, EQUIPPED_FIRST_PERSON -> renderSpellBlock(item, -0.4f, 0.50f, 0.35f); + default -> {} } } - public String getResourceLocationForMeta(int meta) { - switch (meta) { - case 0: - return "alchemicalwizardry:textures/models/SpellEffectFire.png"; - case 1: - return "alchemicalwizardry:textures/models/SpellEffectIce.png"; - case 2: - return "alchemicalwizardry:textures/models/SpellEffectWind.png"; - case 3: - return "alchemicalwizardry:textures/models/SpellEffectEarth.png"; - } - return ""; + public ResourceLocation getResourceLocationForMeta(int meta) { + return switch (meta) { + case 0 -> TEXTURE_FIRE; + case 1 -> TEXTURE_ICE; + case 2 -> TEXTURE_WIND; + default -> TEXTURE_EARTH; + }; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellEnhancementBlockItemRenderer.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellEnhancementBlockItemRenderer.java index 3f49073236..a002e7c17d 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellEnhancementBlockItemRenderer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellEnhancementBlockItemRenderer.java @@ -1,7 +1,5 @@ package WayofTime.alchemicalWizardry.common.renderer.block.itemRender; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; @@ -14,19 +12,53 @@ public class TESpellEnhancementBlockItemRenderer implements IItemRenderer { - private ModelSpellEnhancementBlock modelSpellBlock = new ModelSpellEnhancementBlock(); + private static final ResourceLocation TEXTURE_POWER_1 = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEnhancementPower1.png"); + private static final ResourceLocation TEXTURE_POWER_2 = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEnhancementPower2.png"); + private static final ResourceLocation TEXTURE_POWER_3 = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEnhancementPower3.png"); + private static final ResourceLocation TEXTURE_POWER_4 = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEnhancementPower4.png"); + private static final ResourceLocation TEXTURE_COST_1 = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEnhancementCost1.png"); + private static final ResourceLocation TEXTURE_COST_2 = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEnhancementCost2.png"); + private static final ResourceLocation TEXTURE_COST_3 = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEnhancementCost3.png"); + private static final ResourceLocation TEXTURE_COST_4 = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEnhancementCost4.png"); + private static final ResourceLocation TEXTURE_POTENCY_1 = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEnhancementPotency1.png"); + private static final ResourceLocation TEXTURE_POTENCY_2 = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEnhancementPotency2.png"); + private static final ResourceLocation TEXTURE_POTENCY_3 = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEnhancementPotency3.png"); + private static final ResourceLocation TEXTURE_POTENCY_4 = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellEnhancementPotency4.png"); + private static final ModelSpellEnhancementBlock MODEL = new ModelSpellEnhancementBlock(); - private void renderConduitItem(RenderBlocks render, ItemStack item, float translateX, float translateY, - float translateZ) { + private void renderSpellBlock(ItemStack item, float translateX, float translateY, float translateZ) { GL11.glPushMatrix(); - GL11.glTranslatef((float) translateX + 0.5F, (float) translateY + 1.5F, (float) translateZ + 0.5F); - ResourceLocation test = new ResourceLocation(this.getResourceLocationForMeta(item.getItemDamage())); + GL11.glTranslatef(translateX + 0.5F, translateY + 1.5F, translateZ + 0.5F); + ResourceLocation test = this.getResourceLocationForMeta(item.getItemDamage()); FMLClientHandler.instance().getClient().renderEngine.bindTexture(test); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.modelSpellBlock - .render((Entity) null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, ForgeDirection.DOWN, ForgeDirection.UP); + MODEL.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, ForgeDirection.DOWN, ForgeDirection.UP); GL11.glPopMatrix(); GL11.glPopMatrix(); } @@ -36,18 +68,7 @@ private void renderConduitItem(RenderBlocks render, ItemStack item, float transl */ @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { - switch (type) { - case ENTITY: - return true; - case EQUIPPED: - return true; - case EQUIPPED_FIRST_PERSON: - return true; - case INVENTORY: - return true; - default: - return false; - } + return type != ItemRenderType.FIRST_PERSON_MAP; } @Override @@ -58,49 +79,26 @@ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRe @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { switch (type) { - case ENTITY: - renderConduitItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - case EQUIPPED: - renderConduitItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f); - break; - case EQUIPPED_FIRST_PERSON: - renderConduitItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f); - break; - case INVENTORY: - renderConduitItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - default: + case ENTITY, INVENTORY -> renderSpellBlock(item, -0.5f, -0.5f, -0.5f); + case EQUIPPED, EQUIPPED_FIRST_PERSON -> renderSpellBlock(item, -0.4f, 0.50f, 0.35f); + default -> {} } } - public String getResourceLocationForMeta(int meta) { - switch (meta) { - case 0: - return "alchemicalwizardry:textures/models/SpellEnhancementPower1.png"; - case 1: - return "alchemicalwizardry:textures/models/SpellEnhancementPower2.png"; - case 2: - return "alchemicalwizardry:textures/models/SpellEnhancementPower3.png"; - case 3: - return "alchemicalwizardry:textures/models/SpellEnhancementPower4.png"; - case 5: - return "alchemicalwizardry:textures/models/SpellEnhancementCost1.png"; - case 6: - return "alchemicalwizardry:textures/models/SpellEnhancementCost2.png"; - case 7: - return "alchemicalwizardry:textures/models/SpellEnhancementCost3.png"; - case 8: - return "alchemicalwizardry:textures/models/SpellEnhancementCost4.png"; - case 10: - return "alchemicalwizardry:textures/models/SpellEnhancementPotency1.png"; - case 11: - return "alchemicalwizardry:textures/models/SpellEnhancementPotency2.png"; - case 12: - return "alchemicalwizardry:textures/models/SpellEnhancementPotency3.png"; - case 13: - return "alchemicalwizardry:textures/models/SpellEnhancementPotency4.png"; - } - return "alchemicalwizardry:textures/models/SpellEnhancementPower1.png"; + public ResourceLocation getResourceLocationForMeta(int meta) { + return switch (meta) { + case 1 -> TEXTURE_POWER_2; + case 2 -> TEXTURE_POWER_3; + case 3 -> TEXTURE_POWER_4; + case 5 -> TEXTURE_COST_1; + case 6 -> TEXTURE_COST_2; + case 7 -> TEXTURE_COST_3; + case 8 -> TEXTURE_COST_4; + case 10 -> TEXTURE_POTENCY_1; + case 11 -> TEXTURE_POTENCY_2; + case 12 -> TEXTURE_POTENCY_3; + case 13 -> TEXTURE_POTENCY_4; + default -> TEXTURE_POWER_1; + }; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellModifierBlockItemRenderer.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellModifierBlockItemRenderer.java index fa3a6fe86b..32ccf43c9f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellModifierBlockItemRenderer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellModifierBlockItemRenderer.java @@ -1,7 +1,5 @@ package WayofTime.alchemicalWizardry.common.renderer.block.itemRender; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; @@ -14,19 +12,29 @@ public class TESpellModifierBlockItemRenderer implements IItemRenderer { - private ModelSpellModifierBlock modelSpellBlock = new ModelSpellModifierBlock(); + private static final ResourceLocation TEXTURE_OFFENSIVE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellModifierOffensive.png"); + private static final ResourceLocation TEXTURE_DEFENSIVE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellModifierDefensive.png"); + private static final ResourceLocation TEXTURE_ENVIRONMENTAL = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellModifierEnvironmental.png"); + private static final ResourceLocation TEXTURE_DEFAULT = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellModifierDefault.png"); + private static final ModelSpellModifierBlock MODEL = new ModelSpellModifierBlock(); - private void renderConduitItem(RenderBlocks render, ItemStack item, float translateX, float translateY, - float translateZ) { + private void renderSpellBlock(ItemStack item, float translateX, float translateY, float translateZ) { GL11.glPushMatrix(); - GL11.glTranslatef((float) translateX + 0.5F, (float) translateY + 1.5F, (float) translateZ + 0.5F); - ResourceLocation test = new ResourceLocation(this.getResourceLocationForMeta(item.getItemDamage())); + GL11.glTranslatef(translateX + 0.5F, translateY + 1.5F, translateZ + 0.5F); + ResourceLocation test = this.getResourceLocationForMeta(item.getItemDamage()); FMLClientHandler.instance().getClient().renderEngine.bindTexture(test); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.modelSpellBlock - .render((Entity) null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, ForgeDirection.DOWN, ForgeDirection.UP); + MODEL.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, ForgeDirection.DOWN, ForgeDirection.UP); GL11.glPopMatrix(); GL11.glPopMatrix(); } @@ -36,18 +44,7 @@ private void renderConduitItem(RenderBlocks render, ItemStack item, float transl */ @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { - switch (type) { - case ENTITY: - return true; - case EQUIPPED: - return true; - case EQUIPPED_FIRST_PERSON: - return true; - case INVENTORY: - return true; - default: - return false; - } + return type != ItemRenderType.FIRST_PERSON_MAP; } @Override @@ -58,33 +55,18 @@ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRe @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { switch (type) { - case ENTITY: - renderConduitItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - case EQUIPPED: - renderConduitItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f); - break; - case EQUIPPED_FIRST_PERSON: - renderConduitItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f); - break; - case INVENTORY: - renderConduitItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - default: + case ENTITY, INVENTORY -> renderSpellBlock(item, -0.5f, -0.5f, -0.5f); + case EQUIPPED, EQUIPPED_FIRST_PERSON -> renderSpellBlock(item, -0.4f, 0.50f, 0.35f); + default -> {} } } - public String getResourceLocationForMeta(int meta) { - switch (meta) { - case 0: - return "alchemicalwizardry:textures/models/SpellModifierDefault.png"; - case 1: - return "alchemicalwizardry:textures/models/SpellModifierOffensive.png"; - case 2: - return "alchemicalwizardry:textures/models/SpellModifierDefensive.png"; - case 3: - return "alchemicalwizardry:textures/models/SpellModifierEnvironmental.png"; - } - return "alchemicalwizardry:textures/models/SpellModifierDefault.png"; + public ResourceLocation getResourceLocationForMeta(int meta) { + return switch (meta) { + case 1 -> TEXTURE_OFFENSIVE; + case 2 -> TEXTURE_DEFENSIVE; + case 3 -> TEXTURE_ENVIRONMENTAL; + default -> TEXTURE_DEFAULT; + }; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellParadigmBlockItemRenderer.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellParadigmBlockItemRenderer.java index 0cafb727b2..e5f22c568d 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellParadigmBlockItemRenderer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TESpellParadigmBlockItemRenderer.java @@ -1,7 +1,5 @@ package WayofTime.alchemicalWizardry.common.renderer.block.itemRender; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; @@ -14,18 +12,28 @@ public class TESpellParadigmBlockItemRenderer implements IItemRenderer { - private ModelSpellParadigmBlock modelSpellBlock = new ModelSpellParadigmBlock(); + private static final ResourceLocation TEXTURE_SELF = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellParadigmSelf.png"); + private static final ResourceLocation TEXTURE_MELEE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellParadigmMelee.png"); + private static final ResourceLocation TEXTURE_TOOL = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellParadigmTool.png"); + private static final ResourceLocation TEXTURE_PROJECTILE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/SpellParadigmProjectile.png"); + private static final ModelSpellParadigmBlock MODEL = new ModelSpellParadigmBlock(); - private void renderConduitItem(RenderBlocks render, ItemStack item, float translateX, float translateY, - float translateZ) { + private void renderSpellBlock(ItemStack item, float translateX, float translateY, float translateZ) { GL11.glPushMatrix(); - GL11.glTranslatef((float) translateX + 0.5F, (float) translateY + 1.5F, (float) translateZ + 0.5F); - ResourceLocation test = new ResourceLocation(this.getResourceLocationForMeta(item.getItemDamage())); + GL11.glTranslatef(translateX + 0.5F, translateY + 1.5F, translateZ + 0.5F); + ResourceLocation test = this.getResourceLocationForMeta(item.getItemDamage()); FMLClientHandler.instance().getClient().renderEngine.bindTexture(test); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.modelSpellBlock - .render((Entity) null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, ForgeDirection.DOWN, ForgeDirection.UP); + MODEL.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, ForgeDirection.DOWN, ForgeDirection.UP); GL11.glPopMatrix(); GL11.glPopMatrix(); } @@ -35,18 +43,7 @@ private void renderConduitItem(RenderBlocks render, ItemStack item, float transl */ @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { - switch (type) { - case ENTITY: - return true; - case EQUIPPED: - return true; - case EQUIPPED_FIRST_PERSON: - return true; - case INVENTORY: - return true; - default: - return false; - } + return type != ItemRenderType.FIRST_PERSON_MAP; } @Override @@ -57,33 +54,18 @@ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRe @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { switch (type) { - case ENTITY: - renderConduitItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - case EQUIPPED: - renderConduitItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f); - break; - case EQUIPPED_FIRST_PERSON: - renderConduitItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f); - break; - case INVENTORY: - renderConduitItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - default: + case ENTITY, INVENTORY -> renderSpellBlock(item, -0.5f, -0.5f, -0.5f); + case EQUIPPED, EQUIPPED_FIRST_PERSON -> renderSpellBlock(item, -0.4f, 0.50f, 0.35f); + default -> {} } } - public String getResourceLocationForMeta(int meta) { - switch (meta) { - case 0: - return "alchemicalwizardry:textures/models/SpellParadigmProjectile.png"; - case 1: - return "alchemicalwizardry:textures/models/SpellParadigmSelf.png"; - case 2: - return "alchemicalwizardry:textures/models/SpellParadigmMelee.png"; - case 3: - return "alchemicalwizardry:textures/models/SpellParadigmTool.png"; - } - return "alchemicalwizardry:textures/models/SpellParadigmProjectile.png"; + public ResourceLocation getResourceLocationForMeta(int meta) { + return switch (meta) { + case 1 -> TEXTURE_SELF; + case 2 -> TEXTURE_MELEE; + case 3 -> TEXTURE_TOOL; + default -> TEXTURE_PROJECTILE; + }; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEWritingTableItemRenderer.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEWritingTableItemRenderer.java index 52931e95e7..8b83a9a9d3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEWritingTableItemRenderer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/block/itemRender/TEWritingTableItemRenderer.java @@ -1,6 +1,5 @@ package WayofTime.alchemicalWizardry.common.renderer.block.itemRender; -import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; @@ -12,11 +11,10 @@ public class TEWritingTableItemRenderer implements IItemRenderer { - private ModelWritingTable model; - - public TEWritingTableItemRenderer() { - model = new ModelWritingTable(); - } + private static final ResourceLocation TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/WritingTable.png"); + private static final ModelWritingTable MODEL = new ModelWritingTable(); @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { @@ -32,37 +30,19 @@ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRe public void renderItem(ItemRenderType type, ItemStack item, Object... data) { float scale = 0.08f; switch (type) { - case ENTITY: { - renderBloodAltar(0f, 0f, 0f, scale); - return; - } - - case EQUIPPED: { - renderBloodAltar(0f, 0f, 0f, scale); - return; - } - - case INVENTORY: { - renderBloodAltar(0f, -0.25f, 0f, scale); - return; - } - - default: - return; + case ENTITY, EQUIPPED -> renderChemistrySet(0f, 0f, 0f, scale); + case INVENTORY -> renderChemistrySet(0f, -0.25f, 0f, scale); } } - private void renderBloodAltar(float x, float y, float z, float scale) { + private void renderChemistrySet(float x, float y, float z, float scale) { GL11.glPushMatrix(); - // Disable Lighting Calculations GL11.glDisable(GL11.GL_LIGHTING); GL11.glTranslatef(x, y, z); GL11.glScalef(scale, scale, scale); GL11.glRotatef(180f, 0f, 1f, 0f); - ResourceLocation test = new ResourceLocation("alchemicalwizardry:textures/models/WritingTable.png"); - FMLClientHandler.instance().getClient().renderEngine.bindTexture(test); - model.render((Entity) null, 0, 0, 0, 0, 0, 0); - // Re-enable Lighting Calculations + FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE); + MODEL.render(null, 0, 0, 0, 0, 0, 0); GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderBileDemon.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderBileDemon.java index 27fe4ca957..2b0d2ac384 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderBileDemon.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderBileDemon.java @@ -5,23 +5,18 @@ import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import WayofTime.alchemicalWizardry.common.entity.mob.EntityBileDemon; - public class RenderBileDemon extends RenderLiving { - private static final ResourceLocation field_110833_a = new ResourceLocation( + private static final ResourceLocation BILE_DEMON = new ResourceLocation( "alchemicalwizardry", "textures/models/BileDemon.png"); - public RenderBileDemon(ModelBase par1ModelBase, float par2) { - super(par1ModelBase, par2); - } - - public ResourceLocation func_110832_a(EntityBileDemon par1EntityBileDemon) { - return field_110833_a; + public RenderBileDemon(ModelBase mainModel, float shadowSize) { + super(mainModel, shadowSize); } - public ResourceLocation getEntityTexture(Entity par1Entity) { - return this.func_110832_a((EntityBileDemon) par1Entity); + @Override + public ResourceLocation getEntityTexture(Entity entity) { + return BILE_DEMON; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderBoulderFist.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderBoulderFist.java index ef761e5018..95b04e85ca 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderBoulderFist.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderBoulderFist.java @@ -5,23 +5,18 @@ import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import WayofTime.alchemicalWizardry.common.entity.mob.EntityBoulderFist; - public class RenderBoulderFist extends RenderLiving { - private static final ResourceLocation field_110833_a = new ResourceLocation( + private static final ResourceLocation BOULDER_FIST = new ResourceLocation( "alchemicalwizardry", "textures/models/BoulderFist.png"); - public RenderBoulderFist(ModelBase par1ModelBase, float par2) { - super(par1ModelBase, par2); - } - - public ResourceLocation func_110832_a(EntityBoulderFist par1EntityBoulderFist) { - return field_110833_a; + public RenderBoulderFist(ModelBase mainModel, float shadowSize) { + super(mainModel, shadowSize); } - public ResourceLocation getEntityTexture(Entity par1Entity) { - return this.func_110832_a((EntityBoulderFist) par1Entity); + @Override + public ResourceLocation getEntityTexture(Entity entity) { + return BOULDER_FIST; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderElemental.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderElemental.java index 0eff7b7867..127e83d731 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderElemental.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderElemental.java @@ -5,9 +5,7 @@ import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import WayofTime.alchemicalWizardry.common.entity.mob.EntityAirElemental; import WayofTime.alchemicalWizardry.common.entity.mob.EntityEarthElemental; -import WayofTime.alchemicalWizardry.common.entity.mob.EntityElemental; import WayofTime.alchemicalWizardry.common.entity.mob.EntityFireElemental; import WayofTime.alchemicalWizardry.common.entity.mob.EntityHolyElemental; import WayofTime.alchemicalWizardry.common.entity.mob.EntityShadeElemental; @@ -15,58 +13,38 @@ public class RenderElemental extends RenderLiving { - private static final ResourceLocation airBeacon = new ResourceLocation( + private static final ResourceLocation AIR_BEACON = new ResourceLocation( "alchemicalwizardry", "textures/models/AirFloatingBeacon.png"); - private static final ResourceLocation waterBeacon = new ResourceLocation( + private static final ResourceLocation WATER_BEACON = new ResourceLocation( "alchemicalwizardry", "textures/models/WaterFloatingBeacon.png"); - private static final ResourceLocation earthBeacon = new ResourceLocation( + private static final ResourceLocation EARTH_BEACON = new ResourceLocation( "alchemicalwizardry", "textures/models/EarthFloatingBeacon.png"); - private static final ResourceLocation fireBeacon = new ResourceLocation( + private static final ResourceLocation FIRE_BEACON = new ResourceLocation( "alchemicalwizardry", "textures/models/FireFloatingBeacon.png"); - private static final ResourceLocation shadeBeacon = new ResourceLocation( + private static final ResourceLocation SHADE_BEACON = new ResourceLocation( "alchemicalwizardry", "textures/models/DarkFloatingBeacon.png"); - private static final ResourceLocation holyBeacon = new ResourceLocation( + private static final ResourceLocation HOLY_BEACON = new ResourceLocation( "alchemicalwizardry", "textures/models/HolyFloatingBeacon.png"); - public RenderElemental(ModelBase par1ModelBase, float par2) { - super(par1ModelBase, par2); + public RenderElemental(ModelBase mainModel, float shadowSize) { + super(mainModel, shadowSize); } - public ResourceLocation func_110832_a(EntityElemental par1EntityElemental) { - if (par1EntityElemental instanceof EntityAirElemental) { - return airBeacon; - } - - if (par1EntityElemental instanceof EntityWaterElemental) { - return waterBeacon; - } - - if (par1EntityElemental instanceof EntityEarthElemental) { - return earthBeacon; - } - - if (par1EntityElemental instanceof EntityFireElemental) { - return fireBeacon; - } - - if (par1EntityElemental instanceof EntityShadeElemental) { - return shadeBeacon; - } - - if (par1EntityElemental instanceof EntityHolyElemental) { - return holyBeacon; - } - - return airBeacon; - } - - public ResourceLocation getEntityTexture(Entity par1Entity) { - return this.func_110832_a((EntityElemental) par1Entity); + @Override + public ResourceLocation getEntityTexture(Entity entity) { + return switch (entity) { + case EntityWaterElemental _ -> WATER_BEACON; + case EntityEarthElemental _ -> EARTH_BEACON; + case EntityFireElemental _ -> FIRE_BEACON; + case EntityShadeElemental _ -> SHADE_BEACON; + case EntityHolyElemental _ -> HOLY_BEACON; + default -> AIR_BEACON; + }; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderFallenAngel.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderFallenAngel.java index 014804275e..685572dee0 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderFallenAngel.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderFallenAngel.java @@ -5,26 +5,22 @@ import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import WayofTime.alchemicalWizardry.common.entity.mob.EntityFallenAngel; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderFallenAngel extends RenderLiving { - private static final ResourceLocation field_110833_a = new ResourceLocation( + private static final ResourceLocation WINGED_ANGEL = new ResourceLocation( "alchemicalwizardry", "textures/models/WingedAngel.png"); - public RenderFallenAngel(ModelBase par1ModelBase, float par2) { - super(par1ModelBase, par2); + public RenderFallenAngel(ModelBase mainModel, float shadowSize) { + super(mainModel, shadowSize); } - public ResourceLocation func_110832_a(EntityFallenAngel par1EntityFallenAngel) { - return field_110833_a; - } - - public ResourceLocation getEntityTexture(Entity par1Entity) { - return this.func_110832_a((EntityFallenAngel) par1Entity); + @Override + public ResourceLocation getEntityTexture(Entity entity) { + return WINGED_ANGEL; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderIceDemon.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderIceDemon.java index 40b66902b8..e1b3878a77 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderIceDemon.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderIceDemon.java @@ -5,23 +5,18 @@ import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import WayofTime.alchemicalWizardry.common.entity.mob.EntityIceDemon; - public class RenderIceDemon extends RenderLiving { - private static final ResourceLocation field_110833_a = new ResourceLocation( + private static final ResourceLocation ICE_DEMON = new ResourceLocation( "alchemicalwizardry", "textures/models/IceDemon.png"); - public RenderIceDemon(ModelBase par1ModelBase, float par2) { - super(par1ModelBase, par2); - } - - public ResourceLocation func_110832_a(EntityIceDemon par1EntityIceDemon) { - return field_110833_a; + public RenderIceDemon(ModelBase mainModel, float shadowSize) { + super(mainModel, shadowSize); } - public ResourceLocation getEntityTexture(Entity par1Entity) { - return this.func_110832_a((EntityIceDemon) par1Entity); + @Override + public ResourceLocation getEntityTexture(Entity entity) { + return ICE_DEMON; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderLowerGuardian.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderLowerGuardian.java index dd46553d4e..5fff2a6534 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderLowerGuardian.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderLowerGuardian.java @@ -5,23 +5,18 @@ import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import WayofTime.alchemicalWizardry.common.entity.mob.EntityLowerGuardian; - public class RenderLowerGuardian extends RenderLiving { - private static final ResourceLocation field_110833_a = new ResourceLocation( + private static final ResourceLocation LOWER_GUARDIAN = new ResourceLocation( "alchemicalwizardry", "textures/models/LowerGuardian.png"); - public RenderLowerGuardian(ModelBase par1ModelBase, float par2) { - super(par1ModelBase, par2); - } - - public ResourceLocation func_110832_a(EntityLowerGuardian par1EntityLowerGuardian) { - return field_110833_a; + public RenderLowerGuardian(ModelBase mainModel, float shadowSize) { + super(mainModel, shadowSize); } - public ResourceLocation getEntityTexture(Entity par1Entity) { - return this.func_110832_a((EntityLowerGuardian) par1Entity); + @Override + public ResourceLocation getEntityTexture(Entity entity) { + return LOWER_GUARDIAN; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderMinorDemonGrunt.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderMinorDemonGrunt.java index f7b794d7d9..f3d71bca4b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderMinorDemonGrunt.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderMinorDemonGrunt.java @@ -5,7 +5,6 @@ import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityMinorDemonGrunt; import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityMinorDemonGruntEarth; import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityMinorDemonGruntFire; import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityMinorDemonGruntIce; @@ -13,41 +12,34 @@ public class RenderMinorDemonGrunt extends RenderLiving { - private static final ResourceLocation normalTexture = new ResourceLocation( + private static final ResourceLocation NORMAL_GRUNT = new ResourceLocation( "alchemicalwizardry", "textures/models/MinorDemonGrunt_normal.png"); - private static final ResourceLocation fireTexture = new ResourceLocation( + private static final ResourceLocation FIRE_GRUNT = new ResourceLocation( "alchemicalwizardry", "textures/models/MinorDemonGrunt_fire.png"); - private static final ResourceLocation iceTexture = new ResourceLocation( + private static final ResourceLocation ICE_GRUNT = new ResourceLocation( "alchemicalwizardry", "textures/models/MinorDemonGrunt_ice.png"); - private static final ResourceLocation windTexture = new ResourceLocation( + private static final ResourceLocation WIND_GRUNT = new ResourceLocation( "alchemicalwizardry", "textures/models/MinorDemonGrunt_wind.png"); - private static final ResourceLocation earthTexture = new ResourceLocation( + private static final ResourceLocation EARTH_GRUNT = new ResourceLocation( "alchemicalwizardry", "textures/models/MinorDemonGrunt_earth.png"); - public RenderMinorDemonGrunt(ModelBase par1ModelBase, float par2) { - super(par1ModelBase, par2); - } - - public ResourceLocation func_110832_a(EntityMinorDemonGrunt entity) { - if (entity instanceof EntityMinorDemonGruntFire) { - return fireTexture; - } else if (entity instanceof EntityMinorDemonGruntWind) { - return windTexture; - } else if (entity instanceof EntityMinorDemonGruntIce) { - return iceTexture; - } else if (entity instanceof EntityMinorDemonGruntEarth) { - return earthTexture; - } - - return normalTexture; + public RenderMinorDemonGrunt(ModelBase mainModel, float shadowSize) { + super(mainModel, shadowSize); } + @Override public ResourceLocation getEntityTexture(Entity entity) { - return this.func_110832_a((EntityMinorDemonGrunt) entity); + return switch (entity) { + case EntityMinorDemonGruntFire _ -> FIRE_GRUNT; + case EntityMinorDemonGruntWind _ -> WIND_GRUNT; + case EntityMinorDemonGruntIce _ -> ICE_GRUNT; + case EntityMinorDemonGruntEarth _ -> EARTH_GRUNT; + default -> NORMAL_GRUNT; + }; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderMinorDemonGruntGuardian.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderMinorDemonGruntGuardian.java index 0d609d555f..eccb8d5bd4 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderMinorDemonGruntGuardian.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderMinorDemonGruntGuardian.java @@ -5,7 +5,6 @@ import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityMinorDemonGruntGuardian; import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityMinorDemonGruntGuardianEarth; import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityMinorDemonGruntGuardianFire; import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityMinorDemonGruntGuardianIce; @@ -13,41 +12,35 @@ public class RenderMinorDemonGruntGuardian extends RenderLiving { - private static final ResourceLocation normalTexture = new ResourceLocation( + private static final ResourceLocation NORMAL_GUARDIAN = new ResourceLocation( "alchemicalwizardry", "textures/models/MinorDemonGruntGuardian_normal.png"); - private static final ResourceLocation fireTexture = new ResourceLocation( + private static final ResourceLocation FIRE_GUARDIAN = new ResourceLocation( "alchemicalwizardry", "textures/models/MinorDemonGruntGuardian_fire.png"); - private static final ResourceLocation iceTexture = new ResourceLocation( + private static final ResourceLocation ICE_GUARDIAN = new ResourceLocation( "alchemicalwizardry", "textures/models/MinorDemonGruntGuardian_ice.png"); - private static final ResourceLocation windTexture = new ResourceLocation( + private static final ResourceLocation WIND_GUARDIAN = new ResourceLocation( "alchemicalwizardry", "textures/models/MinorDemonGruntGuardian_wind.png"); - private static final ResourceLocation earthTexture = new ResourceLocation( + private static final ResourceLocation EARTH_GUARDIAN = new ResourceLocation( "alchemicalwizardry", "textures/models/MinorDemonGruntGuardian_earth.png"); - public RenderMinorDemonGruntGuardian(ModelBase par1ModelBase, float par2) { - super(par1ModelBase, par2); - } - - public ResourceLocation func_110832_a(EntityMinorDemonGruntGuardian entity) { - if (entity instanceof EntityMinorDemonGruntGuardianFire) { - return fireTexture; - } else if (entity instanceof EntityMinorDemonGruntGuardianWind) { - return windTexture; - } else if (entity instanceof EntityMinorDemonGruntGuardianIce) { - return iceTexture; - } else if (entity instanceof EntityMinorDemonGruntGuardianEarth) { - return earthTexture; - } - - return normalTexture; + public RenderMinorDemonGruntGuardian(ModelBase mainModel, float shadowSize) { + super(mainModel, shadowSize); } + @Override public ResourceLocation getEntityTexture(Entity entity) { - return this.func_110832_a((EntityMinorDemonGruntGuardian) entity); + return switch (entity) { + case EntityMinorDemonGruntGuardianFire _ -> FIRE_GUARDIAN; + case EntityMinorDemonGruntGuardianWind _ -> WIND_GUARDIAN; + case EntityMinorDemonGruntGuardianIce _ -> ICE_GUARDIAN; + case EntityMinorDemonGruntGuardianEarth _ -> EARTH_GUARDIAN; + default -> NORMAL_GUARDIAN; + }; + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderShade.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderShade.java index bc14155e76..f84a1159ca 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderShade.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderShade.java @@ -5,23 +5,18 @@ import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import WayofTime.alchemicalWizardry.common.entity.mob.EntityShade; - public class RenderShade extends RenderLiving { - private static final ResourceLocation field_110833_a = new ResourceLocation( + private static final ResourceLocation SHADE = new ResourceLocation( "alchemicalwizardry", "textures/models/ShadeMob.png"); - public RenderShade(ModelBase par1ModelBase, float par2) { - super(par1ModelBase, par2); - } - - public ResourceLocation func_110832_a(EntityShade par1EntityShade) { - return field_110833_a; + public RenderShade(ModelBase mainModel, float shadowSize) { + super(mainModel, shadowSize); } - public ResourceLocation getEntityTexture(Entity par1Entity) { - return this.func_110832_a((EntityShade) par1Entity); + @Override + public ResourceLocation getEntityTexture(Entity entity) { + return SHADE; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderSmallEarthGolem.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderSmallEarthGolem.java index 177d82976b..9f83994812 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderSmallEarthGolem.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderSmallEarthGolem.java @@ -5,23 +5,18 @@ import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import WayofTime.alchemicalWizardry.common.entity.mob.EntitySmallEarthGolem; - public class RenderSmallEarthGolem extends RenderLiving { - private static final ResourceLocation field_110833_a = new ResourceLocation( + private static final ResourceLocation SMALL_EARTH_GOLEM = new ResourceLocation( "alchemicalwizardry", "textures/models/SmallEarthGolem.png"); - public RenderSmallEarthGolem(ModelBase par1ModelBase, float par2) { - super(par1ModelBase, par2); - } - - public ResourceLocation func_110832_a(EntitySmallEarthGolem par1EntitySmallEarthGolem) { - return field_110833_a; + public RenderSmallEarthGolem(ModelBase mainModel, float shadowSize) { + super(mainModel, shadowSize); } - public ResourceLocation getEntityTexture(Entity par1Entity) { - return this.func_110832_a((EntitySmallEarthGolem) par1Entity); + @Override + public ResourceLocation getEntityTexture(Entity entity) { + return SMALL_EARTH_GOLEM; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderWingedFireDemon.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderWingedFireDemon.java index 546d203cbe..5bf7205706 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderWingedFireDemon.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/mob/RenderWingedFireDemon.java @@ -5,23 +5,18 @@ import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import WayofTime.alchemicalWizardry.common.entity.mob.EntityWingedFireDemon; - public class RenderWingedFireDemon extends RenderLiving { - private static final ResourceLocation field_110833_a = new ResourceLocation( + private static final ResourceLocation FIRE_DEMON = new ResourceLocation( "alchemicalwizardry", "textures/models/WingedFireDemon.png"); - public RenderWingedFireDemon(ModelBase par1ModelBase, float par2) { - super(par1ModelBase, par2); - } - - public ResourceLocation func_110832_a(EntityWingedFireDemon par1EntityWingedFireDemon) { - return field_110833_a; + public RenderWingedFireDemon(ModelBase mainModel, float shadowSize) { + super(mainModel, shadowSize); } - public ResourceLocation getEntityTexture(Entity par1Entity) { - return this.func_110832_a((EntityWingedFireDemon) par1Entity); + @Override + public ResourceLocation getEntityTexture(Entity entity) { + return FIRE_DEMON; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelAlchemicalCalcinator.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelAlchemicalCalcinator.java index 209cbdcdf3..6e451c34c5 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelAlchemicalCalcinator.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelAlchemicalCalcinator.java @@ -105,6 +105,7 @@ public ModelAlchemicalCalcinator() { setRotation(Shape5, 0F, 0F, 0F); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -129,6 +130,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelBileDemon.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelBileDemon.java index f9a8bb4ab9..b7dcd3c0e3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelBileDemon.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelBileDemon.java @@ -124,6 +124,7 @@ public ModelBileDemon() { rightArm.mirror = false; } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -152,6 +153,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.head.rotateAngleX = f4 / (180F / (float) Math.PI); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelBloodAltar.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelBloodAltar.java index 53ba2cdc28..14c3bf8af2 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelBloodAltar.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelBloodAltar.java @@ -16,18 +16,15 @@ public class ModelBloodAltar extends ModelBase { - private static final ResourceLocation altar_texture = new ResourceLocation( - "alchemicalwizardry:textures/models/altar.png"); + private static final ResourceLocation TEXTURE = new ResourceLocation( + "alchemicalwizardry", + "textures/models/altar.png"); - private IModelCustom modelBloodAltar; - - public ModelBloodAltar() { - modelBloodAltar = AdvancedModelLoader - .loadModel(new ResourceLocation("alchemicalwizardry:models/bloodaltar-fixeUV.obj")); - } + private final IModelCustom MODEL = AdvancedModelLoader + .loadModel(new ResourceLocation("alchemicalwizardry:models/bloodaltar-fixeUV.obj")); public void renderBloodAltar() { - modelBloodAltar.renderAll(); + MODEL.renderAll(); } public void renderBloodAltar(TEAltar altar, double x, double y, double z) { @@ -39,7 +36,7 @@ public void renderBloodAltar(TEAltar altar, double x, double y, double z) { // Scale our object to about half-size in all directions (the OBJ file is a little large) GL11.glScalef(scale, scale, scale); // Bind the texture, so that OpenGL properly textures our block. - FMLClientHandler.instance().getClient().renderEngine.bindTexture(altar_texture); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE); // Render the object, using modelTutBox.renderAll(); this.renderBloodAltar(); // Pop this matrix from the stack. @@ -58,10 +55,10 @@ public void renderBloodLevel(TEAltar altar, double x, double y, double z) { public void renderBloodLevel(IIcon icon) { Tessellator tessellator = Tessellator.instance; - double minU = (double) icon.getInterpolatedU(0); - double maxU = (double) icon.getInterpolatedU(16); - double minV = (double) icon.getInterpolatedV(0); - double maxV = (double) icon.getInterpolatedV(16); + double minU = icon.getInterpolatedU(0); + double maxU = icon.getInterpolatedU(16); + double minV = icon.getInterpolatedV(0); + double maxV = icon.getInterpolatedV(16); tessellator.startDrawingQuads(); tessellator.setNormal(0, 1, 0); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelBoulderFist.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelBoulderFist.java index 89d573b581..3956b45b78 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelBoulderFist.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelBoulderFist.java @@ -108,6 +108,7 @@ public ModelBoulderFist() { setRotation(head, 0F, 0F, 0F); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -131,6 +132,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.head.rotateAngleX = f4 / (180F / (float) Math.PI); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelConduit.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelConduit.java index 7df47a526d..1bec576301 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelConduit.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelConduit.java @@ -276,6 +276,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelCrystalBelljar.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelCrystalBelljar.java index 11fefe50ee..11d08e9bb2 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelCrystalBelljar.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelCrystalBelljar.java @@ -70,6 +70,7 @@ public ModelCrystalBelljar() { setRotation(jar5, 0F, 0F, 0F); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -105,6 +106,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelElemental.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelElemental.java index 563868dea6..2659fcac18 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelElemental.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelElemental.java @@ -42,6 +42,7 @@ public ModelElemental() { setRotation(Shape3, ((float) Math.PI / 4F), 0F, ((float) Math.PI / 4F)); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -57,6 +58,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); World world = entity.worldObj; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelEnergyBazookaMainProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelEnergyBazookaMainProjectile.java index ce8cc8c37d..5a2e2a39a0 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelEnergyBazookaMainProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelEnergyBazookaMainProjectile.java @@ -90,6 +90,7 @@ public ModelEnergyBazookaMainProjectile() { setRotation(base3, 0F, 0F, 0F); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -112,6 +113,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelFallenAngel.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelFallenAngel.java index afcbb8c280..4ed12ef596 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelFallenAngel.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelFallenAngel.java @@ -76,6 +76,7 @@ public ModelFallenAngel() { setRotation(leftleg, 0F, 0F, 0F); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -95,6 +96,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.head.rotateAngleX = f4 / (180F / (float) Math.PI); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelIceDemon.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelIceDemon.java index 240b2c93ed..3cf17e1898 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelIceDemon.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelIceDemon.java @@ -141,6 +141,7 @@ public ModelIceDemon() { setRotation(Shape1, 0.5948578F, 0F, 0F); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -169,6 +170,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.head.rotateAngleX = f4 / (180F / (float) Math.PI); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelLowerGuardian.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelLowerGuardian.java index 432f7042be..6688503196 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelLowerGuardian.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelLowerGuardian.java @@ -134,6 +134,7 @@ public ModelLowerGuardian() { hornAppendage4.mirror = false; } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -160,8 +161,9 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } - public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) { - EntityLowerGuardian entityLowerGuardian = (EntityLowerGuardian) par1EntityLivingBase; + @Override + public void setLivingAnimations(EntityLivingBase entity, float par2, float par3, float par4) { + EntityLowerGuardian entityLowerGuardian = (EntityLowerGuardian) entity; int i = entityLowerGuardian.getAttackTimer(); if (i > 0) { @@ -175,6 +177,7 @@ private float func_78172_a(float par1, float par2) { return (Math.abs(par1 % par2 - par2 * 0.5F) - par2 * 0.25F) / (par2 * 0.25F); } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.Head.rotateAngleX = f4 / (180F / (float) Math.PI); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelMeteor.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelMeteor.java index b39a11e664..61e80dc8fa 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelMeteor.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelMeteor.java @@ -62,6 +62,7 @@ public ModelMeteor() { setRotation(Shape7, 0F, 0F, 0F); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -80,6 +81,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelMinorDemonGrunt.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelMinorDemonGrunt.java index 0e2db480cd..741dff2708 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelMinorDemonGrunt.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelMinorDemonGrunt.java @@ -75,6 +75,7 @@ public ModelMinorDemonGrunt() { setRotation(middle, 0F, 0F, 0F); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -94,6 +95,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelMinorDemonGruntGuardian.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelMinorDemonGruntGuardian.java index 949f713c91..e3073c53e3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelMinorDemonGruntGuardian.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelMinorDemonGruntGuardian.java @@ -128,6 +128,7 @@ public ModelMinorDemonGruntGuardian() { setRotation(bar2, 0F, 0F, -0.7853982F); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -154,6 +155,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelOmegaArmour.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelOmegaArmour.java index 21301e677e..8c13fbece9 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelOmegaArmour.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelOmegaArmour.java @@ -791,6 +791,7 @@ public ModelOmegaArmour(float f, boolean addHelmet, boolean addChestPiece, boole } } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { // super.render(entity, f, f1, f2, f3, f4, f5); @@ -877,6 +878,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelOmegaWater.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelOmegaWater.java index 1e49ce13bf..2002620bf4 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelOmegaWater.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelOmegaWater.java @@ -461,6 +461,7 @@ public ModelOmegaWater(float f, boolean addHelmet, boolean addChestPiece, boolea } } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -478,6 +479,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelPedestal.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelPedestal.java index 5eccbfe17e..9597e8e099 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelPedestal.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelPedestal.java @@ -34,6 +34,7 @@ public ModelPedestal() { setRotation(middle, 0F, 0F, 0F); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -48,6 +49,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelPlinth.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelPlinth.java index f92f191048..289f69703f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelPlinth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelPlinth.java @@ -62,6 +62,7 @@ public ModelPlinth() { setRotation(edge4, 0F, 0F, 0F); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -80,6 +81,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelShade.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelShade.java index 0c988075b2..81b480e57d 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelShade.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelShade.java @@ -57,6 +57,7 @@ public ModelShade() { setRotation(head, 0F, 0F, 0F); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -74,6 +75,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.head.rotateAngleX = f4 / (180F / (float) Math.PI); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSmallEarthGolem.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSmallEarthGolem.java index 4ec3dc01e6..43e3c209fa 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSmallEarthGolem.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSmallEarthGolem.java @@ -90,6 +90,7 @@ public ModelSmallEarthGolem() { setRotation(back1, 0F, 0F, 0F); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -111,6 +112,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.head.rotateAngleX = f4 / (180F / (float) Math.PI); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellEffectBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellEffectBlock.java index 424152b0eb..ad05d63356 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellEffectBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellEffectBlock.java @@ -320,6 +320,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellEnhancementBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellEnhancementBlock.java index 630af816ba..fd0344d63a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellEnhancementBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellEnhancementBlock.java @@ -321,6 +321,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellModifierBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellModifierBlock.java index 464e96701c..42ea7378d8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellModifierBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellModifierBlock.java @@ -289,6 +289,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellParadigmBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellParadigmBlock.java index 3668607df1..f511709d92 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellParadigmBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelSpellParadigmBlock.java @@ -220,6 +220,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelWingedFireDemon.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelWingedFireDemon.java index cbaa6622c3..b471c81e5f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelWingedFireDemon.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelWingedFireDemon.java @@ -89,7 +89,6 @@ public ModelWingedFireDemon() { setRotation(head, 0F, 0F, 0F); rightShoulder = new ModelRenderer(this, 0, 29); rightShoulder.mirror = true; - rightShoulder.mirror = true; rightShoulder.addBox(-8F, -5F, -4F, 8, 7, 8); rightShoulder.setRotationPoint(-5F, -10F, 0F); rightShoulder.setTextureSize(64, 64); @@ -98,7 +97,6 @@ public ModelWingedFireDemon() { rightShoulder.mirror = false; rightArm = new ModelRenderer(this, 32, 0); rightArm.mirror = true; - rightArm.mirror = true; rightArm.addBox(-7F, 2F, -2F, 4, 12, 4); rightArm.setRotationPoint(-5F, -10F, 0F); rightArm.setTextureSize(64, 64); @@ -149,6 +147,7 @@ public ModelWingedFireDemon() { rightHorn2.mirror = false; } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -177,6 +176,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.head.rotateAngleX = f4 / (180F / (float) Math.PI); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelWritingTable.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelWritingTable.java index 4e68919e65..009807aab8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelWritingTable.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelWritingTable.java @@ -104,6 +104,7 @@ public ModelWritingTable() { setRotation(Shape1, 0F, 0F, 0F); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); @@ -128,6 +129,7 @@ private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/projectile/RenderEnergyBazookaMainProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/projectile/RenderEnergyBazookaMainProjectile.java index df389d86a6..e07b4b8391 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/projectile/RenderEnergyBazookaMainProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/projectile/RenderEnergyBazookaMainProjectile.java @@ -16,14 +16,12 @@ public class RenderEnergyBazookaMainProjectile extends Render { private static final ResourceLocation field_110833_a = new ResourceLocation( "alchemicalwizardry", "textures/models/EnergyBazookaMainProjectile.png"); - private float scale = 1.0f; @Override public void doRender(Entity entity, double d0, double d1, double d2, float f, float f1) { GL11.glPushMatrix(); GL11.glTranslatef((float) d0, (float) d1, (float) d2); GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glScalef(scale, scale, scale); this.bindTexture(this.getEntityTexture(entity)); GL11.glRotatef(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * f1, 0.0F, 1.0F, 0.0F); GL11.glRotatef( diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/projectile/RenderEnergyBlastProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/projectile/RenderEnergyBlastProjectile.java index 95bd3a2dde..623bca4775 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/projectile/RenderEnergyBlastProjectile.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/projectile/RenderEnergyBlastProjectile.java @@ -45,9 +45,9 @@ public void doRenderEnergyBlastProjectile(Entity entityShot, double par2, double } @Override - public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { - if (par1Entity instanceof IProjectile) { - this.doRenderEnergyBlastProjectile(par1Entity, par2, par4, par6, par8, par9); + public void doRender(Entity entity, double par2, double par4, double par6, float par8, float par9) { + if (entity instanceof IProjectile) { + this.doRenderEnergyBlastProjectile(entity, par2, par4, par6, par8, par9); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/projectile/RenderFireProjectile.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/projectile/RenderFireProjectile.java deleted file mode 100644 index a319abfcd2..0000000000 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/projectile/RenderFireProjectile.java +++ /dev/null @@ -1,41 +0,0 @@ -package WayofTime.alchemicalWizardry.common.renderer.projectile; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class RenderFireProjectile { - // public void doRenderProjectile(FireProjectile entityShot, double par2, double par4, double par6, float par8, - // float par9) - // { - // GL11.glPushMatrix(); - // GL11.glTranslatef((float)par2, (float)par4, (float)par6); - // GL11.glEnable(GL12.GL_RESCALE_NORMAL); - // GL11.glScalef(0.1F, 0.1F, 0.1F); - // this.func_110776_a(this.func_110775_a(entityShot)); - // Tessellator var12 = Tessellator.instance; - // GL11.glRotatef(180.0F - renderManager.playerViewY, 0.0F, 1.0F, 0.0F); - // GL11.glRotatef(-renderManager.playerViewX, 1.0F, 0.0F, 0.0F); - // var12.startDrawingQuads(); - // var12.setNormal(0.0F, 1.0F, 0.0F); - // var12.addVertexWithUV(-0.5F, -0.25F, 0.0D, 0, 1); - // var12.addVertexWithUV(0.5F, -0.25F, 0.0D, 1, 1); - // var12.addVertexWithUV(0.5F, 0.75F, 0.0D, 1, 0); - // var12.addVertexWithUV(-0.5F, 0.75F, 0.0D, 0, 0); - // var12.draw(); - // GL11.glDisable(GL12.GL_RESCALE_NORMAL); - // GL11.glPopMatrix(); - // } - // - // @Override - // public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) - // { - // this.doRenderProjectile((FireProjectile)par1Entity, par2, par4, par6, par8, par9); - // } - // - // @Override - // protected ResourceLocation func_110775_a(Entity entity) - // { - // return new ResourceLocation("alchemicalwizardry:/textures/entities/fireProjectile.png"); - // } -} diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/projectile/RenderMeteor.java b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/projectile/RenderMeteor.java index 6e6d79faf8..54df9bec72 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/renderer/projectile/RenderMeteor.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/renderer/projectile/RenderMeteor.java @@ -16,14 +16,12 @@ public class RenderMeteor extends Render { private static final ResourceLocation field_110833_a = new ResourceLocation( "alchemicalwizardry", "textures/models/Meteor.png"); - private float scale = 1.0f; @Override public void doRender(Entity entity, double d0, double d1, double d2, float f, float f1) { GL11.glPushMatrix(); GL11.glTranslatef((float) d0, (float) d1, (float) d2); GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glScalef(scale, scale, scale); this.bindTexture(this.getEntityTexture(entity)); GL11.glRotatef(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * f1, 0.0F, 1.0F, 0.0F); GL11.glRotatef( diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/LocalStorageAlphaPact.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/LocalStorageAlphaPact.java index 0387949139..3c9566365d 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/LocalStorageAlphaPact.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/LocalStorageAlphaPact.java @@ -9,13 +9,13 @@ public class LocalStorageAlphaPact extends LocalRitualStorage { - public static Set hoardList = new HashSet(); + public static Set hoardList = new HashSet<>(); public void thrallDemon(IHoardDemon demon) { if (demon instanceof IHoardDemon) { - boolean enthrall = ((IHoardDemon) demon).thrallDemon(new Int3(this.xCoord, this.yCoord, this.zCoord)); + boolean enthrall = demon.thrallDemon(new Int3(this.xCoord, this.yCoord, this.zCoord)); if (enthrall) { - this.hoardList.add((IHoardDemon) demon); + hoardList.add(demon); } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectAlphaPact.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectAlphaPact.java index 450707a920..30d6de90f5 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectAlphaPact.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectAlphaPact.java @@ -13,7 +13,6 @@ import WayofTime.alchemicalWizardry.api.rituals.LocalRitualStorage; import WayofTime.alchemicalWizardry.api.rituals.RitualComponent; import WayofTime.alchemicalWizardry.api.rituals.RitualEffect; -import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityMinorDemonGrunt; import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon; @@ -23,9 +22,7 @@ public class RitualEffectAlphaPact extends RitualEffect { @Override public void performEffect(IMasterRitualStone ritualStone) { - String owner = ritualStone.getOwner(); - int currentEssence = SoulNetworkHandler.getCurrentEssence(owner); World world = ritualStone.getWorld(); int x = ritualStone.getXCoord(); int y = ritualStone.getYCoord(); @@ -36,33 +33,28 @@ public void performEffect(IMasterRitualStone ritualStone) { } LocalRitualStorage stor = ritualStone.getLocalStorage(); - if (stor instanceof LocalStorageAlphaPact) { - LocalStorageAlphaPact storage = (LocalStorageAlphaPact) stor; + if (stor instanceof LocalStorageAlphaPact storage) { - Object[] demonList = storage.hoardList.toArray(); + Object[] demonList = LocalStorageAlphaPact.hoardList.toArray(); for (Object demon : demonList) { - if (demon instanceof EntityLivingBase) { - if (!((EntityLivingBase) demon).isEntityAlive()) { - System.out.println(storage.hoardList.remove(demon)); + if (demon instanceof EntityLivingBase entity) { + if (!entity.isEntityAlive()) { + System.out.println(LocalStorageAlphaPact.hoardList.remove(demon)); } } } - System.out.println("Hi!"); - - int summons = 0; - int horizontalRange = 25; int verticalRange = 20; - if (storage.hoardList.isEmpty()) { + if (LocalStorageAlphaPact.hoardList.isEmpty()) { IHoardDemon demon = this.getRandomDemonForStage(world, x, y, z, horizontalRange, verticalRange); if (demon instanceof EntityLivingBase) { world.spawnEntityInWorld((EntityLivingBase) demon); storage.thrallDemon(demon); } - } else {} + } } } @@ -73,7 +65,7 @@ public IHoardDemon getRandomDemonForStage(World world, int x, int y, int z, int boolean isGood = false; for (int n = 0; n < 100; n++) { double newX = x + (rand.nextInt(horizontalRange) - horizontalRange) + 0.5; - double newY = y + (double) (rand.nextInt((int) verticalRange)); + double newY = y + (double) (rand.nextInt(verticalRange)); double newZ = z + (rand.nextInt(horizontalRange) - horizontalRange) + 0.5; entityLiving.posX = newX; @@ -107,7 +99,7 @@ public IHoardDemon getRandomDemonForStage(World world, int x, int y, int z, int } } - if (isGood = false) { + if (!isGood) { return null; } @@ -123,13 +115,14 @@ public int getCostPerRefresh() { return 1; } + @Override public LocalRitualStorage getNewLocalStorage() { return new LocalStorageAlphaPact(); } @Override public List getRitualComponentList() { - ArrayList omegaRitual = new ArrayList(); + ArrayList omegaRitual = new ArrayList<>(); this.addCornerRunes(omegaRitual, 1, 0, RitualComponent.BLANK); this.addOffsetRunes(omegaRitual, 2, 1, 0, RitualComponent.FIRE); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectAnimalGrowth.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectAnimalGrowth.java index d99a783f13..c1174ef42e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectAnimalGrowth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectAnimalGrowth.java @@ -40,17 +40,11 @@ public void performEffect(IMasterRitualStone ritualStone) { double range = 2; - AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox( - (double) x, - (double) y + 1, - (double) z, - (double) (x + 1), - (double) (y + 3), - (double) (z + 1)).expand(range, 0, range); + AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(x, y + 1, z, x + 1, y + 3, z + 1) + .expand(range, 0, range); List list = world.getEntitiesWithinAABB(EntityAgeable.class, axisalignedbb); int entityCount = 0; - boolean flag = false; if (currentEssence < this.getCostPerRefresh() * list.size()) { SoulNetworkHandler.causeNauseaToPlayer(owner); @@ -65,8 +59,7 @@ public void performEffect(IMasterRitualStone ritualStone) { } else { hasReductus = hasReductus && this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false); - if (hasReductus && entity instanceof EntityAnimal && entity.getGrowingAge() > 0) { - EntityAnimal animal = (EntityAnimal) entity; + if (hasReductus && entity instanceof EntityAnimal animal && entity.getGrowingAge() > 0) { entity.setGrowingAge(Math.max(0, animal.getGrowingAge() - 20 * 2)); this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true); entityCount++; @@ -100,7 +93,6 @@ public void performEffect(IMasterRitualStone ritualStone) { hasVirtus = hasVirtus && this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false); - boolean hasLP = SoulNetworkHandler.canSyphonFromOnlyNetwork(owner, breedingCost); for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack stack = inventory.getStackInSlot(i); @@ -125,7 +117,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList animalGrowthRitual = new ArrayList(); + ArrayList animalGrowthRitual = new ArrayList<>(); animalGrowthRitual.add(new RitualComponent(0, 0, 2, RitualComponent.DUSK)); animalGrowthRitual.add(new RitualComponent(2, 0, 0, RitualComponent.DUSK)); animalGrowthRitual.add(new RitualComponent(0, 0, -2, RitualComponent.DUSK)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectApiaryOverclock.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectApiaryOverclock.java index 34bb4dd249..e3a748e9c8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectApiaryOverclock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectApiaryOverclock.java @@ -52,7 +52,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList apiaryRitual = new ArrayList(); + ArrayList apiaryRitual = new ArrayList<>(); apiaryRitual.add(new RitualComponent(1, 0, 0, RitualComponent.DUSK)); apiaryRitual.add(new RitualComponent(1, 0, 1, RitualComponent.DUSK)); apiaryRitual.add(new RitualComponent(1, 0, -1, RitualComponent.DUSK)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectAutoAlchemy.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectAutoAlchemy.java index 57388eb7d3..6642427980 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectAutoAlchemy.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectAutoAlchemy.java @@ -39,144 +39,156 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh() * 6) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - boolean hasPotentia = this - .canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, false); + return; + } + boolean hasPotentia = this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, false); - int flag = 0; + int flag = 0; - TileEntity topEntity = world.getTileEntity(x, y + 1, z); - if (!(topEntity instanceof IBloodAltar) || !(topEntity instanceof IBloodAltar)) { - return; - } + TileEntity topEntity = world.getTileEntity(x, y + 1, z); + if (!(topEntity instanceof IBloodAltar altar)) { + return; + } - IBloodAltar altar = (IBloodAltar) topEntity; - ItemStack targetStack = ((IInventory) altar).getStackInSlot(0); - if (targetStack == null) { + ItemStack targetStack = ((IInventory) altar).getStackInSlot(0); + if (targetStack == null) { + return; + } + + ItemStack[] recipe = AlchemyRecipeRegistry.getRecipeForItemStack(targetStack); + if (recipe != null) { + TEWritingTable alchemyEntity; + IInventory outputInv = null; + IInventory inputInv1 = null; + IInventory inputInv2 = null; + + TileEntity northEntity = world.getTileEntity(x, y, z - 1); + TileEntity southEntity = world.getTileEntity(x, y, z + 1); + TileEntity eastEntity = world.getTileEntity(x + 1, y, z); + TileEntity westEntity = world.getTileEntity(x - 1, y, z); + + if (northEntity instanceof TEWritingTable chemistrySet) { + alchemyEntity = chemistrySet; + if (southEntity instanceof IInventory inv && !(southEntity instanceof TEWritingTable)) { + outputInv = inv; + } + if (eastEntity instanceof IInventory inv && !(eastEntity instanceof TEWritingTable)) { + inputInv1 = inv; + } + if (westEntity instanceof IInventory inv && !(westEntity instanceof TEWritingTable)) { + inputInv2 = inv; + } + } else if (southEntity instanceof TEWritingTable chemistrySet) { + alchemyEntity = chemistrySet; + if (northEntity instanceof IInventory inv) { + outputInv = inv; + } + if (eastEntity instanceof IInventory inv && !(eastEntity instanceof TEWritingTable)) { + inputInv1 = inv; + } + if (westEntity instanceof IInventory inv && !(westEntity instanceof TEWritingTable)) { + inputInv2 = inv; + } + } else if (eastEntity instanceof TEWritingTable chemistrySet) { + alchemyEntity = chemistrySet; + if (westEntity instanceof IInventory inv && !(westEntity instanceof TEWritingTable)) { + outputInv = inv; + } + if (northEntity instanceof IInventory inv) { + inputInv1 = inv; + } + if (southEntity instanceof IInventory inv) { + inputInv2 = inv; + } + } else if (westEntity instanceof TEWritingTable chemistrySet) { + alchemyEntity = chemistrySet; + if (eastEntity instanceof IInventory inv) { + outputInv = inv; + } + if (northEntity instanceof IInventory inv) { + inputInv1 = inv; + } + if (southEntity instanceof IInventory inv) { + inputInv2 = inv; + } + } else { return; } - ItemStack[] recipe = AlchemyRecipeRegistry.getRecipeForItemStack(targetStack); - if (recipe != null) { - TEWritingTable alchemyEntity; - IInventory outputInv = null; - IInventory inputInv1 = null; - IInventory inputInv2 = null; - - TileEntity northEntity = world.getTileEntity(x, y, z - 1); - TileEntity southEntity = world.getTileEntity(x, y, z + 1); - TileEntity eastEntity = world.getTileEntity(x + 1, y, z); - TileEntity westEntity = world.getTileEntity(x - 1, y, z); - - if (northEntity instanceof TEWritingTable) { - alchemyEntity = (TEWritingTable) northEntity; - if (southEntity instanceof IInventory && !(southEntity instanceof TEWritingTable)) { - outputInv = (IInventory) southEntity; - } - if (eastEntity instanceof IInventory && !(eastEntity instanceof TEWritingTable)) { - inputInv1 = (IInventory) eastEntity; - } - if (westEntity instanceof IInventory && !(westEntity instanceof TEWritingTable)) { - inputInv2 = (IInventory) westEntity; - } - } else if (southEntity instanceof TEWritingTable) { - alchemyEntity = (TEWritingTable) southEntity; - if (northEntity instanceof IInventory && !(northEntity instanceof TEWritingTable)) { - outputInv = (IInventory) northEntity; - } - if (eastEntity instanceof IInventory && !(eastEntity instanceof TEWritingTable)) { - inputInv1 = (IInventory) eastEntity; - } - if (westEntity instanceof IInventory && !(westEntity instanceof TEWritingTable)) { - inputInv2 = (IInventory) westEntity; - } - } else if (eastEntity instanceof TEWritingTable) { - alchemyEntity = (TEWritingTable) eastEntity; - if (westEntity instanceof IInventory && !(westEntity instanceof TEWritingTable)) { - outputInv = (IInventory) westEntity; - } - if (northEntity instanceof IInventory && !(northEntity instanceof TEWritingTable)) { - inputInv1 = (IInventory) northEntity; - } - if (southEntity instanceof IInventory && !(southEntity instanceof TEWritingTable)) { - inputInv2 = (IInventory) southEntity; - } - } else if (westEntity instanceof TEWritingTable) { - alchemyEntity = (TEWritingTable) westEntity; - if (eastEntity instanceof IInventory && !(eastEntity instanceof TEWritingTable)) { - outputInv = (IInventory) eastEntity; - } - if (northEntity instanceof IInventory && !(northEntity instanceof TEWritingTable)) { - inputInv1 = (IInventory) northEntity; - } - if (southEntity instanceof IInventory && !(southEntity instanceof TEWritingTable)) { - inputInv2 = (IInventory) southEntity; - } - } else { - return; + if (hasPotentia) { + alchemyEntity.setAccelerationTime(5); + if (alchemyEntity.isWorking()) { + this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, true); } + } - if (alchemyEntity != null && hasPotentia) { - alchemyEntity.setAccelerationTime(5); - if (alchemyEntity.isWorking()) { - this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, true); - } - } + if (outputInv != null) { + ItemStack outputStack = alchemyEntity.getStackInSlot(6); + if (outputStack != null) { + for (int i = 0; i < outputInv.getSizeInventory(); i++) { + ItemStack curStack = outputInv.getStackInSlot(i); + if (curStack == null) { + ItemStack copyStack = outputStack.copy(); + copyStack.stackSize = 1; + + outputStack.stackSize--; + if (outputStack.stackSize <= 0) { + alchemyEntity.setInventorySlotContents(6, null); + } else { + alchemyEntity.setInventorySlotContents(6, outputStack); + } - if (outputInv != null) { - ItemStack outputStack = alchemyEntity.getStackInSlot(6); - if (outputStack != null) { - for (int i = 0; i < outputInv.getSizeInventory(); i++) { - ItemStack curStack = outputInv.getStackInSlot(i); - if (curStack == null) { - ItemStack copyStack = outputStack.copy(); - copyStack.stackSize = 1; - - outputStack.stackSize--; - if (outputStack.stackSize <= 0) { - alchemyEntity.setInventorySlotContents(6, null); - } else { - alchemyEntity.setInventorySlotContents(6, outputStack); - } + outputInv.setInventorySlotContents(i, copyStack); + flag++; + break; + } else if (curStack.isItemEqual(outputStack) && curStack.stackSize < curStack.getMaxStackSize() + && ItemStack.areItemStackTagsEqual(outputStack, curStack)) { + outputStack.stackSize--; + if (outputStack.stackSize <= 0) { + alchemyEntity.setInventorySlotContents(6, null); + } else { + alchemyEntity.setInventorySlotContents(6, outputStack); + } - outputInv.setInventorySlotContents(i, copyStack); - flag++; - break; - } else - if (curStack.isItemEqual(outputStack) && curStack.stackSize < curStack.getMaxStackSize() - && ItemStack.areItemStackTagsEqual(outputStack, curStack)) { - outputStack.stackSize--; - if (outputStack.stackSize <= 0) { - alchemyEntity.setInventorySlotContents(6, null); - } else { - alchemyEntity.setInventorySlotContents(6, outputStack); - } - - curStack.stackSize++; - outputInv.setInventorySlotContents(i, curStack); - flag++; - break; - } - } + curStack.stackSize++; + outputInv.setInventorySlotContents(i, curStack); + flag++; + break; + } } + } - for (int i = 0; i < 5; i++) { - ItemStack recItem; - if (recipe.length <= i) { - recItem = null; - } else { - recItem = recipe[i]; - } + for (int i = 0; i < 5; i++) { + ItemStack recItem; + if (recipe.length <= i) { + recItem = null; + } else { + recItem = recipe[i]; + } - ItemStack alchStack = alchemyEntity.getStackInSlot(i + 1); - if ((recItem == null && alchStack != null) - || (alchStack != null && !(areItemStacksEqualWithWildcard(recItem, alchStack)))) { - for (int j = 0; j < outputInv.getSizeInventory(); j++) { - ItemStack curStack = outputInv.getStackInSlot(j); - if (curStack == null) { - ItemStack copyStack = alchStack.copy(); - copyStack.stackSize = 1; + ItemStack alchStack = alchemyEntity.getStackInSlot(i + 1); + if ((recItem != null || alchStack == null) + && (alchStack == null || areItemStacksEqualWithWildcard(recItem, alchStack))) { + continue; + } + for (int j = 0; j < outputInv.getSizeInventory(); j++) { + ItemStack curStack = outputInv.getStackInSlot(j); + if (curStack == null) { + ItemStack copyStack = alchStack.copy(); + copyStack.stackSize = 1; + + alchStack.stackSize--; + if (alchStack.stackSize <= 0) { + alchemyEntity.setInventorySlotContents(i + 1, null); + } else { + alchemyEntity.setInventorySlotContents(i + 1, alchStack); + } + outputInv.setInventorySlotContents(j, copyStack); + flag++; + break; + } else if (curStack.isItemEqual(alchStack) && curStack.stackSize < curStack.getMaxStackSize() + && ItemStack.areItemStackTagsEqual(alchStack, curStack)) { alchStack.stackSize--; if (alchStack.stackSize <= 0) { alchemyEntity.setInventorySlotContents(i + 1, null); @@ -184,151 +196,120 @@ public void performEffect(IMasterRitualStone ritualStone) { alchemyEntity.setInventorySlotContents(i + 1, alchStack); } - outputInv.setInventorySlotContents(j, copyStack); + curStack.stackSize++; + outputInv.setInventorySlotContents(j, curStack); flag++; break; - } else if (curStack.isItemEqual(alchStack) - && curStack.stackSize < curStack.getMaxStackSize() - && ItemStack.areItemStackTagsEqual(alchStack, curStack)) { - alchStack.stackSize--; - if (alchStack.stackSize <= 0) { - alchemyEntity.setInventorySlotContents(i + 1, null); - } else { - alchemyEntity.setInventorySlotContents(i + 1, alchStack); - } - - curStack.stackSize++; - outputInv.setInventorySlotContents(j, curStack); - flag++; - break; - } - } - continue; - } + } } } + } - if (world.getTotalWorldTime() % 10 == 0) { - if (flag == 0 && inputInv1 != null) { - for (int i = 0; i < recipe.length; i++) { - ItemStack recItem = recipe[i]; - if (recItem == null) { + if (world.getTotalWorldTime() % 10 == 0) { + if (flag == 0 && inputInv1 != null) { + for (int i = 0; i < recipe.length; i++) { + ItemStack recItem = recipe[i]; + if (recItem == null) { + continue; + } + ItemStack alchStack = alchemyEntity.getStackInSlot(i + 1); + + if (alchStack != null && ((!areItemStacksEqualWithWildcard(recItem, alchStack)) + || alchStack.stackSize >= (fillToOne ? 1 : alchStack.getMaxStackSize()))) { + continue; + } + + for (int j = 0; j < inputInv1.getSizeInventory(); j++) { + ItemStack curItem = inputInv1.getStackInSlot(j); + if (curItem == null) { continue; } - ItemStack alchStack = alchemyEntity.getStackInSlot(i + 1); - if (alchStack != null && ((!areItemStacksEqualWithWildcard(recItem, alchStack)) - || alchStack.stackSize >= (fillToOne ? 1 : alchStack.getMaxStackSize()))) { + if (!inputInv1.isItemValidForSlot(j, curItem) || (inputInv1 instanceof ISidedInventory input + && !input.canExtractItem(j, curItem, ForgeDirection.DOWN.ordinal()))) { continue; } - for (int j = 0; j < inputInv1.getSizeInventory(); j++) { - ItemStack curItem = inputInv1.getStackInSlot(j); - if (curItem == null) { - continue; - } - - if (!inputInv1.isItemValidForSlot(j, curItem) - || (inputInv1 instanceof ISidedInventory && !((ISidedInventory) inputInv1) - .canExtractItem(j, curItem, ForgeDirection.DOWN.ordinal()))) { - continue; + if (areItemStacksEqualWithWildcard(recItem, curItem)) { + if (alchStack == null) { + ItemStack copyStack = recItem.copy(); + copyStack.stackSize = 1; + alchemyEntity.setInventorySlotContents(i + 1, copyStack); + } else { + alchStack.stackSize++; + alchemyEntity.setInventorySlotContents(i + 1, alchStack); } - - if (areItemStacksEqualWithWildcard(recItem, curItem)) { - if (alchStack == null) { - ItemStack copyStack = recItem.copy(); - copyStack.stackSize = 1; - alchemyEntity.setInventorySlotContents(i + 1, copyStack); - - curItem.stackSize--; - if (curItem.stackSize <= 0) { - inputInv1.setInventorySlotContents(j, null); - } else { - inputInv1.setInventorySlotContents(j, curItem); - } - - flag++; - break; - - } else { - alchStack.stackSize++; - alchemyEntity.setInventorySlotContents(i + 1, alchStack); - - curItem.stackSize--; - if (curItem.stackSize <= 0) { - inputInv1.setInventorySlotContents(j, null); - } else { - inputInv1.setInventorySlotContents(j, curItem); - } - - flag++; - break; - } + curItem.stackSize--; + if (curItem.stackSize <= 0) { + inputInv1.setInventorySlotContents(j, null); + } else { + inputInv1.setInventorySlotContents(j, curItem); } + flag++; + break; } } } - if (flag == 0 && inputInv2 != null) { - for (int i = 0; i < recipe.length; i++) { - ItemStack recItem = recipe[i]; - if (recItem == null) { - continue; - } - ItemStack alchStack = alchemyEntity.getStackInSlot(i + 1); - if (alchStack != null && ((!areItemStacksEqualWithWildcard(recItem, alchStack)) - || alchStack.stackSize >= (fillToOne ? 1 : alchStack.getMaxStackSize()))) { + } + if (flag == 0 && inputInv2 != null) { + for (int i = 0; i < recipe.length; i++) { + ItemStack recItem = recipe[i]; + if (recItem == null) { + continue; + } + ItemStack alchStack = alchemyEntity.getStackInSlot(i + 1); + if (alchStack != null && ((!areItemStacksEqualWithWildcard(recItem, alchStack)) + || alchStack.stackSize >= (fillToOne ? 1 : alchStack.getMaxStackSize()))) { + continue; + } + + for (int j = 0; j < inputInv2.getSizeInventory(); j++) { + ItemStack curItem = inputInv2.getStackInSlot(j); + if (curItem == null) { continue; } + if (areItemStacksEqualWithWildcard(recItem, curItem)) { + if (alchStack == null) { + ItemStack copyStack = recItem.copy(); + copyStack.stackSize = 1; + alchemyEntity.setInventorySlotContents(i + 1, copyStack); - for (int j = 0; j < inputInv2.getSizeInventory(); j++) { - ItemStack curItem = inputInv2.getStackInSlot(j); - if (curItem == null) { - continue; - } - if (areItemStacksEqualWithWildcard(recItem, curItem)) { - if (alchStack == null) { - ItemStack copyStack = recItem.copy(); - copyStack.stackSize = 1; - alchemyEntity.setInventorySlotContents(i + 1, copyStack); - - curItem.stackSize--; - if (curItem.stackSize <= 0) { - inputInv2.setInventorySlotContents(j, null); - } else { - inputInv2.setInventorySlotContents(j, curItem); - } - - flag++; - break; - + curItem.stackSize--; + if (curItem.stackSize <= 0) { + inputInv2.setInventorySlotContents(j, null); } else { - alchStack.stackSize++; - alchemyEntity.setInventorySlotContents(i + 1, alchStack); + inputInv2.setInventorySlotContents(j, curItem); + } - curItem.stackSize--; - if (curItem.stackSize <= 0) { - inputInv2.setInventorySlotContents(j, null); - } else { - inputInv2.setInventorySlotContents(j, curItem); - } + flag++; + break; + } else { + alchStack.stackSize++; + alchemyEntity.setInventorySlotContents(i + 1, alchStack); - flag++; - break; + curItem.stackSize--; + if (curItem.stackSize <= 0) { + inputInv2.setInventorySlotContents(j, null); + } else { + inputInv2.setInventorySlotContents(j, curItem); } + + flag++; + break; } } } } } } + } - if (flag > 0) { - world.markBlockForUpdate(x, y, z + 1); - world.markBlockForUpdate(x, y, z - 1); - world.markBlockForUpdate(x + 1, y, z); - world.markBlockForUpdate(x - 1, y, z); - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * flag); - } + if (flag > 0) { + world.markBlockForUpdate(x, y, z + 1); + world.markBlockForUpdate(x, y, z - 1); + world.markBlockForUpdate(x + 1, y, z); + world.markBlockForUpdate(x - 1, y, z); + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * flag); } } @@ -339,7 +320,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList autoAlchemyRitual = new ArrayList(); + ArrayList autoAlchemyRitual = new ArrayList<>(); autoAlchemyRitual.add(new RitualComponent(1, 0, 1, RitualComponent.DUSK)); autoAlchemyRitual.add(new RitualComponent(1, 0, -1, RitualComponent.DUSK)); autoAlchemyRitual.add(new RitualComponent(-1, 0, -1, RitualComponent.DUSK)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectBinding.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectBinding.java index 006f7c5245..b8894f9654 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectBinding.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectBinding.java @@ -1,15 +1,11 @@ package WayofTime.alchemicalWizardry.common.rituals; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; @@ -34,114 +30,65 @@ public void performEffect(IMasterRitualStone ritualStone) { int z = ritualStone.getZCoord(); if (currentEssence < this.getCostPerRefresh()) { - EntityPlayer entityOwner = SpellHelper.getPlayerForUsername(owner); - - if (entityOwner == null) { - return; - } - - entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80)); - } else { - if (ritualStone.getVar1() == 0) { - int d0 = 0; - AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox( - (double) x, - (double) y + 1, - (double) z, - (double) (x + 1), - (double) (y + 2), - (double) (z + 1)).expand(d0, d0, d0); - List list = world.getEntitiesWithinAABB(EntityItem.class, axisalignedbb); - Iterator iterator = list.iterator(); - EntityItem item; - - while (iterator.hasNext()) { - item = (EntityItem) iterator.next(); - ItemStack itemStack = item.getEntityItem(); - - if (itemStack == null) { - continue; - } + SoulNetworkHandler.causeNauseaToPlayer(owner); + return; + } + if (ritualStone.getVar1() == 0) { + AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(x, y + 1, z, x + 1, y + 2, z + 1); + List list = world.getEntitiesWithinAABB(EntityItem.class, axisalignedbb); - if (BindingRegistry.isRequiredItemValid(itemStack)) { - ritualStone.setVar1(BindingRegistry.getIndexForItem(itemStack) + 1); - itemStack.stackSize--; - world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z)); - ritualStone.setCooldown(ritualStone.getCooldown() - 1); - if (itemStack.stackSize <= 0) { - item.setDead(); - } - break; - } + for (EntityItem item : list) { + ItemStack itemStack = item.getEntityItem(); - if (world.rand.nextInt(10) == 0) { - SpellHelper.sendIndexedParticleToAllAround( - world, - x, - y, - z, - 20, - world.provider.dimensionId, - 1, - x, - y, - z); - } + if (itemStack == null) { + continue; } - SoulNetworkHandler.syphonFromNetwork(owner, getCostPerRefresh()); - } else { - ritualStone.setCooldown(ritualStone.getCooldown() - 1); - - if (world.rand.nextInt(20) == 0) { - int lightningPoint = world.rand.nextInt(8); - - switch (lightningPoint) { - case 0: - world.addWeatherEffect(new EntityLightningBolt(world, x + 4, y + 3, z)); - break; - - case 1: - world.addWeatherEffect(new EntityLightningBolt(world, x - 4, y + 3, z)); - break; - - case 2: - world.addWeatherEffect(new EntityLightningBolt(world, x, y + 3, z + 4)); - break; - - case 3: - world.addWeatherEffect(new EntityLightningBolt(world, x, y + 3, z - 4)); - break; - - case 4: - world.addWeatherEffect(new EntityLightningBolt(world, x + 3, y + 3, z + 3)); - break; - - case 5: - world.addWeatherEffect(new EntityLightningBolt(world, x - 3, y + 3, z + 3)); - break; - - case 6: - world.addWeatherEffect(new EntityLightningBolt(world, x + 3, y + 3, z - 3)); - break; - - case 7: - world.addWeatherEffect(new EntityLightningBolt(world, x - 3, y + 3, z - 3)); - break; + if (BindingRegistry.isRequiredItemValid(itemStack)) { + ritualStone.setVar1(BindingRegistry.getIndexForItem(itemStack) + 1); + itemStack.stackSize--; + world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z)); + ritualStone.setCooldown(ritualStone.getCooldown() - 1); + if (itemStack.stackSize <= 0) { + item.setDead(); } + break; } - if (ritualStone.getCooldown() <= 0) { + if (world.rand.nextInt(10) == 0) { + SpellHelper + .sendIndexedParticleToAllAround(world, x, y, z, 20, world.provider.dimensionId, 1, x, y, z); + } + } - ItemStack spawnedItem = BindingRegistry.getOutputForIndex(ritualStone.getVar1() - 1); + SoulNetworkHandler.syphonFromNetwork(owner, getCostPerRefresh()); + } else { + ritualStone.setCooldown(ritualStone.getCooldown() - 1); + + if (world.rand.nextInt(20) == 0) { + int lightningPoint = world.rand.nextInt(8); + + switch (lightningPoint) { + case 0 -> world.addWeatherEffect(new EntityLightningBolt(world, x + 4, y + 3, z)); + case 1 -> world.addWeatherEffect(new EntityLightningBolt(world, x - 4, y + 3, z)); + case 2 -> world.addWeatherEffect(new EntityLightningBolt(world, x, y + 3, z + 4)); + case 3 -> world.addWeatherEffect(new EntityLightningBolt(world, x, y + 3, z - 4)); + case 4 -> world.addWeatherEffect(new EntityLightningBolt(world, x + 3, y + 3, z + 3)); + case 5 -> world.addWeatherEffect(new EntityLightningBolt(world, x - 3, y + 3, z + 3)); + case 6 -> world.addWeatherEffect(new EntityLightningBolt(world, x + 3, y + 3, z - 3)); + case 7 -> world.addWeatherEffect(new EntityLightningBolt(world, x - 3, y + 3, z - 3)); + } + } - if (spawnedItem != null) { - EntityItem newItem = new EntityItem(world, x + 0.5, y + 1, z + 0.5, spawnedItem.copy()); - world.spawnEntityInWorld(newItem); - } + if (ritualStone.getCooldown() <= 0) { + ItemStack spawnedItem = BindingRegistry.getOutputForIndex(ritualStone.getVar1() - 1); - ritualStone.setActive(false); + if (spawnedItem != null) { + EntityItem newItem = new EntityItem(world, x + 0.5, y + 1, z + 0.5, spawnedItem.copy()); + world.spawnEntityInWorld(newItem); } + + ritualStone.setActive(false); } } } @@ -158,7 +105,7 @@ public int getInitialCooldown() { @Override public List getRitualComponentList() { - ArrayList boundSoulRitual = new ArrayList(); + ArrayList boundSoulRitual = new ArrayList<>(); boundSoulRitual.add(new RitualComponent(3, 0, 0, 2)); boundSoulRitual.add(new RitualComponent(-3, 0, 0, 2)); boundSoulRitual.add(new RitualComponent(0, 0, 3, 2)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectBiomeChanger.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectBiomeChanger.java index e47248474c..f11805e402 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectBiomeChanger.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectBiomeChanger.java @@ -9,14 +9,11 @@ import net.minecraft.block.Block; import net.minecraft.entity.effect.EntityLightningBolt; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -29,7 +26,6 @@ import WayofTime.alchemicalWizardry.api.rituals.RitualEffect; import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; import WayofTime.alchemicalWizardry.common.NewPacketHandler; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; import WayofTime.alchemicalWizardry.common.tileEntity.TEPlinth; public class RitualEffectBiomeChanger extends RitualEffect { @@ -63,206 +59,196 @@ public void performEffect(IMasterRitualStone ritualStone) { int range = 10; if (currentEssence < this.getCostPerRefresh()) { - EntityPlayer entityOwner = SpellHelper.getPlayerForUsername(owner); + SoulNetworkHandler.causeNauseaToPlayer(owner); + return; + } + boolean[][] boolList = new boolean[range * 2 + 1][range * 2 + 1]; - if (entityOwner == null) { - return; + for (int i = 0; i < 2 * range + 1; i++) { + for (int j = 0; j < 2 * range + 1; j++) { + boolList[i][j] = false; } + } - entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80)); - } else { - boolean[][] boolList = new boolean[range * 2 + 1][range * 2 + 1]; + boolList[range][range] = true; - for (int i = 0; i < 2 * range + 1; i++) { - for (int j = 0; j < 2 * range + 1; j++) { - boolList[i][j] = false; - } - } + Queue BFSqueue = new ArrayDeque<>(); + BFSqueue.add(x); + BFSqueue.add(z); - boolList[range][range] = true; + BiConsumer tryEnqueue = (nextX, nextZ) -> { + if (Math.abs(nextX - x) > range || Math.abs(nextZ - z) > range) return; + if (boolList[nextX - (x - range)][nextZ - (z - range)]) return; - Queue BFSqueue = new ArrayDeque<>(); - BFSqueue.add(x); - BFSqueue.add(z); + Block block = world.getBlock(nextX, y + 1, nextZ); + if (block == null || block.equals(ModBlocks.bloodStoneBrick) + || block.equals(ModBlocks.largeBloodStoneBrick)) + return; - BiConsumer tryEnqueue = (nextX, nextZ) -> { - if (Math.abs(nextX - x) > range || Math.abs(nextZ - z) > range) return; - if (boolList[nextX - (x - range)][nextZ - (z - range)]) return; + boolList[nextX - (x - range)][nextZ - (z - range)] = true; + BFSqueue.add(nextX); + BFSqueue.add(nextZ); + }; - Block block = world.getBlock(nextX, y + 1, nextZ); - if (block == null || block.equals(ModBlocks.bloodStoneBrick) - || block.equals(ModBlocks.largeBloodStoneBrick)) - return; + while (!BFSqueue.isEmpty()) { + Integer curX = BFSqueue.remove(); + Integer curZ = BFSqueue.remove(); - boolList[nextX - (x - range)][nextZ - (z - range)] = true; - BFSqueue.add(nextX); - BFSqueue.add(nextZ); - }; + tryEnqueue.accept(curX + 1, curZ); + tryEnqueue.accept(curX, curZ + 1); + tryEnqueue.accept(curX - 1, curZ); + tryEnqueue.accept(curX, curZ - 1); + } - while (!BFSqueue.isEmpty()) { - Integer curX = BFSqueue.remove(); - Integer curZ = BFSqueue.remove(); + float temperature = 0.5f; + float humidity = 0.5f; + float acceptableRange = 0.0999f; + int biomeSkip = 0; - tryEnqueue.accept(curX + 1, curZ); - tryEnqueue.accept(curX, curZ + 1); - tryEnqueue.accept(curX - 1, curZ); - tryEnqueue.accept(curX, curZ - 1); - } + for (int i = -1; i <= 1; i++) { + for (int j = -1; j <= 1; j++) { + if (i == 0 && j == 0) { + continue; + } - float temperature = 0.5f; - float humidity = 0.5f; - float acceptableRange = 0.0999f; - int biomeSkip = 0; + boolean isItemConsumed = false; + TileEntity tileEntity = world.getTileEntity(x + i, y, z + j); - for (int i = -1; i <= 1; i++) { - for (int j = -1; j <= 1; j++) { - if (i == 0 && j == 0) { - continue; - } + if (!(tileEntity instanceof TEPlinth tilePlinth)) { + continue; + } - boolean isItemConsumed = false; - TileEntity tileEntity = world.getTileEntity(x + i, y, z + j); + ItemStack itemStack = tilePlinth.getStackInSlot(0); - if (!(tileEntity instanceof TEPlinth)) { - continue; - } + if (itemStack != null) { + Item itemTest = itemStack.getItem(); - TEPlinth tilePlinth = (TEPlinth) tileEntity; - ItemStack itemStack = tilePlinth.getStackInSlot(0); - - if (itemStack != null) { - Item itemTest = itemStack.getItem(); - - if (itemTest != null) { - if (itemTest instanceof ItemBlock) { - Block item = ((ItemBlock) itemTest).field_150939_a; - if (item == (Blocks.sand)) { - humidity -= 0.1f; - isItemConsumed = true; - } else if (item == (Blocks.lapis_block)) { - humidity += 0.4f; - isItemConsumed = true; - } else if (item == (Blocks.sand)) { - humidity -= 0.1f; - isItemConsumed = true; - } else if (item == (Blocks.sandstone)) { - humidity -= 0.2f; - isItemConsumed = true; - } else if (item == (Blocks.netherrack)) { - humidity -= 0.4f; - isItemConsumed = true; - } else if (item == (Blocks.coal_block)) { - temperature += 0.2f; - isItemConsumed = true; - } else if (item == (Blocks.ice)) { - temperature -= 0.4f; - isItemConsumed = true; - } else if (item == (Blocks.snow)) { - temperature -= 0.2f; - isItemConsumed = true; - } else if (item == (Blocks.wool)) { - int skip = itemStack.getItemDamage() + 1; - biomeSkip += skip; - isItemConsumed = true; - } - } else if (itemTest.equals(Items.dye) && itemStack.getItemDamage() == 4) { - humidity += 0.1f; + if (itemTest != null) { + if (itemTest instanceof ItemBlock block) { + Block item = block.field_150939_a; + if (item == (Blocks.sand)) { + humidity -= 0.1f; + isItemConsumed = true; + } else if (item == (Blocks.lapis_block)) { + humidity += 0.4f; + isItemConsumed = true; + } else if (item == (Blocks.sandstone)) { + humidity -= 0.2f; isItemConsumed = true; - } else if (itemTest.equals(Items.lava_bucket)) { - temperature += 0.4f; + } else if (item == (Blocks.netherrack)) { + humidity -= 0.4f; isItemConsumed = true; - } else if (itemTest.equals(Items.water_bucket)) { - humidity += 0.2f; + } else if (item == (Blocks.coal_block)) { + temperature += 0.2f; isItemConsumed = true; - } else if (itemTest.equals(Items.coal)) { - temperature += 0.1f; + } else if (item == (Blocks.ice)) { + temperature -= 0.4f; isItemConsumed = true; - } else if (itemTest.equals(Items.snowball)) { - temperature -= 0.1f; + } else if (item == (Blocks.snow)) { + temperature -= 0.2f; + isItemConsumed = true; + } else if (item == (Blocks.wool)) { + int skip = itemStack.getItemDamage() + 1; + biomeSkip += skip; isItemConsumed = true; } + } else if (itemTest.equals(Items.dye) && itemStack.getItemDamage() == 4) { // Lapis + humidity += 0.1f; + isItemConsumed = true; + } else if (itemTest.equals(Items.lava_bucket)) { + temperature += 0.4f; + isItemConsumed = true; + } else if (itemTest.equals(Items.water_bucket)) { + humidity += 0.2f; + isItemConsumed = true; + } else if (itemTest.equals(Items.coal)) { + temperature += 0.1f; + isItemConsumed = true; + } else if (itemTest.equals(Items.snowball)) { + temperature -= 0.1f; + isItemConsumed = true; } } + } - if (isItemConsumed) { - tilePlinth.setInventorySlotContents(0, null); - world.markBlockForUpdate(x + i, y, z + j); - world.addWeatherEffect(new EntityLightningBolt(world, x + i, y + 1, z + j)); - } + if (isItemConsumed) { + tilePlinth.setInventorySlotContents(0, null); + world.markBlockForUpdate(x + i, y, z + j); + world.addWeatherEffect(new EntityLightningBolt(world, x + i, y + 1, z + j)); } } + } - boolean wantsSnow = false; - boolean wantsRain = true; - int biomeID = 1; - BiomeGenBase[] biomeList = BiomeGenBase.getBiomeGenArray(); + boolean wantsSnow = false; + boolean wantsRain = true; + int biomeID = 1; + BiomeGenBase[] biomeList = BiomeGenBase.getBiomeGenArray(); - for (BiomeGenBase biome : biomeList) { - if (biome == null) { - continue; - } + for (BiomeGenBase biome : biomeList) { + if (biome == null) { + continue; + } - float temp = biome.temperature; - float rainfall = biome.rainfall; - temperature = Math.min(2.0f, Math.max(0.0f, temperature)); - humidity = Math.min(2.0f, Math.max(0.0f, humidity)); - - if (Math.abs(rainfall - humidity) < acceptableRange && Math.abs(temperature - temp) < acceptableRange) { - biomeID = biome.biomeID; - if (biomeSkip == 0) { - break; - } else { - biomeSkip--; - } + float temp = biome.temperature; + float rainfall = biome.rainfall; + temperature = Math.min(2.0f, Math.max(0.0f, temperature)); + humidity = Math.min(2.0f, Math.max(0.0f, humidity)); + + if (Math.abs(rainfall - humidity) < acceptableRange && Math.abs(temperature - temp) < acceptableRange) { + biomeID = biome.biomeID; + if (biomeSkip == 0) { + break; + } else { + biomeSkip--; } } + } - // Default to Plains if too much biome skip is used - if (biomeSkip != 0) { - biomeID = 1; - } + // Default to Plains if too much biome skip is used + if (biomeSkip != 0) { + biomeID = 1; + } - List chunkList = new ArrayList<>(); + List chunkList = new ArrayList<>(); - for (int chunkX = (x - range) >> 4; chunkX <= (x + range) >> 4; ++chunkX) { - for (int chunkZ = (z - range) >> 4; chunkZ <= (z + range) >> 4; ++chunkZ) { - chunkList.add(world.getChunkFromChunkCoords(chunkX, chunkZ)); - } + for (int chunkX = (x - range) >> 4; chunkX <= (x + range) >> 4; ++chunkX) { + for (int chunkZ = (z - range) >> 4; chunkZ <= (z + range) >> 4; ++chunkZ) { + chunkList.add(world.getChunkFromChunkCoords(chunkX, chunkZ)); } + } - for (Chunk chunk : chunkList) { - byte[] byteArray = chunk.getBiomeArray(); - BitSet mask = new BitSet(); - boolean changed = false; - - for (int cZ = 0; cZ < 16; ++cZ) { - int offsetZ = (chunk.zPosition << 4 | cZ) - (z - range); - if (0 <= offsetZ && offsetZ < 2 * range + 1) { - for (int cX = 0; cX < 16; ++cX) { - int offsetX = (chunk.xPosition << 4 | cX) - (x - range); - if (0 <= offsetX && offsetX < 2 * range + 1) { - if (boolList[offsetX][offsetZ]) { - mask.set(cZ << 4 | cX, true); - byteArray[cZ << 4 | cX] = (byte) biomeID; - changed = true; - } + for (Chunk chunk : chunkList) { + byte[] byteArray = chunk.getBiomeArray(); + BitSet mask = new BitSet(); + boolean changed = false; + + for (int cZ = 0; cZ < 16; ++cZ) { + int offsetZ = (chunk.zPosition << 4 | cZ) - (z - range); + if (0 <= offsetZ && offsetZ < 2 * range + 1) { + for (int cX = 0; cX < 16; ++cX) { + int offsetX = (chunk.xPosition << 4 | cX) - (x - range); + if (0 <= offsetX && offsetX < 2 * range + 1) { + if (boolList[offsetX][offsetZ]) { + mask.set(cZ << 4 | cX, true); + byteArray[cZ << 4 | cX] = (byte) biomeID; + changed = true; } } } } - - if (changed) { - chunk.setBiomeArray(byteArray); - NewPacketHandler.INSTANCE.sendToDimension( - NewPacketHandler - .getGaiaBiomeChangePacket(chunk.xPosition, chunk.zPosition, (byte) biomeID, mask), - world.provider.dimensionId); - } } - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); - ritualStone.setActive(false); + if (changed) { + chunk.setBiomeArray(byteArray); + NewPacketHandler.INSTANCE.sendToDimension( + NewPacketHandler + .getGaiaBiomeChangePacket(chunk.xPosition, chunk.zPosition, (byte) biomeID, mask), + world.provider.dimensionId); + } } + + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); + ritualStone.setActive(false); } @Override @@ -277,7 +263,7 @@ public int getInitialCooldown() { @Override public List getRitualComponentList() { - ArrayList biomeChangerRitual = new ArrayList(); + ArrayList biomeChangerRitual = new ArrayList<>(); biomeChangerRitual.add(new RitualComponent(1, 0, -2, RitualComponent.AIR)); biomeChangerRitual.add(new RitualComponent(1, 0, -3, RitualComponent.AIR)); biomeChangerRitual.add(new RitualComponent(2, 0, -1, RitualComponent.AIR)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectContainment.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectContainment.java index 14f78fd48a..f0cdbf302e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectContainment.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectContainment.java @@ -35,64 +35,62 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh()) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - final int crepitousDrain = 1; - final int terraeDrain = 5; - final int magicalesDrain = 10; - - boolean flag = false; - boolean hasCrepitous = this - .canDrainReagent(ritualStone, ReagentRegistry.crepitousReagent, crepitousDrain, false); - boolean hasTerrae = this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, false); - boolean hasMagicales = this - .canDrainReagent(ritualStone, ReagentRegistry.magicalesReagent, magicalesDrain, false); - int d0 = hasTerrae ? 10 : 5; - List entityList = SpellHelper.getEntitiesInRange(world, x + 0.5, y + 0.5, z + 0.5, d0, d0); - - for (Entity entity : entityList) { - if (!(entity instanceof EntityLivingBase)) { - continue; - } - - EntityLivingBase livingEntity = (EntityLivingBase) entity; + return; + } + final int crepitousDrain = 1; + final int terraeDrain = 5; + final int magicalesDrain = 10; + + boolean flag = false; + boolean hasCrepitous = this + .canDrainReagent(ritualStone, ReagentRegistry.crepitousReagent, crepitousDrain, false); + boolean hasTerrae = this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, false); + boolean hasMagicales = this + .canDrainReagent(ritualStone, ReagentRegistry.magicalesReagent, magicalesDrain, false); + int d0 = hasTerrae ? 10 : 5; + List entityList = SpellHelper.getEntitiesInRange(world, x + 0.5, y + 0.5, z + 0.5, d0, d0); + + for (Entity entity : entityList) { + if (!(entity instanceof EntityLivingBase livingEntity)) { + continue; + } - if (livingEntity instanceof EntityPlayer) { - continue; - } + if (livingEntity instanceof EntityPlayer) { + continue; + } - double xDif = livingEntity.posX - (x + 0.5); - double yDif = livingEntity.posY - (y + 3); - double zDif = livingEntity.posZ - (z + 0.5); - livingEntity.motionX = -0.05 * xDif; - livingEntity.motionY = -0.05 * yDif; - livingEntity.motionZ = -0.05 * zDif; - flag = true; - - livingEntity.fallDistance = 0; - - if (hasMagicales - && this.canDrainReagent(ritualStone, ReagentRegistry.magicalesReagent, magicalesDrain, false)) { - if (!livingEntity.isPotionActive(AlchemicalWizardry.customPotionPlanarBinding)) { - livingEntity.addPotionEffect( - new PotionEffect(AlchemicalWizardry.customPotionPlanarBinding.id, 100, 0)); - this.canDrainReagent(ritualStone, ReagentRegistry.magicalesReagent, magicalesDrain, true); - } + double xDif = livingEntity.posX - (x + 0.5); + double yDif = livingEntity.posY - (y + 3); + double zDif = livingEntity.posZ - (z + 0.5); + livingEntity.motionX = -0.05 * xDif; + livingEntity.motionY = -0.05 * yDif; + livingEntity.motionZ = -0.05 * zDif; + flag = true; + + livingEntity.fallDistance = 0; + + if (hasMagicales + && this.canDrainReagent(ritualStone, ReagentRegistry.magicalesReagent, magicalesDrain, false)) { + if (!livingEntity.isPotionActive(AlchemicalWizardry.customPotionPlanarBinding)) { + livingEntity + .addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionPlanarBinding.id, 100, 0)); + this.canDrainReagent(ritualStone, ReagentRegistry.magicalesReagent, magicalesDrain, true); } + } - if (hasCrepitous - && this.canDrainReagent(ritualStone, ReagentRegistry.crepitousReagent, crepitousDrain, false)) { - if (entity instanceof EntityCreeper) { - ReflectionHelper - .setPrivateValue(EntityCreeper.class, (EntityCreeper) entity, 2, TIME_SINCE_IGNITED); - ((EntityCreeper) entity).setAttackTarget(null); - this.canDrainReagent(ritualStone, ReagentRegistry.crepitousReagent, crepitousDrain, true); - } + if (hasCrepitous + && this.canDrainReagent(ritualStone, ReagentRegistry.crepitousReagent, crepitousDrain, false)) { + if (entity instanceof EntityCreeper) { + ReflectionHelper + .setPrivateValue(EntityCreeper.class, (EntityCreeper) entity, 2, TIME_SINCE_IGNITED); + ((EntityCreeper) entity).setAttackTarget(null); + this.canDrainReagent(ritualStone, ReagentRegistry.crepitousReagent, crepitousDrain, true); } } + } - if (world.getTotalWorldTime() % 2 == 0 && flag) { - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); - } + if (world.getTotalWorldTime() % 2 == 0 && flag) { + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectCrafting.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectCrafting.java index 792909a9d1..b7cd608a61 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectCrafting.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectCrafting.java @@ -17,7 +17,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.oredict.OreDictionary; import WayofTime.alchemicalWizardry.AlchemicalWizardry; import WayofTime.alchemicalWizardry.api.Int3; @@ -54,287 +53,268 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh()) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - NBTTagCompound tag = ritualStone.getCustomRitualTag(); + return; + } + NBTTagCompound tag = ritualStone.getCustomRitualTag(); - if (tag == null) { - ritualStone.setCustomRitualTag(new NBTTagCompound()); - tag = ritualStone.getCustomRitualTag(); - } + if (tag == null) { + ritualStone.setCustomRitualTag(new NBTTagCompound()); + tag = ritualStone.getCustomRitualTag(); + } - boolean lastFailed = tag.getBoolean("didLastCraftFail"); + boolean lastFailed = tag.getBoolean("didLastCraftFail"); - int slotDesignation = tag.getInteger("slotDesignation"); - if (lastFailed) { - slotDesignation++; - tag.setInteger("slotDesignation", slotDesignation); - tag.setBoolean("didLastCraftFail", false); - } - int direction = ritualStone.getDirection(); + int slotDesignation = tag.getInteger("slotDesignation"); + if (lastFailed) { + slotDesignation++; + tag.setInteger("slotDesignation", slotDesignation); + tag.setBoolean("didLastCraftFail", false); + } + int direction = ritualStone.getDirection(); - boolean canContinue = false; + boolean canContinue = false; - ItemStack[] recipe = new ItemStack[9]; - InventoryCrafting inventory = new InventoryCrafting(new Container() { + ItemStack[] recipe = new ItemStack[9]; + InventoryCrafting inventory = new InventoryCrafting(new Container() { - public boolean canInteractWith(EntityPlayer player) { - return false; - } - }, 3, 3); - - for (int i = -1; i <= 1; i++) { - for (int j = -1; j <= 1; j++) { - int gridSpace = (i + 1) * 3 + (j + 1); - - Int3 pos = this.getSlotPositionForDirection(gridSpace, direction); - TileEntity inv = world.getTileEntity(x + pos.xCoord, y + pos.yCoord, z + pos.zCoord); - if (inv instanceof IInventory) { - if (((IInventory) inv).getSizeInventory() <= slotDesignation - || !((IInventory) inv).isItemValidForSlot( - slotDesignation, - ((IInventory) inv).getStackInSlot(slotDesignation))) { - continue; - } else { - ItemStack invStack = ((IInventory) inv).getStackInSlot(slotDesignation); - if (invStack != null) { - inventory.setInventorySlotContents(gridSpace, invStack); - recipe[gridSpace] = invStack; - canContinue = true; - } - } + @Override + public boolean canInteractWith(EntityPlayer player) { + return false; + } + }, 3, 3); + + for (int i = -1; i <= 1; i++) { + for (int j = -1; j <= 1; j++) { + int gridSpace = (i + 1) * 3 + (j + 1); + + Int3 pos = this.getSlotPositionForDirection(gridSpace, direction); + TileEntity inv = world.getTileEntity(x + pos.x(), y + pos.y(), z + pos.z()); + if (inv instanceof IInventory iInventory) { + if (iInventory.getSizeInventory() <= slotDesignation || !iInventory + .isItemValidForSlot(slotDesignation, iInventory.getStackInSlot(slotDesignation))) { + continue; + } + ItemStack invStack = iInventory.getStackInSlot(slotDesignation); + if (invStack != null) { + inventory.setInventorySlotContents(gridSpace, invStack); + recipe[gridSpace] = invStack; + canContinue = true; } } } + } - if (!canContinue) { - tag.setInteger("slotDesignation", 0); - return; - } - - ItemStack returnStack = CraftingManager.getInstance().findMatchingRecipe(inventory, world); - - if (returnStack == null) { - tag.setBoolean("didLastCraftFail", true); - } else { - boolean hasVirtus = this - .canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false); - boolean addOutputToInputs = hasVirtus; - - IInventory outputInv = null; - - List invList = new ArrayList(); - - TileEntity northEntity = world.getTileEntity(x, y - 1, z - 2); - TileEntity southEntity = world.getTileEntity(x, y - 1, z + 2); - TileEntity eastEntity = world.getTileEntity(x + 2, y - 1, z); - TileEntity westEntity = world.getTileEntity(x - 2, y - 1, z); + if (!canContinue) { + tag.setInteger("slotDesignation", 0); + return; + } - switch (direction) { - case 1: - if (southEntity instanceof IInventory) { - outputInv = (IInventory) southEntity; - } else { - return; - } + ItemStack returnStack = CraftingManager.getInstance().findMatchingRecipe(inventory, world); - if (northEntity instanceof IInventory) { - invList.add((IInventory) northEntity); - } - if (eastEntity instanceof IInventory) { - invList.add((IInventory) eastEntity); - } - if (westEntity instanceof IInventory) { - invList.add((IInventory) westEntity); - } + if (returnStack == null) { + tag.setBoolean("didLastCraftFail", true); + } else { - break; + IInventory outputInv = null; - case 2: - if (westEntity instanceof IInventory) { - outputInv = (IInventory) westEntity; - } else { - return; - } + List invList = new ArrayList<>(); - if (northEntity instanceof IInventory) { - invList.add((IInventory) northEntity); - } - if (eastEntity instanceof IInventory) { - invList.add((IInventory) eastEntity); - } - if (southEntity instanceof IInventory) { - invList.add((IInventory) southEntity); - } + TileEntity northEntity = world.getTileEntity(x, y - 1, z - 2); + TileEntity southEntity = world.getTileEntity(x, y - 1, z + 2); + TileEntity eastEntity = world.getTileEntity(x + 2, y - 1, z); + TileEntity westEntity = world.getTileEntity(x - 2, y - 1, z); - break; + switch (direction) { + case 1 -> { + if (southEntity instanceof IInventory out) { + outputInv = out; + } else { + return; + } - case 3: - if (northEntity instanceof IInventory) { - outputInv = (IInventory) northEntity; - } else { - return; - } + if (northEntity instanceof IInventory inv) { + invList.add(inv); + } + if (eastEntity instanceof IInventory inv) { + invList.add(inv); + } + if (westEntity instanceof IInventory inv) { + invList.add(inv); + } + } + case 2 -> { + if (westEntity instanceof IInventory out) { + outputInv = out; + } else { + return; + } - if (eastEntity instanceof IInventory) { - invList.add((IInventory) eastEntity); - } - if (southEntity instanceof IInventory) { - invList.add((IInventory) southEntity); - } - if (westEntity instanceof IInventory) { - invList.add((IInventory) westEntity); - } + if (northEntity instanceof IInventory inv) { + invList.add(inv); + } + if (eastEntity instanceof IInventory inv) { + invList.add(inv); + } + if (southEntity instanceof IInventory inv) { + invList.add(inv); + } + } + case 3 -> { + if (northEntity instanceof IInventory out) { + outputInv = out; + } else { + return; + } - break; + if (eastEntity instanceof IInventory inv) { + invList.add(inv); + } + if (southEntity instanceof IInventory inv) { + invList.add(inv); + } + if (westEntity instanceof IInventory inv) { + invList.add(inv); + } + } + case 4 -> { + if (eastEntity instanceof IInventory out) { + outputInv = out; + } else { + return; + } - case 4: - if (eastEntity instanceof IInventory) { - outputInv = (IInventory) eastEntity; - } else { - return; - } + if (northEntity instanceof IInventory inv) { + invList.add(inv); + } + if (southEntity instanceof IInventory inv) { + invList.add(inv); + } + if (westEntity instanceof IInventory inv) { + invList.add(inv); + } + } + } - if (northEntity instanceof IInventory) { - invList.add((IInventory) northEntity); - } - if (southEntity instanceof IInventory) { - invList.add((IInventory) southEntity); - } - if (westEntity instanceof IInventory) { - invList.add((IInventory) westEntity); - } + if (outputInv != null) { + if (!(!limitToSingleStack + ? SpellHelper.canInsertStackFullyIntoInventory(returnStack, outputInv, ForgeDirection.DOWN) + : SpellHelper.canInsertStackFullyIntoInventory( + returnStack, + outputInv, + ForgeDirection.DOWN, + true, + returnStack.getMaxStackSize()))) { + tag.setBoolean("didLastCraftFail", true); + return; + } - break; + if (this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false)) { + invList.add(outputInv); } - if (outputInv != null) { - if (!(!limitToSingleStack - ? SpellHelper.canInsertStackFullyIntoInventory(returnStack, outputInv, ForgeDirection.DOWN) - : SpellHelper.canInsertStackFullyIntoInventory( - returnStack, - outputInv, - ForgeDirection.DOWN, - true, - returnStack.getMaxStackSize()))) { - tag.setBoolean("didLastCraftFail", true); - return; - } + Map> syphonMap = new HashMap<>(); // Inventory, Slot, how much + // claimed - if (addOutputToInputs) { - invList.add(outputInv); + for (int n = 0; n < recipe.length; n++) // Look for the correct items + { + ItemStack recipeStack = recipe[n]; + if (recipeStack == null) { + continue; } - Map> syphonMap = new HashMap(); // Inventory, Slot, how much claimed + boolean isItemTaken = false; - for (int n = 0; n < recipe.length; n++) // Look for the correct items - { - ItemStack recipeStack = recipe[n]; - if (recipeStack == null) { + for (int i = 0; i < invList.size(); i++) { + if (isItemTaken) { + break; + } + IInventory inputInv = invList.get(i); + if (inputInv == null) { continue; } - boolean isItemTaken = false; - - for (int i = 0; i < invList.size(); i++) { - if (isItemTaken) { - break; - } - IInventory inputInv = invList.get(i); - if (inputInv == null) { + for (int j = 0; j < inputInv.getSizeInventory(); j++) { + if (!inputInv.isItemValidForSlot(j, recipeStack)) { continue; } - for (int j = 0; j < inputInv.getSizeInventory(); j++) { - if (!inputInv.isItemValidForSlot(j, recipeStack)) { - continue; - } - - ItemStack invItem = inputInv.getStackInSlot(j); - if (invItem == null) { - continue; - } - - if (this.areItemsEqualForCrafting(recipeStack, invItem)) { - // TODO - inventory.setInventorySlotContents(n, invItem); - // ItemStack returnedStack = - // CraftingManager.getInstance().findMatchingRecipe(inventory, world); - // if(returnedStack == null || returnedStack.getItem() == null - // || returnedStack.getItem() != returnStack.getItem()) - // { - // continue; - // } - Map slotMap = syphonMap.get(i); - if (slotMap == null) { - slotMap = new HashMap(); - syphonMap.put(i, slotMap); - } + ItemStack invItem = inputInv.getStackInSlot(j); + if (invItem == null) { + continue; + } - if (slotMap.containsKey(j)) { - int syphoned = slotMap.get(j); - if (invItem.stackSize - syphoned > 0) { - slotMap.put(j, syphoned + 1); - isItemTaken = true; - break; - } - } else { - slotMap.put(j, 1); + if (this.areItemsEqualForCrafting(recipeStack, invItem)) { + // TODO + inventory.setInventorySlotContents(n, invItem); + // ItemStack returnedStack = + // CraftingManager.getInstance().findMatchingRecipe(inventory, world); + // if(returnedStack == null || returnedStack.getItem() == null + // || returnedStack.getItem() != returnStack.getItem()) + // { + // continue; + // } + Map slotMap = syphonMap.computeIfAbsent(i, k -> new HashMap<>()); + + if (slotMap.containsKey(j)) { + int syphoned = slotMap.get(j); + if (invItem.stackSize - syphoned > 0) { + slotMap.put(j, syphoned + 1); isItemTaken = true; break; } + } else { + slotMap.put(j, 1); + isItemTaken = true; + break; } } } - - if (!isItemTaken) { - tag.setBoolean("didLastCraftFail", true); - return; - } } - /* The recipe is valid and the items have been found */ - - SpellHelper.insertStackIntoInventory( - CraftingManager.getInstance().findMatchingRecipe(inventory, world), - outputInv, - ForgeDirection.DOWN); - - for (Entry> entry1 : syphonMap.entrySet()) { - IInventory inputInv = invList.get(entry1.getKey()); - for (Entry entry2 : entry1.getValue().entrySet()) { - ItemStack drainedStack = inputInv.getStackInSlot(entry2.getKey()); - Item item = drainedStack.getItem(); - if (item.hasContainerItem(drainedStack)) { - inputInv.setInventorySlotContents(entry2.getKey(), item.getContainerItem(drainedStack)); - } else { - drainedStack.stackSize -= entry2.getValue(); - if (drainedStack.stackSize <= 0) { - inputInv.setInventorySlotContents(entry2.getKey(), null); - } - } - } + if (!isItemTaken) { + tag.setBoolean("didLastCraftFail", true); + return; } + } - if (addOutputToInputs && syphonMap.containsKey(invList.size())) { - this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, true); - } + /* The recipe is valid and the items have been found */ - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); + SpellHelper.insertStackIntoInventory( + CraftingManager.getInstance().findMatchingRecipe(inventory, world), + outputInv, + ForgeDirection.DOWN); - if (hasPotentia) { - this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, true); + for (Entry> entry1 : syphonMap.entrySet()) { + IInventory inputInv = invList.get(entry1.getKey()); + for (Entry entry2 : entry1.getValue().entrySet()) { + ItemStack drainedStack = inputInv.getStackInSlot(entry2.getKey()); + Item item = drainedStack.getItem(); + if (item.hasContainerItem(drainedStack)) { + inputInv.setInventorySlotContents(entry2.getKey(), item.getContainerItem(drainedStack)); + } else { + drainedStack.stackSize -= entry2.getValue(); + if (drainedStack.stackSize <= 0) { + inputInv.setInventorySlotContents(entry2.getKey(), null); + } + } } + } - world.markBlockForUpdate(x, y - 1, z + 2); - world.markBlockForUpdate(x, y - 1, z - 2); - world.markBlockForUpdate(x + 2, y - 1, z); - world.markBlockForUpdate(x - 2, y - 1, z); + if (this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false) + && syphonMap.containsKey(invList.size())) { + this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, true); + } + + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); - // long endTime = System.nanoTime(); - // - // long duration = (endTime - startTime); //divide by 1000000 to get milliseconds. - // System.out.println("(Total) method time in ms: " + (float)(duration)/1000000.0); + if (hasPotentia) { + this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, true); } + + world.markBlockForUpdate(x, y - 1, z + 2); + world.markBlockForUpdate(x, y - 1, z - 2); + world.markBlockForUpdate(x + 2, y - 1, z); + world.markBlockForUpdate(x - 2, y - 1, z); } } } @@ -346,7 +326,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList autoCraftingRitual = new ArrayList(); + ArrayList autoCraftingRitual = new ArrayList<>(); this.addCornerRunes(autoCraftingRitual, 1, 1, RitualComponent.EARTH); this.addParallelRunes(autoCraftingRitual, 1, 1, RitualComponent.EARTH); @@ -366,34 +346,20 @@ public boolean areItemsEqualForCrafting(ItemStack stack1, ItemStack stack2) { if (stack1 == null || stack2 == null) { return false; } - // - // if (stack1.isItemStackDamageable() ^ stack2.isItemStackDamageable()) - // { - // return false; - // } return stack1.getItem() == stack2.getItem() && !stack1.getItem().getHasSubtypes() || stack1.getItemDamage() == stack2.getItemDamage(); } - public boolean areItemStacksEqualWithWildcard(ItemStack recipeStack, ItemStack comparedStack) { - return recipeStack.isItemEqual(comparedStack) || (recipeStack.getItemDamage() == OreDictionary.WILDCARD_VALUE - && recipeStack.getItem() == comparedStack.getItem()); - } - public Int3 getSlotPositionForDirection(int slot, int direction) { int x = slot % 3 - 1; int z = slot / 3 - 1; - switch (direction) { - case 1: // NORTH-facing - return new Int3(x, 2, z); - case 2: // EAST-facing - return new Int3(z, 2, -x); - case 3: // SOUTH-facing - return new Int3(-x, 2, -z); - case 4: // WEST-facing - return new Int3(-z, 2, x); - } - return new Int3(0, 0, 0); + return switch (direction) { + case 1 -> new Int3(x, 2, z); // NORTH-facing + case 2 -> new Int3(z, 2, -x); // EAST-facing + case 3 -> new Int3(-x, 2, -z); // SOUTH-facing + case 4 -> new Int3(-z, 2, x); // WEST-facing + default -> new Int3(0, 0, 0); + }; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectCrushing.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectCrushing.java index 34d0cb39cc..7d7d45dfeb 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectCrushing.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectCrushing.java @@ -48,8 +48,8 @@ public void performEffect(IMasterRitualStone ritualStone) { TileEntity tile = world.getTileEntity(x, y + 1, z); IInventory tileEntity; - if (tile instanceof IInventory) { - tileEntity = (IInventory) tile; + if (tile instanceof IInventory inv) { + tileEntity = inv; } else { return; } @@ -79,7 +79,6 @@ public void performEffect(IMasterRitualStone ritualStone) { boolean hasIncendium = this .canDrainReagent(ritualStone, ReagentRegistry.incendiumReagent, incendiumDrain, false); - boolean isSilkTouch = hasCrystallos; int fortuneLevel = 0; if (hasOrbisTerrae) { fortuneLevel++; @@ -93,101 +92,88 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh()) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - for (int j = -3; j < 0; j++) { - for (int i = -1; i <= 1; i++) { - for (int k = -1; k <= 1; k++) { - Block block = world.getBlock(x + i, y + j, z + k); - int meta = world.getBlockMetadata(x + i, y + j, z + k); - if (block.getBlockHardness(world, x + i, y + j, z + k) == -1) { + return; + } + for (int j = -3; j < 0; j++) { + for (int i = -1; i <= 1; i++) { + for (int k = -1; k <= 1; k++) { + Block block = world.getBlock(x + i, y + j, z + k); + int meta = world.getBlockMetadata(x + i, y + j, z + k); + if (block.getBlockHardness(world, x + i, y + j, z + k) == -1) { + continue; + } + + if (!world.isAirBlock(x + i, y + j, z + k)) { + if ((block.equals(ModBlocks.ritualStone) || block.equals(ModBlocks.blockMasterStone)) + || SpellHelper.isBlockFluid(block)) { continue; } - if (block != null && !world.isAirBlock(x + i, y + j, z + k)) { - if ((block.equals(ModBlocks.ritualStone) || block.equals(ModBlocks.blockMasterStone)) - || SpellHelper.isBlockFluid(block)) { - continue; - } + if (hasCrystallos && block.canSilkHarvest(world, null, x + i, y + j, z + k, meta)) { + ItemStack item = new ItemStack(block, 1, meta); + ItemStack copyStack = ItemStack.copyItemStack(item); - if (isSilkTouch && block.canSilkHarvest(world, null, x + i, y + j, z + k, meta)) { - ItemStack item = new ItemStack(block, 1, meta); - ItemStack copyStack = item.copyItemStack(item); + SpellHelper.insertStackIntoInventory(copyStack, tileEntity, ForgeDirection.DOWN); - SpellHelper.insertStackIntoInventory(copyStack, tileEntity, ForgeDirection.DOWN); + if (copyStack.stackSize > 0) { + world.spawnEntityInWorld(new EntityItem(world, x + 0.4, y + 2, z + 0.5, copyStack)); + } - if (copyStack.stackSize > 0) { - world.spawnEntityInWorld(new EntityItem(world, x + 0.4, y + 2, z + 0.5, copyStack)); - } + this.canDrainReagent(ritualStone, ReagentRegistry.crystallosReagent, crystallosDrain, true); + } else { + ArrayList itemDropList = block + .getDrops(world, x + i, y + j, z + k, meta, fortuneLevel); - if (hasCrystallos) { - this.canDrainReagent( + if (itemDropList != null) { + for (ItemStack item : itemDropList) { + hasIncendium = hasIncendium && this.canDrainReagent( ritualStone, - ReagentRegistry.crystallosReagent, - crystallosDrain, - true); - } - } else { - ArrayList itemDropList = block - .getDrops(world, x + i, y + j, z + k, meta, fortuneLevel); + ReagentRegistry.incendiumReagent, + incendiumDrain, + false); + ItemStack copyStack = ItemStack.copyItemStack(item); - if (itemDropList != null) { - int invSize = tileEntity.getSizeInventory(); - - for (ItemStack item : itemDropList) { - hasIncendium = hasIncendium && this.canDrainReagent( + if (this.usesIncendium(copyStack)) { + copyStack = this.transformToNewItem(copyStack, hasIncendium, false); + this.canDrainReagent( ritualStone, ReagentRegistry.incendiumReagent, incendiumDrain, - false); - ItemStack copyStack = item.copyItemStack(item); - - if (this.usesIncendium(copyStack)) { - copyStack = this.transformToNewItem(copyStack, hasIncendium, false); - this.canDrainReagent( - ritualStone, - ReagentRegistry.incendiumReagent, - incendiumDrain, - true); - } - - SpellHelper - .insertStackIntoInventory(copyStack, tileEntity, ForgeDirection.DOWN); - if (copyStack.stackSize > 0) { - world.spawnEntityInWorld( - new EntityItem(world, x + 0.4, y + 2, z + 0.5, copyStack)); - } - } - - if (hasOrbisTerrae) { - this.canDrainReagent( - ritualStone, - ReagentRegistry.orbisTerraeReagent, - orbisTerraeDrain, - true); - } - if (hasPotentia) { - this.canDrainReagent( - ritualStone, - ReagentRegistry.potentiaReagent, - potentiaDrain, true); } - if (hasVirtus) { - this.canDrainReagent( - ritualStone, - ReagentRegistry.virtusReagent, - virtusDrain, - true); + + SpellHelper.insertStackIntoInventory(copyStack, tileEntity, ForgeDirection.DOWN); + if (copyStack.stackSize > 0) { + world.spawnEntityInWorld( + new EntityItem(world, x + 0.4, y + 2, z + 0.5, copyStack)); } } + + if (hasOrbisTerrae) { + this.canDrainReagent( + ritualStone, + ReagentRegistry.orbisTerraeReagent, + orbisTerraeDrain, + true); + } + if (hasPotentia) { + this.canDrainReagent( + ritualStone, + ReagentRegistry.potentiaReagent, + potentiaDrain, + true); + } + if (hasVirtus) { + this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, true); + } } - world.setBlockToAir(x + i, y + j, z + k); - world.playSoundEffect(x + i, y + j, z + k, "mob.endermen.portal", 1.0F, 1.0F); + } + world.setBlockToAir(x + i, y + j, z + k); + world.playSoundEffect(x + i, y + j, z + k, "mob.endermen.portal", 1.0F, 1.0F); - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); - return; - } + return; } } } @@ -197,14 +183,10 @@ public void performEffect(IMasterRitualStone ritualStone) { private boolean usesIncendium(ItemStack stack) { if (stack != null) { Item item = stack.getItem(); - if (item instanceof ItemBlock) { - Block block = ((ItemBlock) item).field_150939_a; - - if (block == Blocks.cobblestone || block == Blocks.stone) { - return true; - } - } else { + if (item instanceof ItemBlock itemBlock) { + Block block = itemBlock.field_150939_a; + return block == Blocks.cobblestone || block == Blocks.stone; } } return false; @@ -224,8 +206,6 @@ private ItemStack transformToNewItem(ItemStack stack, boolean hasIncendium, bool copyStack = new ItemStack(Blocks.netherrack, stackSize, 0); } } - } else { - } return copyStack; @@ -286,7 +266,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList crushingRitual = new ArrayList(); + ArrayList crushingRitual = new ArrayList<>(); crushingRitual.add(new RitualComponent(0, 0, 1, RitualComponent.EARTH)); crushingRitual.add(new RitualComponent(1, 0, 0, RitualComponent.EARTH)); crushingRitual.add(new RitualComponent(0, 0, -1, RitualComponent.EARTH)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectDemonPortal.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectDemonPortal.java index 723abd5b73..e1a3d8f4bd 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectDemonPortal.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectDemonPortal.java @@ -48,61 +48,54 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh()) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - NBTTagCompound tag = ritualStone.getCustomRitualTag(); - - boolean reagentsFulfilled = true; + return; + } + NBTTagCompound tag = ritualStone.getCustomRitualTag(); - for (Reagent reagent : reagents) { - int reagentAmount = tag.getInteger(ReagentRegistry.getKeyForReagent(reagent)); - if (reagentAmount < neededAmount) { - reagentsFulfilled = false; - // System.out.println("Reagents not fulfilled. Missing: " + - // ReagentRegistry.getKeyForReagent(reagent)); - int drainAmount = Math.min(drainRate, neededAmount - reagentAmount); + boolean reagentsFulfilled = true; - if (drainAmount <= 0) { - continue; - } + for (Reagent reagent : reagents) { + int reagentAmount = tag.getInteger(ReagentRegistry.getKeyForReagent(reagent)); + if (reagentAmount < neededAmount) { + reagentsFulfilled = false; + int drainAmount = Math.min(drainRate, neededAmount - reagentAmount); - if (this.canDrainReagent(ritualStone, reagent, drainAmount, true)) { - if (rand.nextInt(10) == 0) { - this.createRandomLightning(world, x, y, z); - } - reagentAmount += drainAmount; + if (drainAmount <= 0) { + continue; + } - tag.setInteger(ReagentRegistry.getKeyForReagent(reagent), reagentAmount); - break; + if (this.canDrainReagent(ritualStone, reagent, drainAmount, true)) { + if (rand.nextInt(10) == 0) { + this.createRandomLightning(world, x, y, z); } + reagentAmount += drainAmount; + + tag.setInteger(ReagentRegistry.getKeyForReagent(reagent), reagentAmount); + break; } } + } - ritualStone.setCustomRitualTag(tag); - - if (reagentsFulfilled && checkCreatePortal(ritualStone)) { - world.setBlock(x, y + 1, z, ModBlocks.blockDemonPortal); + ritualStone.setCustomRitualTag(tag); - TEDemonPortal portal = (TEDemonPortal) world.getTileEntity(x, y + 1, z); - portal.start(); + if (reagentsFulfilled && checkCreatePortal(ritualStone)) { + world.setBlock(x, y + 1, z, ModBlocks.blockDemonPortal); - ritualStone.setActive(false); - } + TEDemonPortal portal = (TEDemonPortal) world.getTileEntity(x, y + 1, z); + portal.start(); - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); + ritualStone.setActive(false); } + + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); } public boolean checkCreatePortal(IMasterRitualStone ritualStone) { TileEntity entity = ritualStone.getWorld() .getTileEntity(ritualStone.getXCoord(), ritualStone.getYCoord() + 1, ritualStone.getZCoord()); - if (entity instanceof IBloodAltar) { - IBloodAltar altar = (IBloodAltar) entity; - if (altar.hasDemonBlood() && ritualStone.getWorld() - .isAirBlock(ritualStone.getXCoord(), ritualStone.getYCoord() + 2, ritualStone.getZCoord())) { - return true; - } - } - return false; + return entity instanceof IBloodAltar altar && altar.hasDemonBlood() + && ritualStone.getWorld() + .isAirBlock(ritualStone.getXCoord(), ritualStone.getYCoord() + 2, ritualStone.getZCoord()); } @Override @@ -138,8 +131,7 @@ public boolean checkJars(IMasterRitualStone ritualStone) { int z = ritualStone.getZCoord(); for (Int3 pos : jarLocations) { - if (!(ritualStone.getWorld() - .getTileEntity(x + pos.xCoord, y + pos.yCoord, z + pos.zCoord) instanceof TEBellJar)) { + if (!(ritualStone.getWorld().getTileEntity(x + pos.x(), y + pos.y(), z + pos.z()) instanceof TEBellJar)) { return false; } } @@ -149,7 +141,7 @@ public boolean checkJars(IMasterRitualStone ritualStone) { @Override public List getRitualComponentList() { - ArrayList demonRitual = new ArrayList(); + ArrayList demonRitual = new ArrayList<>(); this.addParallelRunes(demonRitual, 3, 0, RitualComponent.FIRE); this.addParallelRunes(demonRitual, 5, 0, RitualComponent.FIRE); this.addCornerRunes(demonRitual, 2, 0, RitualComponent.AIR); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectEllipsoid.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectEllipsoid.java index 1c67698794..8526f913a6 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectEllipsoid.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectEllipsoid.java @@ -4,13 +4,10 @@ import java.util.List; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -20,7 +17,6 @@ import WayofTime.alchemicalWizardry.api.rituals.RitualComponent; import WayofTime.alchemicalWizardry.api.rituals.RitualEffect; import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class RitualEffectEllipsoid extends RitualEffect { @@ -36,13 +32,13 @@ public void performEffect(IMasterRitualStone ritualStone) { TileEntity tile = world.getTileEntity(x, y + 1, z); - if (!(tile instanceof IInventory) || ((IInventory) tile).getSizeInventory() < 3) { + if (!(tile instanceof IInventory above) || above.getSizeInventory() < 3) { return; } - ItemStack item1 = ((IInventory) tile).getStackInSlot(0); - ItemStack item2 = ((IInventory) tile).getStackInSlot(1); - ItemStack item3 = ((IInventory) tile).getStackInSlot(2); + ItemStack item1 = above.getStackInSlot(0); + ItemStack item2 = above.getStackInSlot(1); + ItemStack item3 = above.getStackInSlot(2); int xSize = item1 == null ? 0 : item1.stackSize; int ySize = item2 == null ? 0 : item2.stackSize; @@ -51,135 +47,124 @@ public void performEffect(IMasterRitualStone ritualStone) { int cost = 5; if (currentEssence < cost) { - EntityPlayer entityOwner = SpellHelper.getPlayerForUsername(owner); + SoulNetworkHandler.causeNauseaToPlayer(owner); + return; + } + tile = world.getTileEntity(x, y - 1, z); + if (!(tile instanceof IInventory below)) { + return; + } - if (entityOwner == null) { - return; - } + ItemBlock placedBlock = null; + ItemStack stack = null; + int slot = 0; - entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80)); - } else { - tile = world.getTileEntity(x, y - 1, z); - if (!(tile instanceof IInventory)) { - return; + while (slot < below.getSizeInventory()) { + stack = below.getStackInSlot(slot); + if (stack == null) { + slot++; + continue; } - ItemBlock placedBlock = null; - ItemStack stack = null; - int slot = 0; - IInventory inv = (IInventory) tile; + if (stack.getItem() instanceof ItemBlock) { + placedBlock = (ItemBlock) stack.getItem(); + break; + } - while (slot < inv.getSizeInventory()) { - stack = inv.getStackInSlot(slot); - if (stack == null) { - slot++; - continue; - } + slot++; + } - if (stack.getItem() instanceof ItemBlock) { - placedBlock = (ItemBlock) stack.getItem(); - break; - } + if (placedBlock == null || slot >= below.getSizeInventory()) { + return; + } - slot++; - } + int count = 10; - if (placedBlock == null || stack == null || slot >= inv.getSizeInventory()) { - return; - } + Int3 lastPos = this.getLastPosition(ritualStone.getCustomRitualTag()); - int count = 10; + int i = -xSize; + int j = -ySize; + int k = -zSize; - Int3 lastPos = this.getLastPosition(ritualStone.getCustomRitualTag()); + if (lastPos != null) { + i = Math.min(xSize, Math.max(-xSize, lastPos.x())); + j = Math.min(ySize, Math.max(-ySize, lastPos.y())); + k = Math.min(zSize, Math.max(-zSize, lastPos.z())); + } - int i = -xSize; - int j = -ySize; - int k = -zSize; + boolean incrementNext = false; - if (lastPos != null) { - i = Math.min(xSize, Math.max(-xSize, lastPos.xCoord)); - j = Math.min(ySize, Math.max(-ySize, lastPos.yCoord)); - k = Math.min(zSize, Math.max(-zSize, lastPos.zCoord)); + while (j <= ySize) { + if (y + j < 0) { + j++; + continue; } + while (i <= xSize) { + while (k <= zSize) { + if (Math.pow(i * (ySize - 0.50f) * (zSize - 0.50f), 2) + + Math.pow(j * (xSize - 0.50f) * (zSize - 0.50f), 2) + + Math.pow(k * (xSize - 0.50f) * (ySize - 0.50f), 2) + <= Math.pow((xSize - 1 + 0.50f) * (ySize - 1 + 0.50f) * (zSize - 1 + 0.50f), 2)) { + k++; + continue; + } - boolean incrementNext = false; + if (Math.pow(i * (ySize + 0.50f) * (zSize + 0.50f), 2) + + Math.pow(j * (xSize + 0.50f) * (zSize + 0.50f), 2) + + Math.pow(k * (xSize + 0.50f) * (ySize + 0.50f), 2) + >= Math.pow((xSize + 0.50f) * (ySize + 0.50f) * (zSize + 0.50f), 2)) { + k++; + continue; + } - while (j <= ySize) { - if (y + j < 0) { - j++; - continue; - } - while (i <= xSize) { - while (k <= zSize) { - if (Math.pow(i * (ySize - 0.50f) * (zSize - 0.50f), 2) - + Math.pow(j * (xSize - 0.50f) * (zSize - 0.50f), 2) - + Math.pow(k * (xSize - 0.50f) * (ySize - 0.50f), 2) - <= Math.pow((xSize - 1 + 0.50f) * (ySize - 1 + 0.50f) * (zSize - 1 + 0.50f), 2)) { - k++; - continue; - } + if (incrementNext || count <= 0) { + this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(i, j, k)); + return; + } - if (Math.pow(i * (ySize + 0.50f) * (zSize + 0.50f), 2) - + Math.pow(j * (xSize + 0.50f) * (zSize + 0.50f), 2) - + Math.pow(k * (xSize + 0.50f) * (ySize + 0.50f), 2) - >= Math.pow((xSize + 0.50f) * (ySize + 0.50f) * (zSize + 0.50f), 2)) { - k++; - continue; - } + count--; - if (incrementNext || count <= 0) { - this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(i, j, k)); - return; - } + Block block = world.getBlock(x + i, y + j, z + k); - count--; - - Block block = world.getBlock(x + i, y + j, z + k); - - if (!block.isAir(world, x + i, y + j, z + k)) { - k++; - continue; - } else { - // This is pulled from the ItemBlock's placing calls - int i1 = placedBlock.getMetadata(stack.getItemDamage()); - int j1 = placedBlock.field_150939_a - .onBlockPlaced(world, x + i, y + j, z + k, 0, 0, 0, 0, i1); - - if (placedBlock.placeBlockAt(stack, null, world, x + i, y + j, z + k, 0, 0, 0, 0, j1)) { - world.playSoundEffect( - (double) (x + i + 0.5F), - (double) (y + j + 0.5F), - (double) (z + k + 0.5F), - placedBlock.field_150939_a.stepSound.func_150496_b(), - (placedBlock.field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F, - placedBlock.field_150939_a.stepSound.getPitch() * 0.8F); - --stack.stackSize; - if (stack.stackSize <= 0) { - inv.setInventorySlotContents(slot, null); - } - - this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(i, j, k)); - - incrementNext = true; - SoulNetworkHandler.syphonFromNetwork(owner, cost); - } - - // world.setBlock(x + i, y + j, z + k, Blocks.stone); - - k++; + if (!block.isAir(world, x + i, y + j, z + k)) { + k++; + continue; + } + // This is pulled from the ItemBlock's placing calls + int i1 = placedBlock.getMetadata(stack.getItemDamage()); + int j1 = placedBlock.field_150939_a.onBlockPlaced(world, x + i, y + j, z + k, 0, 0, 0, 0, i1); + + if (placedBlock.placeBlockAt(stack, null, world, x + i, y + j, z + k, 0, 0, 0, 0, j1)) { + world.playSoundEffect( + x + i + 0.5F, + y + j + 0.5F, + z + k + 0.5F, + placedBlock.field_150939_a.stepSound.func_150496_b(), + (placedBlock.field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F, + placedBlock.field_150939_a.stepSound.getPitch() * 0.8F); + --stack.stackSize; + if (stack.stackSize <= 0) { + below.setInventorySlotContents(slot, null); } + + this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(i, j, k)); + + incrementNext = true; + SoulNetworkHandler.syphonFromNetwork(owner, cost); } - k = -zSize; - i++; + + k++; } - i = -xSize; - j++; - this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(i, j, k)); - return; + k = -zSize; + i++; } - - this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(-xSize, -ySize, -zSize)); + i = -xSize; + j++; + this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(i, j, k)); + return; } + + this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(-xSize, -ySize, -zSize)); } @Override @@ -189,7 +174,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList ellipsoidRitual = new ArrayList(); + ArrayList ellipsoidRitual = new ArrayList<>(); ellipsoidRitual.add(new RitualComponent(-1, 0, -1, RitualComponent.DUSK)); ellipsoidRitual.add(new RitualComponent(-1, 0, 1, RitualComponent.DUSK)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectEvaporation.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectEvaporation.java index e1e69f722f..8b271bb1a9 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectEvaporation.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectEvaporation.java @@ -4,10 +4,7 @@ import java.util.List; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; @@ -16,7 +13,6 @@ import WayofTime.alchemicalWizardry.api.rituals.RitualComponent; import WayofTime.alchemicalWizardry.api.rituals.RitualEffect; import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class RitualEffectEvaporation extends RitualEffect { @@ -31,116 +27,110 @@ public void performEffect(IMasterRitualStone ritualStone) { int z = ritualStone.getZCoord(); if (currentEssence < 0) { - EntityPlayer entityOwner = SpellHelper.getPlayerForUsername(owner); + SoulNetworkHandler.causeNauseaToPlayer(owner); + return; + } + Block block1 = world.getBlock(x, y - 1, z); + int range = this.getRadiusForModifierBlock(block1); + + boolean[][][] boolList = new boolean[range * 2 + 1][range * 2 + 1][range * 2 + 1]; - if (entityOwner == null) { - return; + for (int i = 0; i < 2 * range + 1; i++) { + for (int j = 0; j < 2 * range + 1; j++) { + for (int k = 0; k < 2 * range + 1; k++) { + boolList[i][j][k] = false; + } } + } - entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80)); - } else { - Block block1 = world.getBlock(x, y - 1, z); - int range = this.getRadiusForModifierBlock(block1); + boolList[range][range][range] = true; + boolean isReady = false; - boolean[][][] boolList = new boolean[range * 2 + 1][range * 2 + 1][range * 2 + 1]; + while (!isReady) { + isReady = true; for (int i = 0; i < 2 * range + 1; i++) { for (int j = 0; j < 2 * range + 1; j++) { for (int k = 0; k < 2 * range + 1; k++) { - boolList[i][j][k] = false; - } - } - } - - boolList[range][range][range] = true; - boolean isReady = false; - - while (!isReady) { - isReady = true; - - for (int i = 0; i < 2 * range + 1; i++) { - for (int j = 0; j < 2 * range + 1; j++) { - for (int k = 0; k < 2 * range + 1; k++) { - if (boolList[i][j][k]) { - if (i - 1 >= 0 && !boolList[i - 1][j][k]) { - Block block = world.getBlock(x - range + i - 1, y - range + j, z - range + k); - if (world.isAirBlock(x - range + i - 1, y - range + j, z - range + k) - || block == ModBlocks.blockSpectralContainer) { - boolList[i - 1][j][k] = true; - isReady = false; - } + if (boolList[i][j][k]) { + if (i - 1 >= 0 && !boolList[i - 1][j][k]) { + Block block = world.getBlock(x - range + i - 1, y - range + j, z - range + k); + if (world.isAirBlock(x - range + i - 1, y - range + j, z - range + k) + || block == ModBlocks.blockSpectralContainer) { + boolList[i - 1][j][k] = true; + isReady = false; } + } - if (j - 1 >= 0 && !boolList[i][j - 1][k]) { - Block block = world.getBlock(x - range + i, y - range + j - 1, z - range + k); - if (world.isAirBlock(x - range + i, y - range + j - 1, z - range + k) - || block == ModBlocks.blockSpectralContainer) { - boolList[i][j - 1][k] = true; - isReady = false; - } + if (j - 1 >= 0 && !boolList[i][j - 1][k]) { + Block block = world.getBlock(x - range + i, y - range + j - 1, z - range + k); + if (world.isAirBlock(x - range + i, y - range + j - 1, z - range + k) + || block == ModBlocks.blockSpectralContainer) { + boolList[i][j - 1][k] = true; + isReady = false; } + } - if (k - 1 >= 0 && !boolList[i][j][k - 1]) { - Block block = world.getBlock(x - range + i, y - range + j, z - range + k - 1); - if (world.isAirBlock(x - range + i, y - range + j, z - range + k - 1) - || block == ModBlocks.blockSpectralContainer) { - boolList[i][j][k - 1] = true; - isReady = false; - } + if (k - 1 >= 0 && !boolList[i][j][k - 1]) { + Block block = world.getBlock(x - range + i, y - range + j, z - range + k - 1); + if (world.isAirBlock(x - range + i, y - range + j, z - range + k - 1) + || block == ModBlocks.blockSpectralContainer) { + boolList[i][j][k - 1] = true; + isReady = false; } + } - if (i + 1 <= 2 * range && !boolList[i + 1][j][k]) { - Block block = world.getBlock(x - range + i + 1, y - range + j, z - range + k); - if (world.isAirBlock(x - range + i + 1, y - range + j, z - range + k) - || block == ModBlocks.blockSpectralContainer) { - boolList[i + 1][j][k] = true; - isReady = false; - } + if (i + 1 <= 2 * range && !boolList[i + 1][j][k]) { + Block block = world.getBlock(x - range + i + 1, y - range + j, z - range + k); + if (world.isAirBlock(x - range + i + 1, y - range + j, z - range + k) + || block == ModBlocks.blockSpectralContainer) { + boolList[i + 1][j][k] = true; + isReady = false; } + } - if (j + 1 <= 2 * range && !boolList[i][j + 1][k]) { - Block block = world.getBlock(x - range + i, y - range + j + 1, z - range + k); - if (world.isAirBlock(x - range + i, y - range + j + 1, z - range + k) - || block == ModBlocks.blockSpectralContainer) { - boolList[i][j + 1][k] = true; - isReady = false; - } + if (j + 1 <= 2 * range && !boolList[i][j + 1][k]) { + Block block = world.getBlock(x - range + i, y - range + j + 1, z - range + k); + if (world.isAirBlock(x - range + i, y - range + j + 1, z - range + k) + || block == ModBlocks.blockSpectralContainer) { + boolList[i][j + 1][k] = true; + isReady = false; } + } - if (k + 1 <= 2 * range && !boolList[i][j][k + 1]) { - Block block = world.getBlock(x - range + i, y - range + j, z - range + k + 1); - if (world.isAirBlock(x - range + i, y - range + j, z - range + k + 1) - || block == ModBlocks.blockSpectralContainer) { - boolList[i][j][k + 1] = true; - isReady = false; - } + if (k + 1 <= 2 * range && !boolList[i][j][k + 1]) { + Block block = world.getBlock(x - range + i, y - range + j, z - range + k + 1); + if (world.isAirBlock(x - range + i, y - range + j, z - range + k + 1) + || block == ModBlocks.blockSpectralContainer) { + boolList[i][j][k + 1] = true; + isReady = false; } } } } } } + } - for (int i = 0; i < 2 * range + 1; i++) { - for (int j = 0; j < 2 * range + 1; j++) { - for (int k = 0; k < 2 * range + 1; k++) { - if (!boolList[i][j][k]) { - continue; - } + for (int i = 0; i < 2 * range + 1; i++) { + for (int j = 0; j < 2 * range + 1; j++) { + for (int k = 0; k < 2 * range + 1; k++) { + if (!boolList[i][j][k]) { + continue; + } - Block block = world.getBlock(x + i - range, y + j - range, z + k - range); + Block block = world.getBlock(x + i - range, y + j - range, z + k - range); - if (block == ModBlocks.blockSpectralContainer) { - world.setBlockToAir(x + i - range, y + j - range, z + k - range); - } + if (block == ModBlocks.blockSpectralContainer) { + world.setBlockToAir(x + i - range, y + j - range, z + k - range); } } } + } - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); - ritualStone.setActive(false); - } + ritualStone.setActive(false); } @Override @@ -150,7 +140,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList ellipsoidRitual = new ArrayList(); + ArrayList ellipsoidRitual = new ArrayList<>(); ellipsoidRitual.add(new RitualComponent(-1, 0, -1, RitualComponent.DUSK)); ellipsoidRitual.add(new RitualComponent(-1, 0, 1, RitualComponent.DUSK)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectExpulsion.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectExpulsion.java index 78e19115fb..7a1eb546db 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectExpulsion.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectExpulsion.java @@ -2,20 +2,13 @@ import java.util.ArrayList; import java.util.List; -import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.living.EnderTeleportEvent; import WayofTime.alchemicalWizardry.AlchemicalWizardry; import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry; @@ -45,82 +38,73 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh()) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - boolean hasVirtus = this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false); - boolean hasPotentia = this - .canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, false); - - int teleportDistance = hasVirtus ? 300 : 100; - int range = hasPotentia ? 50 : 25; - List playerList = SpellHelper - .getPlayersInRange(world, x + 0.5, y + 0.5, z + 0.5, range, range); - boolean flag = false; + return; + } + boolean hasVirtus = this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false); + boolean hasPotentia = this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, false); + + int teleportDistance = hasVirtus ? 300 : 100; + int range = hasPotentia ? 50 : 25; + List playerList = SpellHelper.getPlayersInRange(world, x + 0.5, y + 0.5, z + 0.5, range, range); + boolean teleported = false; + + TileEntity tile = world.getTileEntity(x, y + 1, z); + IInventory inventoryTile = null; + if (tile instanceof IInventory inv) { + inventoryTile = inv; + } - TileEntity tile = world.getTileEntity(x, y + 1, z); - IInventory inventoryTile = null; - if (tile instanceof IInventory) { - inventoryTile = (IInventory) tile; + players: for (EntityPlayer entityplayer : playerList) { + if (entityplayer.capabilities.isCreativeMode) { + continue; } - - for (EntityPlayer entityplayer : playerList) { - if (entityplayer.capabilities.isCreativeMode) { - continue; - } - String playerString = SpellHelper.getUsername(entityplayer); - if (!playerString.equals(owner)) { - if (inventoryTile != null) { - boolean test = false; - for (int i = 0; i < inventoryTile.getSizeInventory(); i++) { - ItemStack stack = inventoryTile.getStackInSlot(i); - if (stack != null && stack.getItem() instanceof IBindable - && IBindable.getOwnerName(stack).equals(playerString)) { - test = true; - } - } - - if (test) { - continue; + String playerString = SpellHelper.getUsername(entityplayer); + if (!playerString.equals(owner)) { + if (inventoryTile != null) { + for (int i = 0; i < inventoryTile.getSizeInventory(); i++) { + ItemStack stack = inventoryTile.getStackInSlot(i); + if (stack != null && stack.getItem() instanceof IBindable + && IBindable.getOwnerName(stack).equals(playerString)) { + continue players; } } - flag = teleportRandomly(entityplayer, teleportDistance) || flag; } + teleported = SpellTeleport.teleportRandomly(entityplayer, teleportDistance) || teleported; } + } - if (flag) { - if (hasVirtus) { - this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, true); - } - - if (hasPotentia) { - this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, true); - } + if (teleported) { + if (hasVirtus) { + this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, true); + } - SoulNetworkHandler.syphonFromNetwork(owner, getCostPerRefresh()); + if (hasPotentia) { + this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, true); } + + SoulNetworkHandler.syphonFromNetwork(owner, getCostPerRefresh()); } - boolean hasTennebrae = this - .canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tennebraeDrain, false); - if (hasTennebrae && SoulNetworkHandler.canSyphonFromOnlyNetwork(owner, 1000)) { - boolean hasVirtus = this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false); - boolean hasPotentia = this - .canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, false); + if (this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tennebraeDrain, false) + && SoulNetworkHandler.canSyphonFromOnlyNetwork(owner, 1000)) { + hasVirtus = this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false); + hasPotentia = this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, false); - int teleportDistance = hasVirtus ? 300 : 100; - int range = hasPotentia ? 50 : 25; + teleportDistance = hasVirtus ? 300 : 100; + range = hasPotentia ? 50 : 25; List livingList = SpellHelper .getLivingEntitiesInRange(world, x + 0.5, y + 0.5, z + 0.5, range, range); - boolean flag = false; + teleported = false; for (EntityLivingBase livingEntity : livingList) { if (livingEntity instanceof EntityPlayer) { continue; } - flag = teleportRandomly(livingEntity, teleportDistance) || flag; + teleported = SpellTeleport.teleportRandomly(livingEntity, teleportDistance) || teleported; } - if (flag) { + if (teleported) { if (hasVirtus) { this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, true); } @@ -141,125 +125,9 @@ public int getCostPerRefresh() { return AlchemicalWizardry.ritualCostExpulsion[1]; } - public boolean teleportRandomly(EntityLivingBase entityLiving, double distance) { - if (entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) entityLiving; - if (player.capabilities.isCreativeMode) return false; - } - - double x = entityLiving.posX; - double y = entityLiving.posY; - double z = entityLiving.posZ; - Random rand = new Random(); - double d0 = x + (rand.nextDouble() - 0.5D) * distance; - double d1 = y + (double) (rand.nextInt((int) distance) - (distance) / 2); - double d2 = z + (rand.nextDouble() - 0.5D) * distance; - int i = 0; - - while (!teleportTo(entityLiving, d0, d1, d2, x, y, z) && i < 100) { - d0 = x + (rand.nextDouble() - 0.5D) * distance; - d1 = y + (double) (rand.nextInt((int) distance) - (distance) / 2); - d2 = z + (rand.nextDouble() - 0.5D) * distance; - i++; - } - - if (i >= 100) { - return false; - } - - return true; - } - - public boolean teleportTo(EntityLivingBase entityLiving, double par1, double par3, double par5, double lastX, - double lastY, double lastZ) { - EnderTeleportEvent event = new EnderTeleportEvent(entityLiving, par1, par3, par5, 0); - - if (MinecraftForge.EVENT_BUS.post(event)) { - return false; - } - - double d3 = lastX; - double d4 = lastY; - double d5 = lastZ; - SpellTeleport.moveEntityViaTeleport(entityLiving, event.targetX, event.targetY, event.targetZ); - boolean flag = false; - int i = MathHelper.floor_double(entityLiving.posX); - int j = MathHelper.floor_double(entityLiving.posY); - int k = MathHelper.floor_double(entityLiving.posZ); - int l; - - if (entityLiving.worldObj.blockExists(i, j, k)) { - boolean flag1 = false; - - while (!flag1 && j > 0) { - Block block = entityLiving.worldObj.getBlock(i, j - 1, k); - - if (block != null && block.getMaterial().blocksMovement()) { - flag1 = true; - } else { - --entityLiving.posY; - --j; - } - } - - if (flag1) { - SpellTeleport - .moveEntityViaTeleport(entityLiving, entityLiving.posX, entityLiving.posY, entityLiving.posZ); - - if (entityLiving.worldObj.getCollidingBoundingBoxes(entityLiving, entityLiving.boundingBox).isEmpty() - && !entityLiving.worldObj.isAnyLiquid(entityLiving.boundingBox)) { - flag = true; - } - } - } - - if (!flag) { - SpellTeleport.moveEntityViaTeleport(entityLiving, d3, d4, d5); - return false; - } else { - short short1 = 128; - - for (l = 0; l < short1; ++l) { - double d6 = (double) l / ((double) short1 - 1.0D); - float f = (entityLiving.worldObj.rand.nextFloat() - 0.5F) * 0.2F; - float f1 = (entityLiving.worldObj.rand.nextFloat() - 0.5F) * 0.2F; - float f2 = (entityLiving.worldObj.rand.nextFloat() - 0.5F) * 0.2F; - double d7 = d3 + (entityLiving.posX - d3) * d6 - + (entityLiving.worldObj.rand.nextDouble() - 0.5D) * (double) entityLiving.width * 2.0D; - double d8 = d4 + (entityLiving.posY - d4) * d6 - + entityLiving.worldObj.rand.nextDouble() * (double) entityLiving.height; - double d9 = d5 + (entityLiving.posZ - d5) * d6 - + (entityLiving.worldObj.rand.nextDouble() - 0.5D) * (double) entityLiving.width * 2.0D; - entityLiving.worldObj.spawnParticle("portal", d7, d8, d9, (double) f, (double) f1, (double) f2); - } - return true; - } - } - - public void moveEntityViaTeleport(EntityLivingBase entityLiving, double x, double y, double z) { - if (entityLiving instanceof EntityPlayer) { - if (entityLiving != null && entityLiving instanceof EntityPlayerMP) { - EntityPlayerMP entityplayermp = (EntityPlayerMP) entityLiving; - - if (entityplayermp.worldObj == entityLiving.worldObj) { - EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, x, y, z, 5.0F); - - if (!MinecraftForge.EVENT_BUS.post(event)) { - if (entityLiving.isRiding()) { - entityLiving.mountEntity((Entity) null); - } - entityLiving.setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); - } - } - } - } else if (entityLiving != null) { - entityLiving.setPosition(x, y, z); - } - } - @Override public List getRitualComponentList() { - ArrayList expulsionRitual = new ArrayList(); + ArrayList expulsionRitual = new ArrayList<>(); expulsionRitual.add(new RitualComponent(2, 0, 2, RitualComponent.EARTH)); expulsionRitual.add(new RitualComponent(2, 0, 1, RitualComponent.EARTH)); expulsionRitual.add(new RitualComponent(1, 0, 2, RitualComponent.EARTH)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFeatheredEarth.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFeatheredEarth.java index 9cda20e4c9..b7110ef01e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFeatheredEarth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFeatheredEarth.java @@ -52,33 +52,29 @@ public void performEffect(IMasterRitualStone ritualStone) { List entities = world.getEntitiesWithinAABB( EntityLivingBase.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, verticalRange, range)); - int entityCount = 0; + int entityCount = entities.size(); boolean flag = false; + if (currentEssence < this.getCostPerRefresh() * entityCount) { + SoulNetworkHandler.causeNauseaToPlayer(owner); + return; + } for (EntityLivingBase entity : entities) { - entityCount++; + entity.fallDistance = 0; + flag = true; } - if (currentEssence < this.getCostPerRefresh() * entityCount) { - SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - for (EntityLivingBase entity : entities) { - entity.fallDistance = 0; - flag = true; - } + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * entityCount); - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * entityCount); - - if (flag && world.getTotalWorldTime() % costCooldown == 0) { - if (hasTerrae) { - this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, true); - } - if (hasOrbisTerrae) { - this.canDrainReagent(ritualStone, ReagentRegistry.orbisTerraeReagent, orbisTerraeDrain, true); - } - if (hasAether) { - this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true); - } + if (flag && world.getTotalWorldTime() % costCooldown == 0) { + if (hasTerrae) { + this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, true); + } + if (hasOrbisTerrae) { + this.canDrainReagent(ritualStone, ReagentRegistry.orbisTerraeReagent, orbisTerraeDrain, true); + } + if (hasAether) { + this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true); } } } @@ -95,7 +91,7 @@ public int getInitialCooldown() { @Override public List getRitualComponentList() { - ArrayList featheredEarthRitual = new ArrayList(); + ArrayList featheredEarthRitual = new ArrayList<>(); featheredEarthRitual.add(new RitualComponent(1, 0, 0, RitualComponent.DUSK)); featheredEarthRitual.add(new RitualComponent(-1, 0, 0, RitualComponent.DUSK)); featheredEarthRitual.add(new RitualComponent(0, 0, 1, RitualComponent.DUSK)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFeatheredKnife.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFeatheredKnife.java index fefb7f06f5..872c541014 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFeatheredKnife.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFeatheredKnife.java @@ -43,20 +43,18 @@ public void performEffect(IMasterRitualStone ritualStone) { } IBloodAltar tileAltar = null; - boolean testFlag = false; for (int i = -5; i <= 5; i++) { for (int j = -5; j <= 5; j++) { for (int k = -10; k <= 10; k++) { - if (world.getTileEntity(x + i, y + k, z + j) instanceof IBloodAltar) { - tileAltar = (IBloodAltar) world.getTileEntity(x + i, y + k, z + j); - testFlag = true; + if (world.getTileEntity(x + i, y + k, z + j) instanceof IBloodAltar altar) { + tileAltar = altar; } } } } - if (!testFlag) { + if (tileAltar == null) { return; } @@ -67,53 +65,46 @@ public void performEffect(IMasterRitualStone ritualStone) { List list = SpellHelper.getPlayersInRange(world, x + 0.5, y + 0.5, z + 0.5, range, vertRange); int entityCount = 0; - boolean flag = false; if (currentEssence < this.getCostPerRefresh() * list.size()) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - boolean hasMagicales = this - .canDrainReagent(ritualStone, ReagentRegistry.magicalesReagent, magicalesDrain, false); - boolean hasSanctus = this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false); - - EntityPlayer ownerPlayer = SpellHelper.getPlayerForUsername(owner); - for (EntityPlayer player : list) { - hasSanctus = hasSanctus - && this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false); - double threshold = hasSanctus ? 0.7d : 0.3d; - - if ((hasMagicales && player == ownerPlayer) || !hasMagicales) { - if (!SpellHelper.isFakePlayer(world, player)) { - if (player.getHealth() / player.getMaxHealth() > threshold) { - player.setHealth(player.getHealth() - 1); - entityCount++; - tileAltar.sacrificialDaggerCall(this.amount, false); - if (hasSanctus) { - this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, true); - } - if (hasMagicales) { - this.canDrainReagent( - ritualStone, - ReagentRegistry.magicalesReagent, - magicalesDrain, - true); - break; - } - } - } - } + return; + } + boolean hasMagicales = this + .canDrainReagent(ritualStone, ReagentRegistry.magicalesReagent, magicalesDrain, false); + boolean hasSanctus = this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false); + + EntityPlayer ownerPlayer = SpellHelper.getPlayerForUsername(owner); + for (EntityPlayer player : list) { + hasSanctus = hasSanctus + && this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false); + double threshold = hasSanctus ? 0.7d : 0.3d; + + if ((hasMagicales && player != ownerPlayer) || SpellHelper.isFakePlayer(world, player) + || !(player.getHealth() / player.getMaxHealth() > threshold)) { + continue; } + player.setHealth(player.getHealth() - 1); + entityCount++; + tileAltar.sacrificialDaggerCall(this.amount, false); + if (hasSanctus) { + this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, true); + } + if (hasMagicales) { + this.canDrainReagent(ritualStone, ReagentRegistry.magicalesReagent, magicalesDrain, true); + break; + } + } - if (entityCount > 0) { - if (hasReductus) { - this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true); - } - if (hasPotentia) { - this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, true); - } - - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * entityCount); + if (entityCount > 0) { + if (hasReductus) { + this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true); + } + if (hasPotentia) { + this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, true); } + + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * entityCount); } } @@ -124,7 +115,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList featheredKnifeRitual = new ArrayList(); + ArrayList featheredKnifeRitual = new ArrayList<>(); featheredKnifeRitual.add(new RitualComponent(1, 0, 0, RitualComponent.DUSK)); featheredKnifeRitual.add(new RitualComponent(-1, 0, 0, RitualComponent.DUSK)); featheredKnifeRitual.add(new RitualComponent(0, 0, 1, RitualComponent.DUSK)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFlight.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFlight.java index f7eaffd164..f6dc2f80d1 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFlight.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFlight.java @@ -39,40 +39,36 @@ public void performEffect(IMasterRitualStone ritualStone) { axis.maxY = 256; axis.minY = 0; List entities = world.getEntitiesWithinAABB(EntityPlayer.class, axis); - int entityCount = 0; + int entityCount = entities.size(); boolean hasAether = this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, false); boolean hasReductus = this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false); + if (currentEssence < this.getCostPerRefresh() * entityCount) { + SoulNetworkHandler.causeNauseaToPlayer(owner); + return; + } + entityCount = 0; + EntityPlayer ownerEntity = SpellHelper.getPlayerForUsername(owner); for (EntityPlayer entity : entities) { + if (hasReductus && entity != ownerEntity) { + continue; + } + entity.addPotionEffect( + new PotionEffect(AlchemicalWizardry.customPotionFlight.id, hasAether ? 30 * 20 : 20, 0)); entityCount++; } - if (currentEssence < this.getCostPerRefresh() * entityCount) { - SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - entityCount = 0; - EntityPlayer ownerEntity = SpellHelper.getPlayerForUsername(owner); - for (EntityPlayer entity : entities) { - if (hasReductus && entity != ownerEntity) { - continue; - } - entity.addPotionEffect( - new PotionEffect(AlchemicalWizardry.customPotionFlight.id, hasAether ? 30 * 20 : 20, 0)); - entityCount++; + if (entityCount > 0 && world.getTotalWorldTime() % reagentCooldown == 0) { + if (hasAether) { + this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true); } - - if (entityCount > 0 && world.getTotalWorldTime() % reagentCooldown == 0) { - if (hasAether) { - this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true); - } - if (hasReductus) { - this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true); - } + if (hasReductus) { + this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true); } - - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * entityCount); } + + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * entityCount); } @Override @@ -87,7 +83,7 @@ public int getInitialCooldown() { @Override public List getRitualComponentList() { - ArrayList flightRitual = new ArrayList(); + ArrayList flightRitual = new ArrayList<>(); flightRitual.add(new RitualComponent(1, 0, 0, RitualComponent.DUSK)); flightRitual.add(new RitualComponent(-1, 0, 0, RitualComponent.DUSK)); flightRitual.add(new RitualComponent(0, 0, 1, RitualComponent.DUSK)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFullStomach.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFullStomach.java index 373e8e560f..b2474b1283 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFullStomach.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectFullStomach.java @@ -8,7 +8,6 @@ import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.FoodStats; import net.minecraft.world.World; @@ -47,51 +46,47 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh() * playerList.size()) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - TileEntity tile = world.getTileEntity(x, y + 1, z); - IInventory inventory = null; - if (tile instanceof IInventory) { - inventory = (IInventory) tile; - } else { - tile = world.getTileEntity(x, y - 1, z); - if (tile instanceof IInventory) { - inventory = (IInventory) tile; - } - } + return; + } + IInventory inventory = null; + if (world.getTileEntity(x, y + 1, z) instanceof IInventory inv) { + inventory = inv; + } else if (world.getTileEntity(x, y - 1, z) instanceof IInventory inv) { + inventory = inv; + } - int count = 0; + if (inventory == null) { + return; + } - if (inventory != null) { - for (EntityPlayer player : playerList) { - FoodStats foodStats = player.getFoodStats(); - float satLevel = foodStats.getSaturationLevel(); + int count = 0; + for (EntityPlayer player : playerList) { + FoodStats foodStats = player.getFoodStats(); + float satLevel = foodStats.getSaturationLevel(); - for (int i = 0; i < inventory.getSizeInventory(); i++) { - ItemStack stack = inventory.getStackInSlot(i); + for (int i = 0; i < inventory.getSizeInventory(); i++) { + ItemStack stack = inventory.getStackInSlot(i); - if (stack != null && stack.getItem() instanceof ItemFood) { - ItemFood foodItem = (ItemFood) stack.getItem(); + if (stack != null && stack.getItem() instanceof ItemFood foodItem) { - int regularHeal = foodItem.func_150905_g(stack); - float saturatedHeal = foodItem.func_150906_h(stack) * regularHeal * 2.0f; + int regularHeal = foodItem.func_150905_g(stack); + float saturatedHeal = foodItem.func_150906_h(stack) * regularHeal * 2.0f; - if (saturatedHeal + satLevel <= 20) { - NBTTagCompound nbt = new NBTTagCompound(); - foodStats.writeNBT(nbt); - nbt.setFloat("foodSaturationLevel", saturatedHeal + satLevel); - foodStats.readNBT(nbt); + if (saturatedHeal + satLevel <= 20) { + NBTTagCompound nbt = new NBTTagCompound(); + foodStats.writeNBT(nbt); + nbt.setFloat("foodSaturationLevel", saturatedHeal + satLevel); + foodStats.readNBT(nbt); - inventory.decrStackSize(i, 1); - count++; - break; - } - } + inventory.decrStackSize(i, 1); + count++; + break; } } } - - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * count); } + + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * count); } @Override @@ -101,7 +96,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList fullRitual = new ArrayList(); + ArrayList fullRitual = new ArrayList<>(); fullRitual.add(new RitualComponent(0, 0, 3, RitualComponent.FIRE)); fullRitual.add(new RitualComponent(0, 0, -3, RitualComponent.FIRE)); fullRitual.add(new RitualComponent(3, 0, 0, RitualComponent.FIRE)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectGrowth.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectGrowth.java index 0873213eb4..54e966455c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectGrowth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectGrowth.java @@ -35,80 +35,75 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh() * 9) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - boolean hasTerrae = this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, false); - boolean hasOrbisTerrae = this - .canDrainReagent(ritualStone, ReagentRegistry.orbisTerraeReagent, orbisTerraeDrain, false); - boolean hasVirtus = this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false); - - int speed = this.getSpeedForReagents(hasTerrae, hasOrbisTerrae); - if (world.getTotalWorldTime() % speed != 0) { - return; - } + return; + } + boolean hasTerrae = this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, false); + boolean hasOrbisTerrae = this + .canDrainReagent(ritualStone, ReagentRegistry.orbisTerraeReagent, orbisTerraeDrain, false); + boolean hasVirtus = this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false); + + int speed = this.getSpeedForReagents(hasTerrae, hasOrbisTerrae); + if (world.getTotalWorldTime() % speed != 0) { + return; + } - if (this.canDrainReagent(ritualStone, ReagentRegistry.aquasalusReagent, aquasalusDrain, false)) { - int hydrationRange = hasVirtus ? 4 : 1; - for (int i = -hydrationRange; i <= hydrationRange; i++) { - for (int j = -hydrationRange; j <= hydrationRange; j++) { - for (int k = -hydrationRange; k <= hydrationRange; k++) { - - if (this.canDrainReagent( - ritualStone, - ReagentRegistry.aquasalusReagent, - aquasalusDrain, - false)) { - if (SpellHelper.hydrateSoil(world, x + i, y + k, z + j)) { - this.canDrainReagent( - ritualStone, - ReagentRegistry.aquasalusReagent, - aquasalusDrain, - true); - } + if (this.canDrainReagent(ritualStone, ReagentRegistry.aquasalusReagent, aquasalusDrain, false)) { + int hydrationRange = hasVirtus ? 4 : 1; + for (int i = -hydrationRange; i <= hydrationRange; i++) { + for (int j = -hydrationRange; j <= hydrationRange; j++) { + for (int k = -hydrationRange; k <= hydrationRange; k++) { + + if (this.canDrainReagent( + ritualStone, + ReagentRegistry.aquasalusReagent, + aquasalusDrain, + false)) { + if (SpellHelper.hydrateSoil(world, x + i, y + k, z + j)) { + this.canDrainReagent( + ritualStone, + ReagentRegistry.aquasalusReagent, + aquasalusDrain, + true); } } } } } + } - int flag = 0; - - int range = hasVirtus ? 4 : 1; - for (int i = -range; i <= range; i++) { - for (int j = -range; j <= range; j++) { - - for (int k = -range; k <= range; k++) { - - Block block = world.getBlock(x + i, y + k, z + j); - - if (block instanceof IPlantable || block instanceof IGrowable) { - { - SpellHelper.sendIndexedParticleToAllAround( - world, - x, - y, - z, - 20, - world.provider.dimensionId, - 3, - x, - y, - z); - block.updateTick(world, x + i, y + k, z + j, world.rand); - flag++; - } - } + int count = 0; + + int range = hasVirtus ? 4 : 1; + for (int i = -range; i <= range; i++) { + for (int j = -range; j <= range; j++) { + for (int k = -range; k <= range; k++) { + Block block = world.getBlock(x + i, y + k, z + j); + if (block instanceof IPlantable || block instanceof IGrowable) { + SpellHelper.sendIndexedParticleToAllAround( + world, + x, + y, + z, + 20, + world.provider.dimensionId, + 3, + x, + y, + z); + block.updateTick(world, x + i, y + k, z + j, world.rand); + count++; } } } + } - if (flag > 0) { - if (hasTerrae) this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, true); - if (hasOrbisTerrae) - this.canDrainReagent(ritualStone, ReagentRegistry.orbisTerraeReagent, orbisTerraeDrain, true); - if (hasVirtus) this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, true); + if (count > 0) { + if (hasTerrae) this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, true); + if (hasOrbisTerrae) + this.canDrainReagent(ritualStone, ReagentRegistry.orbisTerraeReagent, orbisTerraeDrain, true); + if (hasVirtus) this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, true); - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * flag); - } + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * count); } } @@ -119,7 +114,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList growthRitual = new ArrayList(); + ArrayList growthRitual = new ArrayList<>(); growthRitual.add(new RitualComponent(1, 0, 0, 1)); growthRitual.add(new RitualComponent(-1, 0, 0, 1)); growthRitual.add(new RitualComponent(0, 0, 1, 1)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectHarvest.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectHarvest.java index 9a944436a2..565a78046e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectHarvest.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectHarvest.java @@ -4,10 +4,7 @@ import java.util.List; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.AlchemicalWizardry; @@ -16,7 +13,6 @@ import WayofTime.alchemicalWizardry.api.rituals.RitualComponent; import WayofTime.alchemicalWizardry.api.rituals.RitualEffect; import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class RitualEffectHarvest extends RitualEffect { @@ -32,36 +28,30 @@ public void performEffect(IMasterRitualStone ritualStone) { int maxCount = 100; if (currentEssence < this.getCostPerRefresh() * maxCount) { - EntityPlayer entityOwner = SpellHelper.getPlayerForUsername(owner); + SoulNetworkHandler.causeNauseaToPlayer(owner); + return; + } + if (world.getTotalWorldTime() % 5 != 0) { + return; + } - if (entityOwner == null) { - return; - } + Block block = world.getBlock(x, y - 1, z); + int count = 0; + int range = this.getRadiusForModifierBlock(block); + int vertRange = 4; - entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80)); - } else { - if (world.getTotalWorldTime() % 5 != 0) { - return; - } - - Block block = world.getBlock(x, y - 1, z); - int flag = 0; - int range = this.getRadiusForModifierBlock(block); - int vertRange = 4; - - for (int i = -range; i <= range; i++) { - for (int j = -vertRange; j <= vertRange; j++) { - for (int k = -range; k <= range; k++) { - if (HarvestRegistry.harvestBlock(world, x + i, y + j, z + k) && flag < maxCount) { - flag++; - } + for (int i = -range; i <= range; i++) { + for (int j = -vertRange; j <= vertRange; j++) { + for (int k = -range; k <= range; k++) { + if (HarvestRegistry.harvestBlock(world, x + i, y + j, z + k) && count < maxCount) { + count++; } } } + } - if (flag > 0) { - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * Math.min(maxCount, flag)); - } + if (count > 0) { + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * Math.min(maxCount, count)); } } @@ -92,7 +82,7 @@ public int getRadiusForModifierBlock(Block block) { @Override public List getRitualComponentList() { - ArrayList harvestRitual = new ArrayList(); + ArrayList harvestRitual = new ArrayList<>(); harvestRitual.add(new RitualComponent(1, 0, 1, RitualComponent.DUSK)); harvestRitual.add(new RitualComponent(1, 0, -1, RitualComponent.DUSK)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectHealing.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectHealing.java index 332687d5fb..bd0275826e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectHealing.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectHealing.java @@ -48,7 +48,6 @@ public void performEffect(IMasterRitualStone ritualStone) { List list = SpellHelper .getLivingEntitiesInRange(world, x + 0.5, y + 0.5, z + 0.5, range, vertRange); int entityCount = 0; - boolean flag = false; for (EntityLivingBase livingEntity : list) { if (livingEntity instanceof EntityPlayer) { @@ -65,50 +64,47 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < cost * entityCount) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - entityCount = 0; - - boolean hasReductus = this - .canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false); - - for (EntityLivingBase livingEntity : list) { - hasReductus = hasReductus - && this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false); - if (hasReductus && !(livingEntity instanceof EntityPlayer)) { - continue; - } - - if (livingEntity.getHealth() + 0.1f < livingEntity.getMaxHealth()) { - PotionEffect effect = livingEntity.getActivePotionEffect(Potion.regeneration); - if (effect == null || (effect != null && effect.getAmplifier() <= potency - && effect.getDuration() <= timeDelay)) { - if (!hasVirtus || (this - .canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false))) { - livingEntity - .addPotionEffect(new PotionEffect(Potion.regeneration.id, timeDelay + 2, potency)); - if (hasReductus) { - this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true); - } - if (hasVirtus) { - this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, true); - } - - if (livingEntity instanceof EntityPlayer) { - entityCount += 10; - } else { - entityCount++; - } - } - } - } + return; + } + entityCount = 0; + + boolean hasReductus = this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false); + + for (EntityLivingBase livingEntity : list) { + hasReductus = hasReductus + && this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false); + if (hasReductus && !(livingEntity instanceof EntityPlayer)) { + continue; + } + + if (!(livingEntity.getHealth() + 0.1f < livingEntity.getMaxHealth())) { + continue; + } + PotionEffect effect = livingEntity.getActivePotionEffect(Potion.regeneration); + if ((effect != null && (effect.getAmplifier() > potency || effect.getDuration() > timeDelay)) || (hasVirtus + && (!this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false)))) { + continue; + } + livingEntity.addPotionEffect(new PotionEffect(Potion.regeneration.id, timeDelay + 2, potency)); + if (hasReductus) { + this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true); } + if (hasVirtus) { + this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, true); + } + + if (livingEntity instanceof EntityPlayer) { + entityCount += 10; + } else { + entityCount++; + } + } - if (entityCount > 0) { - if (hasPraesidium) { - this.canDrainReagent(ritualStone, ReagentRegistry.praesidiumReagent, praesidiumDrain, true); - } - SoulNetworkHandler.syphonFromNetwork(owner, cost * entityCount); + if (entityCount > 0) { + if (hasPraesidium) { + this.canDrainReagent(ritualStone, ReagentRegistry.praesidiumReagent, praesidiumDrain, true); } + SoulNetworkHandler.syphonFromNetwork(owner, cost * entityCount); } } @@ -119,7 +115,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList healingRitual = new ArrayList(); + ArrayList healingRitual = new ArrayList<>(); healingRitual.add(new RitualComponent(4, 0, 0, RitualComponent.AIR)); healingRitual.add(new RitualComponent(5, 0, -1, RitualComponent.AIR)); healingRitual.add(new RitualComponent(5, 0, 1, RitualComponent.AIR)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectInterdiction.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectInterdiction.java index 3ca23fae62..a2bab92747 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectInterdiction.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectInterdiction.java @@ -34,82 +34,77 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh()) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - int d0 = 5; - - List list = SpellHelper - .getLivingEntitiesInRange(world, x + 0.5, y + 0.5, z + 0.5, d0, d0); - boolean flag = false; - - boolean hasOffensa = this - .canDrainReagent(ritualStone, ReagentRegistry.magicalesReagent, magicalesDrain, false); - boolean playerFlag = false; - - for (EntityLivingBase entityLiving : list) { - if (!((!hasOffensa && entityLiving instanceof EntityPlayer) - && (SpellHelper.getUsername((EntityPlayer) entityLiving).equals(owner)))) { - double xDif = entityLiving.posX - x; - double yDif = entityLiving.posY - (y + 1); - double zDif = entityLiving.posZ - z; - entityLiving.motionX = 0.1 * xDif; - entityLiving.motionY = 0.1 * yDif; - entityLiving.motionZ = 0.1 * zDif; - - if (hasOffensa && entityLiving instanceof EntityPlayer) { - SpellHelper.setPlayerSpeedFromServer( - (EntityPlayer) entityLiving, - 0.1 * xDif, - 0.1 * yDif, - 0.1 * zDif); - playerFlag = true; - } - entityLiving.fallDistance = 0; - flag = true; - } - } + return; + } + int range = 5; + + List list = SpellHelper + .getLivingEntitiesInRange(world, x + 0.5, y + 0.5, z + 0.5, range, range); + boolean flag = false; - if (playerFlag) { - this.canDrainReagent(ritualStone, ReagentRegistry.magicalesReagent, magicalesDrain, true); + boolean hasMagicales = this + .canDrainReagent(ritualStone, ReagentRegistry.magicalesReagent, magicalesDrain, false); + boolean playerFlag = false; + + for (EntityLivingBase entityLiving : list) { + if (!hasMagicales && entityLiving instanceof EntityPlayer) { + continue; + } + double xDif = entityLiving.posX - x; + double yDif = entityLiving.posY - (y + 1); + double zDif = entityLiving.posZ - z; + entityLiving.motionX = 0.1 * xDif; + entityLiving.motionY = 0.1 * yDif; + entityLiving.motionZ = 0.1 * zDif; + + if (hasMagicales && entityLiving instanceof EntityPlayer player + && !SpellHelper.getUsername(player).equals(owner)) { + SpellHelper.setPlayerSpeedFromServer(player, 0.1 * xDif, 0.1 * yDif, 0.1 * zDif); + playerFlag = true; } + entityLiving.fallDistance = 0; + flag = true; + } - boolean hasAether = this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, false); + if (playerFlag) { + this.canDrainReagent(ritualStone, ReagentRegistry.magicalesReagent, magicalesDrain, true); + } - if (hasAether) { - int aetherDrainRate = 10; + if (this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, false)) { + int aetherDrainRate = 10; - int horizontalRadius = 5; - int verticalRadius = 5; - List itemList = world.getEntitiesWithinAABB( - EntityItem.class, - AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1) - .expand(horizontalRadius, verticalRadius, horizontalRadius)); + int horizontalRadius = 5; + int verticalRadius = 5; + List itemList = world.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1) + .expand(horizontalRadius, verticalRadius, horizontalRadius)); - if (itemList != null) { - boolean itemFlag = false; + if (itemList != null) { + boolean itemFlag = false; - for (EntityItem entity : itemList) { - double xDif = entity.posX - x; - double yDif = entity.posY - (y + 1); - double zDif = entity.posZ - z; - entity.motionX = 0.1 * xDif; - entity.motionY = 0.1 * yDif; - entity.motionZ = 0.1 * zDif; + for (EntityItem entity : itemList) { + double xDif = entity.posX - x; + double yDif = entity.posY - (y + 1); + double zDif = entity.posZ - z; + entity.motionX = 0.1 * xDif; + entity.motionY = 0.1 * yDif; + entity.motionZ = 0.1 * zDif; - itemFlag = true; - } + itemFlag = true; + } - if (itemFlag) { - flag = true; - if (world.getTotalWorldTime() % aetherDrainRate == 0) { - this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true); - } + if (itemFlag) { + flag = true; + if (world.getTotalWorldTime() % aetherDrainRate == 0) { + this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true); } } } + } - if (world.getTotalWorldTime() % 2 == 0 && flag) { - SoulNetworkHandler.syphonFromNetwork(owner, getCostPerRefresh()); - } + if (world.getTotalWorldTime() % 2 == 0 && flag) { + SoulNetworkHandler.syphonFromNetwork(owner, getCostPerRefresh()); } } @@ -120,7 +115,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList interdictionRitual = new ArrayList(); + ArrayList interdictionRitual = new ArrayList<>(); interdictionRitual.add(new RitualComponent(1, 0, 0, 4)); interdictionRitual.add(new RitualComponent(-1, 0, 0, 4)); interdictionRitual.add(new RitualComponent(0, 0, 1, 4)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectItemRouting.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectItemRouting.java index f02f49491c..b2a0a744a2 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectItemRouting.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectItemRouting.java @@ -70,10 +70,8 @@ private void processOutputFoci(World world, IInventory outputFoci, List findBufferChests(World world, int x, int y, int z, Int3 List chestList = new ArrayList<>(); for (Int3 chestLocation : locations) { TileEntity tileEntity = world - .getTileEntity(x + chestLocation.xCoord, y + chestLocation.yCoord, z + chestLocation.zCoord); + .getTileEntity(x + chestLocation.x(), y + chestLocation.y(), z + chestLocation.z()); if (tileEntity instanceof IInventory inv) { chestList.add(inv); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectItemSuction.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectItemSuction.java index ce981a6695..fe195a3525 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectItemSuction.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectItemSuction.java @@ -6,7 +6,6 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -34,12 +33,8 @@ public void performEffect(IMasterRitualStone ritualStone) { int x = ritualStone.getXCoord(); int y = ritualStone.getYCoord(); int z = ritualStone.getZCoord(); - TileEntity tile = world.getTileEntity(x, y + 1, z); - IInventory tileEntity; - if (tile instanceof IInventory) { - tileEntity = (IInventory) tile; - } else { + if (!(world.getTileEntity(x, y + 1, z) instanceof IInventory tileEntity)) { return; } @@ -49,50 +44,45 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh() * 100) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - List itemDropList = SpellHelper.getItemsInRange(world, x + 0.5f, y + 0.5f, z + 0.5f, 10, 10); + return; + } + List itemDropList = SpellHelper.getItemsInRange(world, x + 0.5f, y + 0.5f, z + 0.5f, 10, 10); + + boolean hasReductus = this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false); + + int count = 0; - boolean hasReductus = this - .canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false); + if (itemDropList != null) { + for (EntityItem itemEntity : itemDropList) { + hasReductus = hasReductus + && this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false); + if (hasReductus && itemEntity.age < timeDelayMin) { + continue; + } + ItemStack copyStack = itemEntity.getEntityItem().copy(); - int count = 0; + int pastAmount = copyStack.stackSize; + ItemStack newStack = SpellHelper.insertStackIntoInventory(copyStack, tileEntity, ForgeDirection.DOWN); - if (itemDropList != null) { - int invSize = tileEntity.getSizeInventory(); + if (newStack != null && newStack.stackSize < pastAmount) { + count++; + if (newStack.stackSize <= 0) { + itemEntity.setDead(); + itemEntity.getEntityItem().stackSize = newStack.stackSize; + } - for (EntityItem itemEntity : itemDropList) { - hasReductus = hasReductus - && this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false); - if (hasReductus && itemEntity.age < this.timeDelayMin) { - continue; + if (newStack.stackSize > 0) { + itemEntity.getEntityItem().stackSize = newStack.stackSize; } - ItemStack item = itemEntity.getEntityItem(); - ItemStack copyStack = itemEntity.getEntityItem().copy(); - - int pastAmount = copyStack.stackSize; - ItemStack newStack = SpellHelper - .insertStackIntoInventory(copyStack, tileEntity, ForgeDirection.DOWN); - - if (newStack != null && newStack.stackSize < pastAmount) { - count++; - if (newStack.stackSize <= 0) { - itemEntity.setDead(); - itemEntity.getEntityItem().stackSize = newStack.stackSize; - } - - if (newStack.stackSize > 0) { - itemEntity.getEntityItem().stackSize = newStack.stackSize; - } - if (hasReductus) { - this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true); - } + if (hasReductus) { + this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true); } } } + } - if (count > 0) { - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * Math.min(count, 100)); - } + if (count > 0) { + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * Math.min(count, 100)); } } @@ -103,7 +93,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList suctionRitual = new ArrayList(); + ArrayList suctionRitual = new ArrayList<>(); suctionRitual.add(new RitualComponent(2, 0, 0, RitualComponent.AIR)); suctionRitual.add(new RitualComponent(-2, 0, 0, RitualComponent.AIR)); suctionRitual.add(new RitualComponent(0, 0, 2, RitualComponent.AIR)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectJumping.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectJumping.java index 5af0bd34d7..27f34f07ef 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectJumping.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectJumping.java @@ -37,55 +37,51 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh() * livingList.size()) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - int flag = 0; + return; + } + int flag = 0; - boolean hasAether = this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, false); - boolean hasTerrae = this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, false); + boolean hasAether = this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, false); + boolean hasTerrae = this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, false); - for (EntityLivingBase livingEntity : livingList) { - if (livingEntity.isSneaking()) { - continue; - } + for (EntityLivingBase livingEntity : livingList) { + if (livingEntity.isSneaking()) { + continue; + } - hasAether = hasAether - && this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, false); - hasTerrae = hasTerrae - && this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, false); - - double motionY = 1.5 * (hasAether ? 2 : 1); - - if (livingEntity instanceof EntityPlayer) { - SpellHelper.setPlayerSpeedFromServer( - (EntityPlayer) livingEntity, - livingEntity.motionX, - motionY, - livingEntity.motionZ); - livingEntity.motionY = motionY; - livingEntity.fallDistance = 0; - flag++; - } else { - livingEntity.motionY = motionY; - livingEntity.fallDistance = 0; - flag++; - } + hasAether = hasAether + && this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, false); + hasTerrae = hasTerrae + && this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, false); - if (hasAether) { - this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true); - } - if (hasTerrae) { - if (!livingEntity.isPotionActive(AlchemicalWizardry.customPotionFeatherFall)) { - livingEntity.addPotionEffect( - new PotionEffect(AlchemicalWizardry.customPotionFeatherFall.id, 5 * 20, 0)); - this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, true); - } - } + double motionY = 1.5 * (hasAether ? 2 : 1); + + if (livingEntity instanceof EntityPlayer) { + SpellHelper.setPlayerSpeedFromServer( + (EntityPlayer) livingEntity, + livingEntity.motionX, + motionY, + livingEntity.motionZ); } + livingEntity.motionY = motionY; + livingEntity.fallDistance = 0; + flag++; - if (flag > 0) { - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * flag); + if (hasAether) { + this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true); + } + if (hasTerrae) { + if (!livingEntity.isPotionActive(AlchemicalWizardry.customPotionFeatherFall)) { + livingEntity.addPotionEffect( + new PotionEffect(AlchemicalWizardry.customPotionFeatherFall.id, 5 * 20, 0)); + this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, true); + } } } + + if (flag > 0) { + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * flag); + } } @Override @@ -95,7 +91,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList jumpingRitual = new ArrayList(); + ArrayList jumpingRitual = new ArrayList<>(); for (int i = -1; i <= 1; i++) { jumpingRitual.add(new RitualComponent(1, i, 1, RitualComponent.AIR)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectLava.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectLava.java index c397ad447c..0802c10ab8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectLava.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectLava.java @@ -81,26 +81,23 @@ public void performEffect(IMasterRitualStone ritualStone) { if (world.isAirBlock(x, y + 1, z) && !(block instanceof BlockSpectralContainer)) { if (currentEssence < this.getCostPerRefresh()) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - for (int i = 0; i < 10; i++) { - SpellHelper - .sendIndexedParticleToAllAround(world, x, y, z, 20, world.provider.dimensionId, 3, x, y, z); - } - - world.setBlock(x, y + 1, z, Blocks.lava, 0, 3); - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); + return; } + for (int i = 0; i < 10; i++) { + SpellHelper.sendIndexedParticleToAllAround(world, x, y, z, 20, world.provider.dimensionId, 3, x, y, z); + } + + world.setBlock(x, y + 1, z, Blocks.lava, 0, 3); + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); } else { - boolean hasSanctus = this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false); - if (!hasSanctus) { + if (!this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false)) { return; } TileEntity tile = world.getTileEntity(x, y + 1, z); - if (tile instanceof IFluidHandler) { - int amount = ((IFluidHandler) tile) - .fill(ForgeDirection.DOWN, new FluidStack(FluidRegistry.LAVA, 1000), false); + if (tile instanceof IFluidHandler handler) { + int amount = handler.fill(ForgeDirection.DOWN, new FluidStack(FluidRegistry.LAVA, 1000), false); if (amount >= 1000) { - ((IFluidHandler) tile).fill(ForgeDirection.DOWN, new FluidStack(FluidRegistry.LAVA, 1000), true); + handler.fill(ForgeDirection.DOWN, new FluidStack(FluidRegistry.LAVA, 1000), true); this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, true); @@ -117,7 +114,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList lavaRitual = new ArrayList(); + ArrayList lavaRitual = new ArrayList<>(); lavaRitual.add(new RitualComponent(1, 0, 0, 2)); lavaRitual.add(new RitualComponent(-1, 0, 0, 2)); lavaRitual.add(new RitualComponent(0, 0, 1, 2)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectLeap.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectLeap.java index f2b008b3eb..62ffd5c1ea 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectLeap.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectLeap.java @@ -93,39 +93,31 @@ public void performEffect(IMasterRitualStone ritualStone) { livingEntity.fallDistance = 0; count++; - if (livingEntity instanceof EntityPlayer) { + if (livingEntity instanceof EntityPlayer player) { switch (direction) { - case 1: - SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, 0, motionY, -speed); - break; - case 2: - SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, speed, motionY, 0); - break; - case 3: - SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, 0, motionY, speed); - break; - case 4: - SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, -speed, motionY, 0); - break; + case 1 -> SpellHelper.setPlayerSpeedFromServer(player, 0, motionY, -speed); + case 2 -> SpellHelper.setPlayerSpeedFromServer(player, speed, motionY, 0); + case 3 -> SpellHelper.setPlayerSpeedFromServer(player, 0, motionY, speed); + case 4 -> SpellHelper.setPlayerSpeedFromServer(player, -speed, motionY, 0); } } else { switch (direction) { - case 1: + case 1 -> { livingEntity.motionX = 0.0; livingEntity.motionZ = -speed; - break; - case 2: + } + case 2 -> { livingEntity.motionX = speed; livingEntity.motionZ = 0.0; - break; - case 3: + } + case 3 -> { livingEntity.motionX = 0.0; livingEntity.motionZ = speed; - break; - case 4: + } + case 4 -> { livingEntity.motionX = -speed; livingEntity.motionZ = 0.0; - break; + } } if (hasTenebrae) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectLifeConduit.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectLifeConduit.java index 3972e1876d..8cb4402e6b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectLifeConduit.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectLifeConduit.java @@ -30,24 +30,18 @@ public void performEffect(IMasterRitualStone ritualStone) { int z = ritualStone.getZCoord(); IBloodAltar tileAltar = null; - boolean testFlag = false; for (int i = -5; i <= 5; i++) { for (int j = -5; j <= 5; j++) { for (int k = -10; k <= 10; k++) { - if (world.getTileEntity(x + i, y + k, z + j) instanceof IBloodAltar) { - tileAltar = (IBloodAltar) world.getTileEntity(x + i, y + k, z + j); - testFlag = true; + if (world.getTileEntity(x + i, y + k, z + j) instanceof IBloodAltar altar) { + tileAltar = altar; } } } } - if (!testFlag) { - return; - } - - if (!(tileAltar instanceof IFluidHandler)) { + if (!(tileAltar instanceof IFluidHandler handler)) { return; } @@ -60,6 +54,7 @@ public void performEffect(IMasterRitualStone ritualStone) { for (EntityPlayer player : list) { if (SpellHelper.getUsername(player).equals(owner)) { entityOwner = player; + break; } } @@ -69,17 +64,12 @@ public void performEffect(IMasterRitualStone ritualStone) { int fillAmount = Math.min( currentEssence / 2, - ((IFluidHandler) tileAltar) - .fill(ForgeDirection.UP, new FluidStack(AlchemicalWizardry.lifeEssenceFluid, 10000), false)); - - { - ((IFluidHandler) tileAltar) - .fill(ForgeDirection.UP, new FluidStack(AlchemicalWizardry.lifeEssenceFluid, fillAmount), true); - if (entityOwner.getHealth() > 2.0f && fillAmount != 0) { - entityOwner.setHealth(2.0f); - } - SoulNetworkHandler.syphonFromNetwork(owner, fillAmount * 2); + handler.fill(ForgeDirection.UP, new FluidStack(AlchemicalWizardry.lifeEssenceFluid, 10000), false)); + handler.fill(ForgeDirection.UP, new FluidStack(AlchemicalWizardry.lifeEssenceFluid, fillAmount), true); + if (entityOwner.getHealth() > 2.0f && fillAmount != 0) { + entityOwner.setHealth(2.0f); } + SoulNetworkHandler.syphonFromNetwork(owner, fillAmount * 2); } @Override @@ -89,7 +79,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList conduitRitual = new ArrayList(); + ArrayList conduitRitual = new ArrayList<>(); conduitRitual.add(new RitualComponent(-1, 0, -1, RitualComponent.FIRE)); conduitRitual.add(new RitualComponent(-1, 0, 1, RitualComponent.FIRE)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectMagnetic.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectMagnetic.java index 7cdef5d88a..aa0661c246 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectMagnetic.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectMagnetic.java @@ -84,89 +84,81 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh()) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - int xRep = 0; - int yRep = 0; - int zRep = 0; - boolean replace = false; - - outer: for (int j = 1; j <= 3; j++) { - for (int i = -1; i <= 1; i++) { - for (int k = -1; k <= 1; k++) { - if ((!replace) && world.isAirBlock(x + i, y + j, z + k)) { - xRep = x + i; - yRep = y + j; - zRep = z + k; - replace = true; - break outer; - } + return; + } + int xRep = 0; + int yRep = 0; + int zRep = 0; + boolean replace = false; + + outer: for (int j = 1; j <= 3; j++) { + for (int i = -1; i <= 1; i++) { + for (int k = -1; k <= 1; k++) { + if (world.isAirBlock(x + i, y + j, z + k)) { + xRep = x + i; + yRep = y + j; + zRep = z + k; + replace = true; + break outer; } } } + } - if (replace) { - Int3 lastPos = this.getLastPosition(ritualStone.getCustomRitualTag()); + if (replace) { + Int3 lastPos = this.getLastPosition(ritualStone.getCustomRitualTag()); - int j = y - 1; - int i = 0; - int k = 0; + int height = y - 1; + int i = 0; + int k = 0; - if (lastPos != null) { - j = lastPos.yCoord; - i = Math.min(radius, Math.max(-radius, lastPos.xCoord)); - k = Math.min(radius, Math.max(-radius, lastPos.zCoord)); - } + if (lastPos != null) { + height = lastPos.y(); + i = Math.min(radius, Math.max(-radius, lastPos.x())); + k = Math.min(radius, Math.max(-radius, lastPos.z())); + } - while (j >= 0) { - while (i <= radius) { - while (k <= radius) { - Block block = world.getBlock(x + i, j, z + k); - int meta = world.getBlockMetadata(x + i, j, z + k); - - if (isBlockOre(block, meta)) { - // Allow swapping code. This means the searched block is an ore. - BlockTeleposer.swapBlocks(this, world, world, x + i, j, z + k, xRep, yRep, zRep); - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); - - if (hasPotentia) { - this.canDrainReagent( - ritualStone, - ReagentRegistry.potentiaReagent, - potentiaDrain, - true); - } - - if (hasTerrae) { - this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, true); - } - - if (hasOrbisTerrae) { - this.canDrainReagent( - ritualStone, - ReagentRegistry.orbisTerraeReagent, - orbisTerraeDrain, - true); - } - - this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(i, j, k)); - - return; - } - k++; + if (height < 1) { + height = y - 1; + this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(i, height, k)); + } + while (i <= radius) { + while (k <= radius) { + Block block = world.getBlock(x + i, height, z + k); + int meta = world.getBlockMetadata(x + i, height, z + k); + + if (isBlockOre(block, meta)) { + // Allow swapping code. This means the searched block is an ore. + BlockTeleposer.swapBlocks(this, world, world, x + i, height, z + k, xRep, yRep, zRep); + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); + + if (hasPotentia) { + this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, true); + } + + if (hasTerrae) { + this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, true); } - k = -radius; - i++; + + if (hasOrbisTerrae) { + this.canDrainReagent( + ritualStone, + ReagentRegistry.orbisTerraeReagent, + orbisTerraeDrain, + true); + } + + this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(i, height, k)); + return; } - i = -radius; - j--; - this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(i, j, k)); - return; + k++; } - - j = y - 1; - this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(i, j, k)); - return; + k = -radius; + i++; } + i = -radius; + height--; + this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(i, height, k)); } } @@ -191,7 +183,7 @@ public void setLastPosition(NBTTagCompound tag, Int3 pos) { @Override public List getRitualComponentList() { - ArrayList magneticRitual = new ArrayList(); + ArrayList magneticRitual = new ArrayList<>(); magneticRitual.add(new RitualComponent(1, 0, 1, RitualComponent.EARTH)); magneticRitual.add(new RitualComponent(1, 0, -1, RitualComponent.EARTH)); magneticRitual.add(new RitualComponent(-1, 0, 1, RitualComponent.EARTH)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaStalling.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaStalling.java index b32e4c4935..c029271b3b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaStalling.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaStalling.java @@ -25,7 +25,6 @@ public class RitualEffectOmegaStalling extends RitualEffect { public void performEffect(IMasterRitualStone ritualStone) { String owner = ritualStone.getOwner(); - int currentEssence = SoulNetworkHandler.getCurrentEssence(owner); World world = ritualStone.getWorld(); int x = ritualStone.getXCoord(); int y = ritualStone.getYCoord(); @@ -36,27 +35,25 @@ public void performEffect(IMasterRitualStone ritualStone) { } TileEntity tile = world.getTileEntity(x, y + 5, z); - if (tile instanceof TileEntityBeacon) { - int levels = ((TileEntityBeacon) tile).getLevels(); - if (levels >= 4) { - int horizontalRadius = 100; - int verticalRadius = 100; + if (!(tile instanceof TileEntityBeacon beacon) || beacon.getLevels() < 4) { + return; + } + int horizontalRadius = 100; + int verticalRadius = 100; - List playerList = SpellHelper - .getPlayersInRange(world, x + 0.5, y + 0.5, z + 0.5, horizontalRadius, verticalRadius); + List playerList = SpellHelper + .getPlayersInRange(world, x + 0.5, y + 0.5, z + 0.5, horizontalRadius, verticalRadius); - for (EntityPlayer player : playerList) { - if (SoulNetworkHandler.canSyphonFromOnlyNetwork(owner, getCostPerRefresh())) { - Reagent reagent = APISpellHelper.getPlayerReagentType(player); - OmegaParadigm parad = OmegaRegistry.getParadigmForReagent(reagent); - if (parad != null) { - float costOffset = parad.getCostPerTickOfUse(player); - parad.setOmegaStalling(player, 100); - SoulNetworkHandler - .syphonFromNetwork(owner, (int) (getCostPerRefresh() * Math.min(costOffset, 1))); - } - } - } + for (EntityPlayer player : playerList) { + if (!SoulNetworkHandler.canSyphonFromOnlyNetwork(owner, getCostPerRefresh())) { + continue; + } + Reagent reagent = APISpellHelper.getPlayerReagentType(player); + OmegaParadigm parad = OmegaRegistry.getParadigmForReagent(reagent); + if (parad != null) { + float costOffset = parad.getCostPerTickOfUse(player); + parad.setOmegaStalling(player, 100); + SoulNetworkHandler.syphonFromNetwork(owner, (int) (getCostPerRefresh() * Math.min(costOffset, 1))); } } } @@ -68,7 +65,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList omegaRitual = new ArrayList(); + ArrayList omegaRitual = new ArrayList<>(); this.addCornerRunes(omegaRitual, 1, 0, RitualComponent.FIRE); this.addOffsetRunes(omegaRitual, 2, 1, 0, RitualComponent.DUSK); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaTest.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaTest.java index c5568afd86..c7edbdc535 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaTest.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaTest.java @@ -22,7 +22,6 @@ import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone; import WayofTime.alchemicalWizardry.api.rituals.RitualComponent; import WayofTime.alchemicalWizardry.api.rituals.RitualEffect; -import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; import WayofTime.alchemicalWizardry.api.spell.APISpellHelper; import WayofTime.alchemicalWizardry.common.NewPacketHandler; import WayofTime.alchemicalWizardry.common.omega.OmegaParadigm; @@ -33,14 +32,10 @@ public class RitualEffectOmegaTest extends RitualEffect { - public static final boolean isTesting = false; public static final int drainTotal = 32 * 1000; @Override public void performEffect(IMasterRitualStone ritualStone) { - String owner = ritualStone.getOwner(); - - int currentEssence = SoulNetworkHandler.getCurrentEssence(owner); World world = ritualStone.getWorld(); int x = ritualStone.getXCoord(); int y = ritualStone.getYCoord(); @@ -60,38 +55,36 @@ public void performEffect(IMasterRitualStone ritualStone) { return; } - // System.out.println("Stability: " + stab + ", Enchantability: " + enchantability + ", Enchantment - // Level: " + enchantmentLevel); - double range = 0.5; - List playerList = SpellHelper.getPlayersInRange(world, x + 0.5, y + 1.5, z + 0.5, range, range); + List playerList = SpellHelper + .getPlayersInRange(world, x + range, y + range, z + range, range, range); Reagent reagent = null; - Map reagentMap = new HashMap(); + Map reagentMap = new HashMap<>(); for (int i = 0; i < 4; i++) { Int3 jarLoc = this.getJarLocation(i); - TileEntity tile = world.getTileEntity(x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord); - if (tile instanceof IReagentHandler) { - IReagentHandler container = (IReagentHandler) tile; - ReagentContainerInfo[] containerInfoArray = container.getContainerInfo(ForgeDirection.UP); - if (containerInfoArray == null) { + TileEntity tile = world.getTileEntity(x + jarLoc.x(), y + jarLoc.y(), z + jarLoc.z()); + if (!(tile instanceof IReagentHandler container)) { + continue; + } + ReagentContainerInfo[] containerInfoArray = container.getContainerInfo(ForgeDirection.UP); + if (containerInfoArray == null) { + continue; + } + + for (ReagentContainerInfo containerInfo : containerInfoArray) { + ReagentStack containedReagent = containerInfo.reagent; + if (containedReagent == null) { continue; } - - for (ReagentContainerInfo containerInfo : containerInfoArray) { - ReagentStack containedReagent = containerInfo.reagent; - if (containedReagent == null) { - continue; - } - Reagent rea = containedReagent.reagent; - int amt = containedReagent.amount; - if (reagentMap.containsKey(rea)) { - reagentMap.put(rea, reagentMap.get(rea) + amt); - } else { - reagentMap.put(rea, amt); - } + Reagent rea = containedReagent.reagent; + int amt = containedReagent.amount; + if (reagentMap.containsKey(rea)) { + reagentMap.put(rea, reagentMap.get(rea) + amt); + } else { + reagentMap.put(rea, amt); } } } @@ -107,55 +100,48 @@ public void performEffect(IMasterRitualStone ritualStone) { return; } - int tickDuration = isTesting ? 20 * 30 : 15 * 20 * 60 + (int) ((15 * 20 * 60) * Math.sqrt(stab / 700)); + int tickDuration = 15 * 20 * 60 + (int) ((15 * 20 * 60) * Math.sqrt(stab / 700D)); int affinity = 0; for (EntityPlayer player : playerList) { - OmegaParadigm waterParadigm = OmegaRegistry.getParadigmForReagent(reagent); - if (waterParadigm != null && waterParadigm + OmegaParadigm paradigm = OmegaRegistry.getParadigmForReagent(reagent); + if (paradigm == null || !paradigm .convertPlayerArmour(player, x, y, z, stab, affinity, enchantability, enchantmentLevel)) { - APISpellHelper.setPlayerCurrentReagentAmount(player, tickDuration); - APISpellHelper.setPlayerMaxReagentAmount(player, tickDuration); - APISpellHelper.setPlayerReagentType(player, reagent); - APISpellHelper.setCurrentAdditionalMaxHP(player, waterParadigm.getMaxAdditionalHealth()); - NewPacketHandler.INSTANCE.sendTo( - NewPacketHandler.getReagentBarPacket( - reagent, - APISpellHelper.getPlayerCurrentReagentAmount(player), - APISpellHelper.getPlayerMaxReagentAmount(player)), - (EntityPlayerMP) player); - - if (!isTesting) { - int drainLeft = this.drainTotal; - for (int i = 0; i < 4; i++) { - if (drainLeft <= 0) { - break; - } - Int3 jarLoc = this.getJarLocation(i); - TileEntity tile = world.getTileEntity(x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord); - if (tile instanceof IReagentHandler) { - IReagentHandler container = (IReagentHandler) tile; - ReagentStack drained = container - .drain(ForgeDirection.UP, new ReagentStack(reagent, drainLeft), true); - if (drained != null) { - drainLeft -= drained.amount; - world.markBlockForUpdate(x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord); - world.addWeatherEffect( - new EntityLightningBolt( - world, - x + jarLoc.xCoord, - y + jarLoc.yCoord, - z + jarLoc.zCoord)); - } - } + continue; + } + APISpellHelper.setPlayerCurrentReagentAmount(player, tickDuration); + APISpellHelper.setPlayerMaxReagentAmount(player, tickDuration); + APISpellHelper.setPlayerReagentType(player, reagent); + APISpellHelper.setCurrentAdditionalMaxHP(player, paradigm.getMaxAdditionalHealth()); + NewPacketHandler.INSTANCE.sendTo( + NewPacketHandler.getReagentBarPacket( + reagent, + APISpellHelper.getPlayerCurrentReagentAmount(player), + APISpellHelper.getPlayerMaxReagentAmount(player)), + (EntityPlayerMP) player); + + int drainLeft = drainTotal; + for (int i = 0; i < 4; i++) { + if (drainLeft <= 0) { + break; + } + Int3 jarLoc = this.getJarLocation(i); + TileEntity tile = world.getTileEntity(x + jarLoc.x(), y + jarLoc.y(), z + jarLoc.z()); + if (tile instanceof IReagentHandler container) { + ReagentStack drained = container + .drain(ForgeDirection.UP, new ReagentStack(reagent, drainLeft), true); + if (drained != null) { + drainLeft -= drained.amount; + world.markBlockForUpdate(x + jarLoc.x(), y + jarLoc.y(), z + jarLoc.z()); + world.addWeatherEffect( + new EntityLightningBolt(world, x + jarLoc.x(), y + jarLoc.y(), z + jarLoc.z())); } - - ritualStone.setActive(false); } - - break; } + + ritualStone.setActive(false); + break; } } @@ -166,7 +152,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList omegaRitual = new ArrayList(); + ArrayList omegaRitual = new ArrayList<>(); this.addCornerRunes(omegaRitual, 1, 0, RitualComponent.DUSK); this.addCornerRunes(omegaRitual, 2, 0, RitualComponent.DUSK); this.addCornerRunes(omegaRitual, 3, 0, RitualComponent.BLANK); @@ -231,17 +217,12 @@ public List getRitualComponentList() { } public Int3 getJarLocation(int i) { - switch (i) { - case 0: - return new Int3(-3, 0, 0); - case 1: - return new Int3(3, 0, 0); - case 2: - return new Int3(0, 0, -3); - case 3: - return new Int3(0, 0, 3); - default: - return new Int3(0, 0, 0); - } + return switch (i) { + case 0 -> new Int3(-3, 0, 0); + case 1 -> new Int3(3, 0, 0); + case 2 -> new Int3(0, 0, -3); + case 3 -> new Int3(0, 0, 3); + default -> new Int3(0, 0, 0); + }; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSpawnWard.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSpawnWard.java index c4cea72d9d..6fe7d8c612 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSpawnWard.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSpawnWard.java @@ -28,43 +28,41 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh()) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - int horizRange = 32; - int vertRange = 32; - - int dimension = world.provider.dimensionId; - - if (AlchemicalWizardryEventHooks.respawnMap.containsKey(new Integer(dimension))) { - List list = AlchemicalWizardryEventHooks.respawnMap.get(new Integer(dimension)); - if (list != null) { - if (!list.contains(new CoordAndRange(x, y, z, horizRange, vertRange))) { - boolean hasFoundAndRemoved = false; - for (CoordAndRange coords : list) { - int xLocation = coords.xCoord; - int yLocation = coords.yCoord; - int zLocation = coords.zCoord; - - if (xLocation == x && yLocation == y && zLocation == z) { - list.remove(coords); - hasFoundAndRemoved = true; - break; - } + return; + } + int horizRange = 32; + int vertRange = 32; + + int dimension = world.provider.dimensionId; + + if (AlchemicalWizardryEventHooks.respawnMap.containsKey(dimension)) { + List list = AlchemicalWizardryEventHooks.respawnMap.get(dimension); + if (list != null) { + if (!list.contains(new CoordAndRange(x, y, z, horizRange, vertRange))) { + for (CoordAndRange coords : list) { + int xLocation = coords.xCoord; + int yLocation = coords.yCoord; + int zLocation = coords.zCoord; + + if (xLocation == x && yLocation == y && zLocation == z) { + list.remove(coords); + break; } - list.add(new CoordAndRange(x, y, z, horizRange, vertRange)); } - } else { - list = new LinkedList(); list.add(new CoordAndRange(x, y, z, horizRange, vertRange)); - AlchemicalWizardryEventHooks.respawnMap.put(new Integer(dimension), list); } } else { - List list = new LinkedList(); + list = new LinkedList<>(); list.add(new CoordAndRange(x, y, z, horizRange, vertRange)); - AlchemicalWizardryEventHooks.respawnMap.put(new Integer(dimension), list); + AlchemicalWizardryEventHooks.respawnMap.put(dimension, list); } - - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); + } else { + List list = new LinkedList<>(); + list.add(new CoordAndRange(x, y, z, horizRange, vertRange)); + AlchemicalWizardryEventHooks.respawnMap.put(dimension, list); } + + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); } @Override @@ -74,7 +72,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList wardRitualRitual = new ArrayList(); + ArrayList wardRitualRitual = new ArrayList<>(); for (int i = 2; i <= 4; i++) { if (i <= 3) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSphereCreator.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSphereCreator.java index 00dfd55aa8..8487d95156 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSphereCreator.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSphereCreator.java @@ -40,21 +40,16 @@ public void performEffect(IMasterRitualStone ritualStone) { // boolean hasPotentia = this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, // potentiaDrain, false); - if (world.getTotalWorldTime() % 1 != 0) { - return; - } - if (currentEssence < this.getCostPerRefresh()) { SoulNetworkHandler.causeNauseaToPlayer(owner); } else { TileEntity tile = world.getTileEntity(x, y + 1, z); - if (!(tile instanceof IInventory)) { + if (!(tile instanceof IInventory inv)) { return; } int negYOffset = 0; - int radius = 0; - IInventory inv = (IInventory) tile; + int radius; int invSize = inv.getSizeInventory(); if (invSize < 1) { @@ -92,9 +87,9 @@ public void performEffect(IMasterRitualStone ritualStone) { int k = -radius; if (lastPos != null) { - j = Math.min(radius, Math.max(-radius, lastPos.yCoord)); - i = Math.min(radius, Math.max(-radius, lastPos.xCoord)); - k = Math.min(radius, Math.max(-radius, lastPos.zCoord)); + j = Math.min(radius, Math.max(-radius, lastPos.y())); + i = Math.min(radius, Math.max(-radius, lastPos.x())); + k = Math.min(radius, Math.max(-radius, lastPos.z())); } int yP = y + negYOffset; @@ -174,7 +169,7 @@ public void setLastPosition(NBTTagCompound tag, Int3 pos) { @Override public List getRitualComponentList() { - ArrayList magneticRitual = new ArrayList(); + ArrayList magneticRitual = new ArrayList<>(); magneticRitual.add(new RitualComponent(1, 0, 1, RitualComponent.EARTH)); magneticRitual.add(new RitualComponent(1, 0, -1, RitualComponent.EARTH)); magneticRitual.add(new RitualComponent(-1, 0, 1, RitualComponent.EARTH)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSummonMeteor.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSummonMeteor.java index 09655a909f..27f0a7ecee 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSummonMeteor.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSummonMeteor.java @@ -4,10 +4,7 @@ import java.util.List; import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; @@ -19,7 +16,6 @@ import WayofTime.alchemicalWizardry.api.rituals.RitualEffect; import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; import WayofTime.alchemicalWizardry.common.entity.projectile.EntityMeteor; -import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; import WayofTime.alchemicalWizardry.common.summoning.meteor.MeteorRegistry; public class RitualEffectSummonMeteor extends RitualEffect { @@ -45,41 +41,41 @@ public void performEffect(IMasterRitualStone ritualStone) { if (entities == null) return; for (EntityItem entityItem : entities) { - if (entityItem != null && MeteorRegistry.isValidMeteorFocusItem(entityItem.getEntityItem())) { - ItemStack stack = entityItem.getEntityItem(); - if (stack == null || stack.stackSize <= 0) continue; + if (entityItem == null || !MeteorRegistry.isValidMeteorFocusItem(entityItem.getEntityItem())) { + continue; + } + ItemStack stack = entityItem.getEntityItem(); + if (stack == null || stack.stackSize <= 0) continue; - int meteorID = MeteorRegistry.getMeteorIDForItem(stack); - int cost = MeteorRegistry.meteorList.get(meteorID).cost; + int meteorID = MeteorRegistry.getMeteorIDForItem(stack); + int cost = MeteorRegistry.meteorList.get(meteorID).cost; - if (currentEssence < cost) { - EntityPlayer entityOwner = SpellHelper.getPlayerForUsername(owner); - if (entityOwner != null) entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80)); - return; - } + if (currentEssence < cost) { + SoulNetworkHandler.causeNauseaToPlayer(owner); + return; + } - EntityMeteor meteor = new EntityMeteor(world, x + 0.5f, 257, z + 0.5f, meteorID); - meteor.motionY = -1.0f; + EntityMeteor meteor = new EntityMeteor(world, x + 0.5f, 257, z + 0.5f, meteorID); + meteor.motionY = -1.0f; - for (Reagent r : ReagentRegistry.reagentList.values()) { - if (this.canDrainReagent(ritualStone, r, 1000, true)) { - meteor.reagentList.add(r); - } + for (Reagent r : ReagentRegistry.reagentList.values()) { + if (this.canDrainReagent(ritualStone, r, 1000, true)) { + meteor.reagentList.add(r); } + } - stack.stackSize--; - - if (stack.stackSize <= 0) { - world.removeEntity(entityItem); - } else { - entityItem.setEntityItemStack(stack); - } + stack.stackSize--; - world.spawnEntityInWorld(meteor); - ritualStone.setActive(false); - SoulNetworkHandler.syphonFromNetwork(owner, cost); - break; + if (stack.stackSize <= 0) { + world.removeEntity(entityItem); + } else { + entityItem.setEntityItemStack(stack); } + + world.spawnEntityInWorld(meteor); + ritualStone.setActive(false); + SoulNetworkHandler.syphonFromNetwork(owner, cost); + break; } } @@ -90,7 +86,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList meteorRitual = new ArrayList(); + ArrayList meteorRitual = new ArrayList<>(); meteorRitual.add(new RitualComponent(2, 0, 0, RitualComponent.FIRE)); meteorRitual.add(new RitualComponent(-2, 0, 0, RitualComponent.FIRE)); meteorRitual.add(new RitualComponent(0, 0, 2, RitualComponent.FIRE)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSupression.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSupression.java index 1cd2cf5efa..15acd4bffe 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSupression.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSupression.java @@ -4,9 +4,6 @@ import java.util.List; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -54,45 +51,38 @@ public void performEffect(IMasterRitualStone ritualStone) { } if (currentEssence < this.getCostPerRefresh() * costMod) { - EntityPlayer entityOwner = SpellHelper.getPlayerForUsername(owner); - - if (entityOwner == null) { - return; - } - - entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80)); - } else { - for (int i = -radius; i <= radius; i++) { - for (int j = (expansion ? -radius : yIndex); j <= (expansion ? radius : yIndex); j++) { - for (int k = -radius; k <= radius; k++) { - if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f)) { - continue; - } + SoulNetworkHandler.causeNauseaToPlayer(owner); + return; + } + for (int i = -radius; i <= radius; i++) { + for (int j = (expansion ? -radius : yIndex); j <= (expansion ? radius : yIndex); j++) { + for (int k = -radius; k <= radius; k++) { + if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f)) { + continue; + } - Block block = world.getBlock(x + i, y + j, z + k); + Block block = world.getBlock(x + i, y + j, z + k); - if (SpellHelper.isBlockFluid(block)) { - TESpectralContainer - .createSpectralBlockAtLocation(world, x + i, y + j, z + k, 3 * masterRadius); - } else { - TileEntity tile = world.getTileEntity(x + i, y + j, z + k); - if (tile instanceof TESpectralContainer) { - ((TESpectralContainer) tile).resetDuration(3 * masterRadius); - } + if (SpellHelper.isBlockFluid(block)) { + TESpectralContainer.createSpectralBlockAtLocation(world, x + i, y + j, z + k, 3 * masterRadius); + } else { + TileEntity tile = world.getTileEntity(x + i, y + j, z + k); + if (tile instanceof TESpectralContainer container) { + container.resetDuration(3 * masterRadius); } } } } + } - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * costMod); + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * costMod); - if (world.getTotalWorldTime() % 100 == 0) { - if (hasAquasalus) { - this.canDrainReagent(ritualStone, ReagentRegistry.aquasalusReagent, aquasalusDrain, true); - } - if (hasAether) { - this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true); - } + if (world.getTotalWorldTime() % 100 == 0) { + if (hasAquasalus) { + this.canDrainReagent(ritualStone, ReagentRegistry.aquasalusReagent, aquasalusDrain, true); + } + if (hasAether) { + this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true); } } } @@ -104,7 +94,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList supressionRitual = new ArrayList(); + ArrayList supressionRitual = new ArrayList<>(); supressionRitual.add(new RitualComponent(2, 0, 2, RitualComponent.WATER)); supressionRitual.add(new RitualComponent(2, 0, -2, RitualComponent.WATER)); supressionRitual.add(new RitualComponent(-2, 0, 2, RitualComponent.WATER)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectUnbinding.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectUnbinding.java index b3bf295808..6bccbd807c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectUnbinding.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectUnbinding.java @@ -1,7 +1,6 @@ package WayofTime.alchemicalWizardry.common.rituals; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import net.minecraft.entity.effect.EntityLightningBolt; @@ -37,126 +36,109 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh()) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - int d0 = 0; - AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox( - (double) x, - (double) y + 1, - (double) z, - (double) (x + 1), - (double) (y + 2), - (double) (z + 1)).expand(d0, d0, d0); - List list = world.getEntitiesWithinAABB(EntityItem.class, axisalignedbb); - Iterator iterator = list.iterator(); - EntityItem item; - - boolean drain = false; - - while (iterator.hasNext()) { - final int sanctusDrain = 1000; - item = (EntityItem) iterator.next(); - ItemStack itemStack = item.getEntityItem(); - - if (itemStack == null) { - continue; - } + return; + } + AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(x, y + 1, z, x + 1, y + 2, z + 1); + List list = world.getEntitiesWithinAABB(EntityItem.class, axisalignedbb); + boolean drain = false; - boolean hasSanctus = this - .canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false); - if (hasSanctus) { - if (itemStack.getItem() instanceof IBindable && !IBindable.getOwnerName(itemStack).equals("")) { - world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z - 5)); - world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z + 5)); - world.addWeatherEffect(new EntityLightningBolt(world, x - 5, y + 1, z)); - world.addWeatherEffect(new EntityLightningBolt(world, x + 5, y + 1, z)); - - IBindable.setItemOwner(itemStack, ""); - this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, true); - drain = true; - ritualStone.setActive(false); - break; - } - } + for (EntityItem item : list) { + final int sanctusDrain = 1000; + ItemStack itemStack = item.getEntityItem(); - if (itemStack.getItem() == ModItems.boundHelmet) { - ritualStone.setVar1(5); - } else if (itemStack.getItem() == ModItems.boundPlate) { - ritualStone.setVar1(8); - } else if (itemStack.getItem() == ModItems.boundLeggings) { - ritualStone.setVar1(7); - } else if (itemStack.getItem() == ModItems.boundBoots) { - ritualStone.setVar1(4); - } else if (UnbindingRegistry.isRequiredItemValid(itemStack)) { - ritualStone.setVar1(UnbindingRegistry.getIndexForItem(itemStack) + 9); - } + if (itemStack == null) { + continue; + } - if (ritualStone.getVar1() > 0 && ritualStone.getVar1() <= 8) { - item.setDead(); - doLightning(world, x, y, z); - ItemStack[] inv = ((BoundArmour) itemStack.getItem()).getInternalInventory(itemStack); - int bloodSockets = 0; - if (itemStack.getItem() == ModItems.boundHelmet) { - bloodSockets = 5; - } else if (itemStack.getItem() == ModItems.boundPlate) { - bloodSockets = 8; - } else if (itemStack.getItem() == ModItems.boundLeggings) { - bloodSockets = 7; - } else if (itemStack.getItem() == ModItems.boundBoots) { - bloodSockets = 4; - } - if (inv != null) { - for (ItemStack internalItem : inv) { - if (internalItem != null) { - doLightning(world, x, y, z); - EntityItem newItem = new EntityItem( - world, - x + 0.5, - y + 1, - z + 0.5, - internalItem.copy()); - world.spawnEntityInWorld(newItem); - } - } - } + boolean hasSanctus = this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false); + if (hasSanctus) { + if (itemStack.getItem() instanceof IBindable && !IBindable.getOwnerName(itemStack).isEmpty()) { + world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z - 5)); + world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z + 5)); + world.addWeatherEffect(new EntityLightningBolt(world, x - 5, y + 1, z)); + world.addWeatherEffect(new EntityLightningBolt(world, x + 5, y + 1, z)); - EntityItem newItem = new EntityItem( - world, - x + 0.5, - y + 1, - z + 0.5, - new ItemStack(ModBlocks.bloodSocket, bloodSockets)); - world.spawnEntityInWorld(newItem); - ritualStone.setActive(false); + IBindable.setItemOwner(itemStack, ""); + this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, true); drain = true; + ritualStone.setActive(false); break; - } else if (ritualStone.getVar1() >= 9) { - item.setDead(); - doLightning(world, x, y, z); - List spawnedItem = UnbindingRegistry.getOutputForIndex(ritualStone.getVar1() - 9); - - if (spawnedItem != null) { - for (ItemStack itemStack1 : spawnedItem) { - EntityItem newItem = new EntityItem(world, x + 0.5, y + 1, z + 0.5, itemStack1.copy()); + } + } + + int sockets = getBloodSockets(itemStack); + if (sockets > 0) { + ritualStone.setVar1(sockets); + } else if (UnbindingRegistry.isRequiredItemValid(itemStack)) { + ritualStone.setVar1(UnbindingRegistry.getIndexForItem(itemStack) + 9); + } + + if (ritualStone.getVar1() > 0 && ritualStone.getVar1() <= 8 + && itemStack.getItem() instanceof BoundArmour armor) { + item.setDead(); + doLightning(world, x, y, z); + ItemStack[] inv = armor.getInternalInventory(itemStack); + int bloodSockets = getBloodSockets(itemStack); + if (inv != null) { + for (ItemStack internalItem : inv) { + if (internalItem != null) { + doLightning(world, x, y, z); + EntityItem newItem = new EntityItem(world, x + 0.5, y + 1, z + 0.5, internalItem.copy()); world.spawnEntityInWorld(newItem); } } + } - ritualStone.setActive(false); - drain = true; - break; + EntityItem newItem = new EntityItem( + world, + x + 0.5, + y + 1, + z + 0.5, + new ItemStack(ModBlocks.bloodSocket, bloodSockets)); + world.spawnEntityInWorld(newItem); + ritualStone.setActive(false); + drain = true; + break; + } else if (ritualStone.getVar1() >= 9) { + item.setDead(); + doLightning(world, x, y, z); + List spawnedItem = UnbindingRegistry.getOutputForIndex(ritualStone.getVar1() - 9); + + if (spawnedItem != null) { + for (ItemStack itemStack1 : spawnedItem) { + EntityItem newItem = new EntityItem(world, x + 0.5, y + 1, z + 0.5, itemStack1.copy()); + world.spawnEntityInWorld(newItem); + } } - } - if (drain) { - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); + ritualStone.setActive(false); + drain = true; + break; } } + if (drain) { + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); + } + if (world.rand.nextInt(10) == 0) { SpellHelper.sendIndexedParticleToAllAround(world, x, y, z, 20, world.provider.dimensionId, 1, x, y, z); } } + private static int getBloodSockets(ItemStack itemStack) { + if (itemStack.getItem() == ModItems.boundHelmet) { + return 5; + } else if (itemStack.getItem() == ModItems.boundPlate) { + return 8; + } else if (itemStack.getItem() == ModItems.boundLeggings) { + return 7; + } else if (itemStack.getItem() == ModItems.boundBoots) { + return 4; + } + return 0; + } + private void doLightning(World world, int x, int y, int z) { world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z - 5)); world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z + 5)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectVeilOfEvil.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectVeilOfEvil.java index a64b74168c..648dc5b618 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectVeilOfEvil.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectVeilOfEvil.java @@ -28,43 +28,37 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh()) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - int horizRange = 32; - int vertRange = 32; - - int dimension = world.provider.dimensionId; - - if (AlchemicalWizardryEventHooks.forceSpawnMap.containsKey(new Integer(dimension))) { - List list = AlchemicalWizardryEventHooks.forceSpawnMap.get(new Integer(dimension)); - if (list != null) { - if (!list.contains(new CoordAndRange(x, y, z, horizRange, vertRange))) { - boolean hasFoundAndRemoved = false; - for (CoordAndRange coords : list) { - int xLocation = coords.xCoord; - int yLocation = coords.yCoord; - int zLocation = coords.zCoord; - - if (xLocation == x && yLocation == y && zLocation == z) { - list.remove(coords); - hasFoundAndRemoved = true; - break; - } + return; + } + int horizRange = 32; + int vertRange = 32; + + int dimension = world.provider.dimensionId; + + if (AlchemicalWizardryEventHooks.forceSpawnMap.containsKey(dimension)) { + List list = AlchemicalWizardryEventHooks.forceSpawnMap.get(dimension); + if (list != null) { + if (!list.contains(new CoordAndRange(x, y, z, horizRange, vertRange))) { + for (CoordAndRange coords : list) { + if (coords.xCoord == x && coords.yCoord == y && coords.zCoord == z) { + list.remove(coords); + break; } - list.add(new CoordAndRange(x, y, z, horizRange, vertRange)); } - } else { - list = new LinkedList(); list.add(new CoordAndRange(x, y, z, horizRange, vertRange)); - AlchemicalWizardryEventHooks.forceSpawnMap.put(new Integer(dimension), list); } } else { - List list = new LinkedList(); + list = new LinkedList<>(); list.add(new CoordAndRange(x, y, z, horizRange, vertRange)); - AlchemicalWizardryEventHooks.forceSpawnMap.put(new Integer(dimension), list); + AlchemicalWizardryEventHooks.forceSpawnMap.put(dimension, list); } - - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); + } else { + List list = new LinkedList<>(); + list.add(new CoordAndRange(x, y, z, horizRange, vertRange)); + AlchemicalWizardryEventHooks.forceSpawnMap.put(dimension, list); } + + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh()); } @Override @@ -74,7 +68,7 @@ public int getCostPerRefresh() { @Override public List getRitualComponentList() { - ArrayList veilRitual = new ArrayList(); + ArrayList veilRitual = new ArrayList<>(); veilRitual.add(new RitualComponent(1, 0, 2, RitualComponent.DUSK)); veilRitual.add(new RitualComponent(2, 0, 1, RitualComponent.DUSK)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectWater.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectWater.java index 4f1fa7a91a..fddb9200fd 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectWater.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectWater.java @@ -33,6 +33,7 @@ public class RitualEffectWater extends RitualEffect { public static final int reductusDrain = 2; public static final int crystallosDrain = 10; + @Override public void performEffect(IMasterRitualStone ritualStone) { String owner = ritualStone.getOwner(); @@ -71,8 +72,7 @@ public void performEffect(IMasterRitualStone ritualStone) { int range = 10; List list = SpellHelper.getEntitiesInRange(world, x + 0.5, y + 0.5, z + 0.5, range, range); for (Entity entity : list) { - if (entity instanceof EntityLivingBase) { - EntityLivingBase livingEntity = (EntityLivingBase) entity; + if (entity instanceof EntityLivingBase livingEntity) { if (livingEntity == SpellHelper.getPlayerForUsername(owner)) { continue; @@ -118,11 +118,10 @@ public void performEffect(IMasterRitualStone ritualStone) { return; } TileEntity tile = world.getTileEntity(x, y + 1, z); - if (tile instanceof IFluidHandler) { - int amount = ((IFluidHandler) tile) - .fill(ForgeDirection.DOWN, new FluidStack(FluidRegistry.WATER, 1000), false); + if (tile instanceof IFluidHandler handler) { + int amount = handler.fill(ForgeDirection.DOWN, new FluidStack(FluidRegistry.WATER, 1000), false); if (amount >= 1000) { - ((IFluidHandler) tile).fill(ForgeDirection.DOWN, new FluidStack(FluidRegistry.WATER, 1000), true); + handler.fill(ForgeDirection.DOWN, new FluidStack(FluidRegistry.WATER, 1000), true); this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, true); @@ -168,13 +167,14 @@ public void performEffect(IMasterRitualStone ritualStone) { } } + @Override public int getCostPerRefresh() { return AlchemicalWizardry.ritualCostWater[1]; } @Override public List getRitualComponentList() { - ArrayList waterRitual = new ArrayList(); + ArrayList waterRitual = new ArrayList<>(); waterRitual.add(new RitualComponent(-1, 0, 1, 1)); waterRitual.add(new RitualComponent(-1, 0, -1, 1)); waterRitual.add(new RitualComponent(1, 0, -1, 1)); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectWellOfSuffering.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectWellOfSuffering.java index 646038c943..ff7a0d4b02 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectWellOfSuffering.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectWellOfSuffering.java @@ -40,20 +40,18 @@ public void performEffect(IMasterRitualStone ritualStone) { } IBloodAltar tileAltar = null; - boolean testFlag = false; for (int i = -5; i <= 5; i++) { for (int j = -5; j <= 5; j++) { for (int k = -10; k <= 10; k++) { - if (world.getTileEntity(x + i, y + k, z + j) instanceof IBloodAltar) { - tileAltar = (IBloodAltar) world.getTileEntity(x + i, y + k, z + j); - testFlag = true; + if (world.getTileEntity(x + i, y + k, z + j) instanceof IBloodAltar altar) { + tileAltar = altar; } } } } - if (!testFlag) { + if (tileAltar == null) { return; } @@ -72,30 +70,30 @@ public void performEffect(IMasterRitualStone ritualStone) { if (currentEssence < this.getCostPerRefresh() * list.size()) { SoulNetworkHandler.causeNauseaToPlayer(owner); - } else { - for (EntityLivingBase livingEntity : list) { - if (!livingEntity.isEntityAlive() || livingEntity instanceof EntityPlayer - || AlchemicalWizardry.wellBlacklist.contains(livingEntity.getClass())) { - continue; - } + return; + } + for (EntityLivingBase livingEntity : list) { + if (!livingEntity.isEntityAlive() || livingEntity instanceof EntityPlayer + || AlchemicalWizardry.wellBlacklist.contains(livingEntity.getClass())) { + continue; + } - hasOffensa = hasOffensa - && this.canDrainReagent(ritualStone, ReagentRegistry.offensaReagent, offensaDrain, true); + hasOffensa = hasOffensa + && this.canDrainReagent(ritualStone, ReagentRegistry.offensaReagent, offensaDrain, true); - if (livingEntity.attackEntityFrom(DamageSource.outOfWorld, hasOffensa ? 2 : 1)) { - hasTennebrae = hasTennebrae - && this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tennebraeDrain, true); + if (livingEntity.attackEntityFrom(DamageSource.outOfWorld, hasOffensa ? 2 : 1)) { + hasTennebrae = hasTennebrae + && this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tennebraeDrain, true); - entityCount++; - tileAltar.sacrificialDaggerCall(amount * (hasTennebrae ? 2 : 1) * (hasOffensa ? 2 : 1), true); - } + entityCount++; + tileAltar.sacrificialDaggerCall(amount * (hasTennebrae ? 2 : 1) * (hasOffensa ? 2 : 1), true); } + } - SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * entityCount); + SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * entityCount); - if (hasPotentia) { - this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, true); - } + if (hasPotentia) { + this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, true); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/routing/RoutingFocusLogicLimit.java b/src/main/java/WayofTime/alchemicalWizardry/common/routing/RoutingFocusLogicLimit.java index bb95e50945..2d77d83d75 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/routing/RoutingFocusLogicLimit.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/routing/RoutingFocusLogicLimit.java @@ -5,6 +5,7 @@ public class RoutingFocusLogicLimit extends RoutingFocusLogic implements ILimitingLogic { + @Override public int getRoutingLimit() { return 0; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/routing/RoutingFocusLogicMatchNBT.java b/src/main/java/WayofTime/alchemicalWizardry/common/routing/RoutingFocusLogicMatchNBT.java index fe77a1d028..46add83006 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/routing/RoutingFocusLogicMatchNBT.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/routing/RoutingFocusLogicMatchNBT.java @@ -11,6 +11,7 @@ public class RoutingFocusLogicMatchNBT extends RoutingFocusLogic { + @Override public boolean getDefaultMatch(ItemStack keyStack, ItemStack checkedStack) { return (keyStack != null && keyStack.getItem() != null && checkedStack != null diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellHelper.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellHelper.java index 18aff51a82..3876f7de7f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellHelper.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellHelper.java @@ -1,6 +1,7 @@ package WayofTime.alchemicalWizardry.common.spell.complex.effect; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Random; import java.util.regex.Pattern; @@ -89,45 +90,39 @@ public static void smeltBlockInWorld(World world, int posX, int posY, int posZ) } public static boolean canPlayerSeeAlchemy(EntityPlayer player) { - if (player != null) { - ItemStack stack = player.getCurrentArmor(3); - if (stack != null) { - Item item = stack.getItem(); - if (item instanceof IAlchemyGoggles - && ((IAlchemyGoggles) item).showIngameHUD(player.worldObj, stack, player)) { - return true; - } - } - - ItemStack heldStack = player.getHeldItem(); - if (heldStack != null && heldStack.getItem() instanceof IReagentManipulator) { + if (player == null) { + return false; + } + ItemStack stack = player.getCurrentArmor(3); + if (stack != null) { + Item item = stack.getItem(); + if (item instanceof IAlchemyGoggles + && ((IAlchemyGoggles) item).showIngameHUD(player.worldObj, stack, player)) { return true; } } - return false; + ItemStack heldStack = player.getHeldItem(); + return heldStack != null && heldStack.getItem() instanceof IReagentManipulator; } public static boolean canPlayerSeeLPBar(EntityPlayer player) { - if (player != null) { - for (int i = 0; i < 4; i++) { - ItemStack stack = player.getCurrentArmor(i); - if (stack != null) { - Item item = stack.getItem(); - if (item instanceof ILPGauge && ((ILPGauge) item).canSeeLPBar(stack)) { - return true; - } + if (player == null) { + return false; + } + for (int i = 0; i < 4; i++) { + ItemStack stack = player.getCurrentArmor(i); + if (stack != null) { + Item item = stack.getItem(); + if (item instanceof ILPGauge && ((ILPGauge) item).canSeeLPBar(stack)) { + return true; } } - - ItemStack heldStack = player.getHeldItem(); - - if (heldStack != null && heldStack.getItem() instanceof SigilDivination) { - return true; - } } - return false; + ItemStack heldStack = player.getHeldItem(); + + return heldStack != null && heldStack.getItem() instanceof SigilDivination; } public static List getEntitiesInRange(World world, double posX, double posY, double posZ, @@ -175,7 +170,8 @@ public static Vec3 getEntityBlockVector(Entity entity) { int posY = (int) entity.posY; int posZ = (int) Math.round(entity.posZ - 0.5f); - return entity.getLookVec().createVectorHelper(posX, posY, posZ); + entity.getLookVec(); + return Vec3.createVectorHelper(posX, posY, posZ); } public static ForgeDirection getDirectionForLookVector(Vec3 lookVec) { @@ -333,7 +329,7 @@ public static boolean isFakePlayer(World world, EntityPlayer player) { return !world.isRemote && isFakePlayer(player); } - private static final Pattern FAKE_PLAYER_PATTERN = Pattern.compile("^(?:\\[.*\\])|(?:ComputerCraft)$"); + private static final Pattern FAKE_PLAYER_PATTERN = Pattern.compile("^\\[.*]|ComputerCraft$"); public static boolean isFakePlayer(EntityPlayer player) { return player instanceof FakePlayer || FAKE_PLAYER_PATTERN.matcher(SpellHelper.getUsername(player)).matches(); @@ -387,7 +383,7 @@ public static ItemStack getDustForOre(ItemStack item) { ArrayList items = OreDictionary.getOres(dustName); - if (items != null && items.size() >= 1) { + if (items != null && !items.isEmpty()) { return (items.get(0).copy()); } } @@ -409,30 +405,19 @@ public static MovingObjectPosition raytraceFromEntity(World world, Entity player } public static String getNumeralForInt(int num) { - switch (num) { - case 1: - return "I"; - case 2: - return "II"; - case 3: - return "III"; - case 4: - return "IV"; - case 5: - return "V"; - case 6: - return "VI"; - case 7: - return "VII"; - case 8: - return "VIII"; - case 9: - return "IX"; - case 10: - return "X"; - default: - return ""; - } + return switch (num) { + case 1 -> "I"; + case 2 -> "II"; + case 3 -> "III"; + case 4 -> "IV"; + case 5 -> "V"; + case 6 -> "VI"; + case 7 -> "VII"; + case 8 -> "VIII"; + case 9 -> "IX"; + case 10 -> "X"; + default -> ""; + }; } /** @@ -629,15 +614,13 @@ public static ItemStack insertStackIntoInventory(ItemStack stack, IInventory inv boolean[] canBeInserted = new boolean[inventory.getSizeInventory()]; - if (inventory instanceof ISidedInventory) { - int[] array = ((ISidedInventory) inventory).getAccessibleSlotsFromSide(dir.ordinal()); + if (inventory instanceof ISidedInventory inv) { + int[] array = inv.getAccessibleSlotsFromSide(dir.ordinal()); for (int in : array) { - canBeInserted[in] = ((ISidedInventory) inventory).canInsertItem(in, stack, dir.ordinal()); + canBeInserted[in] = inv.canInsertItem(in, stack, dir.ordinal()); } } else { - for (int i = 0; i < canBeInserted.length; i++) { - canBeInserted[i] = true; - } + Arrays.fill(canBeInserted, true); } int numberMatching = 0; @@ -684,15 +667,13 @@ public static ItemStack insertStackIntoInventory(ItemStack stack, IInventory inv public static int getNumberOfItemsInInventory(IInventory inventory, ForgeDirection dir) { boolean[] canBeInserted = new boolean[inventory.getSizeInventory()]; - if (inventory instanceof ISidedInventory) { - int[] array = ((ISidedInventory) inventory).getAccessibleSlotsFromSide(dir.ordinal()); + if (inventory instanceof ISidedInventory inv) { + int[] array = inv.getAccessibleSlotsFromSide(dir.ordinal()); for (int in : array) { canBeInserted[in] = true; } } else { - for (int i = 0; i < canBeInserted.length; i++) { - canBeInserted[i] = true; - } + Arrays.fill(canBeInserted, true); } int amountOfItems = 0; @@ -739,10 +720,8 @@ public static Entity teleportEntitySameDim(double x, double y, double z, Entity return player; } else { WorldServer world = (WorldServer) entity.worldObj; - if (entity != null) { - entity.setPosition(x, y, z); - entity.timeUntilPortal = 150; - } + entity.setPosition(x, y, z); + entity.timeUntilPortal = 150; world.resetUpdateEntityTick(); entity.worldObj.playSoundEffect(x, y, z, "mob.endermen.portal", 1.0F, 1.0F); return entity; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/cse/earth/CSEToolDefaultEarth.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/cse/earth/CSEToolDefaultEarth.java index c6e0d19210..d4378294d7 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/cse/earth/CSEToolDefaultEarth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/cse/earth/CSEToolDefaultEarth.java @@ -25,25 +25,14 @@ public void modifyParadigm(SpellParadigm parad) { if (parad instanceof SpellParadigmTool) { String toolClass = "pickaxe"; - float digSpeed = 7.0f; - - switch (this.powerEnhancement) { - case 1: - digSpeed = 9.0f; - break; - case 2: - digSpeed = 12.0f; - break; - case 3: - digSpeed = 16.0f; - break; - case 4: - digSpeed = 21.0f; - break; - case 5: - digSpeed = 27.0f; - break; - } + float digSpeed = switch (this.powerEnhancement) { + case 1 -> 9.0f; + case 2 -> 12.0f; + case 3 -> 16.0f; + case 4 -> 21.0f; + case 5 -> 27.0f; + default -> 7.0f; + }; ((SpellParadigmTool) parad).setDigSpeed(toolClass, digSpeed); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/cse/earth/CSEToolDefensiveEarth.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/cse/earth/CSEToolDefensiveEarth.java index db95e8ec93..74882fbc86 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/cse/earth/CSEToolDefensiveEarth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/cse/earth/CSEToolDefensiveEarth.java @@ -25,25 +25,14 @@ public void modifyParadigm(SpellParadigm parad) { if (parad instanceof SpellParadigmTool) { String toolClass = "shovel"; - float digSpeed = 7.0f; - - switch (this.powerEnhancement) { - case 1: - digSpeed = 9.0f; - break; - case 2: - digSpeed = 12.0f; - break; - case 3: - digSpeed = 16.0f; - break; - case 4: - digSpeed = 21.0f; - break; - case 5: - digSpeed = 27.0f; - break; - } + float digSpeed = switch (this.powerEnhancement) { + case 1 -> 9.0f; + case 2 -> 12.0f; + case 3 -> 16.0f; + case 4 -> 21.0f; + case 5 -> 27.0f; + default -> 7.0f; + }; ((SpellParadigmTool) parad).setDigSpeed(toolClass, digSpeed); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/cse/wind/CSEToolDefaultWind.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/cse/wind/CSEToolDefaultWind.java index 77fd31f4be..d90851ed7d 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/cse/wind/CSEToolDefaultWind.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/cse/wind/CSEToolDefaultWind.java @@ -25,25 +25,14 @@ public void modifyParadigm(SpellParadigm parad) { if (parad instanceof SpellParadigmTool) { String toolClass = "axe"; - float digSpeed = 7.0f; - - switch (this.powerEnhancement) { - case 1: - digSpeed = 9.0f; - break; - case 2: - digSpeed = 12.0f; - break; - case 3: - digSpeed = 16.0f; - break; - case 4: - digSpeed = 21.0f; - break; - case 5: - digSpeed = 27.0f; - break; - } + float digSpeed = switch (this.powerEnhancement) { + case 1 -> 9.0f; + case 2 -> 12.0f; + case 3 -> 16.0f; + case 4 -> 21.0f; + case 5 -> 27.0f; + default -> 7.0f; + }; ((SpellParadigmTool) parad).setDigSpeed(toolClass, digSpeed); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/earth/ToolOffensiveEarth.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/earth/ToolOffensiveEarth.java index 9e16ce9348..cff9f1b33c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/earth/ToolOffensiveEarth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/earth/ToolOffensiveEarth.java @@ -21,7 +21,7 @@ public ToolOffensiveEarth(int power, int potency, int cost) { @Override public List handleItemsOnBlockBroken(ItemStack toolStack, List itemList) { - List newList = new LinkedList(); + List newList = new LinkedList<>(); for (ItemStack stack : itemList) { if (stack != null && stack.getItem() instanceof ItemBlock diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/fire/ToolDefaultFire.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/fire/ToolDefaultFire.java index 63be504db8..c6f0961027 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/fire/ToolDefaultFire.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/fire/ToolDefaultFire.java @@ -16,7 +16,7 @@ public ToolDefaultFire(int power, int potency, int cost) { @Override public List handleItemsOnBlockBroken(ItemStack toolStack, List itemList) { - LinkedList newList = new LinkedList(); + LinkedList newList = new LinkedList<>(); for (ItemStack item : itemList) { ItemStack newItem = FurnaceRecipes.smelting().getSmeltingResult(item); if (newItem != null) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/tool/DigAreaEffect.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/tool/DigAreaEffect.java index 79976659ea..9f79c7757b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/tool/DigAreaEffect.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/tool/DigAreaEffect.java @@ -4,6 +4,7 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; @@ -11,6 +12,7 @@ import WayofTime.alchemicalWizardry.api.items.ItemSpellMultiTool; import WayofTime.alchemicalWizardry.api.spell.IDigAreaEffect; import WayofTime.alchemicalWizardry.api.spell.SpellParadigmTool; +import WayofTime.alchemicalWizardry.common.items.BoundPickaxe; import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; public class DigAreaEffect implements IDigAreaEffect { @@ -49,70 +51,59 @@ public int digSurroundingArea(ItemStack container, World world, EntityPlayer pla public void breakBlock(ItemStack container, World world, EntityPlayer player, float blockHardness, int x, int y, int z, ItemSpellMultiTool itemTool) { - int hlvl = -1; - Block localBlock = world.getBlock(x, y, z); - int localMeta = world.getBlockMetadata(x, y, z); - String toolClass = localBlock.getHarvestTool(localMeta); - if (toolClass != null && itemTool.getHarvestLevel(container, toolClass) != -1) - hlvl = localBlock.getHarvestLevel(localMeta); - int toolLevel = itemTool.getHarvestLevel(container, toolClass); - - float localHardness = localBlock == null ? Float.MAX_VALUE : localBlock.getBlockHardness(world, x, y, z); - - if (hlvl <= toolLevel && localHardness - this.getHardnessDifference() <= blockHardness) { - boolean cancelHarvest = false; - - if (!cancelHarvest) { - if (localBlock != null && !(localHardness < 0)) { - boolean isEffective = false; - - String localToolClass = itemTool.getToolClassForMaterial(localBlock.getMaterial()); - - if (localToolClass != null && itemTool.getHarvestLevel(container, toolClass) - >= localBlock.getHarvestLevel(localMeta)) { - isEffective = true; - } - - if (localBlock.getMaterial().isToolNotRequired()) { - isEffective = true; - } - - if (!player.capabilities.isCreativeMode) { - if (isEffective) { - if (localBlock.removedByPlayer(world, player, x, y, z)) { - localBlock.onBlockDestroyedByPlayer(world, x, y, z, localMeta); - } - localBlock.onBlockHarvested(world, x, y, z, localMeta, player); - if (localHardness > 0f) - itemTool.onBlockDestroyed(container, world, localBlock, x, y, z, player); - - List items = SpellHelper.getItemsFromBlock( - world, - localBlock, - x, - y, - z, - localMeta, - itemTool.getSilkTouch(container), - itemTool.getFortuneLevel(container)); - - SpellParadigmTool parad = itemTool.loadParadigmFromStack(container); - items = parad.handleItemList(container, items); - - if (!world.isRemote) { - SpellHelper.spawnItemListInWorld(items, world, x + 0.5f, y + 0.5f, z + 0.5f); - } - - world.func_147479_m(x, y, z); - } else {} - - } else { - world.setBlockToAir(x, y, z); - world.func_147479_m(x, y, z); - } - } - } + Block block = world.getBlock(x, y, z); + if (block == null || block == Blocks.air) return; + int meta = world.getBlockMetadata(x, y, z); + String blockRequiredTool = block.getHarvestTool(meta); + if (blockRequiredTool != null && itemTool.getHarvestLevel(container, blockRequiredTool) != -1 + && block.getHarvestLevel(meta) > itemTool.getHarvestLevel(container, blockRequiredTool)) { + return; + } + + float localHardness = block.getBlockHardness(world, x, y, z); + + if (localHardness - this.getHardnessDifference() > blockHardness + || BoundPickaxe.checkPermissions(world, x, y, z, block, meta, player) + || localHardness < 0) { + return; + } + + String localToolClass = itemTool.getToolClassForMaterial(block.getMaterial()); + + if (player.capabilities.isCreativeMode) { + world.setBlockToAir(x, y, z); + world.func_147479_m(x, y, z); + return; + } + if ((localToolClass == null + || itemTool.getHarvestLevel(container, blockRequiredTool) < block.getHarvestLevel(meta)) + && !block.getMaterial().isToolNotRequired()) { + return; } + if (block.removedByPlayer(world, player, x, y, z, true)) { + block.onBlockDestroyedByPlayer(world, x, y, z, meta); + } + block.onBlockHarvested(world, x, y, z, meta, player); + if (localHardness > 0f) itemTool.onBlockDestroyed(container, world, block, x, y, z, player); + + List items = SpellHelper.getItemsFromBlock( + world, + block, + x, + y, + z, + meta, + itemTool.getSilkTouch(container), + itemTool.getFortuneLevel(container)); + + SpellParadigmTool parad = itemTool.loadParadigmFromStack(container); + items = parad.handleItemList(container, items); + + if (!world.isRemote) { + SpellHelper.spawnItemListInWorld(items, world, x + 0.5f, y + 0.5f, z + 0.5f); + } + + world.func_147479_m(x, y, z); } public float getHardnessDifference() { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/tool/DigAreaTunnel.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/tool/DigAreaTunnel.java index 4a9ec9d850..9ebdfcff06 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/tool/DigAreaTunnel.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/tool/DigAreaTunnel.java @@ -30,7 +30,7 @@ public int digSurroundingArea(ItemStack container, World world, EntityPlayer pla return 0; } - List vectorLine = new LinkedList(); + List vectorLine = new LinkedList<>(); double initialX = blockPos.blockX; double initialY = blockPos.blockY; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/tool/RightClickTunnel.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/tool/RightClickTunnel.java index d438a6861a..0df68c78f5 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/tool/RightClickTunnel.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/tool/RightClickTunnel.java @@ -30,7 +30,7 @@ public int onRightClickBlock(ItemStack stack, EntityLivingBase weilder, World wo return 0; } - List vectorLine = new LinkedList(); + List vectorLine = new LinkedList<>(); double initialX = mop.blockX; double initialY = mop.blockY; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/HomSpell.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/HomSpell.java index 52bd2a4c26..1ae72c6c98 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/HomSpell.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/HomSpell.java @@ -2,7 +2,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; public abstract class HomSpell implements ISimpleSpell { @@ -19,20 +18,16 @@ public HomSpell() { } @Override - public abstract ItemStack onOffensiveRangedRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer); + public abstract ItemStack onOffensiveRangedRightClick(ItemStack item, World world, EntityPlayer player); @Override - public abstract ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer); + public abstract ItemStack onOffensiveMeleeRightClick(ItemStack item, World world, EntityPlayer player); @Override - public abstract ItemStack onDefensiveRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer); + public abstract ItemStack onDefensiveRightClick(ItemStack item, World world, EntityPlayer player); @Override - public abstract ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer); + public abstract ItemStack onEnvironmentalRightClick(ItemStack item, World world, EntityPlayer player); public int getOffensiveRangedEnergy() { return offensiveRangedEnergy; @@ -56,74 +51,4 @@ public void setEnergies(int offensiveRanged, int offensiveMelee, int defensive, this.defensiveEnergy = defensive; this.environmentalEnergy = environmental; } - - public void setSpellParadigm(ItemStack itemStack, int paradigm) { - if (itemStack.getTagCompound() == null) { - itemStack.setTagCompound(new NBTTagCompound()); - } - - itemStack.getTagCompound().setInteger("paradigm", paradigm); - } - - public int getSpellParadigm(ItemStack itemStack) { - if (itemStack.getTagCompound() == null) { - itemStack.setTagCompound(new NBTTagCompound()); - } - - return (itemStack.getTagCompound().getInteger("paradigm")); - } - - // @Override - public ItemStack useSpell(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - int paradigm = getSpellParadigm(par1ItemStack); - - if (par3EntityPlayer.isSneaking()) { - if (paradigm < 3) { - this.setSpellParadigm(par1ItemStack, paradigm + 1); - } else { - this.setSpellParadigm(par1ItemStack, 0); - } - - return par1ItemStack; - } - - switch (paradigm) { - case 0: - return this.onOffensiveRangedRightClick(par1ItemStack, par2World, par3EntityPlayer); - - case 1: - return this.onOffensiveMeleeRightClick(par1ItemStack, par2World, par3EntityPlayer); - - case 2: - return this.onDefensiveRightClick(par1ItemStack, par2World, par3EntityPlayer); - - case 3: - return this.onEnvironmentalRightClick(par1ItemStack, par2World, par3EntityPlayer); - } - - return par1ItemStack; - } - - // @Override - // public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean - // par4) - // { - // if (!(par1ItemStack.getTagCompound() == null)) - // { - // if (!par1ItemStack.getTagCompound().getString("ownerName").equals("")) - // { - // par3List.add("Current owner: " + par1ItemStack.getTagCompound().getString("ownerName")); - // } - // - // par3List.add("Current paradigm: " + this.getSpellParadigm(par1ItemStack)); - // } - // } - - public int getDimensionID(ItemStack itemStack) { - if (itemStack.getTagCompound() == null) { - itemStack.setTagCompound(new NBTTagCompound()); - } - - return itemStack.getTagCompound().getInteger("dimensionId"); - } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/HomSpellComponent.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/HomSpellComponent.java index f820991179..88751d4b62 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/HomSpellComponent.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/HomSpellComponent.java @@ -2,21 +2,4 @@ import net.minecraft.item.ItemStack; -public class HomSpellComponent { - - public HomSpell spell; - public ItemStack item; - - public HomSpellComponent(ItemStack item, HomSpell spell) { - this.item = item; - this.spell = spell; - } - - public HomSpell getSpell() { - return spell; - } - - public ItemStack getItemStack() { - return this.item; - } -} +public record HomSpellComponent(ItemStack item, HomSpell spell) {} diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/HomSpellRegistry.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/HomSpellRegistry.java index f01734e252..2fedf1cb5b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/HomSpellRegistry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/HomSpellRegistry.java @@ -8,7 +8,7 @@ public class HomSpellRegistry { - public static List spellList = new ArrayList(); + public static List spellList = new ArrayList<>(); public static void registerBasicSpell(ItemStack item, HomSpell spell) { spellList.add(new HomSpellComponent(item, spell)); @@ -20,22 +20,10 @@ public static HomSpell getSpellForItemStack(ItemStack testItem) { } for (HomSpellComponent hsc : spellList) { - ItemStack item = hsc.getItemStack(); - - if (item != null) { - if (item.getItem() instanceof ItemBlock) { - if (testItem.getItem() instanceof ItemBlock) { - if (testItem.getItem() == item.getItem()) { - return hsc.getSpell(); - } - } - } else { - if (!(testItem.getItem() instanceof ItemBlock)) { - if (testItem.getItem() == item.getItem()) { - return hsc.getSpell(); - } - } - } + ItemStack item = hsc.item(); + + if (item != null && item.getItem() instanceof ItemBlock && testItem.getItem() == item.getItem()) { + return hsc.spell(); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/ISimpleSpell.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/ISimpleSpell.java index e267ca1003..c25f01de77 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/ISimpleSpell.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/ISimpleSpell.java @@ -6,11 +6,11 @@ public interface ISimpleSpell { - ItemStack onOffensiveRangedRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer); + ItemStack onOffensiveRangedRightClick(ItemStack item, World world, EntityPlayer player); - ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer); + ItemStack onOffensiveMeleeRightClick(ItemStack item, World world, EntityPlayer player); - ItemStack onDefensiveRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer); + ItemStack onDefensiveRightClick(ItemStack item, World world, EntityPlayer player); - ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer); + ItemStack onEnvironmentalRightClick(ItemStack item, World world, EntityPlayer player); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellEarthBender.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellEarthBender.java index 8cfa2994f7..a426e67e40 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellEarthBender.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellEarthBender.java @@ -23,162 +23,145 @@ public SpellEarthBender() { } @Override - public ItemStack onOffensiveRangedRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveRangedRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveRangedEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveRangedEnergy()); } - par2World.spawnEntityInWorld(new MudProjectile(par2World, par3EntityPlayer, 8, false)); - par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - return par1ItemStack; + world.spawnEntityInWorld(new MudProjectile(world, player, 8, false)); + world.playSoundAtEntity(player, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + return item; } @Override - public ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveMeleeRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveMeleeEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveMeleeEnergy()); } - if (!par2World.isRemote) { + if (!world.isRemote) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { - par2World.spawnEntityInWorld( + world.spawnEntityInWorld( new MudProjectile( - par2World, - par3EntityPlayer, + world, + player, 3, 3, - par3EntityPlayer.posX, - par3EntityPlayer.posY + par3EntityPlayer.getEyeHeight(), - par3EntityPlayer.posZ, - par3EntityPlayer.rotationYaw + i * 10F, - par3EntityPlayer.rotationPitch + j * 5F, + player.posX, + player.posY + player.getEyeHeight(), + player.posZ, + player.rotationYaw + i * 10F, + player.rotationPitch + j * 5F, true)); } } } - return par1ItemStack; + return item; } @Override - public ItemStack onDefensiveRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onDefensiveRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getDefensiveEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getDefensiveEnergy()); } - double xCoord = par3EntityPlayer.posX; - double yCoord = par3EntityPlayer.posY; - double zCoord = par3EntityPlayer.posZ; - int posX = (int) xCoord; - int posY = (int) yCoord; - int posZ = (int) zCoord; + int posX = (int) player.posX; + int posY = (int) player.posY; + int posZ = (int) player.posZ; Block blockID = Blocks.stone; - if (par2World.isAirBlock(posX, posY + 3, posZ)) { - par2World.setBlock(posX, posY + 3, posZ, Blocks.glass); + if (world.isAirBlock(posX, posY + 3, posZ)) { + world.setBlock(posX, posY + 3, posZ, Blocks.glass); } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { - if (par2World.isAirBlock(posX + i - 1, posY + j, posZ - 2)) { - par2World.setBlock(posX + i - 1, posY + j, posZ - 2, blockID); + if (world.isAirBlock(posX + i - 1, posY + j, posZ - 2)) { + world.setBlock(posX + i - 1, posY + j, posZ - 2, blockID); } - if (par2World.isAirBlock(posX + 2, posY + j, posZ - 1 + i)) { - par2World.setBlock(posX + 2, posY + j, posZ - 1 + i, blockID); + if (world.isAirBlock(posX + 2, posY + j, posZ - 1 + i)) { + world.setBlock(posX + 2, posY + j, posZ - 1 + i, blockID); } - if (par2World.isAirBlock(posX - i + 1, posY + j, posZ + 2)) { - par2World.setBlock(posX - i + 1, posY + j, posZ + 2, blockID); + if (world.isAirBlock(posX - i + 1, posY + j, posZ + 2)) { + world.setBlock(posX - i + 1, posY + j, posZ + 2, blockID); } - if (par2World.isAirBlock(posX - 2, posY + j, posZ + 1 - i)) { - par2World.setBlock(posX - 2, posY + j, posZ + 1 - i, blockID); + if (world.isAirBlock(posX - 2, posY + j, posZ + 1 - i)) { + world.setBlock(posX - 2, posY + j, posZ + 1 - i, blockID); } - { - if (par2World.isAirBlock(posX - 1 + i, posY + 3, posZ - 1 + j)) { - par2World.setBlock(posX - 1 + i, posY + 3, posZ - 1 + j, blockID); - } + if (world.isAirBlock(posX - 1 + i, posY + 3, posZ - 1 + j)) { + world.setBlock(posX - 1 + i, posY + 3, posZ - 1 + j, blockID); } } } for (int i = 0; i < 20; i++) { SpellHelper.sendParticleToAllAround( - par2World, - xCoord, - yCoord, - zCoord, + world, + player.posX, + player.posY, + player.posZ, 30, - par2World.provider.dimensionId, + world.provider.dimensionId, "mobSpell", - xCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, - yCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, - zCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, + player.posX + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, + player.posY + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, + player.posZ + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, 0.0F, 0.410F, 1.0F); } - return par1ItemStack; + return item; } @Override - public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onEnvironmentalRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getEnvironmentalEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getEnvironmentalEnergy()); } int range = 3; - if (!par2World.isRemote) { + if (!world.isRemote) { for (int i = -range; i <= range; i++) { for (int j = -1; j <= 1; j++) { for (int k = -range; k <= range; k++) { - if (par2World.getBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ + k) == Blocks.water - || par2World.getBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ + k) == Blocks.flowing_water) { - int x = par2World.rand.nextInt(2); - - if (x == 0) { - par2World.setBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ + k, + Block block = world + .getBlock((int) player.posX + i, (int) player.posY + j, (int) player.posZ + k); + if (block == Blocks.water || block == Blocks.flowing_water) { + if (world.rand.nextInt(2) == 0) { + world.setBlock( + (int) player.posX + i, + (int) player.posY + j, + (int) player.posZ + k, Blocks.sand); } else { - par2World.setBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ + k, + world.setBlock( + (int) player.posX + i, + (int) player.posY + j, + (int) player.posZ + k, Blocks.dirt); } } @@ -187,27 +170,23 @@ public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2Wo } } - double xCoord = par3EntityPlayer.posX; - double yCoord = par3EntityPlayer.posY; - double zCoord = par3EntityPlayer.posZ; - for (int i = 0; i < 16; i++) { SpellHelper.sendParticleToAllAround( - par2World, - xCoord, - yCoord, - zCoord, + world, + player.posX, + player.posY, + player.posZ, 30, - par2World.provider.dimensionId, + world.provider.dimensionId, "mobSpell", - xCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, - yCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, - zCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, + player.posX + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, + player.posY + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, + player.posZ + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, 0.0F, 0.410F, 1.0F); } - return par1ItemStack; + return item; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellExplosions.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellExplosions.java index b63acfa3dc..c12bf337bf 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellExplosions.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellExplosions.java @@ -20,91 +20,86 @@ public SpellExplosions() { } @Override - public ItemStack onOffensiveRangedRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveRangedRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveRangedEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveRangedEnergy()); } - par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + world.playSoundAtEntity(player, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - if (!par2World.isRemote) { - par2World.spawnEntityInWorld(new ExplosionProjectile(par2World, par3EntityPlayer, 6, true)); + if (!world.isRemote) { + world.spawnEntityInWorld(new ExplosionProjectile(world, player, 6, true)); } - return par1ItemStack; + return item; } @Override - public ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveMeleeRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveMeleeEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveMeleeEnergy()); } int distance = 4; - double yaw = par3EntityPlayer.rotationYaw / 180 * Math.PI; - double pitch = par3EntityPlayer.rotationPitch / 180 * Math.PI; - par2World.createExplosion( - par3EntityPlayer, - par3EntityPlayer.posX + Math.sin(yaw) * Math.cos(pitch) * (-distance), - par3EntityPlayer.posY + par3EntityPlayer.getEyeHeight() + Math.sin(-pitch) * distance, - par3EntityPlayer.posZ + Math.cos(yaw) * Math.cos(pitch) * distance, + double yaw = player.rotationYaw / 180 * Math.PI; + double pitch = player.rotationPitch / 180 * Math.PI; + world.createExplosion( + player, + player.posX + Math.sin(yaw) * Math.cos(pitch) * (-distance), + player.posY + player.getEyeHeight() + Math.sin(-pitch) * distance, + player.posZ + Math.cos(yaw) * Math.cos(pitch) * distance, (float) (3), true); - return par1ItemStack; + return item; } @Override - public ItemStack onDefensiveRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onDefensiveRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getDefensiveEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getDefensiveEnergy()); } int distance = 4; - par2World.createExplosion( - par3EntityPlayer, - par3EntityPlayer.posX, - par3EntityPlayer.posY + par3EntityPlayer.getEyeHeight(), - par3EntityPlayer.posZ, + world.createExplosion( + player, + player.posX, + player.posY + player.getEyeHeight(), + player.posZ, (float) (distance), false); - return par1ItemStack; + return item; } @Override - public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onEnvironmentalRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getEnvironmentalEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getEnvironmentalEnergy()); } int radius = 3; for (int i = 0; i < 360; i += 36) { - par2World.createExplosion( - par3EntityPlayer, - par3EntityPlayer.posX + Math.cos(i) * radius, - par3EntityPlayer.posY, - par3EntityPlayer.posZ + Math.sin(i) * radius, + world.createExplosion( + player, + player.posX + Math.cos(i) * radius, + player.posY, + player.posZ + Math.sin(i) * radius, (float) (2), true); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellFireBurst.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellFireBurst.java index 95aca9a6c8..40da577054 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellFireBurst.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellFireBurst.java @@ -1,6 +1,5 @@ package WayofTime.alchemicalWizardry.common.spell.simple; -import java.util.Iterator; import java.util.List; import java.util.Random; @@ -26,124 +25,111 @@ public SpellFireBurst() { } @Override - public ItemStack onOffensiveRangedRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveRangedRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveRangedEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveRangedEnergy()); } - par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + world.playSoundAtEntity(player, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - if (!par2World.isRemote) { - FireProjectile proj = new FireProjectile(par2World, par3EntityPlayer, 7); - par2World.spawnEntityInWorld(proj); + if (!world.isRemote) { + FireProjectile proj = new FireProjectile(world, player, 7); + world.spawnEntityInWorld(proj); } - return par1ItemStack; + return item; } @Override - public ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveMeleeRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveMeleeEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveMeleeEnergy()); } - par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + world.playSoundAtEntity(player, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - if (!par2World.isRemote) { + if (!world.isRemote) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { - par2World.spawnEntityInWorld( + world.spawnEntityInWorld( new FireProjectile( - par2World, - par3EntityPlayer, + world, + player, 8, 2, - par3EntityPlayer.posX, - par3EntityPlayer.posY + par3EntityPlayer.getEyeHeight(), - par3EntityPlayer.posZ, - par3EntityPlayer.rotationYaw + i * 10F, - par3EntityPlayer.rotationPitch + j * 10F)); + player.posX, + player.posY + player.getEyeHeight(), + player.posZ, + player.rotationYaw + i * 10F, + player.rotationPitch + j * 10F)); } } } - return par1ItemStack; + return item; } @Override - public ItemStack onDefensiveRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onDefensiveRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getDefensiveEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getDefensiveEnergy()); } - par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + world.playSoundAtEntity(player, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); int d0 = 2; AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox( - par3EntityPlayer.posX, - par3EntityPlayer.posY, - par3EntityPlayer.posZ, - (par3EntityPlayer.posX + 1), - (par3EntityPlayer.posY + 2), - (par3EntityPlayer.posZ + 1)).expand(d0, d0, d0); - List list = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityLivingBase entityLiving = (EntityLivingBase) iterator.next(); - - if (entityLiving instanceof EntityPlayer) { - if (entityLiving.equals(par3EntityPlayer)) { - continue; - } + player.posX, + player.posY, + player.posZ, + player.posX + 1, + player.posY + 2, + player.posZ + 1).expand(d0, d0, d0); + List list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); + + for (EntityLivingBase entityLiving : list) { + if (entityLiving instanceof EntityPlayer && entityLiving.equals(player)) { + continue; } entityLiving.setFire(100); entityLiving.attackEntityFrom(DamageSource.inFire, 2); } - return par1ItemStack; + return item; } @Override - public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onEnvironmentalRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getEnvironmentalEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getEnvironmentalEnergy()); } - par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + world.playSoundAtEntity(player, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { for (int k = -1; k <= 1; k++) { - if (par2World.isAirBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ + k)) { - if (par2World.rand.nextFloat() < 0.8F) { - par2World.setBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ + k, + if (world.isAirBlock((int) player.posX + i, (int) player.posY + j, (int) player.posZ + k)) { + if (world.rand.nextFloat() < 0.8F) { + world.setBlock( + (int) player.posX + i, + (int) player.posY + j, + (int) player.posZ + k, Blocks.fire); } } @@ -151,6 +137,6 @@ public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2Wo } } - return par1ItemStack; + return item; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellFrozenWater.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellFrozenWater.java index a335eb9388..16ae5f693e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellFrozenWater.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellFrozenWater.java @@ -22,171 +22,124 @@ public SpellFrozenWater() { } @Override - public ItemStack onOffensiveRangedRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveRangedRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveRangedEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveRangedEnergy()); } - par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + world.playSoundAtEntity(player, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - if (!par2World.isRemote) { - par2World.spawnEntityInWorld(new IceProjectile(par2World, par3EntityPlayer, 6)); + if (!world.isRemote) { + world.spawnEntityInWorld(new IceProjectile(world, player, 6)); } - return par1ItemStack; + return item; } @Override - public ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveMeleeRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveMeleeEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveMeleeEnergy()); } for (int i = -2; i <= 2; i++) { - par2World.spawnEntityInWorld( + world.spawnEntityInWorld( new IceProjectile( - par2World, - par3EntityPlayer, + world, + player, 6, 2, - par3EntityPlayer.posX, - par3EntityPlayer.posY + par3EntityPlayer.getEyeHeight(), - par3EntityPlayer.posZ, - par3EntityPlayer.rotationYaw + i * 5F, - par3EntityPlayer.rotationPitch)); + player.posX, + player.posY + player.getEyeHeight(), + player.posZ, + player.rotationYaw + i * 5F, + player.rotationPitch)); } - return par1ItemStack; + return item; } @Override - public ItemStack onDefensiveRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, getDefensiveEnergy()); + public ItemStack onDefensiveRightClick(ItemStack item, World world, EntityPlayer player) { + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, getDefensiveEnergy()); } - float yaw = par3EntityPlayer.rotationYaw; - float pitch = par3EntityPlayer.rotationPitch; + float yaw = player.rotationYaw; + float pitch = player.rotationPitch; int range = 2; if (pitch > 40F) { for (int i = -range; i <= range; i++) { for (int j = -range; j <= range; j++) { - if (par2World.isAirBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY - 1, - (int) par3EntityPlayer.posZ + j)) { - par2World.setBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY - 1, - (int) par3EntityPlayer.posZ + j, - Blocks.ice); + if (world.isAirBlock((int) player.posX + i, (int) player.posY - 1, (int) player.posZ + j)) { + world.setBlock((int) player.posX + i, (int) player.posY - 1, (int) player.posZ + j, Blocks.ice); } } } - return par1ItemStack; + return item; } else if (pitch < -40F) { for (int i = -range; i <= range; i++) { for (int j = -range; j <= range; j++) { - if (par2World.isAirBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY + 3, - (int) par3EntityPlayer.posZ + j)) { - par2World.setBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY + 3, - (int) par3EntityPlayer.posZ + j, - Blocks.ice); + if (world.isAirBlock((int) player.posX + i, (int) player.posY + 3, (int) player.posZ + j)) { + world.setBlock((int) player.posX + i, (int) player.posY + 3, (int) player.posZ + j, Blocks.ice); } } } - return par1ItemStack; + return item; } if ((yaw >= 315 && yaw < 360) || (yaw >= 0 && yaw < 45)) { for (int i = -range; i <= range; i++) { for (int j = 0; j < range * 2 + 1; j++) { - if (par2World.isAirBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ + 2)) { - par2World.setBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ + 2, - Blocks.ice); + if (world.isAirBlock((int) player.posX + i, (int) player.posY + j, (int) player.posZ + 2)) { + world.setBlock((int) player.posX + i, (int) player.posY + j, (int) player.posZ + 2, Blocks.ice); } } } } else if (yaw >= 45 && yaw < 135) { for (int i = -range; i <= range; i++) { for (int j = 0; j < range * 2 + 1; j++) { - if (par2World.isAirBlock( - (int) par3EntityPlayer.posX - 2, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ + i)) { - par2World.setBlock( - (int) par3EntityPlayer.posX - 2, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ + i, - Blocks.ice); + if (world.isAirBlock((int) player.posX - 2, (int) player.posY + j, (int) player.posZ + i)) { + world.setBlock((int) player.posX - 2, (int) player.posY + j, (int) player.posZ + i, Blocks.ice); } } } } else if (yaw >= 135 && yaw < 225) { for (int i = -range; i <= range; i++) { for (int j = 0; j < range * 2 + 1; j++) { - if (par2World.isAirBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ - 2)) { - par2World.setBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ - 2, - Blocks.ice); + if (world.isAirBlock((int) player.posX + i, (int) player.posY + j, (int) player.posZ - 2)) { + world.setBlock((int) player.posX + i, (int) player.posY + j, (int) player.posZ - 2, Blocks.ice); } } } } else { for (int i = -range; i <= range; i++) { for (int j = 0; j < range * 2 + 1; j++) { - if (par2World.isAirBlock( - (int) par3EntityPlayer.posX + 2, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ + i)) { - par2World.setBlock( - (int) par3EntityPlayer.posX + 2, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ + i, - Blocks.ice); + if (world.isAirBlock((int) player.posX + 2, (int) player.posY + j, (int) player.posZ + i)) { + world.setBlock((int) player.posX + 2, (int) player.posY + j, (int) player.posZ + i, Blocks.ice); } } } } - return par1ItemStack; + return item; } @Override - public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onEnvironmentalRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } int radius = 3; @@ -194,20 +147,18 @@ public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2Wo for (int i = -radius; i <= radius; i++) { for (int j = -radius; j <= radius; j++) { for (int k = -radius; k <= radius; k++) { - Block block = par2World.getBlock( - (int) par3EntityPlayer.posX + i - 1, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ + k); + Block block = world + .getBlock((int) player.posX + i - 1, (int) player.posY + j, (int) player.posZ + k); if (block == Blocks.water || block == Blocks.flowing_water) { - par2World.setBlock( - (int) par3EntityPlayer.posX + i - 1, - (int) par3EntityPlayer.posY + j, - (int) par3EntityPlayer.posZ + k, + world.setBlock( + (int) player.posX + i - 1, + (int) player.posY + j, + (int) player.posZ + k, Blocks.ice); } } } } - return par1ItemStack; + return item; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellHolyBlast.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellHolyBlast.java index 9257c1a050..a7d44675e7 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellHolyBlast.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellHolyBlast.java @@ -1,6 +1,5 @@ package WayofTime.alchemicalWizardry.common.spell.simple; -import java.util.Iterator; import java.util.List; import java.util.Random; @@ -26,62 +25,54 @@ public SpellHolyBlast() { } @Override - public ItemStack onOffensiveRangedRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveRangedRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveRangedEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveRangedEnergy()); } - par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + world.playSoundAtEntity(player, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - if (!par2World.isRemote) { - par2World.spawnEntityInWorld(new HolyProjectile(par2World, par3EntityPlayer, 8)); + if (!world.isRemote) { + world.spawnEntityInWorld(new HolyProjectile(world, player, 8)); } - return par1ItemStack; + return item; } @Override - public ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveMeleeRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveMeleeEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveMeleeEnergy()); } int distance = 2; - double yaw = par3EntityPlayer.rotationYaw / 180 * Math.PI; - double pitch = par3EntityPlayer.rotationPitch / 180 * Math.PI; - double xCoord = par3EntityPlayer.posX + Math.sin(yaw) * Math.cos(pitch) * (-distance); - double yCoord = par3EntityPlayer.posY + par3EntityPlayer.getEyeHeight() + Math.sin(-pitch) * distance; - double zCoord = par3EntityPlayer.posZ + Math.cos(yaw) * Math.cos(pitch) * distance; - float d0 = 0.5f; + double yaw = player.rotationYaw / 180 * Math.PI; + double pitch = player.rotationPitch / 180 * Math.PI; + double v = Math.sin(yaw) * Math.cos(pitch) * (-distance); + double v1 = Math.cos(yaw) * Math.cos(pitch) * distance; + double xCoord = player.posX + v; + double yCoord = player.posY + player.getEyeHeight() + Math.sin(-pitch) * distance; + double zCoord = player.posZ + v1; AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox( - par3EntityPlayer.posX - 0.5 + Math.sin(yaw) * Math.cos(pitch) * (-distance), - par3EntityPlayer.posY + par3EntityPlayer.getEyeHeight() + Math.sin(-pitch) * distance, - par3EntityPlayer.posZ - 0.5 + Math.cos(yaw) * Math.cos(pitch) * distance, - par3EntityPlayer.posX + Math.sin(yaw) * Math.cos(pitch) * (-distance) + 0.5, - par3EntityPlayer.posY + par3EntityPlayer.getEyeHeight() + Math.sin(-pitch) * distance + 1, - par3EntityPlayer.posZ + Math.cos(yaw) * Math.cos(pitch) * distance + 0.5).expand(d0, d0, d0); - List list = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityLivingBase entityLiving = (EntityLivingBase) iterator.next(); - - if (entityLiving instanceof EntityPlayer) { - if (entityLiving.equals(par3EntityPlayer)) { - continue; - } + xCoord - 0.5 + v, + yCoord + player.getEyeHeight() + Math.sin(-pitch) * distance, + zCoord - 0.5 + v1, + xCoord + v + 0.5, + yCoord + player.getEyeHeight() + Math.sin(-pitch) * distance + 1, + zCoord + v1 + 0.5).expand(0.5f, 0.5f, 0.5f); + List list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); + + for (EntityLivingBase entityLiving : list) { + if (entityLiving instanceof EntityPlayer && entityLiving.equals(player)) { + continue; } int i = 1; @@ -89,19 +80,19 @@ public ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2W if (entityLiving.isEntityUndead()) { i = 3; } - entityLiving.attackEntityFrom(DamageSource.causePlayerDamage(par3EntityPlayer), 5 * i); + entityLiving.attackEntityFrom(DamageSource.causePlayerDamage(player), 5 * i); } - par2World.createExplosion(par3EntityPlayer, xCoord, yCoord, zCoord, (float) (1), false); + world.createExplosion(player, xCoord, yCoord, zCoord, (float) (1), false); for (int i = 0; i < 5; i++) { SpellHelper.sendParticleToAllAround( - par2World, + world, xCoord, yCoord, zCoord, 30, - par2World.provider.dimensionId, + world.provider.dimensionId, "mobSpell", xCoord + itemRand.nextFloat() - itemRand.nextFloat(), yCoord + itemRand.nextFloat() - itemRand.nextFloat(), @@ -111,67 +102,61 @@ public ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2W 1.0F); } - return par1ItemStack; + return item; } @Override - public ItemStack onDefensiveRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onDefensiveRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getDefensiveEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getDefensiveEnergy()); } - if (!par2World.isRemote) { + if (!world.isRemote) { for (int i = 0; i < 360; i += 18) { - par2World.spawnEntityInWorld( + world.spawnEntityInWorld( new HolyProjectile( - par2World, - par3EntityPlayer, + world, + player, 8, 3, - par3EntityPlayer.posX, - par3EntityPlayer.posY + (par3EntityPlayer.height / 2), - par3EntityPlayer.posZ, + player.posX, + player.posY + (player.height / 2), + player.posZ, i, 0)); } } - return par1ItemStack; + return item; } @Override - public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onEnvironmentalRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getEnvironmentalEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getEnvironmentalEnergy()); } int d0 = 3; AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox( - par3EntityPlayer.posX, - par3EntityPlayer.posY, - par3EntityPlayer.posZ, - (par3EntityPlayer.posX + 1), - (par3EntityPlayer.posY + 2), - (par3EntityPlayer.posZ + 1)).expand(d0, d0, d0); - List list = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityLivingBase entityLiving = (EntityLivingBase) iterator.next(); - - if (entityLiving instanceof EntityPlayer) { - if (entityLiving.equals(par3EntityPlayer)) { - continue; - } + player.posX, + player.posY, + player.posZ, + (player.posX + 1), + (player.posY + 2), + (player.posZ + 1)).expand(d0, d0, d0); + List list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); + + for (EntityLivingBase entityLiving : list) { + if (entityLiving instanceof EntityPlayer && entityLiving.equals(player)) { + continue; } int i = 1; @@ -179,28 +164,22 @@ public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2Wo if (entityLiving.isEntityUndead()) { i = 3; } - entityLiving.attackEntityFrom(DamageSource.causePlayerDamage(par3EntityPlayer), 5 * i); + entityLiving.attackEntityFrom(DamageSource.causePlayerDamage(player), 5 * i); } - par2World.createExplosion( - par3EntityPlayer, - par3EntityPlayer.posX, - par3EntityPlayer.posY, - par3EntityPlayer.posZ, - (float) (2), - false); - double xCoord = par3EntityPlayer.posX; - double yCoord = par3EntityPlayer.posY; - double zCoord = par3EntityPlayer.posZ; + world.createExplosion(player, player.posX, player.posY, player.posZ, (float) (2), false); + double xCoord = player.posX; + double yCoord = player.posY; + double zCoord = player.posZ; for (int i = 0; i < 20; i++) { SpellHelper.sendParticleToAllAround( - par2World, + world, xCoord, yCoord, zCoord, 30, - par2World.provider.dimensionId, + world.provider.dimensionId, "mobSpell", xCoord + itemRand.nextFloat() - itemRand.nextFloat(), yCoord + itemRand.nextFloat() - itemRand.nextFloat(), @@ -210,6 +189,6 @@ public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2Wo 1.0F); } - return par1ItemStack; + return item; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellLightningBolt.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellLightningBolt.java index 6163c6c36c..25778ee0b6 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellLightningBolt.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellLightningBolt.java @@ -22,59 +22,55 @@ public SpellLightningBolt() { } @Override - public ItemStack onOffensiveRangedRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveRangedRightClick(ItemStack item, World world, EntityPlayer player) { + if (IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveRangedEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveRangedEnergy()); } - par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + world.playSoundAtEntity(player, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - if (!par2World.isRemote) { - par2World.spawnEntityInWorld(new LightningBoltProjectile(par2World, par3EntityPlayer, 8, false)); + if (!world.isRemote) { + world.spawnEntityInWorld(new LightningBoltProjectile(world, player, 8, false)); } - return par1ItemStack; + return item; } @Override - public ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { + public ItemStack onOffensiveMeleeRightClick(ItemStack item, World world, EntityPlayer player) { // TODO Make it work better...? - if (IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + if (IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveMeleeEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveMeleeEnergy()); } - double xCoord = par3EntityPlayer.posX; - double yCoord = par3EntityPlayer.posY; - double zCoord = par3EntityPlayer.posZ; - par2World.getWorldInfo().setRaining(true); - if (par2World.isRemote) { - par2World.setRainStrength(1.0f); - par2World.setThunderStrength(1.0f); + double xCoord = player.posX; + double yCoord = player.posY; + double zCoord = player.posZ; + world.getWorldInfo().setRaining(true); + if (world.isRemote) { + world.setRainStrength(1.0f); + world.setThunderStrength(1.0f); } - par2World.getWorldInfo().setThunderTime(0); - par2World.getWorldInfo().setThundering(true); + world.getWorldInfo().setThunderTime(0); + world.getWorldInfo().setThundering(true); for (int i = 0; i < 5; i++) { SpellHelper.sendParticleToAllAround( - par2World, + world, xCoord, yCoord, zCoord, 30, - par2World.provider.dimensionId, + world.provider.dimensionId, "mobSpell", xCoord + itemRand.nextFloat() - itemRand.nextFloat(), yCoord + itemRand.nextFloat() - itemRand.nextFloat(), @@ -84,27 +80,27 @@ public ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2W 1.0F); } - return par1ItemStack; + return item; } @Override - public ItemStack onDefensiveRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onDefensiveRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getDefensiveEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getDefensiveEnergy()); } - double xCoord = par3EntityPlayer.posX; - double yCoord = par3EntityPlayer.posY; - double zCoord = par3EntityPlayer.posZ; + double xCoord = player.posX; + double yCoord = player.posY; + double zCoord = player.posZ; for (int i = 0; i < 5; i++) { - par2World.addWeatherEffect( + world.addWeatherEffect( new EntityLightningBolt( - par2World, + world, xCoord + itemRand.nextInt(64) - 32, yCoord + itemRand.nextInt(8) - 8, zCoord + itemRand.nextInt(64) - 32)); @@ -112,12 +108,12 @@ public ItemStack onDefensiveRightClick(ItemStack par1ItemStack, World par2World, for (int i = 0; i < 8; i++) { SpellHelper.sendParticleToAllAround( - par2World, + world, xCoord, yCoord, zCoord, 30, - par2World.provider.dimensionId, + world.provider.dimensionId, "mobSpell", xCoord + itemRand.nextFloat() - itemRand.nextFloat(), yCoord + itemRand.nextFloat() - itemRand.nextFloat(), @@ -127,24 +123,23 @@ public ItemStack onDefensiveRightClick(ItemStack par1ItemStack, World par2World, 1.0F); } - return par1ItemStack; + return item; } @Override - public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onEnvironmentalRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getEnvironmentalEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getEnvironmentalEnergy()); } - if (!par2World.isRemote) { - par2World.spawnEntityInWorld(new LightningBoltProjectile(par2World, par3EntityPlayer, 8, true)); + if (!world.isRemote) { + world.spawnEntityInWorld(new LightningBoltProjectile(world, player, 8, true)); } - return par1ItemStack; + return item; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellTeleport.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellTeleport.java index ae8dbd62a3..ce01d15220 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellTeleport.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellTeleport.java @@ -1,6 +1,5 @@ package WayofTime.alchemicalWizardry.common.spell.simple; -import java.util.Iterator; import java.util.List; import java.util.Random; @@ -30,130 +29,113 @@ public SpellTeleport() { } @Override - public ItemStack onOffensiveRangedRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveRangedRightClick(ItemStack item, World world, EntityPlayer player) { + if (IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveRangedEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveRangedEnergy()); } - par2World.spawnEntityInWorld(new TeleportProjectile(par2World, par3EntityPlayer, 8, true)); - par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - return par1ItemStack; + world.spawnEntityInWorld(new TeleportProjectile(world, player, 8, true)); + world.playSoundAtEntity(player, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + return item; } @Override - public ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveMeleeRightClick(ItemStack item, World world, EntityPlayer player) { + if (IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveMeleeEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveMeleeEnergy()); } - par2World.spawnEntityInWorld(new TeleportProjectile(par2World, par3EntityPlayer, 8, false)); - return par1ItemStack; + world.spawnEntityInWorld(new TeleportProjectile(world, player, 8, false)); + return item; } @Override - public ItemStack onDefensiveRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onDefensiveRightClick(ItemStack item, World world, EntityPlayer player) { + if (IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getDefensiveEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getDefensiveEnergy()); } - double xCoord = par3EntityPlayer.posX; - double yCoord = par3EntityPlayer.posY; - double zCoord = par3EntityPlayer.posZ; - SpellTeleport.teleportRandomly(par3EntityPlayer, 128); + SpellTeleport.teleportRandomly(player, 128); for (int i = 0; i < 20; i++) { SpellHelper.sendParticleToAllAround( - par2World, - xCoord, - yCoord, - zCoord, + world, + player.posX, + player.posY, + player.posZ, 30, - par2World.provider.dimensionId, + world.provider.dimensionId, "portal", - xCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 2, - yCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 2, - zCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 2, + player.posX + (itemRand.nextFloat() - itemRand.nextFloat()) * 2, + player.posY + (itemRand.nextFloat() - itemRand.nextFloat()) * 2, + player.posZ + (itemRand.nextFloat() - itemRand.nextFloat()) * 2, itemRand.nextFloat(), itemRand.nextFloat(), itemRand.nextFloat()); } - return par1ItemStack; + return item; } @Override - public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onEnvironmentalRightClick(ItemStack item, World world, EntityPlayer player) { + if (IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getEnvironmentalEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getEnvironmentalEnergy()); } - if (!par2World.isRemote) { + if (!world.isRemote) { int d0 = 3; AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox( - par3EntityPlayer.posX, - par3EntityPlayer.posY, - par3EntityPlayer.posZ, - (par3EntityPlayer.posX + 1), - (par3EntityPlayer.posY + 2), - (par3EntityPlayer.posZ + 1)).expand(d0, d0, d0); - List list = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityLivingBase entityLiving = (EntityLivingBase) iterator.next(); - - if (entityLiving instanceof EntityPlayer) { - if (entityLiving.equals(par3EntityPlayer)) { - continue; - } + player.posX, + player.posY, + player.posZ, + (player.posX + 1), + (player.posY + 2), + (player.posZ + 1)).expand(d0, d0, d0); + List list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); + + for (EntityLivingBase entityLiving : list) { + if (entityLiving instanceof EntityPlayer && entityLiving.equals(player)) { + continue; } SpellTeleport.teleportRandomly(entityLiving, 128); } } - double xCoord = par3EntityPlayer.posX; - double yCoord = par3EntityPlayer.posY; - double zCoord = par3EntityPlayer.posZ; - for (int i = 0; i < 32; i++) { SpellHelper.sendParticleToAllAround( - par2World, - xCoord, - yCoord, - zCoord, + world, + player.posX, + player.posY, + player.posZ, 30, - par2World.provider.dimensionId, + world.provider.dimensionId, "portal", - xCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 2, - yCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 2, - zCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 2, + player.posX + (itemRand.nextFloat() - itemRand.nextFloat()) * 2, + player.posY + (itemRand.nextFloat() - itemRand.nextFloat()) * 2, + player.posZ + (itemRand.nextFloat() - itemRand.nextFloat()) * 2, itemRand.nextFloat(), itemRand.nextFloat(), itemRand.nextFloat()); } - return par1ItemStack; + return item; } public static boolean teleportRandomly(EntityLivingBase entityLiving, double distance) { @@ -173,89 +155,81 @@ public static boolean teleportRandomly(EntityLivingBase entityLiving, double dis i++; } - if (i >= 100) { - return false; - } - - return true; + return i < 100; } - private static boolean teleportTo(EntityLivingBase entityLiving, double par1, double par3, double par5, - double lastX, double lastY, double lastZ) { - EnderTeleportEvent event = new EnderTeleportEvent(entityLiving, par1, par3, par5, 0); + public static boolean teleportTo(EntityLivingBase entityLiving, double x, double y, double z, double lastX, + double lastY, double lastZ) { + EnderTeleportEvent event = new EnderTeleportEvent(entityLiving, x, y, z, 0); if (MinecraftForge.EVENT_BUS.post(event)) { return false; } SpellTeleport.moveEntityViaTeleport(entityLiving, event.targetX, event.targetY, event.targetZ); - boolean flag = false; - int i = MathHelper.floor_double(entityLiving.posX); - int j = MathHelper.floor_double(entityLiving.posY); - int k = MathHelper.floor_double(entityLiving.posZ); + boolean clear = false; + int posX = MathHelper.floor_double(entityLiving.posX); + int posY = MathHelper.floor_double(entityLiving.posY); + int posZ = MathHelper.floor_double(entityLiving.posZ); Block l; - if (entityLiving.worldObj.blockExists(i, j, k)) { - boolean flag1 = false; + if (entityLiving.worldObj.blockExists(posX, posY, posZ)) { + boolean foundFloor = false; - while (!flag1 && j > 0) { - l = entityLiving.worldObj.getBlock(i, j - 1, k); + while (!foundFloor && posY > 0) { + l = entityLiving.worldObj.getBlock(posX, posY - 1, posZ); if (l != null && l.getMaterial().blocksMovement()) { - flag1 = true; + foundFloor = true; } else { --entityLiving.posY; - --j; + --posY; } } - if (flag1) { + if (foundFloor) { SpellTeleport .moveEntityViaTeleport(entityLiving, entityLiving.posX, entityLiving.posY, entityLiving.posZ); if (entityLiving.worldObj.getCollidingBoundingBoxes(entityLiving, entityLiving.boundingBox).isEmpty() && !entityLiving.worldObj.isAnyLiquid(entityLiving.boundingBox)) { - flag = true; + clear = true; } } } - if (!flag) { + if (!clear) { SpellTeleport.moveEntityViaTeleport(entityLiving, lastX, lastY, lastZ); return false; - } else { - short short1 = 128; - - for (j = 0; j < short1; ++j) { - double d6 = (double) j / ((double) short1 - 1.0D); - float f = (entityLiving.worldObj.rand.nextFloat() - 0.5F) * 0.2F; - float f1 = (entityLiving.worldObj.rand.nextFloat() - 0.5F) * 0.2F; - float f2 = (entityLiving.worldObj.rand.nextFloat() - 0.5F) * 0.2F; - double d7 = lastX + (entityLiving.posX - lastX) * d6 - + (entityLiving.worldObj.rand.nextDouble() - 0.5D) * (double) entityLiving.width * 2.0D; - double d8 = lastY + (entityLiving.posY - lastY) * d6 - + entityLiving.worldObj.rand.nextDouble() * (double) entityLiving.height; - double d9 = lastZ + (entityLiving.posZ - lastZ) * d6 - + (entityLiving.worldObj.rand.nextDouble() - 0.5D) * (double) entityLiving.width * 2.0D; - entityLiving.worldObj.spawnParticle("portal", d7, d8, d9, (double) f, (double) f1, (double) f2); - } - return true; } + short short1 = 128; + + for (posY = 0; posY < short1; ++posY) { + double d6 = (double) posY / ((double) short1 - 1.0D); + float f = (entityLiving.worldObj.rand.nextFloat() - 0.5F) * 0.2F; + float f1 = (entityLiving.worldObj.rand.nextFloat() - 0.5F) * 0.2F; + float f2 = (entityLiving.worldObj.rand.nextFloat() - 0.5F) * 0.2F; + double d7 = lastX + (entityLiving.posX - lastX) * d6 + + (entityLiving.worldObj.rand.nextDouble() - 0.5D) * (double) entityLiving.width * 2.0D; + double d8 = lastY + (entityLiving.posY - lastY) * d6 + + entityLiving.worldObj.rand.nextDouble() * (double) entityLiving.height; + double d9 = lastZ + (entityLiving.posZ - lastZ) * d6 + + (entityLiving.worldObj.rand.nextDouble() - 0.5D) * (double) entityLiving.width * 2.0D; + entityLiving.worldObj.spawnParticle("portal", d7, d8, d9, f, f1, f2); + } + return true; } public static void moveEntityViaTeleport(EntityLivingBase entityLiving, double x, double y, double z) { if (entityLiving instanceof EntityPlayer) { - if (entityLiving != null && entityLiving instanceof EntityPlayerMP) { - EntityPlayerMP entityplayermp = (EntityPlayerMP) entityLiving; - if (entityplayermp.worldObj == entityLiving.worldObj) { - EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, x, y, z, 5.0F); - - if (!MinecraftForge.EVENT_BUS.post(event)) { - if (entityLiving.isRiding()) { - entityLiving.mountEntity(null); - } - entityLiving.setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); + if (entityLiving instanceof EntityPlayerMP entityplayermp) { + EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, x, y, z, 5.0F); + + if (!MinecraftForge.EVENT_BUS.post(event)) { + if (entityLiving.isRiding()) { + entityLiving.mountEntity(null); } + entityLiving.setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); } } } else if (entityLiving != null) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellWateryGrave.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellWateryGrave.java index 09304e6295..ae7bbd96e0 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellWateryGrave.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellWateryGrave.java @@ -1,6 +1,5 @@ package WayofTime.alchemicalWizardry.common.spell.simple; -import java.util.Iterator; import java.util.List; import java.util.Random; @@ -29,83 +28,73 @@ public SpellWateryGrave() { } @Override - public ItemStack onOffensiveRangedRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveRangedRightClick(ItemStack item, World world, EntityPlayer player) { + if (IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveRangedEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveRangedEnergy()); } - par2World.spawnEntityInWorld(new WaterProjectile(par2World, par3EntityPlayer, 8)); - par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - return par1ItemStack; + world.spawnEntityInWorld(new WaterProjectile(world, player, 8)); + world.playSoundAtEntity(player, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + return item; } @Override - public ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveMeleeRightClick(ItemStack item, World world, EntityPlayer player) { + if (IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveMeleeEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveMeleeEnergy()); } - if (!par2World.isRemote) { + if (!world.isRemote) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { - par2World.spawnEntityInWorld( + world.spawnEntityInWorld( new WaterProjectile( - par2World, - par3EntityPlayer, + world, + player, 3, 3, - par3EntityPlayer.posX, - par3EntityPlayer.posY + par3EntityPlayer.getEyeHeight(), - par3EntityPlayer.posZ, - par3EntityPlayer.rotationYaw + i * 10F, - par3EntityPlayer.rotationPitch + j * 5F)); + player.posX, + player.posY + player.getEyeHeight(), + player.posZ, + player.rotationYaw + i * 10F, + player.rotationPitch + j * 5F)); } } } - return par1ItemStack; + return item; } @Override - public ItemStack onDefensiveRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onDefensiveRightClick(ItemStack item, World world, EntityPlayer player) { + if (IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getDefensiveEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getDefensiveEnergy()); } - int d0 = 3; AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox( - par3EntityPlayer.posX, - par3EntityPlayer.posY, - par3EntityPlayer.posZ, - (par3EntityPlayer.posX + 1), - (par3EntityPlayer.posY + 2), - (par3EntityPlayer.posZ + 1)).expand(d0, d0, d0); - List list = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityLivingBase entityLiving = (EntityLivingBase) iterator.next(); - - if (entityLiving instanceof EntityPlayer) { - if (entityLiving.equals(par3EntityPlayer)) { - continue; - } + player.posX, + player.posY, + player.posZ, + (player.posX + 1), + (player.posY + 2), + (player.posZ + 1)).expand(3, 3, 3); + List list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); + + for (EntityLivingBase entityLiving : list) { + if (entityLiving instanceof EntityPlayer && entityLiving.equals(player)) { + continue; } int x = 1; @@ -118,72 +107,60 @@ public ItemStack onDefensiveRightClick(ItemStack par1ItemStack, World par2World, entityLiving.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionDrowning.id, 100, x - 1)); } - double xCoord = par3EntityPlayer.posX; - double yCoord = par3EntityPlayer.posY; - double zCoord = par3EntityPlayer.posZ; - for (int i = 0; i < 20; i++) { SpellHelper.sendParticleToAllAround( - par2World, - xCoord, - yCoord, - zCoord, + world, + player.posX, + player.posY, + player.posZ, 30, - par2World.provider.dimensionId, + world.provider.dimensionId, "mobSpell", - xCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, - yCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, - zCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, + player.posX + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, + player.posY + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, + player.posZ + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, 0.0F, 0.410F, 1.0F); } - return par1ItemStack; + return item; } @Override - public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onEnvironmentalRightClick(ItemStack item, World world, EntityPlayer player) { + if (IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getEnvironmentalEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getEnvironmentalEnergy()); } int range = 2; - if (!par2World.isRemote) { + if (!world.isRemote) { for (int i = -range; i <= range; i++) { for (int j = -range; j <= range; j++) { - if (par2World.isAirBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY, - (int) par3EntityPlayer.posZ + j)) { - par2World.setBlock( - (int) par3EntityPlayer.posX + i, - (int) par3EntityPlayer.posY, - (int) par3EntityPlayer.posZ + j, - Blocks.water); + if (world.isAirBlock((int) player.posX + i, (int) player.posY, (int) player.posZ + j)) { + world.setBlock((int) player.posX + i, (int) player.posY, (int) player.posZ + j, Blocks.water); } } } } - double xCoord = par3EntityPlayer.posX; - double yCoord = par3EntityPlayer.posY; - double zCoord = par3EntityPlayer.posZ; + double xCoord = player.posX; + double yCoord = player.posY; + double zCoord = player.posZ; for (int i = 0; i < 16; i++) { SpellHelper.sendParticleToAllAround( - par2World, + world, xCoord, yCoord, zCoord, 30, - par2World.provider.dimensionId, + world.provider.dimensionId, "mobSpell", xCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, yCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, @@ -193,6 +170,6 @@ public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2Wo 1.0F); } - return par1ItemStack; + return item; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellWindGust.java b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellWindGust.java index e44904b9d1..ac0185d88c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellWindGust.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/spell/simple/SpellWindGust.java @@ -1,6 +1,5 @@ package WayofTime.alchemicalWizardry.common.spell.simple; -import java.util.Iterator; import java.util.List; import java.util.Random; @@ -26,62 +25,54 @@ public SpellWindGust() { } @Override - public ItemStack onOffensiveRangedRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveRangedRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveRangedEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveRangedEnergy()); } - par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + world.playSoundAtEntity(player, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - if (!par2World.isRemote) { - par2World.spawnEntityInWorld(new WindGustProjectile(par2World, par3EntityPlayer, 8)); + if (!world.isRemote) { + world.spawnEntityInWorld(new WindGustProjectile(world, player, 8)); } - return par1ItemStack; + return item; } @Override - public ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onOffensiveMeleeRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems - .syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveMeleeEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getOffensiveMeleeEnergy()); } int distance = 3; - double yaw = par3EntityPlayer.rotationYaw / 180 * Math.PI; - double pitch = par3EntityPlayer.rotationPitch / 180 * Math.PI; - double xCoord = par3EntityPlayer.posX + Math.sin(yaw) * Math.cos(pitch) * (-distance); - double yCoord = par3EntityPlayer.posY + par3EntityPlayer.getEyeHeight() + Math.sin(-pitch) * distance; - double zCoord = par3EntityPlayer.posZ + Math.cos(yaw) * Math.cos(pitch) * distance; - float d0 = 0.5f; + double yaw = player.rotationYaw / 180 * Math.PI; + double pitch = player.rotationPitch / 180 * Math.PI; + double v = Math.cos(yaw) * Math.cos(pitch) * distance; + double v1 = Math.sin(yaw) * Math.cos(pitch) * (-distance); + double xCoord = player.posX + v1; + double yCoord = player.posY + player.getEyeHeight() + Math.sin(-pitch) * distance; + double zCoord = player.posZ + v; AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox( - par3EntityPlayer.posX - 0.5 + Math.sin(yaw) * Math.cos(pitch) * (-distance), - par3EntityPlayer.posY + par3EntityPlayer.getEyeHeight() + Math.sin(-pitch) * distance, - par3EntityPlayer.posZ - 0.5 + Math.cos(yaw) * Math.cos(pitch) * distance, - par3EntityPlayer.posX + Math.sin(yaw) * Math.cos(pitch) * (-distance) + 0.5, - par3EntityPlayer.posY + par3EntityPlayer.getEyeHeight() + Math.sin(-pitch) * distance + 1, - par3EntityPlayer.posZ + Math.cos(yaw) * Math.cos(pitch) * distance + 0.5).expand(d0, d0, d0); - List list = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityLivingBase entityLiving = (EntityLivingBase) iterator.next(); - - if (entityLiving instanceof EntityPlayer) { - if (entityLiving.equals(par3EntityPlayer)) { - continue; - } + xCoord - 0.5 + v1, + yCoord + player.getEyeHeight() + Math.sin(-pitch) * distance, + zCoord - 0.5 + v, + xCoord + v1 + 0.5, + yCoord + player.getEyeHeight() + Math.sin(-pitch) * distance + 1, + zCoord + v + 0.5).expand(0.5f, 0.5f, 0.5f); + List list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); + + for (EntityLivingBase entityLiving : list) { + if (entityLiving instanceof EntityPlayer && entityLiving.equals(player)) { + continue; } entityLiving.motionX = Math.sin(-yaw) * 2; entityLiving.motionY = 2; @@ -89,12 +80,12 @@ public ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2W } for (int i = 0; i < 5; i++) { SpellHelper.sendParticleToAllAround( - par2World, + world, xCoord, yCoord, zCoord, 30, - par2World.provider.dimensionId, + world.provider.dimensionId, "mobSpell", xCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, yCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, @@ -103,100 +94,87 @@ public ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2W 0.410F, 1.0F); } - return par1ItemStack; + return item; } @Override - public ItemStack onDefensiveRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onDefensiveRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getDefensiveEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getDefensiveEnergy()); } - double yaw = par3EntityPlayer.rotationYaw / 180 * Math.PI; - double pitch = par3EntityPlayer.rotationPitch / 180 * Math.PI; + double yaw = player.rotationYaw / 180 * Math.PI; + double pitch = player.rotationPitch / 180 * Math.PI; double wantedVelocity = 5; double xVel = Math.sin(yaw) * Math.cos(pitch) * (-wantedVelocity); double yVel = Math.sin(-pitch) * wantedVelocity; double zVel = Math.cos(yaw) * Math.cos(pitch) * wantedVelocity; - Vec3 vec = par3EntityPlayer.getLookVec(); - par3EntityPlayer.motionX = vec.xCoord * wantedVelocity; - par3EntityPlayer.motionY = vec.yCoord * wantedVelocity; - par3EntityPlayer.motionZ = vec.zCoord * wantedVelocity; - SpellHelper.setPlayerSpeedFromServer(par3EntityPlayer, xVel, yVel, zVel); - par2World.playSoundEffect( - (double) ((float) par3EntityPlayer.posX + 0.5F), - (double) ((float) par3EntityPlayer.posY + 0.5F), - (double) ((float) par3EntityPlayer.posZ + 0.5F), + Vec3 vec = player.getLookVec(); + player.motionX = vec.xCoord * wantedVelocity; + player.motionY = vec.yCoord * wantedVelocity; + player.motionZ = vec.zCoord * wantedVelocity; + SpellHelper.setPlayerSpeedFromServer(player, xVel, yVel, zVel); + world.playSoundEffect( + (float) player.posX + 0.5F, + (float) player.posY + 0.5F, + (float) player.posZ + 0.5F, "random.fizz", 0.5F, - 2.6F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.8F); - par3EntityPlayer.fallDistance = 0; - double xCoord = par3EntityPlayer.posX; - double yCoord = par3EntityPlayer.posY; - double zCoord = par3EntityPlayer.posZ; + 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + player.fallDistance = 0; for (int i = 0; i < 8; i++) { SpellHelper.sendParticleToAllAround( - par2World, - xCoord, - yCoord, - zCoord, + world, + player.posX, + player.posY, + player.posZ, 30, - par2World.provider.dimensionId, + world.provider.dimensionId, "mobSpell", - xCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, - yCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, - zCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, + player.posX + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, + player.posY + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, + player.posZ + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, 0.0F, 0.410F, 1.0F); } - return par1ItemStack; + return item; } @Override - public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2World, - EntityPlayer par3EntityPlayer) { - if (!IBindable.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) { - return par1ItemStack; + public ItemStack onEnvironmentalRightClick(ItemStack item, World world, EntityPlayer player) { + if (!IBindable.checkAndSetItemOwner(item, player) || player.isSneaking()) { + return item; } - if (!par3EntityPlayer.capabilities.isCreativeMode) { - EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getEnvironmentalEnergy()); + if (!player.capabilities.isCreativeMode) { + EnergyItems.syphonAndDamageWhileInContainer(item, player, this.getEnvironmentalEnergy()); } - int d0 = 3; AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox( - par3EntityPlayer.posX, - par3EntityPlayer.posY, - par3EntityPlayer.posZ, - (par3EntityPlayer.posX + 1), - (par3EntityPlayer.posY + 2), - (par3EntityPlayer.posZ + 1)).expand(d0, d0, d0); - List list = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); - Iterator iterator = list.iterator(); - double xCoord = par3EntityPlayer.posX; - double yCoord = par3EntityPlayer.posY; - double zCoord = par3EntityPlayer.posZ; + player.posX, + player.posY, + player.posZ, + player.posX + 1, + player.posY + 2, + player.posZ + 1).expand(3, 3, 3); + List list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); double wantedVel = 2; - while (iterator.hasNext()) { - EntityLivingBase entityLiving = (EntityLivingBase) iterator.next(); - - if (entityLiving instanceof EntityPlayer) { - if (entityLiving.equals(par3EntityPlayer)) { - continue; - } + for (EntityLivingBase entityLiving : list) { + if (entityLiving instanceof EntityPlayer && entityLiving.equals(player)) { + continue; } - double posXDif = entityLiving.posX - par3EntityPlayer.posX; - double posYDif = entityLiving.posY - par3EntityPlayer.posY + 1; - double posZDif = entityLiving.posZ - par3EntityPlayer.posZ; + double posXDif = entityLiving.posX - player.posX; + double posYDif = entityLiving.posY - player.posY + 1; + double posZDif = entityLiving.posZ - player.posZ; double distance2 = Math.pow(posXDif, 2) + Math.pow(posYDif, 2) + Math.pow(posZDif, 2); double distance = Math.sqrt(distance2); entityLiving.motionX = posXDif * wantedVel / distance; @@ -205,21 +183,21 @@ public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2Wo } for (int i = 0; i < 20; i++) { SpellHelper.sendParticleToAllAround( - par2World, - xCoord, - yCoord, - zCoord, + world, + player.posX, + player.posY, + player.posZ, 30, - par2World.provider.dimensionId, + world.provider.dimensionId, "mobSpell", - xCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, - yCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, - zCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, + player.posX + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, + player.posY + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, + player.posZ + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, 0.0F, 0.410F, 1.0F); } - return par1ItemStack; + return item; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/summoning/SummoningFallenAngel.java b/src/main/java/WayofTime/alchemicalWizardry/common/summoning/SummoningFallenAngel.java index 85b8189f35..7ca01ed993 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/summoning/SummoningFallenAngel.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/summoning/SummoningFallenAngel.java @@ -12,6 +12,7 @@ public SummoningFallenAngel(String id) { super(id); } + @Override public EntityLivingBase getEntity(World worldObj) { return new EntityFallenAngel(worldObj); } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/summoning/SummoningHelperAW.java b/src/main/java/WayofTime/alchemicalWizardry/common/summoning/SummoningHelperAW.java index e762f10ca7..404ee51ab3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/summoning/SummoningHelperAW.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/summoning/SummoningHelperAW.java @@ -32,6 +32,7 @@ public SummoningHelperAW(String id) { super(id); } + @Override public EntityLivingBase getEntity(World worldObj) { if (this.id.equals(AlchemicalWizardry.entityFallenAngelID)) { return new EntityFallenAngel(worldObj); @@ -112,7 +113,4 @@ public EntityLivingBase getEntity(World worldObj) { return new EntityPig(worldObj); } - public String getSummoningHelperID() { - return id; - } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEAltar.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEAltar.java index 6bf2a22725..51dc50aa22 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEAltar.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEAltar.java @@ -120,71 +120,66 @@ public int getRSPowerOutput() { return 5; } + @Override public void addToDemonBloodDuration(int dur) { this.demonBloodDuration += dur; } + @Override public boolean hasDemonBlood() { return this.demonBloodDuration > 0; } + @Override public void decrementDemonBlood() { this.demonBloodDuration = Math.max(0, this.demonBloodDuration - 1); } @Override - public void readFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readFromNBT(par1NBTTagCompound); + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); - resultID = par1NBTTagCompound.getInteger("resultID"); - resultDamage = par1NBTTagCompound.getInteger("resultDamage"); + resultID = tag.getInteger("resultID"); + resultDamage = tag.getInteger("resultDamage"); - if (!par1NBTTagCompound.hasKey("Empty")) { - FluidStack fluid = this.fluid.loadFluidStackFromNBT(par1NBTTagCompound); + if (!tag.hasKey("Empty")) { + FluidStack fluid = FluidStack.loadFluidStackFromNBT(tag); if (fluid != null) { setMainFluid(fluid); } - FluidStack fluidOut = new FluidStack( - AlchemicalWizardry.lifeEssenceFluid, - par1NBTTagCompound.getInteger("outputAmount")); + FluidStack fluidOut = new FluidStack(AlchemicalWizardry.lifeEssenceFluid, tag.getInteger("outputAmount")); - if (fluidOut != null) { - setOutputFluid(fluidOut); - } + setOutputFluid(fluidOut); - FluidStack fluidIn = new FluidStack( - AlchemicalWizardry.lifeEssenceFluid, - par1NBTTagCompound.getInteger("inputAmount")); + FluidStack fluidIn = new FluidStack(AlchemicalWizardry.lifeEssenceFluid, tag.getInteger("inputAmount")); - if (fluidIn != null) { - setInputFluid(fluidIn); - } + setInputFluid(fluidIn); } - upgradeLevel = par1NBTTagCompound.getInteger("upgradeLevel"); - isActive = par1NBTTagCompound.getBoolean("isActive"); - liquidRequired = par1NBTTagCompound.getInteger("liquidRequired"); - canBeFilled = par1NBTTagCompound.getBoolean("canBeFilled"); - isUpgraded = par1NBTTagCompound.getBoolean("isUpgraded"); - consumptionRate = par1NBTTagCompound.getInteger("consumptionRate"); - drainRate = par1NBTTagCompound.getInteger("drainRate"); - consumptionMultiplier = par1NBTTagCompound.getFloat("consumptionMultiplier"); - efficiencyMultiplier = par1NBTTagCompound.getFloat("efficiencyMultiplier"); - selfSacrificeEfficiencyMultiplier = par1NBTTagCompound.getFloat("selfSacrificeEfficiencyMultiplier"); - sacrificeEfficiencyMultiplier = par1NBTTagCompound.getFloat("sacrificeEfficiencyMultiplier"); - capacityMultiplier = par1NBTTagCompound.getFloat("capacityMultiplier"); - orbCapacityMultiplier = par1NBTTagCompound.getFloat("orbCapacityMultiplier"); - dislocationMultiplier = par1NBTTagCompound.getFloat("dislocationMultiplier"); - capacity = par1NBTTagCompound.getInteger("capacity"); - bufferCapacity = par1NBTTagCompound.getInteger("bufferCapacity"); - progress = par1NBTTagCompound.getInteger("progress"); - isResultBlock = par1NBTTagCompound.getBoolean("isResultBlock"); - lockdownDuration = par1NBTTagCompound.getInteger("lockdownDuration"); - accelerationUpgrades = par1NBTTagCompound.getInteger("accelerationUpgrades"); - demonBloodDuration = par1NBTTagCompound.getInteger("demonBloodDuration"); - cooldownAfterCrafting = par1NBTTagCompound.getInteger("cooldownAfterCrafting"); + upgradeLevel = tag.getInteger("upgradeLevel"); + isActive = tag.getBoolean("isActive"); + liquidRequired = tag.getInteger("liquidRequired"); + canBeFilled = tag.getBoolean("canBeFilled"); + isUpgraded = tag.getBoolean("isUpgraded"); + consumptionRate = tag.getInteger("consumptionRate"); + drainRate = tag.getInteger("drainRate"); + consumptionMultiplier = tag.getFloat("consumptionMultiplier"); + efficiencyMultiplier = tag.getFloat("efficiencyMultiplier"); + selfSacrificeEfficiencyMultiplier = tag.getFloat("selfSacrificeEfficiencyMultiplier"); + sacrificeEfficiencyMultiplier = tag.getFloat("sacrificeEfficiencyMultiplier"); + capacityMultiplier = tag.getFloat("capacityMultiplier"); + orbCapacityMultiplier = tag.getFloat("orbCapacityMultiplier"); + dislocationMultiplier = tag.getFloat("dislocationMultiplier"); + capacity = tag.getInteger("capacity"); + bufferCapacity = tag.getInteger("bufferCapacity"); + progress = tag.getInteger("progress"); + isResultBlock = tag.getBoolean("isResultBlock"); + lockdownDuration = tag.getInteger("lockdownDuration"); + accelerationUpgrades = tag.getInteger("accelerationUpgrades"); + demonBloodDuration = tag.getInteger("demonBloodDuration"); + cooldownAfterCrafting = tag.getInteger("cooldownAfterCrafting"); } public void setMainFluid(FluidStack fluid) { @@ -200,48 +195,48 @@ public void setInputFluid(FluidStack fluid) { } @Override - public void writeToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeToNBT(par1NBTTagCompound); + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); - par1NBTTagCompound.setInteger("resultID", resultID); - par1NBTTagCompound.setInteger("resultDamage", resultDamage); + tag.setInteger("resultID", resultID); + tag.setInteger("resultDamage", resultDamage); if (fluid != null) { - fluid.writeToNBT(par1NBTTagCompound); + fluid.writeToNBT(tag); } else { - par1NBTTagCompound.setString("Empty", ""); + tag.setString("Empty", ""); } if (fluidOutput != null) { - par1NBTTagCompound.setInteger("outputAmount", fluidOutput.amount); + tag.setInteger("outputAmount", fluidOutput.amount); } if (fluidInput != null) { - par1NBTTagCompound.setInteger("inputAmount", fluidInput.amount); + tag.setInteger("inputAmount", fluidInput.amount); } - par1NBTTagCompound.setInteger("upgradeLevel", upgradeLevel); - par1NBTTagCompound.setBoolean("isActive", isActive); - par1NBTTagCompound.setInteger("liquidRequired", liquidRequired); - par1NBTTagCompound.setBoolean("canBeFilled", canBeFilled); - par1NBTTagCompound.setBoolean("isUpgraded", isUpgraded); - par1NBTTagCompound.setInteger("consumptionRate", consumptionRate); - par1NBTTagCompound.setInteger("drainRate", drainRate); - par1NBTTagCompound.setFloat("consumptionMultiplier", consumptionMultiplier); - par1NBTTagCompound.setFloat("efficiencyMultiplier", efficiencyMultiplier); - par1NBTTagCompound.setFloat("sacrificeEfficiencyMultiplier", sacrificeEfficiencyMultiplier); - par1NBTTagCompound.setFloat("selfSacrificeEfficiencyMultiplier", selfSacrificeEfficiencyMultiplier); - par1NBTTagCompound.setBoolean("isResultBlock", isResultBlock); - par1NBTTagCompound.setFloat("capacityMultiplier", capacityMultiplier); - par1NBTTagCompound.setFloat("orbCapacityMultiplier", orbCapacityMultiplier); - par1NBTTagCompound.setFloat("dislocationMultiplier", dislocationMultiplier); - par1NBTTagCompound.setInteger("capacity", capacity); - par1NBTTagCompound.setInteger("progress", progress); - par1NBTTagCompound.setInteger("bufferCapacity", bufferCapacity); - par1NBTTagCompound.setInteger("lockdownDuration", lockdownDuration); - par1NBTTagCompound.setInteger("accelerationUpgrades", this.accelerationUpgrades); - par1NBTTagCompound.setInteger("demonBloodDuration", demonBloodDuration); - par1NBTTagCompound.setInteger("cooldownAfterCrafting", cooldownAfterCrafting); + tag.setInteger("upgradeLevel", upgradeLevel); + tag.setBoolean("isActive", isActive); + tag.setInteger("liquidRequired", liquidRequired); + tag.setBoolean("canBeFilled", canBeFilled); + tag.setBoolean("isUpgraded", isUpgraded); + tag.setInteger("consumptionRate", consumptionRate); + tag.setInteger("drainRate", drainRate); + tag.setFloat("consumptionMultiplier", consumptionMultiplier); + tag.setFloat("efficiencyMultiplier", efficiencyMultiplier); + tag.setFloat("sacrificeEfficiencyMultiplier", sacrificeEfficiencyMultiplier); + tag.setFloat("selfSacrificeEfficiencyMultiplier", selfSacrificeEfficiencyMultiplier); + tag.setBoolean("isResultBlock", isResultBlock); + tag.setFloat("capacityMultiplier", capacityMultiplier); + tag.setFloat("orbCapacityMultiplier", orbCapacityMultiplier); + tag.setFloat("dislocationMultiplier", dislocationMultiplier); + tag.setInteger("capacity", capacity); + tag.setInteger("progress", progress); + tag.setInteger("bufferCapacity", bufferCapacity); + tag.setInteger("lockdownDuration", lockdownDuration); + tag.setInteger("accelerationUpgrades", this.accelerationUpgrades); + tag.setInteger("demonBloodDuration", demonBloodDuration); + tag.setInteger("cooldownAfterCrafting", cooldownAfterCrafting); } @Override @@ -340,16 +335,14 @@ public int fill(FluidStack resource, boolean doFill) { if (fluidInput == null) { fluidInput = new FluidStack(resource, Math.min(bufferCapacity, resource.amount)); - if (tile != null) { - FluidEvent.fireEvent( - new FluidEvent.FluidFillingEvent( - fluidInput, - tile.getWorldObj(), - tile.xCoord, - tile.yCoord, - tile.zCoord, - this)); - } + FluidEvent.fireEvent( + new FluidEvent.FluidFillingEvent( + fluidInput, + tile.getWorldObj(), + tile.xCoord, + tile.yCoord, + tile.zCoord, + this)); return fluidInput.amount; } @@ -367,16 +360,14 @@ public int fill(FluidStack resource, boolean doFill) { fluidInput.amount = bufferCapacity; } - if (tile != null) { - FluidEvent.fireEvent( - new FluidEvent.FluidFillingEvent( - fluidInput, - tile.getWorldObj(), - tile.xCoord, - tile.yCoord, - tile.zCoord, - this)); - } + FluidEvent.fireEvent( + new FluidEvent.FluidFillingEvent( + fluidInput, + tile.getWorldObj(), + tile.xCoord, + tile.yCoord, + tile.zCoord, + this)); return filled; } @@ -402,16 +393,14 @@ public FluidStack drain(int maxDrain, boolean doDrain) { fluidOutput = null; } - if (this != null) { - FluidEvent.fireEvent( - new FluidEvent.FluidDrainingEvent( - fluidOutput, - this.worldObj, - this.xCoord, - this.yCoord, - this.zCoord, - this)); - } + FluidEvent.fireEvent( + new FluidEvent.FluidDrainingEvent( + fluidOutput, + this.worldObj, + this.xCoord, + this.yCoord, + this.zCoord, + this)); } if (fluidOutput == null) { @@ -625,7 +614,7 @@ public void updateEntity() { String ownerName = itemTag.getString("ownerName"); - if (ownerName.equals("")) { + if (ownerName.isEmpty()) { return; } @@ -710,14 +699,14 @@ public boolean isActive() { return isActive; } + @Override public void sacrificialDaggerCall(int amount, boolean isSacrifice) { if (!isSacrifice && this.lockdownDuration > 0) { - int amt = (int) Math.min( - bufferCapacity - fluidInput.amount, - (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount); + int amt = (int) Math + .min(bufferCapacity - fluidInput.amount, (1 + selfSacrificeEfficiencyMultiplier) * amount); fluidInput.amount += amt; } else { - fluid.amount += Math.min( + fluid.amount += (int) Math.min( capacity - fluid.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount); } @@ -734,16 +723,11 @@ public void handlePacketData(int[] intData, int[] fluidData, int capacity) { } if (intData.length == 3) { - for (int i = 0; i < 1; i++) { - if (intData[i * 3 + 2] != 0) { - ItemStack is = new ItemStack( - Item.getItemById(intData[i * 3]), - intData[i * 3 + 2], - intData[i * 3 + 1]); - inv[i] = is; - } else { - inv[i] = null; - } + if (intData[2] != 0) { + ItemStack is = new ItemStack(Item.getItemById(intData[0]), intData[2], intData[1]); + inv[0] = is; + } else { + inv[0] = null; } } @@ -777,6 +761,7 @@ public int[] buildIntDataList() { return sortList; } + @Override public void startCycle() { if (worldObj != null) { worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEConduit.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEConduit.java index 79e5913810..9368f1b915 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEConduit.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEConduit.java @@ -7,13 +7,13 @@ public class TEConduit extends TESpellBlock { @Override - public void readFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readFromNBT(par1NBTTagCompound); + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); } @Override - public void writeToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeToNBT(par1NBTTagCompound); + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); } // Logic for the actual block is under here diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TECrucible.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TECrucible.java index 5f7b4f48ba..2c2673289a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TECrucible.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TECrucible.java @@ -20,7 +20,7 @@ public class TECrucible extends TEInventory { - private int radius = 5; + private final int radius = 5; public float rColour; public float gColour; @@ -37,7 +37,7 @@ public class TECrucible extends TEInventory { public TECrucible() { super(1); - float f = (float) 1.0F; + float f = 1.0F; float f1 = f * 0.6F + 0.4F; float f2 = f * f * 0.7F - 0.5F; float f3 = f * f * 0.6F - 0.7F; @@ -54,8 +54,7 @@ public void updateEntity() { if (ticksRemaining <= 0) { ItemStack stack = this.getStackInSlot(0); - if (stack != null && stack.getItem() instanceof IIncense) { - IIncense incense = (IIncense) stack.getItem(); + if (stack != null && stack.getItem() instanceof IIncense incense) { rColour = incense.getRedColour(stack); gColour = incense.getGreenColour(stack); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEHomHeart.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEHomHeart.java index 52f45d12f8..0c98e96b4d 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEHomHeart.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEHomHeart.java @@ -11,7 +11,7 @@ public class TEHomHeart extends TileEntity { - public boolean canCastSpell(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + public boolean canCastSpell(ItemStack item, World world, EntityPlayer player) { return true; } @@ -19,44 +19,39 @@ public int getCostForSpell() { HomSpell spell = getSpell(); if (spell != null) { - switch (getModifiedParadigm()) { - case 0: - return spell.getOffensiveRangedEnergy(); - - case 1: - return spell.getOffensiveMeleeEnergy(); - - case 2: - return spell.getDefensiveEnergy(); - - case 3: - return spell.getEnvironmentalEnergy(); - } + return switch (getModifiedParadigm()) { + case 0 -> spell.getOffensiveRangedEnergy(); + case 1 -> spell.getOffensiveMeleeEnergy(); + case 2 -> spell.getDefensiveEnergy(); + case 3 -> spell.getEnvironmentalEnergy(); + default -> throw new IllegalStateException("Unexpected value: " + getModifiedParadigm()); + }; } return 0; } - public int castSpell(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + public int castSpell(ItemStack item, World world, EntityPlayer player) { HomSpell spell = getSpell(); if (spell != null) { switch (getModifiedParadigm()) { - case 0: - spell.onOffensiveRangedRightClick(par1ItemStack, par2World, par3EntityPlayer); + case 0 -> { + spell.onOffensiveRangedRightClick(item, world, player); return spell.getOffensiveRangedEnergy(); - - case 1: - spell.onOffensiveMeleeRightClick(par1ItemStack, par2World, par3EntityPlayer); + } + case 1 -> { + spell.onOffensiveMeleeRightClick(item, world, player); return spell.getOffensiveMeleeEnergy(); - - case 2: - spell.onDefensiveRightClick(par1ItemStack, par2World, par3EntityPlayer); + } + case 2 -> { + spell.onDefensiveRightClick(item, world, player); return spell.getDefensiveEnergy(); - - case 3: - spell.onEnvironmentalRightClick(par1ItemStack, par2World, par3EntityPlayer); + } + case 3 -> { + spell.onEnvironmentalRightClick(item, world, player); return spell.getEnvironmentalEnergy(); + } } } @@ -108,15 +103,11 @@ public HomSpell getSpell() { tileEntity = worldObj.getTileEntity(xCoord, yCoord, zCoord + 1); - if (tileEntity instanceof TEAltar) { - ItemStack itemStack = ((TEAltar) tileEntity).getStackInSlot(0); + if (tileEntity instanceof TEAltar altar) { + ItemStack itemStack = altar.getStackInSlot(0); if (itemStack != null) { - HomSpell spell = HomSpellRegistry.getSpellForItemStack(itemStack); - - if (spell != null) { - return spell; - } + return HomSpellRegistry.getSpellForItemStack(itemStack); } } @@ -128,22 +119,16 @@ public int getModifiedParadigm() { TileEntity tileEntity = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord); - if (tileEntity instanceof TileEntitySkull) { - int skullType = ((TileEntitySkull) tileEntity).func_145904_a(); - - switch (skullType) { - case 0: - return 0; + if (tileEntity instanceof TileEntitySkull skull) { + int skullType = skull.func_145904_a(); - case 1: - return 1; - - case 2: - return 2; - - case 4: - return 3; - } + return switch (skullType) { + case 0 -> 0; + case 1 -> 1; + case 2 -> 2; + case 4 -> 3; + default -> -1; + }; } return -1; diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEMasterStone.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEMasterStone.java index 1d9c9df9c5..e25483a98e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEMasterStone.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEMasterStone.java @@ -46,7 +46,6 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone, IBl private String currentRitualString; private boolean isActive; private String owner; - private String varString1; private int cooldown; private int var1; private int direction; @@ -63,14 +62,13 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone, IBl public TEMasterStone() { tanks = new ReagentContainer[] { new ReagentContainer(1000), new ReagentContainer(1000), new ReagentContainer(1000) }; - this.attunedTankMap = new HashMap(); + this.attunedTankMap = new HashMap<>(); isActive = false; owner = ""; cooldown = 0; var1 = 0; direction = 0; - varString1 = ""; currentRitualString = ""; isRunning = false; runningTime = 0; @@ -101,10 +99,10 @@ public void writeClientNBT(NBTTagCompound tag) { NBTTagList tagList = new NBTTagList(); - for (int i = 0; i < this.tanks.length; i++) { + for (ReagentContainer tank : this.tanks) { NBTTagCompound savedTag = new NBTTagCompound(); - if (this.tanks[i] != null) { - this.tanks[i].writeToNBT(savedTag); + if (tank != null) { + tank.writeToNBT(savedTag); } tagList.appendTag(savedTag); } @@ -170,10 +168,10 @@ public void writeToNBT(NBTTagCompound tag) { NBTTagList tagList = new NBTTagList(); - for (int i = 0; i < this.tanks.length; i++) { + for (ReagentContainer tank : this.tanks) { NBTTagCompound savedTag = new NBTTagCompound(); - if (this.tanks[i] != null) { - this.tanks[i].writeToNBT(savedTag); + if (tank != null) { + tank.writeToNBT(savedTag); } tagList.appendTag(savedTag); } @@ -209,7 +207,7 @@ public void activateRitual(World world, int crystalLevel, ItemStack activationCr String testRitual = Rituals.checkValidRitual(world, xCoord, yCoord, zCoord); - if (testRitual.equals("")) { + if (testRitual.isEmpty()) { player.addChatMessage(new ChatComponentTranslation("message.masterstone.nothinghappened")); return; } @@ -281,7 +279,7 @@ public void activateRitual(World world, int crystalLevel, ItemStack activationCr } } - if (!this.currentRitualString.equals("")) { + if (!this.currentRitualString.isEmpty()) { Rituals.onRitualBroken(this, this.currentRitualString, RitualBreakMethod.ACTIVATE); } this.setOwner(eventOwnerKey); @@ -289,7 +287,9 @@ public void activateRitual(World world, int crystalLevel, ItemStack activationCr var1 = 0; currentRitualString = testRitual; storage = Rituals.getLocalStorage(currentRitualString); - storage.setLocation(new Int3(xCoord, yCoord, zCoord)); + if (storage != null) { + storage.setLocation(new Int3(xCoord, yCoord, zCoord)); + } isActive = true; isRunning = true; direction = Rituals.getDirectionOfRitual(world, xCoord, yCoord, zCoord, testRitual); @@ -368,30 +368,37 @@ public void updateEntity() { performRitual(worldObj, xCoord, yCoord, zCoord, currentRitualString); } + @Override public void performRitual(World world, int x, int y, int z, String currentRitualString) { Rituals.performEffect(this, currentRitualString); } + @Override public String getOwner() { return owner; } + @Override public void setCooldown(int newCooldown) { this.cooldown = newCooldown; } + @Override public int getCooldown() { return this.cooldown; } + @Override public void setVar1(int newVar1) { this.var1 = newVar1; } + @Override public int getVar1() { return this.var1; } + @Override public void setActive(boolean active) { Rituals.onRitualBroken(this, this.currentRitualString, RitualBreakMethod.DEACTIVATE); this.isActive = active; @@ -399,6 +406,7 @@ public void setActive(boolean active) { worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } + @Override public int getDirection() { return this.direction; } @@ -444,16 +452,16 @@ public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { readClientNBT(packet.func_148857_g()); } + @Override public AxisAlignedBB getRenderBoundingBox() { double renderExtention = 1.0d; - AxisAlignedBB bb = AxisAlignedBB.getBoundingBox( + return AxisAlignedBB.getBoundingBox( xCoord - renderExtention, yCoord - renderExtention, zCoord - renderExtention, xCoord + 1 + renderExtention, yCoord + 1 + renderExtention, zCoord + 1 + renderExtention); - return bb; } /* ISegmentedReagentHandler */ @@ -531,13 +539,13 @@ public ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean do Reagent reagent = resource.reagent; int drained = 0; - for (int i = 0; i < tanks.length; i++) { + for (ReagentContainer tank : tanks) { if (drained >= maxDrain) { break; } - if (resource.isReagentEqual(tanks[i].getReagent())) { - ReagentStack drainStack = tanks[i].drain(maxDrain - drained, doDrain); + if (resource.isReagentEqual(tank.getReagent())) { + ReagentStack drainStack = tank.drain(maxDrain - drained, doDrain); if (drainStack != null) { drained += drainStack.amount; } @@ -550,8 +558,8 @@ public ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean do /* Only returns the amount from the first available tank */ @Override public ReagentStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - for (int i = 0; i < tanks.length; i++) { - ReagentStack stack = tanks[i].drain(maxDrain, doDrain); + for (ReagentContainer tank : tanks) { + ReagentStack stack = tank.drain(maxDrain, doDrain); if (stack != null) { if (doDrain) { worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); @@ -611,9 +619,10 @@ public Map getAttunedTankMap() { return this.attunedTankMap; } + @Override public boolean areTanksEmpty() { - for (int i = 0; i < this.tanks.length; i++) { - if (tanks[i] != null && tanks[i].getReagent() != null) { + for (ReagentContainer tank : this.tanks) { + if (tank != null && tank.getReagent() != null) { return false; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEMimicBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEMimicBlock.java index 7fdd907bf3..b01396fdb3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEMimicBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEMimicBlock.java @@ -21,7 +21,7 @@ public class TEMimicBlock extends TileEntity { - private ItemStack[] inv; + private final ItemStack[] inv; public Reagent reagent; private int ticksRemaining; @@ -46,40 +46,40 @@ public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { } @Override - public void readFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readFromNBT(par1NBTTagCompound); - NBTTagList tagList = par1NBTTagCompound.getTagList("Inventory", Constants.NBT.TAG_COMPOUND); + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); + NBTTagList tagList = tag.getTagList("Inventory", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < tagList.tagCount(); i++) { - NBTTagCompound tag = tagList.getCompoundTagAt(i); - int slot = tag.getByte("Slot"); + NBTTagCompound slot = tagList.getCompoundTagAt(i); + int s = slot.getByte("Slot"); - if (slot >= 0 && slot < inv.length) { - inv[slot] = ItemStack.loadItemStackFromNBT(tag); + if (s >= 0 && s < inv.length) { + inv[s] = ItemStack.loadItemStackFromNBT(slot); } } - ticksRemaining = par1NBTTagCompound.getInteger("ticksRemaining"); - reagent = ReagentRegistry.getReagentForKey(par1NBTTagCompound.getString("reagent")); + ticksRemaining = tag.getInteger("ticksRemaining"); + reagent = ReagentRegistry.getReagentForKey(tag.getString("reagent")); } @Override - public void writeToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeToNBT(par1NBTTagCompound); + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); NBTTagList itemList = new NBTTagList(); for (int i = 0; i < inv.length; i++) { if (inv[i] != null) { - NBTTagCompound tag = new NBTTagCompound(); - tag.setByte("Slot", (byte) i); - inv[i].writeToNBT(tag); - itemList.appendTag(tag); + NBTTagCompound slot = new NBTTagCompound(); + slot.setByte("Slot", (byte) i); + inv[i].writeToNBT(slot); + itemList.appendTag(slot); } } - par1NBTTagCompound.setTag("Inventory", itemList); - par1NBTTagCompound.setInteger("ticksRemaining", ticksRemaining); - par1NBTTagCompound.setString("reagent", ReagentRegistry.getKeyForReagent(reagent)); + tag.setTag("Inventory", itemList); + tag.setInteger("ticksRemaining", ticksRemaining); + tag.setString("reagent", ReagentRegistry.getKeyForReagent(reagent)); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEOrientable.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEOrientable.java index a6d1ede202..1829802c09 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEOrientable.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEOrientable.java @@ -19,17 +19,17 @@ public TEOrientable() { } @Override - public void readFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readFromNBT(par1NBTTagCompound); - this.setInputDirection(ForgeDirection.getOrientation(par1NBTTagCompound.getInteger("inputFace"))); - this.setOutputDirection(ForgeDirection.getOrientation(par1NBTTagCompound.getInteger("outputFace"))); + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); + this.setInputDirection(ForgeDirection.getOrientation(tag.getInteger("inputFace"))); + this.setOutputDirection(ForgeDirection.getOrientation(tag.getInteger("outputFace"))); } @Override - public void writeToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeToNBT(par1NBTTagCompound); - par1NBTTagCompound.setInteger("inputFace", TEOrientable.getIntForForgeDirection(this.getInputDirection())); - par1NBTTagCompound.setInteger("outputFace", TEOrientable.getIntForForgeDirection(this.getOutputDirection())); + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); + tag.setInteger("inputFace", TEOrientable.getIntForForgeDirection(this.getInputDirection())); + tag.setInteger("outputFace", TEOrientable.getIntForForgeDirection(this.getOutputDirection())); } @Override @@ -53,28 +53,14 @@ public void setOutputDirection(ForgeDirection direction) { } public static int getIntForForgeDirection(ForgeDirection direction) { - switch (direction) { - case DOWN: - return 0; - - case UP: - return 1; - - case NORTH: - return 2; - - case SOUTH: - return 3; - - case WEST: - return 4; - - case EAST: - return 5; - - default: - return 0; - } + return switch (direction) { + case UP -> 1; + case NORTH -> 2; + case SOUTH -> 3; + case WEST -> 4; + case EAST -> 5; + default -> 0; + }; } @Override @@ -83,10 +69,7 @@ public Packet getDescriptionPacket() { } public boolean isSideRendered(ForgeDirection side) { - if (side.equals(this.getInputDirection()) || side.equals(this.getOutputDirection())) { - return true; - } - return false; + return side.equals(this.getInputDirection()) || side.equals(this.getOutputDirection()); } public String getResourceLocationForMeta(int meta) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEPedestal.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEPedestal.java index ccb41de761..0e11680321 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEPedestal.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEPedestal.java @@ -26,21 +26,21 @@ public TEPedestal() { } @Override - public void readFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readFromNBT(par1NBTTagCompound); + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); - resultID = par1NBTTagCompound.getInteger("resultID"); - resultDamage = par1NBTTagCompound.getInteger("resultDamage"); - isActive = par1NBTTagCompound.getBoolean("isActive"); + resultID = tag.getInteger("resultID"); + resultDamage = tag.getInteger("resultDamage"); + isActive = tag.getBoolean("isActive"); } @Override - public void writeToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeToNBT(par1NBTTagCompound); + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); - par1NBTTagCompound.setInteger("resultID", resultID); - par1NBTTagCompound.setInteger("resultDamage", resultDamage); - par1NBTTagCompound.setBoolean("isActive", isActive); + tag.setInteger("resultID", resultID); + tag.setInteger("resultDamage", resultDamage); + tag.setBoolean("isActive", isActive); } @Override @@ -78,16 +78,11 @@ public void handlePacketData(int[] intData) { } if (intData.length == 3) { - for (int i = 0; i < 1; i++) { - if (intData[i * 3 + 2] != 0) { - ItemStack is = new ItemStack( - Item.getItemById(intData[i * 3]), - intData[i * 3 + 2], - intData[i * 3 + 1]); - inv[i] = is; - } else { - inv[i] = null; - } + if (intData[2] != 0) { + ItemStack is = new ItemStack(Item.getItemById(intData[0]), intData[2], intData[1]); + inv[0] = is; + } else { + inv[0] = null; } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEPlinth.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEPlinth.java index 4177df6d3b..a48284b659 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEPlinth.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEPlinth.java @@ -35,7 +35,7 @@ public class TEPlinth extends TEInventory { private int progressInterval; private int progress; - public static List pedestalPositions = new ArrayList(); + public static List pedestalPositions = new ArrayList<>(); public TEPlinth() { super(sizeInv); @@ -48,90 +48,90 @@ public TEPlinth() { } @Override - public void readFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readFromNBT(par1NBTTagCompound); + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); - NBTTagList ring1TagList = par1NBTTagCompound.getTagList("ring1Inv", Constants.NBT.TAG_COMPOUND); + NBTTagList ring1TagList = tag.getTagList("ring1Inv", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < ring1TagList.tagCount(); i++) { - NBTTagCompound tag = ring1TagList.getCompoundTagAt(i); - int slot = tag.getByte("Slot"); + NBTTagCompound items = ring1TagList.getCompoundTagAt(i); + int slot = items.getByte("Slot"); if (slot >= 0 && slot < inv.length) { - ring1Inv[slot] = ItemStack.loadItemStackFromNBT(tag); + ring1Inv[slot] = ItemStack.loadItemStackFromNBT(items); } } - NBTTagList ring2TagList = par1NBTTagCompound.getTagList("ring2Inv", Constants.NBT.TAG_COMPOUND); + NBTTagList ring2TagList = tag.getTagList("ring2Inv", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < ring2TagList.tagCount(); i++) { - NBTTagCompound tag = ring2TagList.getCompoundTagAt(i); - int slot = tag.getByte("Slot"); + NBTTagCompound items = ring2TagList.getCompoundTagAt(i); + int slot = items.getByte("Slot"); if (slot >= 0 && slot < inv.length) { - ring2Inv[slot] = ItemStack.loadItemStackFromNBT(tag); + ring2Inv[slot] = ItemStack.loadItemStackFromNBT(items); } } - NBTTagList ring3TagList = par1NBTTagCompound.getTagList("ring3Inv", Constants.NBT.TAG_COMPOUND); + NBTTagList ring3TagList = tag.getTagList("ring3Inv", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < ring3TagList.tagCount(); i++) { - NBTTagCompound tag = ring3TagList.getCompoundTagAt(i); - int slot = tag.getByte("Slot"); + NBTTagCompound items = ring3TagList.getCompoundTagAt(i); + int slot = items.getByte("Slot"); if (slot >= 0 && slot < inv.length) { - ring3Inv[slot] = ItemStack.loadItemStackFromNBT(tag); + ring3Inv[slot] = ItemStack.loadItemStackFromNBT(items); } } - progress = par1NBTTagCompound.getInteger("progress"); - progressInterval = par1NBTTagCompound.getInteger("progressInterval"); - isActive = par1NBTTagCompound.getBoolean("isActive"); + progress = tag.getInteger("progress"); + progressInterval = tag.getInteger("progressInterval"); + isActive = tag.getBoolean("isActive"); } @Override - public void writeToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeToNBT(par1NBTTagCompound); + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); NBTTagList ring1ItemList = new NBTTagList(); for (int i = 0; i < ring1Inv.length; i++) { if (ring1Inv[i] != null) { - NBTTagCompound tag = new NBTTagCompound(); - tag.setByte("Slot", (byte) i); - ring1Inv[i].writeToNBT(tag); - ring1ItemList.appendTag(tag); + NBTTagCompound items = new NBTTagCompound(); + items.setByte("Slot", (byte) i); + ring1Inv[i].writeToNBT(items); + ring1ItemList.appendTag(items); } } - par1NBTTagCompound.setTag("ring1Inv", ring1ItemList); + tag.setTag("ring1Inv", ring1ItemList); NBTTagList ring2ItemList = new NBTTagList(); for (int i = 0; i < ring2Inv.length; i++) { if (ring2Inv[i] != null) { - NBTTagCompound tag = new NBTTagCompound(); - tag.setByte("Slot", (byte) i); - ring2Inv[i].writeToNBT(tag); - ring2ItemList.appendTag(tag); + NBTTagCompound items = new NBTTagCompound(); + items.setByte("Slot", (byte) i); + ring2Inv[i].writeToNBT(items); + ring2ItemList.appendTag(items); } } - par1NBTTagCompound.setTag("ring2Inv", ring1ItemList); + tag.setTag("ring2Inv", ring1ItemList); NBTTagList ring3ItemList = new NBTTagList(); for (int i = 0; i < ring3Inv.length; i++) { if (ring3Inv[i] != null) { - NBTTagCompound tag = new NBTTagCompound(); - tag.setByte("Slot", (byte) i); - ring3Inv[i].writeToNBT(tag); - ring3ItemList.appendTag(tag); + NBTTagCompound items = new NBTTagCompound(); + items.setByte("Slot", (byte) i); + ring3Inv[i].writeToNBT(items); + ring3ItemList.appendTag(items); } } - par1NBTTagCompound.setTag("ring3Inv", ring1ItemList); - par1NBTTagCompound.setInteger("progress", progress); - par1NBTTagCompound.setInteger("progressInterval", progressInterval); - par1NBTTagCompound.setBoolean("isActive", isActive); + tag.setTag("ring3Inv", ring1ItemList); + tag.setInteger("progress", progress); + tag.setInteger("progressInterval", progressInterval); + tag.setBoolean("isActive", isActive); } @Override @@ -154,8 +154,8 @@ public void updateEntity() { } if (!isActive()) { - if (getStackInSlot(0) != null && getStackInSlot(0).getItem() instanceof EnergyBattery) { - int bloodOrbLevel = ((EnergyBattery) getStackInSlot(0).getItem()).getOrbLevel(); + if (getStackInSlot(0) != null && getStackInSlot(0).getItem() instanceof EnergyBattery orb) { + int bloodOrbLevel = orb.getOrbLevel(); if (SummoningRegistry.isRecipeValid( bloodOrbLevel, @@ -170,9 +170,11 @@ public void updateEntity() { isActive = true; paradigm = true; progress = 0; - ring1Inv = src.getRingRecipeForRing(1); - ring2Inv = src.getRingRecipeForRing(2); - ring3Inv = src.getRingRecipeForRing(3); + if (src != null) { + ring1Inv = src.getRingRecipeForRing(1); + ring2Inv = src.getRingRecipeForRing(2); + ring3Inv = src.getRingRecipeForRing(3); + } } else if (SummoningRegistry.isRecipeValid( bloodOrbLevel, composeItemsForRingAndParadigm(1, false), @@ -186,37 +188,27 @@ public void updateEntity() { isActive = true; paradigm = false; progress = 0; - ring1Inv = src.getRingRecipeForRing(1); - ring2Inv = src.getRingRecipeForRing(2); - ring3Inv = src.getRingRecipeForRing(3); + if (src != null) { + ring1Inv = src.getRingRecipeForRing(1); + ring2Inv = src.getRingRecipeForRing(2); + ring3Inv = src.getRingRecipeForRing(3); + } } else { isActive = false; progress = 0; } } } else { - if (getStackInSlot(0) != null && getStackInSlot(0).getItem() instanceof EnergyBattery) { + if (getStackInSlot(0) != null && getStackInSlot(0).getItem() instanceof EnergyBattery orb) { if (progress % progressInterval == 0) { int ring = (progress / progressInterval) / 6 + 1; int slot = (progress / progressInterval) % 6; - ItemStack itemStack; - - switch (ring) { - case 1: - itemStack = this.ring1Inv[slot]; - break; - - case 2: - itemStack = this.ring2Inv[slot]; - break; - - case 3: - itemStack = this.ring3Inv[slot]; - break; - - default: - itemStack = null; - } + ItemStack itemStack = switch (ring) { + case 1 -> this.ring1Inv[slot]; + case 2 -> this.ring2Inv[slot]; + case 3 -> this.ring3Inv[slot]; + default -> null; + }; if (itemStack == null) { progress += progressInterval; @@ -230,7 +222,7 @@ public void updateEntity() { } if (progress >= progressInterval * 18) { - int bloodOrbLevel = ((EnergyBattery) getStackInSlot(0).getItem()).getOrbLevel(); + int bloodOrbLevel = orb.getOrbLevel(); EntityLivingBase entity = SummoningRegistry .getEntity(worldObj, bloodOrbLevel, ring1Inv, ring2Inv, ring3Inv); @@ -256,47 +248,13 @@ public void updateEntity() { } } - public void deleteItemsInRing(int ring) { - if (paradigm) { - int i = 0; - - for (PlinthComponent pc : pedestalPositions) { - if (i < 6 && pc.getRing() == ring) { - TileEntity tileEntity = worldObj - .getTileEntity(xCoord + pc.xOffset, yCoord + pc.yOffset, zCoord + pc.zOffset); - - if (tileEntity instanceof TEPedestal) { - ((TEPedestal) tileEntity).setInventorySlotContents(0, null); - worldObj.markBlockForUpdate(xCoord + pc.xOffset, yCoord + pc.yOffset, zCoord + pc.zOffset); - i++; - } - } - } - } else { - int i = 0; - - for (PlinthComponent pc : pedestalPositions) { - if (i < 6 && pc.getRing() == ring) { - TileEntity tileEntity = worldObj - .getTileEntity(xCoord + pc.zOffset, yCoord + pc.yOffset, zCoord + pc.xOffset); - - if (tileEntity instanceof TEPedestal) { - ((TEPedestal) tileEntity).setInventorySlotContents(0, null); - worldObj.markBlockForUpdate(xCoord + pc.zOffset, yCoord + pc.yOffset, zCoord + pc.xOffset); - i++; - } - } - } - } - } - public boolean deleteItemStackInRing(int ring, ItemStack itemStack) { if (itemStack == null) { return true; } + int i = 0; if (paradigm) { - int i = 0; for (PlinthComponent pc : pedestalPositions) { if (i < 6 && pc.getRing() == ring) { @@ -344,7 +302,6 @@ public boolean deleteItemStackInRing(int ring, ItemStack itemStack) { } } } else { - int i = 0; for (PlinthComponent pc : pedestalPositions) { if (i < 6 && pc.getRing() == ring) { @@ -395,8 +352,8 @@ public boolean deleteItemStackInRing(int ring, ItemStack itemStack) { public ItemStack[] composeItemsForRingAndParadigm(int ring, boolean paradigm) { ItemStack[] composed = new ItemStack[6]; + int i = 0; if (paradigm) { - int i = 0; for (PlinthComponent pc : pedestalPositions) { if (i < 6 && pc.getRing() == ring) { @@ -410,7 +367,6 @@ public ItemStack[] composeItemsForRingAndParadigm(int ring, boolean paradigm) { } } } else { - int i = 0; for (PlinthComponent pc : pedestalPositions) { if (i < 6 && pc.getRing() == ring) { @@ -447,22 +403,17 @@ public void handlePacketData(int[] intData) { } if (intData.length == 3) { - for (int i = 0; i < 1; i++) { - if (intData[i * 3 + 2] != 0) { - ItemStack is = new ItemStack( - Item.getItemById(intData[i * 3]), - intData[i * 3 + 2], - intData[i * 3 + 1]); - inv[i] = is; - } else { - inv[i] = null; - } + if (intData[2] != 0) { + ItemStack is = new ItemStack(Item.getItemById(intData[0]), intData[2], intData[1]); + inv[0] = is; + } else { + inv[0] = null; } } } public int[] buildIntDataList() { - int[] sortList = new int[3]; // 1 * 3 + int[] sortList = new int[3]; int pos = 0; for (ItemStack is : inv) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEReagentConduit.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEReagentConduit.java index 66e0c2e0ee..4a204a9ea0 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEReagentConduit.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEReagentConduit.java @@ -14,7 +14,6 @@ import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.ForgeDirection; @@ -52,9 +51,9 @@ public TEReagentConduit() { public TEReagentConduit(int numberOfTanks, int size) { super(numberOfTanks, size); - destinationList = new LinkedList(); - reagentTargetList = new HashMap(); - reagentTankDesignationList = new HashMap(); + destinationList = new LinkedList<>(); + reagentTargetList = new HashMap<>(); + reagentTankDesignationList = new HashMap<>(); } public Int3 getColour() { @@ -67,9 +66,9 @@ public Int3 getColour() { if (container != null && container.getReagent() != null) { Reagent reagent = container.getReagent().reagent; - redMap[i] = reagent.getColourRed(); - greenMap[i] = reagent.getColourGreen(); - blueMap[i] = reagent.getColourBlue(); + redMap[i] = reagent.red(); + greenMap[i] = reagent.green(); + blueMap[i] = reagent.blue(); } } @@ -98,9 +97,9 @@ public void writeToNBT(NBTTagCompound tag) { NBTTagList tagList = new NBTTagList(); - for (int i = 0; i < destinationList.size(); i++) { + for (ColourAndCoords colourAndCoords : destinationList) { NBTTagCompound savedTag = new NBTTagCompound(); - tagList.appendTag(destinationList.get(i).writeToNBT(savedTag)); + tagList.appendTag(colourAndCoords.writeToNBT(savedTag)); } tag.setTag("destinationList", tagList); @@ -150,7 +149,7 @@ public void readFromNBT(NBTTagCompound tag) { NBTTagList tagList = tag.getTagList("destinationList", Constants.NBT.TAG_COMPOUND); - destinationList = new LinkedList(); + destinationList = new LinkedList<>(); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound savedTag = tagList.getCompoundTagAt(i); @@ -158,7 +157,7 @@ public void readFromNBT(NBTTagCompound tag) { destinationList.add(ColourAndCoords.readFromNBT(savedTag)); } - reagentTargetList = new HashMap(); + reagentTargetList = new HashMap<>(); NBTTagList reagentTagList = tag.getTagList("reagentTargetList", Constants.NBT.TAG_COMPOUND); @@ -167,7 +166,7 @@ public void readFromNBT(NBTTagCompound tag) { Reagent reagent = ReagentRegistry.getReagentForKey(savedTag.getString("reagent")); - List coordList = new LinkedList(); + List coordList = new LinkedList<>(); NBTTagList coordinateList = savedTag.getTagList("coordinateList", Constants.NBT.TAG_COMPOUND); @@ -178,7 +177,7 @@ public void readFromNBT(NBTTagCompound tag) { reagentTargetList.put(reagent, coordList); } - reagentTankDesignationList = new HashMap(); + reagentTankDesignationList = new HashMap<>(); NBTTagList tankDesignationList = tag.getTagList("tankDesignationList", Constants.NBT.TAG_COMPOUND); @@ -187,14 +186,14 @@ public void readFromNBT(NBTTagCompound tag) { this.reagentTankDesignationList.put( ReagentRegistry.getReagentForKey(savedTag.getString("reagent")), - new Integer(savedTag.getInteger("integer"))); + savedTag.getInteger("integer")); } } public void readClientNBT(NBTTagCompound tag) { NBTTagList tagList = tag.getTagList("destinationList", Constants.NBT.TAG_COMPOUND); - destinationList = new LinkedList(); + destinationList = new LinkedList<>(); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound savedTag = tagList.getCompoundTagAt(i); @@ -216,19 +215,19 @@ public void readClientNBT(NBTTagCompound tag) { public void writeClientNBT(NBTTagCompound tag) { NBTTagList tagList = new NBTTagList(); - for (int i = 0; i < destinationList.size(); i++) { + for (ColourAndCoords colourAndCoords : destinationList) { NBTTagCompound savedTag = new NBTTagCompound(); - tagList.appendTag(destinationList.get(i).writeToNBT(savedTag)); + tagList.appendTag(colourAndCoords.writeToNBT(savedTag)); } tag.setTag("destinationList", tagList); NBTTagList reagentTagList = new NBTTagList(); - for (int i = 0; i < this.tanks.length; i++) { + for (ReagentContainer tank : this.tanks) { NBTTagCompound savedTag = new NBTTagCompound(); - if (this.tanks[i] != null) { - this.tanks[i].writeToNBT(savedTag); + if (tank != null) { + tank.writeToNBT(savedTag); } reagentTagList.appendTag(savedTag); } @@ -276,9 +275,9 @@ public void updateEntity() { continue; } - int x = xCoord + coord.xCoord; - int y = yCoord + coord.yCoord; - int z = zCoord + coord.zCoord; + int x = xCoord + coord.x(); + int y = yCoord + coord.y(); + int z = zCoord + coord.z(); TileEntity tile = worldObj.getTileEntity(x, y, z); if (tile instanceof IReagentHandler) { @@ -315,25 +314,24 @@ public void updateEntity() { public void sendPlayerStuffs() { Minecraft mc = Minecraft.getMinecraft(); EntityPlayer player = mc.thePlayer; - World world = mc.theWorld; if (SpellHelper.canPlayerSeeAlchemy(player)) { for (ColourAndCoords colourSet : this.destinationList) { if (!(worldObj.getTileEntity( - xCoord + colourSet.xCoord, - yCoord + colourSet.yCoord, - zCoord + colourSet.zCoord) instanceof IReagentHandler)) { + xCoord + colourSet.x(), + yCoord + colourSet.y(), + zCoord + colourSet.z()) instanceof IReagentHandler)) { continue; } EntityParticleBeam beam = new EntityParticleBeam(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - double velocity = Math.sqrt( - Math.pow(colourSet.xCoord, 2) + Math.pow(colourSet.yCoord, 2) + Math.pow(colourSet.zCoord, 2)); + double velocity = Math + .sqrt(Math.pow(colourSet.x(), 2) + Math.pow(colourSet.y(), 2) + Math.pow(colourSet.z(), 2)); double wantedVel = 0.3d; beam.setVelocity( - wantedVel * colourSet.xCoord / velocity, - wantedVel * colourSet.yCoord / velocity, - wantedVel * colourSet.zCoord / velocity); - beam.setColour(colourSet.colourRed / 255f, colourSet.colourGreen / 255f, colourSet.colourBlue / 255f); - beam.setDestination(xCoord + colourSet.xCoord, yCoord + colourSet.yCoord, zCoord + colourSet.zCoord); + wantedVel * colourSet.x() / velocity, + wantedVel * colourSet.y() / velocity, + wantedVel * colourSet.z() / velocity); + beam.setColour(colourSet.red() / 255f, colourSet.green() / 255f, colourSet.blue() / 255f); + beam.setDestination(xCoord + colourSet.x(), yCoord + colourSet.y(), zCoord + colourSet.z()); worldObj.spawnEntityInWorld(beam); } } @@ -353,7 +351,7 @@ public void updateColourList() { } public List compileListForReagentTargets(Map> map) { - List list = new LinkedList(); + List list = new LinkedList<>(); for (Entry> entry : map.entrySet()) { if (entry.getValue() != null) { @@ -368,13 +366,13 @@ public List compileListForReagentTargets(Map coordList = this.reagentTargetList.get(reagent); if (coordList == null) { - List newCoordList = new LinkedList(); + List newCoordList = new LinkedList<>(); newCoordList.add(newCoord); this.reagentTargetList.put(reagent, newCoordList); } else { @@ -449,7 +447,7 @@ public boolean addReagentDestinationViaOffset(Reagent reagent, int xOffset, int return true; } else { - List newCoordList = new LinkedList(); + List newCoordList = new LinkedList<>(); newCoordList.add(newCoord); this.reagentTargetList.put(reagent, newCoordList); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESchematicSaver.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESchematicSaver.java index c52867e49a..7251c71198 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESchematicSaver.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESchematicSaver.java @@ -41,21 +41,13 @@ public void rightClickBlock(EntityPlayer player, int side) { } } } - - AlchemicalWizardry.logger.info("" + i); } - - AlchemicalWizardry.logger.info("I got here!"); Gson gson = new GsonBuilder().setPrettyPrinting().create(); String json = gson.toJson(schematic); - AlchemicalWizardry.logger.info("Here, too!"); - Writer writer; - try { - writer = new FileWriter("config/BloodMagic/schematics/" + new Random().nextInt() + ".json"); + try (Writer writer = new FileWriter("config/BloodMagic/schematics/" + new Random().nextInt() + ".json")) { writer.write(json); - writer.close(); } catch (IOException e) { - e.printStackTrace(); + AlchemicalWizardry.logger.error(e); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESocket.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESocket.java index c763801b58..4cc3fd6a04 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESocket.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESocket.java @@ -25,21 +25,21 @@ public TESocket() { } @Override - public void readFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readFromNBT(par1NBTTagCompound); + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); - resultID = par1NBTTagCompound.getInteger("resultID"); - resultDamage = par1NBTTagCompound.getInteger("resultDamage"); - isActive = par1NBTTagCompound.getBoolean("isActive"); + resultID = tag.getInteger("resultID"); + resultDamage = tag.getInteger("resultDamage"); + isActive = tag.getBoolean("isActive"); } @Override - public void writeToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeToNBT(par1NBTTagCompound); + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); - par1NBTTagCompound.setInteger("resultID", resultID); - par1NBTTagCompound.setInteger("resultDamage", resultDamage); - par1NBTTagCompound.setBoolean("isActive", isActive); + tag.setInteger("resultID", resultID); + tag.setInteger("resultDamage", resultDamage); + tag.setBoolean("isActive", isActive); } @Override @@ -77,16 +77,11 @@ public void handlePacketData(int[] intData) { } if (intData.length == 3) { - for (int i = 0; i < 1; i++) { - if (intData[i * 3 + 2] != 0) { - ItemStack is = new ItemStack( - Item.getItemById(intData[i * 3]), - intData[i * 3 + 2], - intData[i * 3 + 1]); - inv[i] = is; - } else { - inv[i] = null; - } + if (intData[2] != 0) { + ItemStack is = new ItemStack(Item.getItemById(intData[0]), intData[2], intData[1]); + inv[0] = is; + } else { + inv[0] = null; } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpectralBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpectralBlock.java index cbeb16f4a8..706acb93af 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpectralBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpectralBlock.java @@ -15,17 +15,17 @@ public TESpectralBlock() { } @Override - public void readFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readFromNBT(par1NBTTagCompound); + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); - ticksRemaining = par1NBTTagCompound.getInteger("ticksRemaining"); + ticksRemaining = tag.getInteger("ticksRemaining"); } @Override - public void writeToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeToNBT(par1NBTTagCompound); + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); - par1NBTTagCompound.setInteger("ticksRemaining", ticksRemaining); + tag.setInteger("ticksRemaining", ticksRemaining); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpectralContainer.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpectralContainer.java index c4c0c4794e..6fe2c7034b 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpectralContainer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpectralContainer.java @@ -14,7 +14,7 @@ public class TESpectralContainer extends TileEntity { - private ItemStack[] inv; + private final ItemStack[] inv; private int ticksRemaining; @@ -25,38 +25,38 @@ public TESpectralContainer() { } @Override - public void readFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readFromNBT(par1NBTTagCompound); - NBTTagList tagList = par1NBTTagCompound.getTagList("Inventory", Constants.NBT.TAG_COMPOUND); + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); + NBTTagList tagList = tag.getTagList("Inventory", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < tagList.tagCount(); i++) { - NBTTagCompound tag = tagList.getCompoundTagAt(i); - int slot = tag.getByte("Slot"); + NBTTagCompound slot = tagList.getCompoundTagAt(i); + int s = slot.getByte("Slot"); - if (slot >= 0 && slot < inv.length) { - inv[slot] = ItemStack.loadItemStackFromNBT(tag); + if (s >= 0 && s < inv.length) { + inv[s] = ItemStack.loadItemStackFromNBT(slot); } } - ticksRemaining = par1NBTTagCompound.getInteger("ticksRemaining"); + ticksRemaining = tag.getInteger("ticksRemaining"); } @Override - public void writeToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeToNBT(par1NBTTagCompound); + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); NBTTagList itemList = new NBTTagList(); for (int i = 0; i < inv.length; i++) { if (inv[i] != null) { - NBTTagCompound tag = new NBTTagCompound(); - tag.setByte("Slot", (byte) i); - inv[i].writeToNBT(tag); - itemList.appendTag(tag); + NBTTagCompound slot = new NBTTagCompound(); + slot.setByte("Slot", (byte) i); + inv[i].writeToNBT(slot); + itemList.appendTag(slot); } } - par1NBTTagCompound.setTag("Inventory", itemList); - par1NBTTagCompound.setInteger("ticksRemaining", ticksRemaining); + tag.setTag("Inventory", itemList); + tag.setInteger("ticksRemaining", ticksRemaining); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellBlock.java index f7fe70600f..2a37fdbaf3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellBlock.java @@ -12,8 +12,7 @@ public abstract class TESpellBlock extends TEOrientable implements ISpellTile { public void modifySpellParadigm(SpellParadigm parad) { this.applySpellChange(parad); TileEntity tile = this.getTileAtOutput(); - if (tile instanceof TESpellBlock) { - TESpellBlock outputBlock = (TESpellBlock) tile; + if (tile instanceof TESpellBlock outputBlock) { outputBlock.modifySpellParadigm(parad); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellEffectBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellEffectBlock.java index 968f0f3477..ba912c1322 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellEffectBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellEffectBlock.java @@ -13,31 +13,22 @@ protected void applySpellChange(SpellParadigm parad) { public SpellEffect getSpellEffect() { int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - switch (meta) { - case 0: - return new SpellEffect(ComplexSpellType.FIRE); - case 1: - return new SpellEffect(ComplexSpellType.ICE); - case 2: - return new SpellEffect(ComplexSpellType.WIND); - case 3: - return new SpellEffect(ComplexSpellType.EARTH); - } - return new SpellEffect(ComplexSpellType.FIRE); + return switch (meta) { + case 1 -> new SpellEffect(ComplexSpellType.ICE); + case 2 -> new SpellEffect(ComplexSpellType.WIND); + case 3 -> new SpellEffect(ComplexSpellType.EARTH); + default -> new SpellEffect(ComplexSpellType.FIRE); + }; } @Override public String getResourceLocationForMeta(int meta) { - switch (meta) { - case 0: - return "alchemicalwizardry:textures/models/SpellEffectFire.png"; - case 1: - return "alchemicalwizardry:textures/models/SpellEffectIce.png"; - case 2: - return "alchemicalwizardry:textures/models/SpellEffectWind.png"; - case 3: - return "alchemicalwizardry:textures/models/SpellEffectEarth.png"; - } - return ""; + return switch (meta) { + case 0 -> "alchemicalwizardry:textures/models/SpellEffectFire.png"; + case 1 -> "alchemicalwizardry:textures/models/SpellEffectIce.png"; + case 2 -> "alchemicalwizardry:textures/models/SpellEffectWind.png"; + case 3 -> "alchemicalwizardry:textures/models/SpellEffectEarth.png"; + default -> ""; + }; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellEnhancementBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellEnhancementBlock.java index 39448f3c98..e714dffad7 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellEnhancementBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellEnhancementBlock.java @@ -10,19 +10,12 @@ public class TESpellEnhancementBlock extends TESpellBlock { @Override protected void applySpellChange(SpellParadigm parad) { - int i = -1; - - switch (this.enhancementType()) { - case 0: - i = parad.getBufferedEffectPower(); - break; - case 1: - i = parad.getBufferedEffectCost(); - break; - case 2: - i = parad.getBufferedEffectPotency(); - break; - } + int i = switch (this.enhancementType()) { + case 0 -> parad.getBufferedEffectPower(); + case 1 -> parad.getBufferedEffectCost(); + case 2 -> parad.getBufferedEffectPotency(); + default -> -1; + }; if (i != -1 && i < this.getLimit()) { parad.applyEnhancement(getSpellEnhancement()); @@ -32,123 +25,43 @@ protected void applySpellChange(SpellParadigm parad) { } public SpellEnhancement getSpellEnhancement() { - int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - switch (meta) { - case 0: - case 1: - case 2: - case 3: - case 4: - return new SpellEnhancementPower(); - case 5: - case 6: - case 7: - case 8: - case 9: - return new SpellEnhancementCost(); - case 10: - case 11: - case 12: - case 13: - case 14: - return new SpellEnhancementPotency(); - } - return new SpellEnhancementCost(); + return switch (enhancementType()) { + case 0 -> new SpellEnhancementPower(); + case 2 -> new SpellEnhancementPotency(); + default -> new SpellEnhancementCost(); + }; } public int getLimit() { int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - switch (meta) { - case 0: - return 1; - case 1: - return 2; - case 2: - return 3; - case 3: - return 4; - case 4: - return 5; - case 5: - return 1; - case 6: - return 2; - case 7: - return 3; - case 8: - return 4; - case 9: - return 5; - case 10: - return 1; - case 11: - return 2; - case 12: - return 3; - case 13: - return 4; - case 14: - return 5; - } - return 0; + if (meta > 14) return 0; + return meta % 5 + 1; } - public int enhancementType() // 0 is power, 1 is cost, 2 is potency - { + // 0 is power, 1 is cost, 2 is potency, -1 is invalid + public int enhancementType() { int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - switch (meta) { - case 0: - case 1: - case 2: - case 3: - case 4: - return 0; - case 5: - case 6: - case 7: - case 8: - case 9: - return 1; - case 10: - case 11: - case 12: - case 13: - case 14: - return 2; - } - return 1; + if (meta > 14) return -1; + return meta / 5; } public void doBadStuff() {} @Override public String getResourceLocationForMeta(int meta) { - switch (meta) { - case 0: - return "alchemicalwizardry:textures/models/SpellEnhancementPower1.png"; - case 1: - return "alchemicalwizardry:textures/models/SpellEnhancementPower2.png"; - case 2: - return "alchemicalwizardry:textures/models/SpellEnhancementPower3.png"; - case 3: - return "alchemicalwizardry:textures/models/SpellEnhancementPower4.png"; - case 5: - return "alchemicalwizardry:textures/models/SpellEnhancementCost1.png"; - case 6: - return "alchemicalwizardry:textures/models/SpellEnhancementCost2.png"; - case 7: - return "alchemicalwizardry:textures/models/SpellEnhancementCost3.png"; - case 8: - return "alchemicalwizardry:textures/models/SpellEnhancementCost4.png"; - case 10: - return "alchemicalwizardry:textures/models/SpellEnhancementPotency1.png"; - case 11: - return "alchemicalwizardry:textures/models/SpellEnhancementPotency2.png"; - case 12: - return "alchemicalwizardry:textures/models/SpellEnhancementPotency3.png"; - case 13: - return "alchemicalwizardry:textures/models/SpellEnhancementPotency4.png"; - } - return "alchemicalwizardry:textures/models/SpellEnhancementPower1.png"; + return switch (meta) { + case 1 -> "alchemicalwizardry:textures/models/SpellEnhancementPower2.png"; + case 2 -> "alchemicalwizardry:textures/models/SpellEnhancementPower3.png"; + case 3 -> "alchemicalwizardry:textures/models/SpellEnhancementPower4.png"; + case 5 -> "alchemicalwizardry:textures/models/SpellEnhancementCost1.png"; + case 6 -> "alchemicalwizardry:textures/models/SpellEnhancementCost2.png"; + case 7 -> "alchemicalwizardry:textures/models/SpellEnhancementCost3.png"; + case 8 -> "alchemicalwizardry:textures/models/SpellEnhancementCost4.png"; + case 10 -> "alchemicalwizardry:textures/models/SpellEnhancementPotency1.png"; + case 11 -> "alchemicalwizardry:textures/models/SpellEnhancementPotency2.png"; + case 12 -> "alchemicalwizardry:textures/models/SpellEnhancementPotency3.png"; + case 13 -> "alchemicalwizardry:textures/models/SpellEnhancementPotency4.png"; + default -> "alchemicalwizardry:textures/models/SpellEnhancementPower1.png"; + }; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellModifierBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellModifierBlock.java index 12c7df084f..2657085ac8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellModifierBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellModifierBlock.java @@ -12,31 +12,21 @@ protected void applySpellChange(SpellParadigm parad) { public ComplexSpellModifier getSpellModifier() { int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - switch (meta) { - case 0: - return ComplexSpellModifier.DEFAULT; - case 1: - return ComplexSpellModifier.OFFENSIVE; - case 2: - return ComplexSpellModifier.DEFENSIVE; - case 3: - return ComplexSpellModifier.ENVIRONMENTAL; - } - return ComplexSpellModifier.DEFAULT; + return switch (meta) { + case 1 -> ComplexSpellModifier.OFFENSIVE; + case 2 -> ComplexSpellModifier.DEFENSIVE; + case 3 -> ComplexSpellModifier.ENVIRONMENTAL; + default -> ComplexSpellModifier.DEFAULT; + }; } @Override public String getResourceLocationForMeta(int meta) { - switch (meta) { - case 0: - return "alchemicalwizardry:textures/models/SpellModifierDefault.png"; - case 1: - return "alchemicalwizardry:textures/models/SpellModifierOffensive.png"; - case 2: - return "alchemicalwizardry:textures/models/SpellModifierDefensive.png"; - case 3: - return "alchemicalwizardry:textures/models/SpellModifierEnvironmental.png"; - } - return "alchemicalwizardry:textures/models/SpellModifierDefault.png"; + return switch (meta) { + case 1 -> "alchemicalwizardry:textures/models/SpellModifierOffensive.png"; + case 2 -> "alchemicalwizardry:textures/models/SpellModifierDefensive.png"; + case 3 -> "alchemicalwizardry:textures/models/SpellModifierEnvironmental.png"; + default -> "alchemicalwizardry:textures/models/SpellModifierDefault.png"; + }; } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellParadigmBlock.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellParadigmBlock.java index 0f422a9029..40a38614bb 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellParadigmBlock.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TESpellParadigmBlock.java @@ -16,22 +16,18 @@ public class TESpellParadigmBlock extends TESpellBlock implements ISpellParadigm public SpellParadigm getSpellParadigm() { int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - switch (meta) { - case 0: - return new SpellParadigmProjectile(); - case 1: - return new SpellParadigmSelf(); - case 2: - return new SpellParadigmMelee(); - case 3: - return new SpellParadigmTool(); - } - return new SpellParadigmSelf(); + return switch (meta) { + case 0 -> new SpellParadigmProjectile(); + case 2 -> new SpellParadigmMelee(); + case 3 -> new SpellParadigmTool(); + default -> new SpellParadigmSelf(); + }; } @Override protected void applySpellChange(SpellParadigm parad) {} + @Override public boolean canInputRecieve() { return false; } @@ -46,17 +42,12 @@ public void castSpell(World world, EntityPlayer entity, ItemStack spellCasterSta @Override public String getResourceLocationForMeta(int meta) { - switch (meta) { - case 0: - return "alchemicalwizardry:textures/models/SpellParadigmProjectile.png"; - case 1: - return "alchemicalwizardry:textures/models/SpellParadigmSelf.png"; - case 2: - return "alchemicalwizardry:textures/models/SpellParadigmMelee.png"; - case 3: - return "alchemicalwizardry:textures/models/SpellParadigmTool.png"; - } - return "alchemicalwizardry:textures/models/SpellParadigmProjectile.png"; + return switch (meta) { + case 1 -> "alchemicalwizardry:textures/models/SpellParadigmSelf.png"; + case 2 -> "alchemicalwizardry:textures/models/SpellParadigmMelee.png"; + case 3 -> "alchemicalwizardry:textures/models/SpellParadigmTool.png"; + default -> "alchemicalwizardry:textures/models/SpellParadigmProjectile.png"; + }; } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TETeleposer.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TETeleposer.java index 5df54614f2..042cefd794 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TETeleposer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TETeleposer.java @@ -40,21 +40,21 @@ public TETeleposer() { } @Override - public void readFromNBT(NBTTagCompound par1NBTTagCompound) { - super.readFromNBT(par1NBTTagCompound); + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); - resultID = par1NBTTagCompound.getInteger("resultID"); - resultDamage = par1NBTTagCompound.getInteger("resultDamage"); - hasRedstone = par1NBTTagCompound.getBoolean("hasRedstone"); + resultID = tag.getInteger("resultID"); + resultDamage = tag.getInteger("resultDamage"); + hasRedstone = tag.getBoolean("hasRedstone"); } @Override - public void writeToNBT(NBTTagCompound par1NBTTagCompound) { - super.writeToNBT(par1NBTTagCompound); + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); - par1NBTTagCompound.setInteger("resultID", resultID); - par1NBTTagCompound.setInteger("resultDamage", resultDamage); - par1NBTTagCompound.setBoolean("hasRedstone", hasRedstone); + tag.setInteger("resultID", resultID); + tag.setInteger("resultDamage", resultDamage); + tag.setBoolean("hasRedstone", hasRedstone); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEWritingTable.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEWritingTable.java index f352c7de39..5d9e76509a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEWritingTable.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEWritingTable.java @@ -1,6 +1,7 @@ package WayofTime.alchemicalWizardry.common.tileEntity; import java.util.List; +import java.util.Objects; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.ISidedInventory; @@ -39,9 +40,11 @@ public class TEWritingTable extends TEInventory implements ISidedInventory, IBlo private int progress; private int amountUsed; - private int accelerationTime; + private static final int[] inputSides = { 0, 1, 2, 3, 4, 5 }; + private static final int[] outputSides = { 6 }; + public TEWritingTable() { super(sizeInv); } @@ -73,11 +76,8 @@ public String getInventoryName() { @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { - switch (i) { - case 0: - if (itemstack != null) { - return itemstack.getItem() instanceof IBloodOrb; - } + if (i == 0 && itemstack != null) { + return itemstack.getItem() instanceof IBloodOrb; } return i != 6; } @@ -129,9 +129,7 @@ public int[] buildIntDataList() { public ItemStack getResultingItemStack() { ItemStack[] composedRecipe = new ItemStack[5]; - for (int i = 0; i < 5; i++) { - composedRecipe[i] = inv[i + 1]; - } + System.arraycopy(inv, 1, composedRecipe, 0, 5); return AlchemyRecipeRegistry.getResult(composedRecipe, inv[0]); } @@ -143,9 +141,7 @@ public boolean isRecipeValid() { public int getAmountNeeded(ItemStack bloodOrb) { ItemStack[] composedRecipe = new ItemStack[5]; - for (int i = 0; i < 5; i++) { - composedRecipe[i] = inv[i + 1]; - } + System.arraycopy(inv, 1, composedRecipe, 0, 5); return AlchemyRecipeRegistry.getAmountNeeded(composedRecipe, bloodOrb); } @@ -166,11 +162,7 @@ public int getPotionFlaskPosition() { } public boolean containsCombinationCatalyst() { - if (getCombinationCatalystPosition() != -1) { - return true; - } else { - return false; - } + return getCombinationCatalystPosition() != -1; } public int getCombinationCatalystPosition() { @@ -190,9 +182,7 @@ public boolean containsRegisteredPotionIngredient() { public int getRegisteredPotionIngredientPosition() { ItemStack[] composedRecipe = new ItemStack[5]; - for (int i = 0; i < 5; i++) { - composedRecipe[i] = inv[i + 1]; - } + System.arraycopy(inv, 1, composedRecipe, 0, 5); int location = AlchemicalPotionCreationHandler.getRegisteredPotionIngredientPosition(composedRecipe); @@ -306,8 +296,10 @@ public void updateEntity() { } int potionID = AlchemicalPotionCreationHandler.getPotionIDForStack(ingredientStack); - int catalystLevel = ((ICatalyst) catalystStack.getItem()).getCatalystLevel(); - boolean isConcentration = ((ICatalyst) catalystStack.getItem()).isConcentration(); + ICatalyst catalyst = (ICatalyst) catalystStack.getItem(); + assert catalyst != null; + int catalystLevel = catalyst.getCatalystLevel(); + boolean isConcentration = catalyst.isConcentration(); if (potionID == -1 || catalystLevel < 0) { progress = 0; @@ -319,12 +311,12 @@ public void updateEntity() { return; } + AlchemyFlask flask = (AlchemyFlask) flaskStack.getItem(); + assert flask != null; if (isConcentration) { - ((AlchemyFlask) flaskStack.getItem()) - .setConcentrationOfPotion(flaskStack, potionID, catalystLevel); + flask.setConcentrationOfPotion(flaskStack, potionID, catalystLevel); } else { - ((AlchemyFlask) flaskStack.getItem()) - .setDurationFactorOfPotion(flaskStack, potionID, catalystLevel); + flask.setDurationFactorOfPotion(flaskStack, potionID, catalystLevel); } this.setInventorySlotContents(6, flaskStack); this.decrStackSize(this.getPotionFlaskPosition(), 1); @@ -370,13 +362,15 @@ public void updateEntity() { return; } - int potionEffectNumber = ((AlchemyFlask) flaskStack.getItem()) - .getNumberOfPotionEffects(flaskStack); + AlchemyFlask flask = (AlchemyFlask) flaskStack.getItem(); + assert flask != null; + int potionEffectNumber = flask.getNumberOfPotionEffects(flaskStack); int potionID = AlchemicalPotionCreationHandler.getPotionIDForStack(ingredientStack); int tickDuration = AlchemicalPotionCreationHandler .getPotionTickDurationForStack(ingredientStack); - float successChance = ((IBindingAgent) agentStack.getItem()) - .getSuccessRateForPotionNumber(potionEffectNumber); + IBindingAgent binder = (IBindingAgent) agentStack.getItem(); + assert binder != null; + float successChance = binder.getSuccessRateForPotionNumber(potionEffectNumber); if (potionID == -1) { progress = 0; @@ -387,7 +381,7 @@ public void updateEntity() { return; } - ((AlchemyFlask) flaskStack.getItem()).addPotionEffect(flaskStack, potionID, tickDuration); + flask.addPotionEffect(flaskStack, potionID, tickDuration); if (successChance > worldObj.rand.nextFloat()) { this.setInventorySlotContents(6, flaskStack); } else { @@ -436,7 +430,9 @@ public void updateEntity() { return; } - ((AlchemyFlask) flaskStack.getItem()).setIsPotionThrowable(true, flaskStack); + AlchemyFlask flask = (AlchemyFlask) flaskStack.getItem(); + assert flask != null; + flask.setIsPotionThrowable(true, flaskStack); this.setInventorySlotContents(6, flaskStack); this.decrStackSize(this.getPotionFlaskPosition(), 1); this.decrStackSize(this.getBlankSlatePosition(), 1); @@ -478,9 +474,12 @@ public void updateEntity() { return; } - int potionEffects = ((AlchemyFlask) flaskStack.getItem()).getNumberOfPotionEffects(flaskStack); - int potionFillAmount = ((IFillingAgent) fillingAgent.getItem()) - .getFilledAmountForPotionNumber(potionEffects); + AlchemyFlask flask = (AlchemyFlask) flaskStack.getItem(); + assert flask != null; + int potionEffects = flask.getNumberOfPotionEffects(flaskStack); + IFillingAgent fillingAgentItem = (IFillingAgent) fillingAgent.getItem(); + assert fillingAgentItem != null; + int potionFillAmount = fillingAgentItem.getFilledAmountForPotionNumber(potionEffects); flaskStack.setItemDamage(Math.max(0, flaskStack.getItemDamage() - potionFillAmount)); this.setInventorySlotContents(6, flaskStack); this.decrStackSize(this.getPotionFlaskPosition(), 1); @@ -585,9 +584,7 @@ public void updateEntity() { ItemStack[] composedRecipe = new ItemStack[5]; - for (int i = 0; i < 5; i++) { - composedRecipe[i] = inv[i + 1]; - } + System.arraycopy(inv, 1, composedRecipe, 0, 5); this.decrementSlots(this.getRecipeForItems(composedRecipe, inv[0])); @@ -628,9 +625,7 @@ && getResultingItemStack().stackSize ItemStack[] composedRecipe = new ItemStack[5]; - for (int i = 0; i < 5; i++) { - composedRecipe[i] = inv[i + 1]; - } + System.arraycopy(inv, 1, composedRecipe, 0, 5); this.decrementSlots(this.getRecipeForItems(composedRecipe, inv[0])); @@ -642,8 +637,7 @@ && getResultingItemStack().stackSize } } - public void decrementSlots(ItemStack[] recipe) // TODO Fix this. This doesn't work. - { + public void decrementSlots(ItemStack[] recipe) { boolean[] decrementedList = new boolean[] { false, false, false, false, false }; for (int i = 0; i < (Math.min(recipe.length, 5)); i++) { @@ -660,7 +654,7 @@ public void decrementSlots(ItemStack[] recipe) // TODO Fix this. This doesn't wo && (testStack.isItemEqual(decStack) || (testStack.getItem() == decStack.getItem() && decStack.getItemDamage() == OreDictionary.WILDCARD_VALUE)) && !(decrementedList[j])) { - if (testStack.getItem().hasContainerItem(testStack)) { + if (testStack.getItem() != null && testStack.getItem().hasContainerItem(testStack)) { this.inv[j + 1] = testStack.getItem().getContainerItem(testStack); } else { this.decrStackSize(j + 1, 1); @@ -708,12 +702,10 @@ public void setAccelerationTime(int accelerationTime) { @Override public int[] getAccessibleSlotsFromSide(int side) { ForgeDirection dir = ForgeDirection.getOrientation(side); - switch (dir) { - case DOWN: - return new int[] { 6 }; - default: - return new int[] { 0, 1, 2, 3, 4, 5 }; + if (Objects.requireNonNull(dir) == ForgeDirection.DOWN) { + return outputSides; } + return inputSides; } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/container/ContainerAltar.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/container/ContainerAltar.java index 1ea88f7a6b..0fe8317fa6 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/container/ContainerAltar.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/container/ContainerAltar.java @@ -44,7 +44,7 @@ protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) { @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { ItemStack stack = null; - Slot slotObject = (Slot) inventorySlots.get(slot); + Slot slotObject = inventorySlots.get(slot); if (slotObject != null && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); stack = stackInSlot.copy(); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/container/ContainerTeleposer.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/container/ContainerTeleposer.java index d7a3648dcb..2a5bc5a0dc 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/container/ContainerTeleposer.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/container/ContainerTeleposer.java @@ -40,7 +40,7 @@ protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) { @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { ItemStack stack = null; - Slot slotObject = (Slot) inventorySlots.get(slot); + Slot slotObject = inventorySlots.get(slot); int slots = inventorySlots.size(); if (slotObject != null && slotObject.getHasStack()) { @@ -48,11 +48,7 @@ public ItemStack transferStackInSlot(EntityPlayer player, int slot) { stack = stackInSlot.copy(); if (stack.getItem() instanceof TelepositionFocus) { - if (slot <= slots) { - if (!this.mergeItemStack(stackInSlot, 0, slots, false)) { - return null; - } - } else if (!this.mergeItemStack(stackInSlot, slots, 36 + slots, false)) { + if (!this.mergeItemStack(stackInSlot, 0, slots, false)) { return null; } } @@ -73,7 +69,7 @@ public ItemStack transferStackInSlot(EntityPlayer player, int slot) { return stack; } - private class SlotTeleposer extends Slot { + private static class SlotTeleposer extends Slot { public SlotTeleposer(IInventory inventory, int slotIndex, int x, int y) { super(inventory, slotIndex, x, y); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/container/ContainerWritingTable.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/container/ContainerWritingTable.java index 64066c9c12..5f93ea53ee 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/container/ContainerWritingTable.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/container/ContainerWritingTable.java @@ -45,7 +45,7 @@ protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) { @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { ItemStack stack = null; - Slot slotObject = (Slot) inventorySlots.get(slot); + Slot slotObject = inventorySlots.get(slot); if (slotObject != null && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); stack = stackInSlot.copy(); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/Alchemy.java b/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/Alchemy.java index a9ef38c23f..dc929970a6 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/Alchemy.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/Alchemy.java @@ -50,12 +50,12 @@ public void undo() { @Override public String describe() { - return "Adding Alchemy Recipe for " + ((AlchemyRecipe) recipe).getResult().getDisplayName(); + return "Adding Alchemy Recipe for " + recipe.getResult().getDisplayName(); } @Override public String describeUndo() { - return "Removing Alchemy Recipe for " + ((AlchemyRecipe) recipe).getResult().getDisplayName(); + return "Removing Alchemy Recipe for " + recipe.getResult().getDisplayName(); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/Binding.java b/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/Binding.java index a58b239ef8..4c290788ab 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/Binding.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/Binding.java @@ -48,12 +48,12 @@ public void undo() { @Override public String describe() { - return "Adding Binding Recipe for " + ((BindingRecipe) recipe).getResult().getDisplayName(); + return "Adding Binding Recipe for " + recipe.getResult().getDisplayName(); } @Override public String describeUndo() { - return "Removing Binding Recipe for " + ((BindingRecipe) recipe).getResult().getDisplayName(); + return "Removing Binding Recipe for " + recipe.getResult().getDisplayName(); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/BloodAltar.java b/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/BloodAltar.java index ca9ec62261..9d1ab58257 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/BloodAltar.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/BloodAltar.java @@ -53,12 +53,12 @@ public void undo() { @Override public String describe() { - return "Adding Blood Altar Recipe for " + ((AltarRecipe) recipe).getResult().getDisplayName(); + return "Adding Blood Altar Recipe for " + recipe.getResult().getDisplayName(); } @Override public String describeUndo() { - return "Removing Blood Altar Recipe for " + ((AltarRecipe) recipe).getResult().getDisplayName(); + return "Removing Blood Altar Recipe for " + recipe.getResult().getDisplayName(); } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/BloodOrb.java b/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/BloodOrb.java index c719ee894c..9c228ae9b0 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/BloodOrb.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/BloodOrb.java @@ -112,7 +112,7 @@ public Remove(ItemStack output) { @Override public void apply() { - for (IRecipe r : (List) CraftingManager.getInstance().getRecipeList()) { + for (IRecipe r : CraftingManager.getInstance().getRecipeList()) { if ((r instanceof ShapedBloodOrbRecipe || r instanceof ShapelessBloodOrbRecipe) && r.getRecipeOutput() != null && r.getRecipeOutput().isItemEqual(output)) { diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/HarvestMoon.java b/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/HarvestMoon.java index ea7e5d6469..9102725e18 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/HarvestMoon.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/HarvestMoon.java @@ -40,8 +40,8 @@ public static void addHarvestable(IItemStack block, int meta, IItemStack seed) { private static class Add implements IUndoableAction { - private IHarvestHandler handler; - private String name; + private final IHarvestHandler handler; + private final String name; public Add(Block block, int meta, ItemStack seed) { handler = new GenericItemStackHarvestHandler(block, meta, seed); diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/MTHelper.java b/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/MTHelper.java index b44ce11628..a049f85940 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/MTHelper.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tweaker/MTHelper.java @@ -59,7 +59,7 @@ public static Object[] toObjects(IIngredient[] ingredient) { public static Object[] toShapedObjects(IIngredient[][] ingredients) { if (ingredients == null) return null; else { - ArrayList prep = new ArrayList(); + ArrayList prep = new ArrayList<>(); prep.add("abc"); prep.add("def"); prep.add("ghi"); @@ -79,6 +79,6 @@ public static Object[] toShapedObjects(IIngredient[][] ingredients) { } public static String toString(IOreDictEntry entry) { - return ((IOreDictEntry) entry).getName(); + return entry.getName(); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/compat/structurelib/AltarStructure.java b/src/main/java/WayofTime/alchemicalWizardry/compat/structurelib/AltarStructure.java index d579228a40..b170859f3c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/compat/structurelib/AltarStructure.java +++ b/src/main/java/WayofTime/alchemicalWizardry/compat/structurelib/AltarStructure.java @@ -18,7 +18,6 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; -import com.github.bsideup.jabel.Desugar; import com.google.common.base.Joiner; import com.gtnewhorizon.structurelib.alignment.constructable.IMultiblockInfoContainer; import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; @@ -104,9 +103,9 @@ public static void registerAltarStructureInfo() { altarBuilder.addElement(keys[i], ofChain( values[i].stream() - .map(s -> s.getMeta() == OreDictionary.WILDCARD_VALUE - ? ofBlockAnyMeta(s.getBlock()) - : ofBlock(s.getBlock(), s.getMeta())) + .map(s -> s.meta() == OreDictionary.WILDCARD_VALUE + ? ofBlockAnyMeta(s.block()) + : ofBlock(s.block(), s.meta())) .toArray(IStructureElement[]::new) ) ); @@ -118,7 +117,6 @@ public static void registerAltarStructureInfo() { // spotless:on } - @Desugar private record AltarMultiblockInfoContainer(IStructureDefinition structureAltar) implements IMultiblockInfoContainer {