From 00d6f8eb460ede774dfedab2e63f4a13124f5e82 Mon Sep 17 00:00:00 2001 From: Nicholas Ignoffo Date: Mon, 12 Dec 2016 19:56:36 -0800 Subject: [PATCH] Initial stab at 1.11 About halfway. --- build.gradle | 4 +- gradle.properties | 15 +- .../java/WayofTime/bloodmagic/BloodMagic.java | 36 +--- .../api/recipe/AlchemyTableRecipe.java | 4 +- .../api/registry/RitualRegistry.java | 2 + .../api/teleport/TeleporterBloodMagic.java | 2 +- .../block/base/BlockEnumStairs.java | 3 +- .../compat/buttons/BloodMagicPlugin.java | 25 --- .../buttons/button/ButtonFillNetwork.java | 41 ---- .../guideapi/CompatibilityGuideAPI.java | 70 ------ .../compat/guideapi/GuideBloodMagic.java | 42 ++-- .../guideapi/page/PageAlchemyArray.java | 11 +- .../compat/guideapi/page/PageAltarRecipe.java | 2 +- .../AlchemyArrayCraftingCategory.java | 14 +- .../AlchemyArrayCraftingRecipeHandler.java | 8 - .../AlchemyArrayCraftingRecipeJEI.java | 15 +- .../AlchemyTableRecipeCategory.java | 20 +- .../AlchemyTableRecipeHandler.java | 8 - .../alchemyTable/AlchemyTableRecipeJEI.java | 31 +-- .../compat/jei/altar/AltarRecipeCategory.java | 14 +- .../compat/jei/altar/AltarRecipeHandler.java | 8 - .../compat/jei/altar/AltarRecipeJEI.java | 19 +- .../ArmourDowngradeRecipeCategory.java | 20 +- .../ArmourDowngradeRecipeHandler.java | 10 +- .../ArmourDowngradeRecipeJEI.java | 45 +--- .../minecraft/CrossVersionProxy110.java | 39 ---- .../compat/minecraft/CrossVersionProxy19.java | 31 --- .../compat/minecraft/ICrossVersionProxy.java | 17 -- .../compat/waila/WailaCallbackHandler.java | 6 - .../provider/DataProviderAlchemyArray.java | 4 +- .../provider/DataProviderBloodAltar.java | 8 +- .../waila/provider/DataProviderBloodTank.java | 2 +- .../waila/provider/DataProviderMimic.java | 2 +- .../waila/provider/DataProviderPillar.java | 43 ---- .../DataProviderRitualController.java | 2 +- .../waila/provider/DataProviderTeleposer.java | 2 +- .../compress/AdvancedCompressionHandler.java | 32 +-- .../compress/BaseCompressionHandler.java | 12 +- .../compress/StorageBlockCraftingManager.java | 30 +-- ...StorageBlockCraftingRecipeAssimilator.java | 14 +- .../bloodmagic/demonAura/WillChunk.java | 10 +- .../demonAura/WorldDemonWillHandler.java | 3 + .../entity/ai/EntityAIAttackRangedBow.java | 4 +- .../entity/ai/EntityAIAttackStealthMelee.java | 2 +- .../entity/ai/EntityAIEatAndCorruptBlock.java | 2 +- .../entity/ai/EntityAIFollowOwner.java | 10 +- .../ai/EntityAIGrabEffectsFromOwner.java | 10 +- .../entity/ai/EntityAIPickUpAlly.java | 4 +- .../entity/ai/EntityAIProtectAlly.java | 2 +- .../entity/ai/EntityAIRetreatToHeal.java | 2 +- .../entity/ai/EntityAIStealthRetreat.java | 2 +- .../ai/EntityAIStealthTowardsTarget.java | 4 +- .../entity/mob/EntityAspectedDemonBase.java | 6 +- .../entity/mob/EntityCorruptedChicken.java | 4 +- .../entity/mob/EntityCorruptedSheep.java | 4 +- .../entity/mob/EntityCorruptedSpider.java | 20 +- .../entity/mob/EntityCorruptedZombie.java | 27 +-- .../entity/mob/EntityDemonBase.java | 40 ++-- .../bloodmagic/entity/mob/EntityMimic.java | 26 +-- .../entity/mob/EntitySentientSpecter.java | 58 +++-- .../entity/projectile/EntityBloodLight.java | 12 +- .../entity/projectile/EntityMeteor.java | 6 +- .../projectile/EntitySentientArrow.java | 2 +- .../entity/projectile/EntitySoulSnare.java | 6 +- .../fakePlayer/FakeNetHandlerPlayServer.java | 73 ++++--- .../bloodmagic/fakePlayer/FakePlayerBM.java | 2 - .../bloodmagic/gson/Serializers.java | 2 +- .../inversion/InversionPillarHandler.java | 33 +-- .../item/armour/ItemLivingArmour.java | 12 +- .../bloodmagic/livingArmour/LivingArmour.java | 4 +- .../LivingArmourUpgradeDisoriented.java | 4 +- .../LivingArmourUpgradeMeleeDecrease.java | 2 +- .../LivingArmourUpgradeSlowness.java | 2 +- .../LivingArmourUpgradeFallProtect.java | 2 +- .../LivingArmourUpgradeHealthboost.java | 2 +- .../LivingArmourUpgradeKnockbackResist.java | 4 +- .../LivingArmourUpgradeMeleeDamage.java | 2 +- .../upgrade/LivingArmourUpgradeRepairing.java | 2 +- .../LivingArmourUpgradeSolarPowered.java | 2 +- .../upgrade/LivingArmourUpgradeSpeed.java | 2 +- .../bloodmagic/meteor/MeteorComponent.java | 6 +- .../PlayerVelocityPacketProcessor.java | 2 +- .../bloodmagic/potion/BMPotionUtils.java | 2 +- .../potion/PotionEventHandlers.java | 6 +- .../potion/item/ItemPotionFlask.java | 3 +- .../AlchemyTableDyeableRecipe.java | 29 +-- .../AlchemyTablePotionAugmentRecipe.java | 18 +- .../AlchemyTablePotionRecipe.java | 47 ++-- .../bloodmagic/registry/ModCompatibility.java | 2 - .../bloodmagic/registry/ModEntities.java | 26 ++- .../bloodmagic/registry/ModRecipes.java | 2 +- .../bloodmagic/ritual/RitualAltarBuilder.java | 42 ++-- .../bloodmagic/ritual/RitualAnimalGrowth.java | 9 +- .../bloodmagic/ritual/RitualArmourEvolve.java | 2 +- .../bloodmagic/ritual/RitualCobblestone.java | 2 +- .../bloodmagic/ritual/RitualCrushing.java | 58 ++--- .../bloodmagic/ritual/RitualExpulsion.java | 30 +-- .../ritual/RitualFeatheredKnife.java | 2 +- .../bloodmagic/ritual/RitualFelling.java | 8 +- .../bloodmagic/ritual/RitualForsakenSoul.java | 2 +- .../bloodmagic/ritual/RitualFullStomach.java | 2 +- .../bloodmagic/ritual/RitualJumping.java | 33 ++- .../bloodmagic/ritual/RitualMagnetic.java | 5 +- .../bloodmagic/ritual/RitualMeteor.java | 2 +- .../bloodmagic/ritual/RitualPlacer.java | 34 +-- .../bloodmagic/ritual/RitualPortal.java | 14 +- .../bloodmagic/ritual/RitualPump.java | 16 +- .../ritual/RitualUpgradeRemove.java | 4 +- .../ritual/RitualWellOfSuffering.java | 2 +- .../bloodmagic/ritual/RitualZephyr.java | 40 ++-- .../harvest/HarvestHandlerPlantable.java | 6 +- .../ritual/harvest/HarvestHandlerStem.java | 2 +- .../ritual/harvest/HarvestHandlerTall.java | 2 +- .../imperfect/ImperfectRitualZombie.java | 2 +- .../bloodmagic/ritual/portal/Teleports.java | 32 +-- .../bloodmagic/routing/DefaultItemFilter.java | 25 +-- .../routing/IgnoreNBTItemFilter.java | 2 +- .../bloodmagic/routing/ModIdItemFilter.java | 2 +- .../bloodmagic/routing/TestItemFilter.java | 49 ++--- .../structures/BuildTestStructure.java | 4 +- .../bloodmagic/structures/Dungeon.java | 12 +- .../bloodmagic/tile/TileAlchemyArray.java | 4 +- .../bloodmagic/tile/TileAlchemyTable.java | 61 ++---- .../bloodmagic/tile/TileDemonCrucible.java | 22 +- .../bloodmagic/tile/TileDemonCrystal.java | 34 +-- .../tile/TileDemonCrystallizer.java | 20 +- .../bloodmagic/tile/TileDemonPylon.java | 10 +- .../bloodmagic/tile/TileIncenseAltar.java | 18 +- .../bloodmagic/tile/TileInventory.java | 32 +-- .../bloodmagic/tile/TileInversionPillar.java | 52 ++--- .../tile/TileMasterRitualStone.java | 2 +- .../WayofTime/bloodmagic/tile/TileMimic.java | 63 +++--- .../bloodmagic/tile/TilePhantomBlock.java | 4 +- .../tile/TilePurificationAltar.java | 8 +- .../bloodmagic/tile/TileSoulForge.java | 46 ++-- .../bloodmagic/tile/TileSpectralBlock.java | 4 +- .../bloodmagic/tile/TileTeleposer.java | 27 ++- .../tile/container/ContainerAlchemyTable.java | 24 +-- .../container/ContainerItemRoutingNode.java | 24 +-- .../container/ContainerMasterRoutingNode.java | 2 +- .../tile/container/ContainerSoulForge.java | 22 +- .../tile/container/ContainerTeleposer.java | 18 +- .../tile/routing/TileFilteredRoutingNode.java | 14 +- .../tile/routing/TileInputRoutingNode.java | 4 +- .../tile/routing/TileMasterRoutingNode.java | 20 +- .../tile/routing/TileOutputRoutingNode.java | 4 +- .../tile/routing/TileRoutingNode.java | 10 +- .../WayofTime/bloodmagic/util/ChatUtil.java | 2 +- .../bloodmagic/util/GhostItemHelper.java | 2 +- .../java/WayofTime/bloodmagic/util/Utils.java | 201 ++++++++---------- .../util/handler/event/ClientHandler.java | 55 ++--- .../util/handler/event/CraftingHandler.java | 2 - .../util/handler/event/GenericHandler.java | 34 +-- .../handler/event/LivingArmourHandler.java | 4 +- .../handler/event/StatTrackerHandler.java | 6 +- .../util/handler/event/WillHandler.java | 12 +- .../bloodmagic/util/helper/RecipeHelper.java | 6 +- 157 files changed, 1036 insertions(+), 1554 deletions(-) delete mode 100644 src/main/java/WayofTime/bloodmagic/compat/buttons/BloodMagicPlugin.java delete mode 100644 src/main/java/WayofTime/bloodmagic/compat/buttons/button/ButtonFillNetwork.java delete mode 100644 src/main/java/WayofTime/bloodmagic/compat/guideapi/CompatibilityGuideAPI.java delete mode 100644 src/main/java/WayofTime/bloodmagic/compat/minecraft/CrossVersionProxy110.java delete mode 100644 src/main/java/WayofTime/bloodmagic/compat/minecraft/CrossVersionProxy19.java delete mode 100644 src/main/java/WayofTime/bloodmagic/compat/minecraft/ICrossVersionProxy.java delete mode 100644 src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderPillar.java diff --git a/build.gradle b/build.gradle index fafe77aa..f41cd6e5 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,6 @@ if (new File(projectDir, '.git').exists()) repositories { maven { url "http://dvs1.progwml6.com/files/maven" } - maven { url "http://mobiusstrip.eu/maven" } maven { url "http://tehnut.info/maven" } ivy { @@ -60,9 +59,8 @@ repositories { dependencies { deobfCompile "mezz.jei:jei_${mc_version}:${jei_version}" - deobfCompile "mcp.mobius.waila:Waila:${waila_version}_${mc_version}:dev" + deobfCompile "mcp.mobius.waila:Hwyla:${waila_version}_${mc_version}" deobfCompile "info.amerifrance.guideapi:Guide-API:${mc_version}-${guideapi_version}" - deobfCompile "info.tehnut.buttons:Buttons:${buttons_version}:api" // compile name: "Thaumcraft", version: "${mc_version}-${thaumcraft_version}", ext: "jar" // compile name: 'Baubles', version: "${baubles_version}", ext: 'jar' diff --git a/gradle.properties b/gradle.properties index 2fd30a99..bd15f2b6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,12 @@ mod_name=BloodMagic package_group=com.wayoftime.bloodmagic mod_version=2.1.0 -mc_version=1.9.4 -forge_version=12.17.0.1957 +mc_version=1.11 +forge_version=13.19.1.2189 curse_id=224791 -mappings_version=snapshot_20160518 +mappings_version=snapshot_20161212 -jei_version=3.6.8.225 -waila_version=1.7.0-B3 -thaumcraft_version=5.1.5 -baubles_version=1.1.3.0 -guideapi_version=2.0.0-37 -buttons_version=1.10.2-0.0.3-3 \ No newline at end of file +jei_version=4.0.5.203 +waila_version=1.8.5-B19 +guideapi_version=2.1.0-47 \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/BloodMagic.java b/src/main/java/WayofTime/bloodmagic/BloodMagic.java index 776ab881..22651882 100644 --- a/src/main/java/WayofTime/bloodmagic/BloodMagic.java +++ b/src/main/java/WayofTime/bloodmagic/BloodMagic.java @@ -1,15 +1,13 @@ package WayofTime.bloodmagic; import java.io.File; -import java.util.Map; import WayofTime.bloodmagic.meteor.MeteorConfigHandler; import lombok.Getter; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.launchwrapper.Launch; import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; @@ -25,7 +23,6 @@ import WayofTime.bloodmagic.api.util.helper.LogHelper; import WayofTime.bloodmagic.client.gui.GuiHandler; import WayofTime.bloodmagic.command.CommandBloodMagic; import WayofTime.bloodmagic.compat.ICompatibility; -import WayofTime.bloodmagic.compat.minecraft.ICrossVersionProxy; import WayofTime.bloodmagic.network.BloodMagicPacketHandler; import WayofTime.bloodmagic.proxy.CommonProxy; import WayofTime.bloodmagic.registry.ModArmourTrackers; @@ -42,8 +39,6 @@ import WayofTime.bloodmagic.structures.ModDungeons; import WayofTime.bloodmagic.util.Utils; import WayofTime.bloodmagic.util.handler.IMCHandler; -import com.google.common.collect.ImmutableMap; - @Mod(modid = Constants.Mod.MODID, name = Constants.Mod.NAME, version = Constants.Mod.VERSION, dependencies = Constants.Mod.DEPEND, guiFactory = "WayofTime.bloodmagic.client.gui.config.ConfigGuiFactory") @Getter public class BloodMagic @@ -57,18 +52,18 @@ public class BloodMagic public static CreativeTabs tabBloodMagic = new CreativeTabs(Constants.Mod.MODID + ".creativeTab") { @Override - public Item getTabIconItem() + public ItemStack getTabIconItem() { - return ModItems.BLOOD_ORB; + return new ItemStack(ModItems.BLOOD_ORB); } }; public static CreativeTabs tabUpgradeTome = new CreativeTabs(Constants.Mod.MODID + ".creativeTabTome") { @Override - public Item getTabIconItem() + public ItemStack getTabIconItem() { - return ModItems.UPGRADE_TOME; + return new ItemStack(ModItems.UPGRADE_TOME); } @Override @@ -76,32 +71,13 @@ public class BloodMagic { return true; } - }; + }.setNoTitle().setBackgroundImageName("upgrade_tomes.png"); @Getter private static boolean isDev = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); - @Getter - private static ICrossVersionProxy crossVersionProxy; - private static final Map PROXY_MAP = ImmutableMap.of("1.9.4", "WayofTime.bloodmagic.compat.minecraft.CrossVersionProxy19", "1.10", "WayofTime.bloodmagic.compat.minecraft.CrossVersionProxy110", "1.10.2", "WayofTime.bloodmagic.compat.minecraft.CrossVersionProxy110"); - static { - try - { - String mcVersion = (String) Loader.class.getDeclaredField("MC_VERSION").get(null); - - if (!PROXY_MAP.containsKey(mcVersion)) - throw new IllegalStateException("Blood Magic couldn't find a cross version proxy!"); - - Class proxyClass = Class.forName(PROXY_MAP.get(mcVersion)); - crossVersionProxy = (ICrossVersionProxy) proxyClass.newInstance(); - } - catch (Exception e) - { - throw new IllegalArgumentException("Blood Magic could not find a cross version proxy!", e); - } - tabUpgradeTome.setNoTitle().setBackgroundImageName("upgrade_tomes.png"); FluidRegistry.enableUniversalBucket(); diff --git a/src/main/java/WayofTime/bloodmagic/api/recipe/AlchemyTableRecipe.java b/src/main/java/WayofTime/bloodmagic/api/recipe/AlchemyTableRecipe.java index 457d180f..ba317b86 100644 --- a/src/main/java/WayofTime/bloodmagic/api/recipe/AlchemyTableRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/api/recipe/AlchemyTableRecipe.java @@ -15,7 +15,7 @@ import net.minecraftforge.oredict.OreDictionary; public class AlchemyTableRecipe { protected ItemStack output = null; - protected ArrayList input = new ArrayList(); + protected ArrayList input = new ArrayList(); @Getter protected int lpDrained; @Getter @@ -148,7 +148,7 @@ public class AlchemyTableRecipe * * @return The recipes input vales. */ - public ArrayList getInput() + public ArrayList getInput() { return this.input; } diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/RitualRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/RitualRegistry.java index ff0c43d9..f348f630 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/RitualRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/RitualRegistry.java @@ -5,6 +5,7 @@ import WayofTime.bloodmagic.api.ritual.Ritual; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -57,6 +58,7 @@ public class RitualRegistry registerRitual(ritual, ritual.getName()); } + @Nullable public static Ritual getRitualForId(String id) { Ritual ritual = registry.get(id); diff --git a/src/main/java/WayofTime/bloodmagic/api/teleport/TeleporterBloodMagic.java b/src/main/java/WayofTime/bloodmagic/api/teleport/TeleporterBloodMagic.java index 2c164ee8..e24c0da2 100644 --- a/src/main/java/WayofTime/bloodmagic/api/teleport/TeleporterBloodMagic.java +++ b/src/main/java/WayofTime/bloodmagic/api/teleport/TeleporterBloodMagic.java @@ -33,6 +33,6 @@ public class TeleporterBloodMagic extends Teleporter @Override public void placeInPortal(Entity entity, float rotationYaw) { - entity.setLocationAndAngles(MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY) + 2, MathHelper.floor_double(entity.posZ), entity.rotationYaw, entity.rotationPitch); + entity.setLocationAndAngles(MathHelper.floor(entity.posX), MathHelper.floor(entity.posY) + 2, MathHelper.floor(entity.posZ), entity.rotationYaw, entity.rotationPitch); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumStairs.java b/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumStairs.java index a1d62f6a..77a857e2 100644 --- a/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumStairs.java +++ b/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumStairs.java @@ -27,6 +27,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeModContainer; import org.apache.commons.lang3.ArrayUtils; import WayofTime.bloodmagic.BloodMagic; @@ -368,7 +369,7 @@ public class BlockEnumStairs & IStringSerializable> extends Bl @Override public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) { - if (BloodMagic.getCrossVersionProxy().disableStairSlabCulling()) + if (ForgeModContainer.disableStairSlabCulling) return super.doesSideBlockRendering(state, world, pos, face); if (state.isOpaqueCube()) diff --git a/src/main/java/WayofTime/bloodmagic/compat/buttons/BloodMagicPlugin.java b/src/main/java/WayofTime/bloodmagic/compat/buttons/BloodMagicPlugin.java deleted file mode 100644 index ae82e9c0..00000000 --- a/src/main/java/WayofTime/bloodmagic/compat/buttons/BloodMagicPlugin.java +++ /dev/null @@ -1,25 +0,0 @@ -package WayofTime.bloodmagic.compat.buttons; - -import WayofTime.bloodmagic.compat.buttons.button.ButtonFillNetwork; -import net.minecraft.util.ResourceLocation; -import tehnut.buttons.api.ButtonsPlugin; -import tehnut.buttons.api.IWidgetPlugin; -import tehnut.buttons.api.IWidgetRegistry; -import tehnut.buttons.api.WidgetTexture; - -@ButtonsPlugin -public class BloodMagicPlugin extends IWidgetPlugin.Base { - - public static final WidgetTexture FILL_BUTTON = new WidgetTexture( - new ResourceLocation("bloodmagic", "textures/gui/buttons_compat.png"), - 0, - 0, - 20, - 20 - ); - - @Override - public void register(IWidgetRegistry widgetRegistry) { - widgetRegistry.addUtilityButton(new ButtonFillNetwork()); - } -} diff --git a/src/main/java/WayofTime/bloodmagic/compat/buttons/button/ButtonFillNetwork.java b/src/main/java/WayofTime/bloodmagic/compat/buttons/button/ButtonFillNetwork.java deleted file mode 100644 index c058ce03..00000000 --- a/src/main/java/WayofTime/bloodmagic/compat/buttons/button/ButtonFillNetwork.java +++ /dev/null @@ -1,41 +0,0 @@ -package WayofTime.bloodmagic.compat.buttons.button; - -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.saving.SoulNetwork; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -import WayofTime.bloodmagic.compat.buttons.BloodMagicPlugin; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentTranslation; -import tehnut.buttons.api.button.utility.Button; - -import javax.annotation.Nullable; -import java.util.Collections; -import java.util.List; - -public class ButtonFillNetwork extends Button { - - public ButtonFillNetwork() { - super(BloodMagicPlugin.FILL_BUTTON); - - setServerRequired(); - } - - @Nullable - @Override - public List getTooltip() { - return Collections.singletonList(new TextComponentTranslation("button.bloodmagic.tooltip.fill")); - } - - @Override - public void onServerClick(EntityPlayerMP player) { - SoulNetwork network = NetworkHelper.getSoulNetwork(player); - network.setCurrentEssence(Integer.MAX_VALUE); - } - - @Override - public ResourceLocation getButtonId() { - return new ResourceLocation(Constants.Mod.MODID, "button_fillnetwork"); - } -} diff --git a/src/main/java/WayofTime/bloodmagic/compat/guideapi/CompatibilityGuideAPI.java b/src/main/java/WayofTime/bloodmagic/compat/guideapi/CompatibilityGuideAPI.java deleted file mode 100644 index 138544cf..00000000 --- a/src/main/java/WayofTime/bloodmagic/compat/guideapi/CompatibilityGuideAPI.java +++ /dev/null @@ -1,70 +0,0 @@ -package WayofTime.bloodmagic.compat.guideapi; - -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.item.crafting.IRecipe; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.registry.GameRegistry; -import net.minecraftforge.fml.relauncher.Side; -import WayofTime.bloodmagic.compat.ICompatibility; -import amerifrance.guideapi.api.GuideAPI; -import net.minecraftforge.oredict.ShapelessOreRecipe; - -public class CompatibilityGuideAPI implements ICompatibility -{ - private static IRecipe guideRecipe = null; - private static boolean worldFlag; - - @Override - public void loadCompatibility(InitializationPhase phase) - { - switch (phase) - { - case PRE_INIT: - { - GuideBloodMagic.initBook(); - GameRegistry.register(GuideBloodMagic.guideBook); - if (FMLCommonHandler.instance().getSide() == Side.CLIENT) - GuideAPI.setModel(GuideBloodMagic.guideBook); - - break; - } - case INIT: - { - guideRecipe = new ShapelessOreRecipe(GuideAPI.getStackFromBook(GuideBloodMagic.guideBook), new ItemStack(Items.BOOK), Blocks.GLASS, Items.FEATHER); - break; - } - case POST_INIT: - { - if (FMLCommonHandler.instance().getSide() == Side.CLIENT) - GuideBloodMagic.initCategories(); - break; - } - case MAPPING: - { - if (!worldFlag) { - GameRegistry.addRecipe(guideRecipe); - worldFlag = true; - } else { - CraftingManager.getInstance().getRecipeList().remove(guideRecipe); - worldFlag = false; - } - break; - } - } - } - - @Override - public String getModId() - { - return "guideapi"; - } - - @Override - public boolean enableCompat() - { - return true; - } -} diff --git a/src/main/java/WayofTime/bloodmagic/compat/guideapi/GuideBloodMagic.java b/src/main/java/WayofTime/bloodmagic/compat/guideapi/GuideBloodMagic.java index dc06383b..73cb0fdb 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/guideapi/GuideBloodMagic.java +++ b/src/main/java/WayofTime/bloodmagic/compat/guideapi/GuideBloodMagic.java @@ -1,50 +1,56 @@ package WayofTime.bloodmagic.compat.guideapi; +import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.compat.guideapi.book.*; -import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin; import WayofTime.bloodmagic.registry.ModBlocks; import WayofTime.bloodmagic.registry.ModItems; import amerifrance.guideapi.api.GuideAPI; +import amerifrance.guideapi.api.GuideBook; +import amerifrance.guideapi.api.IGuideBook; import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.util.NBTBookTags; import amerifrance.guideapi.category.CategoryItemStack; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.relauncher.Side; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.oredict.ShapelessOreRecipe; +import javax.annotation.Nullable; import java.awt.Color; -public class GuideBloodMagic +@GuideBook +public class GuideBloodMagic implements IGuideBook { public static Book guideBook; - public static void initBook() - { + @Nullable + @Override + public Book buildBook() { guideBook = new Book(); guideBook.setTitle("guide.BloodMagic.title"); guideBook.setDisplayName("guide.BloodMagic.display"); guideBook.setWelcomeMessage("guide.BloodMagic.welcome"); guideBook.setAuthor("guide.BloodMagic.author"); - guideBook.setRegistryName("BloodMagic"); + guideBook.setRegistryName(new ResourceLocation(Constants.Mod.MODID, "guide")); guideBook.setColor(Color.RED); - if (FMLCommonHandler.instance().getSide() == Side.CLIENT) - GuideAPI.setModel(guideBook); + return guideBook; } - public static void initCategories() - { + @Override + public void handleModel(ItemStack bookStack) { + GuideAPI.setModel(guideBook); + } + + @Override + public void handlePost(ItemStack bookStack) { guideBook.addCategory(new CategoryItemStack(CategoryAlchemy.buildCategory(), "guide.BloodMagic.category.alchemy", new ItemStack(ModItems.ARCANE_ASHES))); guideBook.addCategory(new CategoryItemStack(CategoryArchitect.buildCategory(), "guide.BloodMagic.category.architect", new ItemStack(ModItems.SIGIL_DIVINATION))); guideBook.addCategory(new CategoryItemStack(CategoryDemon.buildCategory(), "guide.BloodMagic.category.demon", new ItemStack(ModItems.BLOOD_SHARD))); guideBook.addCategory(new CategoryItemStack(CategoryRitual.buildCategory(), "guide.BloodMagic.category.ritual", new ItemStack(ModBlocks.RITUAL_CONTROLLER))); // guideBook.addCategory(new CategoryItemStack(CategorySpell.buildCategory(), "guide.BloodMagic.category.spell", new ItemStack(ModItems.ritualDiviner))); - } - public static void initJEIBlacklist() - { - if (Loader.isModLoaded("JEI")) - BloodMagicPlugin.jeiHelper.getNbtIgnoreList().ignoreNbtTagNames(GuideAPI.guideBook, NBTBookTags.BOOK_TAG, NBTBookTags.CATEGORY_PAGE_TAG, NBTBookTags.CATEGORY_TAG, NBTBookTags.ENTRY_PAGE_TAG, NBTBookTags.ENTRY_TAG, NBTBookTags.KEY_TAG, NBTBookTags.PAGE_TAG); + GameRegistry.addRecipe(new ShapelessOreRecipe(GuideAPI.getStackFromBook(GuideBloodMagic.guideBook), new ItemStack(Items.BOOK), Blocks.GLASS, Items.FEATHER)); } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageAlchemyArray.java b/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageAlchemyArray.java index 0c2defc9..b8fd8cfc 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageAlchemyArray.java +++ b/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageAlchemyArray.java @@ -2,6 +2,7 @@ package WayofTime.bloodmagic.compat.guideapi.page; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import lombok.AllArgsConstructor; @@ -32,17 +33,17 @@ public class PageAlchemyArray extends Page public PageAlchemyArray(List resources, ItemStack inputStack, ItemStack catalystStack) { - this(resources, inputStack, catalystStack, null); + this(resources, inputStack, catalystStack, ItemStack.EMPTY); } public PageAlchemyArray(ResourceLocation resource, ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack) { - this(Arrays.asList(resource), inputStack, catalystStack, outputStack); + this(Collections.singletonList(resource), inputStack, catalystStack, outputStack); } public PageAlchemyArray(ResourceLocation resource, ItemStack inputStack, ItemStack catalystStack) { - this(Arrays.asList(resource), inputStack, catalystStack); + this(Collections.singletonList(resource), inputStack, catalystStack); } @Override @@ -53,7 +54,7 @@ public class PageAlchemyArray extends Page int y = guiTop + 30; Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("bloodmagicguide" + ":textures/gui/alchemyArrayCrafting.png")); - guiBase.drawTexturedModalRect(x, y, 0, 0, 62, 88 + (outputStack == null ? 0 : 26)); + guiBase.drawTexturedModalRect(x, y, 0, 0, 62, 88 + (outputStack.isEmpty() ? 0 : 26)); guiBase.drawCenteredString(fontRenderer, TextHelper.localize("guide.BloodMagic.page.alchemyArray"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0); @@ -85,7 +86,7 @@ public class PageAlchemyArray extends Page guiBase.renderToolTip(catalystStack, mouseX, mouseY); } - if (outputStack != null) + if (!outputStack.isEmpty()) { int outputX = x + 43; int outputY = y + 95; diff --git a/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageAltarRecipe.java b/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageAltarRecipe.java index 72369163..48490476 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageAltarRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageAltarRecipe.java @@ -53,7 +53,7 @@ public class PageAltarRecipe extends Page guiBase.renderToolTip(input.get(0), mouseX, mouseY); } - if (output == null) + if (output.isEmpty()) { output = new ItemStack(Blocks.BARRIER); } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingCategory.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingCategory.java index 72653f5f..d2afe677 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingCategory.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingCategory.java @@ -1,12 +1,15 @@ package WayofTime.bloodmagic.compat.jei.alchemyArray; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin; @@ -50,14 +53,15 @@ public class AlchemyArrayCraftingCategory implements IRecipeCategory } + @Nullable @Override - public void drawAnimations(Minecraft minecraft) + public IDrawable getIcon() { - + return null; } @Override - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { recipeLayout.getItemStacks().init(INPUT_SLOT, true, 0, 5); recipeLayout.getItemStacks().init(CATALYST_SLOT, true, 29, 3); @@ -66,9 +70,9 @@ public class AlchemyArrayCraftingCategory implements IRecipeCategory if (recipeWrapper instanceof AlchemyArrayCraftingRecipeJEI) { AlchemyArrayCraftingRecipeJEI alchemyArrayWrapper = (AlchemyArrayCraftingRecipeJEI) recipeWrapper; - recipeLayout.getItemStacks().set(INPUT_SLOT, alchemyArrayWrapper.getInputs()); + recipeLayout.getItemStacks().set(INPUT_SLOT, ingredients.getInputs(ItemStack.class).get(0)); recipeLayout.getItemStacks().set(CATALYST_SLOT, alchemyArrayWrapper.getCatalyst()); - recipeLayout.getItemStacks().set(OUTPUT_SLOT, alchemyArrayWrapper.getOutputs()); + recipeLayout.getItemStacks().set(OUTPUT_SLOT, ingredients.getOutputs(ItemStack.class).get(0).get(0)); } } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeHandler.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeHandler.java index 0d6f2acb..42d996db 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeHandler.java @@ -15,14 +15,6 @@ public class AlchemyArrayCraftingRecipeHandler implements IRecipeHandler getInputs() - { - return inputs; - } - public ItemStack getCatalyst() { return catalyst; } @Override - @Nonnull - public List getOutputs() - { - return Collections.singletonList(output); + public void getIngredients(IIngredients ingredients) { + ingredients.setOutputs(ItemStack.class, Collections.singletonList(output)); + ingredients.setInputs(ItemStack.class, inputs); } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeCategory.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeCategory.java index 7f4c84d7..34b16e28 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeCategory.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeCategory.java @@ -1,14 +1,13 @@ package WayofTime.bloodmagic.compat.jei.alchemyTable; -import java.util.ArrayList; -import java.util.List; - import javax.annotation.Nonnull; +import javax.annotation.Nullable; import mezz.jei.api.gui.ICraftingGridHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; @@ -63,15 +62,16 @@ public class AlchemyTableRecipeCategory implements IRecipeCategory } + @Nullable @Override - public void drawAnimations(Minecraft minecraft) + public IDrawable getIcon() { - + return null; } - @Override @SuppressWarnings("unchecked") - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) + @Override + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); @@ -90,9 +90,9 @@ public class AlchemyTableRecipeCategory implements IRecipeCategory if (recipeWrapper instanceof AlchemyTableRecipeJEI) { AlchemyTableRecipeJEI recipe = (AlchemyTableRecipeJEI) recipeWrapper; - guiItemStacks.set(ORB_SLOT, (ArrayList) recipe.getInputs().get(1)); - craftingGridHelper.setOutput(guiItemStacks, recipe.getOutputs()); - craftingGridHelper.setInput(guiItemStacks, (List) recipe.getInputs().get(0), 3, 2); + guiItemStacks.set(ORB_SLOT, ingredients.getInputs(ItemStack.class).get(1)); + craftingGridHelper.setOutput(guiItemStacks, ingredients.getOutputs(ItemStack.class).get(0)); + craftingGridHelper.setInputs(guiItemStacks, ingredients.getInputs(ItemStack.class), 3, 2); } } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeHandler.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeHandler.java index 91755902..f271d1c4 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeHandler.java @@ -15,14 +15,6 @@ public class AlchemyTableRecipeHandler implements IRecipeHandler validGems = new ArrayList(); - public AlchemyTableRecipeJEI(AlchemyTableRecipe recipe) { this.recipe = recipe; } @Override - @Nonnull - public List getInputs() - { - ArrayList ret = new ArrayList(); - ret.add(recipe.getInput()); - ret.add(OrbRegistry.getOrbsDownToTier(recipe.getTierRequired())); - return ret; + public void getIngredients(IIngredients ingredients) { +// ingredients.setInputLists(ItemStack.class, Lists.newArrayList(recipe.getInput(), OrbRegistry.getOrbsDownToTier(recipe.getTierRequired()))); + ingredients.setOutput(ItemStack.class, recipe.getRecipeOutput(new ArrayList())); } - @Override - @Nonnull - public List getOutputs() - { - return Collections.singletonList(recipe.getRecipeOutput(new ArrayList())); - } - - @Nullable @Override public List getTooltipStrings(int mouseX, int mouseY) { @@ -54,8 +34,7 @@ public class AlchemyTableRecipeJEI extends BlankRecipeWrapper { ret.add(TextHelper.localize("jei.BloodMagic.recipe.lpDrained", recipe.getLpDrained())); ret.add(TextHelper.localize("jei.BloodMagic.recipe.ticksRequired", recipe.getTicksRequired())); - return ret; } - return null; + return ret; } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeCategory.java b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeCategory.java index a4a7fc70..b27cb37e 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeCategory.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeCategory.java @@ -1,11 +1,13 @@ package WayofTime.bloodmagic.compat.jei.altar; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.List; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; @@ -52,14 +54,14 @@ public class AltarRecipeCategory implements IRecipeCategory } + @Nullable @Override - public void drawAnimations(Minecraft minecraft) - { - + public IDrawable getIcon() { + return null; } @Override - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { recipeLayout.getItemStacks().init(INPUT_SLOT, true, 31, 0); recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 125, 30); @@ -67,9 +69,9 @@ public class AltarRecipeCategory implements IRecipeCategory if (recipeWrapper instanceof AltarRecipeJEI) { AltarRecipeJEI altarRecipeWrapper = (AltarRecipeJEI) recipeWrapper; - List> inputs = altarRecipeWrapper.getInputs(); + List> inputs = ingredients.getInputs(ItemStack.class); recipeLayout.getItemStacks().set(INPUT_SLOT, inputs.get(0)); - recipeLayout.getItemStacks().set(OUTPUT_SLOT, altarRecipeWrapper.getOutputs()); + recipeLayout.getItemStacks().set(OUTPUT_SLOT, ingredients.getOutputs(ItemStack.class).get(0)); } } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeHandler.java b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeHandler.java index dc414295..7fc390e2 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeHandler.java @@ -15,14 +15,6 @@ public class AltarRecipeHandler implements IRecipeHandler return AltarRecipeJEI.class; } - @Deprecated - @Nonnull - @Override - public String getRecipeCategoryUid() - { - return Constants.Compat.JEI_CATEGORY_ALTAR; - } - @Override public String getRecipeCategoryUid(@Nonnull AltarRecipeJEI recipe) { diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeJEI.java b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeJEI.java index 7b9e00cc..a9e1cf18 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeJEI.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeJEI.java @@ -2,13 +2,12 @@ package WayofTime.bloodmagic.compat.jei.altar; import java.awt.Color; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import WayofTime.bloodmagic.util.helper.NumeralHelper; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; @@ -37,18 +36,11 @@ public class AltarRecipeJEI extends BlankRecipeWrapper } @Override - public List> getInputs() - { - return Collections.singletonList(input); + public void getIngredients(IIngredients ingredients) { + ingredients.setInputs(ItemStack.class, input); + ingredients.setOutput(ItemStack.class, output); } - @Override - public List getOutputs() - { - return Collections.singletonList(output); - } - - @Nullable @Override public List getTooltipStrings(int mouseX, int mouseY) { @@ -57,9 +49,8 @@ public class AltarRecipeJEI extends BlankRecipeWrapper { ret.add(TextHelper.localize("jei.BloodMagic.recipe.consumptionRate", consumptionRate)); ret.add(TextHelper.localize("jei.BloodMagic.recipe.drainRate", drainRate)); - return ret; } - return null; + return ret; } @Override diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeCategory.java b/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeCategory.java index 83e8efd5..5ca3e731 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeCategory.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeCategory.java @@ -1,14 +1,13 @@ package WayofTime.bloodmagic.compat.jei.armourDowngrade; -import java.util.ArrayList; -import java.util.List; - import javax.annotation.Nonnull; +import javax.annotation.Nullable; import mezz.jei.api.gui.ICraftingGridHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; @@ -63,15 +62,15 @@ public class ArmourDowngradeRecipeCategory implements IRecipeCategory } + @Nullable @Override - public void drawAnimations(Minecraft minecraft) - { - + public IDrawable getIcon() { + return null; } @Override @SuppressWarnings("unchecked") - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper, IIngredients ingredients) { IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); @@ -89,10 +88,9 @@ public class ArmourDowngradeRecipeCategory implements IRecipeCategory if (recipeWrapper instanceof ArmourDowngradeRecipeJEI) { - ArmourDowngradeRecipeJEI recipe = (ArmourDowngradeRecipeJEI) recipeWrapper; - guiItemStacks.set(KEY_SLOT, (ArrayList) recipe.getInputs().get(1)); - craftingGridHelper.setOutput(guiItemStacks, recipe.getOutputs()); - craftingGridHelper.setInput(guiItemStacks, (List) recipe.getInputs().get(0), 3, 2); + guiItemStacks.set(KEY_SLOT, ingredients.getInputs(ItemStack.class).get(1)); + craftingGridHelper.setOutput(guiItemStacks, ingredients.getOutputs(ItemStack.class).get(0)); + craftingGridHelper.setInputs(guiItemStacks, ingredients.getInputs(ItemStack.class), 3, 2); } } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeHandler.java b/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeHandler.java index 757f1c32..b532e9ea 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeHandler.java @@ -15,14 +15,6 @@ public class ArmourDowngradeRecipeHandler implements IRecipeHandler 0 && recipe.getOutputs().size() > 0; + return true; } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeJEI.java b/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeJEI.java index a66d53f6..8ab68515 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeJEI.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeJEI.java @@ -1,65 +1,28 @@ package WayofTime.bloodmagic.compat.jei.armourDowngrade; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import lombok.Getter; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeWrapper; import net.minecraft.item.ItemStack; import WayofTime.bloodmagic.api.recipe.LivingArmourDowngradeRecipe; import WayofTime.bloodmagic.api.util.helper.ItemHelper.LivingUpgrades; import WayofTime.bloodmagic.registry.ModItems; -import com.google.common.collect.Lists; - public class ArmourDowngradeRecipeJEI extends BlankRecipeWrapper { @Getter private LivingArmourDowngradeRecipe recipe; -// @Getter -// private ArrayList validGems = new ArrayList(); - public ArmourDowngradeRecipeJEI(LivingArmourDowngradeRecipe recipe) { this.recipe = recipe; } @Override - @Nonnull - public List getInputs() - { - ArrayList ret = new ArrayList(); - ret.add(recipe.getInput()); - ret.add(Lists.newArrayList(recipe.getKey())); - return ret; - } - - @Override - @Nonnull - public List getOutputs() - { + public void getIngredients(IIngredients ingredients) { + // TODO - inputs ItemStack upgradeStack = new ItemStack(ModItems.UPGRADE_TOME); LivingUpgrades.setUpgrade(upgradeStack, recipe.getRecipeOutput()); - return Collections.singletonList(upgradeStack); - } - - @Nullable - @Override - public List getTooltipStrings(int mouseX, int mouseY) - { -// ArrayList ret = new ArrayList(); -// if (mouseX >= 58 && mouseX <= 78 && mouseY >= 21 && mouseY <= 34) -// { -// ret.add(TextHelper.localize("jei.BloodMagic.recipe.lpDrained", recipe.getLpDrained())); -// ret.add(TextHelper.localize("jei.BloodMagic.recipe.ticksRequired", recipe.getTicksRequired())); -// return ret; -// } - return null; + ingredients.setOutput(ItemStack.class, upgradeStack); } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/minecraft/CrossVersionProxy110.java b/src/main/java/WayofTime/bloodmagic/compat/minecraft/CrossVersionProxy110.java deleted file mode 100644 index 937fbcde..00000000 --- a/src/main/java/WayofTime/bloodmagic/compat/minecraft/CrossVersionProxy110.java +++ /dev/null @@ -1,39 +0,0 @@ -package WayofTime.bloodmagic.compat.minecraft; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.ForgeModContainer; -import net.minecraftforge.fml.relauncher.ReflectionHelper; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -public class CrossVersionProxy110 implements ICrossVersionProxy { - - @Override - public TileEntity createTileFromData(World world, NBTTagCompound tagCompound) - { - Method m = ReflectionHelper.findMethod(TileEntity.class, null, new String[] { "create", "func_190200_a", "a" }, World.class, NBTTagCompound.class); - try - { - return (TileEntity) m.invoke(null, world, tagCompound); - } catch (Exception e) - { - return null; - } - } - - @Override - public boolean disableStairSlabCulling() - { - Field disableStairSlabCulling = ReflectionHelper.findField(ForgeModContainer.class, "disableStairSlabCulling"); - try - { - return (Boolean) disableStairSlabCulling.get(null); - } catch (Exception e) - { - return false; - } - } -} diff --git a/src/main/java/WayofTime/bloodmagic/compat/minecraft/CrossVersionProxy19.java b/src/main/java/WayofTime/bloodmagic/compat/minecraft/CrossVersionProxy19.java deleted file mode 100644 index 8c1253bb..00000000 --- a/src/main/java/WayofTime/bloodmagic/compat/minecraft/CrossVersionProxy19.java +++ /dev/null @@ -1,31 +0,0 @@ -package WayofTime.bloodmagic.compat.minecraft; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.ReflectionHelper; - -import java.lang.reflect.Method; - -public class CrossVersionProxy19 implements ICrossVersionProxy -{ - - @Override - public TileEntity createTileFromData(World world, NBTTagCompound tagCompound) - { - Method m = ReflectionHelper.findMethod(TileEntity.class, null, new String[] { "create", "func_189514_c", "c" }, NBTTagCompound.class); - try - { - return (TileEntity) m.invoke(null, tagCompound); - } catch (Exception e) - { - return null; - } - } - - @Override - public boolean disableStairSlabCulling() - { - return false; - } -} diff --git a/src/main/java/WayofTime/bloodmagic/compat/minecraft/ICrossVersionProxy.java b/src/main/java/WayofTime/bloodmagic/compat/minecraft/ICrossVersionProxy.java deleted file mode 100644 index f8bd12de..00000000 --- a/src/main/java/WayofTime/bloodmagic/compat/minecraft/ICrossVersionProxy.java +++ /dev/null @@ -1,17 +0,0 @@ -package WayofTime.bloodmagic.compat.minecraft; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -/** - * Allows for Blood Magic to support multiple MC versions that have only slight changes. - * - * Implementation copied from Botania. - */ -public interface ICrossVersionProxy -{ - TileEntity createTileFromData(World world, NBTTagCompound tagCompound); - - boolean disableStairSlabCulling(); -} diff --git a/src/main/java/WayofTime/bloodmagic/compat/waila/WailaCallbackHandler.java b/src/main/java/WayofTime/bloodmagic/compat/waila/WailaCallbackHandler.java index f88c75c8..dd76cf93 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/waila/WailaCallbackHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compat/waila/WailaCallbackHandler.java @@ -4,9 +4,6 @@ import WayofTime.bloodmagic.block.*; import WayofTime.bloodmagic.compat.waila.provider.*; import mcp.mobius.waila.api.IWailaRegistrar; import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.block.base.BlockEnumPillar; -import WayofTime.bloodmagic.block.base.BlockEnumPillarCap; -import WayofTime.bloodmagic.block.base.BlockEnumStairs; public class WailaCallbackHandler { @@ -22,9 +19,6 @@ public class WailaCallbackHandler registrar.registerStackProvider(new DataProviderAlchemyArray(), BlockAlchemyArray.class); registrar.registerStackProvider(new DataProviderMimic(), BlockMimic.class); registrar.registerNBTProvider(new DataProviderMimic(), BlockMimic.class); - registrar.registerStackProvider(DataProviderPillar.INSTANCE, BlockEnumPillarCap.class); - registrar.registerStackProvider(DataProviderPillar.INSTANCE, BlockEnumPillar.class); - registrar.registerStackProvider(DataProviderPillar.INSTANCE, BlockEnumStairs.class); registrar.addConfig(Constants.Mod.MODID, Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK, false); registrar.addConfig(Constants.Mod.MODID, Constants.Compat.WAILA_CONFIG_ALTAR, true); diff --git a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderAlchemyArray.java b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderAlchemyArray.java index 3ff12659..f840c83e 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderAlchemyArray.java +++ b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderAlchemyArray.java @@ -43,10 +43,10 @@ public class DataProviderAlchemyArray implements IWailaDataProvider if (tile instanceof TileAlchemyArray) { TileAlchemyArray tileArray = (TileAlchemyArray) tile; - if (tileArray.getStackInSlot(0) != null) + if (!tileArray.getStackInSlot(0).isEmpty()) currenttip.add(TextHelper.localize("waila.BloodMagic.array.reagent", tileArray.getStackInSlot(0).getDisplayName())); - if (tileArray.getStackInSlot(1) != null) + if (!tileArray.getStackInSlot(1).isEmpty()) currenttip.add(TextHelper.localize("waila.BloodMagic.array.catalyst", tileArray.getStackInSlot(1).getDisplayName())); } } else diff --git a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderBloodAltar.java b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderBloodAltar.java index 2638641b..7a877071 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderBloodAltar.java +++ b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderBloodAltar.java @@ -129,10 +129,10 @@ public class DataProviderBloodAltar implements IWailaDataProvider private static boolean holdingSeerSigil(EntityPlayer player) { - if (player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() instanceof ItemSigilSeer) + if (player.getHeldItemMainhand().getItem() instanceof ItemSigilSeer) return true; - if (player.getHeldItemOffhand() != null && player.getHeldItemOffhand().getItem() instanceof ItemSigilSeer) + if (player.getHeldItemOffhand().getItem() instanceof ItemSigilSeer) return true; return false; @@ -140,10 +140,10 @@ public class DataProviderBloodAltar implements IWailaDataProvider private static boolean holdingDivinationSigil(EntityPlayer player) { - if (player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() instanceof ItemSigilDivination) + if (player.getHeldItemMainhand().getItem() instanceof ItemSigilDivination) return true; - if (player.getHeldItemOffhand() != null && player.getHeldItemOffhand().getItem() instanceof ItemSigilDivination) + if (player.getHeldItemOffhand().getItem() instanceof ItemSigilDivination) return true; return false; diff --git a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderBloodTank.java b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderBloodTank.java index 6f381db5..5e39a63b 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderBloodTank.java +++ b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderBloodTank.java @@ -35,7 +35,7 @@ public class DataProviderBloodTank implements IWailaDataProvider @Override public List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { - if (!config.getConfig(Constants.Compat.WAILA_CONFIG_BLOOD_TANK)) + if (!config.getConfig(Constants.Compat.WAILA_CONFIG_BLOOD_TANK) && !config.getConfig("capability.tankinfo")) return currenttip; if (accessor.getPlayer().isSneaking() || config.getConfig(Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK)) diff --git a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderMimic.java b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderMimic.java index 3f42d8db..1ce57020 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderMimic.java +++ b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderMimic.java @@ -20,7 +20,7 @@ public class DataProviderMimic implements IWailaDataProvider public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { if (accessor.getNBTData().getBoolean("hasItem")) - return ItemStack.loadItemStackFromNBT(accessor.getNBTData()); + return new ItemStack(accessor.getNBTData()); return new ItemStack(accessor.getBlock(), 1, accessor.getMetadata()); } diff --git a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderPillar.java b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderPillar.java deleted file mode 100644 index c24886ae..00000000 --- a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderPillar.java +++ /dev/null @@ -1,43 +0,0 @@ -package WayofTime.bloodmagic.compat.waila.provider; - -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; -import mcp.mobius.waila.api.IWailaDataProvider; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import java.util.List; - -public class DataProviderPillar implements IWailaDataProvider { - - public static final DataProviderPillar INSTANCE = new DataProviderPillar(); - - @Override - public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { - return new ItemStack(accessor.getBlock(), 1, accessor.getBlock().damageDropped(accessor.getBlockState())); - } - - @Override - public List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { - return null; - } - - @Override - public List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { - return null; - } - - @Override - public List getWailaTail(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { - return null; - } - - @Override - public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) { - return null; - } -} diff --git a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderRitualController.java b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderRitualController.java index b9c1106c..6e2910fc 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderRitualController.java +++ b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderRitualController.java @@ -65,7 +65,7 @@ public class DataProviderRitualController implements IWailaDataProvider if (accessor.getBlock().getMetaFromState(accessor.getBlockState()) == 1 && accessor.getTileEntity() instanceof TileImperfectRitualStone) { - if (accessor.getWorld().getBlockState(accessor.getPosition().up()).getBlock() != null) + if (accessor.getWorld().isAirBlock(accessor.getPosition().up())) { Block up = accessor.getWorld().getBlockState(accessor.getPosition().up()).getBlock(); int meta = up.getMetaFromState(accessor.getWorld().getBlockState(accessor.getPosition().up())); diff --git a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderTeleposer.java b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderTeleposer.java index 18136cee..7a787263 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderTeleposer.java +++ b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderTeleposer.java @@ -42,7 +42,7 @@ public class DataProviderTeleposer implements IWailaDataProvider if (accessor.getBlock() instanceof BlockTeleposer && accessor.getTileEntity() instanceof TileTeleposer) { TileTeleposer teleposer = (TileTeleposer) accessor.getTileEntity(); - if (teleposer.getStackInSlot(0) != null) + if (!teleposer.getStackInSlot(0).isEmpty()) { ItemStack contained = teleposer.getStackInSlot(0); BlockPos toPos = ((ItemTelepositionFocus) contained.getItem()).getBlockPos(contained); diff --git a/src/main/java/WayofTime/bloodmagic/compress/AdvancedCompressionHandler.java b/src/main/java/WayofTime/bloodmagic/compress/AdvancedCompressionHandler.java index 5a04209c..9c681f00 100644 --- a/src/main/java/WayofTime/bloodmagic/compress/AdvancedCompressionHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compress/AdvancedCompressionHandler.java @@ -20,15 +20,15 @@ public class AdvancedCompressionHandler extends CompressionHandler { for (ItemStack invStack : inv) { - if (invStack == null) + if (invStack.isEmpty()) { continue; } for (int i = 2; i <= 3; i++) { - ItemStack stacky = getRecipe(invStack, world, i); - if (stacky != null) + ItemStack stack = getRecipe(invStack, world, i); + if (!stack.isEmpty()) { int threshold = CompressionRegistry.getItemThreshold(invStack); @@ -37,13 +37,13 @@ public class AdvancedCompressionHandler extends CompressionHandler if (neededLeft <= 0) { iterateThroughInventory(invStack, 0, inv, needed, true); - return stacky; + return stack; } } } } - return null; + return ItemStack.EMPTY; } public int iterateThroughInventory(ItemStack required, int kept, ItemStack[] inv, int needed, boolean doDrain) @@ -54,14 +54,14 @@ public class AdvancedCompressionHandler extends CompressionHandler { i++; - if (invStack == null) + if (invStack.isEmpty()) { continue; } if (invStack.isItemEqual(required) && (invStack.getTagCompound() == null ? required.getTagCompound() == null : invStack.getTagCompound().equals(required.getTagCompound()))) { - int stackSize = invStack.stackSize; + int stackSize = invStack.getCount(); int used = 0; if (kept > 0) { @@ -76,10 +76,10 @@ public class AdvancedCompressionHandler extends CompressionHandler int remainingFromStack = Math.max(stackSize - used - needed, 0); if (doDrain) { - invStack.stackSize = remainingFromStack + used; - if (invStack.stackSize <= 0) + invStack.setCount(remainingFromStack + used); + if (invStack.isEmpty()) { - inv[i] = null; + inv[i] = ItemStack.EMPTY; } } @@ -98,7 +98,7 @@ public class AdvancedCompressionHandler extends CompressionHandler public static boolean isResultStackReversible(ItemStack stack, int gridSize, World world) { - if (stack == null) + if (stack.isEmpty()) { return false; } @@ -113,12 +113,12 @@ public class AdvancedCompressionHandler extends CompressionHandler inventory.setInventorySlotContents(0, stack); ItemStack returnStack = StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world); - if (returnStack == null) + if (returnStack.isEmpty()) { return false; } - ItemStack compressedStack = null; + ItemStack compressedStack = ItemStack.EMPTY; switch (gridSize) { case 2: @@ -129,7 +129,7 @@ public class AdvancedCompressionHandler extends CompressionHandler break; } - return compressedStack != null && CompressionRegistry.areItemStacksEqual(stack, compressedStack); + return !compressedStack.isEmpty() && CompressionRegistry.areItemStacksEqual(stack, compressedStack); } public static ItemStack getRecipe(ItemStack stack, World world, int gridSize) @@ -151,7 +151,7 @@ public class AdvancedCompressionHandler extends CompressionHandler public static boolean has22Recipe(ItemStack stack, World world) { - return get22Recipe(stack, world) != null; + return !get22Recipe(stack, world).isEmpty(); } public static ItemStack get22Recipe(ItemStack stack, World world) @@ -161,7 +161,7 @@ public class AdvancedCompressionHandler extends CompressionHandler public static boolean has33Recipe(ItemStack stack, World world) { - return get33Recipe(stack, world) != null; + return !get33Recipe(stack, world).isEmpty(); } public static ItemStack get33Recipe(ItemStack stack, World world) diff --git a/src/main/java/WayofTime/bloodmagic/compress/BaseCompressionHandler.java b/src/main/java/WayofTime/bloodmagic/compress/BaseCompressionHandler.java index 7eba6bb3..4573bde1 100644 --- a/src/main/java/WayofTime/bloodmagic/compress/BaseCompressionHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compress/BaseCompressionHandler.java @@ -38,7 +38,7 @@ public class BaseCompressionHandler extends CompressionHandler return this.getResultStack(); } - return null; + return ItemStack.EMPTY; } public int getRemainingNeeded(ItemStack[] inv) @@ -53,7 +53,7 @@ public class BaseCompressionHandler extends CompressionHandler public int iterateThroughInventory(ItemStack[] inv, boolean doDrain) { - int needed = this.required.stackSize; + int needed = this.required.getCount(); int kept = this.getLeftover(); int i = -1; @@ -68,7 +68,7 @@ public class BaseCompressionHandler extends CompressionHandler if (invStack.isItemEqual(this.required) && (invStack.getTagCompound() == null ? this.required.getTagCompound() == null : invStack.getTagCompound().equals(this.required.getTagCompound()))) { - int stackSize = invStack.stackSize; + int stackSize = invStack.getCount(); int used = 0; if (kept > 0) { @@ -83,10 +83,10 @@ public class BaseCompressionHandler extends CompressionHandler int remainingFromStack = Math.max(stackSize - used - needed, 0); if (doDrain) { - invStack.stackSize = remainingFromStack + used; - if (invStack.stackSize <= 0) + invStack.setCount(remainingFromStack + used); + if (invStack.isEmpty()) { - inv[i] = null; + inv[i] = ItemStack.EMPTY; } } diff --git a/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingManager.java b/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingManager.java index 21b6357b..7a2844a2 100644 --- a/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingManager.java +++ b/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingManager.java @@ -32,7 +32,7 @@ public class StorageBlockCraftingManager private static boolean isResultStackReversible(ItemStack stack, int gridSize, World world, List list) { - if (stack == null) + if (stack.isEmpty()) { return false; } @@ -47,12 +47,12 @@ public class StorageBlockCraftingManager inventory.setInventorySlotContents(0, stack); ItemStack returnStack = StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world, list); - if (returnStack == null || returnStack.getItem() == null) + if (returnStack.isEmpty()) { return false; } - ItemStack compressedStack = null; + ItemStack compressedStack = ItemStack.EMPTY; switch (gridSize) { case 2: @@ -63,7 +63,7 @@ public class StorageBlockCraftingManager break; } - return compressedStack != null && CompressionRegistry.areItemStacksEqual(stack, compressedStack); + return !compressedStack.isEmpty() && CompressionRegistry.areItemStacksEqual(stack, compressedStack); } private static ItemStack getRecipe(ItemStack stack, World world, int gridSize, List list) @@ -85,7 +85,7 @@ public class StorageBlockCraftingManager private static boolean has22Recipe(ItemStack stack, World world, List list) { - return get22Recipe(stack, world, list) != null; + return !get22Recipe(stack, world, list).isEmpty(); } private static ItemStack get22Recipe(ItemStack stack, World world, List list) @@ -95,7 +95,7 @@ public class StorageBlockCraftingManager private static boolean has33Recipe(ItemStack stack, World world, List list) { - return get33Recipe(stack, world, list) != null; + return !get33Recipe(stack, world, list).isEmpty(); } private static ItemStack get33Recipe(ItemStack stack, World world, List list) @@ -111,15 +111,15 @@ public class StorageBlockCraftingManager private ItemStack findMatchingRecipe(InventoryCrafting craftingInventory, World world, List list) { int i = 0; - ItemStack itemstack = null; - ItemStack itemstack1 = null; + ItemStack itemstack = ItemStack.EMPTY; + ItemStack itemstack1 = ItemStack.EMPTY; int j; for (j = 0; j < craftingInventory.getSizeInventory(); ++j) { ItemStack itemstack2 = craftingInventory.getStackInSlot(j); - if (itemstack2 != null) + if (!itemstack2.isEmpty()) { if (i == 0) { @@ -135,13 +135,13 @@ public class StorageBlockCraftingManager } } - if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && itemstack.getItem().isRepairable()) + if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.getCount() == 1 && itemstack1.getCount() == 1 && itemstack.getItem().isRepairable()) { Item item = itemstack.getItem(); - int j1 = item.getMaxDamage() - itemstack.getItemDamage(); - int k = item.getMaxDamage() - itemstack1.getItemDamage(); - int l = j1 + k + item.getMaxDamage() * 5 / 100; - int i1 = item.getMaxDamage() - l; + int j1 = item.getMaxDamage(itemstack) - itemstack.getItemDamage(); + int k = item.getMaxDamage(itemstack) - itemstack1.getItemDamage(); + int l = j1 + k + item.getMaxDamage(itemstack) * 5 / 100; + int i1 = item.getMaxDamage(itemstack) - l; if (i1 < 0) { @@ -161,7 +161,7 @@ public class StorageBlockCraftingManager } } - return null; + return ItemStack.EMPTY; } } } diff --git a/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingRecipeAssimilator.java b/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingRecipeAssimilator.java index 5dc209df..20316b3d 100644 --- a/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingRecipeAssimilator.java +++ b/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingRecipeAssimilator.java @@ -33,10 +33,10 @@ public class StorageBlockCraftingRecipeAssimilator continue; ItemStack output = recipe.getRecipeOutput(); - if (output == null || output.getItem() == null) + if (output.isEmpty()) continue; - if (output.stackSize == 1) + if (output.getCount() == 1) { PackingRecipe packingRecipe = getPackingRecipe(recipe); @@ -44,7 +44,7 @@ public class StorageBlockCraftingRecipeAssimilator { packingRecipes.add(packingRecipe); } - } else if ((output.stackSize == 4 || output.stackSize == 9) && recipe.getRecipeSize() == 1) + } else if ((output.getCount() == 4 || output.getCount() == 9) && recipe.getRecipeSize() == 1) { unpackingRecipes.add(recipe); } @@ -81,7 +81,7 @@ public class StorageBlockCraftingRecipeAssimilator { // the recipe could be parsed, use its inputs directly since that's faster verify recipe size - if (recipePack.inputCount != unpacked.stackSize) + if (recipePack.inputCount != unpacked.getCount()) continue; // check if any of the input options matches the unpacked @@ -99,14 +99,14 @@ public class StorageBlockCraftingRecipeAssimilator { // unknown IRecipe, check through the recipe conventionally verify recipe size for 3x3 to skip anything smaller quickly - if (unpacked.stackSize == 9 && recipePack.recipe.getRecipeSize() < 9) + if (unpacked.getCount() == 9 && recipePack.recipe.getRecipeSize() < 9) continue; // initialize inventory late, but only once per unpack recipe if (inventory == null) { - if (unpacked.stackSize == 4) + if (unpacked.getCount() == 4) { inventory = inventory2x2; } else @@ -114,7 +114,7 @@ public class StorageBlockCraftingRecipeAssimilator inventory = inventory3x3; } - for (int i = 0; i < unpacked.stackSize; i++) + for (int i = 0; i < unpacked.getCount(); i++) { inventory.setInventorySlotContents(i, unpacked.copy()); } diff --git a/src/main/java/WayofTime/bloodmagic/demonAura/WillChunk.java b/src/main/java/WayofTime/bloodmagic/demonAura/WillChunk.java index 37f31156..15db5c60 100644 --- a/src/main/java/WayofTime/bloodmagic/demonAura/WillChunk.java +++ b/src/main/java/WayofTime/bloodmagic/demonAura/WillChunk.java @@ -29,13 +29,7 @@ public class WillChunk this.currentWill = currentWill; } - public boolean isModified() - { - if ((this.chunkRef != null) && (this.chunkRef.get() != null)) - { - return ((Chunk) this.chunkRef.get()).needsSaving(false); - } - - return false; + public boolean isModified() { + return (this.chunkRef != null) && (this.chunkRef.get() != null) && this.chunkRef.get().needsSaving(false); } } diff --git a/src/main/java/WayofTime/bloodmagic/demonAura/WorldDemonWillHandler.java b/src/main/java/WayofTime/bloodmagic/demonAura/WorldDemonWillHandler.java index b5a1a6bf..23109866 100644 --- a/src/main/java/WayofTime/bloodmagic/demonAura/WorldDemonWillHandler.java +++ b/src/main/java/WayofTime/bloodmagic/demonAura/WorldDemonWillHandler.java @@ -7,6 +7,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; +import javax.annotation.Nullable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; @@ -15,6 +16,7 @@ public class WorldDemonWillHandler static ConcurrentHashMap containedWills = new ConcurrentHashMap(); public static ConcurrentHashMap> dirtyChunks = new ConcurrentHashMap>(); + @Nullable public static DemonWillHolder getWillHolder(int dim, int x, int y) { WillChunk chunk = getWillChunk(dim, x, y); @@ -36,6 +38,7 @@ public class WorldDemonWillHandler return containedWills.get(dim); } + @Nullable public static WillChunk getWillChunk(int dim, int x, int y) { if (!containedWills.containsKey(dim)) diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackRangedBow.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackRangedBow.java index 09db9725..deb2f90c 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackRangedBow.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackRangedBow.java @@ -37,12 +37,12 @@ public class EntityAIAttackRangedBow extends EntityAIBase */ public boolean shouldExecute() { - return this.entity.getAttackTarget() == null ? false : this.isBowInMainhand(); + return this.entity.getAttackTarget() != null && this.isBowInMainhand(); } protected boolean isBowInMainhand() { - return this.entity.getHeldItemMainhand() != null && this.entity.getHeldItemMainhand().getItem() instanceof ItemBow; + return this.entity.getHeldItemMainhand().getItem() instanceof ItemBow; } /** diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackStealthMelee.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackStealthMelee.java index e54d3c1e..6a5ca700 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackStealthMelee.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackStealthMelee.java @@ -37,7 +37,7 @@ public class EntityAIAttackStealthMelee extends EntityAIBase public EntityAIAttackStealthMelee(EntityCorruptedChicken creature, double speedIn, boolean useLongMemory) { this.chicken = creature; - this.worldObj = creature.worldObj; + this.worldObj = creature.getEntityWorld(); this.speedTowardsTarget = speedIn; this.longMemory = useLongMemory; this.setMutexBits(3); diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIEatAndCorruptBlock.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIEatAndCorruptBlock.java index 6c95a68a..288fc685 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIEatAndCorruptBlock.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIEatAndCorruptBlock.java @@ -20,7 +20,7 @@ public class EntityAIEatAndCorruptBlock extends EntityAIBase public EntityAIEatAndCorruptBlock(EntityAspectedDemonBase entity) { this.grassEaterEntity = entity; - this.world = entity.worldObj; + this.world = entity.getEntityWorld(); this.setMutexBits(7); } diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIFollowOwner.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIFollowOwner.java index 7227f8cf..cac00901 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIFollowOwner.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIFollowOwner.java @@ -29,7 +29,7 @@ public class EntityAIFollowOwner extends EntityAIBase public EntityAIFollowOwner(EntityDemonBase thePetIn, double followSpeedIn, float minDistIn, float maxDistIn) { this.thePet = thePetIn; - this.theWorld = thePetIn.worldObj; + this.theWorld = thePetIn.getEntityWorld(); this.followSpeed = followSpeedIn; this.petPathfinder = thePetIn.getNavigator(); this.minDist = minDistIn; @@ -100,7 +100,7 @@ public class EntityAIFollowOwner extends EntityAIBase { IBlockState iblockstate = this.theWorld.getBlockState(pos); Block block = iblockstate.getBlock(); - return block == Blocks.AIR ? true : !iblockstate.isFullCube(); + return block == Blocks.AIR || !iblockstate.isFullCube(); } /** @@ -122,9 +122,9 @@ public class EntityAIFollowOwner extends EntityAIBase { if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D) { - int i = MathHelper.floor_double(this.theOwner.posX) - 2; - int j = MathHelper.floor_double(this.theOwner.posZ) - 2; - int k = MathHelper.floor_double(this.theOwner.getEntityBoundingBox().minY); + int i = MathHelper.floor(this.theOwner.posX) - 2; + int j = MathHelper.floor(this.theOwner.posZ) - 2; + int k = MathHelper.floor(this.theOwner.getEntityBoundingBox().minY); for (int l = 0; l <= 4; ++l) { diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIGrabEffectsFromOwner.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIGrabEffectsFromOwner.java index 04e5fc62..1559d2b2 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIGrabEffectsFromOwner.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIGrabEffectsFromOwner.java @@ -32,7 +32,7 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase public EntityAIGrabEffectsFromOwner(EntitySentientSpecter thePetIn, double followSpeedIn, float minDistIn) { this.thePet = thePetIn; - this.theWorld = thePetIn.worldObj; + this.theWorld = thePetIn.getEntityWorld(); this.followSpeed = followSpeedIn; this.petPathfinder = thePetIn.getNavigator(); this.minDist = minDistIn; @@ -105,7 +105,7 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase { IBlockState iblockstate = this.theWorld.getBlockState(pos); Block block = iblockstate.getBlock(); - return block == Blocks.AIR ? true : !iblockstate.isFullCube(); + return block == Blocks.AIR || !iblockstate.isFullCube(); } /** @@ -135,9 +135,9 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase { if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D) { - int i = MathHelper.floor_double(this.theOwner.posX) - 2; - int j = MathHelper.floor_double(this.theOwner.posZ) - 2; - int k = MathHelper.floor_double(this.theOwner.getEntityBoundingBox().minY); + int i = MathHelper.floor(this.theOwner.posX) - 2; + int j = MathHelper.floor(this.theOwner.posZ) - 2; + int k = MathHelper.floor(this.theOwner.getEntityBoundingBox().minY); for (int l = 0; l <= 4; ++l) { diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIPickUpAlly.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIPickUpAlly.java index c1ac0d59..62477326 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIPickUpAlly.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIPickUpAlly.java @@ -40,7 +40,7 @@ public class EntityAIPickUpAlly extends EntityAIBase public EntityAIPickUpAlly(EntityAspectedDemonBase creature, double speedIn, boolean useLongMemory) { this.entity = creature; - this.worldObj = creature.worldObj; + this.worldObj = creature.getEntityWorld(); this.speedTowardsTarget = speedIn; this.longMemory = useLongMemory; this.setMutexBits(3); @@ -57,7 +57,7 @@ public class EntityAIPickUpAlly extends EntityAIBase } AxisAlignedBB bb = new AxisAlignedBB(entity.posX - 0.5, entity.posY - 0.5, entity.posZ - 0.5, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5).expandXyz(5); - List list = this.entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, bb, new EntityAspectedDemonBase.WillTypePredicate(entity.getType())); + List list = this.entity.getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, bb, new EntityAspectedDemonBase.WillTypePredicate(entity.getType())); for (EntityLivingBase testEntity : list) { if (testEntity != this.entity) diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIProtectAlly.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIProtectAlly.java index ad46d8ca..23b345ca 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIProtectAlly.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIProtectAlly.java @@ -21,7 +21,7 @@ public class EntityAIProtectAlly extends EntityAIBase public EntityAIProtectAlly(EntityCorruptedSheep entity) { this.entity = entity; - this.world = entity.worldObj; + this.world = entity.getEntityWorld(); this.setMutexBits(7); } diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIRetreatToHeal.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIRetreatToHeal.java index c4b08304..57561229 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIRetreatToHeal.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIRetreatToHeal.java @@ -69,7 +69,7 @@ public class EntityAIRetreatToHeal extends EntityAIBase } //This part almost doesn't matter - List list = this.theEntity.worldObj.getEntitiesWithinAABB(this.classToAvoid, this.theEntity.getEntityBoundingBox().expand((double) this.avoidDistance, 3.0D, (double) this.avoidDistance), Predicates.and(new Predicate[] { EntitySelectors.CAN_AI_TARGET, this.canBeSeenSelector, this.avoidTargetSelector })); + List list = this.theEntity.getEntityWorld().getEntitiesWithinAABB(this.classToAvoid, this.theEntity.getEntityBoundingBox().expand((double) this.avoidDistance, 3.0D, (double) this.avoidDistance), Predicates.and(new Predicate[] { EntitySelectors.CAN_AI_TARGET, this.canBeSeenSelector, this.avoidTargetSelector })); if (list.isEmpty()) { diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIStealthRetreat.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIStealthRetreat.java index 68d84d7b..533af52b 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIStealthRetreat.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIStealthRetreat.java @@ -82,7 +82,7 @@ public class EntityAIStealthRetreat extends EntityAIBase @Override public void startExecuting() { - ticksLeft = this.entity.worldObj.rand.nextInt(100) + 100; + ticksLeft = this.entity.getEntityWorld().rand.nextInt(100) + 100; this.entityPathNavigate.setPath(this.entityPathEntity, this.farSpeed); } diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIStealthTowardsTarget.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIStealthTowardsTarget.java index fa9a52fe..cba52335 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIStealthTowardsTarget.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIStealthTowardsTarget.java @@ -47,7 +47,7 @@ public class EntityAIStealthTowardsTarget extends EntityAIBase return false; } else { - ticksLeft = this.entity.worldObj.rand.nextInt(200) + 100; + ticksLeft = this.entity.getEntityWorld().rand.nextInt(200) + 100; this.xPosition = vec3d.xCoord; this.yPosition = vec3d.yCoord; this.zPosition = vec3d.zCoord; @@ -75,7 +75,7 @@ public class EntityAIStealthTowardsTarget extends EntityAIBase if (this.entity.getNavigator().noPath()) { EntityLivingBase target = this.entity.getAttackTarget(); - Vec3d vec3d = null; + Vec3d vec3d; if (target instanceof EntityCreature) { vec3d = RandomPositionGenerator.findRandomTarget((EntityCreature) target, 10, 7); diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityAspectedDemonBase.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityAspectedDemonBase.java index a3ba864b..caeedfd3 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityAspectedDemonBase.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityAspectedDemonBase.java @@ -180,15 +180,15 @@ public abstract class EntityAspectedDemonBase extends EntityDemonBase float newAmount = amount; if (source.isProjectile()) { - newAmount *= MathHelper.clamp_double(1 - getProjectileResist(), 0, 1); + newAmount *= MathHelper.clamp(1 - getProjectileResist(), 0, 1); } else { - newAmount *= MathHelper.clamp_double(1 - getMeleeResist(), 0, 1); + newAmount *= MathHelper.clamp(1 - getMeleeResist(), 0, 1); } if (source.isMagicDamage()) { - newAmount *= MathHelper.clamp_double(1 - getMagicResist(), 0, 1); + newAmount *= MathHelper.clamp(1 - getMagicResist(), 0, 1); } return super.attackEntityFrom(source, newAmount); diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedChicken.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedChicken.java index 474343cf..77058576 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedChicken.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedChicken.java @@ -139,7 +139,7 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase this.oFlap = this.wingRotation; this.oFlapSpeed = this.destPos; this.destPos = (float) ((double) this.destPos + (double) (this.onGround ? -1 : 4) * 0.3D); - this.destPos = MathHelper.clamp_float(this.destPos, 0.0F, 1.0F); + this.destPos = MathHelper.clamp(this.destPos, 0.0F, 1.0F); if (!this.onGround && this.wingRotDelta < 1.0F) { @@ -155,7 +155,7 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase this.wingRotation += this.wingRotDelta * 2.0F; - if (!this.worldObj.isRemote && !this.isChild() && --this.timeUntilNextEgg <= 0) + if (!this.getEntityWorld().isRemote && !this.isChild() && --this.timeUntilNextEgg <= 0) { this.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); this.dropItem(Items.EGG, 1); diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSheep.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSheep.java index 516ff8d2..b6ceb3c6 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSheep.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSheep.java @@ -121,7 +121,7 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh @Override public void onLivingUpdate() { - if (this.worldObj.isRemote) + if (this.getEntityWorld().isRemote) { this.sheepTimer = Math.max(0, this.sheepTimer - 1); this.castTimer = Math.max(0, castTimer - 1); @@ -359,7 +359,7 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); - this.setFleeceColor(getRandomSheepColor(this.worldObj.rand)); + this.setFleeceColor(getRandomSheepColor(this.getEntityWorld().rand)); return livingdata; } diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSpider.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSpider.java index ee512510..1b6ec0cc 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSpider.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSpider.java @@ -52,7 +52,7 @@ public class EntityCorruptedSpider extends EntityAspectedDemonBase this.tasks.addTask(5, new EntityAIWander(this, 0.8D)); this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(6, new EntityAILookIdle(this)); - this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0])); + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, 10, true, false, new EntityAspectedDemonBase.TeamAttackPredicate(this))); @@ -95,7 +95,7 @@ public class EntityCorruptedSpider extends EntityAspectedDemonBase } @Override - protected PathNavigate getNewNavigator(World worldIn) + protected PathNavigate createNavigator(World worldIn) { return new PathNavigateClimber(this, worldIn); } @@ -104,7 +104,7 @@ public class EntityCorruptedSpider extends EntityAspectedDemonBase protected void entityInit() { super.entityInit(); - this.dataManager.register(CLIMBING, Byte.valueOf((byte) 0)); + this.dataManager.register(CLIMBING, (byte) 0); } @Override @@ -112,7 +112,7 @@ public class EntityCorruptedSpider extends EntityAspectedDemonBase { super.onUpdate(); - if (!this.worldObj.isRemote) + if (!this.getEntityWorld().isRemote) { this.setBesideClimbableBlock(this.isCollidedHorizontally); } @@ -168,17 +168,17 @@ public class EntityCorruptedSpider extends EntityAspectedDemonBase @Override public boolean isPotionApplicable(PotionEffect potioneffectIn) { - return potioneffectIn.getPotion() == MobEffects.POISON ? false : super.isPotionApplicable(potioneffectIn); + return potioneffectIn.getPotion() != MobEffects.POISON && super.isPotionApplicable(potioneffectIn); } public boolean isBesideClimbableBlock() { - return (((Byte) this.dataManager.get(CLIMBING)).byteValue() & 1) != 0; + return (this.dataManager.get(CLIMBING) & 1) != 0; } public void setBesideClimbableBlock(boolean climbing) { - byte b0 = ((Byte) this.dataManager.get(CLIMBING)).byteValue(); + byte b0 = this.dataManager.get(CLIMBING); if (climbing) { @@ -188,7 +188,7 @@ public class EntityCorruptedSpider extends EntityAspectedDemonBase b0 = (byte) (b0 & -2); } - this.dataManager.set(CLIMBING, Byte.valueOf(b0)); + this.dataManager.set(CLIMBING, b0); } @Override @@ -213,7 +213,7 @@ public class EntityCorruptedSpider extends EntityAspectedDemonBase if (f >= 0.5F && this.attacker.getRNG().nextInt(100) == 0) { - this.attacker.setAttackTarget((EntityLivingBase) null); + this.attacker.setAttackTarget(null); return false; } else { @@ -240,7 +240,7 @@ public class EntityCorruptedSpider extends EntityAspectedDemonBase public boolean shouldExecute() { float f = this.taskOwner.getBrightness(1.0F); - return f >= 0.5F ? false : super.shouldExecute(); + return !(f >= 0.5F) && super.shouldExecute(); } } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedZombie.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedZombie.java index 34b0825e..719b98de 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedZombie.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedZombie.java @@ -73,17 +73,17 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase @Override public void setCombatTask() { - if (this.worldObj != null && !this.worldObj.isRemote) + if (!this.getEntityWorld().isRemote) { this.tasks.removeTask(this.aiAttackOnCollide); this.tasks.removeTask(this.aiArrowAttack); ItemStack itemstack = this.getHeldItemMainhand(); - if (itemstack != null && itemstack.getItem() instanceof ItemBow) + if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow) { int i = 20; - if (this.worldObj.getDifficulty() != EnumDifficulty.HARD) + if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD) { i = 40; } @@ -100,7 +100,7 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase @Override public boolean attackEntityFrom(DamageSource source, float amount) { - return this.isEntityInvulnerable(source) ? false : super.attackEntityFrom(source, amount); + return !this.isEntityInvulnerable(source) && super.attackEntityFrom(source, amount); } /** @@ -128,7 +128,7 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase */ public double absorbWillFromAuraToHeal(double toHeal) { - if (worldObj.isRemote) + if (getEntityWorld().isRemote) { return 0; } @@ -139,13 +139,13 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase return 0; } - double will = WorldDemonWillHandler.getCurrentWill(worldObj, getPosition(), getType()); + double will = WorldDemonWillHandler.getCurrentWill(getEntityWorld(), getPosition(), getType()); toHeal = Math.min(healthMissing, Math.min(toHeal, will / getWillToHealth())); if (toHeal > 0) { this.heal((float) toHeal); - return WorldDemonWillHandler.drainWill(worldObj, getPosition(), getType(), toHeal * getWillToHealth(), true); + return WorldDemonWillHandler.drainWill(getEntityWorld(), getPosition(), getType(), toHeal * getWillToHealth(), true); } return 0; @@ -164,7 +164,7 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase public void onUpdate() { - if (!this.worldObj.isRemote && this.ticksExisted % 20 == 0) + if (!this.getEntityWorld().isRemote && this.ticksExisted % 20 == 0) { absorbWillFromAuraToHeal(2); } @@ -174,15 +174,8 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase //TODO: Change to fit the given AI @Override - public boolean shouldAttackEntity(EntityLivingBase attacker, EntityLivingBase owner) - { - if (!(attacker instanceof EntityCreeper) && !(attacker instanceof EntityGhast)) - { - return super.shouldAttackEntity(attacker, owner); - } else - { - return false; - } + public boolean shouldAttackEntity(EntityLivingBase attacker, EntityLivingBase owner) { + return !(attacker instanceof EntityCreeper) && !(attacker instanceof EntityGhast) && super.shouldAttackEntity(attacker, owner); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityDemonBase.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityDemonBase.java index 70d99fa1..7373eea7 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityDemonBase.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityDemonBase.java @@ -39,8 +39,8 @@ import com.google.common.base.Predicate; public class EntityDemonBase extends EntityCreature implements IEntityOwnable { - protected static final DataParameter TAMED = EntityDataManager.createKey(EntityDemonBase.class, DataSerializers.BYTE); - protected static final DataParameter> OWNER_UNIQUE_ID = EntityDataManager.>createKey(EntityDemonBase.class, DataSerializers.OPTIONAL_UNIQUE_ID); + protected static final DataParameter TAMED = EntityDataManager.createKey(EntityDemonBase.class, DataSerializers.BYTE); + protected static final DataParameter> OWNER_UNIQUE_ID = EntityDataManager.createKey(EntityDemonBase.class, DataSerializers.OPTIONAL_UNIQUE_ID); public EntityDemonBase(World worldIn) { @@ -51,7 +51,7 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable protected void entityInit() { super.entityInit(); - this.dataManager.register(TAMED, Byte.valueOf((byte) 0)); + this.dataManager.register(TAMED, (byte) 0); this.dataManager.register(OWNER_UNIQUE_ID, Optional.absent()); } @@ -84,7 +84,7 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable @Override public boolean attackEntityFrom(DamageSource source, float amount) { - return this.isEntityInvulnerable(source) ? false : super.attackEntityFrom(source, amount); + return !this.isEntityInvulnerable(source) && super.attackEntityFrom(source, amount); } /** @@ -106,7 +106,7 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable if (flag) { - if (i > 0 && attackedEntity instanceof EntityLivingBase) + if (i > 0) { ((EntityLivingBase) attackedEntity).knockBack(this, (float) i * 0.5F, (double) MathHelper.sin(this.rotationYaw * 0.017453292F), (double) (-MathHelper.cos(this.rotationYaw * 0.017453292F))); this.motionX *= 0.6D; @@ -124,16 +124,16 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable { EntityPlayer entityplayer = (EntityPlayer) attackedEntity; ItemStack itemstack = this.getHeldItemMainhand(); - ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null; + ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : ItemStack.EMPTY; - if (itemstack != null && itemstack1 != null && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD) + if (!itemstack.isEmpty() && !itemstack1.isEmpty() && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD) { float f1 = 0.25F + (float) EnchantmentHelper.getEfficiencyModifier(this) * 0.05F; if (this.rand.nextFloat() < f1) { entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100); - this.worldObj.setEntityState(entityplayer, (byte) 30); + this.getEntityWorld().setEntityState(entityplayer, (byte) 30); } } } @@ -149,7 +149,7 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable { super.setItemStackToSlot(slotIn, stack); - if (!this.worldObj.isRemote && slotIn == EntityEquipmentSlot.MAINHAND) + if (!this.getEntityWorld().isRemote && slotIn == EntityEquipmentSlot.MAINHAND) { this.setCombatTask(); } @@ -169,10 +169,10 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable { this.heal((float) toHeal); - if (worldObj instanceof WorldServer) + if (getEntityWorld() instanceof WorldServer) { - WorldServer server = (WorldServer) worldObj; - server.spawnParticle(EnumParticleTypes.HEART, this.posX + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, this.posY + 0.5D + (double) (this.rand.nextFloat() * this.height), this.posZ + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, 7, 0.2, 0.2, 0.2, 0, new int[0]); + WorldServer server = (WorldServer) getEntityWorld(); + server.spawnParticle(EnumParticleTypes.HEART, this.posX + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, this.posY + 0.5D + (double) (this.rand.nextFloat() * this.height), this.posZ + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, 7, 0.2, 0.2, 0.2, 0); } } @@ -207,7 +207,7 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable { super.readEntityFromNBT(tag); - String s = ""; + String s; if (tag.hasKey("OwnerUUID", 8)) { @@ -248,7 +248,7 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable } } - return attacker instanceof EntityPlayer && owner instanceof EntityPlayer && !((EntityPlayer) owner).canAttackPlayer((EntityPlayer) attacker) ? false : !(attacker instanceof EntityHorse) || !((EntityHorse) attacker).isTame(); + return !(attacker instanceof EntityPlayer && owner instanceof EntityPlayer && !((EntityPlayer) owner).canAttackPlayer((EntityPlayer) attacker)) && (!(attacker instanceof EntityHorse) || !((EntityHorse) attacker).isTame()); } else { return false; @@ -262,19 +262,19 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable public boolean isTamed() { - return (((Byte) this.dataManager.get(TAMED)).byteValue() & 4) != 0; + return (this.dataManager.get(TAMED) & 4) != 0; } public void setTamed(boolean tamed) { - byte b0 = ((Byte) this.dataManager.get(TAMED)).byteValue(); + byte b0 = this.dataManager.get(TAMED); if (tamed) { - this.dataManager.set(TAMED, Byte.valueOf((byte) (b0 | 4))); + this.dataManager.set(TAMED, (byte) (b0 | 4)); } else { - this.dataManager.set(TAMED, Byte.valueOf((byte) (b0 & -5))); + this.dataManager.set(TAMED, (byte) (b0 & -5)); } // this.setupTamedAI(); @@ -316,7 +316,7 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable @Override public UUID getOwnerId() { - return (UUID) (this.dataManager.get(OWNER_UNIQUE_ID)).orNull(); + return (this.dataManager.get(OWNER_UNIQUE_ID)).orNull(); } public void setOwnerId(UUID uuid) @@ -330,7 +330,7 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable try { UUID uuid = this.getOwnerId(); - return uuid == null ? null : this.worldObj.getPlayerEntityByUUID(uuid); + return uuid == null ? null : this.getEntityWorld().getPlayerEntityByUUID(uuid); } catch (IllegalArgumentException var2) { return null; diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityMimic.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityMimic.java index 37c32741..cfe63b1a 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityMimic.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityMimic.java @@ -43,7 +43,7 @@ public class EntityMimic extends EntityDemonBase /** * Copy of EntitySpider's AI (should be pretty evident...) */ - private static final DataParameter CLIMBING = EntityDataManager.createKey(EntityMimic.class, DataSerializers.BYTE); + private static final DataParameter CLIMBING = EntityDataManager.createKey(EntityMimic.class, DataSerializers.BYTE); public boolean dropItemsOnBreak = true; public NBTTagCompound tileTag = new NBTTagCompound(); @@ -64,7 +64,7 @@ public class EntityMimic extends EntityDemonBase this.tasks.addTask(8, new EntityAILookIdle(this)); this.tasks.addTask(7, new EntityAIMimicReform(this)); - this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0])); + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); this.targetTasks.addTask(2, new EntityMimic.AISpiderTarget(this, EntityPlayer.class)); this.targetTasks.addTask(3, new EntityMimic.AISpiderTarget(this, EntityIronGolem.class)); } @@ -160,7 +160,7 @@ public class EntityMimic extends EntityDemonBase } BlockPos newPos = centerPos.add(i, j, k); - if (spawnMimicBlockAtPosition(worldObj, newPos)) + if (spawnMimicBlockAtPosition(getEntityWorld(), newPos)) { return true; } @@ -178,7 +178,7 @@ public class EntityMimic extends EntityDemonBase { super.onDeath(cause); - if (!worldObj.isRemote) + if (!getEntityWorld().isRemote) { BlockPos centerPos = this.getPosition(); @@ -201,7 +201,7 @@ public class EntityMimic extends EntityDemonBase } BlockPos newPos = centerPos.add(i, j, k); - if (spawnHeldBlockOnDeath(worldObj, newPos)) + if (spawnHeldBlockOnDeath(getEntityWorld(), newPos)) { return; } @@ -227,7 +227,7 @@ public class EntityMimic extends EntityDemonBase * Returns new PathNavigateGround instance */ @Override - protected PathNavigate getNewNavigator(World worldIn) + protected PathNavigate createNavigator(World worldIn) { return new PathNavigateClimber(this, worldIn); } @@ -236,7 +236,7 @@ public class EntityMimic extends EntityDemonBase protected void entityInit() { super.entityInit(); - this.dataManager.register(CLIMBING, Byte.valueOf((byte) 0)); + this.dataManager.register(CLIMBING, (byte) 0); // this.dataManager.register(ITEMSTACK, null); } @@ -246,7 +246,7 @@ public class EntityMimic extends EntityDemonBase @Override public void onUpdate() { - if (!this.worldObj.isRemote && this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL) + if (!this.getEntityWorld().isRemote && this.getEntityWorld().getDifficulty() == EnumDifficulty.PEACEFUL) { if (reformIntoMimicBlock(this.getPosition())) { @@ -256,7 +256,7 @@ public class EntityMimic extends EntityDemonBase super.onUpdate(); - if (!this.worldObj.isRemote) + if (!this.getEntityWorld().isRemote) { this.setBesideClimbableBlock(this.isCollidedHorizontally); } @@ -324,7 +324,7 @@ public class EntityMimic extends EntityDemonBase @Override public boolean isPotionApplicable(PotionEffect potioneffectIn) { - return potioneffectIn.getPotion() == MobEffects.POISON ? false : super.isPotionApplicable(potioneffectIn); + return potioneffectIn.getPotion() != MobEffects.POISON && super.isPotionApplicable(potioneffectIn); } /** @@ -333,7 +333,7 @@ public class EntityMimic extends EntityDemonBase */ public boolean isBesideClimbableBlock() { - return (((Byte) this.dataManager.get(CLIMBING)).byteValue() & 1) != 0; + return (this.dataManager.get(CLIMBING) & 1) != 0; } /** @@ -342,7 +342,7 @@ public class EntityMimic extends EntityDemonBase */ public void setBesideClimbableBlock(boolean climbing) { - byte b0 = ((Byte) this.dataManager.get(CLIMBING)).byteValue(); + byte b0 = this.dataManager.get(CLIMBING); if (climbing) { @@ -352,7 +352,7 @@ public class EntityMimic extends EntityDemonBase b0 = (byte) (b0 & -2); } - this.dataManager.set(CLIMBING, Byte.valueOf(b0)); + this.dataManager.set(CLIMBING, b0); } public float getEyeHeight() diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntitySentientSpecter.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntitySentientSpecter.java index 6e6c15a9..11eb66eb 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntitySentientSpecter.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntitySentientSpecter.java @@ -107,17 +107,17 @@ public class EntitySentientSpecter extends EntityDemonBase @Override public void setCombatTask() { - if (this.worldObj != null && !this.worldObj.isRemote) + if (!this.getEntityWorld().isRemote) { this.tasks.removeTask(this.aiAttackOnCollide); this.tasks.removeTask(this.aiArrowAttack); ItemStack itemstack = this.getHeldItemMainhand(); - if (itemstack != null && itemstack.getItem() instanceof ItemBow) + if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow) { int i = 20; - if (this.worldObj.getDifficulty() != EnumDifficulty.HARD) + if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD) { i = 40; } @@ -132,16 +132,11 @@ public class EntitySentientSpecter extends EntityDemonBase } @Override - public boolean isPotionApplicable(PotionEffect effect) - { + public boolean isPotionApplicable(PotionEffect effect) { Potion potion = effect.getPotion(); - if (potion == MobEffects.REGENERATION || potion == MobEffects.INSTANT_HEALTH) //Specter cannot be healed by normal means - { - return false; - } - - return super.isPotionApplicable(effect); + //Specter cannot be healed by normal means + return !(potion == MobEffects.REGENERATION || potion == MobEffects.INSTANT_HEALTH) && super.isPotionApplicable(effect); } public boolean canStealEffectFromOwner(EntityLivingBase owner, PotionEffect effect) @@ -280,7 +275,7 @@ public class EntitySentientSpecter extends EntityDemonBase @Override public boolean attackEntityFrom(DamageSource source, float amount) { - return this.isEntityInvulnerable(source) ? false : super.attackEntityFrom(source, amount); + return !this.isEntityInvulnerable(source) && super.attackEntityFrom(source, amount); } /** @@ -311,7 +306,7 @@ public class EntitySentientSpecter extends EntityDemonBase { super.onDeath(cause); - if (!worldObj.isRemote && getHeldItemMainhand() != null) + if (!getEntityWorld().isRemote && !getHeldItemMainhand().isEmpty()) { this.entityDropItem(getHeldItemMainhand(), 0); } @@ -339,20 +334,21 @@ public class EntitySentientSpecter extends EntityDemonBase } @Override - public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack) + public boolean processInteract(EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); if (this.isTamed() && player.equals(this.getOwner()) && hand == EnumHand.MAIN_HAND) { - if (stack == null && player.isSneaking()) //Should return to the entity + if (stack.isEmpty() && player.isSneaking()) //Should return to the entity { - if (!worldObj.isRemote) + if (!getEntityWorld().isRemote) { - if (getHeldItemMainhand() != null) + if (!getHeldItemMainhand().isEmpty()) { this.entityDropItem(getHeldItemMainhand(), 0); } - if (getHeldItemOffhand() != null) + if (!getHeldItemOffhand().isEmpty()) { this.entityDropItem(getHeldItemOffhand(), 0); } @@ -367,7 +363,7 @@ public class EntitySentientSpecter extends EntityDemonBase } } - return super.processInteract(player, hand, stack); + return super.processInteract(player, hand); } public boolean isEntityInvulnerable(DamageSource source) @@ -380,9 +376,9 @@ public class EntitySentientSpecter extends EntityDemonBase { this.heal((float) toHeal); - if (worldObj instanceof WorldServer) + if (getEntityWorld() instanceof WorldServer) { - WorldServer server = (WorldServer) worldObj; + WorldServer server = (WorldServer) getEntityWorld(); server.spawnParticle(EnumParticleTypes.HEART, this.posX + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, this.posY + 0.5D + (double) (this.rand.nextFloat() * this.height), this.posZ + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, 7, 0.2, 0.2, 0.2, 0, new int[0]); } } @@ -394,7 +390,7 @@ public class EntitySentientSpecter extends EntityDemonBase */ public double absorbWillFromAuraToHeal(double toHeal) { - if (worldObj.isRemote) + if (getEntityWorld().isRemote) { return 0; } @@ -405,13 +401,13 @@ public class EntitySentientSpecter extends EntityDemonBase return 0; } - double will = WorldDemonWillHandler.getCurrentWill(worldObj, getPosition(), getType()); + double will = WorldDemonWillHandler.getCurrentWill(getEntityWorld(), getPosition(), getType()); toHeal = Math.min(healthMissing, Math.min(toHeal, will / getWillToHealth())); if (toHeal > 0) { this.heal((float) toHeal); - return WorldDemonWillHandler.drainWill(worldObj, getPosition(), getType(), toHeal * getWillToHealth(), true); + return WorldDemonWillHandler.drainWill(getEntityWorld(), getPosition(), getType(), toHeal * getWillToHealth(), true); } return 0; @@ -430,7 +426,7 @@ public class EntitySentientSpecter extends EntityDemonBase public void onUpdate() { - if (!this.worldObj.isRemote && this.ticksExisted % 20 == 0) + if (!this.getEntityWorld().isRemote && this.ticksExisted % 20 == 0) { absorbWillFromAuraToHeal(2); } @@ -485,7 +481,7 @@ public class EntitySentientSpecter extends EntityDemonBase ItemStack heldStack = this.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND); if (heldStack != null && heldStack.getItem() == ModItems.SENTIENT_BOW) { - EntityTippedArrow arrowEntity = ((ItemSentientBow) heldStack.getItem()).getArrowEntity(worldObj, heldStack, target, this, velocity); + EntityTippedArrow arrowEntity = ((ItemSentientBow) heldStack.getItem()).getArrowEntity(getEntityWorld(), heldStack, target, this, velocity); if (arrowEntity != null) { List effects = getPotionEffectsForArrowRemovingDuration(0.2f); @@ -495,19 +491,19 @@ public class EntitySentientSpecter extends EntityDemonBase } this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); - this.worldObj.spawnEntityInWorld(arrowEntity); + this.getEntityWorld().spawnEntity(arrowEntity); } } else { - EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.worldObj, this); //TODO: Change to an arrow created by the Sentient Bow + EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.getEntityWorld(), this); //TODO: Change to an arrow created by the Sentient Bow double d0 = target.posX - this.posX; double d1 = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - entitytippedarrow.posY; double d2 = target.posZ - this.posZ; - double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2); + double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); entitytippedarrow.setThrowableHeading(d0, d1 + d3 * 0.2, d2, 1.6F, 0); //TODO: Yes, it is an accurate arrow. Don't be hatin' int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this); int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this); - entitytippedarrow.setDamage((double) (velocity * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.worldObj.getDifficulty().getDifficultyId() * 0.11F)); + entitytippedarrow.setDamage((double) (velocity * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.getEntityWorld().getDifficulty().getDifficultyId() * 0.11F)); if (i > 0) { @@ -533,7 +529,7 @@ public class EntitySentientSpecter extends EntityDemonBase } this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); - this.worldObj.spawnEntityInWorld(entitytippedarrow); + this.getEntityWorld().spawnEntity(entitytippedarrow); } } diff --git a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityBloodLight.java b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityBloodLight.java index d2bb8bd4..6d8f86ef 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityBloodLight.java +++ b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityBloodLight.java @@ -61,7 +61,7 @@ public class EntityBloodLight extends EntityThrowable implements IThrowableEntit @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); + float var9 = MathHelper.sqrt(var1 * var1 + var3 * var3 + var5 * var5); var1 /= var9; var3 /= var9; var5 /= var9; @@ -74,7 +74,7 @@ public class EntityBloodLight extends EntityThrowable implements IThrowableEntit motionX = var1; motionY = var3; motionZ = var5; - float var10 = MathHelper.sqrt_double(var1 * var1 + var5 * var5); + float var10 = MathHelper.sqrt(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); } @@ -105,9 +105,9 @@ public class EntityBloodLight extends EntityThrowable implements IThrowableEntit EnumFacing sideHit = mop.sideHit; BlockPos blockPos = mop.getBlockPos().offset(sideHit); - if (worldObj.isAirBlock(blockPos)) + if (getEntityWorld().isAirBlock(blockPos)) { - worldObj.setBlockState(blockPos, ModBlocks.BLOOD_LIGHT.getDefaultState()); + getEntityWorld().setBlockState(blockPos, ModBlocks.BLOOD_LIGHT.getDefaultState()); } } @@ -129,9 +129,9 @@ public class EntityBloodLight extends EntityThrowable implements IThrowableEntit } } - if (worldObj.isAirBlock(new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ))) + if (getEntityWorld().isAirBlock(new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ))) { - worldObj.setBlockState(new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ), Blocks.FIRE.getDefaultState()); + getEntityWorld().setBlockState(new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ), Blocks.FIRE.getDefaultState()); } // spawnHitParticles("magicCrit", 8); diff --git a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityMeteor.java b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityMeteor.java index 6735b95b..5170be8c 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityMeteor.java +++ b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityMeteor.java @@ -95,12 +95,12 @@ public class EntityMeteor extends EntityThrowable implements IThrowableEntity public void generateMeteor(BlockPos pos) { - MeteorRegistry.generateMeteorForItem(meteorStack, worldObj, pos, Blocks.STONE.getDefaultState(), radiusModifier, explosionModifier, fillerChance); + MeteorRegistry.generateMeteorForItem(meteorStack, getEntityWorld(), pos, Blocks.STONE.getDefaultState(), radiusModifier, explosionModifier, fillerChance); } public DamageSource getDamageSource() { - return DamageSource.anvil; + return DamageSource.ANVIL; } @Override @@ -127,7 +127,7 @@ public class EntityMeteor extends EntityThrowable implements IThrowableEntity radiusModifier = nbt.getDouble("radiusModifier"); explosionModifier = nbt.getDouble("explosionModifier"); fillerChance = nbt.getDouble("fillerChance"); - meteorStack = ItemStack.loadItemStackFromNBT(nbt); + meteorStack = new ItemStack(nbt); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java index c9dc343e..c6cf622f 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java +++ b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java @@ -41,7 +41,7 @@ public class EntitySentientArrow extends EntityTippedArrow { if (this.shootingEntity instanceof EntityPlayer) { - if (hitEntity.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL && !(hitEntity instanceof IMob)) + if (hitEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(hitEntity instanceof IMob)) { return; } diff --git a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySoulSnare.java b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySoulSnare.java index aa26da03..ee30ed6d 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySoulSnare.java +++ b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySoulSnare.java @@ -39,7 +39,7 @@ public class EntitySoulSnare extends EntityThrowable if (result.entityHit != null && result.entityHit != this.getThrower()) { - if (result.entityHit instanceof EntityLivingBase && result.entityHit.worldObj.rand.nextDouble() < 0.25) + if (result.entityHit instanceof EntityLivingBase && result.entityHit.getEntityWorld().rand.nextDouble() < 0.25) { ((EntityLivingBase) result.entityHit).addPotionEffect(new PotionEffect(ModPotions.soulSnare, 300, 0)); } @@ -49,10 +49,10 @@ public class EntitySoulSnare extends EntityThrowable for (int j = 0; j < 8; ++j) { - this.worldObj.spawnParticle(EnumParticleTypes.SNOWBALL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]); + this.getEntityWorld().spawnParticle(EnumParticleTypes.SNOWBALL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } - if (!this.worldObj.isRemote) + if (!this.getEntityWorld().isRemote) { this.setDead(); } diff --git a/src/main/java/WayofTime/bloodmagic/fakePlayer/FakeNetHandlerPlayServer.java b/src/main/java/WayofTime/bloodmagic/fakePlayer/FakeNetHandlerPlayServer.java index 7486c89b..b807b886 100644 --- a/src/main/java/WayofTime/bloodmagic/fakePlayer/FakeNetHandlerPlayServer.java +++ b/src/main/java/WayofTime/bloodmagic/fakePlayer/FakeNetHandlerPlayServer.java @@ -5,31 +5,13 @@ import net.minecraft.network.EnumPacketDirection; import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; -import net.minecraft.network.play.client.CPacketAnimation; -import net.minecraft.network.play.client.CPacketChatMessage; -import net.minecraft.network.play.client.CPacketClickWindow; -import net.minecraft.network.play.client.CPacketClientSettings; -import net.minecraft.network.play.client.CPacketClientStatus; -import net.minecraft.network.play.client.CPacketCloseWindow; -import net.minecraft.network.play.client.CPacketConfirmTransaction; -import net.minecraft.network.play.client.CPacketCreativeInventoryAction; -import net.minecraft.network.play.client.CPacketEnchantItem; -import net.minecraft.network.play.client.CPacketEntityAction; -import net.minecraft.network.play.client.CPacketHeldItemChange; -import net.minecraft.network.play.client.CPacketInput; -import net.minecraft.network.play.client.CPacketKeepAlive; -import net.minecraft.network.play.client.CPacketPlayer; -import net.minecraft.network.play.client.CPacketPlayerAbilities; -import net.minecraft.network.play.client.CPacketPlayerDigging; -import net.minecraft.network.play.client.CPacketPlayerTryUseItem; -import net.minecraft.network.play.client.CPacketResourcePackStatus; -import net.minecraft.network.play.client.CPacketSpectate; -import net.minecraft.network.play.client.CPacketTabComplete; -import net.minecraft.network.play.client.CPacketUpdateSign; -import net.minecraft.network.play.client.CPacketUseEntity; +import net.minecraft.network.play.client.*; +import net.minecraft.network.play.server.SPacketPlayerPosLook; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.fml.common.FMLCommonHandler; +import java.util.Set; + /** * All credits for this go to CrazyPants, from EIO */ @@ -47,7 +29,47 @@ public class FakeNetHandlerPlayServer extends NetHandlerPlayServer } @Override - public void kickPlayerFromServer(String p_147360_1_) + public void update() + { + } + + @Override + public void disconnect(String reason) + { + } + + @Override + public void processVehicleMove(CPacketVehicleMove packetIn) + { + } + + @Override + public void processConfirmTeleport(CPacketConfirmTeleport packetIn) + { + } + + @Override + public void setPlayerLocation(double x, double y, double z, float yaw, float pitch, Set relativeSet) + { + } + + @Override + public void processTryUseItemOnBlock(CPacketPlayerTryUseItemOnBlock packetIn) + { + } + + @Override + public void processTryUseItem(CPacketPlayerTryUseItem packetIn) + { + } + + @Override + public void processSteerBoat(CPacketSteerBoat packetIn) + { + } + + @Override + public void processCustomPayload(CPacketCustomPayload packetIn) { } @@ -71,11 +93,6 @@ public class FakeNetHandlerPlayServer extends NetHandlerPlayServer { } - @Override - public void processPlayerBlockPlacement(CPacketPlayerTryUseItem packetIn) - { - } - @Override public void onDisconnect(ITextComponent p_147231_1_) { diff --git a/src/main/java/WayofTime/bloodmagic/fakePlayer/FakePlayerBM.java b/src/main/java/WayofTime/bloodmagic/fakePlayer/FakePlayerBM.java index 18e2c0d4..1de85e6b 100644 --- a/src/main/java/WayofTime/bloodmagic/fakePlayer/FakePlayerBM.java +++ b/src/main/java/WayofTime/bloodmagic/fakePlayer/FakePlayerBM.java @@ -16,8 +16,6 @@ import com.mojang.authlib.GameProfile; */ public class FakePlayerBM extends FakePlayer { - ItemStack prevWeapon; - public FakePlayerBM(World world, BlockPos pos, GameProfile profile) { super(FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(world.provider.getDimension()), profile); diff --git a/src/main/java/WayofTime/bloodmagic/gson/Serializers.java b/src/main/java/WayofTime/bloodmagic/gson/Serializers.java index 51945b5e..3b67c610 100644 --- a/src/main/java/WayofTime/bloodmagic/gson/Serializers.java +++ b/src/main/java/WayofTime/bloodmagic/gson/Serializers.java @@ -34,7 +34,7 @@ public class Serializers @Override public EnumDemonWillType read(PacketBuffer buf) { - return (EnumDemonWillType) buf.readEnumValue(EnumDemonWillType.class); + return buf.readEnumValue(EnumDemonWillType.class); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/inversion/InversionPillarHandler.java b/src/main/java/WayofTime/bloodmagic/inversion/InversionPillarHandler.java index 512cb8cb..1a13c8f5 100644 --- a/src/main/java/WayofTime/bloodmagic/inversion/InversionPillarHandler.java +++ b/src/main/java/WayofTime/bloodmagic/inversion/InversionPillarHandler.java @@ -94,12 +94,8 @@ public class InversionPillarHandler { List otherPosList = willMap.get(type); - Iterator posIterator = otherPosList.iterator(); - while (posIterator.hasNext()) - { - BlockPos closePos = posIterator.next(); - if (!closePos.equals(pos) && closePos.distanceSq(pos) <= farthestDistanceSquared) - { + for (BlockPos closePos : otherPosList) { + if (!closePos.equals(pos) && closePos.distanceSq(pos) <= farthestDistanceSquared) { closePosList.add(closePos); } } @@ -113,16 +109,11 @@ public class InversionPillarHandler { Map> posMap = willMap.get(type); - Iterator closePosIterator = closePosList.iterator(); - while (closePosIterator.hasNext()) - { - BlockPos closePos = closePosIterator.next(); + for (BlockPos closePos : closePosList) { List posList = posMap.get(closePos); - if (posList != null && !posList.contains(pos)) - { + if (posList != null && !posList.contains(pos)) { posList.add(pos); - } else - { + } else { posList = new ArrayList(); posList.add(pos); posMap.put(closePos, posList); @@ -220,18 +211,12 @@ public class InversionPillarHandler //Positions that are new this iteration and need to be dumped into uncheckedPosList next iteration. List newPosList = new ArrayList(); - Iterator itr = uncheckedPosList.iterator(); - while (itr.hasNext()) - { - BlockPos checkPos = itr.next(); + for (BlockPos checkPos : uncheckedPosList) { List posList = posMap.get(checkPos); - if (posList != null) - { - for (BlockPos testPos : posList) - { + if (posList != null) { + for (BlockPos testPos : posList) { //Check if the position has already been checked, is scheduled to be checked, or is already found it needs to be checked. - if (!checkedPosList.contains(testPos) && !uncheckedPosList.contains(testPos) && !newPosList.contains(testPos)) - { + if (!checkedPosList.contains(testPos) && !uncheckedPosList.contains(testPos) && !newPosList.contains(testPos)) { newPosList.add(testPos); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java b/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java index d94bdcca..db0523da 100644 --- a/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java +++ b/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java @@ -52,6 +52,8 @@ import WayofTime.bloodmagic.util.helper.TextHelper; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; +import javax.annotation.Nullable; + public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshProvider { private static Field _FLAGS = ReflectionHelper.findField(Entity.class, "FLAGS", "field_184240_ax"); @@ -138,12 +140,12 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP int maxAbsorption = 100000; - if (source.equals(DamageSource.drown)) + if (source.equals(DamageSource.DROWN)) { return new ArmorProperties(-1, 0, 0); } - if (source.equals(DamageSource.outOfWorld)) + if (source.equals(DamageSource.OUT_OF_WORLD)) { return new ArmorProperties(-1, 0, 0); } @@ -243,7 +245,7 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP if (damage > this.getMaxDamage(stack) - this.getDamage(stack)) { //TODO: Syphon a load of LP. - if (entity.worldObj.isRemote && entity instanceof EntityPlayer) + if (entity.getEntityWorld().isRemote && entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; SoulNetwork network = NetworkHelper.getSoulNetwork(player); @@ -307,7 +309,7 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP if (tracker != null) { double progress = tracker.getProgress(armour, upgrade.getUpgradeLevel()); - tooltip.add(TextHelper.localize("tooltip.BloodMagic.livingArmour.upgrade.progress", TextHelper.localize(upgrade.getUnlocalizedName()), MathHelper.clamp_int((int) (progress * 100D), 0, 100))); + tooltip.add(TextHelper.localize("tooltip.BloodMagic.livingArmour.upgrade.progress", TextHelper.localize(upgrade.getUnlocalizedName()), MathHelper.clamp((int) (progress * 100D), 0, 100))); } } else { @@ -458,6 +460,7 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP return ret; } + @Nullable public static LivingArmour getLivingArmourFromStack(ItemStack stack) { NBTTagCompound livingTag = getArmourTag(stack); @@ -549,6 +552,7 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP return uuid != null && armourMap.containsKey(uuid); } + @Nullable public static LivingArmour getLivingArmour(ItemStack stack) { UUID uuid = Utils.getUUID(stack); diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java b/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java index 6c880de0..9c1e1728 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java @@ -197,7 +197,7 @@ public class LivingArmour implements ILivingArmour continue; } - if ((world.isRemote && upgrade.runOnClient()) || !world.isRemote) + if (!world.isRemote || upgrade.runOnClient()) { upgrade.onTick(world, player, this); } @@ -385,7 +385,7 @@ public class LivingArmour implements ILivingArmour continue; } ItemStack slotStack = player.getItemStackFromSlot(slot); - if (slotStack == null || !(slotStack.getItem() instanceof ItemLivingArmour)) + if (slotStack.isEmpty() || !(slotStack.getItem() instanceof ItemLivingArmour)) return false; } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeDisoriented.java b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeDisoriented.java index 61f0be8e..81b1ae68 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeDisoriented.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeDisoriented.java @@ -22,8 +22,8 @@ public class LivingArmourUpgradeDisoriented extends LivingArmourUpgrade { if (world.isRemote && player.ticksExisted % 20 == 0 && world.rand.nextDouble() <= chance[this.level]) { - player.rotationYaw = (float) (world.rand.nextFloat() * 360); - player.rotationPitch = (float) (world.rand.nextFloat() * 180 - 90); + player.rotationYaw = world.rand.nextFloat() * 360; + player.rotationPitch = world.rand.nextFloat() * 180 - 90; } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeMeleeDecrease.java b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeMeleeDecrease.java index 96dc33fa..76ec099f 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeMeleeDecrease.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeMeleeDecrease.java @@ -36,7 +36,7 @@ public class LivingArmourUpgradeMeleeDecrease extends LivingArmourUpgrade { Multimap modifierMap = HashMultimap.create(); - modifierMap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(0271023, 5321), "damage modifier" + 2, meleeDamage[this.level], 1)); + modifierMap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(new UUID(271023, 5321), "damage modifier" + 2, meleeDamage[this.level], 1)); return modifierMap; } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlowness.java b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlowness.java index ad67cfe4..b516db11 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlowness.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlowness.java @@ -29,7 +29,7 @@ public class LivingArmourUpgradeSlowness extends LivingArmourUpgrade { Multimap modifierMap = HashMultimap.create(); - modifierMap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(85472, 8502), "speed modifier" + 2, speedModifier[this.level], 1)); + modifierMap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(), new AttributeModifier(new UUID(85472, 8502), "speed modifier" + 2, speedModifier[this.level], 1)); return modifierMap; } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFallProtect.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFallProtect.java index 12e23ef7..39d51dc5 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFallProtect.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFallProtect.java @@ -19,7 +19,7 @@ public class LivingArmourUpgradeFallProtect extends LivingArmourUpgrade @Override public double getArmourProtection(EntityLivingBase wearer, DamageSource source) { - if (source.equals(DamageSource.fall)) + if (source.equals(DamageSource.FALL)) { return protectionLevel[this.level]; } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeHealthboost.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeHealthboost.java index b593da5a..4dc51e55 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeHealthboost.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeHealthboost.java @@ -34,7 +34,7 @@ public class LivingArmourUpgradeHealthboost extends LivingArmourUpgrade { Multimap modifierMap = HashMultimap.create(); - modifierMap.put(SharedMonsterAttributes.MAX_HEALTH.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(9423688, 1), "Health modifier" + 1, healthModifier[this.level], 0)); + modifierMap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(9423688, 1), "Health modifier" + 1, healthModifier[this.level], 0)); return modifierMap; } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeKnockbackResist.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeKnockbackResist.java index 078aa21f..c59f4e48 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeKnockbackResist.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeKnockbackResist.java @@ -26,11 +26,11 @@ public class LivingArmourUpgradeKnockbackResist extends LivingArmourUpgrade { Multimap modifierMap = HashMultimap.create(); - modifierMap.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(895132, 1), "Knockback modifier" + 1, kbModifier[this.level], 0)); + modifierMap.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(new UUID(895132, 1), "Knockback modifier" + 1, kbModifier[this.level], 0)); if (healthModifier[this.level] > 0) { - modifierMap.put(SharedMonsterAttributes.MAX_HEALTH.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(952142, 1), "Health modifier" + 1, healthModifier[this.level], 0)); + modifierMap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(952142, 1), "Health modifier" + 1, healthModifier[this.level], 0)); } return modifierMap; diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeMeleeDamage.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeMeleeDamage.java index 228404de..4bbe2fc7 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeMeleeDamage.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeMeleeDamage.java @@ -34,7 +34,7 @@ public class LivingArmourUpgradeMeleeDamage extends LivingArmourUpgrade { Multimap modifierMap = HashMultimap.create(); - modifierMap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(9423688, 1), "damage modifier" + 1, meleeDamage[this.level], 0)); + modifierMap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(new UUID(9423688, 1), "damage modifier" + 1, meleeDamage[this.level], 0)); return modifierMap; } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeRepairing.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeRepairing.java index 818e177b..00f17e9f 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeRepairing.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeRepairing.java @@ -32,7 +32,7 @@ public class LivingArmourUpgradeRepairing extends LivingArmourUpgrade EntityEquipmentSlot randomSlot = EntityEquipmentSlot.values()[2 + world.rand.nextInt(4)]; ItemStack repairStack = player.getItemStackFromSlot(randomSlot); - if (repairStack != null) + if (!repairStack.isEmpty()) { if (repairStack.isItemStackDamageable() && repairStack.isItemDamaged()) { diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSolarPowered.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSolarPowered.java index b86b39cc..5196c902 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSolarPowered.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSolarPowered.java @@ -29,7 +29,7 @@ public class LivingArmourUpgradeSolarPowered extends LivingArmourUpgrade @Override public double getArmourProtection(EntityLivingBase wearer, DamageSource source) { - if (wearer.worldObj.canSeeSky(wearer.getPosition()) || wearer.worldObj.provider.isDaytime()) + if (wearer.getEntityWorld().canSeeSky(wearer.getPosition()) || wearer.getEntityWorld().provider.isDaytime()) { return protectionLevel[this.level]; } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSpeed.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSpeed.java index eca1937e..6e591e7a 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSpeed.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSpeed.java @@ -61,7 +61,7 @@ public class LivingArmourUpgradeSpeed extends LivingArmourUpgrade if (healthModifier[this.level] > 0) { - modifierMap.put(SharedMonsterAttributes.MAX_HEALTH.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(952142, 1), "Health modifier" + 1, healthModifier[this.level], 0)); + modifierMap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(952142, 1), "Health modifier" + 1, healthModifier[this.level], 0)); } return modifierMap; diff --git a/src/main/java/WayofTime/bloodmagic/meteor/MeteorComponent.java b/src/main/java/WayofTime/bloodmagic/meteor/MeteorComponent.java index af778bd4..1c230eef 100644 --- a/src/main/java/WayofTime/bloodmagic/meteor/MeteorComponent.java +++ b/src/main/java/WayofTime/bloodmagic/meteor/MeteorComponent.java @@ -7,9 +7,11 @@ import lombok.Getter; import lombok.Setter; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.oredict.OreDictionary; import WayofTime.bloodmagic.util.Utils; @@ -34,8 +36,8 @@ public class MeteorComponent meta = Integer.parseInt(stringList[2]); } - Block ore = Block.REGISTRY.getObject(new ResourceLocation(domain, block)); - if (ore != null) + Block ore = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(domain, block)); + if (ore != Blocks.AIR) { return ore.getStateFromMeta(meta); } diff --git a/src/main/java/WayofTime/bloodmagic/network/PlayerVelocityPacketProcessor.java b/src/main/java/WayofTime/bloodmagic/network/PlayerVelocityPacketProcessor.java index d2a1c13f..e9a6f608 100644 --- a/src/main/java/WayofTime/bloodmagic/network/PlayerVelocityPacketProcessor.java +++ b/src/main/java/WayofTime/bloodmagic/network/PlayerVelocityPacketProcessor.java @@ -59,7 +59,7 @@ public class PlayerVelocityPacketProcessor implements IMessage, IMessageHandler< @SideOnly(Side.CLIENT) public void onMessageFromServer() { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; + EntityPlayer player = Minecraft.getMinecraft().player; player.motionX = motionX; player.motionY = motionY; player.motionZ = motionZ; diff --git a/src/main/java/WayofTime/bloodmagic/potion/BMPotionUtils.java b/src/main/java/WayofTime/bloodmagic/potion/BMPotionUtils.java index 1296ed4b..4306fdfa 100644 --- a/src/main/java/WayofTime/bloodmagic/potion/BMPotionUtils.java +++ b/src/main/java/WayofTime/bloodmagic/potion/BMPotionUtils.java @@ -30,7 +30,7 @@ public class BMPotionUtils public static double damageMobAndGrowSurroundingPlants(EntityLivingBase entity, int horizontalRadius, int verticalRadius, double damageRatio, int maxPlantsGrown) { - World world = entity.worldObj; + World world = entity.getEntityWorld(); if (world.isRemote) { return 0; diff --git a/src/main/java/WayofTime/bloodmagic/potion/PotionEventHandlers.java b/src/main/java/WayofTime/bloodmagic/potion/PotionEventHandlers.java index 58813ea4..081d1a87 100644 --- a/src/main/java/WayofTime/bloodmagic/potion/PotionEventHandlers.java +++ b/src/main/java/WayofTime/bloodmagic/potion/PotionEventHandlers.java @@ -59,12 +59,10 @@ public class PotionEventHandlers { int d0 = 3; AxisAlignedBB axisAlignedBB = new AxisAlignedBB(event.getEntityLiving().posX - 0.5, event.getEntityLiving().posY - 0.5, event.getEntityLiving().posZ - 0.5, event.getEntityLiving().posX + 0.5, event.getEntityLiving().posY + 0.5, event.getEntityLiving().posZ + 0.5).expand(d0, d0, d0); - List entityList = event.getEntityLiving().worldObj.getEntitiesWithinAABB(Entity.class, axisAlignedBB); + List entityList = event.getEntityLiving().getEntityWorld().getEntitiesWithinAABB(Entity.class, axisAlignedBB); - for (Object thing : entityList) + for (Entity projectile : entityList) { - Entity projectile = (Entity) thing; - if (projectile == null) continue; if (!(projectile instanceof IProjectile)) diff --git a/src/main/java/WayofTime/bloodmagic/potion/item/ItemPotionFlask.java b/src/main/java/WayofTime/bloodmagic/potion/item/ItemPotionFlask.java index d96ae079..05fc2117 100644 --- a/src/main/java/WayofTime/bloodmagic/potion/item/ItemPotionFlask.java +++ b/src/main/java/WayofTime/bloodmagic/potion/item/ItemPotionFlask.java @@ -76,8 +76,9 @@ public class ItemPotionFlask extends Item implements IVariantProvider } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); int remainingUses = stack.getMaxDamage() - stack.getItemDamage(); if (remainingUses <= 0) { diff --git a/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTableDyeableRecipe.java b/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTableDyeableRecipe.java index 465ecef2..d94d13bd 100644 --- a/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTableDyeableRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTableDyeableRecipe.java @@ -51,13 +51,11 @@ public class AlchemyTableDyeableRecipe extends AlchemyTableRecipe if (match) { inputItemLocation = x; - continue; } else { if (slot.getItem() == Items.NAME_TAG || slot.getItem() == Items.DYE) { nameTagOrDyeLocation = x; - continue; } } } @@ -108,30 +106,19 @@ public class AlchemyTableDyeableRecipe extends AlchemyTableRecipe boolean hasNameTagOrDye = false; boolean hasInputItem = false; - for (int x = 0; x < checkedList.size(); x++) - { - ItemStack slot = checkedList.get(x); - - if (slot != null) - { + for (ItemStack slot : checkedList) { + if (slot != null) { boolean match = OreDictionary.itemMatches(inputItem, slot, false); - if (match && hasInputItem) - { + if (match && hasInputItem) { return false; - } else if (match) - { + } else if (match) { hasInputItem = true; - continue; - } else - { - if (slot.getItem() == Items.NAME_TAG || slot.getItem() == Items.DYE) - { - if (hasNameTagOrDye) - { + } else { + if (slot.getItem() == Items.NAME_TAG || slot.getItem() == Items.DYE) { + if (hasNameTagOrDye) { return false; - } else - { + } else { hasNameTagOrDye = true; } } diff --git a/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTablePotionAugmentRecipe.java b/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTablePotionAugmentRecipe.java index 4769bcc9..f10586cb 100644 --- a/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTablePotionAugmentRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTablePotionAugmentRecipe.java @@ -1,9 +1,6 @@ package WayofTime.bloodmagic.recipe.alchemyTable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; +import java.util.*; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; @@ -38,7 +35,7 @@ public class AlchemyTablePotionAugmentRecipe extends AlchemyTablePotionRecipe public AlchemyTablePotionAugmentRecipe(int lpDrained, int ticksRequired, int tierRequired, ItemStack inputItem, PotionEffect baseEffect, double lengthAugment, int powerAugment) { - this(lpDrained, ticksRequired, tierRequired, Arrays.asList(inputItem), baseEffect, lengthAugment, powerAugment); + this(lpDrained, ticksRequired, tierRequired, Collections.singletonList(inputItem), baseEffect, lengthAugment, powerAugment); } @Override @@ -79,19 +76,14 @@ public class AlchemyTablePotionAugmentRecipe extends AlchemyTablePotionRecipe List effectList = PotionUtils.getEffectsFromStack(outputStack); List newEffectList = new ArrayList(); - Iterator effectIterator = effectList.iterator(); - while (effectIterator.hasNext()) - { - PotionEffect effect = effectIterator.next(); - if (effect.getPotion() == wantedPotion) - { + for (PotionEffect effect : effectList) { + if (effect.getPotion() == wantedPotion) { double currentLengthAugment = Math.max(lengthAugment, BMPotionUtils.getLengthAugment(outputStack, wantedPotion)); int currentPowerAugment = Math.max(powerAugment, effect.getAmplifier()); int potionLength = wantedPotion.isInstant() ? 1 : BMPotionUtils.getAugmentedLength(baseEffect.getDuration(), currentLengthAugment, currentPowerAugment); newEffectList.add(new PotionEffect(wantedPotion, potionLength, currentPowerAugment)); BMPotionUtils.setLengthAugment(outputStack, wantedPotion, currentLengthAugment); - } else - { + } else { newEffectList.add(effect); } } diff --git a/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTablePotionRecipe.java b/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTablePotionRecipe.java index 48d9c4bf..23e24887 100644 --- a/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTablePotionRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTablePotionRecipe.java @@ -1,9 +1,6 @@ package WayofTime.bloodmagic.recipe.alchemyTable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; +import java.util.*; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; @@ -40,7 +37,7 @@ public class AlchemyTablePotionRecipe extends AlchemyTableRecipe public AlchemyTablePotionRecipe(int lpDrained, int ticksRequired, int tierRequired, ItemStack inputItem, PotionEffect baseEffect) { - this(lpDrained, ticksRequired, tierRequired, Arrays.asList(inputItem), baseEffect); + this(lpDrained, ticksRequired, tierRequired, Collections.singletonList(inputItem), baseEffect); } @Override @@ -58,7 +55,6 @@ public class AlchemyTablePotionRecipe extends AlchemyTableRecipe if (match) { flaskLocation = x; - continue; } } } @@ -68,7 +64,7 @@ public class AlchemyTablePotionRecipe extends AlchemyTableRecipe return getModifiedFlaskForInput(inputList.get(flaskLocation)); } - return getModifiedFlaskForInput(null); + return getModifiedFlaskForInput(ItemStack.EMPTY); } @Override @@ -76,39 +72,27 @@ public class AlchemyTablePotionRecipe extends AlchemyTableRecipe { ArrayList required = new ArrayList(input); - for (int x = 0; x < checkedList.size(); x++) - { - ItemStack slot = checkedList.get(x); - - if (slot != null) - { + for (ItemStack slot : checkedList) { + if (slot != null) { boolean inRecipe = false; - Iterator req = required.iterator(); - while (req.hasNext()) - { + for (Object aRequired : required) { boolean match = false; - Object next = req.next(); + Object next = aRequired; - if (next instanceof ItemStack) - { + if (next instanceof ItemStack) { match = OreDictionary.itemMatches((ItemStack) next, slot, false); - } else if (next instanceof List) - { + } else if (next instanceof List) { Iterator itr = ((List) next).iterator(); - while (itr.hasNext() && !match) - { + while (itr.hasNext() && !match) { match = OreDictionary.itemMatches(itr.next(), slot, false); } } - if (match) - { - if (next instanceof ItemStack && ((ItemStack) next).getItem() == ModItems.POTION_FLASK) - { - if (!isPotionFlaskValidInput(slot)) - { + if (match) { + if (next instanceof ItemStack && ((ItemStack) next).getItem() == ModItems.POTION_FLASK) { + if (!isPotionFlaskValidInput(slot)) { break; } } @@ -119,8 +103,7 @@ public class AlchemyTablePotionRecipe extends AlchemyTableRecipe } } - if (!inRecipe) - { + if (!inRecipe) { return false; } } @@ -150,7 +133,7 @@ public class AlchemyTablePotionRecipe extends AlchemyTableRecipe public ItemStack getModifiedFlaskForInput(ItemStack inputStack) { - if (inputStack == null) + if (inputStack.isEmpty()) { ItemStack outputStack = new ItemStack(ModItems.POTION_FLASK); diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModCompatibility.java b/src/main/java/WayofTime/bloodmagic/registry/ModCompatibility.java index fdf91ba5..5496ba23 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModCompatibility.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModCompatibility.java @@ -1,7 +1,6 @@ package WayofTime.bloodmagic.registry; import WayofTime.bloodmagic.compat.ICompatibility; -import WayofTime.bloodmagic.compat.guideapi.CompatibilityGuideAPI; import WayofTime.bloodmagic.compat.jei.CompatibilityJustEnoughItems; import WayofTime.bloodmagic.compat.waila.CompatibilityWaila; import net.minecraftforge.fml.common.Loader; @@ -16,7 +15,6 @@ public class ModCompatibility { compatibilities.add(new CompatibilityJustEnoughItems()); compatibilities.add(new CompatibilityWaila()); - compatibilities.add(new CompatibilityGuideAPI()); // compatibilities.add(new CompatibilityThaumcraft()); } diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModEntities.java b/src/main/java/WayofTime/bloodmagic/registry/ModEntities.java index 0fce4e69..b7ff118d 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModEntities.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModEntities.java @@ -1,7 +1,6 @@ package WayofTime.bloodmagic.registry; -import net.minecraftforge.fml.common.registry.EntityRegistry; -import WayofTime.bloodmagic.BloodMagic; +import net.minecraftforge.fml.common.registry.EntityEntry; import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken; import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; import WayofTime.bloodmagic.entity.mob.EntityCorruptedSpider; @@ -12,22 +11,21 @@ import WayofTime.bloodmagic.entity.projectile.EntityBloodLight; import WayofTime.bloodmagic.entity.projectile.EntityMeteor; import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow; import WayofTime.bloodmagic.entity.projectile.EntitySoulSnare; +import net.minecraftforge.fml.common.registry.GameRegistry; public class ModEntities { public static void init() { - int id = 0; - - EntityRegistry.registerModEntity(EntityBloodLight.class, "BloodLight", id++, BloodMagic.instance, 64, 20, true); - EntityRegistry.registerModEntity(EntitySoulSnare.class, "SoulSnare", id++, BloodMagic.instance, 64, 1, true); - EntityRegistry.registerModEntity(EntitySentientArrow.class, "SoulArrow", id++, BloodMagic.instance, 64, 1, true); - EntityRegistry.registerModEntity(EntityMeteor.class, "Meteor", id++, BloodMagic.instance, 64, 1, true); - EntityRegistry.registerModEntity(EntitySentientSpecter.class, "SentientSpecter", id++, BloodMagic.instance, 64, 1, true); - EntityRegistry.registerModEntity(EntityMimic.class, "Mimic", id++, BloodMagic.instance, 64, 1, true); - EntityRegistry.registerModEntity(EntityCorruptedZombie.class, "CorruptedZombie", id++, BloodMagic.instance, 64, 1, true); - EntityRegistry.registerModEntity(EntityCorruptedSheep.class, "CorruptedSheep", id++, BloodMagic.instance, 64, 1, true); - EntityRegistry.registerModEntity(EntityCorruptedChicken.class, "CorruptedChicken", id++, BloodMagic.instance, 64, 1, true); - EntityRegistry.registerModEntity(EntityCorruptedSpider.class, "CorruptedSpider", id++, BloodMagic.instance, 64, 1, true); + GameRegistry.register(new EntityEntry(EntityBloodLight.class, "BloodLight").setRegistryName("BloodLight")); + GameRegistry.register(new EntityEntry(EntitySoulSnare.class, "SoulSnare").setRegistryName("SoulSnare")); + GameRegistry.register(new EntityEntry(EntitySentientArrow.class, "SoulArrow").setRegistryName("SoulArrow")); + GameRegistry.register(new EntityEntry(EntityMeteor.class, "Meteor").setRegistryName("Meteor")); + GameRegistry.register(new EntityEntry(EntitySentientSpecter.class, "SentientSpecter").setRegistryName("SentientSpecter")); + GameRegistry.register(new EntityEntry(EntityMimic.class, "Mimic").setRegistryName("Mimic")); + GameRegistry.register(new EntityEntry(EntityCorruptedZombie.class, "CorruptedZombie").setRegistryName("CorruptedZombie")); + GameRegistry.register(new EntityEntry(EntityCorruptedSheep.class, "CorruptedSheep").setRegistryName("CorruptedSheep")); + GameRegistry.register(new EntityEntry(EntityCorruptedChicken.class, "CorruptedChicken").setRegistryName("CorruptedChicken")); + GameRegistry.register(new EntityEntry(EntityCorruptedSpider.class, "CorruptedSpider").setRegistryName("CorruptedSpider")); } } diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java b/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java index 7226d51e..82a41b2e 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java @@ -456,7 +456,7 @@ public class ModRecipes if (dustList != null && dustList.size() > 0) { ItemStack dustStack = dustList.get(0).copy(); - dustStack.stackSize = 2; + dustStack.setCount(2); AlchemyTableRecipeRegistry.registerRecipe(new AlchemyTableCustomRecipe(dustStack, 400, 200, 1, ore, ItemCuttingFluid.getStack(ItemCuttingFluid.BASIC))); addedOreRecipeList.add(ore); } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualAltarBuilder.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualAltarBuilder.java index 6a093244..90a5e8a1 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualAltarBuilder.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualAltarBuilder.java @@ -203,16 +203,16 @@ public class RitualAltarBuilder extends Ritual { if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) { - IItemHandler iItemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN); + IItemHandler itemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN); - if (iItemHandler.getSlots() <= 0) + if (itemHandler.getSlots() <= 0) { return false; } - for (int i = 0; i < iItemHandler.getSlots(); i++) + for (int i = 0; i < itemHandler.getSlots(); i++) { - if (iItemHandler.getStackInSlot(i) != null && iItemHandler.getStackInSlot(i).stackSize > 0 && iItemHandler.getStackInSlot(i).getItem() == item && iItemHandler.getStackInSlot(i).getItemDamage() == damage && iItemHandler.extractItem(i, 1, !consumeItem) != null) + if (!itemHandler.getStackInSlot(i).isEmpty() && itemHandler.getStackInSlot(i).getItem() == item && itemHandler.getStackInSlot(i).getItemDamage() == damage && !itemHandler.extractItem(i, 1, !consumeItem).isEmpty()) { return true; } @@ -222,7 +222,7 @@ public class RitualAltarBuilder extends Ritual IInventory inv = (IInventory) tileEntity; for (int i = 0; i < inv.getSizeInventory(); i++) { - if (inv.getStackInSlot(i) != null && inv.getStackInSlot(i).stackSize > 0 && inv.getStackInSlot(i).getItem() == item && inv.getStackInSlot(i).getItemDamage() == damage) + if (!inv.getStackInSlot(0).isEmpty() && inv.getStackInSlot(i).getItem() == item && inv.getStackInSlot(i).getItemDamage() == damage) { if (consumeItem) { @@ -242,19 +242,19 @@ public class RitualAltarBuilder extends Ritual { if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) { - IItemHandler iItemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN); + IItemHandler itemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN); - if (iItemHandler.getSlots() <= 0) + if (itemHandler.getSlots() <= 0) { return null; } - for (int i = 0; i < iItemHandler.getSlots(); i++) + for (int i = 0; i < itemHandler.getSlots(); i++) { - if (iItemHandler.getStackInSlot(i) != null && iItemHandler.getStackInSlot(i).stackSize > 0 && iItemHandler.getStackInSlot(i).getItem() instanceof ItemBlock && Block.getBlockFromItem(iItemHandler.getStackInSlot(i).getItem()) instanceof BlockBloodRune && iItemHandler.extractItem(i, 1, true) != null) + if (!itemHandler.getStackInSlot(i).isEmpty() && itemHandler.getStackInSlot(i).getItem() instanceof ItemBlock && Block.getBlockFromItem(itemHandler.getStackInSlot(i).getItem()) instanceof BlockBloodRune && itemHandler.extractItem(i, 1, true) != null) { - BlockStack blockStack = new BlockStack(Utils.getBlockForComponent(EnumAltarComponent.BLOODRUNE), iItemHandler.getStackInSlot(i).getItemDamage()); - iItemHandler.extractItem(i, 1, false); + BlockStack blockStack = new BlockStack(Utils.getBlockForComponent(EnumAltarComponent.BLOODRUNE), itemHandler.getStackInSlot(i).getItemDamage()); + itemHandler.extractItem(i, 1, false); return blockStack; } } @@ -263,7 +263,7 @@ public class RitualAltarBuilder extends Ritual IInventory inv = (IInventory) tileEntity; for (int i = 0; i < inv.getSizeInventory(); i++) { - if (inv.getStackInSlot(i) != null && inv.getStackInSlot(i).stackSize > 0 && inv.getStackInSlot(i).getItem() instanceof ItemBlock && Block.getBlockFromItem(inv.getStackInSlot(i).getItem()) instanceof BlockBloodRune) + if (!inv.getStackInSlot(i).isEmpty() && inv.getStackInSlot(i).getItem() instanceof ItemBlock && Block.getBlockFromItem(inv.getStackInSlot(i).getItem()) instanceof BlockBloodRune) { BlockStack blockStack = new BlockStack(Utils.getBlockForComponent(EnumAltarComponent.BLOODRUNE), inv.getStackInSlot(i).getItemDamage()); inv.decrStackSize(i, 1); @@ -281,22 +281,22 @@ public class RitualAltarBuilder extends Ritual { if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) { - IItemHandler iItemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN); + IItemHandler itemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN); - if (iItemHandler.getSlots() <= 0) + if (itemHandler.getSlots() <= 0) { return null; } - for (int i = 0; i < iItemHandler.getSlots(); i++) + for (int i = 0; i < itemHandler.getSlots(); i++) { - if (iItemHandler.getStackInSlot(i) != null && iItemHandler.getStackInSlot(i).stackSize > 0 && iItemHandler.getStackInSlot(i).getItem() instanceof ItemBlock && !(Block.getBlockFromItem(iItemHandler.getStackInSlot(i).getItem()) instanceof BlockBloodRune) && iItemHandler.extractItem(i, 1, true) != null) + if (!itemHandler.getStackInSlot(i).isEmpty() && itemHandler.getStackInSlot(i).getItem() instanceof ItemBlock && !(Block.getBlockFromItem(itemHandler.getStackInSlot(i).getItem()) instanceof BlockBloodRune) && itemHandler.extractItem(i, 1, true) != null) { - Block block = Block.getBlockFromItem(iItemHandler.getStackInSlot(i).getItem()); + Block block = Block.getBlockFromItem(itemHandler.getStackInSlot(i).getItem()); if (block != null && block != Blocks.GLOWSTONE && block != ModBlocks.BLOOD_STONE && block != ModBlocks.CRYSTAL) { - BlockStack blockStack = new BlockStack(block, iItemHandler.getStackInSlot(i).getItemDamage()); - iItemHandler.extractItem(i, 1, false); + BlockStack blockStack = new BlockStack(block, itemHandler.getStackInSlot(i).getItemDamage()); + itemHandler.extractItem(i, 1, false); return blockStack; } } @@ -306,10 +306,10 @@ public class RitualAltarBuilder extends Ritual IInventory inv = (IInventory) tileEntity; for (int i = 0; i < inv.getSizeInventory(); i++) { - if (inv.getStackInSlot(i) != null && inv.getStackInSlot(i).stackSize > 0 && inv.getStackInSlot(i).getItem() instanceof ItemBlock && !(Block.getBlockFromItem(inv.getStackInSlot(i).getItem()) instanceof BlockBloodRune)) + if (!inv.getStackInSlot(i).isEmpty() && inv.getStackInSlot(i).getItem() instanceof ItemBlock && !(Block.getBlockFromItem(inv.getStackInSlot(i).getItem()) instanceof BlockBloodRune)) { Block block = Block.getBlockFromItem(inv.getStackInSlot(i).getItem()); - if (block != null && block != Blocks.GLOWSTONE && block != ModBlocks.BLOOD_STONE && block != ModBlocks.CRYSTAL) + if (block != Blocks.GLOWSTONE && block != ModBlocks.BLOOD_STONE && block != ModBlocks.CRYSTAL) { BlockStack blockStack = new BlockStack(block, inv.getStackInSlot(i).getItemDamage()); inv.decrStackSize(i, 1); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualAnimalGrowth.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualAnimalGrowth.java index 6b2728fd..7e7c7c19 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualAnimalGrowth.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualAnimalGrowth.java @@ -232,7 +232,14 @@ public class RitualAnimalGrowth extends Ritual @Override public ITextComponent[] provideInformationOfRitualToPlayer(EntityPlayer player) { - return new ITextComponent[] { new TextComponentTranslation(this.getUnlocalizedName() + ".info"), new TextComponentTranslation(this.getUnlocalizedName() + ".default.info"), new TextComponentTranslation(this.getUnlocalizedName() + ".corrosive.info"), new TextComponentTranslation(this.getUnlocalizedName() + ".steadfast.info"), new TextComponentTranslation(this.getUnlocalizedName() + ".destructive.info"), new TextComponentTranslation(this.getUnlocalizedName() + ".vengeful.info") }; + return new ITextComponent[] { + new TextComponentTranslation(this.getUnlocalizedName() + ".info"), + new TextComponentTranslation(this.getUnlocalizedName() + ".default.info"), + new TextComponentTranslation(this.getUnlocalizedName() + ".corrosive.info"), + new TextComponentTranslation(this.getUnlocalizedName() + ".steadfast.info"), + new TextComponentTranslation(this.getUnlocalizedName() + ".destructive.info"), + new TextComponentTranslation(this.getUnlocalizedName() + ".vengeful.info") + }; } public int getBreedingDecreaseForWill(double vengefulWill) diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualArmourEvolve.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualArmourEvolve.java index 2fb686f9..caff98f0 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualArmourEvolve.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualArmourEvolve.java @@ -55,7 +55,7 @@ public class RitualArmourEvolve extends Ritual masterRitualStone.setActive(false); - world.spawnEntityInWorld(new EntityLightningBolt(world, pos.getX(), pos.getY() - 1, pos.getZ(), true)); + world.spawnEntity(new EntityLightningBolt(world, pos.getX(), pos.getY() - 1, pos.getZ(), true)); } } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualCobblestone.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualCobblestone.java index 3f8a2d0e..7756789a 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualCobblestone.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualCobblestone.java @@ -48,7 +48,7 @@ public class RitualCobblestone extends Ritual if (tileEntity != null && tileEntity instanceof TileAlchemyArray) { TileAlchemyArray alchemyArray = (TileAlchemyArray) tileEntity; - if (alchemyArray.getStackInSlot(0) != null && alchemyArray.getStackInSlot(0).getItem() instanceof ItemComponent) + if (!alchemyArray.getStackInSlot(0).isEmpty() && alchemyArray.getStackInSlot(0).getItem() instanceof ItemComponent) { switch (alchemyArray.getStackInSlot(0).getItemDamage()) { diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualCrushing.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualCrushing.java index c88dd481..3c11f58c 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualCrushing.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualCrushing.java @@ -129,7 +129,7 @@ public class RitualCrushing extends Ritual if (useCuttingFluid) { ItemStack checkStack = block.getItem(world, newPos, state); - if (checkStack == null) + if (checkStack.isEmpty()) { continue; } @@ -159,7 +159,7 @@ public class RitualCrushing extends Ritual } ItemStack result = recipe.getRecipeOutput(input); - if (result == null) + if (result.isEmpty()) { continue; } @@ -167,7 +167,7 @@ public class RitualCrushing extends Ritual if (tile != null) { result = Utils.insertStackIntoTile(result, tile, EnumFacing.DOWN); - if (result != null && result.stackSize > 0) + if (!result.isEmpty()) { Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, result); } @@ -189,7 +189,7 @@ public class RitualCrushing extends Ritual if (!isBlockClaimed && isSilkTouch && block.canSilkHarvest(world, newPos, state, null)) { ItemStack checkStack = block.getItem(world, newPos, state); - if (checkStack == null) + if (checkStack.isEmpty()) { continue; } @@ -210,7 +210,7 @@ public class RitualCrushing extends Ritual else Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack); - if (copyStack != null && copyStack.stackSize > 0) + if (!copyStack.isEmpty()) { Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack); } @@ -223,31 +223,28 @@ public class RitualCrushing extends Ritual List stackList = block.getDrops(world, newPos, state, fortune); - if (stackList != null && !stackList.isEmpty()) + for (ItemStack item : stackList) { - for (ItemStack item : stackList) - { - ItemStack copyStack = ItemStack.copyItemStack(item); + ItemStack copyStack = item.copy(); - if (tile != null) - { - copyStack = Utils.insertStackIntoTile(copyStack, tile, EnumFacing.DOWN); - } else - { - Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack); - continue; - } - if (copyStack != null && copyStack.stackSize > 0) - { - Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack); - } - } - - if (fortune > 0) + if (tile != null) { - WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DESTRUCTIVE, destructiveWillDrain, true); - destructiveWill -= destructiveWillDrain; + copyStack = Utils.insertStackIntoTile(copyStack, tile, EnumFacing.DOWN); + } else + { + Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack); + continue; } + if (!copyStack.isEmpty()) + { + Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack); + } + } + + if (fortune > 0) + { + WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DESTRUCTIVE, destructiveWillDrain, true); + destructiveWill -= destructiveWillDrain; } } @@ -323,7 +320,14 @@ public class RitualCrushing extends Ritual @Override public ITextComponent[] provideInformationOfRitualToPlayer(EntityPlayer player) { - return new ITextComponent[] { new TextComponentTranslation(this.getUnlocalizedName() + ".info"), new TextComponentTranslation(this.getUnlocalizedName() + ".default.info"), new TextComponentTranslation(this.getUnlocalizedName() + ".corrosive.info"), new TextComponentTranslation(this.getUnlocalizedName() + ".steadfast.info"), new TextComponentTranslation(this.getUnlocalizedName() + ".destructive.info"), new TextComponentTranslation(this.getUnlocalizedName() + ".vengeful.info") }; + return new ITextComponent[] { + new TextComponentTranslation(this.getUnlocalizedName() + ".info"), + new TextComponentTranslation(this.getUnlocalizedName() + ".default.info"), + new TextComponentTranslation(this.getUnlocalizedName() + ".corrosive.info"), + new TextComponentTranslation(this.getUnlocalizedName() + ".steadfast.info"), + new TextComponentTranslation(this.getUnlocalizedName() + ".destructive.info"), + new TextComponentTranslation(this.getUnlocalizedName() + ".vengeful.info") + }; } @Override diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualExpulsion.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualExpulsion.java index 694cc40a..ed43dd81 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualExpulsion.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualExpulsion.java @@ -136,20 +136,20 @@ public class RitualExpulsion extends Ritual moveEntityViaTeleport(entityLiving, event.getTargetX(), event.getTargetY(), event.getTargetZ()); 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 i = MathHelper.floor(entityLiving.posX); + int j = MathHelper.floor(entityLiving.posY); + int k = MathHelper.floor(entityLiving.posZ); int l; - if (!entityLiving.worldObj.isAirBlock(new BlockPos(i, j, k))) + if (!entityLiving.getEntityWorld().isAirBlock(new BlockPos(i, j, k))) { boolean flag1 = false; while (!flag1 && j > 0) { - IBlockState state = entityLiving.worldObj.getBlockState(new BlockPos(i, j - 1, k)); + IBlockState state = entityLiving.getEntityWorld().getBlockState(new BlockPos(i, j - 1, k)); - if (state != null && state.getMaterial().blocksMovement()) + if (state.getMaterial().blocksMovement()) { flag1 = true; } else @@ -163,7 +163,7 @@ public class RitualExpulsion extends Ritual { moveEntityViaTeleport(entityLiving, entityLiving.posX, entityLiving.posY, entityLiving.posZ); - if (!entityLiving.isCollided && !entityLiving.worldObj.containsAnyLiquid(entityLiving.getEntityBoundingBox())) + if (!entityLiving.isCollided && !entityLiving.getEntityWorld().containsAnyLiquid(entityLiving.getEntityBoundingBox())) { flag = true; } @@ -179,13 +179,13 @@ public class RitualExpulsion extends Ritual for (l = 0; l < 128; ++l) { double lengthVal = (double) l / ((double) 128 - 1.0D); - float randF1 = (entityLiving.worldObj.rand.nextFloat() - 0.5F) * 0.2F; - float randF2 = (entityLiving.worldObj.rand.nextFloat() - 0.5F) * 0.2F; - float randF3 = (entityLiving.worldObj.rand.nextFloat() - 0.5F) * 0.2F; - double lengthValX = lastX + (entityLiving.posX - lastX) * lengthVal + (entityLiving.worldObj.rand.nextDouble() - 0.5D) * (double) entityLiving.width * 2.0D; - double lengthValY = lastY + (entityLiving.posY - lastY) * lengthVal + entityLiving.worldObj.rand.nextDouble() * (double) entityLiving.height; - double lengthValZ = lastZ + (entityLiving.posZ - lastZ) * lengthVal + (entityLiving.worldObj.rand.nextDouble() - 0.5D) * (double) entityLiving.width * 2.0D; - entityLiving.worldObj.spawnParticle(EnumParticleTypes.PORTAL, lengthValX, lengthValY, lengthValZ, (double) randF1, (double) randF2, (double) randF3); + float randF1 = (entityLiving.getEntityWorld().rand.nextFloat() - 0.5F) * 0.2F; + float randF2 = (entityLiving.getEntityWorld().rand.nextFloat() - 0.5F) * 0.2F; + float randF3 = (entityLiving.getEntityWorld().rand.nextFloat() - 0.5F) * 0.2F; + double lengthValX = lastX + (entityLiving.posX - lastX) * lengthVal + (entityLiving.getEntityWorld().rand.nextDouble() - 0.5D) * (double) entityLiving.width * 2.0D; + double lengthValY = lastY + (entityLiving.posY - lastY) * lengthVal + entityLiving.getEntityWorld().rand.nextDouble() * (double) entityLiving.height; + double lengthValZ = lastZ + (entityLiving.posZ - lastZ) * lengthVal + (entityLiving.getEntityWorld().rand.nextDouble() - 0.5D) * (double) entityLiving.width * 2.0D; + entityLiving.getEntityWorld().spawnParticle(EnumParticleTypes.PORTAL, lengthValX, lengthValY, lengthValZ, (double) randF1, (double) randF2, (double) randF3); } return true; @@ -200,7 +200,7 @@ public class RitualExpulsion extends Ritual { EntityPlayerMP entityplayermp = (EntityPlayerMP) entityLiving; - if (entityplayermp.worldObj == entityLiving.worldObj) + if (entityplayermp.getEntityWorld() == entityLiving.getEntityWorld()) { EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, x, y, z, 5.0F); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualFeatheredKnife.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualFeatheredKnife.java index 20097edd..8a1ef785 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualFeatheredKnife.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualFeatheredKnife.java @@ -138,7 +138,7 @@ public class RitualFeatheredKnife extends Ritual float sacrificedHealth = 1; double lpModifier = 1; - if ((health / player.getMaxHealth() > healthThreshold) && ((useIncense && !player.isPotionActive(ModPotions.soulFray)) || !useIncense)) + if ((health / player.getMaxHealth() > healthThreshold) && (!useIncense || !player.isPotionActive(ModPotions.soulFray))) { if (useIncense) { diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualFelling.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualFelling.java index e235c7ba..9ee51f61 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualFelling.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualFelling.java @@ -114,17 +114,17 @@ public class RitualFelling extends Ritual private void placeInInventory(IBlockState blockState, World world, BlockPos blockPos, BlockPos tileEntityPos) { TileEntity tile = world.getTileEntity(tileEntityPos); - if (tile != null && blockState.getBlock().getDrops(world, blockPos, world.getBlockState(blockPos), 0) != null) + if (tile != null) { if (tile instanceof IInventory) { for (ItemStack stack : blockState.getBlock().getDrops(world, blockPos, world.getBlockState(blockPos), 0)) { ItemStack copyStack = stack.copy(); - Utils.insertStackIntoInventory(copyStack, (IInventory) tile, EnumFacing.DOWN); - if (copyStack.stackSize > 0) + Utils.insertStackIntoTile(copyStack, tile, EnumFacing.DOWN); + if (!copyStack.isEmpty()) { - world.spawnEntityInWorld(new EntityItem(world, blockPos.getX() + 0.4, blockPos.getY() + 2, blockPos.getZ() + 0.4, copyStack)); + world.spawnEntity(new EntityItem(world, blockPos.getX() + 0.4, blockPos.getY() + 2, blockPos.getZ() + 0.4, copyStack)); } } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualForsakenSoul.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualForsakenSoul.java index 0659e5d4..7ac7ad56 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualForsakenSoul.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualForsakenSoul.java @@ -123,7 +123,7 @@ public class RitualForsakenSoul extends Ritual { if (entity.isEntityAlive() && !(entity instanceof EntityPlayer)) { - if (entity.attackEntityFrom(DamageSource.outOfWorld, 1)) + if (entity.attackEntityFrom(DamageSource.OUT_OF_WORLD, 1)) { if (!entity.isEntityAlive()) { diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualFullStomach.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualFullStomach.java index 19c80230..2a811bcd 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualFullStomach.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualFullStomach.java @@ -67,7 +67,7 @@ public class RitualFullStomach extends Ritual for (int i = lastSlot; i < inventory.getSizeInventory(); i++) { ItemStack stack = inventory.getStackInSlot(i); - if (stack != null && stack.getItem() instanceof ItemFood) + if (!stack.isEmpty() && stack.getItem() instanceof ItemFood) { ItemFood foodItem = (ItemFood) stack.getItem(); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualJumping.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualJumping.java index f5e2e7b4..e2f1c1ec 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualJumping.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualJumping.java @@ -42,30 +42,27 @@ public class RitualJumping extends Ritual AreaDescriptor jumpRange = getBlockRange(JUMP_RANGE); List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, jumpRange.getAABB(masterRitualStone.getBlockPos())); - if (entities != null) + for (EntityLivingBase entity : entities) { - for (EntityLivingBase entity : entities) + if (totalEffects >= maxEffects) { - if (totalEffects >= maxEffects) - { - break; - } + break; + } - double motionY = 1.5; + double motionY = 1.5; - entity.fallDistance = 0; - if (entity.isSneaking()) - { - continue; - } + entity.fallDistance = 0; + if (entity.isSneaking()) + { + continue; + } - entity.motionY = motionY; - totalEffects++; + entity.motionY = motionY; + totalEffects++; - if (entity instanceof EntityPlayer) - { - Utils.setPlayerSpeedFromServer((EntityPlayer) entity, entity.motionX, entity.motionY, entity.motionZ); - } + if (entity instanceof EntityPlayer) + { + Utils.setPlayerSpeedFromServer((EntityPlayer) entity, entity.motionX, entity.motionY, entity.motionZ); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualMagnetic.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualMagnetic.java index 9f4ee548..ddf403dc 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualMagnetic.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualMagnetic.java @@ -9,6 +9,7 @@ import net.minecraft.block.BlockOre; import net.minecraft.block.BlockRedstoneOre; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -50,7 +51,7 @@ public class RitualMagnetic extends Ritual if (block instanceof BlockOre || block instanceof BlockRedstoneOre) return true; - if (Item.getItemFromBlock(block) == null) + if (Item.getItemFromBlock(block) == Items.AIR) return false; BlockStack type = new BlockStack(block, meta); @@ -71,7 +72,7 @@ public class RitualMagnetic extends Ritual public static boolean isBlockOre(ItemStack stack) { - if (stack == null) + if (stack.isEmpty()) { return false; } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualMeteor.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualMeteor.java index 1ef24b08..cc690201 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualMeteor.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualMeteor.java @@ -65,7 +65,7 @@ public class RitualMeteor extends Ritual { EntityMeteor meteor = new EntityMeteor(world, pos.getX(), 260, pos.getZ(), 0, -0.1, 0, radiusModifier, explosionModifier, fillerChance); meteor.setMeteorStack(stack.copy()); - world.spawnEntityInWorld(meteor); + world.spawnEntity(meteor); entityItem.setDead(); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualPlacer.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualPlacer.java index f373eb83..fdc32722 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualPlacer.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualPlacer.java @@ -49,32 +49,32 @@ public class RitualPlacer extends Ritual } AreaDescriptor areaDescriptor = getBlockRange(PLACER_RANGE); - IInventory iInventory; + IInventory inventory; if (tileEntity != null) { // Using the new Forge inventory system if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) { - IItemHandler iItemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN); + IItemHandler itemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN); - if (iItemHandler.getSlots() <= 0) + if (itemHandler.getSlots() <= 0) { return; } for (BlockPos blockPos : areaDescriptor.getContainedPositions(masterRitualStone.getBlockPos())) { - for (int inv = 0; inv < iItemHandler.getSlots(); inv++) + for (int inv = 0; inv < itemHandler.getSlots(); inv++) { - if (world.getBlockState(blockPos).getBlock().isReplaceable(world, blockPos) && iItemHandler.getStackInSlot(inv) != null && iItemHandler.getStackInSlot(inv).stackSize != 0) + if (world.getBlockState(blockPos).getBlock().isReplaceable(world, blockPos) && !itemHandler.getStackInSlot(inv).isEmpty()) { - if (iItemHandler.getStackInSlot(inv).getItem() instanceof ItemBlock && world.getBlockState(blockPos.down()) != null) + if (itemHandler.getStackInSlot(inv).getItem() instanceof ItemBlock && world.isAirBlock(blockPos.down())) { - if (iItemHandler.extractItem(inv, 1, true) != null) + if (!itemHandler.extractItem(inv, 1, true).isEmpty()) { - world.setBlockState(blockPos, Block.getBlockFromItem(iItemHandler.getStackInSlot(inv).getItem()).getStateFromMeta(iItemHandler.getStackInSlot(inv).getItemDamage())); - iItemHandler.extractItem(inv, 1, false); + world.setBlockState(blockPos, Block.getBlockFromItem(itemHandler.getStackInSlot(inv).getItem()).getStateFromMeta(itemHandler.getStackInSlot(inv).getItemDamage())); + itemHandler.extractItem(inv, 1, false); tileEntity.markDirty(); network.syphon(getRefreshCost()); } @@ -85,24 +85,24 @@ public class RitualPlacer extends Ritual //Compatibility with the old system, as it still exists } else if (tileEntity instanceof IInventory) { - iInventory = (IInventory) tileEntity; + inventory = (IInventory) tileEntity; - if (iInventory.getSizeInventory() <= 0) + if (inventory.getSizeInventory() <= 0) { return; } for (BlockPos blockPos : areaDescriptor.getContainedPositions(masterRitualStone.getBlockPos())) { - for (int inv = 0; inv < iInventory.getSizeInventory(); inv++) + for (int inv = 0; inv < inventory.getSizeInventory(); inv++) { - if (world.getBlockState(blockPos).getBlock().isReplaceable(world, blockPos) && iInventory.getStackInSlot(inv) != null && iInventory.getStackInSlot(inv).stackSize != 0) + if (world.getBlockState(blockPos).getBlock().isReplaceable(world, blockPos) && !inventory.getStackInSlot(inv).isEmpty()) { - if (iInventory.getStackInSlot(inv).getItem() instanceof ItemBlock && world.getBlockState(blockPos.down()) != null) + if (inventory.getStackInSlot(inv).getItem() instanceof ItemBlock && world.isAirBlock(blockPos.down())) { - world.setBlockState(blockPos, Block.getBlockFromItem(iInventory.getStackInSlot(inv).getItem()).getStateFromMeta(iInventory.getStackInSlot(inv).getItemDamage())); - iInventory.decrStackSize(inv, 1); - iInventory.markDirty(); + world.setBlockState(blockPos, Block.getBlockFromItem(inventory.getStackInSlot(inv).getItem()).getStateFromMeta(inventory.getStackInSlot(inv).getItemDamage())); + inventory.decrStackSize(inv, 1); + inventory.markDirty(); network.syphon(getRefreshCost()); break; } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualPortal.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualPortal.java index 586943ea..215e313a 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualPortal.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualPortal.java @@ -109,13 +109,10 @@ public class RitualPortal extends Ritual } } - if (LocationsHandler.getLocationsHandler() != null) + if (LocationsHandler.getLocationsHandler().addLocation(name, new PortalLocation(x, y + 1, z, world.provider.getDimension()))) { - if (LocationsHandler.getLocationsHandler().addLocation(name, new PortalLocation(x, y + 1, z, world.provider.getDimension()))) - { - portalRitualTag.setString(PORTAL_ID_TAG, name); - return true; - } + portalRitualTag.setString(PORTAL_ID_TAG, name); + return true; } } return false; @@ -191,10 +188,7 @@ public class RitualPortal extends Ritual int z = masterRitualStone.getBlockPos().getZ(); EnumFacing direction = masterRitualStone.getDirection(); - if (LocationsHandler.getLocationsHandler() != null) - { - LocationsHandler.getLocationsHandler().removeLocation(portalRitualTag.getString(PORTAL_ID_TAG), new PortalLocation(x, y + 1, z, world.provider.getDimension())); - } + LocationsHandler.getLocationsHandler().removeLocation(portalRitualTag.getString(PORTAL_ID_TAG), new PortalLocation(x, y + 1, z, world.provider.getDimension())); if (direction == EnumFacing.NORTH || direction == EnumFacing.SOUTH) { diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualPump.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualPump.java index 5111d5f9..2a7c9471 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualPump.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualPump.java @@ -11,7 +11,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidHandler; +import net.minecraftforge.fluids.capability.CapabilityFluidHandler; +import net.minecraftforge.fluids.capability.IFluidHandler; import java.util.ArrayList; import java.util.Iterator; @@ -49,14 +50,17 @@ public class RitualPump extends Ritual return; } - if (tileEntity != null && tileEntity instanceof IFluidHandler) + if (tileEntity != null && tileEntity.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN)) { - IFluidHandler fluidHandler = (IFluidHandler) tileEntity; + IFluidHandler fluidHandler = tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN); if (!cached || liquidsCache.isEmpty()) { - if (fluidHandler.drain(EnumFacing.DOWN, 1000, false) != null) + if (fluidHandler.drain(1000, false) != null) { - FluidStack fluidStack = fluidHandler.drain(EnumFacing.DOWN, 1000, false); + FluidStack fluidStack = fluidHandler.drain(1000, false); + if (fluidStack == null) + return; + for (BlockPos blockPos : getBlockRange(PUMP_RANGE).getContainedPositions(masterRitualStone.getBlockPos())) { if (!liquidsCache.contains(blockPos)) @@ -77,7 +81,7 @@ public class RitualPump extends Ritual { network.syphon(getRefreshCost()); currentPos = blockPosIterator.next(); - fluidHandler.fill(EnumFacing.DOWN, fluidHandler.drain(EnumFacing.DOWN, 1000, false), true); + fluidHandler.fill(fluidHandler.drain(1000, false), true); world.setBlockState(currentPos, Blocks.STONE.getDefaultState()); blockPosIterator.remove(); } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualUpgradeRemove.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualUpgradeRemove.java index c859c7f2..79dacbe7 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualUpgradeRemove.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualUpgradeRemove.java @@ -79,7 +79,7 @@ public class RitualUpgradeRemove extends Ritual if (successful) { removedUpgrade = true; - world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, upgradeStack)); + world.spawnEntity(new EntityItem(world, player.posX, player.posY, player.posZ, upgradeStack)); for (Entry trackerEntry : armour.trackerMap.entrySet()) { StatTracker tracker = trackerEntry.getValue(); @@ -102,7 +102,7 @@ public class RitualUpgradeRemove extends Ritual masterRitualStone.setActive(false); - world.spawnEntityInWorld(new EntityLightningBolt(world, pos.getX(), pos.getY() - 1, pos.getZ(), true)); + world.spawnEntity(new EntityLightningBolt(world, pos.getX(), pos.getY() - 1, pos.getZ(), true)); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualWellOfSuffering.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualWellOfSuffering.java index df2f176f..5f1fbb4f 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualWellOfSuffering.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualWellOfSuffering.java @@ -97,7 +97,7 @@ public class RitualWellOfSuffering extends Ritual if (entity.isEntityAlive() && !(entity instanceof EntityPlayer)) { - if (entity.attackEntityFrom(DamageSource.outOfWorld, 1)) + if (entity.attackEntityFrom(DamageSource.OUT_OF_WORLD, 1)) { String entityName = entity.getClass().getSimpleName(); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualZephyr.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualZephyr.java index 7f45574d..e8b2d377 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualZephyr.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualZephyr.java @@ -43,7 +43,6 @@ public class RitualZephyr extends Ritual BlockPos masterPos = masterRitualStone.getBlockPos(); AreaDescriptor chestRange = getBlockRange(CHEST_RANGE); TileEntity tileInventory = world.getTileEntity(chestRange.getContainedPositions(masterPos).get(0)); - if (!masterRitualStone.getWorldObj().isRemote && tileInventory != null) { if (currentEssence < getRefreshCost()) @@ -57,32 +56,29 @@ public class RitualZephyr extends Ritual List itemList = world.getEntitiesWithinAABB(EntityItem.class, zephyrRange.getAABB(masterRitualStone.getBlockPos())); int count = 0; - if (itemList != null) + for (EntityItem entityItem : itemList) { - for (EntityItem entityItem : itemList) + if (entityItem.isDead) { - if (entityItem.isDead) - { - continue; - } + continue; + } - ItemStack copyStack = entityItem.getEntityItem().copy(); - int originalAmount = copyStack.stackSize; - ItemStack newStack = Utils.insertStackIntoTile(copyStack, tileInventory, EnumFacing.DOWN); + ItemStack copyStack = entityItem.getEntityItem().copy(); + int originalAmount = copyStack.getCount(); + ItemStack newStack = Utils.insertStackIntoTile(copyStack, tileInventory, EnumFacing.DOWN); - if (newStack != null && newStack.stackSize < originalAmount) - { - count++; - if (newStack.stackSize <= 0) - entityItem.setDead(); - - entityItem.getEntityItem().stackSize = newStack.stackSize; - } - - if (newStack == null) - { + if (!newStack.isEmpty() && newStack.getCount() < originalAmount) + { + count++; + if (newStack.isEmpty()) entityItem.setDead(); - } + + entityItem.getEntityItem().setCount(newStack.getCount()); + } + + if (newStack.isEmpty()) + { + entityItem.setDead(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerPlantable.java b/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerPlantable.java index 74b5b1cd..ff8db2e9 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerPlantable.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerPlantable.java @@ -51,8 +51,8 @@ public class HarvestHandlerPlantable implements IHarvestHandler if (stack.getItem() instanceof IPlantable) { - if (stack.stackSize > 1) - stack.stackSize--; + if (stack.getCount() > 1) + stack.shrink(1); else drops.remove(stack); @@ -70,7 +70,7 @@ public class HarvestHandlerPlantable implements IHarvestHandler if (!world.isRemote) { EntityItem toDrop = new EntityItem(world, pos.getX(), pos.getY() + 0.5, pos.getZ(), stack); - world.spawnEntityInWorld(toDrop); + world.spawnEntity(toDrop); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerStem.java b/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerStem.java index 16984fd4..1d98a5f1 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerStem.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerStem.java @@ -61,7 +61,7 @@ public class HarvestHandlerStem implements IHarvestHandler for (ItemStack drop : drops) { EntityItem item = new EntityItem(world, cropPos.getX(), cropPos.getY() + 0.5, cropPos.getZ(), drop); - world.spawnEntityInWorld(item); + world.spawnEntity(item); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerTall.java b/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerTall.java index 8bcdecf8..4325a79b 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerTall.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerTall.java @@ -47,7 +47,7 @@ public class HarvestHandlerTall implements IHarvestHandler for (ItemStack drop : drops) { EntityItem item = new EntityItem(world, pos.getX(), pos.getY() + 0.5, pos.getZ(), drop); - world.spawnEntityInWorld(item); + world.spawnEntity(item); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java index 362fe1b8..75dfaf5d 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java @@ -28,7 +28,7 @@ public class ImperfectRitualZombie extends ImperfectRitual zombie.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 20000, 3)); if (!imperfectRitualStone.getRitualWorld().isRemote) - imperfectRitualStone.getRitualWorld().spawnEntityInWorld(zombie); + imperfectRitualStone.getRitualWorld().spawnEntity(zombie); return true; } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/portal/Teleports.java b/src/main/java/WayofTime/bloodmagic/ritual/portal/Teleports.java index e3c035d1..f15568ad 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/portal/Teleports.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/portal/Teleports.java @@ -54,7 +54,7 @@ public class Teleports return; if (teleposer) - if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.worldObj, entity.getPosition(), entity.worldObj, new BlockPos(x, y, z)))) + if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.getEntityWorld(), entity.getPosition(), entity.getEntityWorld(), new BlockPos(x, y, z)))) return; network.syphon(getTeleportCost()); @@ -62,13 +62,13 @@ public class Teleports EntityPlayerMP player = (EntityPlayerMP) entity; player.setPositionAndUpdate(x + 0.5, y + 0.5, z + 0.5); - player.worldObj.updateEntityWithOptionalForce(player, false); + player.getEntityWorld().updateEntityWithOptionalForce(player, false); player.connection.sendPacket(new SPacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel())); player.timeUntilPortal = 150; - player.worldObj.playSound(x, y, z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.AMBIENT, 1.0F, 1.0F, false); + player.getEntityWorld().playSound(x, y, z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.AMBIENT, 1.0F, 1.0F, false); if (teleposer) - MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent.Post(entity, entity.worldObj, entity.getPosition(), entity.worldObj, new BlockPos(x, y, z))); + MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent.Post(entity, entity.getEntityWorld(), entity.getPosition(), entity.getEntityWorld(), new BlockPos(x, y, z))); } else { SoulNetwork network = NetworkHelper.getSoulNetwork(networkToDrain); @@ -76,20 +76,20 @@ public class Teleports return; if (teleposer) - if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.worldObj, entity.getPosition(), entity.worldObj, new BlockPos(x, y, z)))) + if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.getEntityWorld(), entity.getPosition(), entity.getEntityWorld(), new BlockPos(x, y, z)))) return; network.syphon(getTeleportCost() / 10); - WorldServer world = (WorldServer) entity.worldObj; + WorldServer world = (WorldServer) entity.getEntityWorld(); entity.setPosition(x + 0.5, y + 0.5, z + 0.5); entity.timeUntilPortal = 150; world.resetUpdateEntityTick(); - entity.worldObj.playSound(x, y, z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.AMBIENT, 1.0F, 1.0F, false); + entity.getEntityWorld().playSound(x, y, z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.AMBIENT, 1.0F, 1.0F, false); if (teleposer) - MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent.Post(entity, entity.worldObj, entity.getPosition(), entity.worldObj, new BlockPos(x, y, z))); + MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent.Post(entity, entity.getEntityWorld(), entity.getPosition(), entity.getEntityWorld(), new BlockPos(x, y, z))); } } } @@ -137,14 +137,14 @@ public class Teleports { EntityPlayerMP player = (EntityPlayerMP) entity; - if (!player.worldObj.isRemote) + if (!player.getEntityWorld().isRemote) { SoulNetwork network = NetworkHelper.getSoulNetwork(networkToDrain); if (network.getCurrentEssence() < getTeleportCost()) return; if (teleposer) - if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.worldObj, entity.getPosition(), newWorldServer, new BlockPos(x, y, z)))) + if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.getEntityWorld(), entity.getPosition(), newWorldServer, new BlockPos(x, y, z)))) return; network.syphon(getTeleportCost()); @@ -152,20 +152,20 @@ public class Teleports player.changeDimension(newWorldID); //TODO: UNTESTED // server.getConfigurationManager().transferPlayerToDimension(player, newWorldID, new TeleporterBloodMagic(newWorldServer)); player.setPositionAndUpdate(x + 0.5, y + 0.5, z + 0.5); - player.worldObj.updateEntityWithOptionalForce(player, false); + player.getEntityWorld().updateEntityWithOptionalForce(player, false); player.connection.sendPacket(new SPacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel())); if (teleposer) - MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent.Post(entity, entity.worldObj, entity.getPosition(), newWorldServer, new BlockPos(x, y, z))); + MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent.Post(entity, entity.getEntityWorld(), entity.getPosition(), newWorldServer, new BlockPos(x, y, z))); } - } else if (!entity.worldObj.isRemote) + } else if (!entity.getEntityWorld().isRemote) { SoulNetwork network = NetworkHelper.getSoulNetwork(networkToDrain); if (network.getCurrentEssence() < (getTeleportCost() / 10)) return; if (teleposer) - if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.worldObj, entity.getPosition(), newWorldServer, new BlockPos(x, y, z)))) + if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.getEntityWorld(), entity.getPosition(), newWorldServer, new BlockPos(x, y, z)))) return; network.syphon(getTeleportCost() / 10); @@ -181,7 +181,7 @@ public class Teleports { teleportedEntity.setLocationAndAngles(x + 0.5, y + 0.5, z + 0.5, entity.rotationYaw, entity.rotationPitch); teleportedEntity.forceSpawn = true; - newWorldServer.spawnEntityInWorld(teleportedEntity); + newWorldServer.spawnEntity(teleportedEntity); teleportedEntity.setWorld(newWorldServer); teleportedEntity.timeUntilPortal = teleportedEntity instanceof EntityPlayer ? 150 : 20; } @@ -189,7 +189,7 @@ public class Teleports oldWorldServer.resetUpdateEntityTick(); newWorldServer.resetUpdateEntityTick(); if (teleposer) - MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent.Post(entity, entity.worldObj, entity.getPosition(), newWorldServer, new BlockPos(x, y, z))); + MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent.Post(entity, entity.getEntityWorld(), entity.getPosition(), newWorldServer, new BlockPos(x, y, z))); } entity.timeUntilPortal = entity instanceof EntityLiving ? 150 : 20; newWorldServer.playSound(x, y, z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.AMBIENT, 1.0F, 1.0F, false); diff --git a/src/main/java/WayofTime/bloodmagic/routing/DefaultItemFilter.java b/src/main/java/WayofTime/bloodmagic/routing/DefaultItemFilter.java index 5e220868..b436f7e6 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/DefaultItemFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/DefaultItemFilter.java @@ -27,12 +27,9 @@ public class DefaultItemFilter implements IItemFilter * * @param filteredList * - The list of ItemStacks that the filter is set to. - * @param inventory + * @param itemHandler * - The inventory that is being accessed. This inventory is either * being pulled from or pushed to. - * @param side - * - The side that the inventory is being accessed from. Used for - * pulling/pushing from/to the inventory. * @param isFilterOutput * - Tells the filter what actions to expect. If true, it should be * initialized as an output filter. If false, it should be @@ -59,7 +56,7 @@ public class DefaultItemFilter implements IItemFilter @Override public ItemStack transferStackThroughOutputFilter(ItemStack inputStack) { - int allowedAmount = inputStack.stackSize; //This is done to make the migration to a maximum amount transfered a lot easier + int allowedAmount = inputStack.getCount(); //This is done to make the migration to a maximum amount transfered a lot easier if (allowedAmount <= 0) { @@ -67,12 +64,12 @@ public class DefaultItemFilter implements IItemFilter } ItemStack testStack = inputStack.copy(); - testStack.stackSize = allowedAmount; + testStack.setCount(allowedAmount); ItemStack remainderStack = Utils.insertStackIntoTile(testStack, itemHandler); - int changeAmount = allowedAmount - (remainderStack == null ? 0 : remainderStack.stackSize); + int changeAmount = allowedAmount - (remainderStack.isEmpty() ? 0 : remainderStack.getCount()); testStack = inputStack.copy(); - testStack.stackSize -= changeAmount; + testStack.shrink(changeAmount); World world = accessedTile.getWorld(); BlockPos pos = accessedTile.getPos(); @@ -91,26 +88,24 @@ public class DefaultItemFilter implements IItemFilter for (int slot = 0; slot < itemHandler.getSlots(); slot++) { ItemStack inputStack = itemHandler.getStackInSlot(slot); - if (inputStack == null || itemHandler.extractItem(slot, inputStack.stackSize, true) == null)//(accessedInventory instanceof ISidedInventory && !((ISidedInventory) accessedInventory).canExtractItem(slot, inputStack, accessedSide))) + if (inputStack.isEmpty() || itemHandler.extractItem(slot, inputStack.getCount(), true).isEmpty())//(accessedInventory instanceof ISidedInventory && !((ISidedInventory) accessedInventory).canExtractItem(slot, inputStack, accessedSide))) { continue; } - int allowedAmount = Math.min(itemHandler.extractItem(slot, inputStack.stackSize, true).stackSize, maxTransfer); + int allowedAmount = Math.min(itemHandler.extractItem(slot, inputStack.getCount(), true).getCount(), maxTransfer); ItemStack testStack = inputStack.copy(); - testStack.stackSize = allowedAmount; + testStack.setCount(allowedAmount); ItemStack remainderStack = outputFilter.transferStackThroughOutputFilter(testStack); - int changeAmount = allowedAmount - (remainderStack == null ? 0 : remainderStack.stackSize); + int changeAmount = allowedAmount - (remainderStack.isEmpty() ? 0 : remainderStack.getCount()); - if (remainderStack != null && remainderStack.stackSize == allowedAmount) + if (!remainderStack.isEmpty() && remainderStack.getCount() == allowedAmount) { //Nothing has changed. Moving on! continue; } - maxTransfer -= changeAmount; - itemHandler.extractItem(slot, changeAmount, false); World world = accessedTile.getWorld(); diff --git a/src/main/java/WayofTime/bloodmagic/routing/IgnoreNBTItemFilter.java b/src/main/java/WayofTime/bloodmagic/routing/IgnoreNBTItemFilter.java index cc0a9288..334959b6 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/IgnoreNBTItemFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/IgnoreNBTItemFilter.java @@ -21,6 +21,6 @@ public class IgnoreNBTItemFilter extends TestItemFilter @Override public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack) { - return filterStack != null && testStack != null && filterStack.getItem() == testStack.getItem() && filterStack.getMetadata() == testStack.getMetadata(); + return ItemStack.areItemsEqual(filterStack, testStack); } } diff --git a/src/main/java/WayofTime/bloodmagic/routing/ModIdItemFilter.java b/src/main/java/WayofTime/bloodmagic/routing/ModIdItemFilter.java index 5d7157e4..8b0afb1b 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/ModIdItemFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/ModIdItemFilter.java @@ -11,7 +11,7 @@ public class ModIdItemFilter extends TestItemFilter @Override public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack) { - if (filterStack != null && testStack != null && filterStack.getItem() != null && testStack.getItem() != null) + if (ItemStack.areItemsEqualIgnoreDurability(filterStack, testStack)) { String keyId = getModID(filterStack.getItem()); String checkedId = getModID(testStack.getItem()); diff --git a/src/main/java/WayofTime/bloodmagic/routing/TestItemFilter.java b/src/main/java/WayofTime/bloodmagic/routing/TestItemFilter.java index f0905745..3af3502e 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/TestItemFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/TestItemFilter.java @@ -40,9 +40,6 @@ public class TestItemFilter implements IItemFilter * being pulled from or pushed to. * @param itemHandler * - The item handler - * @param side - * - The side that the inventory is being accessed from. Used for - * pulling/pushing from/to the inventory. * @param isFilterOutput * - Tells the filter what actions to expect. If true, it should be * initialized as an output filter. If false, it should be @@ -60,23 +57,23 @@ public class TestItemFilter implements IItemFilter for (int slot = 0; slot < itemHandler.getSlots(); slot++) { ItemStack checkedStack = itemHandler.getStackInSlot(slot); - if (checkedStack == null) + if (checkedStack.isEmpty()) { continue; } - int stackSize = checkedStack.stackSize; + int stackSize = checkedStack.getCount(); for (ItemStack filterStack : requestList) { - if (filterStack.stackSize == 0) + if (filterStack.getCount() == 0) { continue; } if (doStacksMatch(filterStack, checkedStack)) { - filterStack.stackSize = Math.max(filterStack.stackSize - stackSize, 0); + filterStack.setCount(Math.max(filterStack.getCount() - stackSize, 0)); } } } @@ -85,24 +82,24 @@ public class TestItemFilter implements IItemFilter requestList = filteredList; for (ItemStack filterStack : requestList) { - filterStack.stackSize *= -1; //Invert the stack size so that + filterStack.setCount(filterStack.getCount() * -1); //Invert the stack size so that } for (int slot = 0; slot < itemHandler.getSlots(); slot++) { ItemStack checkedStack = itemHandler.getStackInSlot(slot); - if (checkedStack == null) + if (checkedStack.isEmpty()) { continue; } - int stackSize = checkedStack.stackSize; + int stackSize = checkedStack.getCount(); for (ItemStack filterStack : filteredList) { if (doStacksMatch(filterStack, checkedStack)) { - filterStack.stackSize += stackSize; + filterStack.grow(stackSize); } } } @@ -112,7 +109,7 @@ public class TestItemFilter implements IItemFilter while (iterator.hasNext()) { ItemStack filterStack = iterator.next(); - if (filterStack.stackSize <= 0) + if (filterStack.isEmpty()) { iterator.remove(); } @@ -137,7 +134,7 @@ public class TestItemFilter implements IItemFilter { if (doStacksMatch(filterStack, inputStack)) { - allowedAmount = Math.min(filterStack.stackSize, inputStack.stackSize); + allowedAmount = Math.min(filterStack.getCount(), inputStack.getCount()); break; } } @@ -148,12 +145,12 @@ public class TestItemFilter implements IItemFilter } ItemStack testStack = inputStack.copy(); - testStack.stackSize = allowedAmount; + testStack.setCount(allowedAmount); ItemStack remainderStack = Utils.insertStackIntoTile(testStack, itemHandler); - int changeAmount = allowedAmount - (remainderStack == null ? 0 : remainderStack.stackSize); + int changeAmount = allowedAmount - (remainderStack.isEmpty() ? 0 : remainderStack.getCount()); testStack = inputStack.copy(); - testStack.stackSize -= changeAmount; + testStack.shrink(changeAmount); Iterator itr = requestList.iterator(); while (itr.hasNext()) @@ -161,8 +158,8 @@ public class TestItemFilter implements IItemFilter ItemStack filterStack = itr.next(); if (doStacksMatch(filterStack, inputStack)) { - filterStack.stackSize -= changeAmount; - if (filterStack.stackSize <= 0) + filterStack.shrink(changeAmount); + if (filterStack.isEmpty()) { itr.remove(); } @@ -186,7 +183,7 @@ public class TestItemFilter implements IItemFilter for (int slot = 0; slot < itemHandler.getSlots(); slot++) { ItemStack inputStack = itemHandler.getStackInSlot(slot); - if (inputStack == null || itemHandler.extractItem(slot, inputStack.stackSize, true) == null)//(accessedInventory instanceof ISidedInventory && !((ISidedInventory) accessedInventory).canExtractItem(slot, inputStack, accessedSide))) + if (inputStack.isEmpty() || itemHandler.extractItem(slot, inputStack.getCount(), true).isEmpty())//(accessedInventory instanceof ISidedInventory && !((ISidedInventory) accessedInventory).canExtractItem(slot, inputStack, accessedSide))) { continue; } @@ -196,7 +193,7 @@ public class TestItemFilter implements IItemFilter { if (doStacksMatch(filterStack, inputStack)) { - allowedAmount = Math.min(maxTransfer, Math.min(filterStack.stackSize, itemHandler.extractItem(slot, inputStack.stackSize, true).stackSize)); + allowedAmount = Math.min(maxTransfer, Math.min(filterStack.getCount(), itemHandler.extractItem(slot, inputStack.getCount(), true).getCount())); break; } } @@ -207,18 +204,16 @@ public class TestItemFilter implements IItemFilter } ItemStack testStack = inputStack.copy(); - testStack.stackSize = allowedAmount; + testStack.setCount(allowedAmount); ItemStack remainderStack = outputFilter.transferStackThroughOutputFilter(testStack); - int changeAmount = allowedAmount - (remainderStack == null ? 0 : remainderStack.stackSize); + int changeAmount = allowedAmount - (remainderStack.isEmpty() ? 0 : remainderStack.getCount()); - if (remainderStack != null && remainderStack.stackSize == allowedAmount) + if (!remainderStack.isEmpty() && remainderStack.getCount() == allowedAmount) { //Nothing has changed. Moving on! continue; } - maxTransfer -= changeAmount; - itemHandler.extractItem(slot, changeAmount, false); Iterator itr = requestList.iterator(); @@ -227,8 +222,8 @@ public class TestItemFilter implements IItemFilter ItemStack filterStack = itr.next(); if (doStacksMatch(filterStack, inputStack)) { - filterStack.stackSize -= changeAmount; - if (filterStack.stackSize <= 0) + filterStack.shrink(changeAmount); + if (filterStack.isEmpty()) { itr.remove(); } diff --git a/src/main/java/WayofTime/bloodmagic/structures/BuildTestStructure.java b/src/main/java/WayofTime/bloodmagic/structures/BuildTestStructure.java index 5618a689..1957af31 100644 --- a/src/main/java/WayofTime/bloodmagic/structures/BuildTestStructure.java +++ b/src/main/java/WayofTime/bloodmagic/structures/BuildTestStructure.java @@ -45,8 +45,8 @@ public class BuildTestStructure settings.setRotation(rot); settings.setIgnoreEntities(true); - settings.setChunk((ChunkPos) null); - settings.setReplacedBlock((Block) null); + settings.setChunk(null); + settings.setReplacedBlock(null); settings.setIgnoreStructureBlock(false); // settings.func_189946_a(MathHelper.clamp_float(schema.integrity, 0.0F, 1.0F)); diff --git a/src/main/java/WayofTime/bloodmagic/structures/Dungeon.java b/src/main/java/WayofTime/bloodmagic/structures/Dungeon.java index 0d640d3c..4a00f85c 100644 --- a/src/main/java/WayofTime/bloodmagic/structures/Dungeon.java +++ b/src/main/java/WayofTime/bloodmagic/structures/Dungeon.java @@ -40,8 +40,8 @@ public class Dungeon settings.setRotation(rot); settings.setIgnoreEntities(true); - settings.setChunk((ChunkPos) null); - settings.setReplacedBlock((Block) null); + settings.setChunk(null); + settings.setReplacedBlock(null); settings.setIgnoreStructureBlock(false); DungeonRoom room = getRandomRoom(rand); @@ -142,10 +142,8 @@ public class Dungeon EnumFacing face = removedDoor1.getKey(); if (availableDoorMap.containsKey(face)) { - availableDoorMap.get(face).remove(removedDoor1); + availableDoorMap.get(face).remove(removedDoor1.getRight()); } - - removedDoor1 = null; } if (removedDoor2 != null) @@ -153,10 +151,8 @@ public class Dungeon EnumFacing face = removedDoor2.getKey(); if (availableDoorMap.containsKey(face)) { - availableDoorMap.get(face).remove(removedDoor2); + availableDoorMap.get(face).remove(removedDoor2.getRight()); } - - removedDoor2 = null; } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java b/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java index b9aade81..a1ebd2cf 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java @@ -35,7 +35,7 @@ public class TileAlchemyArray extends TileInventory implements ITickable, IAlche { if (arrayEffect != null) { - arrayEffect.onEntityCollidedWithBlock(this, worldObj, pos, state, entity); + arrayEffect.onEntityCollidedWithBlock(this, getWorld(), pos, state, entity); } } @@ -145,7 +145,7 @@ public class TileAlchemyArray extends TileInventory implements ITickable, IAlche { this.decrStackSize(0, 1); this.decrStackSize(1, 1); - this.worldObj.setBlockToAir(getPos()); + this.getWorld().setBlockToAir(getPos()); } return true; diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyTable.java b/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyTable.java index 2e1c3d1a..c3e9a446 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyTable.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyTable.java @@ -76,7 +76,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, { if (blockedSlots.contains(slot)) { - blockedSlots.remove((Object) slot); + blockedSlots.remove(slot); } else { blockedSlots.add(slot); @@ -136,7 +136,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, { if (this.isSlave()) { - TileEntity tile = worldObj.getTileEntity(connectedPos); + TileEntity tile = getWorld().getTileEntity(connectedPos); if (tile instanceof TileAlchemyTable) { return (T) new SidedInvWrapper((TileAlchemyTable) tile, facing); @@ -172,7 +172,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, case DOWN: return index != outputSlot && index != orbSlot && index != toolSlot; case UP: - if (index == orbSlot && stack != null && stack.getItem() instanceof IBloodOrb) + if (index == orbSlot && !stack.isEmpty() && stack.getItem() instanceof IBloodOrb) { return true; } else if (index == toolSlot) @@ -195,7 +195,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, case DOWN: return index == outputSlot; case UP: - if (index == orbSlot && stack != null && stack.getItem() instanceof IBloodOrb) + if (index == orbSlot && !stack.isEmpty() && stack.getItem() instanceof IBloodOrb) { return true; } else if (index == toolSlot) @@ -237,7 +237,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, for (int i = 0; i < 6; i++) { - if (getStackInSlot(i) != null) + if (!getStackInSlot(i).isEmpty()) { inputList.add(getStackInSlot(i)); } @@ -246,12 +246,12 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, int tier = getTierOfOrb(); AlchemyTableRecipe recipe = AlchemyTableRecipeRegistry.getMatchingRecipe(inputList, getWorld(), getPos()); - if (recipe != null && (burnTime > 0 || (!worldObj.isRemote && tier >= recipe.getTierRequired() && this.getContainedLp() >= recipe.getLpDrained()))) + if (recipe != null && (burnTime > 0 || (!getWorld().isRemote && tier >= recipe.getTierRequired() && this.getContainedLp() >= recipe.getLpDrained()))) { if (burnTime == 1) { - IBlockState state = worldObj.getBlockState(pos); - worldObj.notifyBlockUpdate(getPos(), state, state, 3); + IBlockState state = getWorld().getBlockState(pos); + getWorld().notifyBlockUpdate(getPos(), state, state, 3); } if (canCraft(inputList, recipe)) @@ -261,18 +261,18 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, if (burnTime == ticksRequired) { - if (!worldObj.isRemote) + if (!getWorld().isRemote) { int requiredLp = recipe.getLpDrained(); if (requiredLp > 0) { - if (!worldObj.isRemote) + if (!getWorld().isRemote) { consumeLp(requiredLp); } } - if (!worldObj.isRemote) + if (!getWorld().isRemote) { craftItem(inputList, recipe); } @@ -280,8 +280,8 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, burnTime = 0; - IBlockState state = worldObj.getBlockState(pos); - worldObj.notifyBlockUpdate(getPos(), state, state, 3); + IBlockState state = getWorld().getBlockState(pos); + getWorld().notifyBlockUpdate(getPos(), state, state, 3); } else if (burnTime > ticksRequired + 10) { burnTime = 0; @@ -310,13 +310,13 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, ItemStack outputStack = recipe.getRecipeOutput(inputList); ItemStack currentOutputStack = getStackInSlot(outputSlot); - if (outputStack == null) + if (outputStack.isEmpty()) return false; - if (currentOutputStack == null) + if (currentOutputStack.isEmpty()) return true; if (!currentOutputStack.isItemEqual(outputStack)) return false; - int result = currentOutputStack.stackSize + outputStack.stackSize; + int result = currentOutputStack.getCount() + outputStack.getCount(); return result <= getInventoryStackLimit() && result <= currentOutputStack.getMaxStackSize(); } @@ -324,7 +324,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, public int getTierOfOrb() { ItemStack orbStack = getStackInSlot(orbSlot); - if (orbStack != null) + if (!orbStack.isEmpty()) { if (orbStack.getItem() instanceof IBloodOrb) { @@ -338,7 +338,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, public int getContainedLp() { ItemStack orbStack = getStackInSlot(orbSlot); - if (orbStack != null) + if (!orbStack.isEmpty()) { if (orbStack.getItem() instanceof IBloodOrb) { @@ -372,12 +372,12 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, ItemStack outputStack = recipe.getRecipeOutput(inputList); ItemStack currentOutputStack = getStackInSlot(outputSlot); - if (currentOutputStack == null) + if (currentOutputStack.isEmpty()) { setInventorySlotContents(outputSlot, outputStack); } else if (currentOutputStack.getItem() == currentOutputStack.getItem()) { - currentOutputStack.stackSize += outputStack.stackSize; + currentOutputStack.setCount(outputStack.getCount()); } consumeInventory(recipe); @@ -388,7 +388,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, { ItemStack orbStack = getStackInSlot(orbSlot); - if (orbStack != null) + if (!orbStack.isEmpty()) { if (orbStack.getItem() instanceof IBloodOrb) { @@ -416,24 +416,5 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, { setInventorySlotContents(i, result[i]); } -// for (int i = 0; i < 6; i++) -// { -// ItemStack inputStack = getStackInSlot(i); -// if (inputStack != null) -// { -// if (inputStack.getItem().hasContainerItem(inputStack)) -// { -// setInventorySlotContents(i, inputStack.getItem().getContainerItem(inputStack)); -// continue; -// } -// -// inputStack.stackSize--; -// if (inputStack.stackSize <= 0) -// { -// setInventorySlotContents(i, null); -// continue; -// } -// } -// } } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrucible.java b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrucible.java index e34b3c0f..61c75ec9 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrucible.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrucible.java @@ -30,14 +30,14 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo @Override public void update() { - if (worldObj.isRemote) + if (getWorld().isRemote) { return; } internalCounter++; - if (worldObj.isBlockPowered(getPos())) + if (getWorld().isBlockPowered(getPos())) { //TODO: Fill the contained gem if it is there. ItemStack stack = this.getStackInSlot(0); @@ -70,28 +70,28 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo } else { ItemStack stack = this.getStackInSlot(0); - if (stack != null) + if (!stack.isEmpty()) { if (stack.getItem() instanceof IDemonWillGem) { IDemonWillGem gemItem = (IDemonWillGem) stack.getItem(); for (EnumDemonWillType type : EnumDemonWillType.values()) { - double currentAmount = WorldDemonWillHandler.getCurrentWill(worldObj, pos, type); + double currentAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); double drainAmount = Math.min(maxWill - currentAmount, gemDrainRate); - double filled = WorldDemonWillHandler.fillWillToMaximum(worldObj, pos, type, drainAmount, maxWill, false); + double filled = WorldDemonWillHandler.fillWillToMaximum(getWorld(), pos, type, drainAmount, maxWill, false); filled = gemItem.drainWill(type, stack, filled, false); if (filled > 0) { filled = gemItem.drainWill(type, stack, filled, true); - WorldDemonWillHandler.fillWillToMaximum(worldObj, pos, type, filled, maxWill, true); + WorldDemonWillHandler.fillWillToMaximum(getWorld(), pos, type, filled, maxWill, true); } } } else if (stack.getItem() instanceof IDiscreteDemonWill) //TODO: Limit the speed of this process { IDiscreteDemonWill willItem = (IDiscreteDemonWill) stack.getItem(); EnumDemonWillType type = willItem.getType(stack); - double currentAmount = WorldDemonWillHandler.getCurrentWill(worldObj, pos, type); + double currentAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); double needed = maxWill - currentAmount; double discreteAmount = willItem.getDiscretization(stack); if (needed >= discreteAmount) @@ -99,10 +99,10 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo double filled = willItem.drainWill(stack, discreteAmount); if (filled > 0) { - WorldDemonWillHandler.fillWillToMaximum(worldObj, pos, type, filled, maxWill, true); - if (stack.stackSize <= 0) + WorldDemonWillHandler.fillWillToMaximum(getWorld(), pos, type, filled, maxWill, true); + if (stack.getCount() <= 0) { - this.setInventorySlotContents(0, null); + this.setInventorySlotContents(0, ItemStack.EMPTY); } } } @@ -252,7 +252,7 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo @Override public boolean canInsertItem(int index, ItemStack stack, EnumFacing direction) { - return stack != null ? stack.getItem() instanceof IDemonWillGem || stack.getItem() instanceof IDiscreteDemonWill : false; + return !stack.isEmpty() && (stack.getItem() instanceof IDemonWillGem || stack.getItem() instanceof IDiscreteDemonWill); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java index 44fbc634..b1083df8 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java @@ -41,7 +41,7 @@ public class TileDemonCrystal extends TileTicking @Override public void onUpdate() { - if (worldObj.isRemote) + if (getWorld().isRemote) { return; } @@ -52,20 +52,20 @@ public class TileDemonCrystal extends TileTicking { EnumDemonWillType type = EnumDemonWillType.values()[this.getBlockMetadata()]; - double value = WorldDemonWillHandler.getCurrentWill(worldObj, pos, type); + double value = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); if (type != EnumDemonWillType.DEFAULT) { if (value >= 100) { double nextProgress = getCrystalGrowthPerSecond(value); - progressToNextCrystal += WorldDemonWillHandler.drainWill(worldObj, getPos(), type, nextProgress * sameWillConversionRate, true) / sameWillConversionRate; + progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), type, nextProgress * sameWillConversionRate, true) / sameWillConversionRate; } else { - value = WorldDemonWillHandler.getCurrentWill(worldObj, pos, EnumDemonWillType.DEFAULT); + value = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, EnumDemonWillType.DEFAULT); if (value > 0.5) { double nextProgress = getCrystalGrowthPerSecond(value) * timeDelayForWrongWill; - progressToNextCrystal += WorldDemonWillHandler.drainWill(worldObj, getPos(), EnumDemonWillType.DEFAULT, nextProgress * defaultWillConversionRate, true) / defaultWillConversionRate; + progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), EnumDemonWillType.DEFAULT, nextProgress * defaultWillConversionRate, true) / defaultWillConversionRate; } } } else @@ -73,17 +73,17 @@ public class TileDemonCrystal extends TileTicking if (value > 0.5) { double nextProgress = getCrystalGrowthPerSecond(value); - progressToNextCrystal += WorldDemonWillHandler.drainWill(worldObj, getPos(), type, nextProgress * sameWillConversionRate, true) / sameWillConversionRate; + progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), type, nextProgress * sameWillConversionRate, true) / sameWillConversionRate; } } checkAndGrowCrystal(); } -// if (worldObj.getWorldTime() % 200 == 0) +// if (getWorld().getWorldTime() % 200 == 0) // { // crystalCount = Math.min(crystalCount + 1, 7); -// worldObj.markBlockForUpdate(pos); +// getWorld().markBlockForUpdate(pos); // } } @@ -105,11 +105,11 @@ public class TileDemonCrystal extends TileTicking return 0; } - IBlockState state = worldObj.getBlockState(pos); + IBlockState state = getWorld().getBlockState(pos); int meta = this.getBlockType().getMetaFromState(state); EnumDemonWillType type = EnumDemonWillType.values()[meta]; - double value = WorldDemonWillHandler.getCurrentWill(worldObj, pos, type); + double value = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); double percentDrain = willDrain <= 0 ? 1 : Math.min(1, value / willDrain); if (percentDrain <= 0) { @@ -117,7 +117,7 @@ public class TileDemonCrystal extends TileTicking } // Verification that you can actually drain the will from this chunk, for future proofing. - WorldDemonWillHandler.drainWill(worldObj, pos, type, percentDrain * willDrain, true); + WorldDemonWillHandler.drainWill(getWorld(), pos, type, percentDrain * willDrain, true); progressToNextCrystal += percentDrain * progressPercentage; checkAndGrowCrystal(); @@ -131,8 +131,8 @@ public class TileDemonCrystal extends TileTicking { progressToNextCrystal--; crystalCount++; - IBlockState thisState = worldObj.getBlockState(pos); - worldObj.notifyBlockUpdate(pos, thisState, thisState, 3); + IBlockState thisState = getWorld().getBlockState(pos); + getWorld().notifyBlockUpdate(pos, thisState, thisState, 3); markDirty(); } } @@ -144,15 +144,15 @@ public class TileDemonCrystal extends TileTicking public boolean dropSingleCrystal() { - if (!worldObj.isRemote && crystalCount > 1) + if (!getWorld().isRemote && crystalCount > 1) { - IBlockState state = worldObj.getBlockState(pos); + IBlockState state = getWorld().getBlockState(pos); EnumDemonWillType type = state.getValue(BlockDemonCrystal.TYPE); ItemStack stack = BlockDemonCrystal.getItemStackDropped(type, 1); if (stack != null) { crystalCount--; - worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack)); + getWorld().spawnEntity(new EntityItem(getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack)); return true; } } @@ -167,7 +167,7 @@ public class TileDemonCrystal extends TileTicking public int getCrystalCountForRender() { - return MathHelper.clamp_int(crystalCount - 1, 0, 6); + return MathHelper.clamp(crystalCount - 1, 0, 6); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystallizer.java b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystallizer.java index cb088dd9..a0acb3ee 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystallizer.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystallizer.java @@ -30,26 +30,26 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond @Override public void onUpdate() { - if (worldObj.isRemote) + if (getWorld().isRemote) { return; } BlockPos offsetPos = pos.offset(EnumFacing.UP); - if (worldObj.isAirBlock(offsetPos)) //Room for a crystal to grow + if (getWorld().isAirBlock(offsetPos)) //Room for a crystal to grow { - EnumDemonWillType highestType = WorldDemonWillHandler.getHighestDemonWillType(worldObj, pos); - double amount = WorldDemonWillHandler.getCurrentWill(worldObj, pos, highestType); + EnumDemonWillType highestType = WorldDemonWillHandler.getHighestDemonWillType(getWorld(), pos); + double amount = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, highestType); if (amount >= willToFormCrystal) { internalCounter += getCrystalFormationRate(amount); if (internalCounter >= totalFormationTime) { - if (WorldDemonWillHandler.drainWill(worldObj, getPos(), highestType, willToFormCrystal, false) >= willToFormCrystal) + if (WorldDemonWillHandler.drainWill(getWorld(), getPos(), highestType, willToFormCrystal, false) >= willToFormCrystal) { if (highestType == EnumDemonWillType.DEFAULT && formRandomSpecialCrystal(offsetPos) || formCrystal(highestType, offsetPos)) { - WorldDemonWillHandler.drainWill(worldObj, getPos(), highestType, willToFormCrystal, true); + WorldDemonWillHandler.drainWill(getWorld(), getPos(), highestType, willToFormCrystal, true); internalCounter = 0; } } @@ -60,8 +60,8 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond public boolean formCrystal(EnumDemonWillType type, BlockPos position) { - worldObj.setBlockState(position, ModBlocks.DEMON_CRYSTAL.getStateFromMeta(type.ordinal())); - TileEntity tile = worldObj.getTileEntity(position); + getWorld().setBlockState(position, ModBlocks.DEMON_CRYSTAL.getStateFromMeta(type.ordinal())); + TileEntity tile = getWorld().getTileEntity(position); if (tile instanceof TileDemonCrystal) { ((TileDemonCrystal) tile).setPlacement(EnumFacing.UP); @@ -73,11 +73,11 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond public boolean formRandomSpecialCrystal(BlockPos position) { - if (worldObj.rand.nextDouble() > 0.1) + if (getWorld().rand.nextDouble() > 0.1) { return formCrystal(EnumDemonWillType.DEFAULT, position); } - EnumDemonWillType crystalType = EnumDemonWillType.values()[worldObj.rand.nextInt(EnumDemonWillType.values().length - 1) + 1]; + EnumDemonWillType crystalType = EnumDemonWillType.values()[getWorld().rand.nextInt(EnumDemonWillType.values().length - 1) + 1]; return formCrystal(crystalType, position); } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileDemonPylon.java b/src/main/java/WayofTime/bloodmagic/tile/TileDemonPylon.java index ca95170d..475f73c8 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileDemonPylon.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileDemonPylon.java @@ -23,24 +23,24 @@ public class TileDemonPylon extends TileTicking implements IDemonWillConduit @Override public void onUpdate() { - if (worldObj.isRemote) + if (getWorld().isRemote) { return; } for (EnumDemonWillType type : EnumDemonWillType.values()) { - double currentAmount = WorldDemonWillHandler.getCurrentWill(worldObj, pos, type); + double currentAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); for (EnumFacing side : EnumFacing.HORIZONTALS) { BlockPos offsetPos = pos.offset(side, 16); - double sideAmount = WorldDemonWillHandler.getCurrentWill(worldObj, offsetPos, type); + double sideAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), offsetPos, type); if (sideAmount > currentAmount) { double drainAmount = Math.min((sideAmount - currentAmount) / 2, drainRate); - double drain = WorldDemonWillHandler.drainWill(worldObj, offsetPos, type, drainAmount, true); - WorldDemonWillHandler.fillWill(worldObj, pos, type, drain, true); + double drain = WorldDemonWillHandler.drainWill(getWorld(), offsetPos, type, drainAmount, true); + WorldDemonWillHandler.fillWill(getWorld(), pos, type, drain, true); } } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java b/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java index f08dcf94..6ebf9778 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java @@ -42,13 +42,13 @@ public class TileIncenseAltar extends TileInventory implements ITickable public void update() { AxisAlignedBB aabb = incenseArea.getAABB(getPos()); - List playerList = worldObj.getEntitiesWithinAABB(EntityPlayer.class, aabb); + List playerList = getWorld().getEntitiesWithinAABB(EntityPlayer.class, aabb); if (playerList.isEmpty()) { return; } - if (worldObj.getTotalWorldTime() % 100 == 0) + if (getWorld().getTotalWorldTime() % 100 == 0) { recheckConstruction(); } @@ -65,9 +65,9 @@ public class TileIncenseAltar extends TileInventory implements ITickable if (hasPerformed) { - if (worldObj.rand.nextInt(4) == 0 && worldObj instanceof WorldServer) + if (getWorld().rand.nextInt(4) == 0 && getWorld() instanceof WorldServer) { - WorldServer server = (WorldServer) worldObj; + WorldServer server = (WorldServer) getWorld(); server.spawnParticle(EnumParticleTypes.FLAME, pos.getX() + 0.5, pos.getY() + 1.2, pos.getZ() + 0.5, 1, 0.02, 0.03, 0.02, 0, new int[0]); } } @@ -113,9 +113,9 @@ public class TileIncenseAltar extends TileInventory implements ITickable for (int j = -1; j <= 1; j++) { BlockPos offsetPos = facingOffsetPos.offset(horizontalFacing.rotateY(), j); - IBlockState state = worldObj.getBlockState(offsetPos); + IBlockState state = getWorld().getBlockState(offsetPos); Block block = state.getBlock(); - if (!(block instanceof IIncensePath && ((IIncensePath) block).getLevelOfPath(worldObj, offsetPos, state) >= currentDistance - 2)) + if (!(block instanceof IIncensePath && ((IIncensePath) block).getLevelOfPath(getWorld(), offsetPos, state) >= currentDistance - 2)) { canFormRoad = false; break level; @@ -144,9 +144,9 @@ public class TileIncenseAltar extends TileInventory implements ITickable for (int y = 0 + yOffset; y <= 2 + yOffset; y++) { BlockPos offsetPos = pos.add(i, y, j); - IBlockState state = worldObj.getBlockState(offsetPos); + IBlockState state = getWorld().getBlockState(offsetPos); Block block = state.getBlock(); - TranquilityStack stack = IncenseTranquilityRegistry.getTranquilityOfBlock(worldObj, offsetPos, block, state); + TranquilityStack stack = IncenseTranquilityRegistry.getTranquilityOfBlock(getWorld(), offsetPos, block, state); if (stack != null) { if (!tranquilityMap.containsKey(stack.type)) @@ -186,7 +186,7 @@ public class TileIncenseAltar extends TileInventory implements ITickable appliedTranquility += Math.sqrt(entry.getValue()); } - double bonus = IncenseAltarHandler.getIncenseBonusFromComponents(worldObj, pos, appliedTranquility, roadDistance); + double bonus = IncenseAltarHandler.getIncenseBonusFromComponents(getWorld(), pos, appliedTranquility, roadDistance); incenseAddition = bonus; this.tranquility = appliedTranquility; } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileInventory.java b/src/main/java/WayofTime/bloodmagic/tile/TileInventory.java index 3e34ccdd..2480bb68 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileInventory.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileInventory.java @@ -61,7 +61,7 @@ public class TileInventory extends TileBase implements IInventory if (j >= 0 && j < inventory.length) { - inventory[j] = ItemStack.loadItemStackFromNBT(data); + inventory[j] = new ItemStack(data); } } } @@ -75,7 +75,7 @@ public class TileInventory extends TileBase implements IInventory for (int i = 0; i < inventory.length; i++) { - if ((inventory[i] != null) && !isSyncedSlot(i)) + if ((!inventory[i].isEmpty()) && !isSyncedSlot(i)) { NBTTagCompound data = new NBTTagCompound(); data.setByte("Slot", (byte) i); @@ -115,7 +115,7 @@ public class TileInventory extends TileBase implements IInventory if (!getWorld().isRemote) getWorld().notifyBlockUpdate(getPos(), getWorld().getBlockState(getPos()), getWorld().getBlockState(getPos()), 3); - if (inventory[index].stackSize <= count) + if (inventory[index].getCount() <= count) { ItemStack itemStack = inventory[index]; inventory[index] = null; @@ -124,7 +124,7 @@ public class TileInventory extends TileBase implements IInventory } ItemStack itemStack = inventory[index].splitStack(count); - if (inventory[index].stackSize == 0) + if (inventory[index].getCount() == 0) inventory[index] = null; markDirty(); @@ -150,8 +150,8 @@ public class TileInventory extends TileBase implements IInventory public void setInventorySlotContents(int slot, ItemStack stack) { inventory[slot] = stack; - if (stack != null && stack.stackSize > getInventoryStackLimit()) - stack.stackSize = getInventoryStackLimit(); + if (!stack.isEmpty() && stack.getCount() > getInventoryStackLimit()) + stack.setCount(getInventoryStackLimit()); markDirty(); if (!getWorld().isRemote) getWorld().notifyBlockUpdate(getPos(), getWorld().getBlockState(getPos()), getWorld().getBlockState(getPos()), 3); @@ -163,12 +163,6 @@ public class TileInventory extends TileBase implements IInventory return 64; } - @Override - public boolean isUseableByPlayer(EntityPlayer player) - { - return true; - } - @Override public void openInventory(EntityPlayer player) { @@ -211,6 +205,20 @@ public class TileInventory extends TileBase implements IInventory this.inventory = new ItemStack[size]; } + @Override + public boolean isEmpty() { + for (ItemStack stack : inventory) + if (!stack.isEmpty()) + return false; + + return true; + } + + @Override + public boolean isUsableByPlayer(EntityPlayer player) { + return true; + } + // IWorldNameable @Override diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileInversionPillar.java b/src/main/java/WayofTime/bloodmagic/tile/TileInversionPillar.java index 62bad390..a2a5f56a 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileInversionPillar.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileInversionPillar.java @@ -82,23 +82,23 @@ public class TileInversionPillar extends TileTicking { if (animationOffsetValue < 0) { - animationOffsetValue = worldObj.getTotalWorldTime() * worldObj.rand.nextFloat(); + animationOffsetValue = getWorld().getTotalWorldTime() * getWorld().rand.nextFloat(); animationOffset.setValue(animationOffsetValue); } - if (worldObj.isRemote) + if (getWorld().isRemote) { return; } if (!isRegistered) { - isRegistered = InversionPillarHandler.addPillarToMap(worldObj, getType(), getPos()); + isRegistered = InversionPillarHandler.addPillarToMap(getWorld(), getType(), getPos()); } counter++; - double currentWill = WorldDemonWillHandler.getCurrentWill(worldObj, pos, type); + double currentWill = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); if (counter % 1 == 0) { List pillarList = getNearbyPillarsExcludingThis(); @@ -151,17 +151,17 @@ public class TileInversionPillar extends TileTicking if (currentInfectionRadius >= 8 && currentInversion >= inversionToAddPillar) { //TODO: Improve algorithm - List allConnectedPos = InversionPillarHandler.getAllConnectedPillars(worldObj, type, pos); - BlockPos candidatePos = findCandidatePositionForPillar(worldObj, type, pos, allConnectedPos, 5, 10); + List allConnectedPos = InversionPillarHandler.getAllConnectedPillars(getWorld(), type, pos); + BlockPos candidatePos = findCandidatePositionForPillar(getWorld(), type, pos, allConnectedPos, 5, 10); if (!candidatePos.equals(BlockPos.ORIGIN)) { currentInversion = 0; IBlockState pillarState = ModBlocks.INVERSION_PILLAR.getStateFromMeta(type.ordinal()); IBlockState bottomState = ModBlocks.INVERSION_PILLAR_END.getStateFromMeta(type.ordinal() * 2); IBlockState topState = ModBlocks.INVERSION_PILLAR_END.getStateFromMeta(type.ordinal() * 2 + 1); - worldObj.setBlockState(candidatePos, pillarState); - worldObj.setBlockState(candidatePos.down(), bottomState); - worldObj.setBlockState(candidatePos.up(), topState); + getWorld().setBlockState(candidatePos, pillarState); + getWorld().setBlockState(candidatePos.down(), bottomState); + getWorld().setBlockState(candidatePos.up(), topState); } } } @@ -176,11 +176,11 @@ public class TileInversionPillar extends TileTicking { if (currentInversion > 1000) { - Vec3d vec = new Vec3d(worldObj.rand.nextDouble() * 2 - 1, worldObj.rand.nextDouble() * 2 - 1, worldObj.rand.nextDouble() * 2 - 1).normalize().scale(2 * currentInfectionRadius); + Vec3d vec = new Vec3d(getWorld().rand.nextDouble() * 2 - 1, getWorld().rand.nextDouble() * 2 - 1, getWorld().rand.nextDouble() * 2 - 1).normalize().scale(2 * currentInfectionRadius); BlockPos centralPos = pos.add(vec.xCoord, vec.yCoord, vec.zCoord); - worldObj.setBlockState(centralPos, ModBlocks.DEMON_EXTRAS.getStateFromMeta(0)); + getWorld().setBlockState(centralPos, ModBlocks.DEMON_EXTRAS.getStateFromMeta(0)); currentInversion -= 1000; } } @@ -236,7 +236,7 @@ public class TileInversionPillar extends TileTicking public void spreadWillToSurroundingChunks() { - double currentAmount = WorldDemonWillHandler.getCurrentWill(worldObj, pos, type); + double currentAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); if (currentAmount <= minimumWillForChunkWhenSpreading) { return; @@ -245,7 +245,7 @@ public class TileInversionPillar extends TileTicking for (EnumFacing side : EnumFacing.HORIZONTALS) { BlockPos offsetPos = pos.offset(side, 16); - double sideAmount = WorldDemonWillHandler.getCurrentWill(worldObj, offsetPos, type); + double sideAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), offsetPos, type); if (currentAmount > sideAmount) { double drainAmount = Math.min((currentAmount - sideAmount) / 2, willPushRate); @@ -254,8 +254,8 @@ public class TileInversionPillar extends TileTicking continue; } - double drain = WorldDemonWillHandler.drainWill(worldObj, pos, type, drainAmount, true); - drain = WorldDemonWillHandler.fillWillToMaximum(worldObj, offsetPos, type, drain, maxWillForChunk, true); + double drain = WorldDemonWillHandler.drainWill(getWorld(), pos, type, drainAmount, true); + drain = WorldDemonWillHandler.fillWillToMaximum(getWorld(), offsetPos, type, drain, maxWillForChunk, true); currentInversion -= drain * inversionCostPerWillSpread; } @@ -264,15 +264,15 @@ public class TileInversionPillar extends TileTicking public void removePillarFromMap() { - if (!worldObj.isRemote) + if (!getWorld().isRemote) { - InversionPillarHandler.removePillarFromMap(worldObj, type, pos); + InversionPillarHandler.removePillarFromMap(getWorld(), type, pos); } } public List getNearbyPillarsExcludingThis() { - return InversionPillarHandler.getNearbyPillars(worldObj, type, pos); + return InversionPillarHandler.getNearbyPillars(getWorld(), type, pos); } @Override @@ -322,7 +322,7 @@ public class TileInversionPillar extends TileTicking if (totalGeneratedWill > 0) { - WorldDemonWillHandler.fillWillToMaximum(worldObj, pos, type, totalGeneratedWill, maxWillForChunk, true); + WorldDemonWillHandler.fillWillToMaximum(getWorld(), pos, type, totalGeneratedWill, maxWillForChunk, true); } } @@ -359,9 +359,9 @@ public class TileInversionPillar extends TileTicking for (int i = 0; i < currentInfectionRadius; i++) { - double xOff = (worldObj.rand.nextBoolean() ? 1 : -1) * (worldObj.rand.nextGaussian() + 1) * (currentInfectionRadius); - double yOff = (worldObj.rand.nextBoolean() ? 1 : -1) * (worldObj.rand.nextGaussian() + 1) * (currentInfectionRadius); - double zOff = (worldObj.rand.nextBoolean() ? 1 : -1) * (worldObj.rand.nextGaussian() + 1) * (currentInfectionRadius); + double xOff = (getWorld().rand.nextBoolean() ? 1 : -1) * (getWorld().rand.nextGaussian() + 1) * (currentInfectionRadius); + double yOff = (getWorld().rand.nextBoolean() ? 1 : -1) * (getWorld().rand.nextGaussian() + 1) * (currentInfectionRadius); + double zOff = (getWorld().rand.nextBoolean() ? 1 : -1) * (getWorld().rand.nextGaussian() + 1) * (currentInfectionRadius); double r2 = xOff * xOff + yOff * yOff + zOff * zOff; int maxInfectionRadius2 = (9 * currentInfectionRadius * currentInfectionRadius); if (r2 > maxInfectionRadius2) @@ -378,16 +378,16 @@ public class TileInversionPillar extends TileTicking return 1; //Invalid block (itself!) } - IBlockState state = worldObj.getBlockState(offsetPos); - if (!state.getBlock().isAir(state, worldObj, offsetPos)) + IBlockState state = getWorld().getBlockState(offsetPos); + if (!state.getBlock().isAir(state, getWorld(), offsetPos)) { //Consume Will and set this block Block block = state.getBlock(); if (block == Blocks.DIRT || block == Blocks.STONE || block == Blocks.GRASS) { - if (worldObj.setBlockState(offsetPos, ModBlocks.DEMON_EXTRAS.getStateFromMeta(0))) + if (getWorld().setBlockState(offsetPos, ModBlocks.DEMON_EXTRAS.getStateFromMeta(0))) { - WorldDemonWillHandler.drainWill(worldObj, pos, type, willPerOperation, true); + WorldDemonWillHandler.drainWill(getWorld(), pos, type, willPerOperation, true); currentInversion -= inversionPerOperation; return 0; //Successfully placed diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java b/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java index 58f0b59b..f5167081 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java @@ -51,7 +51,7 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS @Override public void onUpdate() { - if (worldObj.isRemote) + if (getWorld().isRemote) return; if (getWorld().isBlockPowered(getPos()) && isActive()) diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileMimic.java b/src/main/java/WayofTime/bloodmagic/tile/TileMimic.java index 122f3cff..b36f1e8d 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileMimic.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileMimic.java @@ -32,6 +32,8 @@ import WayofTime.bloodmagic.registry.ModItems; import WayofTime.bloodmagic.util.ChatUtil; import WayofTime.bloodmagic.util.Utils; +import javax.annotation.Nullable; + public class TileMimic extends TileInventory implements ITickable { private static Field _blockMetadata = ReflectionHelper.findField(TileEntity.class, "blockMetadata", "field_145847_g"); @@ -55,7 +57,7 @@ public class TileMimic extends TileInventory implements ITickable @Override public void update() { - if (worldObj.isRemote) + if (getWorld().isRemote) { return; } @@ -67,36 +69,36 @@ public class TileMimic extends TileInventory implements ITickable if (potionStack != null) { AxisAlignedBB bb = new AxisAlignedBB(this.getPos()).expand(playerCheckRadius, playerCheckRadius, playerCheckRadius); - List playerList = worldObj.getEntitiesWithinAABB(EntityPlayer.class, bb); + List playerList = getWorld().getEntitiesWithinAABB(EntityPlayer.class, bb); for (EntityPlayer player : playerList) { if (!player.capabilities.isCreativeMode) { - double posX = this.pos.getX() + 0.5 + (2 * worldObj.rand.nextDouble() - 1) * potionSpawnRadius; - double posY = this.pos.getY() + 0.5 + (2 * worldObj.rand.nextDouble() - 1) * potionSpawnRadius; - double posZ = this.pos.getZ() + 0.5 + (2 * worldObj.rand.nextDouble() - 1) * potionSpawnRadius; + double posX = this.pos.getX() + 0.5 + (2 * getWorld().rand.nextDouble() - 1) * potionSpawnRadius; + double posY = this.pos.getY() + 0.5 + (2 * getWorld().rand.nextDouble() - 1) * potionSpawnRadius; + double posZ = this.pos.getZ() + 0.5 + (2 * getWorld().rand.nextDouble() - 1) * potionSpawnRadius; ItemStack newStack = new ItemStack(potionStack.getItem() == ModItems.POTION_FLASK ? Items.SPLASH_POTION : potionStack.getItem()); newStack.setTagCompound(potionStack.getTagCompound()); - EntityPotion potionEntity = new EntityPotion(worldObj, posX, posY, posZ, newStack); + EntityPotion potionEntity = new EntityPotion(getWorld(), posX, posY, posZ, newStack); - worldObj.spawnEntityInWorld(potionEntity); + getWorld().spawnEntity(potionEntity); break; } } } } - if (this.getBlockMetadata() == BlockMimic.sentientMimicMeta && worldObj.getDifficulty() != EnumDifficulty.PEACEFUL && !(mimicedTile instanceof IInventory)) + if (this.getBlockMetadata() == BlockMimic.sentientMimicMeta && getWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(mimicedTile instanceof IInventory)) { AxisAlignedBB bb = new AxisAlignedBB(this.getPos()).expand(playerCheckRadius, playerCheckRadius, playerCheckRadius); - List playerList = worldObj.getEntitiesWithinAABB(EntityPlayer.class, bb); + List playerList = getWorld().getEntitiesWithinAABB(EntityPlayer.class, bb); for (EntityPlayer player : playerList) { - if (!player.capabilities.isCreativeMode && Utils.canEntitySeeBlock(worldObj, player, getPos())) + if (!player.capabilities.isCreativeMode && Utils.canEntitySeeBlock(getWorld(), player, getPos())) { spawnMimicEntity(player); break; @@ -108,10 +110,10 @@ public class TileMimic extends TileInventory implements ITickable public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side) { - if (heldItem != null && player.capabilities.isCreativeMode) + if (!heldItem.isEmpty() && player.capabilities.isCreativeMode) { List list = PotionUtils.getEffectsFromStack(heldItem); - if (list != null && !list.isEmpty()) + if (!list.isEmpty()) { if (!world.isRemote) { @@ -141,10 +143,10 @@ public class TileMimic extends TileInventory implements ITickable if (player.isSneaking()) return false; - if (player.getHeldItem(hand) != null && player.getHeldItem(hand).getItem() == new ItemStack(ModBlocks.MIMIC).getItem()) + if (!player.getHeldItem(hand).isEmpty() && player.getHeldItem(hand).getItem() == new ItemStack(ModBlocks.MIMIC).getItem()) return false; - if (getStackInSlot(0) != null && player.getHeldItem(hand) != null) + if (!getStackInSlot(0).isEmpty() && !player.getHeldItem(hand).isEmpty()) return false; if (!dropItemsOnBreak && !player.capabilities.isCreativeMode) @@ -155,7 +157,7 @@ public class TileMimic extends TileInventory implements ITickable if (player.capabilities.isCreativeMode) { - dropItemsOnBreak = getStackInSlot(0) == null; + dropItemsOnBreak = getStackInSlot(0).isEmpty(); } world.notifyBlockUpdate(pos, state, state, 3); @@ -189,7 +191,7 @@ public class TileMimic extends TileInventory implements ITickable return false; } - if (player.getActiveItemStack() == null && getStackInSlot(1) != null) + if (player.getActiveItemStack().isEmpty() && !getStackInSlot(1).isEmpty()) { switch (sideHit) { @@ -242,31 +244,31 @@ public class TileMimic extends TileInventory implements ITickable public boolean spawnMimicEntity(EntityPlayer target) { - if (this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL) + if (this.getWorld().getDifficulty() == EnumDifficulty.PEACEFUL) { return false; } - if (this.getStackInSlot(0) == null || worldObj.isRemote) + if (this.getStackInSlot(0).isEmpty() || getWorld().isRemote) { return false; } - EntityMimic mimicEntity = new EntityMimic(worldObj); + EntityMimic mimicEntity = new EntityMimic(getWorld()); mimicEntity.setPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); mimicEntity.initializeMimic(getStackInSlot(0), tileTag, dropItemsOnBreak, metaOfReplacedBlock, playerCheckRadius, pos); tileTag = null; mimicedTile = null; - this.setInventorySlotContents(0, null); + this.setInventorySlotContents(0, ItemStack.EMPTY); - worldObj.spawnEntityInWorld(mimicEntity); + getWorld().spawnEntity(mimicEntity); if (target != null) { mimicEntity.setAttackTarget(target); } - worldObj.setBlockToAir(pos); + getWorld().setBlockToAir(pos); return true; } @@ -277,7 +279,7 @@ public class TileMimic extends TileInventory implements ITickable { dropMimicedTileInventory(); } - mimicedTile = getTileFromStackWithTag(worldObj, pos, getStackInSlot(0), tileTag, metaOfReplacedBlock); + mimicedTile = getTileFromStackWithTag(getWorld(), pos, getStackInSlot(0), tileTag, metaOfReplacedBlock); } @Override @@ -288,7 +290,7 @@ public class TileMimic extends TileInventory implements ITickable dropItemsOnBreak = tag.getBoolean("dropItemsOnBreak"); tileTag = tag.getCompoundTag("tileTag"); metaOfReplacedBlock = tag.getInteger("metaOfReplacedBlock"); - mimicedTile = getTileFromStackWithTag(worldObj, pos, getStackInSlot(0), tileTag, metaOfReplacedBlock); + mimicedTile = getTileFromStackWithTag(getWorld(), pos, getStackInSlot(0), tileTag, metaOfReplacedBlock); playerCheckRadius = tag.getInteger("playerCheckRadius"); potionSpawnRadius = tag.getInteger("potionSpawnRadius"); potionSpawnInterval = Math.max(1, tag.getInteger("potionSpawnInterval")); @@ -319,7 +321,7 @@ public class TileMimic extends TileInventory implements ITickable public static boolean replaceMimicWithBlockActual(World world, BlockPos pos, ItemStack stack, NBTTagCompound tileTag, int replacedMeta) { - if (stack != null && stack.getItem() instanceof ItemBlock) + if (!stack.isEmpty() && stack.getItem() instanceof ItemBlock) { Block block = ((ItemBlock) stack.getItem()).getBlock(); IBlockState state = block.getStateFromMeta(replacedMeta); @@ -341,9 +343,10 @@ public class TileMimic extends TileInventory implements ITickable return false; } - public static TileEntity getTileFromStackWithTag(World world, BlockPos pos, ItemStack stack, NBTTagCompound tag, int replacementMeta) + @Nullable + public static TileEntity getTileFromStackWithTag(World world, BlockPos pos, ItemStack stack, @Nullable NBTTagCompound tag, int replacementMeta) { - if (stack != null && stack.getItem() instanceof ItemBlock) + if (!stack.isEmpty() && stack.getItem() instanceof ItemBlock) { Block block = ((ItemBlock) stack.getItem()).getBlock(); IBlockState state = block.getStateFromMeta(stack.getItemDamage()); @@ -356,14 +359,14 @@ public class TileMimic extends TileInventory implements ITickable if (tag != null) { - NBTTagCompound copyTag = (NBTTagCompound) (tag.copy()); + NBTTagCompound copyTag = tag.copy(); copyTag.setInteger("x", pos.getX()); copyTag.setInteger("y", pos.getY()); copyTag.setInteger("z", pos.getZ()); tile.readFromNBT(copyTag); } - tile.setWorldObj(world); + tile.setWorld(world); try { @@ -396,7 +399,7 @@ public class TileMimic extends TileInventory implements ITickable public void dropMimicedTileInventory() { - if (!worldObj.isRemote && mimicedTile instanceof IInventory) + if (!getWorld().isRemote && mimicedTile instanceof IInventory) { InventoryHelper.dropInventoryItems(getWorld(), getPos(), (IInventory) mimicedTile); } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TilePhantomBlock.java b/src/main/java/WayofTime/bloodmagic/tile/TilePhantomBlock.java index 4c5b8f76..d495095b 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TilePhantomBlock.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TilePhantomBlock.java @@ -35,8 +35,8 @@ public class TilePhantomBlock extends TileTicking if (ticksRemaining <= 0) { - worldObj.setBlockToAir(getPos()); - worldObj.removeTileEntity(getPos()); + getWorld().setBlockToAir(getPos()); + getWorld().removeTileEntity(getPos()); } } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TilePurificationAltar.java b/src/main/java/WayofTime/bloodmagic/tile/TilePurificationAltar.java index 387f5562..f393ee0b 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TilePurificationAltar.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TilePurificationAltar.java @@ -33,7 +33,7 @@ public class TilePurificationAltar extends TileInventory implements ITickable if (totalPurity <= 0) { ItemStack stack = this.getStackInSlot(0); - if (stack != null && stack.getItem() instanceof IPurificationAsh) + if (!stack.isEmpty() && stack.getItem() instanceof IPurificationAsh) { totalPurity = ((IPurificationAsh) stack.getItem()).getTotalPurity(stack); maxPurity = ((IPurificationAsh) stack.getItem()).getMaxPurity(stack); @@ -45,7 +45,7 @@ public class TilePurificationAltar extends TileInventory implements ITickable } AxisAlignedBB aabb = purityArea.getAABB(getPos()); - List animalList = worldObj.getEntitiesWithinAABB(EntityAnimal.class, aabb); + List animalList = getWorld().getEntitiesWithinAABB(EntityAnimal.class, aabb); if (animalList.isEmpty()) { return; @@ -65,9 +65,9 @@ public class TilePurificationAltar extends TileInventory implements ITickable if (hasPerformed) { - if (worldObj.rand.nextInt(4) == 0 && worldObj instanceof WorldServer) + if (getWorld().rand.nextInt(4) == 0 && getWorld() instanceof WorldServer) { - WorldServer server = (WorldServer) worldObj; + WorldServer server = (WorldServer) getWorld(); server.spawnParticle(EnumParticleTypes.FLAME, pos.getX() + 0.5, pos.getY() + 1.2, pos.getZ() + 0.5, 1, 0.02, 0.03, 0.02, 0, new int[0]); } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java b/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java index 183f8516..a99b696c 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java @@ -52,22 +52,22 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil @Override public void update() { - if (!worldObj.isRemote) + if (!getWorld().isRemote) { for (EnumDemonWillType type : EnumDemonWillType.values()) { - double willInWorld = WorldDemonWillHandler.getCurrentWill(worldObj, pos, type); + double willInWorld = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); double filled = Math.min(willInWorld, worldWillTransferRate); if (filled > 0) { filled = this.fillDemonWill(type, filled, false); - filled = WorldDemonWillHandler.drainWill(worldObj, pos, type, filled, false); + filled = WorldDemonWillHandler.drainWill(getWorld(), pos, type, filled, false); if (filled > 0) { this.fillDemonWill(type, filled, true); - WorldDemonWillHandler.drainWill(worldObj, pos, type, filled, true); + WorldDemonWillHandler.drainWill(getWorld(), pos, type, filled, true); } } } @@ -85,7 +85,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil for (int i = 0; i < 4; i++) { - if (getStackInSlot(i) != null) + if (!getStackInSlot(i).isEmpty()) { inputList.add(getStackInSlot(i)); } @@ -100,18 +100,18 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil if (burnTime == ticksRequired) { - if (!worldObj.isRemote) + if (!getWorld().isRemote) { double requiredSouls = recipe.getSoulsDrained(); if (requiredSouls > 0) { - if (!worldObj.isRemote && soulsInGem >= recipe.getMinimumSouls()) + if (!getWorld().isRemote && soulsInGem >= recipe.getMinimumSouls()) { consumeSouls(EnumDemonWillType.DEFAULT, requiredSouls); } } - if (!worldObj.isRemote && soulsInGem >= recipe.getMinimumSouls()) + if (!getWorld().isRemote && soulsInGem >= recipe.getMinimumSouls()) craftItem(recipe); } @@ -144,13 +144,13 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil ItemStack outputStack = recipe.getRecipeOutput(); ItemStack currentOutputStack = getStackInSlot(outputSlot); - if (outputStack == null) + if (outputStack.isEmpty()) return false; - if (currentOutputStack == null) + if (currentOutputStack.isEmpty()) return true; if (!currentOutputStack.isItemEqual(outputStack)) return false; - int result = currentOutputStack.stackSize + outputStack.stackSize; + int result = currentOutputStack.getCount() + outputStack.getCount(); return result <= getInventoryStackLimit() && result <= currentOutputStack.getMaxStackSize(); } @@ -162,12 +162,12 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil ItemStack outputStack = recipe.getRecipeOutput(); ItemStack currentOutputStack = getStackInSlot(outputSlot); - if (currentOutputStack == null) + if (currentOutputStack.isEmpty()) { setInventorySlotContents(outputSlot, outputStack); } else if (currentOutputStack.getItem() == currentOutputStack.getItem()) { - currentOutputStack.stackSize += outputStack.stackSize; + currentOutputStack.grow(outputStack.getCount()); } consumeInventory(); @@ -178,7 +178,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil { ItemStack soulStack = getStackInSlot(soulSlot); - if (soulStack != null) + if (!soulStack.isEmpty()) { if (soulStack.getItem() instanceof IDemonWill || soulStack.getItem() instanceof IDemonWillGem) { @@ -243,7 +243,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil for (int i = 0; i < 4; i++) { ItemStack inputStack = getStackInSlot(i); - if (inputStack != null) + if (!inputStack.isEmpty()) { if (inputStack.getItem().hasContainerItem(inputStack)) { @@ -251,11 +251,10 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil continue; } - inputStack.stackSize--; - if (inputStack.stackSize <= 0) + inputStack.shrink(1); + if (inputStack.isEmpty()) { - setInventorySlotContents(i, null); - continue; + setInventorySlotContents(i, ItemStack.EMPTY); } } } @@ -281,23 +280,20 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil } ItemStack stack = this.getStackInSlot(soulSlot); - if (stack == null || !(stack.getItem() instanceof IDemonWillGem)) + if (stack.isEmpty() || !(stack.getItem() instanceof IDemonWillGem)) { return 0; } IDemonWillGem willGem = (IDemonWillGem) stack.getItem(); - - double filled = willGem.fillWill(type, stack, amount, doFill); - - return filled; + return willGem.fillWill(type, stack, amount, doFill); } @Override public double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain) { ItemStack stack = this.getStackInSlot(soulSlot); - if (stack == null || !(stack.getItem() instanceof IDemonWillGem)) + if (stack.isEmpty() || !(stack.getItem() instanceof IDemonWillGem)) { return 0; } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileSpectralBlock.java b/src/main/java/WayofTime/bloodmagic/tile/TileSpectralBlock.java index c8eafe62..22c48fef 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileSpectralBlock.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileSpectralBlock.java @@ -42,7 +42,7 @@ public class TileSpectralBlock extends TileTicking @Override public void onUpdate() { - if (worldObj.isRemote) + if (getWorld().isRemote) { return; } @@ -79,7 +79,7 @@ public class TileSpectralBlock extends TileTicking if (!Strings.isNullOrEmpty(containedBlockName)) block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(containedBlockName)); - if (block != null && worldObj.setBlockState(pos, block.getStateFromMeta(containedBlockMeta))) + if (block != null && getWorld().setBlockState(pos, block.getStateFromMeta(containedBlockMeta))) getWorld().notifyBlockUpdate(getPos(), getWorld().getBlockState(getPos()), getWorld().getBlockState(getPos()), 3); } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileTeleposer.java b/src/main/java/WayofTime/bloodmagic/tile/TileTeleposer.java index fc016bb3..625eeb8e 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileTeleposer.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileTeleposer.java @@ -52,9 +52,9 @@ public class TileTeleposer extends TileInventory implements ITickable @Override public void update() { - if (!worldObj.isRemote) + if (!getWorld().isRemote) { - int currentInput = worldObj.getStrongPower(pos); + int currentInput = getWorld().getStrongPower(pos); if (previousInput == 0 && currentInput != 0) { @@ -67,17 +67,16 @@ public class TileTeleposer extends TileInventory implements ITickable public void initiateTeleport() { - if (!worldObj.isRemote && worldObj.getTileEntity(pos) != null && worldObj.getTileEntity(pos) instanceof TileTeleposer && canInitiateTeleport((TileTeleposer) worldObj.getTileEntity(pos)) && worldObj.getBlockState(pos).getBlock() instanceof BlockTeleposer) + if (!getWorld().isRemote && canInitiateTeleport(this) && getBlockType() instanceof BlockTeleposer) { - TileTeleposer teleposer = (TileTeleposer) worldObj.getTileEntity(pos); - ItemStack focusStack = NBTHelper.checkNBT(teleposer.getStackInSlot(0)); + ItemStack focusStack = NBTHelper.checkNBT(getStackInSlot(0)); ItemTelepositionFocus focus = (ItemTelepositionFocus) focusStack.getItem(); - BlockPos focusPos = focus.getBlockPos(teleposer.getStackInSlot(0)); - World focusWorld = focus.getWorld(teleposer.getStackInSlot(0)); + BlockPos focusPos = focus.getBlockPos(getStackInSlot(0)); + World focusWorld = focus.getWorld(getStackInSlot(0)); if (focusWorld != null && focusWorld.getTileEntity(focusPos) instanceof TileTeleposer && !focusWorld.getTileEntity(focusPos).equals(this)) { - final int focusLevel = (teleposer.getStackInSlot(0).getItemDamage() + 1); + final int focusLevel = (getStackInSlot(0).getItemDamage() + 1); final int lpToBeDrained = (int) (0.5F * Math.sqrt((pos.getX() - focusPos.getX()) * (pos.getX() - focusPos.getX()) + (pos.getY() - focusPos.getY() + 1) * (pos.getY() - focusPos.getY() + 1) + (pos.getZ() - focusPos.getZ()) * (pos.getZ() - focusPos.getZ()))); if (NetworkHelper.getSoulNetwork(focus.getOwnerUUID(focusStack)).syphonAndDamage(PlayerHelper.getPlayerFromUUID(focus.getOwnerUUID(focusStack)), lpToBeDrained * (focusLevel * 2 - 1) * (focusLevel * 2 - 1) * (focusLevel * 2 - 1))) @@ -90,7 +89,7 @@ public class TileTeleposer extends TileInventory implements ITickable { for (int k = -(focusLevel - 1); k <= (focusLevel - 1); k++) { - TeleposeEvent event = new TeleposeEvent(worldObj, pos.add(i, 1 + j, k), focusWorld, focusPos.add(i, 1 + j, k)); + TeleposeEvent event = new TeleposeEvent(getWorld(), pos.add(i, 1 + j, k), focusWorld, focusPos.add(i, 1 + j, k)); if (Utils.swapLocations(event.initalWorld, event.initialBlockPos, event.finalWorld, event.finalBlockPos) && !MinecraftForge.EVENT_BUS.post(event)) { blocksTransported++; @@ -104,11 +103,11 @@ public class TileTeleposer extends TileInventory implements ITickable List originalWorldEntities; List focusWorldEntities; AxisAlignedBB originalArea = new AxisAlignedBB(pos.getX(), pos.getY() + 1, pos.getZ(), pos.getX() + 1, Math.min(focusWorld.getHeight(), pos.getY() + 2 * focusLevel), pos.getZ() + 1).expand(focusLevel - 1, 0, focusLevel - 1); - originalWorldEntities = worldObj.getEntitiesWithinAABB(Entity.class, originalArea); + originalWorldEntities = getWorld().getEntitiesWithinAABB(Entity.class, originalArea); AxisAlignedBB focusArea = new AxisAlignedBB(focusPos.getX(), focusPos.getY() + 1, focusPos.getZ(), focusPos.getX() + 1, Math.min(focusWorld.getHeight(), focusPos.getY() + 2 * focusLevel), focusPos.getZ() + 1).expand(focusLevel - 1, 0, focusLevel - 1); focusWorldEntities = focusWorld.getEntitiesWithinAABB(Entity.class, focusArea); - if (focusWorld.equals(worldObj)) + if (focusWorld.equals(getWorld())) { if (!originalWorldEntities.isEmpty()) { @@ -131,7 +130,7 @@ public class TileTeleposer extends TileInventory implements ITickable { for (Entity entity : originalWorldEntities) { - TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(new BlockPos(entity.posX - pos.getX() + focusPos.getX(), entity.posY - pos.getY() + focusPos.getY(), entity.posZ - pos.getZ() + focusPos.getZ()), entity, focusStack.getTagCompound().getString(Constants.NBT.OWNER_UUID), worldObj, focusWorld.provider.getDimension(), true)); + TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(new BlockPos(entity.posX - pos.getX() + focusPos.getX(), entity.posY - pos.getY() + focusPos.getY(), entity.posZ - pos.getZ() + focusPos.getZ()), entity, focusStack.getTagCompound().getString(Constants.NBT.OWNER_UUID), getWorld(), focusWorld.provider.getDimension(), true)); } } @@ -139,7 +138,7 @@ public class TileTeleposer extends TileInventory implements ITickable { for (Entity entity : focusWorldEntities) { - TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(new BlockPos(entity.posX - pos.getX() + focusPos.getX(), entity.posY - pos.getY() + focusPos.getY(), entity.posZ - pos.getZ() + focusPos.getZ()), entity, focusStack.getTagCompound().getString(Constants.NBT.OWNER_UUID), focusWorld, worldObj.provider.getDimension(), true)); + TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(new BlockPos(entity.posX - pos.getX() + focusPos.getX(), entity.posY - pos.getY() + focusPos.getY(), entity.posZ - pos.getZ() + focusPos.getZ()), entity, focusStack.getTagCompound().getString(Constants.NBT.OWNER_UUID), focusWorld, getWorld().provider.getDimension(), true)); } } } @@ -150,6 +149,6 @@ public class TileTeleposer extends TileInventory implements ITickable private boolean canInitiateTeleport(TileTeleposer teleposer) { - return teleposer.getStackInSlot(0) != null && teleposer.getStackInSlot(0).getItem() instanceof ItemTelepositionFocus && !Strings.isNullOrEmpty(((ItemTelepositionFocus) teleposer.getStackInSlot(0).getItem()).getOwnerName(teleposer.getStackInSlot(0))); + return !teleposer.getStackInSlot(0).isEmpty() && teleposer.getStackInSlot(0).getItem() instanceof ItemTelepositionFocus && !Strings.isNullOrEmpty(((ItemTelepositionFocus) teleposer.getStackInSlot(0).getItem()).getOwnerName(teleposer.getStackInSlot(0))); } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerAlchemyTable.java b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerAlchemyTable.java index 79e2923d..4cf8c221 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerAlchemyTable.java +++ b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerAlchemyTable.java @@ -49,7 +49,7 @@ public class ContainerAlchemyTable extends Container if (slotId < 6 && slotId >= 0) { Slot slot = this.getSlot(slotId); - if (!slot.getHasStack() && inventoryPlayer.getItemStack() == null) + if (!slot.getHasStack() && inventoryPlayer.getItemStack().isEmpty()) { ((TileAlchemyTable) tileTable).toggleInputSlotAccessible(slotId); } @@ -61,7 +61,7 @@ public class ContainerAlchemyTable extends Container @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { - ItemStack itemstack = null; + ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) @@ -73,7 +73,7 @@ public class ContainerAlchemyTable extends Container { if (!this.mergeItemStack(itemstack1, 9, 9 + 36, true)) { - return null; + return ItemStack.EMPTY; } slot.onSlotChange(itemstack1, itemstack); @@ -83,31 +83,31 @@ public class ContainerAlchemyTable extends Container { if (!this.mergeItemStack(itemstack1, 7, 8, false)) //TODO: Add alchemy tools to list { - return null; + return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 0, 6, false)) { - return null; + return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 9, 9 + 36, false)) { - return null; + return ItemStack.EMPTY; } - if (itemstack1.stackSize == 0) + if (itemstack1.getCount() == 0) { - slot.putStack(null); + slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } - if (itemstack1.stackSize == itemstack.stackSize) + if (itemstack1.getCount() == itemstack.getCount()) { - return null; + return ItemStack.EMPTY; } - slot.onPickupFromSlot(playerIn, itemstack1); + slot.onTake(playerIn, itemstack1); } return itemstack; @@ -116,7 +116,7 @@ public class ContainerAlchemyTable extends Container @Override public boolean canInteractWith(EntityPlayer playerIn) { - return this.tileTable.isUseableByPlayer(playerIn); + return this.tileTable.isUsableByPlayer(playerIn); } private class SlotOrb extends Slot diff --git a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerItemRoutingNode.java b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerItemRoutingNode.java index c422d24c..be325890 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerItemRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerItemRoutingNode.java @@ -98,7 +98,7 @@ public class ContainerItemRoutingNode extends Container ItemStack copyStack = heldStack.copy(); GhostItemHelper.setItemGhostAmount(copyStack, 0); - copyStack.stackSize = 1; + copyStack.setCount(1); slot.putStack(copyStack); } } @@ -124,7 +124,7 @@ public class ContainerItemRoutingNode extends Container @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { - ItemStack itemstack = null; + ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) @@ -136,7 +136,7 @@ public class ContainerItemRoutingNode extends Container { if (!this.mergeItemStack(itemstack1, slotsOccupied, slotsOccupied + 36, true)) { - return null; + return ItemStack.EMPTY; } slot.onSlotChange(itemstack1, itemstack); @@ -147,28 +147,28 @@ public class ContainerItemRoutingNode extends Container { if (!this.mergeItemStack(itemstack1, 0, 1, false)) { - return null; + return ItemStack.EMPTY; } } - } else if (!this.mergeItemStack(itemstack1, 0 + slotsOccupied, 36 + slotsOccupied, false)) + } else if (!this.mergeItemStack(itemstack1, slotsOccupied, 36 + slotsOccupied, false)) { - return null; + return ItemStack.EMPTY; } - if (itemstack1.stackSize == 0) + if (itemstack1.getCount() == 0) { - slot.putStack(null); + slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } - if (itemstack1.stackSize == itemstack.stackSize) + if (itemstack1.getCount() == itemstack.getCount()) { - return null; + return ItemStack.EMPTY; } - slot.onPickupFromSlot(playerIn, itemstack1); + slot.onTake(playerIn, itemstack1); } return itemstack; @@ -177,7 +177,7 @@ public class ContainerItemRoutingNode extends Container @Override public boolean canInteractWith(EntityPlayer playerIn) { - return this.tileItemRoutingNode.isUseableByPlayer(playerIn); + return this.tileItemRoutingNode.isUsableByPlayer(playerIn); } private class SlotItemFilter extends Slot diff --git a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerMasterRoutingNode.java b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerMasterRoutingNode.java index 77121ecf..64cd4de9 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerMasterRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerMasterRoutingNode.java @@ -18,6 +18,6 @@ public class ContainerMasterRoutingNode extends Container @Override public boolean canInteractWith(EntityPlayer playerIn) { - return this.tileMasterRoutingNode.isUseableByPlayer(playerIn); + return this.tileMasterRoutingNode.isUsableByPlayer(playerIn); } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerSoulForge.java b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerSoulForge.java index 85497373..ecf995d3 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerSoulForge.java +++ b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerSoulForge.java @@ -41,7 +41,7 @@ public class ContainerSoulForge extends Container @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { - ItemStack itemstack = null; + ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) @@ -53,7 +53,7 @@ public class ContainerSoulForge extends Container { if (!this.mergeItemStack(itemstack1, 6, 6 + 36, true)) { - return null; + return ItemStack.EMPTY; } slot.onSlotChange(itemstack1, itemstack); @@ -63,31 +63,31 @@ public class ContainerSoulForge extends Container { if (!this.mergeItemStack(itemstack1, 4, 5, false)) { - return null; + return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 0, 4, false)) { - return null; + return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 6, 42, false)) { - return null; + return ItemStack.EMPTY; } - if (itemstack1.stackSize == 0) + if (itemstack1.getCount() == 0) { - slot.putStack(null); + slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } - if (itemstack1.stackSize == itemstack.stackSize) + if (itemstack1.getCount() == itemstack.getCount()) { - return null; + return ItemStack.EMPTY; } - slot.onPickupFromSlot(playerIn, itemstack1); + slot.onTake(playerIn, itemstack1); } return itemstack; @@ -96,7 +96,7 @@ public class ContainerSoulForge extends Container @Override public boolean canInteractWith(EntityPlayer playerIn) { - return this.tileForge.isUseableByPlayer(playerIn); + return this.tileForge.isUsableByPlayer(playerIn); } private class SlotSoul extends Slot diff --git a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerTeleposer.java b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerTeleposer.java index 2b3e93eb..163361a0 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerTeleposer.java +++ b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerTeleposer.java @@ -34,7 +34,7 @@ public class ContainerTeleposer extends Container @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - ItemStack stack = null; + ItemStack stack = ItemStack.EMPTY; Slot slotObject = inventorySlots.get(slot); int slots = inventorySlots.size(); @@ -49,28 +49,28 @@ public class ContainerTeleposer extends Container { if (!this.mergeItemStack(stackInSlot, 0, slots, false)) { - return null; + return ItemStack.EMPTY; } } else if (!this.mergeItemStack(stackInSlot, slots, 36 + slots, false)) { - return null; + return ItemStack.EMPTY; } } - if (stackInSlot.stackSize == 0) + if (stackInSlot.getCount() == 0) { - slotObject.putStack(null); + slotObject.putStack(ItemStack.EMPTY); } else { slotObject.onSlotChanged(); } - if (stackInSlot.stackSize == stack.stackSize) + if (stackInSlot.getCount() == stack.getCount()) { - return null; + return ItemStack.EMPTY; } - slotObject.onPickupFromSlot(player, stackInSlot); + slotObject.onTake(player, stackInSlot); } return stack; @@ -79,7 +79,7 @@ public class ContainerTeleposer extends Container @Override public boolean canInteractWith(EntityPlayer playerIn) { - return this.tileTeleposer.isUseableByPlayer(playerIn); + return this.tileTeleposer.isUsableByPlayer(playerIn); } private class SlotTeleposer extends Slot diff --git a/src/main/java/WayofTime/bloodmagic/tile/routing/TileFilteredRoutingNode.java b/src/main/java/WayofTime/bloodmagic/tile/routing/TileFilteredRoutingNode.java index a6ae7453..ba4ac2be 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/routing/TileFilteredRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/routing/TileFilteredRoutingNode.java @@ -32,7 +32,7 @@ public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedIn public void setGhostItemAmount(int ghostItemSlot, int amount) { ItemStack stack = itemInventory.getStackInSlot(ghostItemSlot); - if (stack != null) + if (!stack.isEmpty()) { GhostItemHelper.setItemGhostAmount(stack, amount); } @@ -70,10 +70,10 @@ public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedIn if (j == 0) { - inventory[currentActiveSlot] = ItemStack.loadItemStackFromNBT(data); + inventory[currentActiveSlot] = new ItemStack(data); } else if (j >= 1 && j < inventory.length + 1) { - inventory[j - 1] = ItemStack.loadItemStackFromNBT(data); + inventory[j - 1] = new ItemStack(data); } } } @@ -126,14 +126,14 @@ public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedIn public void incrementCurrentPriotiryToMaximum(int max) { priorities[currentActiveSlot] = Math.min(priorities[currentActiveSlot] + 1, max); - IBlockState state = worldObj.getBlockState(pos); - worldObj.notifyBlockUpdate(pos, state, state, 3); + IBlockState state = getWorld().getBlockState(pos); + getWorld().notifyBlockUpdate(pos, state, state, 3); } public void decrementCurrentPriority() { priorities[currentActiveSlot] = Math.max(priorities[currentActiveSlot] - 1, 0); - IBlockState state = worldObj.getBlockState(pos); - worldObj.notifyBlockUpdate(pos, state, state, 3); + IBlockState state = getWorld().getBlockState(pos); + getWorld().notifyBlockUpdate(pos, state, state, 3); } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/routing/TileInputRoutingNode.java b/src/main/java/WayofTime/bloodmagic/tile/routing/TileInputRoutingNode.java index 3ac56f0b..a4df1665 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/routing/TileInputRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/routing/TileInputRoutingNode.java @@ -26,7 +26,7 @@ public class TileInputRoutingNode extends TileFilteredRoutingNode implements IIn @Override public IItemFilter getInputFilterForSide(EnumFacing side) { - TileEntity tile = worldObj.getTileEntity(pos.offset(side)); + TileEntity tile = getWorld().getTileEntity(pos.offset(side)); if (tile != null) { IItemHandler handler = Utils.getInventory(tile, side.getOpposite()); @@ -34,7 +34,7 @@ public class TileInputRoutingNode extends TileFilteredRoutingNode implements IIn { ItemStack filterStack = this.getFilterStack(side); - if (filterStack == null || !(filterStack.getItem() instanceof IItemFilterProvider)) + if (filterStack.isEmpty() || !(filterStack.getItem() instanceof IItemFilterProvider)) { IItemFilter filter = new DefaultItemFilter(); filter.initializeFilter(null, tile, handler, false); diff --git a/src/main/java/WayofTime/bloodmagic/tile/routing/TileMasterRoutingNode.java b/src/main/java/WayofTime/bloodmagic/tile/routing/TileMasterRoutingNode.java index 0bebb147..074e9117 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/routing/TileMasterRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/routing/TileMasterRoutingNode.java @@ -45,15 +45,15 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti @Override public void update() { - if (!worldObj.isRemote) + if (!getWorld().isRemote) { -// currentInput = worldObj.isBlockIndirectlyGettingPowered(pos); - currentInput = worldObj.getStrongPower(pos); +// currentInput = getWorld().isBlockIndirectlyGettingPowered(pos); + currentInput = getWorld().getStrongPower(pos); // System.out.println(currentInput); } - if (worldObj.isRemote || worldObj.getTotalWorldTime() % tickRate != 0) //Temporary tick rate solver + if (getWorld().isRemote || getWorld().getTotalWorldTime() % tickRate != 0) //Temporary tick rate solver { return; } @@ -62,7 +62,7 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti for (BlockPos outputPos : outputNodeList) { - TileEntity outputTile = worldObj.getTileEntity(outputPos); + TileEntity outputTile = getWorld().getTileEntity(outputPos); if (outputTile instanceof IOutputItemRoutingNode && this.isConnected(new LinkedList(), outputPos)) { IOutputItemRoutingNode outputNode = (IOutputItemRoutingNode) outputTile; @@ -96,7 +96,7 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti for (BlockPos inputPos : inputNodeList) { - TileEntity inputTile = worldObj.getTileEntity(inputPos); + TileEntity inputTile = getWorld().getTileEntity(inputPos); if (inputTile instanceof IInputItemRoutingNode && this.isConnected(new LinkedList(), inputPos)) { IInputItemRoutingNode inputNode = (IInputItemRoutingNode) inputTile; @@ -126,7 +126,7 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } } - int maxTransfer = this.getMaxTransferForDemonWill(WorldDemonWillHandler.getCurrentWill(worldObj, pos, EnumDemonWillType.DEFAULT)); + int maxTransfer = this.getMaxTransferForDemonWill(WorldDemonWillHandler.getCurrentWill(getWorld(), pos, EnumDemonWillType.DEFAULT)); for (Entry> outputEntry : outputMap.entrySet()) { @@ -231,7 +231,7 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti // { // return false; // } - TileEntity tile = worldObj.getTileEntity(nodePos); + TileEntity tile = getWorld().getTileEntity(nodePos); if (!(tile instanceof IRoutingNode)) { // connectionMap.remove(nodePos); @@ -254,7 +254,7 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti // path.clear(); // path.addAll(testPath); return true; - } else if (NodeHelper.isNodeConnectionEnabled(worldObj, node, testPos)) + } else if (NodeHelper.isNodeConnectionEnabled(getWorld(), node, testPos)) { if (isConnected(path, testPos)) { @@ -401,7 +401,7 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti while (itr.hasNext()) { BlockPos testPos = itr.next(); - TileEntity tile = worldObj.getTileEntity(testPos); + TileEntity tile = getWorld().getTileEntity(testPos); if (tile instanceof IRoutingNode) { ((IRoutingNode) tile).removeConnection(pos); diff --git a/src/main/java/WayofTime/bloodmagic/tile/routing/TileOutputRoutingNode.java b/src/main/java/WayofTime/bloodmagic/tile/routing/TileOutputRoutingNode.java index a538eebb..135a8a0d 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/routing/TileOutputRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/routing/TileOutputRoutingNode.java @@ -26,7 +26,7 @@ public class TileOutputRoutingNode extends TileFilteredRoutingNode implements IO @Override public IItemFilter getOutputFilterForSide(EnumFacing side) { - TileEntity tile = worldObj.getTileEntity(pos.offset(side)); + TileEntity tile = getWorld().getTileEntity(pos.offset(side)); if (tile != null) { IItemHandler handler = Utils.getInventory(tile, side.getOpposite()); @@ -34,7 +34,7 @@ public class TileOutputRoutingNode extends TileFilteredRoutingNode implements IO { ItemStack filterStack = this.getFilterStack(side); - if (filterStack == null || !(filterStack.getItem() instanceof IItemFilterProvider)) + if (filterStack.isEmpty() || !(filterStack.getItem() instanceof IItemFilterProvider)) { IItemFilter filter = new DefaultItemFilter(); filter.initializeFilter(null, tile, handler, true); diff --git a/src/main/java/WayofTime/bloodmagic/tile/routing/TileRoutingNode.java b/src/main/java/WayofTime/bloodmagic/tile/routing/TileRoutingNode.java index 2dfadd98..ac00e276 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/routing/TileRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/routing/TileRoutingNode.java @@ -30,10 +30,10 @@ public class TileRoutingNode extends TileInventory implements IRoutingNode, IIte @Override public void update() { - if (!worldObj.isRemote) + if (!getWorld().isRemote) { - currentInput = worldObj.isBlockIndirectlyGettingPowered(pos); -// currentInput = worldObj.getStrongPower(pos); + currentInput = getWorld().isBlockIndirectlyGettingPowered(pos); +// currentInput = getWorld().getStrongPower(pos); } } @@ -83,14 +83,14 @@ public class TileRoutingNode extends TileInventory implements IRoutingNode, IIte @Override public void removeAllConnections() { - TileEntity testTile = worldObj.getTileEntity(getMasterPos()); + TileEntity testTile = getWorld().getTileEntity(getMasterPos()); if (testTile instanceof IMasterRoutingNode) { ((IMasterRoutingNode) testTile).removeConnection(pos); // Remove this node from the master } for (BlockPos testPos : connectionList) { - TileEntity tile = worldObj.getTileEntity(testPos); + TileEntity tile = getWorld().getTileEntity(testPos); if (tile instanceof IRoutingNode) { ((IRoutingNode) tile).removeConnection(pos); diff --git a/src/main/java/WayofTime/bloodmagic/util/ChatUtil.java b/src/main/java/WayofTime/bloodmagic/util/ChatUtil.java index d3b022e4..100d5b30 100644 --- a/src/main/java/WayofTime/bloodmagic/util/ChatUtil.java +++ b/src/main/java/WayofTime/bloodmagic/util/ChatUtil.java @@ -110,7 +110,7 @@ public class ChatUtil { for (ITextComponent c : lines) { - player.addChatComponentMessage(c); + player.sendMessage(c); } } diff --git a/src/main/java/WayofTime/bloodmagic/util/GhostItemHelper.java b/src/main/java/WayofTime/bloodmagic/util/GhostItemHelper.java index 4b899b49..f70598e6 100644 --- a/src/main/java/WayofTime/bloodmagic/util/GhostItemHelper.java +++ b/src/main/java/WayofTime/bloodmagic/util/GhostItemHelper.java @@ -59,7 +59,7 @@ public class GhostItemHelper { newStack.setTagCompound(null); } - newStack.stackSize = amount; + newStack.setCount(amount); return newStack; } diff --git a/src/main/java/WayofTime/bloodmagic/util/Utils.java b/src/main/java/WayofTime/bloodmagic/util/Utils.java index 5d3e89d6..1c3c383d 100644 --- a/src/main/java/WayofTime/bloodmagic/util/Utils.java +++ b/src/main/java/WayofTime/bloodmagic/util/Utils.java @@ -46,9 +46,13 @@ import net.minecraftforge.common.ISpecialArmor.ArmorProperties; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fml.common.discovery.ASMDataTable; +import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.wrapper.InvWrapper; +import net.minecraftforge.items.wrapper.PlayerInvWrapper; +import net.minecraftforge.items.wrapper.PlayerMainInvWrapper; import net.minecraftforge.items.wrapper.SidedInvWrapper; import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.BlockStack; @@ -86,32 +90,6 @@ public class Utils return added; } - public static Item getItem(ResourceLocation resource) - { - return Item.REGISTRY.getObject(resource); - } - - public static Block getBlock(ResourceLocation resource) - { - return Block.REGISTRY.getObject(resource); - } - - public static ResourceLocation getResourceForItem(ItemStack stack) - { - if (stack != null) - { - if (stack.getItem() instanceof ItemBlock) - { - return Block.REGISTRY.getNameForObject(((ItemBlock) stack.getItem()).getBlock()); - } else - { - return Item.REGISTRY.getNameForObject(stack.getItem()); - } - } - - return null; - } - public static boolean isImmuneToFireDamage(EntityLivingBase entity) { return entity.isImmuneToFire() || entity.isPotionActive(MobEffects.FIRE_RESISTANCE); @@ -119,7 +97,7 @@ public class Utils public static boolean isPlayerBesideSolidBlockFace(EntityPlayer player) { - World world = player.worldObj; + World world = player.getEntityWorld(); double minimumDistanceFromAxis = 0.7; BlockPos centralPos = player.getPosition(); for (EnumFacing facing : EnumFacing.HORIZONTALS) @@ -142,16 +120,17 @@ public class Utils public static boolean canPlayerSeeDemonWill(EntityPlayer player) { - ItemStack[] mainInventory = player.inventory.mainInventory; + IItemHandler inventory = new PlayerMainInvWrapper(player.inventory); - for (ItemStack stack : mainInventory) + for (int i = 0; i < inventory.getSlots(); i++) { - if (stack == null) + ItemStack stack = inventory.getStackInSlot(i); + if (stack.isEmpty()) { continue; } - if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.worldObj, stack, player)) + if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.getEntityWorld(), stack, player)) { return true; } @@ -165,12 +144,7 @@ public class Utils Vec3d relativePosition = new Vec3d(entity.posX - pos.getX() - 0.5, entity.posY + (double) entity.getEyeHeight() - pos.getY() - 0.5, entity.posZ - pos.getZ() - 0.5); EnumFacing dir = EnumFacing.getFacingFromVector((float) relativePosition.xCoord, (float) relativePosition.yCoord, (float) relativePosition.zCoord); RayTraceResult result = world.rayTraceBlocks(new Vec3d(entity.posX, entity.posY + (double) entity.getEyeHeight(), entity.posZ), new Vec3d(pos.getX() + 0.5 + dir.getFrontOffsetX() * 0.4, pos.getY() + 0.5 + dir.getFrontOffsetY() * 0.4, pos.getZ() + 0.5 + dir.getFrontOffsetZ() * 0.4), false, true, true); - if (result != null) - { - return pos.equals(result.getBlockPos()); - } - - return result != null; + return result == null || pos.equals(result.getBlockPos()); } public static int plantSeedsInArea(World world, AxisAlignedBB aabb, int horizontalRadius, int verticalRadius) @@ -188,7 +162,7 @@ public class Utils public static int plantItemStack(World world, BlockPos centralPos, ItemStack stack, int horizontalRadius, int verticalRadius) { - if (stack == null || stack.stackSize <= 0) + if (stack.isEmpty()) { return 0; } @@ -226,9 +200,9 @@ public class Utils IBlockState plantState = ((IPlantable) item).getPlant(world, newPos); world.setBlockState(newPos, plantState, 3); world.playEvent(2001, newPos, Block.getIdFromBlock(plantState.getBlock()) + (plantState.getBlock().getMetaFromState(plantState) << 12)); - stack.stackSize--; + stack.shrink(1); planted++; - if (stack.stackSize <= 0) + if (stack.isEmpty() || stack.getCount() <= 0) { return planted; } @@ -250,13 +224,13 @@ public class Utils return 0; } - World world = itemEntity.worldObj; + World world = itemEntity.getEntityWorld(); BlockPos pos = itemEntity.getPosition(); ItemStack stack = itemEntity.getEntityItem(); int planted = plantItemStack(world, pos, stack, horizontalRadius, verticalRadius); - if (stack.stackSize <= 0) + if (stack.isEmpty()) { itemEntity.setDead(); } @@ -266,18 +240,19 @@ public class Utils public static int getDemonWillResolution(EntityPlayer player) { - ItemStack[] mainInventory = player.inventory.mainInventory; + IItemHandler inventory = new PlayerMainInvWrapper(player.inventory); - for (ItemStack stack : mainInventory) + for (int i = 0; i < inventory.getSlots(); i++) { - if (stack == null) + ItemStack stack = inventory.getStackInSlot(i); + if (stack.isEmpty()) { continue; } - if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.worldObj, stack, player)) + if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.getEntityWorld(), stack, player)) { - return ((IDemonWillViewer) stack.getItem()).getDemonWillAuraResolution(player.worldObj, stack, player); + return ((IDemonWillViewer) stack.getItem()).getDemonWillAuraResolution(player.getEntityWorld(), stack, player); } } @@ -300,7 +275,7 @@ public class Utils public static void setPlayerSpeedFromServer(EntityPlayer player, double motionX, double motionY, double motionZ) { - if (!player.worldObj.isRemote && player instanceof EntityPlayerMP) + if (!player.getEntityWorld().isRemote && player instanceof EntityPlayerMP) { BloodMagicPacketHandler.sendTo(new PlayerVelocityPacketProcessor(motionX, motionY, motionZ), (EntityPlayerMP) player); } @@ -363,19 +338,19 @@ public class Utils */ public static boolean insertItemToTile(TileInventory tile, EntityPlayer player, int slot) { - if (tile.getStackInSlot(slot) == null && player.getHeldItemMainhand() != null) + if (tile.getStackInSlot(slot).isEmpty() && !player.getHeldItemMainhand().isEmpty()) { ItemStack input = player.getHeldItemMainhand().copy(); - input.stackSize = 1; - player.getHeldItemMainhand().stackSize--; + input.setCount(1); + player.getHeldItemMainhand().shrink(1); tile.setInventorySlotContents(slot, input); return true; - } else if (tile.getStackInSlot(slot) != null && player.getHeldItemMainhand() == null) + } else if (!tile.getStackInSlot(slot).isEmpty() && player.getHeldItemMainhand().isEmpty()) { if (!tile.getWorld().isRemote) { EntityItem invItem = new EntityItem(tile.getWorld(), player.posX, player.posY + 0.25, player.posZ, tile.getStackInSlot(slot)); - tile.getWorld().spawnEntityInWorld(invItem); + tile.getWorld().spawnEntity(invItem); } tile.clear(); return false; @@ -523,7 +498,7 @@ public class Utils return damage; } else { - if (attackedEntity.isPotionActive(resistance) && source != DamageSource.outOfWorld) + if (attackedEntity.isPotionActive(resistance) && source != DamageSource.OUT_OF_WORLD) { int i = (attackedEntity.getActivePotionEffect(resistance).getAmplifier() + 1) * 5; int j = 25 - i; @@ -564,20 +539,23 @@ public class Utils * @param stack2 * Slot content that stack1 is placed into * @return True if they can be combined + * @deprecated use {@link ItemHandlerHelper#canItemStacksStack(ItemStack, ItemStack)} */ + @Deprecated public static boolean canCombine(ItemStack stack1, ItemStack stack2) { - if (stack1 == null || stack1.isItemStackDamageable() ^ stack2.isItemStackDamageable()) - { - return false; - } - - if (stack2 == null) - { - return true; - } - - return stack1.getItem() == stack2.getItem() && stack1.getItemDamage() == stack2.getItemDamage() && ItemStack.areItemStackTagsEqual(stack1, stack2); + return ItemHandlerHelper.canItemStacksStack(stack1, stack2); +// if (stack1.isEmpty() || stack1.isItemStackDamageable() ^ stack2.isItemStackDamageable()) +// { +// return false; +// } +// +// if (stack2.isEmpty()) +// { +// return true; +// } +// +// return stack1.getItem() == stack2.getItem() && stack1.getItemDamage() == stack2.getItemDamage() && ItemStack.areItemStackTagsEqual(stack1, stack2); } /** @@ -591,18 +569,18 @@ public class Utils { ItemStack[] returned = new ItemStack[2]; - if (canCombine(stack1, stack2)) + if (ItemHandlerHelper.canItemStacksStack(stack1, stack2)) { - int transferedAmount = Math.min(transferMax, stack2 == null ? stack1.stackSize : Math.min(stack2.getMaxStackSize() - stack2.stackSize, stack1.stackSize)); + int transferedAmount = Math.min(transferMax, stack2.isEmpty() ? stack1.getCount() : Math.min(stack2.getMaxStackSize() - stack2.getCount(), stack1.getCount())); if (transferedAmount > 0) { ItemStack copyStack = stack1.splitStack(transferedAmount); - if (stack2 == null) + if (stack2.isEmpty()) { stack2 = copyStack; } else { - stack2.stackSize += transferedAmount; + stack2.grow(transferedAmount); } } } @@ -624,18 +602,18 @@ public class Utils { ItemStack[] returned = new ItemStack[2]; - if (canCombine(stack1, stack2)) + if (ItemHandlerHelper.canItemStacksStack(stack1, stack2)) { - int transferedAmount = stack2 == null ? stack1.stackSize : Math.min(stack2.getMaxStackSize() - stack2.stackSize, stack1.stackSize); + int transferedAmount = stack2.isEmpty() ? stack1.getCount() : Math.min(stack2.getMaxStackSize() - stack2.getCount(), stack1.getCount()); if (transferedAmount > 0) { ItemStack copyStack = stack1.splitStack(transferedAmount); - if (stack2 == null) + if (stack2.isEmpty()) { stack2 = copyStack; } else { - stack2.stackSize += transferedAmount; + stack2.grow(transferedAmount); } } } @@ -733,9 +711,9 @@ public class Utils { ItemStack invStack = handler.getStackInSlot(slot); - if (invStack != null && canCombine(stack, invStack)) + if (!invStack.isEmpty() && ItemHandlerHelper.canItemStacksStack(stack, invStack)) { - numberMatching += invStack.stackSize; + numberMatching += invStack.getCount(); } } @@ -749,23 +727,23 @@ public class Utils for (int slot = 0; slot < numberOfSlots; slot++) { ItemStack newCopyStack = copyStack.copy(); - newCopyStack.stackSize = Math.min(copyStack.stackSize, newLimit); + newCopyStack.setCount(Math.min(copyStack.getCount(), newLimit)); newCopyStack = handler.insertItem(slot, newCopyStack, false); - if (newCopyStack == null) + if (newCopyStack.isEmpty()) { - return null; + return ItemStack.EMPTY; } - newLimit -= (copyStack.stackSize - newCopyStack.stackSize); + newLimit -= (copyStack.getCount() - newCopyStack.getCount()); if (newLimit <= 0) { - return null; //TODO + return ItemStack.EMPTY; //TODO } - copyStack.stackSize -= (copyStack.stackSize - newCopyStack.stackSize); + copyStack.shrink(copyStack.getCount() - newCopyStack.getCount()); } return copyStack; @@ -779,9 +757,9 @@ public class Utils public static ItemStack insertStackIntoInventory(ItemStack stack, IInventory inventory, EnumFacing dir) { - if (stack == null) + if (stack.isEmpty()) { - return null; + return ItemStack.EMPTY; } boolean[] canBeInserted = new boolean[inventory.getSizeInventory()]; @@ -812,9 +790,9 @@ public class Utils stack = combinedStacks[0]; inventory.setInventorySlotContents(i, combinedStacks[1]); - if (stack.stackSize <= 0) + if (stack.isEmpty()) { - return stack; + return ItemStack.EMPTY; } } @@ -828,12 +806,12 @@ public class Utils public static boolean canInsertStackFullyIntoInventory(ItemStack stack, IInventory inventory, EnumFacing dir, boolean fillToLimit, int limit) { - if (stack == null) + if (stack.isEmpty()) { return true; } - int itemsLeft = stack.stackSize; + int itemsLeft = stack.getCount(); boolean[] canBeInserted = new boolean[inventory.getSizeInventory()]; @@ -865,14 +843,14 @@ public class Utils ItemStack invStack = inventory.getStackInSlot(i); - if (invStack != null && canCombine(stack, invStack)) + if (!invStack.isEmpty() && ItemHandlerHelper.canItemStacksStack(stack, invStack)) { - numberMatching += invStack.stackSize; + numberMatching += invStack.getCount(); } } } - if (fillToLimit && limit < stack.stackSize + numberMatching) + if (fillToLimit && limit < stack.getCount() + numberMatching) { return false; } @@ -888,12 +866,12 @@ public class Utils boolean canCombine = canCombine(stack, invStack); if (canCombine) { - if (invStack == null) + if (invStack.isEmpty()) { itemsLeft = 0; } else { - itemsLeft -= (invStack.getMaxStackSize() - invStack.stackSize); + itemsLeft -= (invStack.getMaxStackSize() - invStack.getCount()); } } @@ -918,9 +896,9 @@ public class Utils */ public static ItemStack insertStackIntoInventory(ItemStack stack, IInventory inventory, EnumFacing dir, int limit) { - if (stack == null) + if (stack.isEmpty()) { - return null; + return ItemStack.EMPTY; } boolean[] canBeInserted = new boolean[inventory.getSizeInventory()]; @@ -953,7 +931,7 @@ public class Utils if (invStack != null && canCombine(stack, invStack)) { - numberMatching += invStack.stackSize; + numberMatching += invStack.getCount(); } } @@ -971,15 +949,15 @@ public class Utils continue; } - int prevStackSize = stack.stackSize; + int prevStackSize = stack.getCount(); ItemStack[] combinedStacks = combineStacks(stack, inventory.getStackInSlot(i), newLimit); stack = combinedStacks[0]; inventory.setInventorySlotContents(i, combinedStacks[1]); //TODO - newLimit -= (prevStackSize - stack.stackSize); + newLimit -= (prevStackSize - stack.getCount()); - if (newLimit <= 0 || stack.stackSize <= 0) + if (newLimit <= 0 || stack.isEmpty()) { return stack; } @@ -1050,7 +1028,7 @@ public class Utils } entityItem.setEntityItemStack(stack); - return world.spawnEntityInWorld(entityItem); + return world.spawnEntity(entityItem); } public static boolean swapLocations(World initialWorld, BlockPos initialPos, World finalWorld, BlockPos finalPos) @@ -1094,26 +1072,27 @@ public class Utils if (initialTile != null) { - TileEntity newTileInitial = BloodMagic.getCrossVersionProxy().createTileFromData(finalWorld, initialTag); + TileEntity newTileInitial = TileEntity.create(finalWorld, initialTag); + finalWorld.setTileEntity(finalPos, newTileInitial); newTileInitial.setPos(finalPos); - newTileInitial.setWorldObj(finalWorld); + newTileInitial.setWorld(finalWorld); } initialWorld.setBlockState(initialPos, finalBlockState, 3); if (finalTile != null) { - TileEntity newTileFinal = BloodMagic.getCrossVersionProxy().createTileFromData(initialWorld, finalTag); + TileEntity newTileFinal = TileEntity.create(initialWorld, finalTag); initialWorld.setTileEntity(initialPos, newTileFinal); newTileFinal.setPos(initialPos); - newTileFinal.setWorldObj(initialWorld); + newTileFinal.setWorld(initialWorld); } - initialWorld.notifyNeighborsOfStateChange(initialPos, finalStack.getBlock()); - finalWorld.notifyNeighborsOfStateChange(finalPos, initialStack.getBlock()); + initialWorld.notifyNeighborsOfStateChange(initialPos, finalStack.getBlock(), true); + finalWorld.notifyNeighborsOfStateChange(finalPos, initialStack.getBlock(), true); return true; } @@ -1122,25 +1101,25 @@ public class Utils public static ItemStack consumeItem(ItemStack stack) { Item item = stack.getItem(); - boolean largerStack = stack.stackSize > 1; + boolean largerStack = stack.getCount() > 1; if (largerStack) { - stack.stackSize -= 1; + stack.shrink(1); } if (item.hasContainerItem(stack)) { ItemStack ret = item.getContainerItem(stack); - if (ret == null) + if (ret.isEmpty()) { - return null; + return ItemStack.EMPTY; } if (ret.isItemStackDamageable() && ret.getItemDamage() > ret.getMaxDamage()) { - ret = null; + ret = ItemStack.EMPTY; } return ret; } - return largerStack ? stack : null; + return largerStack ? stack : ItemStack.EMPTY; } public static void registerHandlers(Set eventHandlers) diff --git a/src/main/java/WayofTime/bloodmagic/util/handler/event/ClientHandler.java b/src/main/java/WayofTime/bloodmagic/util/handler/event/ClientHandler.java index eeead4a8..af60ddc4 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/ClientHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/ClientHandler.java @@ -6,8 +6,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import javax.annotation.Nullable; - import WayofTime.bloodmagic.client.key.KeyBindings; import WayofTime.bloodmagic.client.render.model.CustomModelFactory; import net.minecraft.client.Minecraft; @@ -93,14 +91,11 @@ public class ClientHandler private static EnumFacing mrsHoloDirection; private static boolean mrsHoloDisplay; - boolean doCrystalRenderTest = true; - public static ResourceLocation crystalResource = new ResourceLocation(Constants.Mod.DOMAIN + "textures/entities/defaultCrystalLayer.png"); - @SubscribeEvent public void onTooltipEvent(ItemTooltipEvent event) { ItemStack stack = event.getItemStack(); - if (stack == null) + if (stack.isEmpty()) { return; } @@ -121,7 +116,7 @@ public class ClientHandler @SubscribeEvent public void onSoundEvent(PlaySoundEvent event) { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; + EntityPlayer player = Minecraft.getMinecraft().player; if (player != null && player.isPotionActive(ModPotions.deafness)) { event.setResultSound(null); @@ -152,8 +147,8 @@ public class ClientHandler @SubscribeEvent public void render(RenderWorldLastEvent event) { - EntityPlayerSP player = minecraft.thePlayer; - World world = player.worldObj; + EntityPlayerSP player = minecraft.player; + World world = player.getEntityWorld(); if (mrsHoloTile != null) { @@ -174,20 +169,20 @@ public class ClientHandler TileEntity tileEntity = world.getTileEntity(minecraft.objectMouseOver.getBlockPos()); - if (tileEntity instanceof TileMasterRitualStone && player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() instanceof ItemRitualDiviner) + if (tileEntity instanceof TileMasterRitualStone && !player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof ItemRitualDiviner) renderRitualStones(player, event.getPartialTicks()); } @SubscribeEvent public void onMouseEvent(MouseEvent event) { - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + EntityPlayerSP player = Minecraft.getMinecraft().player; if (event.getDwheel() != 0 && player != null && player.isSneaking()) { ItemStack stack = player.getHeldItemMainhand(); - if (stack != null) + if (!stack.isEmpty()) { Item item = stack.getItem(); @@ -226,7 +221,7 @@ public class ClientHandler ModelResourceLocation location = new ModelResourceLocation("bloodmagic:BlockBloodTank", "inventory"); IBakedModel model = event.getModelRegistry().getObject(location); - if (model instanceof IBakedModel) + if (model != null) event.getModelRegistry().putObject(location, new CustomModelFactory(model)); if (BloodMagic.isDev() && SUPPRESS_ASSET_ERRORS) @@ -310,8 +305,8 @@ public class ClientHandler ItemSigilHolding.cycleToNextSigil(stack, mode); BloodMagicPacketHandler.INSTANCE.sendToServer(new SigilHoldingPacketProcessor(player.inventory.currentItem, mode)); ItemStack newStack = ItemSigilHolding.getItemStackInSlot(stack, ItemSigilHolding.getCurrentItemOrdinal(stack)); - if (newStack != null) - Minecraft.getMinecraft().ingameGUI.setRecordPlaying(newStack.getDisplayName(), false); + if (!newStack.isEmpty()) + player.sendStatusMessage(newStack.getTextComponent(), true); } private static TextureAtlasSprite forName(TextureMap textureMap, String name, String dir) @@ -321,7 +316,7 @@ public class ClientHandler private void renderRitualStones(EntityPlayerSP player, float partialTicks) { - World world = player.worldObj; + World world = player.getEntityWorld(); ItemRitualDiviner ritualDiviner = (ItemRitualDiviner) player.inventory.getCurrentItem().getItem(); EnumFacing direction = ritualDiviner.getDirection(player.inventory.getCurrentItem()); Ritual ritual = RitualRegistry.getRitualForId(ritualDiviner.getCurrentRitual(player.inventory.getCurrentItem())); @@ -385,8 +380,8 @@ public class ClientHandler public static void renderRitualStones(TileMasterRitualStone masterRitualStone, float partialTicks) { - EntityPlayerSP player = minecraft.thePlayer; - World world = player.worldObj; + EntityPlayerSP player = minecraft.player; + World world = player.world; EnumFacing direction = mrsHoloDirection; Ritual ritual = mrsHoloRitual; @@ -462,28 +457,4 @@ public class ClientHandler mrsHoloRitual = null; mrsHoloDirection = EnumFacing.NORTH; } - - protected void renderHotbarItem(int x, int y, float partialTicks, EntityPlayer player, @Nullable ItemStack stack) - { - if (stack != null) - { - float animation = (float) stack.animationsToGo - partialTicks; - - if (animation > 0.0F) - { - GlStateManager.pushMatrix(); - float f1 = 1.0F + animation / 5.0F; - GlStateManager.translate((float) (x + 8), (float) (y + 12), 0.0F); - GlStateManager.scale(1.0F / f1, (f1 + 1.0F) / 2.0F, 1.0F); - GlStateManager.translate((float) (-(x + 8)), (float) (-(y + 12)), 0.0F); - } - - minecraft.getRenderItem().renderItemAndEffectIntoGUI(player, stack, x, y); - - if (animation > 0.0F) - GlStateManager.popMatrix(); - - minecraft.getRenderItem().renderItemOverlays(minecraft.fontRendererObj, stack, x, y); - } - } } diff --git a/src/main/java/WayofTime/bloodmagic/util/handler/event/CraftingHandler.java b/src/main/java/WayofTime/bloodmagic/util/handler/event/CraftingHandler.java index 0aa39f1d..81fceba7 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/CraftingHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/CraftingHandler.java @@ -147,8 +147,6 @@ public class CraftingHandler event.setCost(1); event.setOutput(outputStack); - - return; } } } diff --git a/src/main/java/WayofTime/bloodmagic/util/handler/event/GenericHandler.java b/src/main/java/WayofTime/bloodmagic/util/handler/event/GenericHandler.java index 2d269a0b..0865ab77 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/GenericHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/GenericHandler.java @@ -3,6 +3,7 @@ package WayofTime.bloodmagic.util.handler.event; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -101,7 +102,7 @@ public class GenericHandler { event.setDamageMultiplier(0); - if (player.worldObj.isRemote) + if (player.getEntityWorld().isRemote) { player.motionY *= -0.9; player.fallDistance = 0; @@ -197,14 +198,14 @@ public class GenericHandler @SubscribeEvent public void onEntityHurt(LivingHurtEvent event) { - if (event.getEntity().worldObj.isRemote) + if (event.getEntity().getEntityWorld().isRemote) return; if (event.getSource().getEntity() instanceof EntityPlayer && !PlayerHelper.isFakePlayer((EntityPlayer) event.getSource().getEntity())) { EntityPlayer player = (EntityPlayer) event.getSource().getEntity(); - if (player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null && player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() instanceof ItemPackSacrifice) + if (!player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty() && player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() instanceof ItemPackSacrifice) { ItemPackSacrifice pack = (ItemPackSacrifice) player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem(); @@ -240,7 +241,7 @@ public class GenericHandler @SubscribeEvent public void onLivingUpdate(LivingUpdateEvent event) { - if (!event.getEntityLiving().worldObj.isRemote) + if (!event.getEntityLiving().getEntityWorld().isRemote) { EntityLivingBase entity = event.getEntityLiving(); if (entity instanceof EntityPlayer && entity.ticksExisted % 50 == 0) //TODO: Change to an incremental counter @@ -265,7 +266,7 @@ public class GenericHandler if (animal.getAttackTarget() != null && animal.getDistanceSqToEntity(animal.getAttackTarget()) < 4) { - animal.worldObj.createExplosion(null, animal.posX, animal.posY + (double) (animal.height / 16.0F), animal.posZ, 2 + animal.getActivePotionEffect(ModPotions.sacrificialLamb).getAmplifier() * 1.5f, false); + animal.getEntityWorld().createExplosion(null, animal.posX, animal.posY + (double) (animal.height / 16.0F), animal.posZ, 2 + animal.getActivePotionEffect(ModPotions.sacrificialLamb).getAmplifier() * 1.5f, false); targetTaskMap.remove(animal); attackTaskMap.remove(animal); } @@ -284,7 +285,7 @@ public class GenericHandler EntityPlayer player = (EntityPlayer) entity; if (player.isSneaking() && player.isPotionActive(ModPotions.cling) && Utils.isPlayerBesideSolidBlockFace(player) && !player.onGround) { - if (player.worldObj.isRemote) + if (player.getEntityWorld().isRemote) { player.motionY = 0; player.motionX *= 0.8; @@ -307,14 +308,15 @@ public class GenericHandler if (entity.isPotionActive(ModPotions.fireFuse)) { - entity.worldObj.spawnParticle(EnumParticleTypes.FLAME, entity.posX + entity.worldObj.rand.nextDouble() * 0.3, entity.posY + entity.worldObj.rand.nextDouble() * 0.3, entity.posZ + entity.worldObj.rand.nextDouble() * 0.3, 0, 0.06d, 0); + Random random = entity.getEntityWorld().rand; + entity.getEntityWorld().spawnParticle(EnumParticleTypes.FLAME, entity.posX + random.nextDouble() * 0.3, entity.posY + random.nextDouble() * 0.3, entity.posZ + random.nextDouble() * 0.3, 0, 0.06d, 0); int r = entity.getActivePotionEffect(ModPotions.fireFuse).getAmplifier(); int radius = 1 * r + 1; if (entity.getActivePotionEffect(ModPotions.fireFuse).getDuration() <= 3) { - entity.worldObj.createExplosion(null, entity.posX, entity.posY, entity.posZ, radius, false); + entity.getEntityWorld().createExplosion(null, entity.posX, entity.posY, entity.posZ, radius, false); } } @@ -335,7 +337,7 @@ public class GenericHandler if (player instanceof EntityPlayerMP) { BlockPos pos = player.getPosition(); - DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(player.worldObj.provider.getDimension(), pos.getX() >> 4, pos.getZ() >> 4); + DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(player.getEntityWorld().provider.getDimension(), pos.getX() >> 4, pos.getZ() >> 4); if (holder != null) { BloodMagicPacketHandler.sendTo(new DemonAuraPacketProcessor(holder), (EntityPlayerMP) player); @@ -352,7 +354,7 @@ public class GenericHandler { IBlockState state = event.getTargetBlock(); Block block = state.getBlock(); - if (block != null && block instanceof BlockAltar && event.getEntityPlayer() != null && event.getEntityPlayer() instanceof EntityPlayerMP && event.getEntityPlayer().getHeldItemMainhand() != null && event.getEntityPlayer().getHeldItemMainhand().getItem() instanceof ItemAltarMaker) + if (block instanceof BlockAltar && event.getEntityPlayer() != null && event.getEntityPlayer() instanceof EntityPlayerMP && !event.getEntityPlayer().getHeldItemMainhand().isEmpty() && event.getEntityPlayer().getHeldItemMainhand().getItem() instanceof ItemAltarMaker) { ItemAltarMaker altarMaker = (ItemAltarMaker) event.getEntityPlayer().getHeldItemMainhand().getItem(); ChatUtil.sendNoSpam(event.getEntityPlayer(), TextHelper.localizeEffect("chat.BloodMagic.altarMaker.destroy", altarMaker.destroyAltar(event.getEntityPlayer()))); @@ -398,7 +400,7 @@ public class GenericHandler return; ItemStack held = event.getItemStack(); - if (held != null && held.getItem() instanceof IBindable) + if (!held.isEmpty() && held.getItem() instanceof IBindable) { held = NBTHelper.checkNBT(held); IBindable bindable = (IBindable) held.getItem(); @@ -418,7 +420,7 @@ public class GenericHandler BindableHelper.setItemOwnerName(held, player.getDisplayNameString()); } - if (held != null && held.getItem() instanceof IBloodOrb) + if (!held.isEmpty() && held.getItem() instanceof IBloodOrb) { held = NBTHelper.checkNBT(held); IBloodOrb bloodOrb = (IBloodOrb) held.getItem(); @@ -466,10 +468,10 @@ public class GenericHandler EntityPlayer player = (EntityPlayer) entity; ItemStack heldStack = player.getHeldItemMainhand(); - if (heldStack != null && heldStack.getItem() == ModItems.BOUND_SWORD && !(attackedEntity instanceof EntityAnimal)) + if (!heldStack.isEmpty() && heldStack.getItem() == ModItems.BOUND_SWORD && !(attackedEntity instanceof EntityAnimal)) for (int i = 0; i <= EnchantmentHelper.getLootingModifier(player); i++) if (attackedEntity.getEntityWorld().rand.nextDouble() < 0.2) - event.getDrops().add(new EntityItem(attackedEntity.worldObj, attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, new ItemStack(ModItems.BLOOD_SHARD, 1, 0))); + event.getDrops().add(new EntityItem(attackedEntity.getEntityWorld(), attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, new ItemStack(ModItems.BLOOD_SHARD, 1, 0))); } } @@ -480,14 +482,14 @@ public class GenericHandler EntityPlayer player = event.getEntityPlayer(); ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantments.MENDING, player); - if (itemstack != null && itemstack.isItemDamaged()) + if (!itemstack.isEmpty() && itemstack.isItemDamaged()) { int i = Math.min(xpToDurability(event.getOrb().xpValue), itemstack.getItemDamage()); event.getOrb().xpValue -= durabilityToXp(i); itemstack.setItemDamage(itemstack.getItemDamage() - i); } - if (!player.worldObj.isRemote) + if (!player.getEntityWorld().isRemote) { for (ItemStack stack : player.inventory.mainInventory) { diff --git a/src/main/java/WayofTime/bloodmagic/util/handler/event/LivingArmourHandler.java b/src/main/java/WayofTime/bloodmagic/util/handler/event/LivingArmourHandler.java index 727e3f75..a4ef11d1 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/LivingArmourHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/LivingArmourHandler.java @@ -308,7 +308,7 @@ public class LivingArmourHandler @SubscribeEvent public void onArrowFire(ArrowLooseEvent event) { - World world = event.getEntityPlayer().worldObj; + World world = event.getEntityPlayer().getEntityWorld(); ItemStack stack = event.getBow(); EntityPlayer player = event.getEntityPlayer(); @@ -368,7 +368,7 @@ public class LivingArmourHandler entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY; - world.spawnEntityInWorld(entityarrow); + world.spawnEntity(entityarrow); } } } diff --git a/src/main/java/WayofTime/bloodmagic/util/handler/event/StatTrackerHandler.java b/src/main/java/WayofTime/bloodmagic/util/handler/event/StatTrackerHandler.java index 7089d682..4cf9e5cb 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/StatTrackerHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/StatTrackerHandler.java @@ -87,7 +87,7 @@ public class StatTrackerHandler if (armour != null) { StatTrackerHealthboost.incrementCounter(armour, event.getAmount()); - if (player.worldObj.canSeeSky(player.getPosition()) && player.worldObj.provider.isDaytime()) + if (player.getEntityWorld().canSeeSky(player.getPosition()) && player.getEntityWorld().provider.isDaytime()) { StatTrackerSolarPowered.incrementCounter(armour, event.getAmount()); } @@ -124,7 +124,7 @@ public class StatTrackerHandler if (sourceEntity != null && !source.isMagicDamage() && !source.isProjectile()) StatTrackerPhysicalProtect.incrementCounter(armour, amount); - if (source.equals(DamageSource.fall)) + if (source.equals(DamageSource.FALL)) StatTrackerFallProtect.incrementCounter(armour, amount); if (source.isProjectile()) @@ -162,7 +162,7 @@ public class StatTrackerHandler { StatTrackerMeleeDamage.incrementCounter(armour, amount); - if (player.worldObj.getLight(player.getPosition()) <= 9) + if (player.getEntityWorld().getLight(player.getPosition()) <= 9) StatTrackerNightSight.incrementCounter(armour, amount); if (mainWeapon != null && mainWeapon.getItem() instanceof ItemSpade) diff --git a/src/main/java/WayofTime/bloodmagic/util/handler/event/WillHandler.java b/src/main/java/WayofTime/bloodmagic/util/handler/event/WillHandler.java index 0192e3a6..5bd47c12 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/WillHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/WillHandler.java @@ -56,7 +56,7 @@ public class WillHandler if (remainder == null || ((IDemonWill) stack.getItem()).getWill(pickupType, stack) < 0.0001 || PlayerDemonWillHandler.isDemonWillFull(pickupType, player)) { - stack.stackSize = 0; + stack.setCount(0); event.setResult(Event.Result.ALLOW); } } @@ -67,7 +67,7 @@ public class WillHandler { if (event.getSource() instanceof EntityDamageSourceIndirect) { - Entity sourceEntity = ((EntityDamageSourceIndirect) event.getSource()).getSourceOfDamage(); + Entity sourceEntity = event.getSource().getSourceOfDamage(); if (sourceEntity instanceof EntitySentientArrow) { @@ -84,21 +84,21 @@ public class WillHandler DamageSource source = event.getSource(); Entity entity = source.getEntity(); - if (attackedEntity.isPotionActive(ModPotions.soulSnare) && (attackedEntity instanceof EntityMob || attackedEntity.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL)) + if (attackedEntity.isPotionActive(ModPotions.soulSnare) && (attackedEntity instanceof EntityMob || attackedEntity.getEntityWorld().getDifficulty() == EnumDifficulty.PEACEFUL)) { PotionEffect eff = attackedEntity.getActivePotionEffect(ModPotions.soulSnare); int lvl = eff.getAmplifier(); double amountOfSouls = attackedEntity.getEntityWorld().rand.nextDouble() * (lvl + 1) * (lvl + 1) * 5; ItemStack soulStack = ((IDemonWill) ModItems.MONSTER_SOUL).createWill(0, amountOfSouls); - event.getDrops().add(new EntityItem(attackedEntity.worldObj, attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, soulStack)); + event.getDrops().add(new EntityItem(attackedEntity.getEntityWorld(), attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, soulStack)); } if (entity != null && entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; ItemStack heldStack = player.getHeldItemMainhand(); - if (heldStack != null && heldStack.getItem() instanceof IDemonWillWeapon && !player.worldObj.isRemote) + if (heldStack != null && heldStack.getItem() instanceof IDemonWillWeapon && !player.getEntityWorld().isRemote) { IDemonWillWeapon demonWillWeapon = (IDemonWillWeapon) heldStack.getItem(); List droppedSouls = demonWillWeapon.getRandomDemonWillDrop(attackedEntity, player, heldStack, event.getLootingLevel()); @@ -114,7 +114,7 @@ public class WillHandler EnumDemonWillType pickupType = ((IDemonWill) remainder.getItem()).getType(remainder); if (((IDemonWill) remainder.getItem()).getWill(pickupType, remainder) >= 0.0001) { - event.getDrops().add(new EntityItem(attackedEntity.worldObj, attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, remainder)); + event.getDrops().add(new EntityItem(attackedEntity.getEntityWorld(), attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, remainder)); } } } diff --git a/src/main/java/WayofTime/bloodmagic/util/helper/RecipeHelper.java b/src/main/java/WayofTime/bloodmagic/util/helper/RecipeHelper.java index 6f8d121c..98f29fa0 100644 --- a/src/main/java/WayofTime/bloodmagic/util/helper/RecipeHelper.java +++ b/src/main/java/WayofTime/bloodmagic/util/helper/RecipeHelper.java @@ -16,7 +16,7 @@ public class RecipeHelper if (recipe != null) { ItemStack resultStack = recipe.getRecipeOutput(); - if (resultStack != null && resultStack.getItem() != null) + if (!resultStack.isEmpty()) { if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) { @@ -36,7 +36,7 @@ public class RecipeHelper if (recipe != null) { ItemStack resultStack = recipe.getOutput(); - if (resultStack != null && resultStack.getItem() != null) + if (!resultStack.isEmpty()) { if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) { @@ -56,7 +56,7 @@ public class RecipeHelper if (recipe != null) { ItemStack resultStack = recipe.getRecipeOutput(); - if (resultStack != null && resultStack.getItem() != null) + if (!resultStack.isEmpty()) { if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) {