diff --git a/src/main/java/WayofTime/bloodmagic/BloodMagic.java b/src/main/java/WayofTime/bloodmagic/BloodMagic.java index 25cb1a75..39cc385d 100644 --- a/src/main/java/WayofTime/bloodmagic/BloodMagic.java +++ b/src/main/java/WayofTime/bloodmagic/BloodMagic.java @@ -1,15 +1,22 @@ package WayofTime.bloodmagic; -import java.io.File; -import java.util.List; - +import WayofTime.bloodmagic.annot.Handler; +import WayofTime.bloodmagic.api.registry.RitualRegistry; +import WayofTime.bloodmagic.api.util.helper.LogHelper; import WayofTime.bloodmagic.api_impl.BloodMagicAPI; import WayofTime.bloodmagic.apiv2.BloodMagicPlugin; import WayofTime.bloodmagic.apiv2.IBloodMagicPlugin; +import WayofTime.bloodmagic.client.gui.GuiHandler; import WayofTime.bloodmagic.command.CommandBloodMagic; -import WayofTime.bloodmagic.api.registry.RitualRegistry; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import WayofTime.bloodmagic.meteor.MeteorConfigHandler; +import WayofTime.bloodmagic.network.BloodMagicPacketHandler; +import WayofTime.bloodmagic.proxy.CommonProxy; +import WayofTime.bloodmagic.registry.*; +import WayofTime.bloodmagic.structures.ModDungeons; import WayofTime.bloodmagic.util.PluginUtil; +import WayofTime.bloodmagic.util.Utils; +import WayofTime.bloodmagic.util.handler.IMCHandler; import com.google.common.collect.Lists; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; @@ -19,70 +26,51 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.*; import net.minecraftforge.fml.common.network.NetworkRegistry; -import WayofTime.bloodmagic.annot.Handler; -import WayofTime.bloodmagic.api.util.helper.LogHelper; -import WayofTime.bloodmagic.client.gui.GuiHandler; -import WayofTime.bloodmagic.network.BloodMagicPacketHandler; -import WayofTime.bloodmagic.proxy.CommonProxy; -import WayofTime.bloodmagic.registry.ModArmourTrackers; -import WayofTime.bloodmagic.registry.ModCorruptionBlocks; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.registry.ModRecipes; -import WayofTime.bloodmagic.registry.ModRituals; -import WayofTime.bloodmagic.registry.ModTranquilityHandlers; -import WayofTime.bloodmagic.structures.ModDungeons; -import WayofTime.bloodmagic.util.Utils; -import WayofTime.bloodmagic.util.handler.IMCHandler; import org.apache.commons.lang3.tuple.Pair; +import java.io.File; +import java.util.List; + @Mod(modid = BloodMagic.MODID, name = BloodMagic.NAME, version = BloodMagic.VERSION, dependencies = BloodMagic.DEPEND, guiFactory = "WayofTime.bloodmagic.client.gui.config.ConfigGuiFactory") -public class BloodMagic -{ +public class BloodMagic { public static final String MODID = "bloodmagic"; public static final String NAME = "Blood Magic: Alchemical Wizardry"; public static final String VERSION = "@VERSION@"; public static final String DEPEND = "required-after:guideapi;"; - public static final CreativeTabs TAB_BM = new CreativeTabs(MODID + ".creativeTab") - { + public static final CreativeTabs TAB_BM = new CreativeTabs(MODID + ".creativeTab") { @Override - public ItemStack getTabIconItem() - { + public ItemStack getTabIconItem() { return new ItemStack(RegistrarBloodMagicItems.BLOOD_ORB); } }; - public static CreativeTabs TAB_TOMES = new CreativeTabs(MODID + ".creativeTabTome") - { + public static final boolean IS_DEV = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); + public static final List> PLUGINS = Lists.newArrayList(); + public static CreativeTabs TAB_TOMES = new CreativeTabs(MODID + ".creativeTabTome") { @Override - public ItemStack getTabIconItem() - { + public ItemStack getTabIconItem() { return new ItemStack(RegistrarBloodMagicItems.UPGRADE_TOME); } @Override - public boolean hasSearchBar() - { + public boolean hasSearchBar() { return true; } }.setNoTitle().setBackgroundImageName("item_search.png"); - public static final boolean IS_DEV = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); - public static final List> PLUGINS = Lists.newArrayList(); - - static - { - FluidRegistry.enableUniversalBucket(); - } @SidedProxy(serverSide = "WayofTime.bloodmagic.proxy.CommonProxy", clientSide = "WayofTime.bloodmagic.proxy.ClientProxy") public static CommonProxy proxy; @Mod.Instance(BloodMagic.MODID) public static BloodMagic instance; + static { + FluidRegistry.enableUniversalBucket(); + } + public LogHelper logger = new LogHelper(MODID); private File configDir; @Mod.EventHandler - public void preInit(FMLPreInitializationEvent event) - { + public void preInit(FMLPreInitializationEvent event) { configDir = new File(event.getModConfigurationDirectory(), "BloodMagic"); ConfigHandler.init(new File(configDir, "BloodMagic.cfg")); @@ -96,8 +84,7 @@ public class BloodMagic } @Mod.EventHandler - public void init(FMLInitializationEvent event) - { + public void init(FMLInitializationEvent event) { BloodMagicPacketHandler.init(); for (Pair plugin : PLUGINS) plugin.getLeft().register(BloodMagicAPI.INSTANCE); @@ -114,8 +101,7 @@ public class BloodMagic } @Mod.EventHandler - public void postInit(FMLPostInitializationEvent event) - { + public void postInit(FMLPostInitializationEvent event) { ModRecipes.addCompressionHandlers(); proxy.postInit(); @@ -127,20 +113,17 @@ public class BloodMagic } @Mod.EventHandler - public void modMapping(FMLModIdMappingEvent event) - { + public void modMapping(FMLModIdMappingEvent event) { } @Mod.EventHandler - public void serverStarting(FMLServerStartingEvent event) - { + public void serverStarting(FMLServerStartingEvent event) { event.registerServerCommand(new CommandBloodMagic()); } @Mod.EventHandler - public void onIMCRecieved(FMLInterModComms.IMCEvent event) - { + public void onIMCRecieved(FMLInterModComms.IMCEvent event) { IMCHandler.handleIMC(event); } } diff --git a/src/main/java/WayofTime/bloodmagic/ConfigHandler.java b/src/main/java/WayofTime/bloodmagic/ConfigHandler.java index 8146e99d..4ec4c8c6 100644 --- a/src/main/java/WayofTime/bloodmagic/ConfigHandler.java +++ b/src/main/java/WayofTime/bloodmagic/ConfigHandler.java @@ -1,13 +1,11 @@ package WayofTime.bloodmagic; -import java.io.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import WayofTime.bloodmagic.annot.Handler; +import WayofTime.bloodmagic.api.BlockStack; +import WayofTime.bloodmagic.api.BloodMagicAPI; +import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.meteor.MeteorConfigHandler; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.block.Block; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.config.Configuration; @@ -15,15 +13,12 @@ import net.minecraftforge.fml.client.event.ConfigChangedEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.oredict.OreDictionary; -import WayofTime.bloodmagic.annot.Handler; -import WayofTime.bloodmagic.api.BlockStack; -import WayofTime.bloodmagic.api.BloodMagicAPI; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.util.Utils; + +import java.io.File; +import java.util.*; @Handler -public class ConfigHandler -{ +public class ConfigHandler { public static Configuration config; // Teleposer @@ -152,14 +147,20 @@ public class ConfigHandler public static boolean thaumcraftGogglesUpgrade; public static boolean ignoreCompressionSpamAddedByCompression; - public static void init(File file) - { + @SubscribeEvent + public void onConfigChanged(ConfigChangedEvent event) { + if (event.getModID().equals(BloodMagic.MODID)) { + syncConfig(); + MeteorConfigHandler.handleMeteors(false); + } + } + + public static void init(File file) { config = new Configuration(file); syncConfig(); } - public static void syncConfig() - { + public static void syncConfig() { String category; category = "Item/Block Blacklisting"; @@ -168,22 +169,22 @@ public class ConfigHandler category = "Teleposer Blacklist"; config.addCustomCategoryComment(category, "Block blacklisting"); - teleposerBlacklisting = config.getStringList("teleposerBlacklist", category, new String[] { "minecraft:bedrock", "minecraft:mob_spawner" }, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta"); + teleposerBlacklisting = config.getStringList("teleposerBlacklist", category, new String[]{"minecraft:bedrock", "minecraft:mob_spawner"}, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta"); buildBlacklist(teleposerBlacklisting, teleposerBlacklist); - teleposerBlacklistEntity = Arrays.asList(config.getStringList("teleposerBlacklistEntity", category, new String[] {}, "Entity class names listed here will not be able to be teleposed.")); + teleposerBlacklistEntity = Arrays.asList(config.getStringList("teleposerBlacklistEntity", category, new String[]{}, "Entity class names listed here will not be able to be teleposed.")); category = "Transposition Sigil Blacklist"; config.addCustomCategoryComment(category, "Block blacklisting"); - transpositionBlacklisting = config.getStringList("transpositionBlacklist", category, new String[] { "minecraft:bedrock", "minecraft:mob_spawner" }, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta"); + transpositionBlacklisting = config.getStringList("transpositionBlacklist", category, new String[]{"minecraft:bedrock", "minecraft:mob_spawner"}, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta"); buildBlacklist(transpositionBlacklisting, transpositionBlacklist); category = "Well of Suffering Blacklist"; config.addCustomCategoryComment(category, "Entity blacklisting from WoS"); - wellOfSufferingBlacklist = Arrays.asList(config.getStringList("wellOfSufferingBlacklist", category, new String[] { "EntityArmorStand", "EntitySentientSpecter" }, "Use the class name of the Entity to blacklist it from usage.\nIE: EntityWolf, EntityWitch, etc")); + wellOfSufferingBlacklist = Arrays.asList(config.getStringList("wellOfSufferingBlacklist", category, new String[]{"EntityArmorStand", "EntitySentientSpecter"}, "Use the class name of the Entity to blacklist it from usage.\nIE: EntityWolf, EntityWitch, etc")); category = "Blood Altar Sacrificial Values"; config.addCustomCategoryComment(category, "Entity Sacrificial Value Settings"); - entitySacrificeValuesList = config.getStringList("entitySacrificeLP:HPValues", category, new String[] { "EntityVillager;100", "EntitySlime;15", "EntityEnderman;10", "EntityCow;100", "EntityChicken;100", "EntityHorse;100", "EntitySheep;100", "EntityWolf;100", "EntityOcelot;100", "EntityPig;100", "EntityRabbit;100", "EntityArmorStand;0", "EntitySentientSpecter;0" }, "Used to edit the amount of LP gained per HP sacrificed for the given entity.\nSetting an entity to 0 effectively blacklists it.\nIf a mod modifies an entity via the API, it will take precedence over this config.\nSyntax: EntityClassName;LPPerHP"); + entitySacrificeValuesList = config.getStringList("entitySacrificeLP:HPValues", category, new String[]{"EntityVillager;100", "EntitySlime;15", "EntityEnderman;10", "EntityCow;100", "EntityChicken;100", "EntityHorse;100", "EntitySheep;100", "EntityWolf;100", "EntityOcelot;100", "EntityPig;100", "EntityRabbit;100", "EntityArmorStand;0", "EntitySentientSpecter;0"}, "Used to edit the amount of LP gained per HP sacrificed for the given entity.\nSetting an entity to 0 effectively blacklists it.\nIf a mod modifies an entity via the API, it will take precedence over this config.\nSyntax: EntityClassName;LPPerHP"); buildEntitySacrificeValues(); category = "Potions"; @@ -310,19 +311,16 @@ public class ConfigHandler config.save(); } - private static void buildBlacklist(String[] blacklisting, List blockBlacklist) - { + private static void buildBlacklist(String[] blacklisting, List blockBlacklist) { blockBlacklist.clear(); - for (String blockSet : blacklisting) - { + for (String blockSet : blacklisting) { String[] blockData = blockSet.split(":"); Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockData[0], blockData[1])); int meta = 0; - if (blockData.length == 3) - { + if (blockData.length == 3) { // Check if it's an int, if so, parse it. If not, set meta to 0 // to avoid crashing. if (Utils.isInteger(blockData[2])) @@ -337,12 +335,10 @@ public class ConfigHandler } } - private static void buildEntitySacrificeValues() - { + private static void buildEntitySacrificeValues() { entitySacrificeValues.clear(); - for (String entityData : entitySacrificeValuesList) - { + for (String entityData : entitySacrificeValuesList) { String[] split = entityData.split(";"); int amount = 500; @@ -353,14 +349,4 @@ public class ConfigHandler entitySacrificeValues.put(split[0], amount); } } - - @SubscribeEvent - public void onConfigChanged(ConfigChangedEvent event) - { - if (event.getModID().equals(BloodMagic.MODID)) - { - syncConfig(); - MeteorConfigHandler.handleMeteors(false); - } - } } diff --git a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectAttractor.java b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectAttractor.java index 7ac8a57f..9a796c9c 100644 --- a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectAttractor.java +++ b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectAttractor.java @@ -1,24 +1,16 @@ package WayofTime.bloodmagic.alchemyArray; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; +import WayofTime.bloodmagic.fakePlayer.FakePlayerBM; +import WayofTime.bloodmagic.tile.TileAlchemyArray; +import com.mojang.authlib.GameProfile; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAITasks; import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; -import net.minecraft.entity.monster.EntityBlaze; -import net.minecraft.entity.monster.EntityEnderman; -import net.minecraft.entity.monster.EntityMob; -import net.minecraft.entity.monster.EntityPigZombie; -import net.minecraft.entity.monster.EntitySilverfish; -import net.minecraft.entity.monster.EntitySlime; -import net.minecraft.entity.monster.EntitySpider; +import net.minecraft.entity.monster.*; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.pathfinding.Path; import net.minecraft.pathfinding.PathFinder; @@ -29,17 +21,13 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.util.FakePlayer; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; -import WayofTime.bloodmagic.fakePlayer.FakePlayerBM; -import WayofTime.bloodmagic.tile.TileAlchemyArray; -import com.mojang.authlib.GameProfile; +import java.util.*; /** * Credits for the initial code go to Crazy Pants of EIO. */ -public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect -{ +public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect { private FakePlayer target; private Set tracking = new HashSet(); @@ -48,26 +36,21 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect private int cooldown = 50; - public AlchemyArrayEffectAttractor(String key) - { + public AlchemyArrayEffectAttractor(String key) { super(key); } @Override - public boolean update(TileEntity tile, int ticksActive) - { - if (tile.getWorld().isRemote) - { + public boolean update(TileEntity tile, int ticksActive) { + if (tile.getWorld().isRemote) { return false; } BlockPos pos = tile.getPos(); counter++; - if (counter < 10) - { + if (counter < 10) { Iterator itr = tracking.iterator(); - while (itr.hasNext()) - { + while (itr.hasNext()) { EntityLiving ent = itr.next(); onEntityTick(pos, ent); } @@ -82,8 +65,7 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect Set trackingThisTick = new HashSet(); List entsInBounds = world.getEntitiesWithinAABB(EntityLiving.class, getBounds(pos)); - for (EntityLiving ent : entsInBounds) - { + for (EntityLiving ent : entsInBounds) { if (!ent.isDead)// && isMobInFilter(ent)) { double x = (pos.getX() + 0.5D - ent.posX); @@ -91,36 +73,30 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect double z = (pos.getZ() + 0.5D - ent.posZ); double distance = Math.sqrt(x * x + y * y + z * z); - if (distance < 2 && tracking.contains(ent)) - { + if (distance < 2 && tracking.contains(ent)) { setEntityCooldown(pos, ent, cooldown); removeAssignedAITask(pos, ent); continue; } - if (!canEntityBeTracked(pos, ent)) - { + if (!canEntityBeTracked(pos, ent)) { // System.out.println("Cooldown: " + getEntityCooldown(pos, ent)); decrementEntityCooldown(pos, ent); continue; } - if (tracking.contains(ent)) - { + if (tracking.contains(ent)) { trackingThisTick.add(ent); onEntityTick(pos, ent); - } else if (tracking.size() < maxMobsAttracted && trackMob(pos, ent)) - { + } else if (tracking.size() < maxMobsAttracted && trackMob(pos, ent)) { trackingThisTick.add(ent); onTracked(ent); } } } - for (EntityLiving e : tracking) - { - if (!trackingThisTick.contains(e)) - { + for (EntityLiving e : tracking) { + if (!trackingThisTick.contains(e)) { onUntracked(e); } } @@ -130,124 +106,98 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect return false; } - public boolean canEntityBeTracked(BlockPos pos, EntityLiving entity) - { + public boolean canEntityBeTracked(BlockPos pos, EntityLiving entity) { return getEntityCooldown(pos, entity) <= 0; } - private String getPosKey(BlockPos pos) - { + private String getPosKey(BlockPos pos) { return "BMAttractor:" + pos; } - public int getEntityCooldown(BlockPos pos, EntityLiving entity) - { + public int getEntityCooldown(BlockPos pos, EntityLiving entity) { return entity.getEntityData().getInteger(getPosKey(pos)); } - public void setEntityCooldown(BlockPos pos, EntityLiving entity, int cooldown) - { + public void setEntityCooldown(BlockPos pos, EntityLiving entity, int cooldown) { entity.getEntityData().setInteger(getPosKey(pos), cooldown); } - public void decrementEntityCooldown(BlockPos pos, EntityLiving entity) - { + public void decrementEntityCooldown(BlockPos pos, EntityLiving entity) { int cooldown = getEntityCooldown(pos, entity); - if (cooldown > 0) - { + if (cooldown > 0) { setEntityCooldown(pos, entity, cooldown - 1); } } - public AxisAlignedBB getBounds(BlockPos pos) - { + public AxisAlignedBB getBounds(BlockPos pos) { return new AxisAlignedBB(pos).expand(getRange(), getRange(), getRange()); } - public float getRange() - { + public float getRange() { return 10; } - private void onUntracked(EntityLiving e) - { - if (e instanceof EntityEnderman) - { + private void onUntracked(EntityLiving e) { + if (e instanceof EntityEnderman) { e.getEntityData().setBoolean("BM:tracked", false); } } - private void onTracked(EntityLiving e) - { - if (e instanceof EntityEnderman) - { + private void onTracked(EntityLiving e) { + if (e instanceof EntityEnderman) { e.getEntityData().setBoolean("BM:tracked", true); } } - private void onEntityTick(BlockPos pos, EntityLiving ent) - { - if (ent instanceof EntitySlime) - { + private void onEntityTick(BlockPos pos, EntityLiving ent) { + if (ent instanceof EntitySlime) { ent.faceEntity(getTarget(ent.getEntityWorld(), pos), 10.0F, 20.0F); - } else if (ent instanceof EntitySilverfish) - { - if (counter < 10) - { + } else if (ent instanceof EntitySilverfish) { + if (counter < 10) { return; } EntitySilverfish sf = (EntitySilverfish) ent; Path pathentity = getPathEntityToEntity(ent, getTarget(ent.getEntityWorld(), pos), getRange()); sf.getNavigator().setPath(pathentity, sf.getAIMoveSpeed()); - } else if (ent instanceof EntityBlaze) - { + } else if (ent instanceof EntityBlaze) { double x = (pos.getX() + 0.5D - ent.posX); double y = (pos.getY() + 1D - ent.posY); double z = (pos.getZ() + 0.5D - ent.posZ); double distance = Math.sqrt(x * x + y * y + z * z); - if (distance > 1.25) - { + if (distance > 1.25) { double speed = 0.01; ent.motionX += x / distance * speed; - if (y > 0) - { + if (y > 0) { ent.motionY += (0.3 - ent.motionY) * 0.3; } ent.motionZ += z / distance * speed; } - } else if (ent instanceof EntityPigZombie || ent instanceof EntitySpider) - { + } else if (ent instanceof EntityPigZombie || ent instanceof EntitySpider) { forceMove(pos, ent); // ent.setAttackTarget(target); - } else if (ent instanceof EntityEnderman) - { + } else if (ent instanceof EntityEnderman) { ent.setAttackTarget(getTarget(ent.getEntityWorld(), pos)); } } - private void forceMove(BlockPos pos, EntityLiving ent) - { + private void forceMove(BlockPos pos, EntityLiving ent) { double x = (pos.getX() + 0.5D - ent.posX); double y = (pos.getY() + 1D - ent.posY); double z = (pos.getZ() + 0.5D - ent.posZ); double distance = Math.sqrt(x * x + y * y + z * z); - if (distance > 2) - { + if (distance > 2) { EntityMob mod = (EntityMob) ent; mod.faceEntity(getTarget(ent.getEntityWorld(), pos), 180, 0); mod.getMoveHelper().strafe(0, 0.3f); - if (mod.posY < pos.getY()) - { + if (mod.posY < pos.getY()) { mod.setJumping(true); - } else - { + } else { mod.setJumping(false); } } } - public Path getPathEntityToEntity(Entity entity, Entity targetEntity, float range) - { + public Path getPathEntityToEntity(Entity entity, Entity targetEntity, float range) { int targX = MathHelper.floor(targetEntity.posX); int targY = MathHelper.floor(targetEntity.posY + 1.0D); int targZ = MathHelper.floor(targetEntity.posZ); @@ -256,74 +206,57 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect return pf.findPath(targetEntity.getEntityWorld(), (EntityLiving) entity, new BlockPos(targX, targY, targZ), range); } - private boolean trackMob(BlockPos pos, EntityLiving ent) - { + private boolean trackMob(BlockPos pos, EntityLiving ent) { //TODO: Figure out if this crud is needed - if (useSetTarget(ent)) - { + if (useSetTarget(ent)) { ent.setAttackTarget(getTarget(ent.getEntityWorld(), pos)); return true; - } else if (useSpecialCase(ent)) - { + } else if (useSpecialCase(ent)) { return applySpecialCase(pos, ent); - } else - { + } else { return attractUsingAITask(pos, ent); } } - private boolean useSetTarget(EntityLiving ent) - { + private boolean useSetTarget(EntityLiving ent) { return ent instanceof EntityPigZombie || ent instanceof EntitySpider || ent instanceof EntitySilverfish; } - public void removeAssignedAITask(BlockPos pos, EntityLiving ent) - { + public void removeAssignedAITask(BlockPos pos, EntityLiving ent) { Set entries = ent.tasks.taskEntries; EntityAIBase remove = null; - for (EntityAITaskEntry entry : entries) - { - if (entry.action instanceof AttractTask) - { + for (EntityAITaskEntry entry : entries) { + if (entry.action instanceof AttractTask) { AttractTask at = (AttractTask) entry.action; - if (at.coord.equals(pos)) - { + if (at.coord.equals(pos)) { remove = entry.action; - } else - { + } else { continue; } } } - if (remove != null) - { + if (remove != null) { ent.tasks.removeTask(remove); } } - private boolean attractUsingAITask(BlockPos pos, EntityLiving ent) - { + private boolean attractUsingAITask(BlockPos pos, EntityLiving ent) { tracking.add(ent); Set entries = ent.tasks.taskEntries; // boolean hasTask = false; EntityAIBase remove = null; // boolean isTracked; - for (EntityAITaskEntry entry : entries) - { - if (entry.action instanceof AttractTask) - { + for (EntityAITaskEntry entry : entries) { + if (entry.action instanceof AttractTask) { AttractTask at = (AttractTask) entry.action; - if (at.coord.equals(pos) || !at.shouldExecute()) - { + if (at.coord.equals(pos) || !at.shouldExecute()) { remove = entry.action; - } else - { + } else { return false; } } } - if (remove != null) - { + if (remove != null) { ent.tasks.removeTask(remove); } @@ -333,18 +266,14 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect return true; } - private void cancelCurrentTasks(EntityLiving ent) - { + private void cancelCurrentTasks(EntityLiving ent) { Iterator iterator = ent.tasks.taskEntries.iterator(); List currentTasks = new ArrayList(); - while (iterator.hasNext()) - { + while (iterator.hasNext()) { EntityAITaskEntry entityaitaskentry = iterator.next(); - if (entityaitaskentry != null) - { - if (entityaitaskentry.action instanceof AttractTask) - { + if (entityaitaskentry != null) { + if (entityaitaskentry.action instanceof AttractTask) { continue; } @@ -353,42 +282,34 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect } // Only available way to stop current execution is to remove all current // tasks, then re-add them - for (EntityAITaskEntry task : currentTasks) - { + for (EntityAITaskEntry task : currentTasks) { ent.tasks.removeTask(task.action); ent.tasks.addTask(task.priority, task.action); } } - private boolean applySpecialCase(BlockPos pos, EntityLiving ent) - { - if (ent instanceof EntitySlime) - { + private boolean applySpecialCase(BlockPos pos, EntityLiving ent) { + if (ent instanceof EntitySlime) { ent.faceEntity(getTarget(ent.getEntityWorld(), pos), 10.0F, 20.0F); // ent.setAttackTarget(getTarget(ent.worldObj, pos)); return true; - } else if (ent instanceof EntitySilverfish) - { + } else if (ent instanceof EntitySilverfish) { EntitySilverfish es = (EntitySilverfish) ent; Path pathentity = getPathEntityToEntity(ent, getTarget(ent.getEntityWorld(), pos), getRange()); es.getNavigator().setPath(pathentity, es.getAIMoveSpeed()); return true; - } else if (ent instanceof EntityBlaze) - { + } else if (ent instanceof EntityBlaze) { return true; } return false; } - private boolean useSpecialCase(EntityLiving ent) - { + private boolean useSpecialCase(EntityLiving ent) { return ent instanceof EntitySlime || ent instanceof EntitySilverfish || ent instanceof EntityBlaze; } - public FakePlayer getTarget(World world, BlockPos pos) - { - if (target == null) - { + public FakePlayer getTarget(World world, BlockPos pos) { + if (target == null) { // System.out.println("...Hi? " + pos); target = new Target(world, pos); } @@ -396,17 +317,22 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect return target; } - private class Target extends FakePlayerBM - { - public Target(World world, BlockPos pos) - { - super(world, pos, new GameProfile(null, BloodMagic.MODID + "ArrayAttractor" + ":" + pos)); - posY += 1; - } + @Override + public void writeToNBT(NBTTagCompound tag) { + } - private static class AttractTask extends EntityAIBase - { + @Override + public void readFromNBT(NBTTagCompound tag) { + + } + + @Override + public AlchemyArrayEffect getNewCopy() { + return new AlchemyArrayEffectAttractor(key); + } + + private static class AttractTask extends EntityAIBase { private EntityLiving mob; private BlockPos coord; private FakePlayer target; @@ -414,21 +340,18 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect private boolean started = false; - private AttractTask(EntityLiving mob, FakePlayer target, BlockPos coord) - { + private AttractTask(EntityLiving mob, FakePlayer target, BlockPos coord) { this.mob = mob; this.coord = coord; this.target = target; } @Override - public boolean shouldExecute() - { + public boolean shouldExecute() { boolean res = false; //TODO: TileEntity te = mob.getEntityWorld().getTileEntity(coord); - if (te instanceof TileAlchemyArray) - { + if (te instanceof TileAlchemyArray) { res = true; } @@ -436,55 +359,38 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect } @Override - public void resetTask() - { + public void resetTask() { started = false; updatesSincePathing = 0; } @Override - public boolean isInterruptible() - { + public boolean isInterruptible() { return true; } @Override - public void updateTask() - { - if (!started || updatesSincePathing > 20) - { + public void updateTask() { + if (!started || updatesSincePathing > 20) { started = true; int speed = 1; // mob.getNavigator().setAvoidsWater(false); boolean res = mob.getNavigator().tryMoveToEntityLiving(target, speed); - if (!res) - { + if (!res) { mob.getNavigator().tryMoveToXYZ(target.posX, target.posY + 1, target.posZ, speed); } updatesSincePathing = 0; - } else - { + } else { updatesSincePathing++; } } } - @Override - public void writeToNBT(NBTTagCompound tag) - { - - } - - @Override - public void readFromNBT(NBTTagCompound tag) - { - - } - - @Override - public AlchemyArrayEffect getNewCopy() - { - return new AlchemyArrayEffectAttractor(key); + private class Target extends FakePlayerBM { + public Target(World world, BlockPos pos) { + super(world, pos, new GameProfile(null, BloodMagic.MODID + "ArrayAttractor" + ":" + pos)); + posY += 1; + } } } diff --git a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectBinding.java b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectBinding.java index 0f25ede0..8310f713 100644 --- a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectBinding.java +++ b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectBinding.java @@ -1,5 +1,8 @@ package WayofTime.bloodmagic.alchemyArray; +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting; +import WayofTime.bloodmagic.client.render.alchemyArray.BindingAlchemyCircleRenderer; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; @@ -7,34 +10,25 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting; -import WayofTime.bloodmagic.client.render.alchemyArray.BindingAlchemyCircleRenderer; -public class AlchemyArrayEffectBinding extends AlchemyArrayEffectCrafting -{ - public AlchemyArrayEffectBinding(String key, ItemStack outputStack) - { +public class AlchemyArrayEffectBinding extends AlchemyArrayEffectCrafting { + public AlchemyArrayEffectBinding(String key, ItemStack outputStack) { super(key, outputStack, 200); } @Override - public boolean update(TileEntity tile, int ticksActive) - { - if (ticksActive >= 50 && ticksActive <= 250) - { + public boolean update(TileEntity tile, int ticksActive) { + if (ticksActive >= 50 && ticksActive <= 250) { // TODO: Find a way to spawn lightning from only the server side - // does not render when just spawned on server, not client. this.spawnLightningOnCircle(tile.getWorld(), tile.getPos(), ticksActive); } - if (tile.getWorld().isRemote) - { + if (tile.getWorld().isRemote) { return false; } - if (ticksActive >= 300) - { + if (ticksActive >= 300) { BlockPos pos = tile.getPos(); ItemStack output = outputStack.copy(); @@ -48,10 +42,8 @@ public class AlchemyArrayEffectBinding extends AlchemyArrayEffectCrafting return false; } - public void spawnLightningOnCircle(World world, BlockPos pos, int ticksActive) - { - if (ticksActive % 50 == 0) - { + public void spawnLightningOnCircle(World world, BlockPos pos, int ticksActive) { + if (ticksActive % 50 == 0) { int circle = ticksActive / 50 - 1; float distance = BindingAlchemyCircleRenderer.getDistanceOfCircle(circle, ticksActive); float angle = BindingAlchemyCircleRenderer.getAngleOfCircle(circle, ticksActive); @@ -65,20 +57,17 @@ public class AlchemyArrayEffectBinding extends AlchemyArrayEffectCrafting } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { //EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { //EMPTY } @Override - public AlchemyArrayEffect getNewCopy() - { + public AlchemyArrayEffect getNewCopy() { return new AlchemyArrayEffectBinding(key, outputStack); } } diff --git a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectBounce.java b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectBounce.java index 3b42eed2..7b0211bd 100644 --- a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectBounce.java +++ b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectBounce.java @@ -1,5 +1,7 @@ package WayofTime.bloodmagic.alchemyArray; +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; +import WayofTime.bloodmagic.api.iface.IAlchemyArray; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -7,34 +9,25 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; -import WayofTime.bloodmagic.api.iface.IAlchemyArray; -public class AlchemyArrayEffectBounce extends AlchemyArrayEffect -{ - public AlchemyArrayEffectBounce(String key) - { +public class AlchemyArrayEffectBounce extends AlchemyArrayEffect { + public AlchemyArrayEffectBounce(String key) { super(key); } @Override - public boolean update(TileEntity tile, int ticksActive) - { + public boolean update(TileEntity tile, int ticksActive) { return false; } @Override - public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) - { - if (entity.isSneaking()) - { + public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) { + if (entity.isSneaking()) { return; - } else if (entity.motionY < 0.0D) - { + } else if (entity.motionY < 0.0D) { entity.motionY = -entity.motionY; - if (!(entity instanceof EntityLivingBase)) - { + if (!(entity instanceof EntityLivingBase)) { entity.motionY *= 0.8D; } @@ -43,20 +36,17 @@ public class AlchemyArrayEffectBounce extends AlchemyArrayEffect } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { } @Override - public AlchemyArrayEffect getNewCopy() - { + public AlchemyArrayEffect getNewCopy() { return new AlchemyArrayEffectBounce(key); } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectMovement.java b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectMovement.java index d1d981a6..f7425b3b 100644 --- a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectMovement.java +++ b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectMovement.java @@ -1,5 +1,7 @@ package WayofTime.bloodmagic.alchemyArray; +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; +import WayofTime.bloodmagic.api.iface.IAlchemyArray; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; @@ -7,25 +9,19 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; -import WayofTime.bloodmagic.api.iface.IAlchemyArray; -public class AlchemyArrayEffectMovement extends AlchemyArrayEffect -{ - public AlchemyArrayEffectMovement(String key) - { +public class AlchemyArrayEffectMovement extends AlchemyArrayEffect { + public AlchemyArrayEffectMovement(String key) { super(key); } @Override - public boolean update(TileEntity tile, int ticksActive) - { + public boolean update(TileEntity tile, int ticksActive) { return false; } @Override - public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) - { + public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) { double motionY = 0.5; double speed = 3; EnumFacing direction = array.getRotation(); @@ -33,51 +29,47 @@ public class AlchemyArrayEffectMovement extends AlchemyArrayEffect entity.motionY = motionY; entity.fallDistance = 0; - switch (direction) - { - case NORTH: - entity.motionX = 0; - entity.motionY = motionY; - entity.motionZ = -speed; - break; + switch (direction) { + case NORTH: + entity.motionX = 0; + entity.motionY = motionY; + entity.motionZ = -speed; + break; - case SOUTH: - entity.motionX = 0; - entity.motionY = motionY; - entity.motionZ = speed; - break; + case SOUTH: + entity.motionX = 0; + entity.motionY = motionY; + entity.motionZ = speed; + break; - case WEST: - entity.motionX = -speed; - entity.motionY = motionY; - entity.motionZ = 0; - break; + case WEST: + entity.motionX = -speed; + entity.motionY = motionY; + entity.motionZ = 0; + break; - case EAST: - entity.motionX = speed; - entity.motionY = motionY; - entity.motionZ = 0; - break; - default: - break; + case EAST: + entity.motionX = speed; + entity.motionY = motionY; + entity.motionZ = 0; + break; + default: + break; } } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { } @Override - public AlchemyArrayEffect getNewCopy() - { + public AlchemyArrayEffect getNewCopy() { return new AlchemyArrayEffectMovement(key); } } diff --git a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectSigil.java b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectSigil.java index 20d22c40..afa6ce77 100644 --- a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectSigil.java +++ b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectSigil.java @@ -1,26 +1,22 @@ package WayofTime.bloodmagic.alchemyArray; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; import WayofTime.bloodmagic.api.iface.ISigil; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; -public class AlchemyArrayEffectSigil extends AlchemyArrayEffect -{ +public class AlchemyArrayEffectSigil extends AlchemyArrayEffect { private final ISigil sigil; - public AlchemyArrayEffectSigil(String key, ISigil sigil) - { + public AlchemyArrayEffectSigil(String key, ISigil sigil) { super(key); this.sigil = sigil; } @Override - public boolean update(TileEntity tile, int ticksActive) - { + public boolean update(TileEntity tile, int ticksActive) { //TODO: Need particles. - if (sigil.hasArrayEffect()) - { + if (sigil.hasArrayEffect()) { sigil.performArrayEffect(tile.getWorld(), tile.getPos()); } @@ -28,20 +24,17 @@ public class AlchemyArrayEffectSigil extends AlchemyArrayEffect } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { } @Override - public AlchemyArrayEffect getNewCopy() - { + public AlchemyArrayEffect getNewCopy() { return new AlchemyArrayEffectSigil(key, sigil); } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectSkeletonTurret.java b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectSkeletonTurret.java index 8396bec4..464cd6cd 100644 --- a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectSkeletonTurret.java +++ b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectSkeletonTurret.java @@ -1,9 +1,8 @@ package WayofTime.bloodmagic.alchemyArray; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; +import WayofTime.bloodmagic.tile.TileAlchemyArray; +import com.google.common.base.Predicate; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIBase; @@ -18,35 +17,29 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.util.FakePlayer; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; -import WayofTime.bloodmagic.tile.TileAlchemyArray; -import com.google.common.base.Predicate; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; /** * Credits for the initial code go to Crazy Pants of EIO. */ -public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect -{ - private EntitySkeleton turret; - - public static Predicate checkSkeleton = new Predicate() - { +public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect { + public static Predicate checkSkeleton = new Predicate() { @Override - public boolean apply(EntityMob input) - { + public boolean apply(EntityMob input) { return !(input instanceof EntitySkeleton); } }; + private EntitySkeleton turret; - public AlchemyArrayEffectSkeletonTurret(String key) - { + public AlchemyArrayEffectSkeletonTurret(String key) { super(key); } @Override - public boolean update(TileEntity tile, int ticksActive) - { + public boolean update(TileEntity tile, int ticksActive) { // if (tile.getWorld().isRemote) // { // return false; @@ -54,15 +47,13 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect BlockPos pos = tile.getPos(); - if (turret != null && !turret.isDead) - { + if (turret != null && !turret.isDead) { double x = (pos.getX() + 0.5D - turret.posX); double y = (pos.getY() + 1D - turret.posY); double z = (pos.getZ() + 0.5D - turret.posZ); double distance = Math.sqrt(x * x + y * y + z * z); - if (distance < 2) - { + if (distance < 2) { // turret.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 100, 100)); return false; } @@ -72,8 +63,7 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect List skeletonsInRange = world.getEntitiesWithinAABB(EntitySkeleton.class, getBounds(pos)); - for (EntitySkeleton entity : skeletonsInRange) - { + for (EntitySkeleton entity : skeletonsInRange) { if (!entity.isDead)// && isMobInFilter(ent)) { modifyAITargetTasks(entity); @@ -85,13 +75,11 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect return false; } - public AxisAlignedBB getBounds(BlockPos pos) - { + public AxisAlignedBB getBounds(BlockPos pos) { return new AxisAlignedBB(pos).expand(getRange(), getRange(), getRange()); } - public float getRange() - { + public float getRange() { return 0; } @@ -105,8 +93,7 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect // e.getEntityData().setBoolean("BM:tracked", true); // } - private boolean modifyAITargetTasks(EntitySkeleton entity) - { + private boolean modifyAITargetTasks(EntitySkeleton entity) { cancelCurrentTargetTasks(entity); // entity.setCombatTask(); @@ -116,13 +103,11 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect return true; } - private void cancelCurrentTargetTasks(EntityLiving entity) - { + private void cancelCurrentTargetTasks(EntityLiving entity) { Iterator iterator = entity.targetTasks.taskEntries.iterator(); List currentTasks = new ArrayList(); - while (iterator.hasNext()) - { + while (iterator.hasNext()) { EntityAITaskEntry entityaitaskentry = iterator.next(); if (entityaitaskentry != null)// && entityaitaskentry.action instanceof EntityAITarget) { @@ -130,14 +115,27 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect } } - for (EntityAITaskEntry task : currentTasks) - { + for (EntityAITaskEntry task : currentTasks) { entity.targetTasks.removeTask(task.action); } } - private static class AttractTask extends EntityAIBase - { + @Override + public void writeToNBT(NBTTagCompound tag) { + + } + + @Override + public void readFromNBT(NBTTagCompound tag) { + + } + + @Override + public AlchemyArrayEffect getNewCopy() { + return new AlchemyArrayEffectSkeletonTurret(key); + } + + private static class AttractTask extends EntityAIBase { private EntityLiving mob; private BlockPos coord; private FakePlayer target; @@ -145,21 +143,18 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect private boolean started = false; - private AttractTask(EntityLiving mob, FakePlayer target, BlockPos coord) - { + private AttractTask(EntityLiving mob, FakePlayer target, BlockPos coord) { this.mob = mob; this.coord = coord; this.target = target; } @Override - public boolean shouldExecute() - { + public boolean shouldExecute() { boolean res = false; //TODO: TileEntity te = mob.getEntityWorld().getTileEntity(coord); - if (te instanceof TileAlchemyArray) - { + if (te instanceof TileAlchemyArray) { res = true; } @@ -167,55 +162,31 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect } @Override - public void resetTask() - { + public void resetTask() { started = false; updatesSincePathing = 0; } @Override - public boolean isInterruptible() - { + public boolean isInterruptible() { return true; } @Override - public void updateTask() - { - if (!started || updatesSincePathing > 20) - { + public void updateTask() { + if (!started || updatesSincePathing > 20) { started = true; int speed = 1; // mob.getNavigator().setAvoidsWater(false); boolean res = mob.getNavigator().tryMoveToEntityLiving(target, speed); - if (!res) - { + if (!res) { mob.getNavigator().tryMoveToXYZ(target.posX, target.posY + 1, target.posZ, speed); } updatesSincePathing = 0; - } else - { + } else { updatesSincePathing++; } } } - - @Override - public void writeToNBT(NBTTagCompound tag) - { - - } - - @Override - public void readFromNBT(NBTTagCompound tag) - { - - } - - @Override - public AlchemyArrayEffect getNewCopy() - { - return new AlchemyArrayEffectSkeletonTurret(key); - } } diff --git a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectUpdraft.java b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectUpdraft.java index 6579a254..2b778e11 100644 --- a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectUpdraft.java +++ b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectUpdraft.java @@ -1,30 +1,26 @@ package WayofTime.bloodmagic.alchemyArray; +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; +import WayofTime.bloodmagic.api.iface.IAlchemyArray; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; -import WayofTime.bloodmagic.api.iface.IAlchemyArray; -public class AlchemyArrayEffectUpdraft extends AlchemyArrayEffect -{ - public AlchemyArrayEffectUpdraft(String key) - { +public class AlchemyArrayEffectUpdraft extends AlchemyArrayEffect { + public AlchemyArrayEffectUpdraft(String key) { super(key); } @Override - public boolean update(TileEntity tile, int ticksActive) - { + public boolean update(TileEntity tile, int ticksActive) { return false; } @Override - public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) - { + public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) { double motionY = 1.5; entity.fallDistance = 0; @@ -33,20 +29,17 @@ public class AlchemyArrayEffectUpdraft extends AlchemyArrayEffect } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { } @Override - public AlchemyArrayEffect getNewCopy() - { + public AlchemyArrayEffect getNewCopy() { return new AlchemyArrayEffectUpdraft(key); } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java b/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java index 2f15c9b6..23cc695f 100644 --- a/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java +++ b/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java @@ -1,9 +1,21 @@ package WayofTime.bloodmagic.altar; -import java.util.List; - +import WayofTime.bloodmagic.api.BlockStack; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.altar.*; +import WayofTime.bloodmagic.api.event.AltarCraftedEvent; import WayofTime.bloodmagic.api.orb.BloodOrb; +import WayofTime.bloodmagic.api.orb.IBloodOrb; +import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry; +import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry.AltarRecipe; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; import WayofTime.bloodmagic.api_impl.BloodMagicAPI; +import WayofTime.bloodmagic.block.BlockBloodRune; +import WayofTime.bloodmagic.block.BlockLifeEssence; +import WayofTime.bloodmagic.tile.TileAltar; +import WayofTime.bloodmagic.util.Utils; +import com.google.common.base.Enums; +import com.google.common.base.Strings; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -19,38 +31,26 @@ import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.capability.FluidTankPropertiesWrapper; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidTankProperties; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.api.BlockStack; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.altar.AltarComponent; -import WayofTime.bloodmagic.api.altar.AltarUpgrade; -import WayofTime.bloodmagic.api.altar.EnumAltarComponent; -import WayofTime.bloodmagic.api.altar.EnumAltarTier; -import WayofTime.bloodmagic.api.altar.IAltarComponent; -import WayofTime.bloodmagic.api.event.AltarCraftedEvent; -import WayofTime.bloodmagic.api.orb.IBloodOrb; -import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry; -import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry.AltarRecipe; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -import WayofTime.bloodmagic.block.BlockBloodRune; -import WayofTime.bloodmagic.block.BlockLifeEssence; -import WayofTime.bloodmagic.tile.TileAltar; -import WayofTime.bloodmagic.util.Utils; +import java.util.List; -import com.google.common.base.Enums; -import com.google.common.base.Strings; - -public class BloodAltar implements IFluidHandler -{ - private TileAltar tileAltar; - private int internalCounter = 0; +public class BloodAltar implements IFluidHandler { + static { + EnumAltarTier.ONE.buildComponents(); + EnumAltarTier.TWO.buildComponents(); + EnumAltarTier.THREE.buildComponents(); + EnumAltarTier.FOUR.buildComponents(); + EnumAltarTier.FIVE.buildComponents(); + EnumAltarTier.SIX.buildComponents(); + } public boolean isActive; protected FluidStack fluidOutput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0); protected FluidStack fluidInput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0); + private TileAltar tileAltar; + private int internalCounter = 0; private EnumAltarTier altarTier = EnumAltarTier.ONE; private AltarUpgrade upgrade; private int capacity = Fluid.BUCKET_VOLUME * 10; @@ -73,181 +73,21 @@ public class BloodAltar implements IFluidHandler private int progress; private int lockdownDuration; private int demonBloodDuration; - private int totalCharge = 0; //TODO save private int chargingRate = 0; private int chargingFrequency = 0; private int maxCharge = 0; - private int cooldownAfterCrafting = 60; - private AltarRecipe recipe; private ItemStack result = ItemStack.EMPTY; - private EnumAltarTier currentTierDisplayed = EnumAltarTier.ONE; - public BloodAltar(TileAltar tileAltar) - { + public BloodAltar(TileAltar tileAltar) { this.tileAltar = tileAltar; } - static - { - EnumAltarTier.ONE.buildComponents(); - EnumAltarTier.TWO.buildComponents(); - EnumAltarTier.THREE.buildComponents(); - EnumAltarTier.FOUR.buildComponents(); - EnumAltarTier.FIVE.buildComponents(); - EnumAltarTier.SIX.buildComponents(); - } - - public static EnumAltarTier getAltarTier(World world, BlockPos pos) - { - for (int i = EnumAltarTier.MAXTIERS - 1; i >= 1; i--) - { - if (checkAltarIsValid(world, pos, i)) - { - return EnumAltarTier.values()[i]; - } - } - - return EnumAltarTier.ONE; - } - - public static boolean checkAltarIsValid(World world, BlockPos worldPos, int altarTier) - { - for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents()) - { - BlockPos componentPos = worldPos.add(altarComponent.getOffset()); - IBlockState state = world.getBlockState(componentPos); - - if (altarComponent.getComponent() == EnumAltarComponent.NOTAIR && world.isAirBlock(componentPos)) - return false; - - if (state.getBlock() instanceof IAltarComponent) { - EnumAltarComponent component = ((IAltarComponent) state.getBlock()).getType(world, state, componentPos); - if (component == null || component != altarComponent.getComponent()) - return false; - } - - EnumAltarComponent component = BloodMagicAPI.INSTANCE.getAltarComponents().get(state); - if (component == null || component != altarComponent.getComponent()) - return false; - } - - return true; - } - - public static Pair getAltarMissingBlock(World world, BlockPos worldPos, int altarTier) - { - if (altarTier >= EnumAltarTier.MAXTIERS) - { - return null; - } - - for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents()) - { - BlockPos componentPos = worldPos.add(altarComponent.getOffset()); - BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos))); - - if (altarComponent.getComponent() != EnumAltarComponent.NOTAIR) - { - if (worldBlock.getBlock() instanceof IAltarComponent) - { - EnumAltarComponent component = ((IAltarComponent) worldBlock.getBlock()).getType(world, worldBlock.getState(), componentPos); - if (component == null || component != altarComponent.getComponent()) - { - return Pair.of(componentPos, altarComponent.getComponent()); - } - } else if (worldBlock.getBlock() != Utils.getBlockForComponent(altarComponent.getComponent())) - { - return new ImmutablePair(componentPos, altarComponent.getComponent()); - } - } else - { - if (world.isAirBlock(componentPos)) - { - return Pair.of(componentPos, altarComponent.getComponent()); - } - } - } - - return null; - } - - public static AltarUpgrade getUpgrades(World world, BlockPos pos, EnumAltarTier altarTier) - { - if (world.isRemote) - { - return null; - } - - AltarUpgrade upgrades = new AltarUpgrade(); - List list = altarTier.getAltarComponents(); - - for (AltarComponent altarComponent : list) - { - BlockPos componentPos = pos.add(altarComponent.getOffset()); - - if (altarComponent.isUpgradeSlot()) - { - BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos))); - - if (worldBlock.getBlock() instanceof BlockBloodRune) - { - switch (((BlockBloodRune) worldBlock.getBlock()).getRuneEffect(worldBlock.getMeta())) - { - case 1: - upgrades.addSpeed(); - break; - - case 2: - upgrades.addEfficiency(); - break; - - case 3: - upgrades.addSacrifice(); - break; - - case 4: - upgrades.addSelfSacrifice(); - break; - - case 5: - upgrades.addDisplacement(); - break; - - case 6: - upgrades.addCapacity(); - break; - - case 7: - upgrades.addBetterCapacity(); - break; - - case 8: - upgrades.addOrbCapacity(); - break; - - case 9: - upgrades.addAcceleration(); - break; - - case 10: - upgrades.addCharging(); - break; - } - } - } - } - - return upgrades; - } - - public void readFromNBT(NBTTagCompound tagCompound) - { - if (!tagCompound.hasKey(Constants.NBT.EMPTY)) - { + public void readFromNBT(NBTTagCompound tagCompound) { + if (!tagCompound.hasKey(Constants.NBT.EMPTY)) { FluidStack fluid = FluidStack.loadFluidStackFromNBT(tagCompound); if (fluid != null) @@ -290,8 +130,7 @@ public class BloodAltar implements IFluidHandler currentTierDisplayed = Enums.getIfPresent(EnumAltarTier.class, tagCompound.getString(Constants.NBT.ALTAR_CURRENT_TIER_DISPLAYED)).or(EnumAltarTier.ONE); } - public void writeToNBT(NBTTagCompound tagCompound) - { + public void writeToNBT(NBTTagCompound tagCompound) { if (fluid != null) fluid.writeToNBT(tagCompound); @@ -334,8 +173,7 @@ public class BloodAltar implements IFluidHandler tagCompound.setString(Constants.NBT.ALTAR_CURRENT_TIER_DISPLAYED, currentTierDisplayed.name()); } - public void startCycle() - { + public void startCycle() { if (tileAltar.getWorld() != null) tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3); @@ -349,14 +187,11 @@ public class BloodAltar implements IFluidHandler ItemStack input = tileAltar.getStackInSlot(0); - if (!input.isEmpty()) - { + if (!input.isEmpty()) { // Do recipes AltarRecipe recipe = AltarRecipeRegistry.getRecipeForInput(input); - if (recipe != null) - { - if (recipe.doesRequiredItemMatch(input, altarTier)) - { + if (recipe != null) { + if (recipe.doesRequiredItemMatch(input, altarTier)) { this.isActive = true; this.recipe = recipe; this.result = recipe.getOutput().isEmpty() ? ItemStack.EMPTY : new ItemStack(recipe.getOutput().getItem(), 1, recipe.getOutput().getMetadata()); @@ -372,8 +207,7 @@ public class BloodAltar implements IFluidHandler isActive = false; } - public void update() - { + public void update() { World world = tileAltar.getWorld(); BlockPos pos = tileAltar.getPos(); @@ -386,17 +220,14 @@ public class BloodAltar implements IFluidHandler if (lockdownDuration > 0) lockdownDuration--; - if (internalCounter % 20 == 0) - { - for (EnumFacing facing : EnumFacing.VALUES) - { + if (internalCounter % 20 == 0) { + for (EnumFacing facing : EnumFacing.VALUES) { BlockPos newPos = pos.offset(facing); IBlockState block = world.getBlockState(newPos); block.getBlock().onNeighborChange(world, newPos, pos); } } - if (internalCounter % (Math.max(20 - this.accelerationUpgrades, 1)) == 0) - { + if (internalCounter % (Math.max(20 - this.accelerationUpgrades, 1)) == 0) { int syphonMax = (int) (20 * this.dislocationMultiplier); int fluidInputted; int fluidOutputted; @@ -411,8 +242,7 @@ public class BloodAltar implements IFluidHandler tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3); } - if (internalCounter % this.getChargingFrequency() == 0 && !this.isActive) - { + if (internalCounter % this.getChargingFrequency() == 0 && !this.isActive) { int chargeInputted = Math.min(chargingRate, this.fluid.amount); chargeInputted = Math.min(chargeInputted, maxCharge - totalCharge); totalCharge += chargeInputted; @@ -426,10 +256,8 @@ public class BloodAltar implements IFluidHandler updateAltar(); } - private void updateAltar() - { - if (!isActive) - { + private void updateAltar() { + if (!isActive) { if (cooldownAfterCrafting > 0) cooldownAfterCrafting--; return; @@ -446,13 +274,11 @@ public class BloodAltar implements IFluidHandler if (world.isRemote) return; - if (!canBeFilled) - { + if (!canBeFilled) { boolean hasOperated = false; int stackSize = input.getCount(); - if (totalCharge > 0) - { + if (totalCharge > 0) { int chargeDrained = Math.min(liquidRequired * stackSize - progress, totalCharge); totalCharge -= chargeDrained; @@ -460,8 +286,7 @@ public class BloodAltar implements IFluidHandler hasOperated = true; } - if (fluid != null && fluid.amount >= 1) - { + if (fluid != null && fluid.amount >= 1) { int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount); if (liquidDrained > (liquidRequired * stackSize - progress)) @@ -472,27 +297,22 @@ public class BloodAltar implements IFluidHandler hasOperated = true; - if (internalCounter % 4 == 0 && world instanceof WorldServer) - { + if (internalCounter % 4 == 0 && world instanceof WorldServer) { WorldServer server = (WorldServer) world; server.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.2, 0, 0.2, 0); } - } else if (!hasOperated && progress > 0) - { + } else if (!hasOperated && progress > 0) { progress -= (int) (efficiencyMultiplier * drainRate); - if (internalCounter % 2 == 0 && world instanceof WorldServer) - { + if (internalCounter % 2 == 0 && world instanceof WorldServer) { WorldServer server = (WorldServer) world; server.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.1, 0, 0.1, 0); } } - if (hasOperated) - { - if (progress >= liquidRequired * stackSize) - { + if (hasOperated) { + if (progress >= liquidRequired * stackSize) { ItemStack result = this.result; if (!result.isEmpty()) @@ -502,8 +322,7 @@ public class BloodAltar implements IFluidHandler tileAltar.setInventorySlotContents(0, result); progress = 0; - if (world instanceof WorldServer) - { + if (world instanceof WorldServer) { WorldServer server = (WorldServer) world; server.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 40, 0.3, 0, 0.3, 0); } @@ -512,8 +331,7 @@ public class BloodAltar implements IFluidHandler this.isActive = false; } } - } else - { + } else { ItemStack returnedItem = tileAltar.getStackInSlot(0); if (returnedItem.isEmpty() || !(returnedItem.getItem() instanceof IBloodOrb)) @@ -530,16 +348,14 @@ public class BloodAltar implements IFluidHandler if (Strings.isNullOrEmpty(ownerUUID)) return; - if (fluid != null && fluid.amount >= 1) - { + if (fluid != null && fluid.amount >= 1) { int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount); BloodOrb orb = item.getOrb(returnedItem); int drain = orb == null ? 0 : NetworkHelper.getSoulNetwork(ownerUUID).add(liquidDrained, (int) (orb.getCapacity() * this.orbCapacityMultiplier)); fluid.amount = fluid.amount - drain; - if (drain > 0 && internalCounter % 4 == 0 && world instanceof WorldServer) - { + if (drain > 0 && internalCounter % 4 == 0 && world instanceof WorldServer) { WorldServer server = (WorldServer) world; server.spawnParticle(EnumParticleTypes.SPELL_WITCH, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0, 0, 0, 0.001); } @@ -549,8 +365,7 @@ public class BloodAltar implements IFluidHandler tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3); } - public void checkTier() - { + public void checkTier() { EnumAltarTier tier = BloodAltar.getAltarTier(tileAltar.getWorld(), tileAltar.getPos()); this.altarTier = tier; @@ -559,8 +374,7 @@ public class BloodAltar implements IFluidHandler if (tier.equals(currentTierDisplayed)) currentTierDisplayed = EnumAltarTier.ONE; - if (tier.equals(EnumAltarTier.ONE)) - { + if (tier.equals(EnumAltarTier.ONE)) { upgrade = null; isUpgraded = false; this.consumptionMultiplier = 0; @@ -576,8 +390,7 @@ public class BloodAltar implements IFluidHandler this.maxCharge = 0; this.totalCharge = 0; return; - } else if (!tier.equals(EnumAltarTier.ONE) && upgrade != null) - { + } else if (!tier.equals(EnumAltarTier.ONE) && upgrade != null) { this.isUpgraded = true; this.accelerationUpgrades = upgrade.getAccelerationCount(); this.consumptionMultiplier = (float) (0.20 * upgrade.getSpeedCount()); @@ -607,128 +420,103 @@ public class BloodAltar implements IFluidHandler tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3); } - public int fillMainTank(int amount) - { + public int fillMainTank(int amount) { int filledAmount = Math.min(capacity - fluid.amount, amount); fluid.amount += filledAmount; return filledAmount; } - public void sacrificialDaggerCall(int amount, boolean isSacrifice) - { - if (this.lockdownDuration > 0) - { + public void sacrificialDaggerCall(int amount, boolean isSacrifice) { + if (this.lockdownDuration > 0) { int amt = (int) Math.min(bufferCapacity - fluidInput.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount); fluidInput.amount += amt; - } else - { + } else { fluid.amount += Math.min(capacity - fluid.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount); } } - public void setMainFluid(FluidStack fluid) - { + public void setMainFluid(FluidStack fluid) { this.fluid = fluid; } - public void setOutputFluid(FluidStack fluid) - { + public void setOutputFluid(FluidStack fluid) { this.fluidOutput = fluid; } - public void setInputFluid(FluidStack fluid) - { + public void setInputFluid(FluidStack fluid) { this.fluidInput = fluid; } - public AltarUpgrade getUpgrade() - { + public AltarUpgrade getUpgrade() { return upgrade; } - public void setUpgrade(AltarUpgrade upgrade) - { + public void setUpgrade(AltarUpgrade upgrade) { this.upgrade = upgrade; } - public int getCapacity() - { + public int getCapacity() { return capacity; } - public FluidStack getFluid() - { + public FluidStack getFluid() { return fluid; } - public int getFluidAmount() - { + public int getFluidAmount() { return fluid.amount; } - public int getCurrentBlood() - { + public int getCurrentBlood() { return getFluidAmount(); } - public EnumAltarTier getTier() - { + public EnumAltarTier getTier() { return altarTier; } - public void setTier(EnumAltarTier tier) - { + public void setTier(EnumAltarTier tier) { this.altarTier = tier; } - public int getProgress() - { + public int getProgress() { return progress; } - public float getSacrificeMultiplier() - { + public float getSacrificeMultiplier() { return sacrificeEfficiencyMultiplier; } - public float getSelfSacrificeMultiplier() - { + public float getSelfSacrificeMultiplier() { return selfSacrificeEfficiencyMultiplier; } - public float getOrbMultiplier() - { + public float getOrbMultiplier() { return orbCapacityMultiplier; } - public float getDislocationMultiplier() - { + public float getDislocationMultiplier() { return dislocationMultiplier; } - public float getConsumptionMultiplier() - { + public float getConsumptionMultiplier() { return consumptionMultiplier; } - public float getConsumptionRate() - { + public float getConsumptionRate() { return consumptionRate; } - public int getLiquidRequired() - { + public int getLiquidRequired() { return liquidRequired; } - public int getBufferCapacity() - { + public int getBufferCapacity() { return bufferCapacity; } - public boolean setCurrentTierDisplayed(EnumAltarTier altarTier) - { + public boolean setCurrentTierDisplayed(EnumAltarTier altarTier) { if (currentTierDisplayed == altarTier) return false; else @@ -736,99 +524,79 @@ public class BloodAltar implements IFluidHandler return true; } - public void addToDemonBloodDuration(int dur) - { + public void addToDemonBloodDuration(int dur) { this.demonBloodDuration += dur; } - public boolean hasDemonBlood() - { + public boolean hasDemonBlood() { return this.demonBloodDuration > 0; } - public void decrementDemonBlood() - { + public void decrementDemonBlood() { this.demonBloodDuration = Math.max(0, this.demonBloodDuration - 1); } - public void setActive() - { - if (tileAltar.getStackInSlot(0).isEmpty()) - { + public void setActive() { + if (tileAltar.getStackInSlot(0).isEmpty()) { isActive = false; } } - public boolean isActive() - { + public boolean isActive() { return isActive; } - public void requestPauseAfterCrafting(int amount) - { - if (this.isActive) - { + public void requestPauseAfterCrafting(int amount) { + if (this.isActive) { this.cooldownAfterCrafting = amount; } } - public int getChargingRate() - { + public int getChargingRate() { return chargingRate; } - public int getTotalCharge() - { + public int getTotalCharge() { return totalCharge; } - public int getChargingFrequency() - { + public int getChargingFrequency() { return chargingFrequency == 0 ? 1 : chargingFrequency; } @Override - public int fill(FluidStack resource, boolean doFill) - { - if (resource == null || resource.getFluid() != BlockLifeEssence.getLifeEssence()) - { + public int fill(FluidStack resource, boolean doFill) { + if (resource == null || resource.getFluid() != BlockLifeEssence.getLifeEssence()) { return 0; } - if (!doFill) - { - if (fluidInput == null) - { + if (!doFill) { + if (fluidInput == null) { return Math.min(bufferCapacity, resource.amount); } - if (!fluidInput.isFluidEqual(resource)) - { + if (!fluidInput.isFluidEqual(resource)) { return 0; } return Math.min(bufferCapacity - fluidInput.amount, resource.amount); } - if (fluidInput == null) - { + if (fluidInput == null) { fluidInput = new FluidStack(resource, Math.min(bufferCapacity, resource.amount)); return fluidInput.amount; } - if (!fluidInput.isFluidEqual(resource)) - { + if (!fluidInput.isFluidEqual(resource)) { return 0; } int filled = bufferCapacity - fluidInput.amount; - if (resource.amount < filled) - { + if (resource.amount < filled) { fluidInput.amount += resource.amount; filled = resource.amount; - } else - { + } else { fluidInput.amount = bufferCapacity; } @@ -836,44 +604,160 @@ public class BloodAltar implements IFluidHandler } @Override - public FluidStack drain(FluidStack resource, boolean doDrain) - { - if (resource == null || !resource.isFluidEqual(fluidOutput)) - { + public FluidStack drain(FluidStack resource, boolean doDrain) { + if (resource == null || !resource.isFluidEqual(fluidOutput)) { return null; } return drain(resource.amount, doDrain); } @Override - public FluidStack drain(int maxDrain, boolean doDrain) - { - if (fluidOutput == null) - { + public FluidStack drain(int maxDrain, boolean doDrain) { + if (fluidOutput == null) { return null; } int drained = maxDrain; - if (fluidOutput.amount < drained) - { + if (fluidOutput.amount < drained) { drained = fluidOutput.amount; } FluidStack stack = new FluidStack(fluidOutput, drained); - if (doDrain) - { + if (doDrain) { fluidOutput.amount -= drained; } return stack; } @Override - public IFluidTankProperties[] getTankProperties() - { - return new IFluidTankProperties[] { new FluidTankPropertiesWrapper(new FluidTank(fluid, capacity)) }; + public IFluidTankProperties[] getTankProperties() { + return new IFluidTankProperties[]{new FluidTankPropertiesWrapper(new FluidTank(fluid, capacity))}; } public EnumAltarTier getCurrentTierDisplayed() { return currentTierDisplayed; } + + public static EnumAltarTier getAltarTier(World world, BlockPos pos) { + for (int i = EnumAltarTier.MAXTIERS - 1; i >= 1; i--) { + if (checkAltarIsValid(world, pos, i)) { + return EnumAltarTier.values()[i]; + } + } + + return EnumAltarTier.ONE; + } + + public static boolean checkAltarIsValid(World world, BlockPos worldPos, int altarTier) { + for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents()) { + BlockPos componentPos = worldPos.add(altarComponent.getOffset()); + IBlockState state = world.getBlockState(componentPos); + + if (altarComponent.getComponent() == EnumAltarComponent.NOTAIR && world.isAirBlock(componentPos)) + return false; + + if (state.getBlock() instanceof IAltarComponent) { + EnumAltarComponent component = ((IAltarComponent) state.getBlock()).getType(world, state, componentPos); + if (component == null || component != altarComponent.getComponent()) + return false; + } + + EnumAltarComponent component = BloodMagicAPI.INSTANCE.getAltarComponents().get(state); + if (component == null || component != altarComponent.getComponent()) + return false; + } + + return true; + } + + public static Pair getAltarMissingBlock(World world, BlockPos worldPos, int altarTier) { + if (altarTier >= EnumAltarTier.MAXTIERS) { + return null; + } + + for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents()) { + BlockPos componentPos = worldPos.add(altarComponent.getOffset()); + BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos))); + + if (altarComponent.getComponent() != EnumAltarComponent.NOTAIR) { + if (worldBlock.getBlock() instanceof IAltarComponent) { + EnumAltarComponent component = ((IAltarComponent) worldBlock.getBlock()).getType(world, worldBlock.getState(), componentPos); + if (component == null || component != altarComponent.getComponent()) { + return Pair.of(componentPos, altarComponent.getComponent()); + } + } else if (worldBlock.getBlock() != Utils.getBlockForComponent(altarComponent.getComponent())) { + return new ImmutablePair(componentPos, altarComponent.getComponent()); + } + } else { + if (world.isAirBlock(componentPos)) { + return Pair.of(componentPos, altarComponent.getComponent()); + } + } + } + + return null; + } + + public static AltarUpgrade getUpgrades(World world, BlockPos pos, EnumAltarTier altarTier) { + if (world.isRemote) { + return null; + } + + AltarUpgrade upgrades = new AltarUpgrade(); + List list = altarTier.getAltarComponents(); + + for (AltarComponent altarComponent : list) { + BlockPos componentPos = pos.add(altarComponent.getOffset()); + + if (altarComponent.isUpgradeSlot()) { + BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos))); + + if (worldBlock.getBlock() instanceof BlockBloodRune) { + switch (((BlockBloodRune) worldBlock.getBlock()).getRuneEffect(worldBlock.getMeta())) { + case 1: + upgrades.addSpeed(); + break; + + case 2: + upgrades.addEfficiency(); + break; + + case 3: + upgrades.addSacrifice(); + break; + + case 4: + upgrades.addSelfSacrifice(); + break; + + case 5: + upgrades.addDisplacement(); + break; + + case 6: + upgrades.addCapacity(); + break; + + case 7: + upgrades.addBetterCapacity(); + break; + + case 8: + upgrades.addOrbCapacity(); + break; + + case 9: + upgrades.addAcceleration(); + break; + + case 10: + upgrades.addCharging(); + break; + } + } + } + } + + return upgrades; + } } diff --git a/src/main/java/WayofTime/bloodmagic/annot/Handler.java b/src/main/java/WayofTime/bloodmagic/annot/Handler.java index 7ac96732..0e972824 100644 --- a/src/main/java/WayofTime/bloodmagic/annot/Handler.java +++ b/src/main/java/WayofTime/bloodmagic/annot/Handler.java @@ -11,6 +11,5 @@ import java.lang.annotation.Target; */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) -public @interface Handler -{ +public @interface Handler { } diff --git a/src/main/java/WayofTime/bloodmagic/api/BlockStack.java b/src/main/java/WayofTime/bloodmagic/api/BlockStack.java index 264f348b..72752c81 100644 --- a/src/main/java/WayofTime/bloodmagic/api/BlockStack.java +++ b/src/main/java/WayofTime/bloodmagic/api/BlockStack.java @@ -6,32 +6,22 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockStack -{ +public class BlockStack { private final Block block; private final int meta; private final IBlockState state; - public BlockStack(Block block, int meta) - { + public BlockStack(Block block, int meta) { this.block = block; this.meta = meta; this.state = block.getStateFromMeta(meta); } - public BlockStack(Block block) - { + public BlockStack(Block block) { this(block, 0); } - public static BlockStack getStackFromPos(World world, BlockPos pos) - { - IBlockState state = world.getBlockState(pos); - return new BlockStack(state.getBlock(), state.getBlock().getMetaFromState(state)); - } - - public ItemStack getItemStack() - { + public ItemStack getItemStack() { return new ItemStack(block, 1, meta); } @@ -66,8 +56,12 @@ public class BlockStack } @Override - public String toString() - { + public String toString() { return getBlock().getRegistryName() + ":" + getMeta(); } + + public static BlockStack getStackFromPos(World world, BlockPos pos) { + IBlockState state = world.getBlockState(pos); + return new BlockStack(state.getBlock(), state.getBlock().getMetaFromState(state)); + } } diff --git a/src/main/java/WayofTime/bloodmagic/api/BloodMagicAPI.java b/src/main/java/WayofTime/bloodmagic/api/BloodMagicAPI.java index 01b09f14..e69115f3 100644 --- a/src/main/java/WayofTime/bloodmagic/api/BloodMagicAPI.java +++ b/src/main/java/WayofTime/bloodmagic/api/BloodMagicAPI.java @@ -5,12 +5,11 @@ import net.minecraft.util.DamageSource; /** * The primary API class. Includes helper methods and blacklists. - * + *

* Some API methods can be used via IMC instead. The supported methods are: */ // TODO - Nuke this class -public class BloodMagicAPI -{ +public class BloodMagicAPI { public static boolean loggingEnabled; public static LogHelper logger = new LogHelper("BloodMagic|API"); diff --git a/src/main/java/WayofTime/bloodmagic/api/Constants.java b/src/main/java/WayofTime/bloodmagic/api/Constants.java index 92f8b7a6..4ead21b0 100644 --- a/src/main/java/WayofTime/bloodmagic/api/Constants.java +++ b/src/main/java/WayofTime/bloodmagic/api/Constants.java @@ -1,16 +1,14 @@ package WayofTime.bloodmagic.api; -import java.util.Locale; - import WayofTime.bloodmagic.BloodMagic; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.registry.ForgeRegistries; -public class Constants -{ - public static class NBT - { +import java.util.Locale; + +public class Constants { + public static class NBT { public static final String OWNER_UUID = "ownerUUID"; public static final String OWNER_NAME = "ownerNAME"; public static final String USES = "uses"; @@ -129,13 +127,11 @@ public class Constants public static final String TANK = "tank"; } - public static class Mod - { + public static class Mod { public static final String DOMAIN = BloodMagic.MODID.toLowerCase(Locale.ENGLISH) + ":"; } - public static final class Gui - { + public static final class Gui { public static final int TELEPOSER_GUI = 0; public static final int SOUL_FORGE_GUI = 1; public static final int ROUTING_NODE_GUI = 2; @@ -144,8 +140,7 @@ public class Constants public static final int SIGIL_HOLDING_GUI = 5; } - public static class Compat - { + public static class Compat { public static final String JEI_CATEGORY_ALTAR = BloodMagic.MODID + ":altar"; public static final String JEI_CATEGORY_BINDING = BloodMagic.MODID + ":binding"; public static final String JEI_CATEGORY_ALCHEMYARRAY = BloodMagic.MODID + ":alchemyArray"; @@ -163,8 +158,7 @@ public class Constants public static final Item THAUMCRAFT_GOGGLES = ForgeRegistries.ITEMS.getValue(new ResourceLocation("Thaumcraft", "goggles")); } - public static class Misc - { + public static class Misc { public static final int POTION_ARRAY_SIZE = 256; public static final float ALTERED_STEP_HEIGHT = 1.00314159f; public static final int NIGHT_VISION_CONSTANT_BEGIN = 30002; diff --git a/src/main/java/WayofTime/bloodmagic/api/DamageSourceBloodMagic.java b/src/main/java/WayofTime/bloodmagic/api/DamageSourceBloodMagic.java index 6cd4140c..d9747ad3 100644 --- a/src/main/java/WayofTime/bloodmagic/api/DamageSourceBloodMagic.java +++ b/src/main/java/WayofTime/bloodmagic/api/DamageSourceBloodMagic.java @@ -6,10 +6,8 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; -public class DamageSourceBloodMagic extends DamageSource -{ - public DamageSourceBloodMagic() - { +public class DamageSourceBloodMagic extends DamageSource { + public DamageSourceBloodMagic() { super("bloodMagic"); setDamageBypassesArmor(); @@ -17,8 +15,7 @@ public class DamageSourceBloodMagic extends DamageSource } @Override - public ITextComponent getDeathMessage(EntityLivingBase livingBase) - { + public ITextComponent getDeathMessage(EntityLivingBase livingBase) { return new TextComponentString(TextHelper.localizeEffect("chat.bloodmagic.damageSource", livingBase.getName())); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/ItemStackWrapper.java b/src/main/java/WayofTime/bloodmagic/api/ItemStackWrapper.java index fc1258d3..d0949cbe 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ItemStackWrapper.java +++ b/src/main/java/WayofTime/bloodmagic/api/ItemStackWrapper.java @@ -9,8 +9,7 @@ import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; -public class ItemStackWrapper -{ +public class ItemStackWrapper { public final Item item; public final int stackSize; public final int meta; @@ -22,88 +21,49 @@ public class ItemStackWrapper this.meta = meta; } - public ItemStackWrapper(Item item, int stackSize) - { + public ItemStackWrapper(Item item, int stackSize) { this(item, stackSize, 0); } - public ItemStackWrapper(Item item) - { + public ItemStackWrapper(Item item) { this(item, 1, 0); } - public ItemStackWrapper(Block block, int stackSize, int meta) - { + public ItemStackWrapper(Block block, int stackSize, int meta) { this(Item.getItemFromBlock(block), stackSize, meta); } - public ItemStackWrapper(Block block, int stackSize) - { + public ItemStackWrapper(Block block, int stackSize) { this(block, stackSize, 0); } - public ItemStackWrapper(Block block) - { + public ItemStackWrapper(Block block) { this(block, 1, 0); } - public ItemStackWrapper(BlockStack blockStack) - { + public ItemStackWrapper(BlockStack blockStack) { this(blockStack.getBlock(), 1, blockStack.getMeta()); } - @Nullable - public static ItemStackWrapper getHolder(ItemStack stack) - { - if (stack.isEmpty()) - return null; - - ItemStackWrapper wrapper = new ItemStackWrapper(stack.getItem(), stack.getCount(), stack.getItemDamage()); - wrapper.setNbtTag(stack.getTagCompound()); - return wrapper; - } - - public ItemStack toStack() - { + public ItemStack toStack() { return new ItemStack(item, stackSize, meta); } - public String getDisplayName() - { + public String getDisplayName() { return toStack().getDisplayName(); } @Override - public String toString() - { + public String toString() { return stackSize + "x" + item.getUnlocalizedName() + "@" + this.meta; } - public ItemStack toStack(int count) - { + public ItemStack toStack(int count) { ItemStack result = new ItemStack(item, count, meta); result.setTagCompound(nbtTag); return result; } - public static List toWrapperList(List itemStackList) - { - List wrapperList = new ArrayList(); - for (ItemStack stack : itemStackList) - wrapperList.add(ItemStackWrapper.getHolder(stack)); - - return wrapperList; - } - - public static List toStackList(List wrapperList) - { - List stackList = new ArrayList(); - for (ItemStackWrapper wrapper : wrapperList) - stackList.add(wrapper.toStack()); - - return stackList; - } - public Item getItem() { return item; } @@ -123,4 +83,30 @@ public class ItemStackWrapper public void setNbtTag(NBTTagCompound nbtTag) { this.nbtTag = nbtTag; } + + @Nullable + public static ItemStackWrapper getHolder(ItemStack stack) { + if (stack.isEmpty()) + return null; + + ItemStackWrapper wrapper = new ItemStackWrapper(stack.getItem(), stack.getCount(), stack.getItemDamage()); + wrapper.setNbtTag(stack.getTagCompound()); + return wrapper; + } + + public static List toWrapperList(List itemStackList) { + List wrapperList = new ArrayList(); + for (ItemStack stack : itemStackList) + wrapperList.add(ItemStackWrapper.getHolder(stack)); + + return wrapperList; + } + + public static List toStackList(List wrapperList) { + List stackList = new ArrayList(); + for (ItemStackWrapper wrapper : wrapperList) + stackList.add(wrapper.toStack()); + + return stackList; + } } diff --git a/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffect.java b/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffect.java index 37946018..7455ca08 100644 --- a/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffect.java +++ b/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffect.java @@ -1,15 +1,14 @@ package WayofTime.bloodmagic.api.alchemyCrafting; +import WayofTime.bloodmagic.api.iface.IAlchemyArray; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.iface.IAlchemyArray; -public abstract class AlchemyArrayEffect -{ +public abstract class AlchemyArrayEffect { public final String key; public AlchemyArrayEffect(String key) { @@ -24,8 +23,7 @@ public abstract class AlchemyArrayEffect public abstract AlchemyArrayEffect getNewCopy(); - public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) - { + public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) { } diff --git a/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffectCrafting.java b/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffectCrafting.java index a3a17109..a15da577 100644 --- a/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffectCrafting.java +++ b/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffectCrafting.java @@ -6,39 +6,32 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; -public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect -{ +public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect { public final ItemStack outputStack; public int tickLimit; - public AlchemyArrayEffectCrafting(ItemStack outputStack) - { + public AlchemyArrayEffectCrafting(ItemStack outputStack) { this(outputStack, 200); } - public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit) - { + public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit) { this(outputStack.toString() + tickLimit, outputStack, tickLimit); } - public AlchemyArrayEffectCrafting(String key, ItemStack outputStack, int tickLimit) - { + public AlchemyArrayEffectCrafting(String key, ItemStack outputStack, int tickLimit) { super(key); this.outputStack = outputStack; this.tickLimit = tickLimit; } @Override - public boolean update(TileEntity tile, int ticksActive) - { + public boolean update(TileEntity tile, int ticksActive) { // TODO: Add recipe rechecking to verify nothing screwy is going on. - if (tile.getWorld().isRemote) - { + if (tile.getWorld().isRemote) { return false; } - if (ticksActive >= tickLimit) - { + if (ticksActive >= tickLimit) { BlockPos pos = tile.getPos(); ItemStack output = outputStack.copy(); @@ -54,20 +47,17 @@ public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { } @Override - public AlchemyArrayEffect getNewCopy() - { + public AlchemyArrayEffect getNewCopy() { return new AlchemyArrayEffectCrafting(key, outputStack, tickLimit); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyCircleRenderer.java b/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyCircleRenderer.java index 37dd53d0..f6276316 100644 --- a/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyCircleRenderer.java +++ b/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyCircleRenderer.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.api.alchemyCrafting; +import WayofTime.bloodmagic.tile.TileAlchemyArray; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; @@ -8,73 +9,57 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; -import WayofTime.bloodmagic.tile.TileAlchemyArray; -public class AlchemyCircleRenderer -{ - public float offsetFromFace = -0.9f; +public class AlchemyCircleRenderer { public final ResourceLocation arrayResource; + public float offsetFromFace = -0.9f; - public AlchemyCircleRenderer() - { + public AlchemyCircleRenderer() { this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png")); } - public AlchemyCircleRenderer(ResourceLocation arrayResource) - { + public AlchemyCircleRenderer(ResourceLocation arrayResource) { this.arrayResource = arrayResource; } - public float getRotation(float craftTime) - { + public float getRotation(float craftTime) { float offset = 2; - if (craftTime >= offset) - { + if (craftTime >= offset) { float modifier = (float) Math.pow(craftTime - offset, 1.5); return modifier * 1f; } return 0; } - public float getSecondaryRotation(float craftTime) - { + public float getSecondaryRotation(float craftTime) { float offset = 50; - if (craftTime >= offset) - { + if (craftTime >= offset) { float modifier = (float) Math.pow(craftTime - offset, 1.7); return modifier * 0.5f; } return 0; } - public float getSizeModifier(float craftTime) - { - if (craftTime >= 150 && craftTime <= 250) - { + public float getSizeModifier(float craftTime) { + if (craftTime >= 150 && craftTime <= 250) { return (200 - craftTime) / 50f; } return 1.0f; } - public float getVerticalOffset(float craftTime) - { - if (craftTime >= 5) - { - if (craftTime <= 40) - { + public float getVerticalOffset(float craftTime) { + if (craftTime >= 5) { + if (craftTime <= 40) { return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3)); - } else - { + } else { return -0.4f; } } return 0; } - public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) - { - if (!(tile instanceof TileAlchemyArray)) - { + public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) { + if (!(tile instanceof TileAlchemyArray)) { return; } @@ -106,30 +91,29 @@ public class AlchemyCircleRenderer GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace); - switch (sideHit) - { - case DOWN: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(-90.0f, 1, 0, 0); - break; - case EAST: - GlStateManager.rotate(-90.0f, 0, 1, 0); - GlStateManager.translate(0, 0, -1); - break; - case NORTH: - break; - case SOUTH: - GlStateManager.rotate(180.0f, 0, 1, 0); - GlStateManager.translate(-1, 0, -1); - break; - case UP: - GlStateManager.translate(0, 1, 0); - GlStateManager.rotate(90.0f, 1, 0, 0); - break; - case WEST: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(90.0f, 0, 1, 0); - break; + switch (sideHit) { + case DOWN: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(-90.0f, 1, 0, 0); + break; + case EAST: + GlStateManager.rotate(-90.0f, 0, 1, 0); + GlStateManager.translate(0, 0, -1); + break; + case NORTH: + break; + case SOUTH: + GlStateManager.rotate(180.0f, 0, 1, 0); + GlStateManager.translate(-1, 0, -1); + break; + case UP: + GlStateManager.translate(0, 1, 0); + GlStateManager.rotate(90.0f, 1, 0, 0); + break; + case WEST: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(90.0f, 0, 1, 0); + break; } GlStateManager.pushMatrix(); diff --git a/src/main/java/WayofTime/bloodmagic/api/altar/AltarComponent.java b/src/main/java/WayofTime/bloodmagic/api/altar/AltarComponent.java index 1ff69871..470097e1 100644 --- a/src/main/java/WayofTime/bloodmagic/api/altar/AltarComponent.java +++ b/src/main/java/WayofTime/bloodmagic/api/altar/AltarComponent.java @@ -5,8 +5,7 @@ import net.minecraft.util.math.BlockPos; /** * Used for building the altar structure. */ -public class AltarComponent -{ +public class AltarComponent { private BlockPos offset; private boolean upgradeSlot; @@ -14,14 +13,11 @@ public class AltarComponent /** * Sets a component location for the altar. - * - * @param offset - * - Where the block should be in relation to the Altar - * @param component - * - The type of Component the location should contain + * + * @param offset - Where the block should be in relation to the Altar + * @param component - The type of Component the location should contain */ - public AltarComponent(BlockPos offset, EnumAltarComponent component) - { + public AltarComponent(BlockPos offset, EnumAltarComponent component) { this.offset = offset; this.component = component; } @@ -29,22 +25,19 @@ public class AltarComponent /** * Use for setting a location at which there must be a block, but the type * of block does not matter. - * - * @param offset - * - Where the block should be in relation to the Altar + * + * @param offset - Where the block should be in relation to the Altar */ - public AltarComponent(BlockPos offset) - { + public AltarComponent(BlockPos offset) { this(offset, EnumAltarComponent.NOTAIR); } /** * Sets the location to an upgrade slot. - * + * * @return the current instance for further use. */ - public AltarComponent setUpgradeSlot() - { + public AltarComponent setUpgradeSlot() { this.upgradeSlot = true; return this; } diff --git a/src/main/java/WayofTime/bloodmagic/api/altar/AltarUpgrade.java b/src/main/java/WayofTime/bloodmagic/api/altar/AltarUpgrade.java index d8b73f87..c18801eb 100644 --- a/src/main/java/WayofTime/bloodmagic/api/altar/AltarUpgrade.java +++ b/src/main/java/WayofTime/bloodmagic/api/altar/AltarUpgrade.java @@ -1,7 +1,6 @@ package WayofTime.bloodmagic.api.altar; -public class AltarUpgrade -{ +public class AltarUpgrade { private int speedCount; private int efficiencyCount; private int sacrificeCount; @@ -31,62 +30,52 @@ public class AltarUpgrade // Adders - public AltarUpgrade addSpeed() - { + public AltarUpgrade addSpeed() { speedCount++; return this; } - public AltarUpgrade addEfficiency() - { + public AltarUpgrade addEfficiency() { efficiencyCount++; return this; } - public AltarUpgrade addSacrifice() - { + public AltarUpgrade addSacrifice() { sacrificeCount++; return this; } - public AltarUpgrade addSelfSacrifice() - { + public AltarUpgrade addSelfSacrifice() { selfSacrificeCount++; return this; } - public AltarUpgrade addDisplacement() - { + public AltarUpgrade addDisplacement() { displacementCount++; return this; } - public AltarUpgrade addCapacity() - { + public AltarUpgrade addCapacity() { capacityCount++; return this; } - public AltarUpgrade addOrbCapacity() - { + public AltarUpgrade addOrbCapacity() { orbCapacityCount++; return this; } - public AltarUpgrade addBetterCapacity() - { + public AltarUpgrade addBetterCapacity() { betterCapacityCount++; return this; } - public AltarUpgrade addAcceleration() - { + public AltarUpgrade addAcceleration() { accelerationCount++; return this; } - public AltarUpgrade addCharging() - { + public AltarUpgrade addCharging() { chargingCount++; return this; } diff --git a/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarComponent.java b/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarComponent.java index 2afd90e8..8443bc1a 100644 --- a/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarComponent.java +++ b/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarComponent.java @@ -5,8 +5,7 @@ import java.util.Locale; /** * List of different components used to construct different tiers of altars. */ -public enum EnumAltarComponent -{ +public enum EnumAltarComponent { GLOWSTONE, BLOODSTONE, BEACON, @@ -18,8 +17,7 @@ public enum EnumAltarComponent private static final String BASE = "chat.bloodmagic.altar.comp."; private String key; - EnumAltarComponent() - { + EnumAltarComponent() { this.key = BASE + name().toLowerCase(Locale.ENGLISH); } diff --git a/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarTier.java b/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarTier.java index ba1ec6ac..16a4e7e1 100644 --- a/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarTier.java +++ b/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarTier.java @@ -5,13 +5,10 @@ import net.minecraft.util.math.BlockPos; import java.util.ArrayList; //@formatter:off -public enum EnumAltarTier -{ - ONE(), TWO() - { +public enum EnumAltarTier { + ONE(), TWO() { @Override - public void buildComponents() - { + public void buildComponents() { altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), EnumAltarComponent.BLOODRUNE)); altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(1, -1, -1), EnumAltarComponent.BLOODRUNE)); @@ -22,11 +19,9 @@ public enum EnumAltarTier altarComponents.add(new AltarComponent(new BlockPos(1, -1, 1), EnumAltarComponent.BLOODRUNE)); } }, - THREE() - { + THREE() { @Override - public void buildComponents() - { + public void buildComponents() { altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(1, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); @@ -48,8 +43,7 @@ public enum EnumAltarTier altarComponents.add(new AltarComponent(new BlockPos(-3, 1, 3), EnumAltarComponent.GLOWSTONE)); altarComponents.add(new AltarComponent(new BlockPos(3, 1, 3), EnumAltarComponent.GLOWSTONE)); - for (int i = -2; i <= 2; i++) - { + for (int i = -2; i <= 2; i++) { altarComponents.add(new AltarComponent(new BlockPos(3, -2, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(-3, -2, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(i, -2, 3), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); @@ -57,23 +51,19 @@ public enum EnumAltarTier } } }, - FOUR() - { + FOUR() { @Override - public void buildComponents() - { + public void buildComponents() { altarComponents.addAll(THREE.getAltarComponents()); - for (int i = -3; i <= 3; i++) - { + for (int i = -3; i <= 3; i++) { altarComponents.add(new AltarComponent(new BlockPos(5, -3, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(-5, -3, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(i, -3, 5), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(i, -3, -5), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); } - for (int i = -2; i <= 1; i++) - { + for (int i = -2; i <= 1; i++) { altarComponents.add(new AltarComponent(new BlockPos(5, i, 5))); altarComponents.add(new AltarComponent(new BlockPos(5, i, -5))); altarComponents.add(new AltarComponent(new BlockPos(-5, i, -5))); @@ -86,19 +76,16 @@ public enum EnumAltarTier altarComponents.add(new AltarComponent(new BlockPos(-5, 2, 5), EnumAltarComponent.BLOODSTONE)); } }, - FIVE() - { + FIVE() { @Override - public void buildComponents() - { + public void buildComponents() { altarComponents.addAll(FOUR.getAltarComponents()); altarComponents.add(new AltarComponent(new BlockPos(-8, -3, 8), EnumAltarComponent.BEACON)); altarComponents.add(new AltarComponent(new BlockPos(-8, -3, -8), EnumAltarComponent.BEACON)); altarComponents.add(new AltarComponent(new BlockPos(8, -3, -8), EnumAltarComponent.BEACON)); altarComponents.add(new AltarComponent(new BlockPos(8, -3, 8), EnumAltarComponent.BEACON)); - for (int i = -6; i <= 6; i++) - { + for (int i = -6; i <= 6; i++) { altarComponents.add(new AltarComponent(new BlockPos(8, -4, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(-8, -4, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(i, -4, 8), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); @@ -106,15 +93,12 @@ public enum EnumAltarTier } } }, - SIX() - { + SIX() { @Override - public void buildComponents() - { + public void buildComponents() { altarComponents.addAll(FIVE.getAltarComponents()); - for (int i = -4; i <= 2; i++) - { + for (int i = -4; i <= 2; i++) { altarComponents.add(new AltarComponent(new BlockPos(11, i, 11))); altarComponents.add(new AltarComponent(new BlockPos(-11, i, -11))); altarComponents.add(new AltarComponent(new BlockPos(11, i, -11))); @@ -126,8 +110,7 @@ public enum EnumAltarTier altarComponents.add(new AltarComponent(new BlockPos(11, 3, -11), EnumAltarComponent.CRYSTAL)); altarComponents.add(new AltarComponent(new BlockPos(-11, 3, 11), EnumAltarComponent.CRYSTAL)); - for (int i = -9; i <= 9; i++) - { + for (int i = -9; i <= 9; i++) { altarComponents.add(new AltarComponent(new BlockPos(11, -5, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(-11, -5, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(i, -5, 11), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); @@ -141,13 +124,11 @@ public enum EnumAltarTier ArrayList altarComponents = new ArrayList(); - public void buildComponents() - { + public void buildComponents() { } - public int toInt() - { + public int toInt() { return ordinal() + 1; } diff --git a/src/main/java/WayofTime/bloodmagic/api/altar/IAltarComponent.java b/src/main/java/WayofTime/bloodmagic/api/altar/IAltarComponent.java index 9e711b00..52d1d763 100644 --- a/src/main/java/WayofTime/bloodmagic/api/altar/IAltarComponent.java +++ b/src/main/java/WayofTime/bloodmagic/api/altar/IAltarComponent.java @@ -6,8 +6,7 @@ import net.minecraft.world.World; import javax.annotation.Nullable; -public interface IAltarComponent -{ +public interface IAltarComponent { @Nullable EnumAltarComponent getType(World world, IBlockState state, BlockPos pos); } diff --git a/src/main/java/WayofTime/bloodmagic/api/altar/IAltarManipulator.java b/src/main/java/WayofTime/bloodmagic/api/altar/IAltarManipulator.java index 1c846da3..57509bc0 100644 --- a/src/main/java/WayofTime/bloodmagic/api/altar/IAltarManipulator.java +++ b/src/main/java/WayofTime/bloodmagic/api/altar/IAltarManipulator.java @@ -4,6 +4,5 @@ package WayofTime.bloodmagic.api.altar; * Any item that implements this interface will not be pulled into the Altar on * right click. */ -public interface IAltarManipulator -{ +public interface IAltarManipulator { } diff --git a/src/main/java/WayofTime/bloodmagic/api/altar/IBloodAltar.java b/src/main/java/WayofTime/bloodmagic/api/altar/IBloodAltar.java index 49749d85..843d2a0e 100644 --- a/src/main/java/WayofTime/bloodmagic/api/altar/IBloodAltar.java +++ b/src/main/java/WayofTime/bloodmagic/api/altar/IBloodAltar.java @@ -1,7 +1,6 @@ package WayofTime.bloodmagic.api.altar; -public interface IBloodAltar -{ +public interface IBloodAltar { int getCapacity(); int getCurrentBlood(); @@ -48,9 +47,8 @@ public interface IBloodAltar * Will set the altar to initiate a cooldown cycle after it crafts before * starting to craft again, giving the user time to interact with the altar. * This can only be set while the altar is not active. - * - * @param cooldown - * - How long the cooldown should last + * + * @param cooldown - How long the cooldown should last */ void requestPauseAfterCrafting(int cooldown); } diff --git a/src/main/java/WayofTime/bloodmagic/api/compress/CompressionHandler.java b/src/main/java/WayofTime/bloodmagic/api/compress/CompressionHandler.java index 2e54883d..22a8fe9e 100644 --- a/src/main/java/WayofTime/bloodmagic/api/compress/CompressionHandler.java +++ b/src/main/java/WayofTime/bloodmagic/api/compress/CompressionHandler.java @@ -3,14 +3,12 @@ package WayofTime.bloodmagic.api.compress; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public abstract class CompressionHandler -{ +public abstract class CompressionHandler { /** * Called to look at the inventory and syphons the required stack. Returns * resultant stack if successful, and null if not. - * - * @param inv - * The inventory iterated through + * + * @param inv The inventory iterated through * @return The result of the compression */ public abstract ItemStack compressInventory(ItemStack[] inv, World world); diff --git a/src/main/java/WayofTime/bloodmagic/api/compress/CompressionRegistry.java b/src/main/java/WayofTime/bloodmagic/api/compress/CompressionRegistry.java index c7c708fb..7fc1bbae 100644 --- a/src/main/java/WayofTime/bloodmagic/api/compress/CompressionRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/compress/CompressionRegistry.java @@ -1,54 +1,44 @@ package WayofTime.bloodmagic.api.compress; +import WayofTime.bloodmagic.util.Utils; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.IItemHandler; +import org.apache.commons.lang3.tuple.Pair; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.items.CapabilityItemHandler; -import net.minecraftforge.items.IItemHandler; - -import org.apache.commons.lang3.tuple.Pair; - -import WayofTime.bloodmagic.util.Utils; - /** * A registry aimed to help compress items in an inventory into its compressible * form. */ -public class CompressionRegistry -{ +public class CompressionRegistry { public static List compressionRegistry = new ArrayList(); public static Map thresholdMap = new HashMap(); - public static void registerHandler(CompressionHandler handler) - { + public static void registerHandler(CompressionHandler handler) { compressionRegistry.add(handler); } /** * Registers an item so that it only compresses while above this threshold - * - * @param stack - * item/block to be compressed - * @param threshold - * amount that is to be compressed + * + * @param stack item/block to be compressed + * @param threshold amount that is to be compressed */ - public static void registerItemThreshold(ItemStack stack, int threshold) - { + public static void registerItemThreshold(ItemStack stack, int threshold) { thresholdMap.put(stack, threshold); } - public static ItemStack compressInventory(ItemStack[] inv, World world) - { - for (CompressionHandler handler : compressionRegistry) - { + public static ItemStack compressInventory(ItemStack[] inv, World world) { + for (CompressionHandler handler : compressionRegistry) { ItemStack stack = handler.compressInventory(inv, world); - if (stack != null) - { + if (stack != null) { return stack; } } @@ -56,32 +46,24 @@ public class CompressionRegistry return null; } - public static Pair compressInventory(TileEntity tile, World world) - { - if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) - { + public static Pair compressInventory(TileEntity tile, World world) { + if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) { IItemHandler itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); ItemStack[] inventory = new ItemStack[itemHandler.getSlots()]; //THIS MUST NOT BE EDITED! ItemStack[] copyInventory = new ItemStack[itemHandler.getSlots()]; - for (int slot = 0; slot < itemHandler.getSlots(); slot++) - { + for (int slot = 0; slot < itemHandler.getSlots(); slot++) { inventory[slot] = itemHandler.extractItem(slot, 64, true); copyInventory[slot] = inventory[slot].copy(); } - for (CompressionHandler handler : compressionRegistry) - { + for (CompressionHandler handler : compressionRegistry) { ItemStack stack = handler.compressInventory(copyInventory, world); - if (!stack.isEmpty()) - { - for (int slot = 0; slot < itemHandler.getSlots(); slot++) - { - if (inventory[slot] != null && !ItemStack.areItemStacksEqual(inventory[slot], copyInventory[slot])) - { + if (!stack.isEmpty()) { + for (int slot = 0; slot < itemHandler.getSlots(); slot++) { + if (inventory[slot] != null && !ItemStack.areItemStacksEqual(inventory[slot], copyInventory[slot])) { itemHandler.extractItem(slot, inventory[slot].getCount(), false); - if (copyInventory[slot] != null) - { + if (copyInventory[slot] != null) { itemHandler.insertItem(slot, copyInventory[slot], false); } } @@ -95,12 +77,9 @@ public class CompressionRegistry return Pair.of(ItemStack.EMPTY, false); } - public static int getItemThreshold(ItemStack stack) - { - for (Map.Entry entry : thresholdMap.entrySet()) - { - if (areItemStacksEqual(entry.getKey(), stack)) - { + public static int getItemThreshold(ItemStack stack) { + for (Map.Entry entry : thresholdMap.entrySet()) { + if (areItemStacksEqual(entry.getKey(), stack)) { return entry.getValue(); } } @@ -108,8 +87,7 @@ public class CompressionRegistry return 0; } - public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack) - { + public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack) { return stack.isItemEqual(compressedStack) && (stack.getTagCompound() == null ? !compressedStack.hasTagCompound() : stack.getTagCompound().equals(compressedStack.getTagCompound())); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/event/AddToNetworkEvent.java b/src/main/java/WayofTime/bloodmagic/api/event/AddToNetworkEvent.java index cc47880d..ddd5c637 100644 --- a/src/main/java/WayofTime/bloodmagic/api/event/AddToNetworkEvent.java +++ b/src/main/java/WayofTime/bloodmagic/api/event/AddToNetworkEvent.java @@ -4,8 +4,7 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; @Cancelable -public class AddToNetworkEvent extends Event -{ +public class AddToNetworkEvent extends Event { public final String ownerNetwork; public int addedAmount; public int maximum; @@ -14,16 +13,12 @@ public class AddToNetworkEvent extends Event * This event is called whenever the network is added to. If cancelled, no * LP will be drained from the source. If result is set to Result.DENY, the * LP will still be drained but the soul network will not be added to. - * - * @param ownerNetwork - * Key used for the soul network - * @param addedAmount - * Amount added - * @param maximum - * Ceiling that the network can add to + * + * @param ownerNetwork Key used for the soul network + * @param addedAmount Amount added + * @param maximum Ceiling that the network can add to */ - public AddToNetworkEvent(String ownerNetwork, int addedAmount, int maximum) - { + public AddToNetworkEvent(String ownerNetwork, int addedAmount, int maximum) { this.ownerNetwork = ownerNetwork; this.addedAmount = addedAmount; this.maximum = maximum; diff --git a/src/main/java/WayofTime/bloodmagic/api/event/AltarCraftedEvent.java b/src/main/java/WayofTime/bloodmagic/api/event/AltarCraftedEvent.java index 11891289..f20d0ec7 100644 --- a/src/main/java/WayofTime/bloodmagic/api/event/AltarCraftedEvent.java +++ b/src/main/java/WayofTime/bloodmagic/api/event/AltarCraftedEvent.java @@ -6,23 +6,19 @@ import net.minecraftforge.fml.common.eventhandler.Event; /** * Fired whenever a craft is completed in a BloodAltar. - * + *

* It is not cancelable, however you can modify the output stack. */ -public class AltarCraftedEvent extends Event -{ +public class AltarCraftedEvent extends Event { private final AltarRecipeRegistry.AltarRecipe altarRecipe; private final ItemStack output; /** - * @param altarRecipe - * - The recipe that was crafted. - * @param output - * - The item obtained from the recipe + * @param altarRecipe - The recipe that was crafted. + * @param output - The item obtained from the recipe */ - public AltarCraftedEvent(AltarRecipeRegistry.AltarRecipe altarRecipe, ItemStack output) - { + public AltarCraftedEvent(AltarRecipeRegistry.AltarRecipe altarRecipe, ItemStack output) { this.altarRecipe = altarRecipe; this.output = output; } diff --git a/src/main/java/WayofTime/bloodmagic/api/event/BoundToolEvent.java b/src/main/java/WayofTime/bloodmagic/api/event/BoundToolEvent.java index deecdc44..ab2de72a 100644 --- a/src/main/java/WayofTime/bloodmagic/api/event/BoundToolEvent.java +++ b/src/main/java/WayofTime/bloodmagic/api/event/BoundToolEvent.java @@ -5,29 +5,25 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; -public class BoundToolEvent extends Event -{ +public class BoundToolEvent extends Event { public EntityPlayer player; - public BoundToolEvent(EntityPlayer player) - { + public BoundToolEvent(EntityPlayer player) { this.player = player; } /** * This event is called when a * {@link WayofTime.bloodmagic.item.ItemBoundTool} is being charged. - * + *

* If canceled, will result in the charging being canceled. */ @Cancelable - public static class Charge extends BoundToolEvent - { + public static class Charge extends BoundToolEvent { public ItemStack result; - public Charge(EntityPlayer player, ItemStack result) - { + public Charge(EntityPlayer player, ItemStack result) { super(player); this.result = result; } @@ -36,18 +32,16 @@ public class BoundToolEvent extends Event /** * This event is called when a * {@link WayofTime.bloodmagic.item.ItemBoundTool}'s charge is released. - * + *

* If canceled, will result in the charge not being released. */ @Cancelable - public static class Release extends BoundToolEvent - { + public static class Release extends BoundToolEvent { public final ItemStack boundTool; public int charge; - public Release(EntityPlayer player, ItemStack boundTool, int charge) - { + public Release(EntityPlayer player, ItemStack boundTool, int charge) { super(player); this.boundTool = boundTool; this.charge = charge; diff --git a/src/main/java/WayofTime/bloodmagic/api/event/ItemBindEvent.java b/src/main/java/WayofTime/bloodmagic/api/event/ItemBindEvent.java index 10b657ba..03348e02 100644 --- a/src/main/java/WayofTime/bloodmagic/api/event/ItemBindEvent.java +++ b/src/main/java/WayofTime/bloodmagic/api/event/ItemBindEvent.java @@ -6,8 +6,7 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; @Cancelable -public class ItemBindEvent extends Event -{ +public class ItemBindEvent extends Event { public final EntityPlayer player; public String key; public ItemStack itemStack; @@ -15,18 +14,14 @@ public class ItemBindEvent extends Event /** * This event is called whenever a player attempts to bind a * {@link WayofTime.bloodmagic.api.iface.IBindable} item. - * - * @param player - * The player doing the binding - * @param key - * The UUID of the player doing the binding - * @param itemStack - * The {@link ItemStack} that the player is binding - * - * This event is {@link Cancelable}.
+ * + * @param player The player doing the binding + * @param key The UUID of the player doing the binding + * @param itemStack The {@link ItemStack} that the player is binding + *

+ * This event is {@link Cancelable}.
*/ - public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack) - { + public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack) { super(); this.player = player; this.key = key; diff --git a/src/main/java/WayofTime/bloodmagic/api/event/RitualEvent.java b/src/main/java/WayofTime/bloodmagic/api/event/RitualEvent.java index 45813ab6..9036f4cb 100644 --- a/src/main/java/WayofTime/bloodmagic/api/event/RitualEvent.java +++ b/src/main/java/WayofTime/bloodmagic/api/event/RitualEvent.java @@ -10,14 +10,12 @@ import net.minecraft.world.World; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; -public class RitualEvent extends Event -{ +public class RitualEvent extends Event { public final IMasterRitualStone mrs; public final String ownerName; public final Ritual ritual; - private RitualEvent(IMasterRitualStone mrs, String ownerName, Ritual ritual) - { + private RitualEvent(IMasterRitualStone mrs, String ownerName, Ritual ritual) { this.mrs = mrs; this.ownerName = ownerName; this.ritual = ritual; @@ -26,18 +24,16 @@ public class RitualEvent extends Event /** * This event is called when a ritual is activated. If cancelled, it will * not activate. - * + *

* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)} */ @Cancelable - public static class RitualActivatedEvent extends RitualEvent - { + public static class RitualActivatedEvent extends RitualEvent { public final EntityPlayer player; public final ItemStack crystalStack; public int crystalTier; - public RitualActivatedEvent(IMasterRitualStone mrs, String owner, Ritual ritual, EntityPlayer player, ItemStack activationCrystal, int crystalTier) - { + public RitualActivatedEvent(IMasterRitualStone mrs, String owner, Ritual ritual, EntityPlayer player, ItemStack activationCrystal, int crystalTier) { super(mrs, owner, ritual); this.player = player; @@ -49,14 +45,12 @@ public class RitualEvent extends Event /** * This event is called when a Ritual effect is performed. If cancelled, the * effect will not happen. - * + *

* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, net.minecraft.util.math.BlockPos)} */ @Cancelable - public static class RitualRunEvent extends RitualEvent - { - public RitualRunEvent(IMasterRitualStone mrs, String owner, Ritual ritual) - { + public static class RitualRunEvent extends RitualEvent { + public RitualRunEvent(IMasterRitualStone mrs, String owner, Ritual ritual) { super(mrs, owner, ritual); } } @@ -64,16 +58,14 @@ public class RitualEvent extends Event /** * This event is called when a Ritual is stopped by a * {@link Ritual.BreakType}. - * + *

* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(Ritual.BreakType)} - * */ - public static class RitualStopEvent extends RitualEvent - { + */ + public static class RitualStopEvent extends RitualEvent { public final Ritual.BreakType method; - public RitualStopEvent(IMasterRitualStone mrs, String owner, Ritual ritual, Ritual.BreakType method) - { + public RitualStopEvent(IMasterRitualStone mrs, String owner, Ritual ritual, Ritual.BreakType method) { super(mrs, owner, ritual); this.method = method; @@ -81,15 +73,13 @@ public class RitualEvent extends Event } @Cancelable - public static class ImperfectRitualActivatedEvent extends Event - { + public static class ImperfectRitualActivatedEvent extends Event { public final IImperfectRitualStone ims; public final String ownerName; public final ImperfectRitual imperfectRitual; - public ImperfectRitualActivatedEvent(IImperfectRitualStone ims, String ownerName, ImperfectRitual imperfectRitual) - { + public ImperfectRitualActivatedEvent(IImperfectRitualStone ims, String ownerName, ImperfectRitual imperfectRitual) { this.ims = ims; this.ownerName = ownerName; this.imperfectRitual = imperfectRitual; diff --git a/src/main/java/WayofTime/bloodmagic/api/event/SacrificeKnifeUsedEvent.java b/src/main/java/WayofTime/bloodmagic/api/event/SacrificeKnifeUsedEvent.java index f3bccfe8..93f72b23 100644 --- a/src/main/java/WayofTime/bloodmagic/api/event/SacrificeKnifeUsedEvent.java +++ b/src/main/java/WayofTime/bloodmagic/api/event/SacrificeKnifeUsedEvent.java @@ -1,13 +1,11 @@ package WayofTime.bloodmagic.api.event; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; @Cancelable -public class SacrificeKnifeUsedEvent extends Event -{ +public class SacrificeKnifeUsedEvent extends Event { public final EntityPlayer player; public final int healthDrained; public int lpAdded; @@ -18,22 +16,16 @@ public class SacrificeKnifeUsedEvent extends Event * This event is called whenever a player attempts to use a * {@link WayofTime.bloodmagic.item.ItemSacrificialDagger} to self-sacrifice * near an altar. - * - * @param player - * The player doing the sacrificing - * @param shouldDrainHealth - * Determines whether or not health is lost - * @param shouldFillAltar - * Determines whether or not an altar should be filled - * @param hp - * Amount of health lost - * @param lpAdded - * Amount of LP added to the altar - * - * This event is {@link Cancelable}.
+ * + * @param player The player doing the sacrificing + * @param shouldDrainHealth Determines whether or not health is lost + * @param shouldFillAltar Determines whether or not an altar should be filled + * @param hp Amount of health lost + * @param lpAdded Amount of LP added to the altar + *

+ * This event is {@link Cancelable}.
*/ - public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp, int lpAdded) - { + public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp, int lpAdded) { this.player = player; this.shouldDrainHealth = shouldDrainHealth; this.shouldFillAltar = shouldFillAltar; diff --git a/src/main/java/WayofTime/bloodmagic/api/event/SoulNetworkEvent.java b/src/main/java/WayofTime/bloodmagic/api/event/SoulNetworkEvent.java index 7b824964..06928b8a 100644 --- a/src/main/java/WayofTime/bloodmagic/api/event/SoulNetworkEvent.java +++ b/src/main/java/WayofTime/bloodmagic/api/event/SoulNetworkEvent.java @@ -9,17 +9,15 @@ import javax.annotation.Nullable; /** * Base event class for Soul Network related events. - * + *

* {@link #ownerUUID} contains the owner's UUID {@link #syphon} contains the * amount of LP to be drained */ -public class SoulNetworkEvent extends Event -{ +public class SoulNetworkEvent extends Event { public final String ownerUUID; public int syphon; - public SoulNetworkEvent(String ownerUUID, int syphon) - { + public SoulNetworkEvent(String ownerUUID, int syphon) { this.ownerUUID = ownerUUID; this.syphon = syphon; } @@ -28,16 +26,14 @@ public class SoulNetworkEvent extends Event * This event is called when an * {@link WayofTime.bloodmagic.api.impl.ItemBindable} is being drained * inside of a {@link net.minecraft.tileentity.TileEntity}. - * + *

* If canceled, the drain will not be executed. */ @Cancelable - public static class ItemDrainInContainerEvent extends SoulNetworkEvent - { + public static class ItemDrainInContainerEvent extends SoulNetworkEvent { public ItemStack stack; - public ItemDrainInContainerEvent(ItemStack stack, String ownerName, int syphon) - { + public ItemDrainInContainerEvent(ItemStack stack, String ownerName, int syphon) { super(ownerName, syphon); this.stack = stack; } @@ -45,18 +41,16 @@ public class SoulNetworkEvent extends Event /** * This event is called when a {@link EntityPlayer} drains the Soul Network - * + *

* If canceled, the drain will not be executed. */ @Cancelable - public static class PlayerDrainNetworkEvent extends SoulNetworkEvent - { + public static class PlayerDrainNetworkEvent extends SoulNetworkEvent { public final EntityPlayer player; // If true, will damage regardless of if the network had enough inside it public boolean shouldDamage; - public PlayerDrainNetworkEvent(EntityPlayer player, String ownerNetwork, int drainAmount) - { + public PlayerDrainNetworkEvent(EntityPlayer player, String ownerNetwork, int drainAmount) { super(ownerNetwork, drainAmount); this.shouldDamage = false; this.player = player; @@ -64,8 +58,7 @@ public class SoulNetworkEvent extends Event } @Cancelable - public static class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent - { + public static class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent { @Nullable public final ItemStack itemStack; /** @@ -77,18 +70,13 @@ public class SoulNetworkEvent extends Event /** * Set result to deny the action i.e. damage/drain anyways. Cancelling * event prevents action without penalties - * - * @param player - * Player using the item - * @param ownerNetwork - * Network that the item is tied to - * @param itemStack - * Item used - * @param drainAmount - * Original drain amount - change to alter cost + * + * @param player Player using the item + * @param ownerNetwork Network that the item is tied to + * @param itemStack Item used + * @param drainAmount Original drain amount - change to alter cost */ - public ItemDrainNetworkEvent(EntityPlayer player, String ownerNetwork, @Nullable ItemStack itemStack, int drainAmount) - { + public ItemDrainNetworkEvent(EntityPlayer player, String ownerNetwork, @Nullable ItemStack itemStack, int drainAmount) { super(player, ownerNetwork, drainAmount); this.itemStack = itemStack; this.damageAmount = (float) (drainAmount) / 100.0f; diff --git a/src/main/java/WayofTime/bloodmagic/api/event/TeleposeEvent.java b/src/main/java/WayofTime/bloodmagic/api/event/TeleposeEvent.java index 26ee25e2..d474e46b 100644 --- a/src/main/java/WayofTime/bloodmagic/api/event/TeleposeEvent.java +++ b/src/main/java/WayofTime/bloodmagic/api/event/TeleposeEvent.java @@ -14,8 +14,7 @@ import net.minecraftforge.fml.common.eventhandler.Event; * transposition. */ @Cancelable -public class TeleposeEvent extends Event -{ +public class TeleposeEvent extends Event { public final World initalWorld; public final BlockPos initialBlockPos; public final IBlockState initialState; @@ -24,8 +23,7 @@ public class TeleposeEvent extends Event public final BlockPos finalBlockPos; public final IBlockState finalState; - public TeleposeEvent(World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos) - { + public TeleposeEvent(World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos) { this.initalWorld = initialWorld; this.initialBlockPos = initialBlockPos; this.initialState = initialWorld.getBlockState(initialBlockPos); @@ -35,13 +33,11 @@ public class TeleposeEvent extends Event this.finalState = finalWorld.getBlockState(finalBlockPos); } - public TileEntity getInitialTile() - { + public TileEntity getInitialTile() { return initalWorld.getTileEntity(initialBlockPos); } - public TileEntity getFinalTile() - { + public TileEntity getFinalTile() { return finalWorld.getTileEntity(finalBlockPos); } @@ -50,37 +46,31 @@ public class TeleposeEvent extends Event * be cancelled to stop transposition. */ @Cancelable - public static class Ent extends TeleposeEvent - { + public static class Ent extends TeleposeEvent { public final Entity entity; - public Ent(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos) - { + public Ent(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos) { super(initialWorld, initialBlockPos, finalWorld, finalBlockPos); this.entity = entity; } @Override - public TileEntity getInitialTile() throws IllegalArgumentException - { + public TileEntity getInitialTile() throws IllegalArgumentException { throw new IllegalArgumentException("Attempted to get a TileEntity from an Entity Telepose Event."); } @Override - public TileEntity getFinalTile() throws IllegalArgumentException - { + public TileEntity getFinalTile() throws IllegalArgumentException { throw new IllegalArgumentException("Attempted to get a TileEntity from an Entity Telepose Event."); } /** * Called after the entity has been transposed. */ - public static class Post extends Ent - { + public static class Post extends Ent { - public Post(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos) - { + public Post(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos) { super(entity, initialWorld, initialBlockPos, finalWorld, finalBlockPos); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/IActivatable.java b/src/main/java/WayofTime/bloodmagic/api/iface/IActivatable.java index 47cd7e6e..c760dd5c 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/IActivatable.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/IActivatable.java @@ -2,8 +2,7 @@ package WayofTime.bloodmagic.api.iface; import net.minecraft.item.ItemStack; -public interface IActivatable -{ +public interface IActivatable { boolean getActivated(ItemStack stack); ItemStack setActivatedState(ItemStack stack, boolean activated); diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/IAlchemyArray.java b/src/main/java/WayofTime/bloodmagic/api/iface/IAlchemyArray.java index e06393b1..60d34f08 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/IAlchemyArray.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/IAlchemyArray.java @@ -2,7 +2,6 @@ package WayofTime.bloodmagic.api.iface; import net.minecraft.util.EnumFacing; -public interface IAlchemyArray -{ +public interface IAlchemyArray { EnumFacing getRotation(); } diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/IAltarReader.java b/src/main/java/WayofTime/bloodmagic/api/iface/IAltarReader.java index e17ae4e4..292e2e74 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/IAltarReader.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/IAltarReader.java @@ -4,7 +4,6 @@ package WayofTime.bloodmagic.api.iface; * Any item that implements this interface will not be pulled into the Altar on * right click. */ -public interface IAltarReader -{ +public interface IAltarReader { } diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/IBindable.java b/src/main/java/WayofTime/bloodmagic/api/iface/IBindable.java index b75f0530..5b515342 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/IBindable.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/IBindable.java @@ -6,41 +6,33 @@ import net.minecraft.item.ItemStack; /** * Implement this interface on any Item that can be bound to a player. */ -public interface IBindable -{ +public interface IBindable { /** * Gets the username of the Item's owner. Usually for display, such as in * the tooltip. - * + *

* If the item is not bound, this will be null. - * - * @param stack - * - The owned ItemStack - * + * + * @param stack - The owned ItemStack * @return - The username of the Item's owner */ String getOwnerName(ItemStack stack); /** * Gets the UUID of the Item's owner. - * + *

* If the item is not bound, this will be null. - * - * @param stack - * - The owned ItemStack - * + * + * @param stack - The owned ItemStack * @return - The UUID of the Item's owner */ String getOwnerUUID(ItemStack stack); /** * Called when the player attempts to bind the item. - * - * @param player - * - The Player attempting to bind the item - * @param stack - * - The ItemStack to attempt binding - * + * + * @param player - The Player attempting to bind the item + * @param stack - The ItemStack to attempt binding * @return If binding was successful. */ boolean onBind(EntityPlayer player, ItemStack stack); diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/ICustomAlchemyConsumable.java b/src/main/java/WayofTime/bloodmagic/api/iface/ICustomAlchemyConsumable.java index 06d2af92..b7d6f034 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/ICustomAlchemyConsumable.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/ICustomAlchemyConsumable.java @@ -6,7 +6,6 @@ import net.minecraft.item.ItemStack; * An interface for items that have custom drainage behaviour when used in * certain alchemy recipes. */ -public interface ICustomAlchemyConsumable -{ +public interface ICustomAlchemyConsumable { ItemStack drainUseOnAlchemyCraft(ItemStack stack); } diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/IDemonWillViewer.java b/src/main/java/WayofTime/bloodmagic/api/iface/IDemonWillViewer.java index 86b6d0a8..cfcbd3d9 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/IDemonWillViewer.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/IDemonWillViewer.java @@ -4,8 +4,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public interface IDemonWillViewer -{ +public interface IDemonWillViewer { boolean canSeeDemonWillAura(World world, ItemStack stack, EntityPlayer player); int getDemonWillAuraResolution(World world, ItemStack stack, EntityPlayer player); diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/IDocumentedBlock.java b/src/main/java/WayofTime/bloodmagic/api/iface/IDocumentedBlock.java index 4c8430fe..fca40184 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/IDocumentedBlock.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/IDocumentedBlock.java @@ -11,27 +11,21 @@ import java.util.List; /** * Marks blocks as one that is documented. - * + *

* This documentation can be read by an * {@link WayofTime.bloodmagic.item.ItemSanguineBook} (or child) */ -public interface IDocumentedBlock -{ +public interface IDocumentedBlock { /** * Provides the documentation to provide to the player. Usually a * short'n'sweet description about basic usage. - * - * @param player - * - The EntityPlayer attempting to view the Documentation. - * @param world - * - The World interaction is happening in. - * @param pos - * - The BlockPos being interacted at. - * @param state - * - The IBlockState of the interacted Block. - * + * + * @param player - The EntityPlayer attempting to view the Documentation. + * @param world - The World interaction is happening in. + * @param pos - The BlockPos being interacted at. + * @param state - The IBlockState of the interacted Block. * @return - A list of formatted ITextComponent to provide to the player. - * Provide an empty list if there is no available documentation. + * Provide an empty list if there is no available documentation. */ @Nonnull List getDocumentation(EntityPlayer player, World world, BlockPos pos, IBlockState state); diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/IHarvestHandler.java b/src/main/java/WayofTime/bloodmagic/api/iface/IHarvestHandler.java index 1ba46fd4..f25382f5 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/IHarvestHandler.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/IHarvestHandler.java @@ -7,23 +7,18 @@ import net.minecraft.world.World; /** * Used to define a HarvestHandler for the Harvest Ritual. */ -public interface IHarvestHandler -{ +public interface IHarvestHandler { /** * Called whenever the Harvest Ritual attempts to harvest a block.
* Use this to break the block, plant a new one, and drop the produced * items.
* Make sure to do checks so you are certain the blocks being handled are * the block types you want. - * - * @param world - * - The world the - * {@link WayofTime.bloodmagic.api.ritual.IMasterRitualStone} is in. - * @param pos - * - The position of the Block being checked - * @param blockStack - * - The Block being checked - * + * + * @param world - The world the + * {@link WayofTime.bloodmagic.api.ritual.IMasterRitualStone} is in. + * @param pos - The position of the Block being checked + * @param blockStack - The Block being checked * @return If the block was successfully harvested. */ boolean harvestAndPlant(World world, BlockPos pos, BlockStack blockStack); diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/IItemLPContainer.java b/src/main/java/WayofTime/bloodmagic/api/iface/IItemLPContainer.java index 0dedec7d..b909856d 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/IItemLPContainer.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/IItemLPContainer.java @@ -5,8 +5,7 @@ import net.minecraft.item.ItemStack; /** * Interface used for any item that can store LP in itself */ -public interface IItemLPContainer -{ +public interface IItemLPContainer { int getCapacity(); void setStoredLP(ItemStack stack, int lp); diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/IMultiWillTool.java b/src/main/java/WayofTime/bloodmagic/api/iface/IMultiWillTool.java index dfb2afa0..9ff0d689 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/IMultiWillTool.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/IMultiWillTool.java @@ -1,9 +1,8 @@ package WayofTime.bloodmagic.api.iface; -import net.minecraft.item.ItemStack; import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import net.minecraft.item.ItemStack; -public interface IMultiWillTool -{ +public interface IMultiWillTool { EnumDemonWillType getCurrentType(ItemStack stack); } diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/INodeRenderer.java b/src/main/java/WayofTime/bloodmagic/api/iface/INodeRenderer.java index 89701cf7..27b48335 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/INodeRenderer.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/INodeRenderer.java @@ -4,6 +4,5 @@ package WayofTime.bloodmagic.api.iface; * Held items that implement this will cause the beams between routing nodes to * render. */ -public interface INodeRenderer -{ +public interface INodeRenderer { } diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/IPurificationAsh.java b/src/main/java/WayofTime/bloodmagic/api/iface/IPurificationAsh.java index d96db141..b6b7940b 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/IPurificationAsh.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/IPurificationAsh.java @@ -2,8 +2,7 @@ package WayofTime.bloodmagic.api.iface; import net.minecraft.item.ItemStack; -public interface IPurificationAsh -{ +public interface IPurificationAsh { double getTotalPurity(ItemStack stack); double getMaxPurity(ItemStack stack); diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/ISentientSwordEffectProvider.java b/src/main/java/WayofTime/bloodmagic/api/iface/ISentientSwordEffectProvider.java index cedfce53..69ed3b28 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/ISentientSwordEffectProvider.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/ISentientSwordEffectProvider.java @@ -1,11 +1,10 @@ package WayofTime.bloodmagic.api.iface; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -public interface ISentientSwordEffectProvider -{ +public interface ISentientSwordEffectProvider { boolean applyOnHitEffect(EnumDemonWillType type, ItemStack swordStack, ItemStack providerStack, EntityLivingBase attacker, EntityLivingBase target); boolean providesEffectForWill(EnumDemonWillType type); diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/ISentientTool.java b/src/main/java/WayofTime/bloodmagic/api/iface/ISentientTool.java index e17789ff..979c1066 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/ISentientTool.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/ISentientTool.java @@ -3,7 +3,6 @@ package WayofTime.bloodmagic.api.iface; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -public interface ISentientTool -{ +public interface ISentientTool { boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player); } diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/ISigil.java b/src/main/java/WayofTime/bloodmagic/api/iface/ISigil.java index 2e318247..bc625ee5 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/ISigil.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/ISigil.java @@ -11,14 +11,12 @@ import javax.annotation.Nonnull; * Used for all {@link WayofTime.bloodmagic.api.impl.ItemSigil} EXCEPT * Sigils of Holdings. */ -public interface ISigil -{ +public interface ISigil { boolean performArrayEffect(World world, BlockPos pos); boolean hasArrayEffect(); - interface Holding - { + interface Holding { @Nonnull ItemStack getHeldItem(ItemStack holdingStack, EntityPlayer player); } diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/IUpgradeTrainer.java b/src/main/java/WayofTime/bloodmagic/api/iface/IUpgradeTrainer.java index 892aefad..6d4300bb 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/IUpgradeTrainer.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/IUpgradeTrainer.java @@ -8,8 +8,7 @@ import java.util.List; * This interface is used for items intended to train specific upgrades while * held in the player's inventory. */ -public interface IUpgradeTrainer -{ +public interface IUpgradeTrainer { List getTrainedUpgrades(ItemStack stack); boolean setTrainedUpgrades(ItemStack stack, List keys); diff --git a/src/main/java/WayofTime/bloodmagic/api/impl/ItemBindable.java b/src/main/java/WayofTime/bloodmagic/api/impl/ItemBindable.java index 034655d1..11fe41a2 100644 --- a/src/main/java/WayofTime/bloodmagic/api/impl/ItemBindable.java +++ b/src/main/java/WayofTime/bloodmagic/api/impl/ItemBindable.java @@ -1,19 +1,16 @@ package WayofTime.bloodmagic.api.impl; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.iface.IBindable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.iface.IBindable; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; /** * Base class for all bindable items. */ -public class ItemBindable extends Item implements IBindable -{ - public ItemBindable() - { +public class ItemBindable extends Item implements IBindable { + public ItemBindable() { super(); setMaxStackSize(1); @@ -22,20 +19,17 @@ public class ItemBindable extends Item implements IBindable // IBindable @Override - public boolean onBind(EntityPlayer player, ItemStack stack) - { + public boolean onBind(EntityPlayer player, ItemStack stack) { return true; } @Override - public String getOwnerName(ItemStack stack) - { + public String getOwnerName(ItemStack stack) { return !stack.isEmpty() ? stack.getTagCompound().getString(Constants.NBT.OWNER_NAME) : null; } @Override - public String getOwnerUUID(ItemStack stack) - { + public String getOwnerUUID(ItemStack stack) { return !stack.isEmpty() ? stack.getTagCompound().getString(Constants.NBT.OWNER_UUID) : null; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/impl/ItemSigil.java b/src/main/java/WayofTime/bloodmagic/api/impl/ItemSigil.java index fcf7b227..ff17b437 100644 --- a/src/main/java/WayofTime/bloodmagic/api/impl/ItemSigil.java +++ b/src/main/java/WayofTime/bloodmagic/api/impl/ItemSigil.java @@ -10,26 +10,22 @@ import net.minecraft.world.World; /** * Base class for all (static) sigils. */ -public class ItemSigil extends ItemBindable implements ISigil -{ +public class ItemSigil extends ItemBindable implements ISigil { private int lpUsed; - public ItemSigil(int lpUsed) - { + public ItemSigil(int lpUsed) { super(); this.lpUsed = lpUsed; } - public boolean isUnusable(ItemStack stack) - { + public boolean isUnusable(ItemStack stack) { NBTHelper.checkNBT(stack); return stack.getTagCompound().getBoolean(Constants.NBT.UNUSABLE); } - public ItemStack setUnusable(ItemStack stack, boolean unusable) - { + public ItemStack setUnusable(ItemStack stack, boolean unusable) { NBTHelper.checkNBT(stack); stack.getTagCompound().setBoolean(Constants.NBT.UNUSABLE, unusable); @@ -37,14 +33,12 @@ public class ItemSigil extends ItemBindable implements ISigil } @Override - public boolean performArrayEffect(World world, BlockPos pos) - { + public boolean performArrayEffect(World world, BlockPos pos) { return false; } @Override - public boolean hasArrayEffect() - { + public boolean hasArrayEffect() { return false; } diff --git a/src/main/java/WayofTime/bloodmagic/api/impl/ItemSigilToggleable.java b/src/main/java/WayofTime/bloodmagic/api/impl/ItemSigilToggleable.java index 0d4e75cd..bd243ec5 100644 --- a/src/main/java/WayofTime/bloodmagic/api/impl/ItemSigilToggleable.java +++ b/src/main/java/WayofTime/bloodmagic/api/impl/ItemSigilToggleable.java @@ -21,24 +21,19 @@ import net.minecraft.world.World; /** * Base class for all toggleable sigils. */ -public class ItemSigilToggleable extends ItemSigil implements IActivatable -{ - public ItemSigilToggleable(int lpUsed) - { +public class ItemSigilToggleable extends ItemSigil implements IActivatable { + public ItemSigilToggleable(int lpUsed) { super(lpUsed); } @Override - public boolean getActivated(ItemStack stack) - { + public boolean getActivated(ItemStack stack) { return !stack.isEmpty() && NBTHelper.checkNBT(stack).getTagCompound().getBoolean(Constants.NBT.ACTIVATED); } @Override - public ItemStack setActivatedState(ItemStack stack, boolean activated) - { - if (!stack.isEmpty()) - { + public ItemStack setActivatedState(ItemStack stack, boolean activated) { + if (!stack.isEmpty()) { NBTHelper.checkNBT(stack).getTagCompound().setBoolean(Constants.NBT.ACTIVATED, activated); return stack; } @@ -47,16 +42,14 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (stack.getItem() instanceof ISigil.Holding) stack = ((Holding) stack.getItem()).getHeldItem(stack, player); if (PlayerHelper.isFakePlayer(player)) return ActionResult.newResult(EnumActionResult.FAIL, stack); - if (!world.isRemote && !isUnusable(stack)) - { + if (!world.isRemote && !isUnusable(stack)) { if (player.isSneaking()) setActivatedState(stack, !getActivated(stack)); if (getActivated(stack) && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) @@ -67,8 +60,7 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); if (stack.getItem() instanceof ISigil.Holding) stack = ((Holding) stack.getItem()).getHeldItem(stack, player); @@ -78,20 +70,15 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable return (NetworkHelper.getSoulNetwork(getOwnerUUID(player.getHeldItem(hand))).syphonAndDamage(player, getLpUsed()) && onSigilUse(player.getHeldItem(hand), player, world, pos, side, hitX, hitY, hitZ)) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; } - public boolean onSigilUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) - { + public boolean onSigilUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) { return false; } @Override - public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) - { - if (!worldIn.isRemote && entityIn instanceof EntityPlayerMP && getActivated(stack)) - { - if (entityIn.ticksExisted % 100 == 0) - { - if (!NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage((EntityPlayer) entityIn, getLpUsed())) - { + public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { + if (!worldIn.isRemote && entityIn instanceof EntityPlayerMP && getActivated(stack)) { + if (entityIn.ticksExisted % 100 == 0) { + if (!NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage((EntityPlayer) entityIn, getLpUsed())) { setActivatedState(stack, false); } } @@ -100,7 +87,6 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable } } - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) - { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { } } diff --git a/src/main/java/WayofTime/bloodmagic/api/incense/EnumTranquilityType.java b/src/main/java/WayofTime/bloodmagic/api/incense/EnumTranquilityType.java index 70331efc..ba589df3 100644 --- a/src/main/java/WayofTime/bloodmagic/api/incense/EnumTranquilityType.java +++ b/src/main/java/WayofTime/bloodmagic/api/incense/EnumTranquilityType.java @@ -1,7 +1,6 @@ package WayofTime.bloodmagic.api.incense; -public enum EnumTranquilityType -{ +public enum EnumTranquilityType { PLANT(), CROP(), TREE(), diff --git a/src/main/java/WayofTime/bloodmagic/api/incense/IIncensePath.java b/src/main/java/WayofTime/bloodmagic/api/incense/IIncensePath.java index 797f6a11..bb7bc0ad 100644 --- a/src/main/java/WayofTime/bloodmagic/api/incense/IIncensePath.java +++ b/src/main/java/WayofTime/bloodmagic/api/incense/IIncensePath.java @@ -4,8 +4,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public interface IIncensePath -{ +public interface IIncensePath { /** * Goes from 0 to however far this path block can be from the altar while * still functioning. 0 represents a block that can work when it is two diff --git a/src/main/java/WayofTime/bloodmagic/api/incense/ITranquilityHandler.java b/src/main/java/WayofTime/bloodmagic/api/incense/ITranquilityHandler.java index 95eaa4b9..e6b88a4d 100644 --- a/src/main/java/WayofTime/bloodmagic/api/incense/ITranquilityHandler.java +++ b/src/main/java/WayofTime/bloodmagic/api/incense/ITranquilityHandler.java @@ -5,7 +5,6 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public interface ITranquilityHandler -{ +public interface ITranquilityHandler { TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state); } diff --git a/src/main/java/WayofTime/bloodmagic/api/incense/IncenseTranquilityRegistry.java b/src/main/java/WayofTime/bloodmagic/api/incense/IncenseTranquilityRegistry.java index 28fb4754..165b80cf 100644 --- a/src/main/java/WayofTime/bloodmagic/api/incense/IncenseTranquilityRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/incense/IncenseTranquilityRegistry.java @@ -8,22 +8,17 @@ import net.minecraft.world.World; import java.util.ArrayList; import java.util.List; -public class IncenseTranquilityRegistry -{ +public class IncenseTranquilityRegistry { public static List handlerList = new ArrayList(); - public static void registerTranquilityHandler(ITranquilityHandler handler) - { + public static void registerTranquilityHandler(ITranquilityHandler handler) { handlerList.add(handler); } - public static TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) - { - for (ITranquilityHandler handler : handlerList) - { + public static TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) { + for (ITranquilityHandler handler : handlerList) { TranquilityStack tranq = handler.getTranquilityOfBlock(world, pos, block, state); - if (tranq != null) - { + if (tranq != null) { return tranq; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/incense/TranquilityStack.java b/src/main/java/WayofTime/bloodmagic/api/incense/TranquilityStack.java index c2855f41..5852d488 100644 --- a/src/main/java/WayofTime/bloodmagic/api/incense/TranquilityStack.java +++ b/src/main/java/WayofTime/bloodmagic/api/incense/TranquilityStack.java @@ -1,12 +1,10 @@ package WayofTime.bloodmagic.api.incense; -public class TranquilityStack -{ +public class TranquilityStack { public final EnumTranquilityType type; public double value; - public TranquilityStack(EnumTranquilityType type, double value) - { + public TranquilityStack(EnumTranquilityType type, double value) { this.type = type; this.value = value; } diff --git a/src/main/java/WayofTime/bloodmagic/api/livingArmour/ILivingArmour.java b/src/main/java/WayofTime/bloodmagic/api/livingArmour/ILivingArmour.java index c47b310d..3a487a6c 100644 --- a/src/main/java/WayofTime/bloodmagic/api/livingArmour/ILivingArmour.java +++ b/src/main/java/WayofTime/bloodmagic/api/livingArmour/ILivingArmour.java @@ -1,7 +1,6 @@ package WayofTime.bloodmagic.api.livingArmour; import com.google.common.collect.Multimap; - import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; @@ -9,12 +8,10 @@ import net.minecraft.world.World; /** * An interface this is used purely for internal implementation. - * + * * @author WayofTime - * */ -public interface ILivingArmour -{ +public interface ILivingArmour { Multimap getAttributeModifiers(); boolean canApplyUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade); @@ -28,11 +25,9 @@ public interface ILivingArmour /** * Ticks the upgrades and stat trackers, passing in the world and player as * well as the LivingArmour - * - * @param world - * - The World - * @param player - * - The player wearing the Armour + * + * @param world - The World + * @param player - The player wearing the Armour */ void onTick(World world, EntityPlayer player); @@ -43,9 +38,8 @@ public interface ILivingArmour /** * Writes the LivingArmour to the NBTTag. This will only write the trackers * that are dirty. - * - * @param tag - * - The NBT tag to write to + * + * @param tag - The NBT tag to write to */ void writeDirtyToNBT(NBTTagCompound tag); diff --git a/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourHandler.java b/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourHandler.java index 0d3c652e..129ea2d8 100644 --- a/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourHandler.java +++ b/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourHandler.java @@ -8,66 +8,53 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -public class LivingArmourHandler -{ +public class LivingArmourHandler { public static List> trackers = new ArrayList>(); public static HashMap> upgradeMap = new HashMap>(); public static HashMap> upgradeConstructorMap = new HashMap>(); public static HashMap upgradeMaxLevelMap = new HashMap(); - public static void registerStatTracker(Class tracker) - { + public static void registerStatTracker(Class tracker) { trackers.add(tracker); } /** * Registers a LivingArmourUpgrade using its unique identifier and class. * This is done to more easily load upgrades - * + * * @param upgrade */ - public static void registerArmourUpgrade(LivingArmourUpgrade upgrade) - { + public static void registerArmourUpgrade(LivingArmourUpgrade upgrade) { Class clazz = upgrade.getClass(); upgradeMap.put(upgrade.getUniqueIdentifier(), clazz); upgradeMaxLevelMap.put(upgrade.getUniqueIdentifier(), upgrade.getMaxTier()); - try - { + try { Constructor ctor = clazz.getConstructor(int.class); - if (ctor == null) - { + if (ctor == null) { BloodMagicAPI.logger.error("Error adding living armour upgrade {} as it doesn't have a valid constructor.", upgrade.getUniqueIdentifier()); - } else - { + } else { upgradeConstructorMap.put(upgrade.getUniqueIdentifier(), ctor); } - } catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } } - public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level) - { + public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level) { return generateUpgradeFromKey(key, level, null); } - public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level, NBTTagCompound tag) - { + public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level, NBTTagCompound tag) { Constructor ctor = upgradeConstructorMap.get(key); - if (ctor != null) - { - try - { + if (ctor != null) { + try { LivingArmourUpgrade upgrade = ctor.newInstance(level); - if (upgrade != null && tag != null) - { + if (upgrade != null && tag != null) { upgrade.readFromNBT(tag); } return upgrade; - } catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java b/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java index bebd8f30..703478fa 100644 --- a/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java +++ b/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java @@ -2,7 +2,6 @@ package WayofTime.bloodmagic.api.livingArmour; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; - import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; @@ -11,8 +10,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.world.World; -public abstract class LivingArmourUpgrade -{ +public abstract class LivingArmourUpgrade { public static String chatBase = "chat.bloodmagic.livingArmour.upgrade."; public static String tooltipBase = "tooltip.bloodmagic.livingArmour.upgrade."; @@ -26,38 +24,32 @@ public abstract class LivingArmourUpgrade * The LivingArmourUpgrade must have a constructor that has a single integer * parameter. Upgrades may have other constructors, but must have one of * these. - * - * @param level - * The level of the upgrade + * + * @param level The level of the upgrade */ - public LivingArmourUpgrade(int level) - { + public LivingArmourUpgrade(int level) { this.level = Math.min(level, getMaxTier() - 1); } - public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) - { + public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) { return 0; } - public double getKnockbackOnHit(EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) - { + public double getKnockbackOnHit(EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) { return 0; } /** * Percentage of damage blocked. This stacks multiplicities with other * upgrades. - * + * * @return 0 for no damage blocked, 1 for full damage blocked */ - public double getArmourProtection(EntityLivingBase wearer, DamageSource source) - { + public double getArmourProtection(EntityLivingBase wearer, DamageSource source) { return 0; } - public int getUpgradeLevel() - { + public int getUpgradeLevel() { return this.level; } @@ -69,17 +61,14 @@ public abstract class LivingArmourUpgrade public abstract int getCostOfUpgrade(); - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { } - public Multimap getAttributeModifiers() - { + public Multimap getAttributeModifiers() { return HashMultimap.create(); } - public double getMiningSpeedModifier(EntityPlayer player) - { + public double getMiningSpeedModifier(EntityPlayer player) { return 1; } @@ -87,18 +76,15 @@ public abstract class LivingArmourUpgrade public abstract void readFromNBT(NBTTagCompound tag); - public int getRunicShielding() - { + public int getRunicShielding() { return 0; } - public boolean runOnClient() - { + public boolean runOnClient() { return false; } - public boolean isDowngrade() - { + public boolean isDowngrade() { return false; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/livingArmour/StatTracker.java b/src/main/java/WayofTime/bloodmagic/api/livingArmour/StatTracker.java index ee27a048..a43b7448 100644 --- a/src/main/java/WayofTime/bloodmagic/api/livingArmour/StatTracker.java +++ b/src/main/java/WayofTime/bloodmagic/api/livingArmour/StatTracker.java @@ -1,14 +1,13 @@ package WayofTime.bloodmagic.api.livingArmour; -import java.util.List; - +import WayofTime.bloodmagic.livingArmour.LivingArmour; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import WayofTime.bloodmagic.livingArmour.LivingArmour; -public abstract class StatTracker -{ +import java.util.List; + +public abstract class StatTracker { private boolean isDirty = false; public abstract String getUniqueIdentifier(); @@ -26,13 +25,10 @@ public abstract class StatTracker /** * Called each tick to update the tracker's information. Called in * LivingArmour - * - * @param world - * World the player is in - * @param player - * The player that has the armour equipped - * @param livingArmour - * The equipped LivingArmour + * + * @param world World the player is in + * @param player The player that has the armour equipped + * @param livingArmour The equipped LivingArmour * @return True if there is a new upgrade unlocked this tick. */ public abstract boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour); @@ -43,30 +39,25 @@ public abstract class StatTracker /** * Used to obtain the progress from the current level to the next level. - * + *

* 0.0 being 0% - 1.0 being 100%. - * - * @param livingArmour - * The equipped LivingArmour + * + * @param livingArmour The equipped LivingArmour * @return the progress from the current level to the next level. */ - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return 1.0D; } - public final boolean isDirty() - { + public final boolean isDirty() { return isDirty; } - public final void markDirty() - { + public final void markDirty() { this.isDirty = true; } - public final void resetDirty() - { + public final void resetDirty() { this.isDirty = false; } diff --git a/src/main/java/WayofTime/bloodmagic/api/orb/BloodOrb.java b/src/main/java/WayofTime/bloodmagic/api/orb/BloodOrb.java index a3c801ff..f5acc317 100644 --- a/src/main/java/WayofTime/bloodmagic/api/orb/BloodOrb.java +++ b/src/main/java/WayofTime/bloodmagic/api/orb/BloodOrb.java @@ -8,11 +8,10 @@ import javax.annotation.Nullable; /** * Base object for all Blood Orbs. Makes Orb creation quite a bit easier. - * + *

* Just create a new BloodOrb instance then register it in {@link net.minecraftforge.event.RegistryEvent.Register} */ -public class BloodOrb extends IForgeRegistryEntry.Impl -{ +public class BloodOrb extends IForgeRegistryEntry.Impl { private final String name; private final int tier; private final int capacity; @@ -22,33 +21,26 @@ public class BloodOrb extends IForgeRegistryEntry.Impl /** * A base object for BloodOrbs. A bit cleaner than the old way through * EnergyItems. - * - * @param name - * - A name for the Orb. Gets put into an unlocalized name. - * @param tier - * - The tier of the Orb. - * @param capacity - * - The max amount of LP the Orb can store. + * + * @param name - A name for the Orb. Gets put into an unlocalized name. + * @param tier - The tier of the Orb. + * @param capacity - The max amount of LP the Orb can store. */ - public BloodOrb(String name, int tier, int capacity) - { + public BloodOrb(String name, int tier, int capacity) { this.name = name; this.tier = tier; this.capacity = capacity; } - public String getName() - { + public String getName() { return name; } - public int getTier() - { + public int getTier() { return tier; } - public int getCapacity() - { + public int getCapacity() { return capacity; } @@ -63,8 +55,7 @@ public class BloodOrb extends IForgeRegistryEntry.Impl } @Override - public String toString() - { + public String toString() { return "BloodOrb{" + "name='" + name + '\'' + ", tier=" + tier + ", capacity=" + capacity + ", owner=" + getRegistryName() + '}'; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/orb/IBloodOrb.java b/src/main/java/WayofTime/bloodmagic/api/orb/IBloodOrb.java index 230b8332..76f1161b 100644 --- a/src/main/java/WayofTime/bloodmagic/api/orb/IBloodOrb.java +++ b/src/main/java/WayofTime/bloodmagic/api/orb/IBloodOrb.java @@ -4,8 +4,7 @@ import net.minecraft.item.ItemStack; import javax.annotation.Nullable; -public interface IBloodOrb -{ +public interface IBloodOrb { @Nullable BloodOrb getOrb(ItemStack stack); } diff --git a/src/main/java/WayofTime/bloodmagic/api/recipe/AlchemyTableCustomRecipe.java b/src/main/java/WayofTime/bloodmagic/api/recipe/AlchemyTableCustomRecipe.java index a136525b..be9afea1 100644 --- a/src/main/java/WayofTime/bloodmagic/api/recipe/AlchemyTableCustomRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/api/recipe/AlchemyTableCustomRecipe.java @@ -1,50 +1,41 @@ package WayofTime.bloodmagic.api.recipe; +import WayofTime.bloodmagic.api.iface.ICustomAlchemyConsumable; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import WayofTime.bloodmagic.api.iface.ICustomAlchemyConsumable; -public class AlchemyTableCustomRecipe extends AlchemyTableRecipe -{ - public AlchemyTableCustomRecipe(Block result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) - { +public class AlchemyTableCustomRecipe extends AlchemyTableRecipe { + public AlchemyTableCustomRecipe(Block result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) { this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe); } - public AlchemyTableCustomRecipe(Item result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) - { + public AlchemyTableCustomRecipe(Item result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) { this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe); } - public AlchemyTableCustomRecipe(ItemStack result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) - { + public AlchemyTableCustomRecipe(ItemStack result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) { super(result, lpDrained, ticksRequired, tierRequired, recipe); } @Override - protected ItemStack getContainerItem(ItemStack stack) - { - if (stack.isEmpty()) - { + protected ItemStack getContainerItem(ItemStack stack) { + if (stack.isEmpty()) { return ItemStack.EMPTY; } ItemStack copyStack = stack.copy(); - if (copyStack.getItem() instanceof ICustomAlchemyConsumable) - { + if (copyStack.getItem() instanceof ICustomAlchemyConsumable) { return ((ICustomAlchemyConsumable) copyStack.getItem()).drainUseOnAlchemyCraft(copyStack); } - if (copyStack.getItem().hasContainerItem(stack)) - { + if (copyStack.getItem().hasContainerItem(stack)) { return copyStack.getItem().getContainerItem(copyStack); } copyStack.shrink(1); - if (copyStack.isEmpty()) - { + if (copyStack.isEmpty()) { return ItemStack.EMPTY; } diff --git a/src/main/java/WayofTime/bloodmagic/api/recipe/AlchemyTableRecipe.java b/src/main/java/WayofTime/bloodmagic/api/recipe/AlchemyTableRecipe.java index c677afb2..553cdb6d 100644 --- a/src/main/java/WayofTime/bloodmagic/api/recipe/AlchemyTableRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/api/recipe/AlchemyTableRecipe.java @@ -1,9 +1,5 @@ package WayofTime.bloodmagic.api.recipe; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import com.google.common.collect.ImmutableList; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -13,49 +9,42 @@ import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; import org.apache.commons.lang3.builder.ToStringBuilder; -public class AlchemyTableRecipe -{ +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class AlchemyTableRecipe { protected ItemStack output = ItemStack.EMPTY; protected ArrayList input = new ArrayList(); protected int lpDrained; protected int ticksRequired; protected int tierRequired; - public AlchemyTableRecipe(Block result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) - { + public AlchemyTableRecipe(Block result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) { this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe); } - public AlchemyTableRecipe(Item result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) - { + public AlchemyTableRecipe(Item result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) { this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe); } - public AlchemyTableRecipe(ItemStack result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) - { + public AlchemyTableRecipe(ItemStack result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) { output = result.copy(); this.lpDrained = lpDrained; this.ticksRequired = ticksRequired; this.tierRequired = tierRequired; - for (Object in : recipe) - { - if (in instanceof ItemStack) - { + for (Object in : recipe) { + if (in instanceof ItemStack) { input.add(((ItemStack) in).copy()); - } else if (in instanceof Item) - { + } else if (in instanceof Item) { input.add(new ItemStack((Item) in)); - } else if (in instanceof Block) - { + } else if (in instanceof Block) { input.add(new ItemStack((Block) in)); - } else if (in instanceof String) - { + } else if (in instanceof String) { input.add(OreDictionary.getOres((String) in)); - } else - { + } else { String ret = "Invalid alchemy recipe: "; - for (Object tmp : recipe) - { + for (Object tmp : recipe) { ret += tmp + ", "; } ret += output; @@ -67,8 +56,7 @@ public class AlchemyTableRecipe /** * Returns the size of the recipe area */ - public int getRecipeSize() - { + public int getRecipeSize() { return input.size(); } @@ -76,12 +64,11 @@ public class AlchemyTableRecipe * Returns the output of the recipe, sensitive to the input list provided. * If the input list does not technically match, the recipe should return * the default output. - * + * * @param inputList * @return */ - public ItemStack getRecipeOutput(List inputList) - { + public ItemStack getRecipeOutput(List inputList) { return output.copy(); } @@ -90,42 +77,33 @@ public class AlchemyTableRecipe * BlockPos are for future-proofing */ @SuppressWarnings("unchecked") - public boolean matches(List checkedList, World world, BlockPos pos) - { + public boolean matches(List checkedList, World world, BlockPos pos) { ArrayList required = new ArrayList(input); - for (ItemStack slot : checkedList) - { - if (!slot.isEmpty()) - { + for (ItemStack slot : checkedList) { + if (!slot.isEmpty()) { boolean inRecipe = false; - for (Object aRequired : required) - { + for (Object aRequired : required) { boolean match = false; - if (aRequired instanceof ItemStack) - { + if (aRequired instanceof ItemStack) { match = OreDictionary.itemMatches((ItemStack) aRequired, slot, false); - } else if (aRequired instanceof List) - { + } else if (aRequired instanceof List) { Iterator itr = ((List) aRequired).iterator(); - while (itr.hasNext() && !match) - { + while (itr.hasNext() && !match) { match = OreDictionary.itemMatches(itr.next(), slot, false); } } - if (match) - { + if (match) { inRecipe = true; required.remove(aRequired); break; } } - if (!inRecipe) - { + if (!inRecipe) { return false; } } @@ -138,42 +116,35 @@ public class AlchemyTableRecipe * Returns the input for this recipe, any mod accessing this value should * never manipulate the values in this array as it will effect the recipe * itself. - * + * * @return The recipes input vales. */ - public List getInput() - { + public List getInput() { return ImmutableList.copyOf(input); } - public ItemStack[] getRemainingItems(ItemStack[] inventory) - { + public ItemStack[] getRemainingItems(ItemStack[] inventory) { ItemStack[] ret = inventory.clone(); - for (int i = 0; i < ret.length; i++) - { + for (int i = 0; i < ret.length; i++) { ret[i] = getContainerItem(inventory[i]); } return ret; } - protected ItemStack getContainerItem(ItemStack stack) - { - if (stack.isEmpty()) - { + protected ItemStack getContainerItem(ItemStack stack) { + if (stack.isEmpty()) { return ItemStack.EMPTY; } ItemStack copyStack = stack.copy(); - if (copyStack.getItem().hasContainerItem(stack)) - { + if (copyStack.getItem().hasContainerItem(stack)) { return copyStack.getItem().getContainerItem(copyStack); } copyStack.shrink(1); - if (copyStack.isEmpty()) - { + if (copyStack.isEmpty()) { return ItemStack.EMPTY; } diff --git a/src/main/java/WayofTime/bloodmagic/api/recipe/LivingArmourDowngradeRecipe.java b/src/main/java/WayofTime/bloodmagic/api/recipe/LivingArmourDowngradeRecipe.java index 2cfe9666..65aa9c3a 100644 --- a/src/main/java/WayofTime/bloodmagic/api/recipe/LivingArmourDowngradeRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/api/recipe/LivingArmourDowngradeRecipe.java @@ -1,9 +1,6 @@ package WayofTime.bloodmagic.api.recipe; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import com.google.common.collect.ImmutableList; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -12,37 +9,31 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.oredict.OreDictionary; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourDowngradeRecipe -{ +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class LivingArmourDowngradeRecipe { protected LivingArmourUpgrade upgrade = null; protected ItemStack keyStack = ItemStack.EMPTY; protected List input = new ArrayList(); - public LivingArmourDowngradeRecipe(LivingArmourUpgrade upgrade, ItemStack keyStack, Object... recipe) - { + public LivingArmourDowngradeRecipe(LivingArmourUpgrade upgrade, ItemStack keyStack, Object... recipe) { this.upgrade = upgrade; this.keyStack = keyStack; - for (Object in : recipe) - { - if (in instanceof ItemStack) - { + for (Object in : recipe) { + if (in instanceof ItemStack) { input.add(((ItemStack) in).copy()); - } else if (in instanceof Item) - { + } else if (in instanceof Item) { input.add(new ItemStack((Item) in)); - } else if (in instanceof Block) - { + } else if (in instanceof Block) { input.add(new ItemStack((Block) in)); - } else if (in instanceof String) - { + } else if (in instanceof String) { input.add(OreDictionary.getOres((String) in)); - } else - { + } else { String ret = "Invalid living armour downgrade recipe: "; - for (Object tmp : recipe) - { + for (Object tmp : recipe) { ret += tmp + ", "; } ret += upgrade.toString(); @@ -54,13 +45,11 @@ public class LivingArmourDowngradeRecipe /** * Returns the size of the recipe area */ - public int getRecipeSize() - { + public int getRecipeSize() { return input.size(); } - public LivingArmourUpgrade getRecipeOutput() - { + public LivingArmourUpgrade getRecipeOutput() { return upgrade; } @@ -69,49 +58,39 @@ public class LivingArmourDowngradeRecipe * BlockPos are for future-proofing */ @SuppressWarnings("unchecked") - public boolean matches(ItemStack key, List checkedList, World world, BlockPos pos) - { - if (!OreDictionary.itemMatches(keyStack, key, false)) - { + public boolean matches(ItemStack key, List checkedList, World world, BlockPos pos) { + if (!OreDictionary.itemMatches(keyStack, key, false)) { return false; } ArrayList required = new ArrayList(input); - for (ItemStack slot : checkedList) - { - if (slot != null) - { + for (ItemStack slot : checkedList) { + if (slot != null) { boolean inRecipe = false; - for (Object aRequired : required) - { + for (Object aRequired : required) { boolean match = false; 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 (match) { inRecipe = true; required.remove(next); break; } } - if (!inRecipe) - { + if (!inRecipe) { return false; } } @@ -124,57 +103,46 @@ public class LivingArmourDowngradeRecipe * Returns the input for this recipe, any mod accessing this value should * never manipulate the values in this array as it will effect the recipe * itself. - * + * * @return The recipes input vales. */ - public List getInput() - { + public List getInput() { return ImmutableList.copyOf(input); } - public ItemStack getKey() - { + public ItemStack getKey() { return this.keyStack; } - public void consumeInventory(IItemHandler inv) - { - for (int i = 0; i < inv.getSlots(); i++) - { + public void consumeInventory(IItemHandler inv) { + for (int i = 0; i < inv.getSlots(); i++) { ItemStack stack = inv.getStackInSlot(i); - if (stack.isEmpty()) - { + if (stack.isEmpty()) { continue; } - if (stack.getItem().hasContainerItem(stack)) - { + if (stack.getItem().hasContainerItem(stack)) { inv.extractItem(i, stack.getCount(), false); inv.insertItem(i, stack.getItem().getContainerItem(stack), false); - } else - { + } else { inv.extractItem(i, 1, false); } } } - protected ItemStack getContainerItem(ItemStack stack) - { - if (stack.isEmpty()) - { + protected ItemStack getContainerItem(ItemStack stack) { + if (stack.isEmpty()) { return ItemStack.EMPTY; } ItemStack copyStack = stack.copy(); - if (copyStack.getItem().hasContainerItem(stack)) - { + if (copyStack.getItem().hasContainerItem(stack)) { return copyStack.getItem().getContainerItem(copyStack); } copyStack.shrink(1); - if (copyStack.isEmpty()) - { + if (copyStack.isEmpty()) { return ItemStack.EMPTY; } diff --git a/src/main/java/WayofTime/bloodmagic/api/recipe/TartaricForgeRecipe.java b/src/main/java/WayofTime/bloodmagic/api/recipe/TartaricForgeRecipe.java index 813d4b04..d4becd01 100644 --- a/src/main/java/WayofTime/bloodmagic/api/recipe/TartaricForgeRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/api/recipe/TartaricForgeRecipe.java @@ -12,47 +12,36 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -public class TartaricForgeRecipe -{ +public class TartaricForgeRecipe { protected ItemStack output = null; protected List input = new ArrayList(); protected double minimumSouls; protected double soulsDrained; - public TartaricForgeRecipe(Block result, double minSouls, double drain, Object... recipe) - { + public TartaricForgeRecipe(Block result, double minSouls, double drain, Object... recipe) { this(new ItemStack(result), minSouls, drain, recipe); } - public TartaricForgeRecipe(Item result, double minSouls, double drain, Object... recipe) - { + public TartaricForgeRecipe(Item result, double minSouls, double drain, Object... recipe) { this(new ItemStack(result), minSouls, drain, recipe); } - public TartaricForgeRecipe(ItemStack result, double minSouls, double drain, Object... recipe) - { + public TartaricForgeRecipe(ItemStack result, double minSouls, double drain, Object... recipe) { output = result.copy(); this.minimumSouls = minSouls; this.soulsDrained = drain; - for (Object in : recipe) - { - if (in instanceof ItemStack) - { + for (Object in : recipe) { + if (in instanceof ItemStack) { input.add(((ItemStack) in).copy()); - } else if (in instanceof Item) - { + } else if (in instanceof Item) { input.add(new ItemStack((Item) in)); - } else if (in instanceof Block) - { + } else if (in instanceof Block) { input.add(new ItemStack((Block) in)); - } else if (in instanceof String) - { + } else if (in instanceof String) { input.add(OreDictionary.getOres((String) in)); - } else - { + } else { String ret = "Invalid soul forge recipe: "; - for (Object tmp : recipe) - { + for (Object tmp : recipe) { ret += tmp + ", "; } ret += output; @@ -64,13 +53,11 @@ public class TartaricForgeRecipe /** * Returns the size of the recipe area */ - public int getRecipeSize() - { + public int getRecipeSize() { return input.size(); } - public ItemStack getRecipeOutput() - { + public ItemStack getRecipeOutput() { return output.copy(); } @@ -79,47 +66,38 @@ public class TartaricForgeRecipe * BlockPos are for future-proofing */ @SuppressWarnings("unchecked") - public boolean matches(List checkedList, World world, BlockPos pos) - { + public boolean matches(List checkedList, World world, BlockPos pos) { ArrayList required = new ArrayList(input); - for (int x = 0; x < checkedList.size(); x++) - { + for (int x = 0; x < checkedList.size(); x++) { ItemStack slot = checkedList.get(x); - if (slot != null) - { + if (slot != null) { boolean inRecipe = false; Iterator req = required.iterator(); - while (req.hasNext()) - { + while (req.hasNext()) { boolean match = false; Object next = req.next(); - 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 (match) { inRecipe = true; required.remove(next); break; } } - if (!inRecipe) - { + if (!inRecipe) { return false; } } @@ -132,11 +110,10 @@ public class TartaricForgeRecipe * Returns the input for this recipe, any mod accessing this value should * never manipulate the values in this array as it will effect the recipe * itself. - * + * * @return The recipes input vales. */ - public List getInput() - { + public List getInput() { return this.input; } diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyArrayRecipeRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyArrayRecipeRegistry.java index a94370cf..c4cf383e 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyArrayRecipeRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyArrayRecipeRegistry.java @@ -1,25 +1,22 @@ package WayofTime.bloodmagic.api.registry; +import WayofTime.bloodmagic.api.ItemStackWrapper; +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting; +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.oredict.OreDictionary; + +import javax.annotation.Nullable; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; -import javax.annotation.Nullable; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.oredict.OreDictionary; -import WayofTime.bloodmagic.api.ItemStackWrapper; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; - -public class AlchemyArrayRecipeRegistry -{ +public class AlchemyArrayRecipeRegistry { public static final AlchemyCircleRenderer defaultRenderer = new AlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BaseArray.png")); private static BiMap, AlchemyArrayRecipe> recipes = HashBiMap.create(); @@ -27,42 +24,30 @@ public class AlchemyArrayRecipeRegistry /** * General case for creating an AlchemyArrayEffect for a given input. - * - * @param input - * - Input item(s) that is used to change the Alchemy Circle into the - * circle that you are making - * @param catalystStack - * - Catalyst item that, when right-clicked onto the array, will - * cause an effect - * @param arrayEffect - * - The effect that will be activated once the array is activated - * @param circleRenderer - * - Circle rendered when the array is passive - can be substituted - * for a special renderer + * + * @param input - Input item(s) that is used to change the Alchemy Circle into the + * circle that you are making + * @param catalystStack - Catalyst item that, when right-clicked onto the array, will + * cause an effect + * @param arrayEffect - The effect that will be activated once the array is activated + * @param circleRenderer - Circle rendered when the array is passive - can be substituted + * for a special renderer */ - public static void registerRecipe(List input, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) - { + public static void registerRecipe(List input, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) { effectMap.put(arrayEffect.getKey(), arrayEffect); - for (Entry, AlchemyArrayRecipe> entry : recipes.entrySet()) - { + for (Entry, AlchemyArrayRecipe> entry : recipes.entrySet()) { AlchemyArrayRecipe arrayRecipe = entry.getValue(); - if (arrayRecipe.doesInputMatchRecipe(input)) - { + if (arrayRecipe.doesInputMatchRecipe(input)) { AlchemyArrayEffect eff = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack); - if (eff != null) - { + if (eff != null) { return; // Recipe already exists! - } else - { + } else { arrayRecipe.catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect); - if (circleRenderer != null) - { - if (arrayRecipe.defaultCircleRenderer == null) - { + if (circleRenderer != null) { + if (arrayRecipe.defaultCircleRenderer == null) { arrayRecipe.defaultCircleRenderer = circleRenderer; - } else - { + } else { arrayRecipe.circleMap.put(ItemStackWrapper.getHolder(catalystStack), circleRenderer); } } @@ -74,63 +59,48 @@ public class AlchemyArrayRecipeRegistry recipes.put(input, new AlchemyArrayRecipe(input, catalystStack, arrayEffect, circleRenderer == null ? defaultRenderer : circleRenderer)); } - public static AlchemyArrayEffect getAlchemyArrayEffect(String key) - { + public static AlchemyArrayEffect getAlchemyArrayEffect(String key) { return effectMap.get(key); } /** - * * @param key * @return an array of two ItemStacks - first index is the input stack, - * second is the catalyst stack. Returns {null, null} if no recipe - * is valid. + * second is the catalyst stack. Returns {null, null} if no recipe + * is valid. */ - public static ItemStack[] getRecipeForArrayEffect(String key) - { - for (Entry, AlchemyArrayRecipe> entry : recipes.entrySet()) - { + public static ItemStack[] getRecipeForArrayEffect(String key) { + for (Entry, AlchemyArrayRecipe> entry : recipes.entrySet()) { AlchemyArrayRecipe recipe = entry.getValue(); - if (recipe != null && entry.getKey().size() > 0) - { - for (Entry effectEntry : recipe.catalystMap.entrySet()) - { - if (effectEntry.getValue() != null && effectEntry.getValue().key.equals(key)) - { - return new ItemStack[] { entry.getKey().get(0), effectEntry.getKey().toStack() }; + if (recipe != null && entry.getKey().size() > 0) { + for (Entry effectEntry : recipe.catalystMap.entrySet()) { + if (effectEntry.getValue() != null && effectEntry.getValue().key.equals(key)) { + return new ItemStack[]{entry.getKey().get(0), effectEntry.getKey().toStack()}; } } } } - return new ItemStack[] { null, null }; + return new ItemStack[]{null, null}; } /** - * @param stack - * of the recipe + * @param stack of the recipe * @return an array of two ItemStacks - first index is the input stack, - * second is the catalyst stack. Returns {null, null} if no recipe - * is valid. + * second is the catalyst stack. Returns {null, null} if no recipe + * is valid. */ - public static ItemStack[] getRecipeForOutputStack(ItemStack stack) - { - for (Entry, AlchemyArrayRecipe> entry : recipes.entrySet()) - { + public static ItemStack[] getRecipeForOutputStack(ItemStack stack) { + for (Entry, AlchemyArrayRecipe> entry : recipes.entrySet()) { AlchemyArrayRecipe recipe = entry.getValue(); - if (recipe != null && entry.getKey().size() > 0) - { - for (Entry effectEntry : recipe.catalystMap.entrySet()) - { - if (effectEntry.getValue() instanceof AlchemyArrayEffectCrafting) - { + if (recipe != null && entry.getKey().size() > 0) { + for (Entry effectEntry : recipe.catalystMap.entrySet()) { + if (effectEntry.getValue() instanceof AlchemyArrayEffectCrafting) { AlchemyArrayEffectCrafting craftingEffect = (AlchemyArrayEffectCrafting) effectEntry.getValue(); ItemStack resultStack = craftingEffect.outputStack; - if (!resultStack.isEmpty()) - { - if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) - { - return new ItemStack[] { entry.getKey().get(0), effectEntry.getKey().toStack() }; + if (!resultStack.isEmpty()) { + if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) { + return new ItemStack[]{entry.getKey().get(0), effectEntry.getKey().toStack()}; } } } @@ -138,123 +108,97 @@ public class AlchemyArrayRecipeRegistry } } - return new ItemStack[] { null, null }; + return new ItemStack[]{null, null}; } - public static void registerCraftingRecipe(ItemStack input, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) - { + public static void registerCraftingRecipe(ItemStack input, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) { registerRecipe(input, catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource); } - public static void registerCraftingRecipe(List inputStacks, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) - { + public static void registerCraftingRecipe(List inputStacks, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) { registerRecipe(inputStacks, catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource); } - public static void registerCraftingRecipe(String inputOreDict, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) - { + public static void registerCraftingRecipe(String inputOreDict, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) { registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.emptyList(), catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource); } - public static void registerCraftingRecipe(ItemStack input, ItemStack catalystStack, ItemStack outputStack) - { + public static void registerCraftingRecipe(ItemStack input, ItemStack catalystStack, ItemStack outputStack) { registerRecipe(input, catalystStack, new AlchemyArrayEffectCrafting(outputStack)); } - public static void registerCraftingRecipe(List inputStacks, ItemStack catalystStack, ItemStack outputStack) - { + public static void registerCraftingRecipe(List inputStacks, ItemStack catalystStack, ItemStack outputStack) { registerRecipe(inputStacks, catalystStack, new AlchemyArrayEffectCrafting(outputStack)); } - public static void registerCraftingRecipe(String inputOreDict, ItemStack catalystStack, ItemStack outputStack) - { + public static void registerCraftingRecipe(String inputOreDict, ItemStack catalystStack, ItemStack outputStack) { registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.emptyList(), catalystStack, new AlchemyArrayEffectCrafting(outputStack)); } - public static void registerRecipe(ItemStack inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) - { + public static void registerRecipe(ItemStack inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) { AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource); registerRecipe(Collections.singletonList(inputStacks), catalystStack, arrayEffect, circleRenderer); } - public static void registerRecipe(ItemStack inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) - { + public static void registerRecipe(ItemStack inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) { registerRecipe(Collections.singletonList(inputStacks), catalystStack, arrayEffect, circleRenderer); } - public static void registerRecipe(List inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) - { + public static void registerRecipe(List inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) { AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource); registerRecipe(inputStacks, catalystStack, arrayEffect, circleRenderer); } - public static void registerRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) - { + public static void registerRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) { AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource); registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.emptyList(), catalystStack, arrayEffect, circleRenderer); } - public static void registerRecipe(ItemStack input, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) - { + public static void registerRecipe(ItemStack input, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) { registerRecipe(Collections.singletonList(input), catalystStack, arrayEffect, (AlchemyCircleRenderer) null); } - public static void registerRecipe(List inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) - { + public static void registerRecipe(List inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) { registerRecipe(inputStacks, catalystStack, arrayEffect, (AlchemyCircleRenderer) null); } - public static void registerRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) - { + public static void registerRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) { registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.emptyList(), catalystStack, arrayEffect, (AlchemyCircleRenderer) null); } - public static void replaceAlchemyCircle(List input, AlchemyCircleRenderer circleRenderer) - { + public static void replaceAlchemyCircle(List input, AlchemyCircleRenderer circleRenderer) { if (circleRenderer == null) return; - for (Entry, AlchemyArrayRecipe> entry : recipes.entrySet()) - { + for (Entry, AlchemyArrayRecipe> entry : recipes.entrySet()) { AlchemyArrayRecipe arrayRecipe = entry.getValue(); if (arrayRecipe.doesInputMatchRecipe(input)) arrayRecipe.defaultCircleRenderer = circleRenderer; } } - public static AlchemyArrayRecipe getRecipeForInput(List input) - { + public static AlchemyArrayRecipe getRecipeForInput(List input) { return recipes.get(input); } - public static AlchemyArrayEffect getAlchemyArrayEffect(List input, @Nullable ItemStack catalystStack) - { - for (Entry, AlchemyArrayRecipe> entry : recipes.entrySet()) - { + public static AlchemyArrayEffect getAlchemyArrayEffect(List input, @Nullable ItemStack catalystStack) { + for (Entry, AlchemyArrayRecipe> entry : recipes.entrySet()) { AlchemyArrayRecipe arrayRecipe = entry.getValue(); - if (input.size() == 1 && arrayRecipe.getInput().size() == 1) - { - if (ItemStackWrapper.getHolder(arrayRecipe.getInput().get(0)).equals(ItemStackWrapper.getHolder(input.get(0)))) - { + if (input.size() == 1 && arrayRecipe.getInput().size() == 1) { + if (ItemStackWrapper.getHolder(arrayRecipe.getInput().get(0)).equals(ItemStackWrapper.getHolder(input.get(0)))) { AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack); - if (effect != null) - { + if (effect != null) { return effect.getNewCopy(); - } else - { + } else { return null; } } - } else - { - if (input.equals(arrayRecipe.getInput())) - { + } else { + if (input.equals(arrayRecipe.getInput())) { AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack); - if (effect != null) - { + if (effect != null) { return effect.getNewCopy(); - } else - { + } else { return null; } } @@ -264,18 +208,14 @@ public class AlchemyArrayRecipeRegistry return null; } - public static AlchemyArrayEffect getAlchemyArrayEffect(ItemStack input, @Nullable ItemStack catalystStack) - { + public static AlchemyArrayEffect getAlchemyArrayEffect(ItemStack input, @Nullable ItemStack catalystStack) { return getAlchemyArrayEffect(Collections.singletonList(input), catalystStack); } - public static AlchemyCircleRenderer getAlchemyCircleRenderer(List input, @Nullable ItemStack catalystStack) - { - for (Entry, AlchemyArrayRecipe> entry : recipes.entrySet()) - { + public static AlchemyCircleRenderer getAlchemyCircleRenderer(List input, @Nullable ItemStack catalystStack) { + for (Entry, AlchemyArrayRecipe> entry : recipes.entrySet()) { AlchemyArrayRecipe arrayRecipe = entry.getValue(); - if (arrayRecipe.doesInputMatchRecipe(input)) - { + if (arrayRecipe.doesInputMatchRecipe(input)) { return arrayRecipe.getAlchemyArrayRendererForCatalyst(catalystStack); } } @@ -283,20 +223,21 @@ public class AlchemyArrayRecipeRegistry return defaultRenderer; } - public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack itemStack, @Nullable ItemStack catalystStack) - { + public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack itemStack, @Nullable ItemStack catalystStack) { return getAlchemyCircleRenderer(Collections.singletonList(itemStack), catalystStack); } - public static class AlchemyArrayRecipe - { - public AlchemyCircleRenderer defaultCircleRenderer; + public static BiMap, AlchemyArrayRecipe> getRecipes() { + return HashBiMap.create(recipes); + } + + public static class AlchemyArrayRecipe { public final List input; public final BiMap catalystMap = HashBiMap.create(); public final BiMap circleMap = HashBiMap.create(); + public AlchemyCircleRenderer defaultCircleRenderer; - private AlchemyArrayRecipe(List input, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer, boolean useless) - { + private AlchemyArrayRecipe(List input, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer, boolean useless) { this.input = input; catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect); @@ -304,47 +245,37 @@ public class AlchemyArrayRecipeRegistry this.defaultCircleRenderer = circleRenderer; } - public AlchemyArrayRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) - { + public AlchemyArrayRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) { this(Collections.singletonList(inputStack), catalystStack, arrayEffect, circleRenderer, false); } - public AlchemyArrayRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) - { + public AlchemyArrayRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) { this(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.emptyList(), catalystStack, arrayEffect, circleRenderer, false); } - public AlchemyArrayRecipe(List inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) - { + public AlchemyArrayRecipe(List inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) { this(inputStacks, catalystStack, arrayEffect, circleRenderer, false); } /** * Compares the inputed list of ItemStacks to see if it matches with the * recipe's list. - * - * @param comparedList - * - The list to compare with - * + * + * @param comparedList - The list to compare with * @return - True if the ItemStack(s) is a compatible item */ - public boolean doesInputMatchRecipe(List comparedList) - { + public boolean doesInputMatchRecipe(List comparedList) { return !(comparedList == null || this.input == null) && (this.input.size() == 1 && comparedList.size() == 1 ? this.input.get(0).isItemEqual(comparedList.get(0)) : this.input.equals(comparedList)); } /** * Gets the actual AlchemyArrayEffect for the given catalyst. - * - * @param comparedStack - * The catalyst that is being checked - * + * + * @param comparedStack The catalyst that is being checked * @return - The effect */ - public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack) - { - for (Entry entry : catalystMap.entrySet()) - { + public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack) { + for (Entry entry : catalystMap.entrySet()) { ItemStack catalystStack = entry.getKey().toStack(); if (comparedStack == null && catalystStack == null) @@ -360,10 +291,8 @@ public class AlchemyArrayRecipeRegistry return null; } - public AlchemyCircleRenderer getAlchemyArrayRendererForCatalyst(@Nullable ItemStack comparedStack) - { - for (Entry entry : circleMap.entrySet()) - { + public AlchemyCircleRenderer getAlchemyArrayRendererForCatalyst(@Nullable ItemStack comparedStack) { + for (Entry entry : circleMap.entrySet()) { ItemStack catalystStack = entry.getKey().toStack(); if (comparedStack == null && catalystStack == null) @@ -418,9 +347,4 @@ public class AlchemyArrayRecipeRegistry return result; } } - - public static BiMap, AlchemyArrayRecipe> getRecipes() - { - return HashBiMap.create(recipes); - } } diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyTableRecipeRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyTableRecipeRegistry.java index cbc13263..daceba43 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyTableRecipeRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyTableRecipeRegistry.java @@ -1,38 +1,31 @@ package WayofTime.bloodmagic.api.registry; +import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + import java.util.ArrayList; import java.util.List; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe; - -public class AlchemyTableRecipeRegistry -{ +public class AlchemyTableRecipeRegistry { private static List recipeList = new ArrayList(); - public static void registerRecipe(AlchemyTableRecipe recipe) - { + public static void registerRecipe(AlchemyTableRecipe recipe) { recipeList.add(recipe); } - public static void registerRecipe(ItemStack outputStack, int lpDrained, int ticksRequired, int tierRequired, Object... objects) - { + public static void registerRecipe(ItemStack outputStack, int lpDrained, int ticksRequired, int tierRequired, Object... objects) { registerRecipe(new AlchemyTableRecipe(outputStack, lpDrained, ticksRequired, tierRequired, objects)); } - public static void removeRecipe(AlchemyTableRecipe recipe) - { + public static void removeRecipe(AlchemyTableRecipe recipe) { recipeList.remove(recipe); } - public static AlchemyTableRecipe getMatchingRecipe(List itemList, World world, BlockPos pos) - { - for (AlchemyTableRecipe recipe : recipeList) - { - if (recipe.matches(itemList, world, pos)) - { + public static AlchemyTableRecipe getMatchingRecipe(List itemList, World world, BlockPos pos) { + for (AlchemyTableRecipe recipe : recipeList) { + if (recipe.matches(itemList, world, pos)) { return recipe; } } @@ -40,8 +33,7 @@ public class AlchemyTableRecipeRegistry return null; } - public static List getRecipeList() - { + public static List getRecipeList() { return new ArrayList(recipeList); } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/AltarRecipeRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/AltarRecipeRegistry.java index 687813fd..64342bfa 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/AltarRecipeRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/AltarRecipeRegistry.java @@ -12,48 +12,41 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import java.util.Collections; import java.util.List; -public class AltarRecipeRegistry -{ +public class AltarRecipeRegistry { private static BiMap, AltarRecipe> recipes = HashBiMap.create(); /** * Registers an {@link AltarRecipe} for the Blood Altar. This can be a * {@code ItemStack}, {@code List}, or {@code String} * OreDictionary entry. - * + *

* If the OreDictionary entry does not exist or is empty, it will not be * registered. - * - * @param altarRecipe - * - The AltarRecipe to register + * + * @param altarRecipe - The AltarRecipe to register */ - public static void registerRecipe(AltarRecipe altarRecipe) - { + public static void registerRecipe(AltarRecipe altarRecipe) { if (!recipes.containsValue(altarRecipe) && altarRecipe.getInput().size() > 0) recipes.put(altarRecipe.getInput(), altarRecipe); else BloodMagicAPI.logger.error("Error adding altar recipe for input [{}].", altarRecipe.toString()); } - public static void registerFillRecipe(ItemStack orbStack, EnumAltarTier tier, int maxForOrb, int consumeRate, int drainRate) - { + public static void registerFillRecipe(ItemStack orbStack, EnumAltarTier tier, int maxForOrb, int consumeRate, int drainRate) { registerRecipe(new AltarRecipe(orbStack, orbStack, tier, maxForOrb, consumeRate, drainRate, true)); } - public static void removeRecipe(AltarRecipe altarRecipe) - { + public static void removeRecipe(AltarRecipe altarRecipe) { recipes.remove(altarRecipe.getInput()); } /** * Gets the recipe that the provided input is registered to. - * - * @param input - * - The input ItemStack to get the recipe for + * + * @param input - The input ItemStack to get the recipe for * @return - The recipe that the provided input is registered to. */ - public static AltarRecipe getRecipeForInput(List input) - { + public static AltarRecipe getRecipeForInput(List input) { List wrapperList = ItemStackWrapper.toWrapperList(input); if (recipes.keySet().contains(wrapperList)) return recipes.get(wrapperList); @@ -62,12 +55,9 @@ public class AltarRecipeRegistry } //TODO: Determine a more time-effective method - public static AltarRecipe getRecipeForInput(ItemStack input) - { - for (AltarRecipe recipe : recipes.values()) - { - if (recipe.doesRequiredItemMatch(input, recipe.getMinTier())) - { + public static AltarRecipe getRecipeForInput(ItemStack input) { + for (AltarRecipe recipe : recipes.values()) { + if (recipe.doesRequiredItemMatch(input, recipe.getMinTier())) { return recipe; } } @@ -75,18 +65,15 @@ public class AltarRecipeRegistry return null; } - public static AltarRecipe getRecipeForInput(String input) - { + public static AltarRecipe getRecipeForInput(String input) { return getRecipeForInput(OreDictionary.getOres(input)); } - public static BiMap, AltarRecipe> getRecipes() - { + public static BiMap, AltarRecipe> getRecipes() { return HashBiMap.create(recipes); } - public static class AltarRecipe - { + public static class AltarRecipe { private final List input; private final ItemStack output; private final EnumAltarTier minTier; @@ -99,24 +86,16 @@ public class AltarRecipeRegistry * {@link WayofTime.bloodmagic.tile.TileAltar}. The output ItemStack is * allowed to be null as some recipes do not contain an output. (Blood * Orbs) - * - * @param input - * - The input ItemStack - * @param output - * - The ItemStack obtained from the recipe - * @param minTier - * - The minimum tier of Altar required - * @param syphon - * - The amount of LP to syphon from the Altar - * @param consumeRate - * - The rate at which LP is consumed during crafting - * @param drainRate - * - The rate at which LP is drained during crafting - * @param fillable - * - Whether the input item can be filled with LP. IE: Orbs + * + * @param input - The input ItemStack + * @param output - The ItemStack obtained from the recipe + * @param minTier - The minimum tier of Altar required + * @param syphon - The amount of LP to syphon from the Altar + * @param consumeRate - The rate at which LP is consumed during crafting + * @param drainRate - The rate at which LP is drained during crafting + * @param fillable - Whether the input item can be filled with LP. IE: Orbs */ - public AltarRecipe(List input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean fillable) - { + public AltarRecipe(List input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean fillable) { this.input = ItemStackWrapper.toWrapperList(input); this.output = output; this.minTier = minTier; @@ -126,33 +105,27 @@ public class AltarRecipeRegistry this.fillable = fillable; } - public AltarRecipe(List input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) - { + public AltarRecipe(List input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) { this(input, output, minTier, syphon, consumeRate, drainRate, false); } - public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean fillable) - { + public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean fillable) { this(Collections.singletonList(input), output, minTier, syphon, consumeRate, drainRate, fillable); } - public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) - { + public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) { this(Collections.singletonList(input), output, minTier, syphon, consumeRate, drainRate, false); } - public AltarRecipe(String inputEntry, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean fillable) - { + public AltarRecipe(String inputEntry, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean fillable) { this(OreDictionary.doesOreNameExist(inputEntry) && OreDictionary.getOres(inputEntry).size() > 0 ? OreDictionary.getOres(inputEntry) : Collections.emptyList(), output, minTier, syphon, consumeRate, drainRate, fillable); } - public AltarRecipe(String inputEntry, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) - { + public AltarRecipe(String inputEntry, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) { this(OreDictionary.doesOreNameExist(inputEntry) && OreDictionary.getOres(inputEntry).size() > 0 ? OreDictionary.getOres(inputEntry) : Collections.emptyList(), output, minTier, syphon, consumeRate, drainRate, false); } - public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck) - { + public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck) { if (comparedStack == null || this.input == null) return false; diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/HarvestRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/HarvestRegistry.java index a12bf312..90b2fa42 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/HarvestRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/HarvestRegistry.java @@ -7,8 +7,7 @@ import net.minecraft.block.BlockStem; import java.util.*; -public class HarvestRegistry -{ +public class HarvestRegistry { private static List handlerList = new ArrayList(); private static Map standardCrops = new HashMap(); private static Set tallCrops = new HashSet(); @@ -17,12 +16,10 @@ public class HarvestRegistry /** * Registers a handler for the Harvest Ritual to call. - * - * @param handler - * - The custom handler to register + * + * @param handler - The custom handler to register */ - public static void registerHandler(IHarvestHandler handler) - { + public static void registerHandler(IHarvestHandler handler) { if (!handlerList.contains(handler)) handlerList.add(handler); } @@ -32,15 +29,12 @@ public class HarvestRegistry * for the * {@link WayofTime.bloodmagic.ritual.harvest.HarvestHandlerPlantable} * handler to handle. - * - * @param crop - * - The crop block to handle. - * @param matureMeta - * - The meta value at which the crop is considered mature and ready - * to be harvested. + * + * @param crop - The crop block to handle. + * @param matureMeta - The meta value at which the crop is considered mature and ready + * to be harvested. */ - public static void registerStandardCrop(Block crop, int matureMeta) - { + public static void registerStandardCrop(Block crop, int matureMeta) { if (!standardCrops.containsKey(crop)) standardCrops.put(crop, matureMeta); } @@ -49,12 +43,10 @@ public class HarvestRegistry * Registers a tall crop (Sugar Cane and Cactus) for the * {@link WayofTime.bloodmagic.ritual.harvest.HarvestHandlerTall} handler to * handle. - * - * @param crop - * - The crop block to handle. + * + * @param crop - The crop block to handle. */ - public static void registerTallCrop(BlockStack crop) - { + public static void registerTallCrop(BlockStack crop) { if (!tallCrops.contains(crop)) tallCrops.add(crop); } @@ -63,59 +55,48 @@ public class HarvestRegistry * Registers a stem crop (Melon and Pumpkin) for the * {@link WayofTime.bloodmagic.ritual.harvest.HarvestHandlerStem} handler to * handle. - * + *

* Use {@link net.minecraftforge.oredict.OreDictionary#WILDCARD_VALUE} to * accept any meta for the crop block. - * + *

* The Stem must be instanceof {@link BlockStem} - * - * @param crop - * - The crop block to handle. - * @param stem - * - The stem of the crop + * + * @param crop - The crop block to handle. + * @param stem - The stem of the crop */ - public static void registerStemCrop(BlockStack crop, BlockStack stem) - { + public static void registerStemCrop(BlockStack crop, BlockStack stem) { if (!stemCrops.containsKey(crop) && stem.getBlock() instanceof BlockStem) stemCrops.put(stem, crop); } /** * Registers a range amplifier for the Harvest Ritual. - * - * @param blockStack - * - The block for the amplifier. - * @param range - * - The range the amplifier provides. + * + * @param blockStack - The block for the amplifier. + * @param range - The range the amplifier provides. */ - public static void registerRangeAmplifier(BlockStack blockStack, int range) - { + public static void registerRangeAmplifier(BlockStack blockStack, int range) { if (!amplifierMap.containsKey(blockStack)) amplifierMap.put(blockStack, range); } - public static List getHandlerList() - { + public static List getHandlerList() { return new ArrayList(handlerList); } - public static Map getStandardCrops() - { + public static Map getStandardCrops() { return new HashMap(standardCrops); } - public static Set getTallCrops() - { + public static Set getTallCrops() { return new HashSet(tallCrops); } - public static Map getStemCrops() - { + public static Map getStemCrops() { return new HashMap(stemCrops); } - public static Map getAmplifierMap() - { + public static Map getAmplifierMap() { return new HashMap(amplifierMap); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/ImperfectRitualRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/ImperfectRitualRegistry.java index 247a2f6e..feebf365 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/ImperfectRitualRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/ImperfectRitualRegistry.java @@ -10,50 +10,40 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -public class ImperfectRitualRegistry -{ +public class ImperfectRitualRegistry { public static final Map enabledRituals = new HashMap(); private static final BiMap registry = HashBiMap.create(); /** * The safe way to register a new Ritual. - * - * @param imperfectRitual - * - The imperfect ritual to register. - * @param id - * - The ID for the imperfect ritual. Cannot be duplicated. + * + * @param imperfectRitual - The imperfect ritual to register. + * @param id - The ID for the imperfect ritual. Cannot be duplicated. */ - public static void registerRitual(ImperfectRitual imperfectRitual, String id, boolean enabled) - { - if (imperfectRitual != null) - { + public static void registerRitual(ImperfectRitual imperfectRitual, String id, boolean enabled) { + if (imperfectRitual != null) { if (registry.containsKey(id)) BloodMagicAPI.logger.error("Duplicate imperfect ritual id: %s", id); - else - { + else { registry.put(id, imperfectRitual); enabledRituals.put(imperfectRitual, enabled); } } } - public static void registerRitual(ImperfectRitual imperfectRitual, String id) - { + public static void registerRitual(ImperfectRitual imperfectRitual, String id) { registerRitual(imperfectRitual, id, true); } - public static void registerRitual(ImperfectRitual imperfectRitual, boolean enabled) - { + public static void registerRitual(ImperfectRitual imperfectRitual, boolean enabled) { registerRitual(imperfectRitual, imperfectRitual.getName(), enabled); } - public static void registerRitual(ImperfectRitual imperfectRitual) - { + public static void registerRitual(ImperfectRitual imperfectRitual) { registerRitual(imperfectRitual, imperfectRitual.getName()); } - public static ImperfectRitual getRitualForBlock(BlockStack blockStack) - { + public static ImperfectRitual getRitualForBlock(BlockStack blockStack) { for (ImperfectRitual imperfectRitual : getRegistry().values()) if (imperfectRitual.getRequiredBlock().equals(blockStack)) return imperfectRitual; @@ -61,60 +51,48 @@ public class ImperfectRitualRegistry return null; } - public static ImperfectRitual getRitualForId(String id) - { + public static ImperfectRitual getRitualForId(String id) { return registry.get(id); } - public static String getIdForRitual(ImperfectRitual imperfectRitual) - { + public static String getIdForRitual(ImperfectRitual imperfectRitual) { return registry.inverse().get(imperfectRitual); } - public static boolean isMapEmpty() - { + public static boolean isMapEmpty() { return registry.isEmpty(); } - public static int getMapSize() - { + public static int getMapSize() { return registry.size(); } - public static boolean ritualEnabled(ImperfectRitual imperfectRitual) - { - try - { + public static boolean ritualEnabled(ImperfectRitual imperfectRitual) { + try { return enabledRituals.get(imperfectRitual); - } catch (NullPointerException e) - { + } catch (NullPointerException e) { BloodMagicAPI.logger.error("Invalid Imperfect Ritual was called"); return false; } } - public static boolean ritualEnabled(String id) - { + public static boolean ritualEnabled(String id) { return ritualEnabled(getRitualForId(id)); } - public static BiMap getRegistry() - { + public static BiMap getRegistry() { return HashBiMap.create(registry); } - public static BiMap getEnabledMap() - { + public static BiMap getEnabledMap() { return HashBiMap.create(enabledRituals); } - public static ArrayList getIds() - { + public static ArrayList getIds() { return new ArrayList(registry.keySet()); } - public static ArrayList getRituals() - { + public static ArrayList getRituals() { return new ArrayList(registry.values()); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/LivingArmourDowngradeRecipeRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/LivingArmourDowngradeRecipeRegistry.java index b6de0ce8..3f635ed3 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/LivingArmourDowngradeRecipeRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/LivingArmourDowngradeRecipeRegistry.java @@ -1,44 +1,37 @@ package WayofTime.bloodmagic.api.registry; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.api.recipe.LivingArmourDowngradeRecipe; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.world.World; +import net.minecraftforge.oredict.OreDictionary; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.World; -import net.minecraftforge.oredict.OreDictionary; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.api.recipe.LivingArmourDowngradeRecipe; - -public class LivingArmourDowngradeRecipeRegistry -{ +public class LivingArmourDowngradeRecipeRegistry { private static List recipeList = new ArrayList(); private static Map>> dialogueMap = new HashMap>>(); - public static void registerRecipe(LivingArmourDowngradeRecipe recipe) - { + public static void registerRecipe(LivingArmourDowngradeRecipe recipe) { recipeList.add(recipe); } - public static void registerDialog(ItemStack keyStack, Map> map) - { + public static void registerDialog(ItemStack keyStack, Map> map) { dialogueMap.put(keyStack, map); } - public static List getDialogForProcessTick(ItemStack keyStack, int tick) - { - for (Entry>> entry : dialogueMap.entrySet()) - { + public static List getDialogForProcessTick(ItemStack keyStack, int tick) { + for (Entry>> entry : dialogueMap.entrySet()) { ItemStack key = entry.getKey(); - if (OreDictionary.itemMatches(key, keyStack, false)) - { + if (OreDictionary.itemMatches(key, keyStack, false)) { Map> map = entry.getValue(); - if (map.containsKey(tick)) - { + if (map.containsKey(tick)) { return map.get(tick); } } @@ -47,17 +40,13 @@ public class LivingArmourDowngradeRecipeRegistry return null; } - public static void registerRecipe(LivingArmourUpgrade upgrade, ItemStack keyStack, Object... recipe) - { + public static void registerRecipe(LivingArmourUpgrade upgrade, ItemStack keyStack, Object... recipe) { registerRecipe(new LivingArmourDowngradeRecipe(upgrade, keyStack, recipe)); } - public static LivingArmourDowngradeRecipe getMatchingRecipe(ItemStack keyStack, List itemList, World world, BlockPos pos) - { - for (LivingArmourDowngradeRecipe recipe : recipeList) - { - if (recipe.matches(keyStack, itemList, world, pos)) - { + public static LivingArmourDowngradeRecipe getMatchingRecipe(ItemStack keyStack, List itemList, World world, BlockPos pos) { + for (LivingArmourDowngradeRecipe recipe : recipeList) { + if (recipe.matches(keyStack, itemList, world, pos)) { return recipe; } } @@ -65,8 +54,7 @@ public class LivingArmourDowngradeRecipeRegistry return null; } - public static List getRecipeList() - { + public static List getRecipeList() { return new ArrayList(recipeList); } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/OrbRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/OrbRegistry.java index a0d2eebe..13cdde2b 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/OrbRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/OrbRegistry.java @@ -17,24 +17,20 @@ import java.util.List; * custom handling, you will need your own item class. */ @Deprecated -public class OrbRegistry -{ - private static List orbs = new ArrayList(); - public static ArrayListMultimap tierMap = ArrayListMultimap.create(); - +public class OrbRegistry { @GameRegistry.ObjectHolder("bloodmagic:blood_orb") private static final Item ORB_ITEM = null; + public static ArrayListMultimap tierMap = ArrayListMultimap.create(); + private static List orbs = new ArrayList(); - public static List getOrbsForTier(int tier) - { + public static List getOrbsForTier(int tier) { if (getTierMap().containsKey(tier)) return getTierMap().get(tier); return Collections.emptyList(); } - public static List getOrbsUpToTier(int tier) - { + public static List getOrbsUpToTier(int tier) { List ret = new ArrayList(); for (int i = 1; i <= tier; i++) @@ -43,8 +39,7 @@ public class OrbRegistry return ret; } - public static List getOrbsDownToTier(int tier) - { + public static List getOrbsDownToTier(int tier) { List ret = new ArrayList(); for (int i = EnumAltarTier.MAXTIERS; i >= tier; i--) @@ -53,8 +48,7 @@ public class OrbRegistry return ret; } - public static ItemStack getOrbStack(BloodOrb orb) - { + public static ItemStack getOrbStack(BloodOrb orb) { ItemStack ret = new ItemStack(ORB_ITEM); NBTTagCompound tag = new NBTTagCompound(); tag.setString("orb", orb.getRegistryName().toString()); @@ -62,8 +56,7 @@ public class OrbRegistry return ret; } - public static ArrayListMultimap getTierMap() - { + public static ArrayListMultimap getTierMap() { return ArrayListMultimap.create(tierMap); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/RitualRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/RitualRegistry.java index 4b090f4c..e62ece62 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/RitualRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/RitualRegistry.java @@ -8,8 +8,7 @@ import com.google.common.collect.HashBiMap; import javax.annotation.Nullable; import java.util.*; -public class RitualRegistry -{ +public class RitualRegistry { public static final Map enabledRituals = new HashMap(); private static final BiMap registry = HashBiMap.create(); private static final List lookupList = new ArrayList(); @@ -23,27 +22,21 @@ public class RitualRegistry /** * The safe way to register a new Ritual. - * - * @param ritual - * - The ritual to register. - * @param id - * - The ID for the ritual. Cannot be duplicated. + * + * @param ritual - The ritual to register. + * @param id - The ID for the ritual. Cannot be duplicated. */ - public static void registerRitual(Ritual ritual, String id, boolean enabled) - { - if (locked) - { + public static void registerRitual(Ritual ritual, String id, boolean enabled) { + if (locked) { BloodMagicAPI.logger.error("This registry has been locked. Please register your ritual earlier."); BloodMagicAPI.logger.error("If you reflect this, I will hunt you down. - TehNut"); return; } - if (ritual != null) - { + if (ritual != null) { if (registry.containsKey(id)) BloodMagicAPI.logger.error("Duplicate ritual id: %s", id); - else - { + else { registry.put(id, ritual); enabledRituals.put(ritual, enabled); orderedIdList.add(id); @@ -51,95 +44,76 @@ public class RitualRegistry } } - public static void registerRitual(Ritual ritual, boolean enabled) - { + public static void registerRitual(Ritual ritual, boolean enabled) { registerRitual(ritual, ritual.getName(), enabled); } - public static void registerRitual(Ritual ritual, String id) - { + public static void registerRitual(Ritual ritual, String id) { registerRitual(ritual, id, true); } - public static void registerRitual(Ritual ritual) - { + public static void registerRitual(Ritual ritual) { registerRitual(ritual, ritual.getName()); } @Nullable - public static Ritual getRitualForId(String id) - { + public static Ritual getRitualForId(String id) { Ritual ritual = registry.get(id); return ritual != null ? ritual.getNewCopy() : null; } - public static String getIdForRitual(Ritual ritual) - { + public static String getIdForRitual(Ritual ritual) { return registry.inverse().get(ritual); } - public static boolean isMapEmpty() - { + public static boolean isMapEmpty() { return registry.isEmpty(); } - public static int getMapSize() - { + public static int getMapSize() { return registry.size(); } - public static boolean ritualEnabled(Ritual ritual) - { - try - { + public static boolean ritualEnabled(Ritual ritual) { + try { return enabledRituals.get(ritual); - } catch (NullPointerException e) - { + } catch (NullPointerException e) { BloodMagicAPI.logger.error("Invalid Ritual was called"); return false; } } - public static boolean ritualEnabled(String id) - { + public static boolean ritualEnabled(String id) { return ritualEnabled(getRitualForId(id)); } - public static BiMap getRegistry() - { + public static BiMap getRegistry() { return HashBiMap.create(registry); } - public static Map getEnabledMap() - { + public static Map getEnabledMap() { return new HashMap(enabledRituals); } - public static ArrayList getIds() - { + public static ArrayList getIds() { return new ArrayList(lookupList); } - public static ArrayList getOrderedIds() - { + public static ArrayList getOrderedIds() { return orderedIdList; } - public static ArrayList getRituals() - { + public static ArrayList getRituals() { return new ArrayList(registry.values()); } - public static void orderLookupList() - { + public static void orderLookupList() { locked = true; // Lock registry so no no rituals can be registered lookupList.clear(); // Make sure it's empty lookupList.addAll(registry.keySet()); - Collections.sort(lookupList, new Comparator() - { + Collections.sort(lookupList, new Comparator() { @Override - public int compare(String o1, String o2) - { + public int compare(String o1, String o2) { Ritual ritual1 = registry.get(o1); Ritual ritual2 = registry.get(o2); return ritual1.getComponents().size() > ritual2.getComponents().size() ? -1 : 0; // Put earlier if bigger diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/TartaricForgeRecipeRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/TartaricForgeRecipeRegistry.java index 24ad8e39..f9df0ffd 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/TartaricForgeRecipeRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/TartaricForgeRecipeRegistry.java @@ -8,31 +8,24 @@ import net.minecraft.world.World; import java.util.ArrayList; import java.util.List; -public class TartaricForgeRecipeRegistry -{ +public class TartaricForgeRecipeRegistry { private static List recipeList = new ArrayList(); - public static void registerRecipe(TartaricForgeRecipe recipe) - { + public static void registerRecipe(TartaricForgeRecipe recipe) { recipeList.add(recipe); } - public static void registerRecipe(ItemStack outputStack, double minimulSouls, double drain, Object... objects) - { + public static void registerRecipe(ItemStack outputStack, double minimulSouls, double drain, Object... objects) { registerRecipe(new TartaricForgeRecipe(outputStack, minimulSouls, drain, objects)); } - public static void removeRecipe(TartaricForgeRecipe recipe) - { + public static void removeRecipe(TartaricForgeRecipe recipe) { recipeList.remove(recipe); } - public static TartaricForgeRecipe getMatchingRecipe(List itemList, World world, BlockPos pos) - { - for (TartaricForgeRecipe recipe : recipeList) - { - if (recipe.matches(itemList, world, pos)) - { + public static TartaricForgeRecipe getMatchingRecipe(List itemList, World world, BlockPos pos) { + for (TartaricForgeRecipe recipe : recipeList) { + if (recipe.matches(itemList, world, pos)) { return recipe; } } @@ -40,8 +33,7 @@ public class TartaricForgeRecipeRegistry return null; } - public static List getRecipeList() - { + public static List getRecipeList() { return new ArrayList(recipeList); } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/AreaDescriptor.java b/src/main/java/WayofTime/bloodmagic/api/ritual/AreaDescriptor.java index 059cf1df..521c9dca 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/AreaDescriptor.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/AreaDescriptor.java @@ -1,26 +1,23 @@ package WayofTime.bloodmagic.api.ritual; +import WayofTime.bloodmagic.api.Constants; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.gen.structure.template.PlacementSettings; +import net.minecraft.world.gen.structure.template.Template; + import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.gen.structure.template.PlacementSettings; -import net.minecraft.world.gen.structure.template.Template; -import WayofTime.bloodmagic.api.Constants; - -public abstract class AreaDescriptor implements Iterator -{ - public List getContainedPositions(BlockPos pos) - { +public abstract class AreaDescriptor implements Iterator { + public List getContainedPositions(BlockPos pos) { return new ArrayList(); } - public AxisAlignedBB getAABB(BlockPos pos) - { + public AxisAlignedBB getAABB(BlockPos pos) { return null; } @@ -30,13 +27,11 @@ public abstract class AreaDescriptor implements Iterator public abstract void resetIterator(); - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { } - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { } @@ -52,7 +47,7 @@ public abstract class AreaDescriptor implements Iterator * This method changes the area descriptor so that its range matches the two * blocks that are selected. When implementing this method, assume that * these positions are the blocks that are clicked by the player. - * + * * @param pos1 * @param pos2 */ @@ -64,8 +59,7 @@ public abstract class AreaDescriptor implements Iterator public abstract AreaDescriptor rotateDescriptor(PlacementSettings settings); - public static class Rectangle extends AreaDescriptor - { + public static class Rectangle extends AreaDescriptor { protected BlockPos minimumOffset; protected BlockPos maximumOffset; // Non-inclusive maximum offset. private BlockPos currentPosition; @@ -79,40 +73,30 @@ public abstract class AreaDescriptor implements Iterator * This constructor takes in the minimum and maximum BlockPos. The * maximum offset is non-inclusive, meaning if you pass in (0,0,0) and * (1,1,1), calling getContainedPositions() will only give (0,0,0). - * - * @param minimumOffset - * - - * @param maximumOffset - * - + * + * @param minimumOffset - + * @param maximumOffset - */ - public Rectangle(BlockPos minimumOffset, BlockPos maximumOffset) - { + public Rectangle(BlockPos minimumOffset, BlockPos maximumOffset) { setOffsets(minimumOffset, maximumOffset); } - public Rectangle(BlockPos minimumOffset, int sizeX, int sizeY, int sizeZ) - { + public Rectangle(BlockPos minimumOffset, int sizeX, int sizeY, int sizeZ) { this(minimumOffset, minimumOffset.add(sizeX, sizeY, sizeZ)); } - public Rectangle(BlockPos minimumOffset, int size) - { + public Rectangle(BlockPos minimumOffset, int size) { this(minimumOffset, size, size, size); } @Override - public List getContainedPositions(BlockPos pos) - { - if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty()) - { + public List getContainedPositions(BlockPos pos) { + if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty()) { ArrayList posList = new ArrayList(); - for (int j = minimumOffset.getY(); j < maximumOffset.getY(); j++) - { - for (int i = minimumOffset.getX(); i < maximumOffset.getX(); i++) - { - for (int k = minimumOffset.getZ(); k < maximumOffset.getZ(); k++) - { + for (int j = minimumOffset.getY(); j < maximumOffset.getY(); j++) { + for (int i = minimumOffset.getX(); i < maximumOffset.getX(); i++) { + for (int k = minimumOffset.getZ(); k < maximumOffset.getZ(); k++) { posList.add(pos.add(i, j, k)); } } @@ -126,8 +110,7 @@ public abstract class AreaDescriptor implements Iterator } @Override - public AxisAlignedBB getAABB(BlockPos pos) - { + public AxisAlignedBB getAABB(BlockPos pos) { AxisAlignedBB tempAABB = new AxisAlignedBB(minimumOffset, maximumOffset); return tempAABB.offset(pos.getX(), pos.getY(), pos.getZ()); } @@ -135,28 +118,23 @@ public abstract class AreaDescriptor implements Iterator /** * Sets the offsets of the AreaDescriptor in a safe way that will make * minimumOffset the lowest corner - * - * @param offset1 - * - - * @param offset2 - * - + * + * @param offset1 - + * @param offset2 - */ - public void setOffsets(BlockPos offset1, BlockPos offset2) - { + public void setOffsets(BlockPos offset1, BlockPos offset2) { this.minimumOffset = new BlockPos(Math.min(offset1.getX(), offset2.getX()), Math.min(offset1.getY(), offset2.getY()), Math.min(offset1.getZ(), offset2.getZ())); this.maximumOffset = new BlockPos(Math.max(offset1.getX(), offset2.getX()), Math.max(offset1.getY(), offset2.getY()), Math.max(offset1.getZ(), offset2.getZ())); blockPosCache = new ArrayList(); } @Override - public void resetCache() - { + public void resetCache() { this.blockPosCache = new ArrayList(); } @Override - public boolean isWithinArea(BlockPos pos) - { + public boolean isWithinArea(BlockPos pos) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); @@ -165,22 +143,18 @@ public abstract class AreaDescriptor implements Iterator } @Override - public boolean hasNext() - { + public boolean hasNext() { return currentPosition == null || !(currentPosition.getX() + 1 == maximumOffset.getX() && currentPosition.getY() + 1 == maximumOffset.getY() && currentPosition.getZ() + 1 == maximumOffset.getZ()); } @Override - public BlockPos next() - { - if (currentPosition != null) - { + public BlockPos next() { + if (currentPosition != null) { int nextX = currentPosition.getX() + 1 >= maximumOffset.getX() ? minimumOffset.getX() : currentPosition.getX() + 1; int nextZ = nextX != minimumOffset.getX() ? currentPosition.getZ() : (currentPosition.getZ() + 1 >= maximumOffset.getZ() ? minimumOffset.getZ() : currentPosition.getZ() + 1); int nextY = (nextZ != minimumOffset.getZ() || nextX != minimumOffset.getX()) ? currentPosition.getY() : (currentPosition.getY() + 1); currentPosition = new BlockPos(nextX, nextY, nextZ); - } else - { + } else { currentPosition = minimumOffset; } @@ -188,20 +162,17 @@ public abstract class AreaDescriptor implements Iterator } @Override - public void remove() - { + public void remove() { } @Override - public void resetIterator() - { + public void resetIterator() { currentPosition = null; } @Override - public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2) - { + public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2) { setOffsets(pos1, pos2); maximumOffset = maximumOffset.add(1, 1, 1); resetIterator(); @@ -209,15 +180,13 @@ public abstract class AreaDescriptor implements Iterator } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { minimumOffset = new BlockPos(tag.getInteger(Constants.NBT.X_COORD + "min"), tag.getInteger(Constants.NBT.Y_COORD + "min"), tag.getInteger(Constants.NBT.Z_COORD + "min")); maximumOffset = new BlockPos(tag.getInteger(Constants.NBT.X_COORD + "max"), tag.getInteger(Constants.NBT.Y_COORD + "max"), tag.getInteger(Constants.NBT.Z_COORD + "max")); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(Constants.NBT.X_COORD + "min", minimumOffset.getX()); tag.setInteger(Constants.NBT.Y_COORD + "min", minimumOffset.getY()); tag.setInteger(Constants.NBT.Z_COORD + "min", minimumOffset.getZ()); @@ -227,8 +196,7 @@ public abstract class AreaDescriptor implements Iterator } @Override - public int getVolumeForOffsets(BlockPos offset1, BlockPos offset2) - { + public int getVolumeForOffsets(BlockPos offset1, BlockPos offset2) { BlockPos minPos = new BlockPos(Math.min(offset1.getX(), offset2.getX()), Math.min(offset1.getY(), offset2.getY()), Math.min(offset1.getZ(), offset2.getZ())); BlockPos maxPos = new BlockPos(Math.max(offset1.getX(), offset2.getX()), Math.max(offset1.getY(), offset2.getY()), Math.max(offset1.getZ(), offset2.getZ())); @@ -238,8 +206,7 @@ public abstract class AreaDescriptor implements Iterator } @Override - public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit) - { + public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit) { BlockPos minPos = new BlockPos(Math.min(offset1.getX(), offset2.getX()), Math.min(offset1.getY(), offset2.getY()), Math.min(offset1.getZ(), offset2.getZ())); BlockPos maxPos = new BlockPos(Math.max(offset1.getX(), offset2.getX()), Math.max(offset1.getY(), offset2.getY()), Math.max(offset1.getZ(), offset2.getZ())); @@ -247,22 +214,18 @@ public abstract class AreaDescriptor implements Iterator } @Override - public int getVolume() - { + public int getVolume() { return (maximumOffset.getX() - minimumOffset.getX()) * (maximumOffset.getY() - minimumOffset.getY()) * (maximumOffset.getZ() - minimumOffset.getZ()); } @Override - public boolean isWithinRange(int verticalLimit, int horizontalLimit) - { + public boolean isWithinRange(int verticalLimit, int horizontalLimit) { return minimumOffset.getY() >= -verticalLimit && maximumOffset.getY() <= verticalLimit + 1 && minimumOffset.getX() >= -horizontalLimit && maximumOffset.getX() <= horizontalLimit + 1 && minimumOffset.getZ() >= -horizontalLimit && maximumOffset.getZ() <= horizontalLimit + 1; } @Override - public boolean intersects(AreaDescriptor descriptor) - { - if (descriptor instanceof AreaDescriptor.Rectangle) - { + public boolean intersects(AreaDescriptor descriptor) { + if (descriptor instanceof AreaDescriptor.Rectangle) { AreaDescriptor.Rectangle rectangle = (AreaDescriptor.Rectangle) descriptor; return !(minimumOffset.getX() >= rectangle.maximumOffset.getX() || minimumOffset.getY() >= rectangle.maximumOffset.getY() || minimumOffset.getZ() >= rectangle.maximumOffset.getZ() || rectangle.minimumOffset.getX() >= maximumOffset.getX() || rectangle.minimumOffset.getY() >= maximumOffset.getY() || rectangle.minimumOffset.getZ() >= maximumOffset.getZ()); @@ -272,14 +235,12 @@ public abstract class AreaDescriptor implements Iterator } @Override - public AreaDescriptor offset(BlockPos offset) - { + public AreaDescriptor offset(BlockPos offset) { return new AreaDescriptor.Rectangle(this.minimumOffset.add(offset), this.maximumOffset.add(offset)); } @Override - public AreaDescriptor rotateDescriptor(PlacementSettings settings) - { + public AreaDescriptor rotateDescriptor(PlacementSettings settings) { BlockPos rotatePos1 = Template.transformedBlockPos(settings, minimumOffset); BlockPos rotatePos2 = Template.transformedBlockPos(settings, maximumOffset.add(-1, -1, -1)); //It works, shut up! @@ -290,8 +251,7 @@ public abstract class AreaDescriptor implements Iterator } } - public static class HemiSphere extends AreaDescriptor - { + public static class HemiSphere extends AreaDescriptor { private BlockPos minimumOffset; private int radius; @@ -300,23 +260,19 @@ public abstract class AreaDescriptor implements Iterator private boolean cache = true; - public HemiSphere(BlockPos minimumOffset, int radius) - { + public HemiSphere(BlockPos minimumOffset, int radius) { setRadius(minimumOffset, radius); } - public void setRadius(BlockPos minimumOffset, int radius) - { + public void setRadius(BlockPos minimumOffset, int radius) { this.minimumOffset = new BlockPos(Math.min(minimumOffset.getX(), minimumOffset.getX()), Math.min(minimumOffset.getY(), minimumOffset.getY()), Math.min(minimumOffset.getZ(), minimumOffset.getZ())); this.radius = radius; blockPosCache = new ArrayList(); } @Override - public List getContainedPositions(BlockPos pos) - { - if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty()) - { + public List getContainedPositions(BlockPos pos) { + if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty()) { ArrayList posList = new ArrayList(); int i = -radius; @@ -325,14 +281,10 @@ public abstract class AreaDescriptor implements Iterator //TODO For some reason the bottom of the hemisphere is not going up with the minOffset - while (i <= radius) - { - while (j <= radius) - { - while (k <= radius) - { - if (i * i + j * j + k * k >= (radius + 0.5F) * (radius + 0.5F)) - { + while (i <= radius) { + while (j <= radius) { + while (k <= radius) { + if (i * i + j * j + k * k >= (radius + 0.5F) * (radius + 0.5F)) { k++; continue; } @@ -360,98 +312,82 @@ public abstract class AreaDescriptor implements Iterator * Since you can't make a box using a sphere, this returns null */ @Override - public AxisAlignedBB getAABB(BlockPos pos) - { + public AxisAlignedBB getAABB(BlockPos pos) { return null; } @Override - public void resetCache() - { + public void resetCache() { this.blockPosCache = new ArrayList(); } @Override - public boolean isWithinArea(BlockPos pos) - { + public boolean isWithinArea(BlockPos pos) { return blockPosCache.contains(pos); } @Override - public boolean hasNext() - { + public boolean hasNext() { return false; } @Override - public BlockPos next() - { + public BlockPos next() { return null; } @Override - public void remove() - { + public void remove() { } @Override - public void resetIterator() - { + public void resetIterator() { } @Override - public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2) - { + public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2) { } @Override - public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2) - { + public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2) { return 0; } @Override - public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit) - { + public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit) { return false; } @Override - public int getVolume() - { + public int getVolume() { return 0; } @Override - public boolean isWithinRange(int verticalLimit, int horizontalLimit) - { + public boolean isWithinRange(int verticalLimit, int horizontalLimit) { return false; } @Override - public boolean intersects(AreaDescriptor descriptor) - { + public boolean intersects(AreaDescriptor descriptor) { return false; } @Override - public AreaDescriptor offset(BlockPos offset) - { + public AreaDescriptor offset(BlockPos offset) { return new AreaDescriptor.HemiSphere(minimumOffset.add(offset), radius); } @Override - public AreaDescriptor rotateDescriptor(PlacementSettings settings) - { + public AreaDescriptor rotateDescriptor(PlacementSettings settings) { return this; } } - public static class Cross extends AreaDescriptor - { + public static class Cross extends AreaDescriptor { private ArrayList blockPosCache; private BlockPos cachedPosition; @@ -461,23 +397,19 @@ public abstract class AreaDescriptor implements Iterator private boolean cache = true; - public Cross(BlockPos center, int size) - { + public Cross(BlockPos center, int size) { this.centerPos = center; this.size = size; this.blockPosCache = new ArrayList(); } @Override - public List getContainedPositions(BlockPos pos) - { - if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty()) - { + public List getContainedPositions(BlockPos pos) { + if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty()) { resetCache(); blockPosCache.add(centerPos.add(pos)); - for (int i = 1; i <= size; i++) - { + for (int i = 1; i <= size; i++) { blockPosCache.add(centerPos.add(pos).add(i, 0, 0)); blockPosCache.add(centerPos.add(pos).add(0, 0, i)); blockPosCache.add(centerPos.add(pos).add(-i, 0, 0)); @@ -491,86 +423,72 @@ public abstract class AreaDescriptor implements Iterator } @Override - public void resetCache() - { + public void resetCache() { blockPosCache = new ArrayList(); } @Override - public boolean isWithinArea(BlockPos pos) - { + public boolean isWithinArea(BlockPos pos) { return blockPosCache.contains(pos); } @Override - public boolean hasNext() - { + public boolean hasNext() { return false; } @Override - public BlockPos next() - { + public BlockPos next() { return null; } @Override - public void remove() - { + public void remove() { } @Override - public void resetIterator() - { + public void resetIterator() { } @Override - public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2) - { + public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2) { } @Override - public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2) - { + public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2) { return 0; } @Override - public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit) - { + public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit) { return false; } @Override - public int getVolume() - { + public int getVolume() { return 0; } @Override - public boolean isWithinRange(int verticalLimit, int horizontalLimit) - { + public boolean isWithinRange(int verticalLimit, int horizontalLimit) { return false; } @Override - public boolean intersects(AreaDescriptor descriptor) - { + public boolean intersects(AreaDescriptor descriptor) { return false; } @Override - public AreaDescriptor offset(BlockPos offset) - { + public AreaDescriptor offset(BlockPos offset) { return new AreaDescriptor.Cross(centerPos.add(offset), size); } @Override - public AreaDescriptor rotateDescriptor(PlacementSettings settings) - { + public AreaDescriptor rotateDescriptor(PlacementSettings settings) { return this; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/CapabilityRuneType.java b/src/main/java/WayofTime/bloodmagic/api/ritual/CapabilityRuneType.java index d166dc4d..af658b4f 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/CapabilityRuneType.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/CapabilityRuneType.java @@ -7,50 +7,40 @@ import net.minecraftforge.common.capabilities.Capability; import java.util.concurrent.Callable; -public final class CapabilityRuneType -{ - public static class RuneTypeStorage implements Capability.IStorage - { +public final class CapabilityRuneType { + public static class RuneTypeStorage implements Capability.IStorage { @Override - public NBTBase writeNBT(Capability capability, IRitualStone.Tile instance, EnumFacing side) - { + public NBTBase writeNBT(Capability capability, IRitualStone.Tile instance, EnumFacing side) { return new NBTTagByte((byte) instance.getRuneType().ordinal()); } @Override - public void readNBT(Capability capability, IRitualStone.Tile instance, EnumFacing side, NBTBase nbt) - { + public void readNBT(Capability capability, IRitualStone.Tile instance, EnumFacing side, NBTBase nbt) { instance.setRuneType(EnumRuneType.byMetadata(((NBTTagByte) nbt).getByte())); } } - public static class RuneTypeWrapper implements IRitualStone.Tile - { + public static class RuneTypeWrapper implements IRitualStone.Tile { private EnumRuneType type = EnumRuneType.BLANK; @Override - public boolean isRuneType(EnumRuneType runeType) - { + public boolean isRuneType(EnumRuneType runeType) { return type == runeType; } @Override - public EnumRuneType getRuneType() - { + public EnumRuneType getRuneType() { return type; } - public void setRuneType(EnumRuneType runeType) - { + public void setRuneType(EnumRuneType runeType) { type = runeType; } } - public static class Factory implements Callable - { + public static class Factory implements Callable { @Override - public IRitualStone.Tile call() throws Exception - { + public IRitualStone.Tile call() throws Exception { return new RuneTypeWrapper(); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/EnumRitualReaderState.java b/src/main/java/WayofTime/bloodmagic/api/ritual/EnumRitualReaderState.java index 82a4f446..b1b9597f 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/EnumRitualReaderState.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/EnumRitualReaderState.java @@ -1,7 +1,6 @@ package WayofTime.bloodmagic.api.ritual; -public enum EnumRitualReaderState -{ +public enum EnumRitualReaderState { SET_AREA, INFORMATION, SET_WILL_TYPES; diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/EnumRuneType.java b/src/main/java/WayofTime/bloodmagic/api/ritual/EnumRuneType.java index eceeb97f..74c7aeb4 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/EnumRuneType.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/EnumRuneType.java @@ -9,8 +9,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry; import java.util.Locale; -public enum EnumRuneType implements IStringSerializable -{ +public enum EnumRuneType implements IStringSerializable { BLANK(TextFormatting.GRAY), WATER(TextFormatting.AQUA), FIRE(TextFormatting.RED), @@ -24,34 +23,29 @@ public enum EnumRuneType implements IStringSerializable public final TextFormatting colorCode; - EnumRuneType(TextFormatting colorCode) - { + EnumRuneType(TextFormatting colorCode) { this.colorCode = colorCode; } - public static EnumRuneType byMetadata(int meta) - { + public ItemStack getScribeStack() { + return new ItemStack(INSCRIPTION_TOOL, 1, ordinal()); + } + + @Override + public String toString() { + return name().toLowerCase(Locale.ENGLISH); + } + + @Override + public String getName() { + return this.toString(); + } + + public static EnumRuneType byMetadata(int meta) { if (meta < 0 || meta >= values().length) meta = 0; return values()[meta]; } - public ItemStack getScribeStack() - { - return new ItemStack(INSCRIPTION_TOOL, 1, ordinal()); - } - - @Override - public String toString() - { - return name().toLowerCase(Locale.ENGLISH); - } - - @Override - public String getName() - { - return this.toString(); - } - } diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/IMasterRitualStone.java b/src/main/java/WayofTime/bloodmagic/api/ritual/IMasterRitualStone.java index 7ffecdb9..6fb8544e 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/IMasterRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/IMasterRitualStone.java @@ -1,22 +1,21 @@ package WayofTime.bloodmagic.api.ritual; -import java.util.List; - import WayofTime.bloodmagic.api.saving.SoulNetwork; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; + +import java.util.List; /** * This interface is for internal implementation only. - * + *

* It is provided via the API for easy obtaining of basic data. */ -public interface IMasterRitualStone -{ +public interface IMasterRitualStone { String getOwner(); SoulNetwork getOwnerNetwork(); diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/IRitualStone.java b/src/main/java/WayofTime/bloodmagic/api/ritual/IRitualStone.java index 3c623ce2..846d6267 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/IRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/IRitualStone.java @@ -5,17 +5,15 @@ import net.minecraft.world.World; /** * This interface is for internal implementation only. - * + *

* It is provided via the API for easy obtaining of basic data. */ -public interface IRitualStone -{ +public interface IRitualStone { boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType); void setRuneType(World world, BlockPos pos, EnumRuneType runeType); - interface Tile - { + interface Tile { boolean isRuneType(EnumRuneType runeType); EnumRuneType getRuneType(); diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/Ritual.java b/src/main/java/WayofTime/bloodmagic/api/ritual/Ritual.java index bec8ef1c..35763652 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/Ritual.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/Ritual.java @@ -1,11 +1,8 @@ package WayofTime.bloodmagic.api.ritual; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - +import WayofTime.bloodmagic.api.soul.DemonWillHolder; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -14,29 +11,30 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.soul.DemonWillHolder; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; import org.apache.commons.lang3.builder.ToStringBuilder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + /** * Abstract class for creating new rituals. Rituals need be registered with * {@link WayofTime.bloodmagic.api.registry.RitualRegistry#registerRitual(Ritual, String)} */ -public abstract class Ritual -{ +public abstract class Ritual { public final ArrayList ritualComponents = new ArrayList(); + protected final Map modableRangeMap = new HashMap(); + protected final Map volumeRangeMap = new HashMap(); + protected final Map horizontalRangeMap = new HashMap(); + protected final Map verticalRangeMap = new HashMap(); private final String name; private final int crystalLevel; private final int activationCost; private final RitualRenderer renderer; private final String unlocalizedName; - protected final Map modableRangeMap = new HashMap(); - protected final Map volumeRangeMap = new HashMap(); - protected final Map horizontalRangeMap = new HashMap(); - protected final Map verticalRangeMap = new HashMap(); - public Ritual(String name, int crystalLevel, int activationCost, RitualRenderer renderer, String unlocalizedName) { this.name = name; this.crystalLevel = crystalLevel; @@ -46,46 +44,36 @@ public abstract class Ritual } /** - * @param name - * - The name of the ritual - * @param crystalLevel - * - Required Activation Crystal tier - * @param activationCost - * - Base LP cost for activating the ritual + * @param name - The name of the ritual + * @param crystalLevel - Required Activation Crystal tier + * @param activationCost - Base LP cost for activating the ritual */ - public Ritual(String name, int crystalLevel, int activationCost, String unlocalizedName) - { + public Ritual(String name, int crystalLevel, int activationCost, String unlocalizedName) { this(name, crystalLevel, activationCost, null, unlocalizedName); } - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { NBTTagList tags = tag.getTagList("areas", 10); - if (tags.hasNoTags()) - { + if (tags.hasNoTags()) { return; } - for (int i = 0; i < tags.tagCount(); i++) - { + for (int i = 0; i < tags.tagCount(); i++) { NBTTagCompound newTag = tags.getCompoundTagAt(i); String rangeKey = newTag.getString("key"); NBTTagCompound storedTag = newTag.getCompoundTag("area"); AreaDescriptor desc = this.getBlockRange(rangeKey); - if (desc != null) - { + if (desc != null) { desc.readFromNBT(storedTag); } } } - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { NBTTagList tags = new NBTTagList(); - for (Entry entry : modableRangeMap.entrySet()) - { + for (Entry entry : modableRangeMap.entrySet()) { NBTTagCompound newTag = new NBTTagCompound(); newTag.setString("key", entry.getKey()); NBTTagCompound storedTag = new NBTTagCompound(); @@ -102,52 +90,44 @@ public abstract class Ritual /** * Called when the player attempts to activate the ritual. - * + *

* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)} - * - * @param masterRitualStone - * - The {@link IMasterRitualStone} that the ritual is bound to - * @param player - * - The activating player - * @param owner - * - Owner of the crystal activating this ritual, or the current - * owner of the ritual if being reactivated. + * + * @param masterRitualStone - The {@link IMasterRitualStone} that the ritual is bound to + * @param player - The activating player + * @param owner - Owner of the crystal activating this ritual, or the current + * owner of the ritual if being reactivated. * @return - Whether activation was successful */ - public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player, String owner) - { + public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player, String owner) { return true; } /** * Called every {@link #getRefreshTime()} ticks while active. - * + *

* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)} - * - * @param masterRitualStone - * - The {@link IMasterRitualStone} that the ritual is bound to + * + * @param masterRitualStone - The {@link IMasterRitualStone} that the ritual is bound to */ public abstract void performRitual(IMasterRitualStone masterRitualStone); /** * Called when the ritual is stopped for a given {@link Ritual.BreakType}. - * + *

* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(Ritual.BreakType)} - * - * @param masterRitualStone - * - The {@link IMasterRitualStone} that the ritual is bound to - * @param breakType - * - The type of break that caused the stoppage. + * + * @param masterRitualStone - The {@link IMasterRitualStone} that the ritual is bound to + * @param breakType - The type of break that caused the stoppage. */ - public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType) - { + public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType) { } /** * Used to set the amount of LP drained every {@link #getRefreshTime()} * ticks. - * + * * @return - The amount of LP drained per refresh */ public abstract int getRefreshCost(); @@ -155,64 +135,52 @@ public abstract class Ritual /** * Used to set the refresh rate of the ritual. (How often * {@link #performRitual(IMasterRitualStone)} is called. - * + * * @return - How often to perform the effect in ticks. */ - public int getRefreshTime() - { + public int getRefreshTime() { return 20; } - public void addBlockRange(String range, AreaDescriptor defaultRange) - { + public void addBlockRange(String range, AreaDescriptor defaultRange) { modableRangeMap.put(range, defaultRange); } /** * Used to grab the range of a ritual for a given effect. - * - * @param range - * - Range that needs to be pulled. + * + * @param range - Range that needs to be pulled. * @return - */ - public AreaDescriptor getBlockRange(String range) - { - if (modableRangeMap.containsKey(range)) - { + public AreaDescriptor getBlockRange(String range) { + if (modableRangeMap.containsKey(range)) { return modableRangeMap.get(range); } return null; } - public List getListOfRanges() - { + public List getListOfRanges() { return new ArrayList(modableRangeMap.keySet()); } - public String getNextBlockRange(String range) - { + public String getNextBlockRange(String range) { List rangeList = getListOfRanges(); - if (rangeList.isEmpty()) - { + if (rangeList.isEmpty()) { return ""; } - if (!rangeList.contains(range)) - { + if (!rangeList.contains(range)) { return rangeList.get(0); } boolean hasMatch = false; - for (String rangeCheck : rangeList) - { - if (hasMatch) - { + for (String rangeCheck : rangeList) { + if (hasMatch) { return rangeCheck; - } else if (rangeCheck.equals(range)) - { + } else if (rangeCheck.equals(range)) { hasMatch = true; } } @@ -220,14 +188,12 @@ public abstract class Ritual return rangeList.get(0); } - public boolean setBlockRangeByBounds(String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2) - { + public boolean setBlockRangeByBounds(String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2) { AreaDescriptor descriptor = this.getBlockRange(range); World world = master.getWorldObj(); BlockPos masterPos = master.getBlockPos(); DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(world, masterPos); - if (canBlockRangeBeModified(range, descriptor, master, offset1, offset2, holder)) - { + if (canBlockRangeBeModified(range, descriptor, master, offset1, offset2, holder)) { descriptor.modifyAreaByBlockPositions(offset1, offset2); return true; } @@ -235,8 +201,7 @@ public abstract class Ritual return false; } - protected boolean canBlockRangeBeModified(String range, AreaDescriptor descriptor, IMasterRitualStone master, BlockPos offset1, BlockPos offset2, DemonWillHolder holder) - { + protected boolean canBlockRangeBeModified(String range, AreaDescriptor descriptor, IMasterRitualStone master, BlockPos offset1, BlockPos offset2, DemonWillHolder holder) { List willConfig = master.getActiveWillConfig(); int maxVolume = getMaxVolumeForRange(range, willConfig, holder); int maxVertical = getMaxVerticalRadiusForRange(range, willConfig, holder); @@ -245,38 +210,31 @@ public abstract class Ritual return (maxVolume <= 0 || descriptor.getVolumeForOffsets(offset1, offset2) <= maxVolume) && descriptor.isWithinRange(offset1, offset2, maxVertical, maxHorizontal); } - protected void setMaximumVolumeAndDistanceOfRange(String range, int volume, int horizontalRadius, int verticalRadius) - { + protected void setMaximumVolumeAndDistanceOfRange(String range, int volume, int horizontalRadius, int verticalRadius) { volumeRangeMap.put(range, volume); horizontalRangeMap.put(range, horizontalRadius); verticalRangeMap.put(range, verticalRadius); } - protected boolean checkDescriptorIsWithinRange(AreaDescriptor descriptor, int maxVolume, int maxHorizontal, int maxVertical) - { + protected boolean checkDescriptorIsWithinRange(AreaDescriptor descriptor, int maxVolume, int maxHorizontal, int maxVertical) { return descriptor.getVolume() <= maxVolume && descriptor.isWithinRange(maxVertical, maxHorizontal); } - public int getMaxVolumeForRange(String range, List activeTypes, DemonWillHolder holder) - { + public int getMaxVolumeForRange(String range, List activeTypes, DemonWillHolder holder) { return volumeRangeMap.get(range); } - public int getMaxVerticalRadiusForRange(String range, List activeTypes, DemonWillHolder holder) - { + public int getMaxVerticalRadiusForRange(String range, List activeTypes, DemonWillHolder holder) { return verticalRangeMap.get(range); } - public int getMaxHorizontalRadiusForRange(String range, List activeTypes, DemonWillHolder holder) - { + public int getMaxHorizontalRadiusForRange(String range, List activeTypes, DemonWillHolder holder) { return horizontalRangeMap.get(range); } - public ITextComponent getErrorForBlockRangeOnFail(EntityPlayer player, String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2) - { + public ITextComponent getErrorForBlockRangeOnFail(EntityPlayer player, String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2) { AreaDescriptor descriptor = this.getBlockRange(range); - if (descriptor == null) - { + if (descriptor == null) { return new TextComponentTranslation("ritual.bloodmagic.blockRange.tooBig", "?"); } @@ -287,27 +245,21 @@ public abstract class Ritual int maxVertical = this.getMaxVerticalRadiusForRange(range, willConfig, holder); int maxHorizontal = this.getMaxHorizontalRadiusForRange(range, willConfig, holder); - if (maxVolume > 0 && descriptor.getVolumeForOffsets(offset1, offset2) > maxVolume) - { + if (maxVolume > 0 && descriptor.getVolumeForOffsets(offset1, offset2) > maxVolume) { return new TextComponentTranslation("ritual.bloodmagic.blockRange.tooBig", maxVolume); - } else - { + } else { return new TextComponentTranslation("ritual.bloodmagic.blockRange.tooFar", maxVertical, maxHorizontal); } } - public ITextComponent[] provideInformationOfRitualToPlayer(EntityPlayer player) - { - return new ITextComponent[] { new TextComponentTranslation(this.getUnlocalizedName() + ".info") }; + public ITextComponent[] provideInformationOfRitualToPlayer(EntityPlayer player) { + return new ITextComponent[]{new TextComponentTranslation(this.getUnlocalizedName() + ".info")}; } - public ITextComponent provideInformationOfRangeToPlayer(EntityPlayer player, String range) - { - if (getListOfRanges().contains(range)) - { + public ITextComponent provideInformationOfRangeToPlayer(EntityPlayer player, String range) { + if (getListOfRanges().contains(range)) { return new TextComponentTranslation(this.getUnlocalizedName() + "." + range + ".info"); - } else - { + } else { return new TextComponentTranslation("ritual.bloodmagic.blockRange.noRange"); } } @@ -317,13 +269,11 @@ public abstract class Ritual */ public abstract ArrayList getComponents(); - public void addRune(ArrayList components, int offset1, int y, int offset2, EnumRuneType rune) - { + public void addRune(ArrayList components, int offset1, int y, int offset2, EnumRuneType rune) { components.add(new RitualComponent(new BlockPos(offset1, y, offset2), rune)); } - public void addOffsetRunes(ArrayList components, int offset1, int offset2, int y, EnumRuneType rune) - { + public void addOffsetRunes(ArrayList components, int offset1, int offset2, int y, EnumRuneType rune) { addRune(components, offset1, y, offset2, rune); addRune(components, offset2, y, offset1, rune); addRune(components, offset1, y, -offset2, rune); @@ -334,34 +284,21 @@ public abstract class Ritual addRune(components, -offset2, y, -offset1, rune); } - public void addCornerRunes(ArrayList components, int offset, int y, EnumRuneType rune) - { + public void addCornerRunes(ArrayList components, int offset, int y, EnumRuneType rune) { addRune(components, offset, y, offset, rune); addRune(components, offset, y, -offset, rune); addRune(components, -offset, y, -offset, rune); addRune(components, -offset, y, offset, rune); } - public void addParallelRunes(ArrayList components, int offset, int y, EnumRuneType rune) - { + public void addParallelRunes(ArrayList components, int offset, int y, EnumRuneType rune) { addRune(components, offset, y, 0, rune); addRune(components, -offset, y, 0, rune); addRune(components, 0, y, -offset, rune); addRune(components, 0, y, offset, rune); } - public enum BreakType - { - REDSTONE, - BREAK_MRS, - BREAK_STONE, - ACTIVATE, - DEACTIVATE, - EXPLOSION, - } - - public double getWillRespectingConfig(World world, BlockPos pos, EnumDemonWillType type, List willConfig) - { + public double getWillRespectingConfig(World world, BlockPos pos, EnumDemonWillType type, List willConfig) { return willConfig.contains(type) ? WorldDemonWillHandler.getCurrentWill(world, pos, type) : 0; } @@ -446,4 +383,13 @@ public abstract class Ritual result = 31 * result + (unlocalizedName != null ? unlocalizedName.hashCode() : 0); return result; } + + public enum BreakType { + REDSTONE, + BREAK_MRS, + BREAK_STONE, + ACTIVATE, + DEACTIVATE, + EXPLOSION, + } } diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/RitualComponent.java b/src/main/java/WayofTime/bloodmagic/api/ritual/RitualComponent.java index 2bfd071f..97d8893d 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/RitualComponent.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/RitualComponent.java @@ -7,8 +7,7 @@ import net.minecraft.util.math.BlockPos; * Used to set a {@link EnumRuneType} type to a given {@link BlockPos} for usage * in Ritual creation. */ -public class RitualComponent -{ +public class RitualComponent { private final BlockPos offset; private final EnumRuneType runeType; @@ -17,43 +16,37 @@ public class RitualComponent this.runeType = runeType; } - public int getX(EnumFacing direction) - { - switch (direction) - { - case EAST: - return -this.getOffset().getZ(); - case SOUTH: - return -this.getOffset().getX(); - case WEST: - return this.getOffset().getZ(); - default: - return this.getOffset().getX(); + public int getX(EnumFacing direction) { + switch (direction) { + case EAST: + return -this.getOffset().getZ(); + case SOUTH: + return -this.getOffset().getX(); + case WEST: + return this.getOffset().getZ(); + default: + return this.getOffset().getX(); } } - public int getY() - { + public int getY() { return this.getOffset().getY(); } - public int getZ(EnumFacing direction) - { - switch (direction) - { - case EAST: - return this.getOffset().getX(); - case SOUTH: - return -this.getOffset().getZ(); - case WEST: - return -this.getOffset().getX(); - default: - return this.getOffset().getZ(); + public int getZ(EnumFacing direction) { + switch (direction) { + case EAST: + return this.getOffset().getX(); + case SOUTH: + return -this.getOffset().getZ(); + case WEST: + return -this.getOffset().getX(); + default: + return this.getOffset().getZ(); } } - public BlockPos getOffset(EnumFacing direction) - { + public BlockPos getOffset(EnumFacing direction) { return new BlockPos(getX(direction), offset.getY(), getZ(direction)); } diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/RitualRenderer.java b/src/main/java/WayofTime/bloodmagic/api/ritual/RitualRenderer.java index 5c50dc52..57251f8d 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/RitualRenderer.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/RitualRenderer.java @@ -3,12 +3,10 @@ package WayofTime.bloodmagic.api.ritual; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; -public abstract class RitualRenderer -{ +public abstract class RitualRenderer { public abstract void renderAt(IMasterRitualStone masterRitualStone, double x, double y, double z); - protected void bindTexture(ResourceLocation resourceLocation) - { + protected void bindTexture(ResourceLocation resourceLocation) { Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/IImperfectRitualStone.java b/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/IImperfectRitualStone.java index fbdcd02a..6c8620db 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/IImperfectRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/IImperfectRitualStone.java @@ -6,11 +6,10 @@ import net.minecraft.world.World; /** * This interface is for internal implementation only. - * + *

* It is provided via the API for easy obtaining of basic data. */ -public interface IImperfectRitualStone -{ +public interface IImperfectRitualStone { boolean performRitual(World world, BlockPos pos, ImperfectRitual imperfectRitual, EntityPlayer player); diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/ImperfectRitual.java b/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/ImperfectRitual.java index 28b92f67..d19ef961 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/ImperfectRitual.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/ImperfectRitual.java @@ -9,8 +9,7 @@ import net.minecraft.world.World; * registered with * {@link WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry#registerRitual(ImperfectRitual)} */ -public abstract class ImperfectRitual -{ +public abstract class ImperfectRitual { private final String name; private final BlockStack requiredBlock; @@ -27,26 +26,20 @@ public abstract class ImperfectRitual } /** - * @param name - * - The name of the ritual - * @param requiredBlock - * - The block required above the ImperfectRitualStone - * @param activationCost - * - Base LP cost for activating the ritual + * @param name - The name of the ritual + * @param requiredBlock - The block required above the ImperfectRitualStone + * @param activationCost - Base LP cost for activating the ritual */ - public ImperfectRitual(String name, BlockStack requiredBlock, int activationCost, String unlocalizedName) - { + public ImperfectRitual(String name, BlockStack requiredBlock, int activationCost, String unlocalizedName) { this(name, requiredBlock, activationCost, false, unlocalizedName); } /** * Called when the player activates the ritual * {@link WayofTime.bloodmagic.tile.TileImperfectRitualStone#performRitual(World, net.minecraft.util.math.BlockPos, ImperfectRitual, EntityPlayer)} - * - * @param imperfectRitualStone - * - The {@link IImperfectRitualStone} that the ritual is bound to - * @param player - * - The player activating the ritual + * + * @param imperfectRitualStone - The {@link IImperfectRitualStone} that the ritual is bound to + * @param player - The player activating the ritual * @return - Whether activation was successful */ public abstract boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player); @@ -72,8 +65,7 @@ public abstract class ImperfectRitual } @Override - public String toString() - { + public String toString() { return getName() + ":" + getRequiredBlock().toString() + "@" + getActivationCost(); } diff --git a/src/main/java/WayofTime/bloodmagic/api/saving/BMWorldSavedData.java b/src/main/java/WayofTime/bloodmagic/api/saving/BMWorldSavedData.java index eae38187..16470fa5 100644 --- a/src/main/java/WayofTime/bloodmagic/api/saving/BMWorldSavedData.java +++ b/src/main/java/WayofTime/bloodmagic/api/saving/BMWorldSavedData.java @@ -6,43 +6,38 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.storage.WorldSavedData; -import java.util.*; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; -public class BMWorldSavedData extends WorldSavedData -{ +public class BMWorldSavedData extends WorldSavedData { public static final String ID = "BloodMagic-SoulNetworks"; private Map soulNetworks = new HashMap(); - public BMWorldSavedData(String id) - { + public BMWorldSavedData(String id) { super(id); } - public BMWorldSavedData() - { + public BMWorldSavedData() { this(ID); } - public SoulNetwork getNetwork(EntityPlayer player) - { + public SoulNetwork getNetwork(EntityPlayer player) { return getNetwork(PlayerHelper.getUUIDFromPlayer(player)); } - public SoulNetwork getNetwork(UUID playerId) - { + public SoulNetwork getNetwork(UUID playerId) { if (!soulNetworks.containsKey(playerId)) soulNetworks.put(playerId, SoulNetwork.newEmpty(playerId).setParent(this)); return soulNetworks.get(playerId); } @Override - public void readFromNBT(NBTTagCompound tagCompound) - { + public void readFromNBT(NBTTagCompound tagCompound) { NBTTagList networkData = tagCompound.getTagList("networkData", 10); - for (int i = 0; i < networkData.tagCount(); i++) - { + for (int i = 0; i < networkData.tagCount(); i++) { NBTTagCompound data = networkData.getCompoundTagAt(i); SoulNetwork network = SoulNetwork.fromNBT(data); network.setParent(this); @@ -51,8 +46,7 @@ public class BMWorldSavedData extends WorldSavedData } @Override - public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) - { + public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { NBTTagList networkData = new NBTTagList(); for (SoulNetwork soulNetwork : soulNetworks.values()) networkData.appendTag(soulNetwork.serializeNBT()); diff --git a/src/main/java/WayofTime/bloodmagic/api/saving/SoulNetwork.java b/src/main/java/WayofTime/bloodmagic/api/saving/SoulNetwork.java index 57048184..4fdb465b 100644 --- a/src/main/java/WayofTime/bloodmagic/api/saving/SoulNetwork.java +++ b/src/main/java/WayofTime/bloodmagic/api/saving/SoulNetwork.java @@ -17,21 +17,18 @@ import net.minecraftforge.fml.common.eventhandler.Event; import javax.annotation.Nullable; import java.util.UUID; -public class SoulNetwork implements INBTSerializable -{ +public class SoulNetwork implements INBTSerializable { private BMWorldSavedData parent; private EntityPlayer cachedPlayer; private UUID playerId; private int currentEssence; private int orbTier; - private SoulNetwork() - { + private SoulNetwork() { // No-op - For creation via NBT only } - public int add(int toAdd, int maximum) - { + public int add(int toAdd, int maximum) { AddToNetworkEvent event = new AddToNetworkEvent(playerId.toString(), toAdd, maximum); if (MinecraftForge.EVENT_BUS.post(event)) @@ -56,15 +53,12 @@ public class SoulNetwork implements INBTSerializable * @deprecated - Please use {@link #add(int, int)} */ @Deprecated - public int addLifeEssence(int toAdd, int maximum) - { + public int addLifeEssence(int toAdd, int maximum) { return add(toAdd, maximum); } - public int syphon(int syphon) - { - if (getCurrentEssence() >= syphon) - { + public int syphon(int syphon) { + if (getCurrentEssence() >= syphon) { setCurrentEssence(getCurrentEssence() - syphon); return syphon; } @@ -72,15 +66,12 @@ public class SoulNetwork implements INBTSerializable return 0; } - public boolean syphonAndDamage(EntityPlayer user, int toSyphon) - { - if (user != null) - { + public boolean syphonAndDamage(EntityPlayer user, int toSyphon) { + if (user != null) { if (user.getEntityWorld().isRemote) return false; - if (!Strings.isNullOrEmpty(playerId.toString())) - { + if (!Strings.isNullOrEmpty(playerId.toString())) { SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(user, playerId.toString(), null, toSyphon); if (MinecraftForge.EVENT_BUS.post(event)) @@ -103,8 +94,7 @@ public class SoulNetwork implements INBTSerializable return false; } - public void causeNausea() - { + public void causeNausea() { if (getPlayer() != null) getPlayer().addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 99)); } @@ -113,29 +103,21 @@ public class SoulNetwork implements INBTSerializable * @deprecated - Please use {@link #causeNausea()} */ @Deprecated - public void causeNauseaToPlayer() - { + public void causeNauseaToPlayer() { causeNausea(); } - public void hurtPlayer(EntityPlayer user, float syphon) - { - if (user != null) - { - if (syphon < 100 && syphon > 0) - { - if (!user.capabilities.isCreativeMode) - { + public void hurtPlayer(EntityPlayer user, float syphon) { + if (user != null) { + if (syphon < 100 && syphon > 0) { + if (!user.capabilities.isCreativeMode) { user.hurtResistantTime = 0; user.attackEntityFrom(BloodMagicAPI.damageSource, 1.0F); } - } else if (syphon >= 100) - { - if (!user.capabilities.isCreativeMode) - { - for (int i = 0; i < ((syphon + 99) / 100); i++) - { + } else if (syphon >= 100) { + if (!user.capabilities.isCreativeMode) { + for (int i = 0; i < ((syphon + 99) / 100); i++) { user.hurtResistantTime = 0; user.attackEntityFrom(BloodMagicAPI.damageSource, 1.0F); } @@ -144,8 +126,7 @@ public class SoulNetwork implements INBTSerializable } } - private void markDirty() - { + private void markDirty() { if (getParent() != null) getParent().markDirty(); else @@ -153,39 +134,23 @@ public class SoulNetwork implements INBTSerializable } @Nullable - public EntityPlayer getPlayer() - { + public EntityPlayer getPlayer() { if (cachedPlayer == null) cachedPlayer = PlayerHelper.getPlayerFromUUID(playerId); return cachedPlayer; } - public SoulNetwork setCurrentEssence(int currentEssence) - { - this.currentEssence = currentEssence; - markDirty(); - return this; + public BMWorldSavedData getParent() { + return parent; } - public SoulNetwork setOrbTier(int orbTier) - { - this.orbTier = orbTier; - markDirty(); - return this; - } - - public SoulNetwork setParent(BMWorldSavedData parent) - { + public SoulNetwork setParent(BMWorldSavedData parent) { this.parent = parent; markDirty(); return this; } - public BMWorldSavedData getParent() { - return parent; - } - public EntityPlayer getCachedPlayer() { return cachedPlayer; } @@ -198,15 +163,26 @@ public class SoulNetwork implements INBTSerializable return currentEssence; } + public SoulNetwork setCurrentEssence(int currentEssence) { + this.currentEssence = currentEssence; + markDirty(); + return this; + } + public int getOrbTier() { return orbTier; } + public SoulNetwork setOrbTier(int orbTier) { + this.orbTier = orbTier; + markDirty(); + return this; + } + // INBTSerializable @Override - public NBTTagCompound serializeNBT() - { + public NBTTagCompound serializeNBT() { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setString("playerId", getPlayerId().toString()); tagCompound.setInteger("currentEssence", getCurrentEssence()); @@ -215,22 +191,19 @@ public class SoulNetwork implements INBTSerializable } @Override - public void deserializeNBT(NBTTagCompound nbt) - { + public void deserializeNBT(NBTTagCompound nbt) { this.playerId = UUID.fromString(nbt.getString("playerId")); this.currentEssence = nbt.getInteger("currentEssence"); this.orbTier = nbt.getInteger("orbTier"); } - public static SoulNetwork fromNBT(NBTTagCompound tagCompound) - { + public static SoulNetwork fromNBT(NBTTagCompound tagCompound) { SoulNetwork soulNetwork = new SoulNetwork(); soulNetwork.deserializeNBT(tagCompound); return soulNetwork; } - public static SoulNetwork newEmpty(UUID uuid) - { + public static SoulNetwork newEmpty(UUID uuid) { SoulNetwork network = new SoulNetwork(); network.playerId = uuid; return network; diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/DemonWillHolder.java b/src/main/java/WayofTime/bloodmagic/api/soul/DemonWillHolder.java index 792381d6..8ec0283e 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/DemonWillHolder.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/DemonWillHolder.java @@ -5,15 +5,12 @@ import net.minecraft.nbt.NBTTagCompound; import java.util.HashMap; import java.util.Map.Entry; -public class DemonWillHolder -{ +public class DemonWillHolder { public HashMap willMap = new HashMap(); - public double addWill(EnumDemonWillType type, double amount, double max) - { + public double addWill(EnumDemonWillType type, double amount, double max) { double current = 0; - if (willMap.containsKey(type)) - { + if (willMap.containsKey(type)) { current = willMap.get(type); } @@ -23,29 +20,22 @@ public class DemonWillHolder return added; } - public void addWill(EnumDemonWillType type, double amount) - { - if (willMap.containsKey(type)) - { + public void addWill(EnumDemonWillType type, double amount) { + if (willMap.containsKey(type)) { willMap.put(type, amount + willMap.get(type)); - } else - { + } else { willMap.put(type, amount); } } - public double drainWill(EnumDemonWillType type, double amount) - { - if (willMap.containsKey(type)) - { + public double drainWill(EnumDemonWillType type, double amount) { + if (willMap.containsKey(type)) { double current = willMap.get(type); double reduced = Math.min(current, amount); - if (reduced >= current) - { + if (reduced >= current) { willMap.remove(type); - } else - { + } else { willMap.put(type, current - reduced); } @@ -55,45 +45,37 @@ public class DemonWillHolder return 0; } - public double getWill(EnumDemonWillType type) - { - if (willMap.containsKey(type)) - { + public double getWill(EnumDemonWillType type) { + if (willMap.containsKey(type)) { return willMap.get(type); } return 0; } - public void readFromNBT(NBTTagCompound tag, String key) - { + public void readFromNBT(NBTTagCompound tag, String key) { NBTTagCompound willTag = tag.getCompoundTag(key); willMap.clear(); - for (EnumDemonWillType type : EnumDemonWillType.values()) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { double amount = willTag.getDouble("EnumWill" + type.getName()); - if (amount > 0) - { + if (amount > 0) { willMap.put(type, amount); } } } - public void writeToNBT(NBTTagCompound tag, String key) - { + public void writeToNBT(NBTTagCompound tag, String key) { NBTTagCompound willTag = new NBTTagCompound(); - for (Entry entry : willMap.entrySet()) - { + for (Entry entry : willMap.entrySet()) { willTag.setDouble("EnumWill" + entry.getKey().getName(), entry.getValue()); } tag.setTag(key, willTag); } - public void clearWill() - { + public void clearWill() { willMap.clear(); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/EnumDemonWillType.java b/src/main/java/WayofTime/bloodmagic/api/soul/EnumDemonWillType.java index df58f660..445697f7 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/EnumDemonWillType.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/EnumDemonWillType.java @@ -1,11 +1,10 @@ package WayofTime.bloodmagic.api.soul; -import java.util.Locale; - import net.minecraft.util.IStringSerializable; -public enum EnumDemonWillType implements IStringSerializable -{ +import java.util.Locale; + +public enum EnumDemonWillType implements IStringSerializable { DEFAULT("default"), CORROSIVE("corrosive"), DESTRUCTIVE("destructive"), @@ -14,20 +13,17 @@ public enum EnumDemonWillType implements IStringSerializable public final String name; - EnumDemonWillType(String name) - { + EnumDemonWillType(String name) { this.name = name; } @Override - public String toString() - { + public String toString() { return name().toLowerCase(Locale.ENGLISH); } @Override - public String getName() - { + public String getName() { return this.toString(); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWill.java b/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWill.java index ea1a3717..7ef8c777 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWill.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWill.java @@ -2,14 +2,11 @@ package WayofTime.bloodmagic.api.soul; import net.minecraft.item.ItemStack; -public interface IDemonWill -{ +public interface IDemonWill { /** * Obtains the amount of Will an ItemStack contains. - * - * @param willStack - * - The stack to retrieve the Will from - * + * + * @param willStack - The stack to retrieve the Will from * @return - The amount of Will an ItemStack contains */ double getWill(EnumDemonWillType type, ItemStack willStack); @@ -19,11 +16,9 @@ public interface IDemonWill /** * Sets the amount of Will in a given ItemStack. - * - * @param willStack - * - The ItemStack of the Will - * @param will - * - The amount of will to set the stack to + * + * @param willStack - The ItemStack of the Will + * @param will - The amount of will to set the stack to */ void setWill(EnumDemonWillType type, ItemStack willStack, double will); @@ -33,12 +28,9 @@ public interface IDemonWill /** * Drains the demonic will from the willStack. If all of the will is * drained, the willStack will be removed. - * - * @param willStack - * - The ItemStack of the will - * @param drainAmount - * - The amount of Will to drain - * + * + * @param willStack - The ItemStack of the will + * @param drainAmount - The amount of Will to drain * @return The amount of will drained. */ double drainWill(EnumDemonWillType type, ItemStack willStack, double drainAmount); @@ -49,12 +41,9 @@ public interface IDemonWill /** * Creates a new ItemStack with the specified number of will. Implementation * should respect the number requested. - * - * @param meta - * - The meta of the ItemStack to create - * @param number - * - The amount of Will to create the Stack with. - * + * + * @param meta - The meta of the ItemStack to create + * @param number - The amount of Will to create the Stack with. * @return - An ItemStack with the set amount of Will */ ItemStack createWill(int meta, double number); diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillConduit.java b/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillConduit.java index 3527af42..bfa3a253 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillConduit.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillConduit.java @@ -2,10 +2,8 @@ package WayofTime.bloodmagic.api.soul; /** * Implement this interface on a block that can accept and store Demonic Will. - * */ -public interface IDemonWillConduit -{ +public interface IDemonWillConduit { int getWeight(); double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill); diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillGem.java b/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillGem.java index cebfe039..26c90de5 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillGem.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillGem.java @@ -2,23 +2,18 @@ package WayofTime.bloodmagic.api.soul; import net.minecraft.item.ItemStack; -public interface IDemonWillGem -{ +public interface IDemonWillGem { /** - * - * @param willGemStack - * - The ItemStack for this demon will gem. - * @param willStack - * - The ItemStack for the will. Item should extend IDemonWill + * @param willGemStack - The ItemStack for this demon will gem. + * @param willStack - The ItemStack for the will. Item should extend IDemonWill * @return - The remainder willStack after the will has been absorbed into - * the gem. Return null if there is no will left in the stack. + * the gem. Return null if there is no will left in the stack. */ ItemStack fillDemonWillGem(ItemStack willGemStack, ItemStack willStack); /** * Returns the number of souls that are left in the soul gem. Returns a * double because souls can be fractionally drained. - * */ double getWill(EnumDemonWillType type, ItemStack willGemStack); diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillWeapon.java b/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillWeapon.java index 1b3699b0..a24d804f 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillWeapon.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWillWeapon.java @@ -5,7 +5,6 @@ import net.minecraft.item.ItemStack; import java.util.List; -public interface IDemonWillWeapon -{ +public interface IDemonWillWeapon { List getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting); } diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/IDiscreteDemonWill.java b/src/main/java/WayofTime/bloodmagic/api/soul/IDiscreteDemonWill.java index 7712cea6..d9ae26d6 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/IDiscreteDemonWill.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/IDiscreteDemonWill.java @@ -2,14 +2,11 @@ package WayofTime.bloodmagic.api.soul; import net.minecraft.item.ItemStack; -public interface IDiscreteDemonWill -{ +public interface IDiscreteDemonWill { /** * Obtains the amount of Will an ItemStack contains. - * - * @param soulStack - * - The stack to retrieve the Will from - * + * + * @param soulStack - The stack to retrieve the Will from * @return - The amount of Will an ItemStack contains */ double getWill(ItemStack soulStack); @@ -18,32 +15,25 @@ public interface IDiscreteDemonWill * Drains the demonic will from the willStack. If all of the will is * drained, the willStack will be removed. Will only drain in discrete * amounts, determined by getDiscretization. - * - * @param willStack - * - The ItemStack of the will - * @param drainAmount - * - The amount of Will to drain - * + * + * @param willStack - The ItemStack of the will + * @param drainAmount - The amount of Will to drain * @return The amount of will drained. */ double drainWill(ItemStack willStack, double drainAmount); /** * Gets the discrete number for this demonic will. - * - * @param willStack - * - The ItemStack of the will - * + * + * @param willStack - The ItemStack of the will * @return - The discrete number for the given stack. */ double getDiscretization(ItemStack willStack); /** * Obtains the type of will this is. - * - * @param willStack - * - The ItemStack of the will - * + * + * @param willStack - The ItemStack of the will * @return - The type of will this is. */ EnumDemonWillType getType(ItemStack willStack); diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java b/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java index 34c2cfa9..464245f5 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java @@ -10,30 +10,22 @@ import net.minecraft.util.NonNullList; * Monster Souls and Soul Gems, etc. The Soul Network's helper methods are found * in {@link WayofTime.bloodmagic.api.util.helper.NetworkHelper} */ -public class PlayerDemonWillHandler -{ +public class PlayerDemonWillHandler { /** * Gets the total amount of Will a player contains in their inventory - * - * @param type - * - The type of Will to check for - * @param player - * - The player to check the will of - * + * + * @param type - The type of Will to check for + * @param player - The player to check the will of * @return - The amount of will the player contains */ - public static double getTotalDemonWill(EnumDemonWillType type, EntityPlayer player) - { + public static double getTotalDemonWill(EnumDemonWillType type, EntityPlayer player) { NonNullList inventory = player.inventory.mainInventory; double souls = 0; - for (ItemStack stack : inventory) - { - if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type) - { + for (ItemStack stack : inventory) { + if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type) { souls += ((IDemonWill) stack.getItem()).getWill(type, stack); - } else if (stack.getItem() instanceof IDemonWillGem) - { + } else if (stack.getItem() instanceof IDemonWillGem) { souls += ((IDemonWillGem) stack.getItem()).getWill(type, stack); } } @@ -41,16 +33,13 @@ public class PlayerDemonWillHandler return souls; } - public static EnumDemonWillType getLargestWillType(EntityPlayer player) - { + public static EnumDemonWillType getLargestWillType(EntityPlayer player) { EnumDemonWillType type = EnumDemonWillType.DEFAULT; double max = getTotalDemonWill(type, player); - for (EnumDemonWillType testType : EnumDemonWillType.values()) - { + for (EnumDemonWillType testType : EnumDemonWillType.values()) { double value = getTotalDemonWill(testType, player); - if (value > max) - { + if (value > max) { type = testType; } } @@ -60,23 +49,17 @@ public class PlayerDemonWillHandler /** * Checks if the player's Tartaric gems are completely full. - * - * @param type - * - The type of Will to check for - * @param player - * - The player to check the Will of - * + * + * @param type - The type of Will to check for + * @param player - The player to check the Will of * @return - True if all Will containers are full, false if not. */ - public static boolean isDemonWillFull(EnumDemonWillType type, EntityPlayer player) - { + public static boolean isDemonWillFull(EnumDemonWillType type, EntityPlayer player) { NonNullList inventory = player.inventory.mainInventory; boolean hasGem = false; - for (ItemStack stack : inventory) - { - if (stack.getItem() instanceof IDemonWillGem) - { + for (ItemStack stack : inventory) { + if (stack.getItem() instanceof IDemonWillGem) { hasGem = true; if (((IDemonWillGem) stack.getItem()).getWill(type, stack) < ((IDemonWillGem) stack.getItem()).getMaxWill(type, stack)) return false; @@ -88,33 +71,26 @@ public class PlayerDemonWillHandler /** * Consumes Will from the inventory of a given player - * - * @param player - * - The player to consume the will of - * @param amount - * - The amount of will to consume - * + * + * @param player - The player to consume the will of + * @param amount - The amount of will to consume * @return - The amount of will consumed. */ - public static double consumeDemonWill(EnumDemonWillType type, EntityPlayer player, double amount) - { + public static double consumeDemonWill(EnumDemonWillType type, EntityPlayer player, double amount) { double consumed = 0; NonNullList inventory = player.inventory.mainInventory; - for (int i = 0; i < inventory.size(); i++) - { + for (int i = 0; i < inventory.size(); i++) { if (consumed >= amount) return consumed; ItemStack stack = inventory.get(i); - if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type) - { + if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type) { consumed += ((IDemonWill) stack.getItem()).drainWill(type, stack, amount - consumed); if (((IDemonWill) stack.getItem()).getWill(type, stack) <= 0) inventory.set(i, ItemStack.EMPTY); - } else if (stack.getItem() instanceof IDemonWillGem) - { + } else if (stack.getItem() instanceof IDemonWillGem) { consumed += ((IDemonWillGem) stack.getItem()).drainWill(type, stack, amount - consumed, true); } } @@ -125,25 +101,19 @@ public class PlayerDemonWillHandler /** * Adds an IDemonWill contained in an ItemStack to one of the Soul Gems in * the player's inventory. - * - * @param player - * - The player to add will to - * @param willStack - * - ItemStack that contains an IDemonWill to be added - * + * + * @param player - The player to add will to + * @param willStack - ItemStack that contains an IDemonWill to be added * @return - The modified willStack */ - public static ItemStack addDemonWill(EntityPlayer player, ItemStack willStack) - { + public static ItemStack addDemonWill(EntityPlayer player, ItemStack willStack) { if (willStack.isEmpty()) return ItemStack.EMPTY; NonNullList inventory = player.inventory.mainInventory; - for (ItemStack stack : inventory) - { - if (stack.getItem() instanceof IDemonWillGem) - { + for (ItemStack stack : inventory) { + if (stack.getItem() instanceof IDemonWillGem) { ItemStack newStack = ((IDemonWillGem) stack.getItem()).fillDemonWillGem(stack, willStack); if (newStack.isEmpty()) return ItemStack.EMPTY; @@ -156,25 +126,18 @@ public class PlayerDemonWillHandler /** * Adds an IDiscreteDemonWill contained in an ItemStack to one of the Soul * Gems in the player's inventory. - * - * @param type - * - The type of Will to add - * @param player - * - The player to check the Will of - * @param amount - * - The amount of will to add - * + * + * @param type - The type of Will to add + * @param player - The player to check the Will of + * @param amount - The amount of will to add * @return - The amount of will added */ - public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount) - { + public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount) { NonNullList inventory = player.inventory.mainInventory; double remaining = amount; - for (ItemStack stack : inventory) - { - if (stack.getItem() instanceof IDemonWillGem) - { + for (ItemStack stack : inventory) { + if (stack.getItem() instanceof IDemonWillGem) { remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true); if (remaining <= 0) break; @@ -187,27 +150,19 @@ public class PlayerDemonWillHandler /** * Adds an IDiscreteDemonWill contained in an ItemStack to one of the Soul * Gems in the player's inventory while ignoring a specified stack. - * - * @param type - * - The type of Will to add - * @param player - * - The player to check the Will of - * @param amount - * - The amount of will to add - * @param ignored - * - A stack to ignore - * + * + * @param type - The type of Will to add + * @param player - The player to check the Will of + * @param amount - The amount of will to add + * @param ignored - A stack to ignore * @return - The amount of will added */ - public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount, ItemStack ignored) - { + public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount, ItemStack ignored) { NonNullList inventory = player.inventory.mainInventory; double remaining = amount; - for (ItemStack stack : inventory) - { - if (!stack.equals(ignored) && stack.getItem() instanceof IDemonWillGem) - { + for (ItemStack stack : inventory) { + if (!stack.equals(ignored) && stack.getItem() instanceof IDemonWillGem) { remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true); if (remaining <= 0) diff --git a/src/main/java/WayofTime/bloodmagic/api/teleport/ITeleport.java b/src/main/java/WayofTime/bloodmagic/api/teleport/ITeleport.java index f9e48986..567b9052 100644 --- a/src/main/java/WayofTime/bloodmagic/api/teleport/ITeleport.java +++ b/src/main/java/WayofTime/bloodmagic/api/teleport/ITeleport.java @@ -1,7 +1,6 @@ package WayofTime.bloodmagic.api.teleport; -public interface ITeleport -{ +public interface ITeleport { void teleport(); int getTeleportCost(); diff --git a/src/main/java/WayofTime/bloodmagic/api/teleport/PortalLocation.java b/src/main/java/WayofTime/bloodmagic/api/teleport/PortalLocation.java index d4c2e9ce..094c195d 100644 --- a/src/main/java/WayofTime/bloodmagic/api/teleport/PortalLocation.java +++ b/src/main/java/WayofTime/bloodmagic/api/teleport/PortalLocation.java @@ -6,38 +6,24 @@ import net.minecraft.util.math.BlockPos; import java.io.Serializable; -public class PortalLocation implements Serializable -{ +public class PortalLocation implements Serializable { private int x; private int y; private int z; private int dimension; - public PortalLocation(int x, int y, int z, int dimension) - { + public PortalLocation(int x, int y, int z, int dimension) { this.x = x; this.y = y; this.z = z; this.dimension = dimension; } - public PortalLocation(BlockPos blockPos, int dimension) - { + public PortalLocation(BlockPos blockPos, int dimension) { this(blockPos.getX(), blockPos.getY(), blockPos.getZ(), dimension); } - public static PortalLocation readFromNBT(NBTTagCompound tag) - { - if (tag.hasKey(Constants.NBT.PORTAL_LOCATION)) - { - NBTTagCompound locationTag = tag.getCompoundTag(Constants.NBT.PORTAL_LOCATION); - return new PortalLocation(locationTag.getInteger(Constants.NBT.X_COORD), locationTag.getInteger(Constants.NBT.Y_COORD), locationTag.getInteger(Constants.NBT.Z_COORD), locationTag.getInteger(Constants.NBT.DIMENSION_ID)); - } - return null; - } - - public NBTTagCompound writeToNBT(NBTTagCompound tag) - { + public NBTTagCompound writeToNBT(NBTTagCompound tag) { NBTTagCompound locationTag = new NBTTagCompound(); locationTag.setInteger(Constants.NBT.X_COORD, x); @@ -49,14 +35,12 @@ public class PortalLocation implements Serializable return tag; } - public BlockPos getBlockPos() - { + public BlockPos getBlockPos() { return new BlockPos(x, y, z); } @Override - public boolean equals(Object o) - { + public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) @@ -73,8 +57,7 @@ public class PortalLocation implements Serializable } @Override - public int hashCode() - { + public int hashCode() { int result = x; result = 31 * result + y; result = 31 * result + z; @@ -96,4 +79,12 @@ public class PortalLocation implements Serializable public int getDimension() { return dimension; } + + public static PortalLocation readFromNBT(NBTTagCompound tag) { + if (tag.hasKey(Constants.NBT.PORTAL_LOCATION)) { + NBTTagCompound locationTag = tag.getCompoundTag(Constants.NBT.PORTAL_LOCATION); + return new PortalLocation(locationTag.getInteger(Constants.NBT.X_COORD), locationTag.getInteger(Constants.NBT.Y_COORD), locationTag.getInteger(Constants.NBT.Z_COORD), locationTag.getInteger(Constants.NBT.DIMENSION_ID)); + } + return null; + } } diff --git a/src/main/java/WayofTime/bloodmagic/api/teleport/Teleport.java b/src/main/java/WayofTime/bloodmagic/api/teleport/Teleport.java index d2535574..72f64bf3 100644 --- a/src/main/java/WayofTime/bloodmagic/api/teleport/Teleport.java +++ b/src/main/java/WayofTime/bloodmagic/api/teleport/Teleport.java @@ -3,16 +3,14 @@ package WayofTime.bloodmagic.api.teleport; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; -public abstract class Teleport implements ITeleport -{ +public abstract class Teleport implements ITeleport { protected int x; protected int y; protected int z; protected Entity entity; protected String networkToDrain; - public Teleport(int x, int y, int z, Entity entity, String networkToDrain) - { + public Teleport(int x, int y, int z, Entity entity, String networkToDrain) { this.x = x; this.y = y; this.z = z; @@ -20,8 +18,7 @@ public abstract class Teleport implements ITeleport this.networkToDrain = networkToDrain; } - public Teleport(BlockPos blockPos, Entity entity, String networkToDrain) - { + public Teleport(BlockPos blockPos, Entity entity, String networkToDrain) { this(blockPos.getX(), blockPos.getY(), blockPos.getZ(), entity, networkToDrain); } diff --git a/src/main/java/WayofTime/bloodmagic/api/teleport/TeleportQueue.java b/src/main/java/WayofTime/bloodmagic/api/teleport/TeleportQueue.java index d4a374cd..941afa9d 100644 --- a/src/main/java/WayofTime/bloodmagic/api/teleport/TeleportQueue.java +++ b/src/main/java/WayofTime/bloodmagic/api/teleport/TeleportQueue.java @@ -6,39 +6,32 @@ import net.minecraftforge.fml.common.gameevent.TickEvent; import java.util.ArrayList; import java.util.List; -public class TeleportQueue -{ +public class TeleportQueue { private static TeleportQueue INSTANCE = new TeleportQueue(); private static List queue; - public static TeleportQueue getInstance() - { - return INSTANCE; - } - - private TeleportQueue() - { + private TeleportQueue() { queue = new ArrayList(); } - public void addITeleport(ITeleport iTeleport) - { + public void addITeleport(ITeleport iTeleport) { queue.add(iTeleport); } @SubscribeEvent - public void serverTick(TickEvent.ServerTickEvent event) - { - if (event.phase != TickEvent.Phase.END) - { + public void serverTick(TickEvent.ServerTickEvent event) { + if (event.phase != TickEvent.Phase.END) { return; } - for (ITeleport iTeleport : queue) - { + for (ITeleport iTeleport : queue) { iTeleport.teleport(); } queue.clear(); } + + public static TeleportQueue getInstance() { + return INSTANCE; + } } diff --git a/src/main/java/WayofTime/bloodmagic/api/teleport/TeleporterBloodMagic.java b/src/main/java/WayofTime/bloodmagic/api/teleport/TeleporterBloodMagic.java index e24c0da2..148eab4a 100644 --- a/src/main/java/WayofTime/bloodmagic/api/teleport/TeleporterBloodMagic.java +++ b/src/main/java/WayofTime/bloodmagic/api/teleport/TeleporterBloodMagic.java @@ -5,34 +5,28 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.Teleporter; import net.minecraft.world.WorldServer; -public class TeleporterBloodMagic extends Teleporter -{ - public TeleporterBloodMagic(WorldServer worldServer) - { +public class TeleporterBloodMagic extends Teleporter { + public TeleporterBloodMagic(WorldServer worldServer) { super(worldServer); } @Override - public boolean makePortal(Entity entity) - { + public boolean makePortal(Entity entity) { return true; } @Override - public void removeStalePortalLocations(long worldTime) - { + public void removeStalePortalLocations(long worldTime) { ; } @Override - public boolean placeInExistingPortal(Entity entityIn, float rotationYaw) - { + public boolean placeInExistingPortal(Entity entityIn, float rotationYaw) { return true; } @Override - public void placeInPortal(Entity entity, float rotationYaw) - { + public void placeInPortal(Entity entity, float rotationYaw) { 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/api/util/helper/BindableHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/BindableHelper.java index 7ebf7eaa..e21b2d92 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/BindableHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/BindableHelper.java @@ -11,19 +11,15 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import java.util.UUID; -public class BindableHelper -{ +public class BindableHelper { /** * Sets the Owner Name of the item without checking if it is already bound. * Also bypasses {@link ItemBindEvent}. - * - * @param stack - * - The ItemStack to bind - * @param ownerName - * - The username to bind the ItemStack to + * + * @param stack - The ItemStack to bind + * @param ownerName - The username to bind the ItemStack to */ - public static void setItemOwnerName(ItemStack stack, String ownerName) - { + public static void setItemOwnerName(ItemStack stack, String ownerName) { stack = NBTHelper.checkNBT(stack); stack.getTagCompound().setString(Constants.NBT.OWNER_NAME, ownerName); @@ -32,14 +28,11 @@ public class BindableHelper /** * Sets the Owner UUID of the item without checking if it is already bound. * Also bypasses {@link ItemBindEvent}. - * - * @param stack - * - The ItemStack to bind - * @param ownerUUID - * - The UUID to bind the ItemStack to + * + * @param stack - The ItemStack to bind + * @param ownerUUID - The UUID to bind the ItemStack to */ - public static void setItemOwnerUUID(ItemStack stack, String ownerUUID) - { + public static void setItemOwnerUUID(ItemStack stack, String ownerUUID) { stack = NBTHelper.checkNBT(stack); stack.getTagCompound().setString(Constants.NBT.OWNER_UUID, ownerUUID); @@ -49,17 +42,14 @@ public class BindableHelper /** * Deprecated. - * + *

* Built into {@link IBindable} now. - * - * @param stack - * - The ItemStack to check the owner of - * + * + * @param stack - The ItemStack to check the owner of * @return - The username of the ItemStack's owner */ @Deprecated - public static String getOwnerName(ItemStack stack) - { + public static String getOwnerName(ItemStack stack) { stack = NBTHelper.checkNBT(stack); return PlayerHelper.getUsernameFromStack(stack); @@ -67,17 +57,14 @@ public class BindableHelper /** * Deprecated. - * + *

* Built into {@link IBindable} now. - * - * @param stack - * - The ItemStack to check the owner of - * + * + * @param stack - The ItemStack to check the owner of * @return - The UUID of the ItemStack's owner */ @Deprecated - public static String getOwnerUUID(ItemStack stack) - { + public static String getOwnerUUID(ItemStack stack) { stack = NBTHelper.checkNBT(stack); return stack.getTagCompound().getString(Constants.NBT.OWNER_UUID); @@ -85,41 +72,32 @@ public class BindableHelper /** * Deprecated. - * + *

* Now handled automatically with * {@link GenericHandler#onInteract(PlayerInteractEvent.RightClickItem)} - * - * @param stack - * - The ItemStack to bind - * @param player - * - The Player to bind the ItemStack to - * + * + * @param stack - The ItemStack to bind + * @param player - The Player to bind the ItemStack to * @return - Whether binding was successful */ @Deprecated - public static boolean checkAndSetItemOwner(ItemStack stack, EntityPlayer player) - { + public static boolean checkAndSetItemOwner(ItemStack stack, EntityPlayer player) { return !PlayerHelper.isFakePlayer(player) && checkAndSetItemOwner(stack, PlayerHelper.getUUIDFromPlayer(player), player.getName()); } /** * Deprecated. - * + *

* Now handled automatically with * {@link GenericHandler#onInteract(PlayerInteractEvent.RightClickItem)} - * - * @param stack - * - The ItemStack to bind - * @param uuid - * - The username to bind the ItemStack to - * @param currentUsername - * - The current name of the player. - * + * + * @param stack - The ItemStack to bind + * @param uuid - The username to bind the ItemStack to + * @param currentUsername - The current name of the player. * @return - Whether the binding was successful */ @Deprecated - public static boolean checkAndSetItemOwner(ItemStack stack, String uuid, String currentUsername) - { + public static boolean checkAndSetItemOwner(ItemStack stack, String uuid, String currentUsername) { stack = NBTHelper.checkNBT(stack); if (!(stack.getItem() instanceof IBindable)) @@ -144,36 +122,28 @@ public class BindableHelper /** * Deprecated. - * + *

* Now handled automatically with * {@link GenericHandler#onInteract(PlayerInteractEvent.RightClickItem)} - * - * @param stack - * - ItemStack to check - * @param uuid - * - UUID of the Player - * @param currentUsername - * - The current name of the player. + * + * @param stack - ItemStack to check + * @param uuid - UUID of the Player + * @param currentUsername - The current name of the player. */ @Deprecated - public static boolean checkAndSetItemOwner(ItemStack stack, UUID uuid, String currentUsername) - { + public static boolean checkAndSetItemOwner(ItemStack stack, UUID uuid, String currentUsername) { return checkAndSetItemOwner(stack, uuid.toString(), currentUsername); } /** * Deprecated. - * + * + * @param stack - The ItemStack to bind + * @param ownerName - The username to bind the ItemStack to * @see #setItemOwnerName(ItemStack, String) - * - * @param stack - * - The ItemStack to bind - * @param ownerName - * - The username to bind the ItemStack to */ @Deprecated - public static void setItemOwner(ItemStack stack, String ownerName) - { + public static void setItemOwner(ItemStack stack, String ownerName) { setItemOwnerName(stack, ownerName); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/IncenseHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/IncenseHelper.java index 4fd64661..8e835696 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/IncenseHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/IncenseHelper.java @@ -4,21 +4,17 @@ import WayofTime.bloodmagic.api.Constants; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; -public class IncenseHelper -{ - public static double getCurrentIncense(EntityPlayer player) - { +public class IncenseHelper { + public static double getCurrentIncense(EntityPlayer player) { NBTTagCompound data = player.getEntityData(); - if (data.hasKey(Constants.NBT.CURRENT_INCENSE)) - { + if (data.hasKey(Constants.NBT.CURRENT_INCENSE)) { return data.getDouble(Constants.NBT.CURRENT_INCENSE); } return 0; } - public static void setCurrentIncense(EntityPlayer player, double amount) - { + public static void setCurrentIncense(EntityPlayer player, double amount) { NBTTagCompound data = player.getEntityData(); data.setDouble(Constants.NBT.CURRENT_INCENSE, amount); } diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/ItemHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/ItemHelper.java index 9657a11f..35a27909 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/ItemHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/ItemHelper.java @@ -11,36 +11,25 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class ItemHelper -{ +public class ItemHelper { // IItemLPContainer - public static class LPContainer - { + public static class LPContainer { /** * Attempts to fill an altar with the contained LP - * - * @param altar - * - The altar in question - * @param itemStack - * - The {@link IItemLPContainer} ItemStack filling the altar - * @param world - * - The world - * @param altarPos - * - The position of the altar - * + * + * @param altar - The altar in question + * @param itemStack - The {@link IItemLPContainer} ItemStack filling the altar + * @param world - The world + * @param altarPos - The position of the altar * @return Whether or not the altar was filled (or at least attempted) */ - public static boolean tryAndFillAltar(IBloodAltar altar, ItemStack itemStack, World world, BlockPos altarPos) - { - if (itemStack.getItem() instanceof IItemLPContainer) - { - if (!altar.isActive()) - { + public static boolean tryAndFillAltar(IBloodAltar altar, ItemStack itemStack, World world, BlockPos altarPos) { + if (itemStack.getItem() instanceof IItemLPContainer) { + if (!altar.isActive()) { IItemLPContainer fillable = (IItemLPContainer) itemStack.getItem(); int amount = fillable.getStoredLP(itemStack); - if (amount > 0) - { + if (amount > 0) { int filledAmount = altar.fillMainTank(amount); amount -= filledAmount; fillable.setStoredLP(itemStack, amount); @@ -55,20 +44,14 @@ public class ItemHelper /** * Adds the given LP into the {@link IItemLPContainer}'s storage - * - * @param stack - * - The item in question - * @param toAdd - * - How much LP should be added to the item - * @param maxCapacity - * - The item's maximum holding capacity - * + * + * @param stack - The item in question + * @param toAdd - How much LP should be added to the item + * @param maxCapacity - The item's maximum holding capacity * @return Whether or not LP was added to the item */ - public static boolean addLPToItem(ItemStack stack, int toAdd, int maxCapacity) - { - if (stack.getItem() instanceof IItemLPContainer) - { + public static boolean addLPToItem(ItemStack stack, int toAdd, int maxCapacity) { + if (stack.getItem() instanceof IItemLPContainer) { IItemLPContainer fillable = (IItemLPContainer) stack.getItem(); stack = NBTHelper.checkNBT(stack); @@ -86,12 +69,9 @@ public class ItemHelper } } - public static class LivingUpgrades - { - public static LivingArmourUpgrade getUpgrade(ItemStack stack) - { - if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) - { + public static class LivingUpgrades { + public static LivingArmourUpgrade getUpgrade(ItemStack stack) { + if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) { String key = getKey(stack); int level = getLevel(stack); @@ -101,19 +81,15 @@ public class ItemHelper return null; } - public static void setUpgrade(ItemStack stack, LivingArmourUpgrade upgrade) - { - if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) - { + public static void setUpgrade(ItemStack stack, LivingArmourUpgrade upgrade) { + if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) { setKey(stack, upgrade.getUniqueIdentifier()); setLevel(stack, upgrade.getUpgradeLevel()); } } - public static void setKey(ItemStack stack, String key) - { - if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) - { + public static void setKey(ItemStack stack, String key) { + if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -121,10 +97,8 @@ public class ItemHelper } } - public static String getKey(ItemStack stack) - { - if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) - { + public static String getKey(ItemStack stack) { + if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -134,10 +108,8 @@ public class ItemHelper return ""; } - public static void setLevel(ItemStack stack, int level) - { - if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) - { + public static void setLevel(ItemStack stack, int level) { + if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -145,10 +117,8 @@ public class ItemHelper } } - public static int getLevel(ItemStack stack) - { - if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) - { + public static int getLevel(ItemStack stack) { + if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/LogHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/LogHelper.java index a7fe7f78..bc10f82e 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/LogHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/LogHelper.java @@ -4,40 +4,33 @@ import WayofTime.bloodmagic.api.BloodMagicAPI; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public class LogHelper -{ +public class LogHelper { private Logger logger; - public LogHelper(String logger) - { + public LogHelper(String logger) { this.logger = LogManager.getLogger(logger); } - public void info(String info, Object... format) - { + public void info(String info, Object... format) { if (BloodMagicAPI.loggingEnabled) logger.info(info, format); } - public void error(String error, Object... format) - { + public void error(String error, Object... format) { if (BloodMagicAPI.loggingEnabled) logger.error(error, format); } - public void debug(String debug, Object... format) - { + public void debug(String debug, Object... format) { if (BloodMagicAPI.loggingEnabled) logger.debug(debug, format); } - public void fatal(String fatal, Object... format) - { + public void fatal(String fatal, Object... format) { logger.error(fatal, format); } - public Logger getLogger() - { + public Logger getLogger() { return logger; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/NBTHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/NBTHelper.java index f189483b..6c1985da 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/NBTHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/NBTHelper.java @@ -3,10 +3,8 @@ package WayofTime.bloodmagic.api.util.helper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class NBTHelper -{ - public static ItemStack checkNBT(ItemStack stack) - { +public class NBTHelper { + public static ItemStack checkNBT(ItemStack stack) { if (stack.getTagCompound() == null) stack.setTagCompound(new NBTTagCompound()); diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/NetworkHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/NetworkHelper.java index 8b1396d6..6e4ae4fe 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/NetworkHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/NetworkHelper.java @@ -17,28 +17,23 @@ import net.minecraftforge.fml.common.eventhandler.Event; import java.util.UUID; -public class NetworkHelper -{ +public class NetworkHelper { // Get /** * Gets the SoulNetwork for the player. - * - * @param uuid - * - The UUID of the SoulNetwork owner - this is UUID.toString(). - * + * + * @param uuid - The UUID of the SoulNetwork owner - this is UUID.toString(). * @return - The SoulNetwork for the given name. */ - public static SoulNetwork getSoulNetwork(String uuid) - { + public static SoulNetwork getSoulNetwork(String uuid) { World world = DimensionManager.getWorld(0); if (world == null || world.getMapStorage() == null) //Hack-ish way to fix the lava crystal. return new BMWorldSavedData().getNetwork(UUID.fromString(uuid)); BMWorldSavedData saveData = (BMWorldSavedData) world.getMapStorage().getOrLoadData(BMWorldSavedData.class, BMWorldSavedData.ID); - if (saveData == null) - { + if (saveData == null) { saveData = new BMWorldSavedData(); world.getMapStorage().setData(BMWorldSavedData.ID, saveData); } @@ -47,42 +42,32 @@ public class NetworkHelper } /** + * @param uuid - The Player's Mojang UUID * @see NetworkHelper#getSoulNetwork(String) - * - * @param uuid - * - The Player's Mojang UUID */ - public static SoulNetwork getSoulNetwork(UUID uuid) - { + public static SoulNetwork getSoulNetwork(UUID uuid) { return getSoulNetwork(uuid.toString()); } /** + * @param player - The Player * @see NetworkHelper#getSoulNetwork(String) - * - * @param player - * - The Player */ - public static SoulNetwork getSoulNetwork(EntityPlayer player) - { + public static SoulNetwork getSoulNetwork(EntityPlayer player) { return getSoulNetwork(PlayerHelper.getUUIDFromPlayer(player)); } /** * Gets the current orb tier of the SoulNetwork. - * - * @param soulNetwork - * - SoulNetwork to get the tier of. - * + * + * @param soulNetwork - SoulNetwork to get the tier of. * @return - The Orb tier of the given SoulNetwork */ - public static int getCurrentMaxOrb(SoulNetwork soulNetwork) - { + public static int getCurrentMaxOrb(SoulNetwork soulNetwork) { return soulNetwork.getOrbTier(); } - public static int getMaximumForTier(int tier) - { + public static int getMaximumForTier(int tier) { int ret = 0; if (tier > OrbRegistry.getTierMap().size() || tier < 0) @@ -102,22 +87,17 @@ public class NetworkHelper /** * Syphons from the player and damages them if there was not enough stored * LP. - * + *

* Handles null-checking the player for you. - * - * @param soulNetwork - * - SoulNetwork to syphon from - * @param user - * - User of the item. - * @param toSyphon - * - Amount of LP to syphon - * + * + * @param soulNetwork - SoulNetwork to syphon from + * @param user - User of the item. + * @param toSyphon - Amount of LP to syphon * @return - Whether the action should be performed. * @deprecated Use {@link #getSoulNetwork(EntityPlayer)} and {@link SoulNetwork#syphonAndDamage(EntityPlayer, int)} */ @Deprecated - public static boolean syphonAndDamage(SoulNetwork soulNetwork, EntityPlayer user, int toSyphon) - { + public static boolean syphonAndDamage(SoulNetwork soulNetwork, EntityPlayer user, int toSyphon) { // if (soulNetwork.getPlayer() == null) // { @@ -130,12 +110,9 @@ public class NetworkHelper /** * Syphons a player from within a container. - * - * @param stack - * - ItemStack in the Container. - * @param toSyphon - * - Amount of LP to syphon - * + * + * @param stack - ItemStack in the Container. + * @param toSyphon - Amount of LP to syphon * @return - If the syphon was successful. */ public static boolean syphonFromContainer(ItemStack stack, int toSyphon) //TODO: Change to a String, int? @@ -155,16 +132,12 @@ public class NetworkHelper /** * Checks if the ItemStack has a user to be syphoned from. - * - * @param stack - * - ItemStack to check - * @param toSyphon - * - Amount of LP to syphon - * + * + * @param stack - ItemStack to check + * @param toSyphon - Amount of LP to syphon * @return - If syphoning is possible */ - public static boolean canSyphonFromContainer(ItemStack stack, int toSyphon) - { + public static boolean canSyphonFromContainer(ItemStack stack, int toSyphon) { stack = NBTHelper.checkNBT(stack); String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_UUID); @@ -180,14 +153,11 @@ public class NetworkHelper /** * Sets the orb tier of the SoulNetwork to the given orb. Will not set if * the given tier is lower than the current tier. - * - * @param soulNetwork - * - SoulNetwork to set the orb tier of - * @param maxOrb - * - Tier of orb to set to + * + * @param soulNetwork - SoulNetwork to set the orb tier of + * @param maxOrb - Tier of orb to set to */ - public static void setMaxOrb(SoulNetwork soulNetwork, int maxOrb) - { + public static void setMaxOrb(SoulNetwork soulNetwork, int maxOrb) { soulNetwork.setOrbTier(Math.max(maxOrb, soulNetwork.getOrbTier())); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerHelper.java index 75b5f6f9..348dc3d8 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerHelper.java @@ -15,55 +15,46 @@ import net.minecraftforge.fml.relauncher.Side; import java.util.ArrayList; import java.util.UUID; -public class PlayerHelper -{ +public class PlayerHelper { /** * A list of all known fake players that do not extend FakePlayer. - * + *

* Will be added to as needed. */ private static final ArrayList knownFakePlayers = Lists.newArrayList(); - public static String getUsernameFromPlayer(EntityPlayer player) - { + public static String getUsernameFromPlayer(EntityPlayer player) { return player.getEntityWorld().isRemote ? "" : UsernameCache.getLastKnownUsername(getUUIDFromPlayer(player)); } - public static EntityPlayer getPlayerFromUsername(String username) - { + public static EntityPlayer getPlayerFromUsername(String username) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) return null; return FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUsername(username); } - public static EntityPlayer getPlayerFromUUID(String uuid) - { + public static EntityPlayer getPlayerFromUUID(String uuid) { return getPlayerFromUsername(getUsernameFromUUID(uuid)); } - public static EntityPlayer getPlayerFromUUID(UUID uuid) - { + public static EntityPlayer getPlayerFromUUID(UUID uuid) { return getPlayerFromUsername(getUsernameFromUUID(uuid)); } - public static UUID getUUIDFromPlayer(EntityPlayer player) - { + public static UUID getUUIDFromPlayer(EntityPlayer player) { return player.getGameProfile().getId(); } - public static String getUsernameFromUUID(String uuid) - { + public static String getUsernameFromUUID(String uuid) { return UsernameCache.getLastKnownUsername(UUID.fromString(uuid)); } - public static String getUsernameFromUUID(UUID uuid) - { + public static String getUsernameFromUUID(UUID uuid) { return UsernameCache.getLastKnownUsername(uuid); } - public static String getUsernameFromStack(ItemStack stack) - { + public static String getUsernameFromStack(ItemStack stack) { stack = NBTHelper.checkNBT(stack); return stack.getTagCompound().getString(Constants.NBT.OWNER_NAME); @@ -71,19 +62,15 @@ public class PlayerHelper /** * Checks whether or not the given player is an "actual" player - * - * @param player - * - The player in question - * + * + * @param player - The player in question * @return If the player is fake or not */ - public static boolean isFakePlayer(EntityPlayer player) - { + public static boolean isFakePlayer(EntityPlayer player) { return player instanceof FakePlayer || (player != null && knownFakePlayers.contains(player.getClass().getCanonicalName())); } - public static void causeNauseaToPlayer(ItemStack stack) - { + public static void causeNauseaToPlayer(ItemStack stack) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) return; @@ -93,8 +80,7 @@ public class PlayerHelper causeNauseaToPlayer(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)); } - public static void causeNauseaToPlayer(String ownerName) - { + public static void causeNauseaToPlayer(String ownerName) { EntityPlayer player = getPlayerFromUsername(ownerName); if (player == null) diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerSacrificeHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerSacrificeHelper.java index aa0702b7..4691fadc 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerSacrificeHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerSacrificeHelper.java @@ -13,27 +13,22 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -public class PlayerSacrificeHelper -{ +public class PlayerSacrificeHelper { public static float scalingOfSacrifice = 1f; public static int soulFrayDuration = 400; public static Potion soulFrayId; - public static double getPlayerIncense(EntityPlayer player) - { + public static double getPlayerIncense(EntityPlayer player) { return IncenseHelper.getCurrentIncense(player); } - public static void setPlayerIncense(EntityPlayer player, double amount) - { + public static void setPlayerIncense(EntityPlayer player, double amount) { IncenseHelper.setCurrentIncense(player, amount); } - public static boolean incrementIncense(EntityPlayer player, double min, double incenseAddition, double increment) - { + public static boolean incrementIncense(EntityPlayer player, double min, double incenseAddition, double increment) { double amount = getPlayerIncense(player); - if (amount < min || amount >= incenseAddition) - { + if (amount < min || amount >= incenseAddition) { return false; } @@ -49,28 +44,22 @@ public class PlayerSacrificeHelper /** * Sacrifices a player's health while the player is under the influence of * incense - * - * @param player - * - The player sacrificing - * + * + * @param player - The player sacrificing * @return Whether or not the health sacrificing succeeded */ - public static boolean sacrificePlayerHealth(EntityPlayer player) - { - if (player.isPotionActive(soulFrayId)) - { + public static boolean sacrificePlayerHealth(EntityPlayer player) { + if (player.isPotionActive(soulFrayId)) { return false; } double amount = getPlayerIncense(player); - if (amount >= 0) - { + if (amount >= 0) { float health = player.getHealth(); float maxHealth = player.getMaxHealth(); - if (health > maxHealth / 10.0) - { + if (health > maxHealth / 10.0) { float sacrificedHealth = health - maxHealth / 10.0f; int lpAdded = (int) (sacrificedHealth * ConfigHandler.sacrificialDaggerConversion * getModifier(amount)); @@ -78,8 +67,7 @@ public class PlayerSacrificeHelper if (MinecraftForge.EVENT_BUS.post(evt)) return false; - if (findAndFillAltar(player.getEntityWorld(), player, evt.lpAdded, false)) - { + if (findAndFillAltar(player.getEntityWorld(), player, evt.lpAdded, false)) { player.setHealth(maxHealth / 10.0f); setPlayerIncense(player, 0); player.addPotionEffect(new PotionEffect(RegistrarBloodMagic.SOUL_FRAY, soulFrayDuration)); @@ -92,28 +80,21 @@ public class PlayerSacrificeHelper return false; } - public static double getModifier(double amount) - { + public static double getModifier(double amount) { return 1 + amount * scalingOfSacrifice; } /** * Finds the nearest {@link IBloodAltar} and attempts to fill it - * - * @param world - * - The world - * @param sacrificingEntity - * - The entity having the sacrifice done on (can be - * {@link EntityPlayer} for self-sacrifice) - * @param amount - * - The amount of which the altar should be filled - * @param isSacrifice - * - Whether this is a Sacrifice or a Self-Sacrifice - * + * + * @param world - The world + * @param sacrificingEntity - The entity having the sacrifice done on (can be + * {@link EntityPlayer} for self-sacrifice) + * @param amount - The amount of which the altar should be filled + * @param isSacrifice - Whether this is a Sacrifice or a Self-Sacrifice * @return Whether the altar is found and (attempted) filled */ - public static boolean findAndFillAltar(World world, EntityLivingBase sacrificingEntity, int amount, boolean isSacrifice) - { + public static boolean findAndFillAltar(World world, EntityLivingBase sacrificingEntity, int amount, boolean isSacrifice) { IBloodAltar altarEntity = getAltar(world, sacrificingEntity.getPosition()); if (altarEntity == null) @@ -127,30 +108,22 @@ public class PlayerSacrificeHelper /** * Gets the nearest {@link IBloodAltar} - * - * @param world - * - The world - * @param blockPos - * - The position of where the check should be in (in a 2 block - * radius from this) - * + * + * @param world - The world + * @param blockPos - The position of where the check should be in (in a 2 block + * radius from this) * @return The nearest altar, if no altar is found, then this will return - * null + * null */ - public static IBloodAltar getAltar(World world, BlockPos blockPos) - { + public static IBloodAltar getAltar(World world, BlockPos blockPos) { TileEntity tileEntity; - for (int x = -2; x <= 2; x++) - { - for (int y = -2; y <= 1; y++) - { - for (int z = -2; z <= 2; z++) - { + for (int x = -2; x <= 2; x++) { + for (int y = -2; y <= 1; y++) { + for (int z = -2; z <= 2; z++) { tileEntity = world.getTileEntity(blockPos.add(x, y, z)); - if (tileEntity instanceof IBloodAltar) - { + if (tileEntity instanceof IBloodAltar) { return (IBloodAltar) tileEntity; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/PurificationHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/PurificationHelper.java index 4bf13551..60e8bda7 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/PurificationHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/PurificationHelper.java @@ -1,35 +1,29 @@ package WayofTime.bloodmagic.api.util.helper; +import WayofTime.bloodmagic.api.Constants; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.nbt.NBTTagCompound; -import WayofTime.bloodmagic.api.Constants; -public class PurificationHelper -{ - public static double getCurrentPurity(EntityAnimal animal) - { +public class PurificationHelper { + public static double getCurrentPurity(EntityAnimal animal) { NBTTagCompound data = animal.getEntityData(); - if (data.hasKey(Constants.NBT.CURRENT_PURITY)) - { + if (data.hasKey(Constants.NBT.CURRENT_PURITY)) { return data.getDouble(Constants.NBT.CURRENT_PURITY); } return 0; } - public static void setCurrentPurity(EntityAnimal animal, double amount) - { + public static void setCurrentPurity(EntityAnimal animal, double amount) { NBTTagCompound data = animal.getEntityData(); data.setDouble(Constants.NBT.CURRENT_PURITY, amount); } - public static double addPurity(EntityAnimal animal, double added, double max) - { + public static double addPurity(EntityAnimal animal, double added, double max) { double currentPurity = getCurrentPurity(animal); double newAmount = Math.min(max, currentPurity + added); - if (newAmount < max) - { + if (newAmount < max) { setCurrentPurity(animal, newAmount); return newAmount - currentPurity; } diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/RitualHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/RitualHelper.java index ac74a042..9597d969 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/RitualHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/RitualHelper.java @@ -16,26 +16,22 @@ import net.minecraftforge.common.capabilities.CapabilityInject; import java.util.ArrayList; -public class RitualHelper -{ +public class RitualHelper { @CapabilityInject(IRitualStone.Tile.class) static Capability RUNE_CAPABILITY = null; - public static boolean canCrystalActivate(Ritual ritual, int crystalLevel) - { + public static boolean canCrystalActivate(Ritual ritual, int crystalLevel) { return ritual.getCrystalLevel() <= crystalLevel && RitualRegistry.ritualEnabled(ritual); } - public static String getNextRitualKey(String currentKey) - { + public static String getNextRitualKey(String currentKey) { int currentIndex = RitualRegistry.getIds().indexOf(currentKey); int nextIndex = RitualRegistry.getRituals().listIterator(currentIndex).nextIndex(); return RitualRegistry.getIds().get(nextIndex); } - public static String getPrevRitualKey(String currentKey) - { + public static String getPrevRitualKey(String currentKey) { int currentIndex = RitualRegistry.getIds().indexOf(currentKey); int previousIndex = RitualRegistry.getIds().listIterator(currentIndex).previousIndex(); @@ -45,23 +41,16 @@ public class RitualHelper /** * Checks the RitualRegistry to see if the configuration of the ritual * stones in the world is valid for the given EnumFacing. - * - * @param world - * - The world - * @param pos - * - Location of the MasterRitualStone - * + * + * @param world - The world + * @param pos - Location of the MasterRitualStone * @return The ID of the valid ritual */ - public static String getValidRitual(World world, BlockPos pos) - { - for (String key : RitualRegistry.getIds()) - { - for (EnumFacing direction : EnumFacing.HORIZONTALS) - { + public static String getValidRitual(World world, BlockPos pos) { + for (String key : RitualRegistry.getIds()) { + for (EnumFacing direction : EnumFacing.HORIZONTALS) { boolean test = checkValidRitual(world, pos, key, direction); - if (test) - { + if (test) { return key; } } @@ -70,13 +59,10 @@ public class RitualHelper return ""; } - public static EnumFacing getDirectionOfRitual(World world, BlockPos pos, String key) - { - for (EnumFacing direction : EnumFacing.HORIZONTALS) - { + public static EnumFacing getDirectionOfRitual(World world, BlockPos pos, String key) { + for (EnumFacing direction : EnumFacing.HORIZONTALS) { boolean test = checkValidRitual(world, pos, key, direction); - if (test) - { + if (test) { return direction; } } @@ -84,11 +70,9 @@ public class RitualHelper return null; } - public static boolean checkValidRitual(World world, BlockPos pos, String ritualId, EnumFacing direction) - { + public static boolean checkValidRitual(World world, BlockPos pos, String ritualId, EnumFacing direction) { Ritual ritual = RitualRegistry.getRitualForId(ritualId); - if (ritual == null) - { + if (ritual == null) { return false; } @@ -97,14 +81,11 @@ public class RitualHelper if (components == null) return false; - for (RitualComponent component : components) - { + for (RitualComponent component : components) { BlockPos newPos = pos.add(component.getOffset(direction)); - if (isRuneType(world, newPos, component.getRuneType())) - { + if (isRuneType(world, newPos, component.getRuneType())) { continue; - } else - { + } else { return false; } } @@ -112,8 +93,7 @@ public class RitualHelper return true; } - public static boolean isRuneType(World world, BlockPos pos, EnumRuneType type) - { + public static boolean isRuneType(World world, BlockPos pos, EnumRuneType type) { if (world == null) return false; Block block = world.getBlockState(pos).getBlock(); @@ -129,8 +109,7 @@ public class RitualHelper return false; } - public static boolean isRune(World world, BlockPos pos) - { + public static boolean isRune(World world, BlockPos pos) { if (world == null) return false; Block block = world.getBlockState(pos).getBlock(); @@ -146,8 +125,7 @@ public class RitualHelper return false; } - public static void setRuneType(World world, BlockPos pos, EnumRuneType type) - { + public static void setRuneType(World world, BlockPos pos, EnumRuneType type) { if (world == null) return; IBlockState state = world.getBlockState(pos); @@ -157,8 +135,7 @@ public class RitualHelper ((IRitualStone) state.getBlock()).setRuneType(world, pos, type); else if (tile instanceof IRitualStone.Tile) ((IRitualStone.Tile) tile).setRuneType(type); - else if (tile != null && tile.hasCapability(RUNE_CAPABILITY, null)) - { + else if (tile != null && tile.hasCapability(RUNE_CAPABILITY, null)) { tile.getCapability(RUNE_CAPABILITY, null).setRuneType(type); world.notifyBlockUpdate(pos, state, state, 3); } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyArray.java b/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyArray.java index 589703ee..1e02ef13 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyArray.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyArray.java @@ -1,9 +1,9 @@ package WayofTime.bloodmagic.block; -import java.util.List; -import java.util.Random; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.tile.TileAlchemyArray; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -22,18 +22,15 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.tile.TileAlchemyArray; -import WayofTime.bloodmagic.util.Utils; import javax.annotation.Nullable; +import java.util.List; +import java.util.Random; -public class BlockAlchemyArray extends Block -{ +public class BlockAlchemyArray extends Block { protected static final AxisAlignedBB ARRAY_AABB = new AxisAlignedBB(0, 0, 0, 1, 0.1, 1); - public BlockAlchemyArray() - { + public BlockAlchemyArray() { super(Material.CLOTH); setUnlocalizedName(BloodMagic.MODID + ".alchemyArray"); @@ -46,61 +43,51 @@ public class BlockAlchemyArray extends Block } @Override - public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) - { + public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileAlchemyArray) - { + if (tile instanceof TileAlchemyArray) { ((TileAlchemyArray) tile).onEntityCollidedWithBlock(state, entity); } } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return ARRAY_AABB; } @Override @SideOnly(Side.CLIENT) - public BlockRenderLayer getBlockLayer() - { + public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.INVISIBLE; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { //TODO: Right click should rotate it TileAlchemyArray array = (TileAlchemyArray) world.getTileEntity(pos); @@ -109,17 +96,13 @@ public class BlockAlchemyArray extends Block ItemStack playerItem = player.getHeldItem(hand); - if (!playerItem.isEmpty()) - { - if (array.getStackInSlot(0).isEmpty()) - { + if (!playerItem.isEmpty()) { + if (array.getStackInSlot(0).isEmpty()) { Utils.insertItemToTile(array, player, 0); - } else if (!array.getStackInSlot(0).isEmpty()) - { + } else if (!array.getStackInSlot(0).isEmpty()) { Utils.insertItemToTile(array, player, 1); array.attemptCraft(); - } else - { + } else { return true; } } @@ -129,20 +112,17 @@ public class BlockAlchemyArray extends Block } @Override - public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) - { + public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(RegistrarBloodMagicItems.ARCANE_ASHES); } @Override - public int quantityDropped(Random random) - { + public int quantityDropped(Random random) { return 0; } @Override - public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) - { + public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) { TileAlchemyArray alchemyArray = (TileAlchemyArray) world.getTileEntity(blockPos); if (alchemyArray != null) alchemyArray.dropItems(); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyTable.java b/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyTable.java index ce4bc9d0..16380c15 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyTable.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyTable.java @@ -1,6 +1,9 @@ package WayofTime.bloodmagic.block; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.item.block.ItemBlockAlchemyTable; +import WayofTime.bloodmagic.tile.TileAlchemyTable; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyBool; @@ -17,19 +20,14 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.tile.TileAlchemyTable; import javax.annotation.Nullable; -public class BlockAlchemyTable extends Block implements IBMBlock -{ +public class BlockAlchemyTable extends Block implements IBMBlock { public static final PropertyBool INVISIBLE = PropertyBool.create("invisible"); public static final PropertyEnum DIRECTION = PropertyEnum.create("direction", EnumFacing.class); - public BlockAlchemyTable() - { + public BlockAlchemyTable() { super(Material.ROCK); // this.setDefaultState(this.blockState.getBaseState().withProperty(DIRECTION, EnumFacing.DOWN).withProperty(INVISIBLE, false)); @@ -43,44 +41,37 @@ public class BlockAlchemyTable extends Block implements IBMBlock } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override - public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) - { + public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) { return layer == BlockRenderLayer.CUTOUT_MIPPED || layer == BlockRenderLayer.TRANSLUCENT; } @Override - public IBlockState getStateFromMeta(int meta) - { + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState(); } @@ -88,17 +79,14 @@ public class BlockAlchemyTable extends Block implements IBMBlock * Convert the BlockState into the correct metadata value */ @Override - public int getMetaFromState(IBlockState state) - { + public int getMetaFromState(IBlockState state) { return 0; } @Override - public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) - { + public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileAlchemyTable) - { + if (tile instanceof TileAlchemyTable) { return state.withProperty(INVISIBLE, ((TileAlchemyTable) tile).isInvisible()).withProperty(DIRECTION, ((TileAlchemyTable) tile).getDirection()); } @@ -106,24 +94,19 @@ public class BlockAlchemyTable extends Block implements IBMBlock } @Override - protected BlockStateContainer createBlockState() - { + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, DIRECTION, INVISIBLE); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { BlockPos position = pos; TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileAlchemyTable) - { - if (((TileAlchemyTable) tile).isSlave()) - { + if (tile instanceof TileAlchemyTable) { + if (((TileAlchemyTable) tile).isSlave()) { position = ((TileAlchemyTable) tile).getConnectedPos(); tile = world.getTileEntity(position); - if (!(tile instanceof TileAlchemyTable)) - { + if (!(tile instanceof TileAlchemyTable)) { return false; } } @@ -135,11 +118,9 @@ public class BlockAlchemyTable extends Block implements IBMBlock } @Override - public void breakBlock(World world, BlockPos pos, IBlockState blockState) - { + public void breakBlock(World world, BlockPos pos, IBlockState blockState) { TileAlchemyTable tile = (TileAlchemyTable) world.getTileEntity(pos); - if (tile != null && !tile.isSlave()) - { + if (tile != null && !tile.isSlave()) { tile.dropItems(); } @@ -158,15 +139,12 @@ public class BlockAlchemyTable extends Block implements IBMBlock } @Override - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) - { + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) { TileAlchemyTable tile = (TileAlchemyTable) world.getTileEntity(pos); - if (tile != null) - { + if (tile != null) { BlockPos connectedPos = tile.getConnectedPos(); TileEntity connectedTile = world.getTileEntity(connectedPos); - if (!(connectedTile instanceof TileAlchemyTable && ((TileAlchemyTable) connectedTile).getConnectedPos().equals(pos))) - { + if (!(connectedTile instanceof TileAlchemyTable && ((TileAlchemyTable) connectedTile).getConnectedPos().equals(pos))) { this.breakBlock(world, pos, state); world.setBlockToAir(pos); } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java b/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java index 53907ba8..886bbe25 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java @@ -1,13 +1,21 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.altar.BloodAltar; import WayofTime.bloodmagic.api.altar.EnumAltarComponent; +import WayofTime.bloodmagic.api.altar.IAltarManipulator; import WayofTime.bloodmagic.api.altar.IBloodAltar; +import WayofTime.bloodmagic.api.iface.IAltarReader; +import WayofTime.bloodmagic.api.iface.IBindable; import WayofTime.bloodmagic.api.iface.IDocumentedBlock; import WayofTime.bloodmagic.api.orb.BloodOrb; +import WayofTime.bloodmagic.api.orb.IBloodOrb; +import WayofTime.bloodmagic.api.saving.SoulNetwork; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.tile.TileAltar; +import WayofTime.bloodmagic.util.Utils; +import com.google.common.base.Strings; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -23,29 +31,15 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.altar.IAltarManipulator; -import WayofTime.bloodmagic.api.iface.IAltarReader; -import WayofTime.bloodmagic.api.iface.IBindable; -import WayofTime.bloodmagic.api.saving.SoulNetwork; -import WayofTime.bloodmagic.api.orb.IBloodOrb; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.tile.TileAltar; -import WayofTime.bloodmagic.util.Utils; - -import com.google.common.base.Strings; - import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; -public class BlockAltar extends Block implements IVariantProvider, IDocumentedBlock, IBMBlock -{ - public BlockAltar() - { +public class BlockAltar extends Block implements IVariantProvider, IDocumentedBlock, IBMBlock { + public BlockAltar() { super(Material.ROCK); setUnlocalizedName(BloodMagic.MODID + ".altar"); @@ -56,32 +50,26 @@ public class BlockAltar extends Block implements IVariantProvider, IDocumentedBl } @Override - public boolean hasComparatorInputOverride(IBlockState state) - { + public boolean hasComparatorInputOverride(IBlockState state) { return true; } @Override - public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) - { + public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) { if (world.isRemote) return 0; TileEntity tile = world.getTileEntity(pos); - if (tile != null && tile instanceof TileAltar) - { + if (tile != null && tile instanceof TileAltar) { TileAltar altar = (TileAltar) tile; ItemStack orbStack = altar.getStackInSlot(0); - if (world.getBlockState(pos.down()).getBlock() instanceof BlockDecorative) - { - if (orbStack.getItem() instanceof IBloodOrb && orbStack.getItem() instanceof IBindable) - { + if (world.getBlockState(pos.down()).getBlock() instanceof BlockDecorative) { + if (orbStack.getItem() instanceof IBloodOrb && orbStack.getItem() instanceof IBindable) { BloodOrb orb = ((IBloodOrb) orbStack.getItem()).getOrb(orbStack); IBindable bindable = (IBindable) orbStack.getItem(); - if (orb != null && !Strings.isNullOrEmpty(bindable.getOwnerUUID(orbStack))) - { + if (orb != null && !Strings.isNullOrEmpty(bindable.getOwnerUUID(orbStack))) { SoulNetwork soulNetwork = NetworkHelper.getSoulNetwork(bindable.getOwnerUUID(orbStack)); int maxEssence = orb.getCapacity(); @@ -90,8 +78,7 @@ public class BlockAltar extends Block implements IVariantProvider, IDocumentedBl return Math.min(15, level) % 16; } } - } else - { + } else { int maxEssence = altar.getCapacity(); int currentEssence = altar.getCurrentBlood(); int level = currentEssence * 15 / maxEssence; @@ -103,38 +90,32 @@ public class BlockAltar extends Block implements IVariantProvider, IDocumentedBl } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return true; } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { TileAltar altar = (TileAltar) world.getTileEntity(pos); if (altar == null || player.isSneaking()) @@ -142,8 +123,7 @@ public class BlockAltar extends Block implements IVariantProvider, IDocumentedBl ItemStack playerItem = player.inventory.getCurrentItem(); - if (playerItem.getItem() instanceof IAltarReader || playerItem.getItem() instanceof IAltarManipulator) - { + if (playerItem.getItem() instanceof IAltarReader || playerItem.getItem() instanceof IAltarManipulator) { playerItem.getItem().onItemRightClick(world, player, hand); return true; } @@ -158,11 +138,9 @@ public class BlockAltar extends Block implements IVariantProvider, IDocumentedBl } @Override - public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) - { + public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) { TileEntity tile = world.getTileEntity(blockPos); - if (tile instanceof TileAltar) - { + if (tile instanceof TileAltar) { TileAltar tileAltar = (TileAltar) world.getTileEntity(blockPos); if (tileAltar != null) tileAltar.dropItems(); @@ -185,8 +163,7 @@ public class BlockAltar extends Block implements IVariantProvider, IDocumentedBl // IVariantProvider @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "normal")); return ret; @@ -195,8 +172,7 @@ public class BlockAltar extends Block implements IVariantProvider, IDocumentedBl // IDocumentedBlock @Override - public List getDocumentation(EntityPlayer player, World world, BlockPos pos, IBlockState state) - { + public List getDocumentation(EntityPlayer player, World world, BlockPos pos, IBlockState state) { List docs = new ArrayList(); IBloodAltar altar = ((IBloodAltar) world.getTileEntity(pos)); Pair missingBlock = BloodAltar.getAltarMissingBlock(world, pos, altar.getTier().toInt()); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockBloodLight.java b/src/main/java/WayofTime/bloodmagic/block/BlockBloodLight.java index 3b395958..71f9d92e 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockBloodLight.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockBloodLight.java @@ -1,8 +1,7 @@ package WayofTime.bloodmagic.block; -import java.util.Random; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -17,16 +16,14 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import javax.annotation.Nullable; +import java.util.Random; -public class BlockBloodLight extends Block -{ +public class BlockBloodLight extends Block { protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.4, 0.4, 0.4, 0.6, 0.6, 0.6); - public BlockBloodLight() - { + public BlockBloodLight() { super(Material.CLOTH); setUnlocalizedName(BloodMagic.MODID + ".bloodLight"); @@ -34,66 +31,55 @@ public class BlockBloodLight extends Block @Nullable @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) - { + public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { return null; } @Override - public boolean isCollidable() - { + public boolean isCollidable() { return false; } @Override - public boolean isReplaceable(IBlockAccess world, BlockPos pos) - { + public boolean isReplaceable(IBlockAccess world, BlockPos pos) { return true; } @Override @SideOnly(Side.CLIENT) - public BlockRenderLayer getBlockLayer() - { + public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @Override - public int getLightValue(IBlockState state) - { + public int getLightValue(IBlockState state) { return 15; } @Override @SideOnly(Side.CLIENT) - public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager particleManager) - { - if (world.getBlockState(pos).getBlock() == this) - { + public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager particleManager) { + if (world.getBlockState(pos).getBlock() == this) { Random random = new Random(); particleManager.spawnEffectParticle(EnumParticleTypes.REDSTONE.getParticleID(), pos.getX() + 0.5D + random.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + random.nextGaussian() / 8, 0, 0, 0); } @@ -102,15 +88,12 @@ public class BlockBloodLight extends Block @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) - { + public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { EntityPlayerSP playerSP = Minecraft.getMinecraft().player; - if (rand.nextInt(3) != 0) - { + if (rand.nextInt(3) != 0) { world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0); - if (!playerSP.getActiveItemStack().isEmpty() && playerSP.getActiveItemStack().getItem() == RegistrarBloodMagicItems.SIGIL_BLOOD_LIGHT) - { + if (!playerSP.getActiveItemStack().isEmpty() && playerSP.getActiveItemStack().getItem() == RegistrarBloodMagicItems.SIGIL_BLOOD_LIGHT) { world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0); world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0); world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0); @@ -119,14 +102,12 @@ public class BlockBloodLight extends Block } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return AABB; } @Override - public int quantityDropped(Random par1Random) - { + public int quantityDropped(Random par1Random) { return 0; } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockBloodRune.java b/src/main/java/WayofTime/bloodmagic/block/BlockBloodRune.java index 30e399f4..bd440dd3 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockBloodRune.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockBloodRune.java @@ -1,28 +1,19 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -import net.minecraft.world.World; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; - import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.block.base.BlockEnum; import WayofTime.bloodmagic.block.enums.EnumBloodRune; -import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.util.helper.TextHelper; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; -public class BlockBloodRune extends BlockEnum -{ - public BlockBloodRune() - { +import java.util.List; + +public class BlockBloodRune extends BlockEnum { + public BlockBloodRune() { super(Material.ROCK, EnumBloodRune.class); setUnlocalizedName(BloodMagic.MODID + ".rune."); @@ -33,14 +24,12 @@ public class BlockBloodRune extends BlockEnum setHarvestLevel("pickaxe", 2); } - public int getRuneEffect(int meta) - { + public int getRuneEffect(int meta) { return meta; } @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag tooltipFlag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag tooltipFlag) { tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.decoration.safe")); super.addInformation(stack, world, tooltip, tooltipFlag); } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockBloodTank.java b/src/main/java/WayofTime/bloodmagic/block/BlockBloodTank.java index f08e8135..6637e06d 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockBloodTank.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockBloodTank.java @@ -24,24 +24,19 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.fluids.FluidActionResult; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; import javax.annotation.Nullable; -import java.util.ArrayList; import java.util.List; -public class BlockBloodTank extends BlockInteger implements IVariantProvider, IBMBlock -{ +public class BlockBloodTank extends BlockInteger implements IVariantProvider, IBMBlock { public static final AxisAlignedBB BOX = new AxisAlignedBB(0.25, 0, 0.25, 0.75, 0.8, 0.75); - public BlockBloodTank() - { + public BlockBloodTank() { super(Material.IRON, TileBloodTank.CAPACITIES.length - 1, "tier"); setUnlocalizedName(BloodMagic.MODID + ".bloodTank"); @@ -55,39 +50,33 @@ public class BlockBloodTank extends BlockInteger implements IVariantProvider, IB @Nullable @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) - { + public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { return BOX; } @Override - public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World worldIn, BlockPos pos) - { + public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World worldIn, BlockPos pos) { return BOX; } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override @SideOnly(Side.CLIENT) - public BlockRenderLayer getBlockLayer() - { + public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT_MIPPED; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @@ -103,11 +92,9 @@ public class BlockBloodTank extends BlockInteger implements IVariantProvider, IB } @Override - public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { + public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { boolean success = FluidUtil.interactWithFluidHandler(player, hand, world, blockPos, side); - if (success) - { + if (success) { world.checkLight(blockPos); world.updateComparatorOutputLevel(blockPos, this); world.markAndNotifyBlock(blockPos, world.getChunkFromBlockCoords(blockPos), state, state, 3); @@ -118,21 +105,18 @@ public class BlockBloodTank extends BlockInteger implements IVariantProvider, IB } @Override - public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) - { + public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) { if (!player.capabilities.isCreativeMode) this.dropBlockAsItem(worldIn, pos, state, 0); super.onBlockHarvested(worldIn, pos, state, player); } @Override - public List getDrops(IBlockAccess world, BlockPos pos, IBlockState blockState, int fortune) - { + public List getDrops(IBlockAccess world, BlockPos pos, IBlockState blockState, int fortune) { List list = Lists.newArrayList(); TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileBloodTank) - { + if (tile instanceof TileBloodTank) { TileBloodTank bloodTank = (TileBloodTank) tile; ItemStack drop = new ItemStack(this, 1, bloodTank.getBlockMetadata()); NBTTagCompound tag = new NBTTagCompound(); @@ -148,15 +132,12 @@ public class BlockBloodTank extends BlockInteger implements IVariantProvider, IB } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState blockState, EntityLivingBase placer, ItemStack stack) - { + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState blockState, EntityLivingBase placer, ItemStack stack) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileBloodTank) - { + if (tile instanceof TileBloodTank) { TileBloodTank bloodTank = (TileBloodTank) tile; NBTTagCompound tag = stack.getTagCompound(); - if (tag != null) - { + if (tag != null) { FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(tag); bloodTank.getTank().setFluid(fluidStack); } @@ -168,11 +149,9 @@ public class BlockBloodTank extends BlockInteger implements IVariantProvider, IB } @Override - public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) - { + public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileBloodTank) - { + if (tile instanceof TileBloodTank) { FluidStack fluidStack = ((TileBloodTank) tile).getTank().getFluid(); return fluidStack == null || fluidStack.amount <= 0 ? 0 : fluidStack.getFluid().getLuminosity(fluidStack); } @@ -181,20 +160,17 @@ public class BlockBloodTank extends BlockInteger implements IVariantProvider, IB } @Override - public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) - { + public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(this, 1, getMetaFromState(state)); } @Override - public boolean hasComparatorInputOverride(IBlockState state) - { + public boolean hasComparatorInputOverride(IBlockState state) { return true; } @Override - public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) - { + public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); if (tile instanceof TileBloodTank) return ((TileBloodTank) tile).getComparatorOutput(); @@ -202,14 +178,12 @@ public class BlockBloodTank extends BlockInteger implements IVariantProvider, IB } @Override - public TileEntity createTileEntity(World worldIn, IBlockState blockState) - { + public TileEntity createTileEntity(World worldIn, IBlockState blockState) { return new TileBloodTank(getMetaFromState(blockState)); } @Override - public boolean hasTileEntity(IBlockState state) - { + public boolean hasTileEntity(IBlockState state) { return true; } @@ -221,8 +195,7 @@ public class BlockBloodTank extends BlockInteger implements IVariantProvider, IB // IVariantProvider @Override - public List> getVariants() - { + public List> getVariants() { List> ret = Lists.newArrayList(); for (int i = 0; i < TileBloodTank.CAPACITIES.length; i++) ret.add(Pair.of(i, "inventory")); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDecorative.java b/src/main/java/WayofTime/bloodmagic/block/BlockDecorative.java index a22fd8a8..281b4fb5 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDecorative.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDecorative.java @@ -1,16 +1,13 @@ package WayofTime.bloodmagic.block; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; - import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.block.base.BlockEnum; import WayofTime.bloodmagic.block.enums.EnumDecorative; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; -public class BlockDecorative extends BlockEnum -{ - public BlockDecorative() - { +public class BlockDecorative extends BlockEnum { + public BlockDecorative() { super(Material.ROCK, EnumDecorative.class); setUnlocalizedName(BloodMagic.MODID + "."); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDemonBase.java b/src/main/java/WayofTime/bloodmagic/block/BlockDemonBase.java index e093621a..782758fa 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDemonBase.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDemonBase.java @@ -1,22 +1,14 @@ package WayofTime.bloodmagic.block; -import java.util.List; - -import com.google.common.collect.Lists; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.util.IStringSerializable; - -import org.apache.commons.lang3.tuple.Pair; - import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.block.base.BlockEnum; import WayofTime.bloodmagic.client.IVariantProvider; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; +import net.minecraft.util.IStringSerializable; -public class BlockDemonBase & IStringSerializable> extends BlockEnum implements IVariantProvider -{ - public BlockDemonBase(String baseName, Class enumClass) - { +public class BlockDemonBase & IStringSerializable> extends BlockEnum implements IVariantProvider { + public BlockDemonBase(String baseName, Class enumClass) { super(Material.ROCK, enumClass); setUnlocalizedName(BloodMagic.MODID + "." + baseName + "."); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrucible.java b/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrucible.java index 986aec2e..b0bfcfb1 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrucible.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrucible.java @@ -1,8 +1,11 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.soul.IDemonWillGem; +import WayofTime.bloodmagic.api.soul.IDiscreteDemonWill; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.tile.TileDemonCrucible; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -16,23 +19,15 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.soul.IDemonWillGem; -import WayofTime.bloodmagic.api.soul.IDiscreteDemonWill; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.tile.TileDemonCrucible; -import WayofTime.bloodmagic.util.Utils; - import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; -public class BlockDemonCrucible extends Block implements IVariantProvider, IBMBlock -{ - public BlockDemonCrucible() - { +public class BlockDemonCrucible extends Block implements IVariantProvider, IBMBlock { + public BlockDemonCrucible() { super(Material.ROCK); setUnlocalizedName(BloodMagic.MODID + ".demonCrucible"); @@ -45,42 +40,35 @@ public class BlockDemonCrucible extends Block implements IVariantProvider, IBMBl } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack heldItem = player.getHeldItem(hand); TileDemonCrucible crucible = (TileDemonCrucible) world.getTileEntity(pos); if (crucible == null || player.isSneaking()) return false; - if (!heldItem.isEmpty()) - { - if (!(heldItem.getItem() instanceof IDiscreteDemonWill) && !(heldItem.getItem() instanceof IDemonWillGem)) - { + if (!heldItem.isEmpty()) { + if (!(heldItem.getItem() instanceof IDiscreteDemonWill) && !(heldItem.getItem() instanceof IDemonWillGem)) { return true; } } @@ -92,8 +80,7 @@ public class BlockDemonCrucible extends Block implements IVariantProvider, IBMBl } @Override - public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) - { + public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) { TileDemonCrucible tile = (TileDemonCrucible) world.getTileEntity(blockPos); if (tile != null) tile.dropItems(); @@ -113,8 +100,7 @@ public class BlockDemonCrucible extends Block implements IVariantProvider, IBMBl } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "normal")); return ret; diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystal.java b/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystal.java index 7f9e6a24..a6964776 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystal.java @@ -1,8 +1,11 @@ package WayofTime.bloodmagic.block; -import java.util.Random; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; +import WayofTime.bloodmagic.item.ItemDemonCrystal; import WayofTime.bloodmagic.item.block.ItemBlockDemonCrystal; +import WayofTime.bloodmagic.tile.TileDemonCrystal; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyEnum; @@ -11,7 +14,6 @@ import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -22,24 +24,16 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; -import WayofTime.bloodmagic.item.ItemDemonCrystal; -import WayofTime.bloodmagic.tile.TileDemonCrystal; import javax.annotation.Nullable; +import java.util.Random; -public class BlockDemonCrystal extends Block implements IBMBlock -{ +public class BlockDemonCrystal extends Block implements IBMBlock { public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 6); public static final PropertyEnum TYPE = PropertyEnum.create("type", EnumDemonWillType.class); public static final PropertyEnum ATTACHED = PropertyEnum.create("attached", EnumFacing.class); - public BlockDemonCrystal() - { + public BlockDemonCrystal() { super(Material.ROCK); this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, EnumDemonWillType.DEFAULT).withProperty(ATTACHED, EnumFacing.UP)); @@ -51,8 +45,7 @@ public class BlockDemonCrystal extends Block implements IBMBlock } @Override - public boolean canPlaceBlockOnSide(World world, BlockPos pos, EnumFacing side) - { + public boolean canPlaceBlockOnSide(World world, BlockPos pos, EnumFacing side) { BlockPos offsetPos = pos.offset(side.getOpposite()); IBlockState offsetState = world.getBlockState(offsetPos); Block offsetBlock = offsetState.getBlock(); @@ -61,25 +54,21 @@ public class BlockDemonCrystal extends Block implements IBMBlock } @Override - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) - { + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) { TileDemonCrystal tile = (TileDemonCrystal) world.getTileEntity(pos); EnumFacing placement = tile.getPlacement(); BlockPos offsetPos = pos.offset(placement.getOpposite()); IBlockState offsetState = world.getBlockState(offsetPos); Block offsetBlock = offsetState.getBlock(); - if (!offsetBlock.isSideSolid(offsetState, world, offsetPos, placement)) - { + if (!offsetBlock.isSideSolid(offsetState, world, offsetPos, placement)) { world.setBlockToAir(pos); } } @Override - public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) - { - if (world.getTileEntity(pos) == null) - { + public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { + if (world.getTileEntity(pos) == null) { return state; } TileDemonCrystal tile = (TileDemonCrystal) world.getTileEntity(pos); @@ -87,39 +76,33 @@ public class BlockDemonCrystal extends Block implements IBMBlock } @Override - public void getSubBlocks(CreativeTabs creativeTabs, NonNullList list) - { + public void getSubBlocks(CreativeTabs creativeTabs, NonNullList list) { for (int i = 0; i < EnumDemonWillType.values().length; i++) list.add(new ItemStack(this, 1, i)); } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @@ -132,8 +115,7 @@ public class BlockDemonCrystal extends Block implements IBMBlock * Convert the given metadata into a BlockState for this Block */ @Override - public IBlockState getStateFromMeta(int meta) - { + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(TYPE, EnumDemonWillType.values()[meta]); } @@ -141,20 +123,17 @@ public class BlockDemonCrystal extends Block implements IBMBlock * Convert the BlockState into the correct metadata value */ @Override - public int getMetaFromState(IBlockState state) - { + public int getMetaFromState(IBlockState state) { return state.getValue(TYPE).ordinal(); } @Override - protected BlockStateContainer createBlockState() - { + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, TYPE, AGE, ATTACHED); } @Override - public void breakBlock(World world, BlockPos pos, IBlockState state) - { + public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntity tile = world.getTileEntity(pos); if (tile instanceof TileDemonCrystal) { EnumDemonWillType type = state.getValue(TYPE); @@ -167,50 +146,20 @@ public class BlockDemonCrystal extends Block implements IBMBlock super.breakBlock(world, pos, state); } - public static ItemStack getItemStackDropped(EnumDemonWillType type, int crystalNumber) - { - ItemStack stack = null; - switch (type) - { - case CORROSIVE: - stack = ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_CORROSIVE); - break; - case DEFAULT: - stack = ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_DEFAULT); - break; - case DESTRUCTIVE: - stack = ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_DESTRUCTIVE); - break; - case STEADFAST: - stack = ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_STEADFAST); - break; - case VENGEFUL: - stack = ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_VENGEFUL); - break; - } - - stack.setCount(crystalNumber); - return stack; - } - @Override - public int quantityDropped(Random random) - { + public int quantityDropped(Random random) { return 0; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { - if (world.isRemote) - { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + if (world.isRemote) { return true; } TileDemonCrystal crystal = (TileDemonCrystal) world.getTileEntity(pos); - if (PlayerDemonWillHandler.getTotalDemonWill(EnumDemonWillType.DEFAULT, player) > 1024) - { + if (PlayerDemonWillHandler.getTotalDemonWill(EnumDemonWillType.DEFAULT, player) > 1024) { crystal.dropSingleCrystal(); world.notifyBlockUpdate(pos, state, state, 3); @@ -235,6 +184,30 @@ public class BlockDemonCrystal extends Block implements IBMBlock return new ItemBlockDemonCrystal(this); } + public static ItemStack getItemStackDropped(EnumDemonWillType type, int crystalNumber) { + ItemStack stack = null; + switch (type) { + case CORROSIVE: + stack = ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_CORROSIVE); + break; + case DEFAULT: + stack = ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_DEFAULT); + break; + case DESTRUCTIVE: + stack = ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_DESTRUCTIVE); + break; + case STEADFAST: + stack = ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_STEADFAST); + break; + case VENGEFUL: + stack = ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_VENGEFUL); + break; + } + + stack.setCount(crystalNumber); + return stack; + } + // @Override // public java.util.List getDrops(net.minecraft.world.IBlockAccess world, BlockPos pos, IBlockState state, int fortune) // { diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystallizer.java b/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystallizer.java index b5b60903..0b255c05 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystallizer.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDemonCrystallizer.java @@ -1,8 +1,8 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.tile.TileDemonCrystallizer; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -13,18 +13,14 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.tile.TileDemonCrystallizer; +import java.util.ArrayList; +import java.util.List; -public class BlockDemonCrystallizer extends BlockContainer implements IVariantProvider, IBMBlock -{ - public BlockDemonCrystallizer() - { +public class BlockDemonCrystallizer extends BlockContainer implements IVariantProvider, IBMBlock { + public BlockDemonCrystallizer() { super(Material.ROCK); setUnlocalizedName(BloodMagic.MODID + ".demonCrystallizer"); @@ -37,50 +33,42 @@ public class BlockDemonCrystallizer extends BlockContainer implements IVariantPr } @Override - public boolean isSideSolid(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) - { + public boolean isSideSolid(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { return side == EnumFacing.UP; } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override - public TileEntity createNewTileEntity(World world, int meta) - { + public TileEntity createNewTileEntity(World world, int meta) { return new TileDemonCrystallizer(); } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "normal")); return ret; diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDemonLight.java b/src/main/java/WayofTime/bloodmagic/block/BlockDemonLight.java index 6d776883..f78e7266 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDemonLight.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDemonLight.java @@ -1,23 +1,13 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; - -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; - import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.block.base.BlockEnum; import WayofTime.bloodmagic.block.enums.EnumSubWillType; -import WayofTime.bloodmagic.client.IVariantProvider; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; -public class BlockDemonLight extends BlockEnum -{ - public BlockDemonLight() - { +public class BlockDemonLight extends BlockEnum { + public BlockDemonLight() { super(Material.ROCK, EnumSubWillType.class); setUnlocalizedName(BloodMagic.MODID + ".demonlight."); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDemonPillarBase.java b/src/main/java/WayofTime/bloodmagic/block/BlockDemonPillarBase.java index 53c2c495..44c7f95f 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDemonPillarBase.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDemonPillarBase.java @@ -1,22 +1,18 @@ package WayofTime.bloodmagic.block; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.block.base.BlockEnumPillar; import com.google.common.collect.Lists; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; - import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.block.base.BlockEnumPillar; +import java.util.List; -public class BlockDemonPillarBase & IStringSerializable> extends BlockEnumPillar -{ - public BlockDemonPillarBase(String baseName, Material materialIn, Class enumClass) - { +public class BlockDemonPillarBase & IStringSerializable> extends BlockEnumPillar { + public BlockDemonPillarBase(String baseName, Material materialIn, Class enumClass) { super(materialIn, enumClass); setUnlocalizedName(BloodMagic.MODID + "." + baseName + "."); @@ -28,12 +24,11 @@ public class BlockDemonPillarBase & IStringSerializable> exten } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = Lists.newArrayList(); //This is done to make the ItemBlocks have the proper model - EnumFacing.Axis[] axis = new EnumFacing.Axis[] { EnumFacing.Axis.Y, EnumFacing.Axis.X, EnumFacing.Axis.Z }; + EnumFacing.Axis[] axis = new EnumFacing.Axis[]{EnumFacing.Axis.Y, EnumFacing.Axis.X, EnumFacing.Axis.Z}; for (int i = 0; i < 3; i++) for (int j = 0; j < this.getTypes().length; j++) diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDemonPillarCapBase.java b/src/main/java/WayofTime/bloodmagic/block/BlockDemonPillarCapBase.java index 865b89ca..51ef6dbb 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDemonPillarCapBase.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDemonPillarCapBase.java @@ -1,22 +1,18 @@ package WayofTime.bloodmagic.block; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.block.base.BlockEnumPillarCap; import com.google.common.collect.Lists; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; - import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.block.base.BlockEnumPillarCap; +import java.util.List; -public class BlockDemonPillarCapBase & IStringSerializable> extends BlockEnumPillarCap -{ - public BlockDemonPillarCapBase(String baseName, Material materialIn, Class enumClass) - { +public class BlockDemonPillarCapBase & IStringSerializable> extends BlockEnumPillarCap { + public BlockDemonPillarCapBase(String baseName, Material materialIn, Class enumClass) { super(materialIn, enumClass); setUnlocalizedName(BloodMagic.MODID + "." + baseName + "."); @@ -28,8 +24,7 @@ public class BlockDemonPillarCapBase & IStringSerializable> ex } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = Lists.newArrayList(); //This is done to make the ItemBlocks have the proper model diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDemonPylon.java b/src/main/java/WayofTime/bloodmagic/block/BlockDemonPylon.java index 1eda088e..28abe0f5 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDemonPylon.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDemonPylon.java @@ -1,8 +1,8 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.tile.TileDemonPylon; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -11,18 +11,14 @@ import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.tile.TileDemonPylon; +import java.util.ArrayList; +import java.util.List; -public class BlockDemonPylon extends BlockContainer implements IVariantProvider -{ - public BlockDemonPylon() - { +public class BlockDemonPylon extends BlockContainer implements IVariantProvider { + public BlockDemonPylon() { super(Material.ROCK); setUnlocalizedName(BloodMagic.MODID + ".demonPylon"); @@ -35,44 +31,37 @@ public class BlockDemonPylon extends BlockContainer implements IVariantProvider } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override - public TileEntity createNewTileEntity(World world, int meta) - { + public TileEntity createNewTileEntity(World world, int meta) { return new TileDemonPylon(); } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "normal")); return ret; diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDemonStairsBase.java b/src/main/java/WayofTime/bloodmagic/block/BlockDemonStairsBase.java index 26ae4b4e..30166d16 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDemonStairsBase.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDemonStairsBase.java @@ -1,24 +1,17 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.block.base.BlockEnumStairs; import com.google.common.collect.Lists; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.util.IStringSerializable; - -import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.block.base.BlockEnumStairs; -import WayofTime.bloodmagic.client.IVariantProvider; +import java.util.List; -public class BlockDemonStairsBase & IStringSerializable> extends BlockEnumStairs -{ - public BlockDemonStairsBase(String baseName, Material materialIn, Class enumClass) - { +public class BlockDemonStairsBase & IStringSerializable> extends BlockEnumStairs { + public BlockDemonStairsBase(String baseName, Material materialIn, Class enumClass) { super(materialIn, enumClass); setUnlocalizedName(BloodMagic.MODID + "." + baseName + "."); @@ -30,8 +23,7 @@ public class BlockDemonStairsBase & IStringSerializable> exten } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = Lists.newArrayList(); for (int i = 0; i < this.getTypes().length; i++) diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDemonWallBase.java b/src/main/java/WayofTime/bloodmagic/block/BlockDemonWallBase.java index 3bd4be9f..2ad6bfe1 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDemonWallBase.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDemonWallBase.java @@ -1,23 +1,17 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.block.base.BlockEnumWall; import com.google.common.collect.Lists; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.util.IStringSerializable; - import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.block.base.BlockEnumWall; -import WayofTime.bloodmagic.client.IVariantProvider; +import java.util.List; -public class BlockDemonWallBase & IStringSerializable> extends BlockEnumWall -{ - public BlockDemonWallBase(String baseName, Material materialIn, Class enumClass) - { +public class BlockDemonWallBase & IStringSerializable> extends BlockEnumWall { + public BlockDemonWallBase(String baseName, Material materialIn, Class enumClass) { super(materialIn, enumClass); setUnlocalizedName(BloodMagic.MODID + "." + baseName + "."); @@ -29,8 +23,7 @@ public class BlockDemonWallBase & IStringSerializable> extends } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = Lists.newArrayList(); for (int i = 0; i < this.getTypes().length; i++) diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockDimensionalPortal.java b/src/main/java/WayofTime/bloodmagic/block/BlockDimensionalPortal.java index 1fe90938..31361c34 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockDimensionalPortal.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockDimensionalPortal.java @@ -1,10 +1,13 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.Random; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; +import WayofTime.bloodmagic.api.teleport.PortalLocation; +import WayofTime.bloodmagic.api.teleport.TeleportQueue; import WayofTime.bloodmagic.block.base.BlockInteger; +import WayofTime.bloodmagic.ritual.portal.LocationsHandler; +import WayofTime.bloodmagic.ritual.portal.Teleports; +import WayofTime.bloodmagic.tile.TileDimensionalPortal; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; @@ -17,23 +20,17 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.teleport.PortalLocation; -import WayofTime.bloodmagic.api.teleport.TeleportQueue; -import WayofTime.bloodmagic.ritual.portal.LocationsHandler; -import WayofTime.bloodmagic.ritual.portal.Teleports; -import WayofTime.bloodmagic.tile.TileDimensionalPortal; import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Random; -public class BlockDimensionalPortal extends BlockInteger -{ +public class BlockDimensionalPortal extends BlockInteger { protected static final AxisAlignedBB AABB_0 = new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.0D, 0.625D); protected static final AxisAlignedBB AABB_1 = new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.0D, 1.0D); protected static final AxisAlignedBB AABB_DEFAULT = new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.0D, 0.625D); - public BlockDimensionalPortal() - { + public BlockDimensionalPortal() { super(Material.PORTAL, 2); setUnlocalizedName(BloodMagic.MODID + ".dimensionalPortal"); setBlockUnbreakable(); @@ -42,79 +39,61 @@ public class BlockDimensionalPortal extends BlockInteger } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) - { + public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { return null; } - public boolean isOpaqueCube() - { + public boolean isOpaqueCube() { return false; } - public boolean isFullCube() - { + public boolean isFullCube() { return false; } @Override - public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) - { + public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { return 12; } @Override - public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState blockState, Entity entity) - { - if (!world.isRemote && world.getTileEntity(pos) instanceof TileDimensionalPortal) - { + public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState blockState, Entity entity) { + if (!world.isRemote && world.getTileEntity(pos) instanceof TileDimensionalPortal) { TileDimensionalPortal tile = (TileDimensionalPortal) world.getTileEntity(pos); - if (LocationsHandler.getLocationsHandler() != null) - { + if (LocationsHandler.getLocationsHandler() != null) { ArrayList linkedLocations = LocationsHandler.getLocationsHandler().getLinkedLocations(tile.portalID); - if (linkedLocations != null && !linkedLocations.isEmpty() && linkedLocations.size() > 1) - { - if (world.getTileEntity(tile.getMasterStonePos()) != null && world.getTileEntity(tile.getMasterStonePos()) instanceof IMasterRitualStone) - { + if (linkedLocations != null && !linkedLocations.isEmpty() && linkedLocations.size() > 1) { + if (world.getTileEntity(tile.getMasterStonePos()) != null && world.getTileEntity(tile.getMasterStonePos()) instanceof IMasterRitualStone) { IMasterRitualStone masterRitualStone = (IMasterRitualStone) world.getTileEntity(tile.getMasterStonePos()); - if (linkedLocations.get(0).equals(new PortalLocation(masterRitualStone.getBlockPos().up(), world.provider.getDimension()))) - { + if (linkedLocations.get(0).equals(new PortalLocation(masterRitualStone.getBlockPos().up(), world.provider.getDimension()))) { PortalLocation portal = linkedLocations.get(1); - if (portal.getDimension() == world.provider.getDimension()) - { + if (portal.getDimension() == world.provider.getDimension()) { TeleportQueue.getInstance().addITeleport(new Teleports.TeleportSameDim(portal.getX(), portal.getY(), portal.getZ(), entity, masterRitualStone.getOwner(), false)); - } else - { + } else { TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(portal.getX(), portal.getY(), portal.getZ(), entity, masterRitualStone.getOwner(), world, portal.getDimension(), false)); } - } else if (linkedLocations.get(1).equals(new PortalLocation(masterRitualStone.getBlockPos().up(), world.provider.getDimension()))) - { + } else if (linkedLocations.get(1).equals(new PortalLocation(masterRitualStone.getBlockPos().up(), world.provider.getDimension()))) { PortalLocation portal = linkedLocations.get(0); - if (portal.getDimension() == world.provider.getDimension()) - { + if (portal.getDimension() == world.provider.getDimension()) { TeleportQueue.getInstance().addITeleport(new Teleports.TeleportSameDim(portal.getX(), portal.getY(), portal.getZ(), entity, masterRitualStone.getOwner(), false)); - } else - { + } else { TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(portal.getX(), portal.getY(), portal.getZ(), entity, masterRitualStone.getOwner(), world, portal.getDimension(), false)); } } @@ -125,23 +104,18 @@ public class BlockDimensionalPortal extends BlockInteger } @Override - public int quantityDropped(Random par1Random) - { + public int quantityDropped(Random par1Random) { return 0; } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) - { + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { int meta = state.getBlock().getMetaFromState(state); - if (meta == 0) - { + if (meta == 0) { return AABB_0; - } else if (meta == 1) - { + } else if (meta == 1) { return AABB_1; - } else - { + } else { return AABB_DEFAULT; } } @@ -155,15 +129,13 @@ public class BlockDimensionalPortal extends BlockInteger @Override @SideOnly(Side.CLIENT) - public BlockRenderLayer getBlockLayer() - { + public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.TRANSLUCENT; } @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) - { + public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { this.spawnParticles(world, pos.getX(), pos.getY(), pos.getZ()); } @@ -178,41 +150,32 @@ public class BlockDimensionalPortal extends BlockInteger return new TileDimensionalPortal(); } - private void spawnParticles(World world, int x, int y, int z) - { + private void spawnParticles(World world, int x, int y, int z) { Random random = world.rand; double d0 = 0.0625D; - for (int i = 0; i < 6; ++i) - { + for (int i = 0; i < 6; ++i) { double particleX = (double) ((float) x + random.nextFloat()); double particleY = (double) ((float) y + random.nextFloat()); double particleZ = (double) ((float) z + random.nextFloat()); - if (i == 0 && !world.getBlockState(new BlockPos(x, y + 1, z)).isOpaqueCube()) - { + if (i == 0 && !world.getBlockState(new BlockPos(x, y + 1, z)).isOpaqueCube()) { particleY = (double) (y + 1) + d0; } - if (i == 1 && !world.getBlockState(new BlockPos(x, y - 1, z)).isOpaqueCube()) - { + if (i == 1 && !world.getBlockState(new BlockPos(x, y - 1, z)).isOpaqueCube()) { particleY = (double) y - d0; } - if (i == 2 && !world.getBlockState(new BlockPos(x, y, z + 1)).isOpaqueCube()) - { + if (i == 2 && !world.getBlockState(new BlockPos(x, y, z + 1)).isOpaqueCube()) { particleZ = (double) (z + 1) + d0; } - if (i == 3 && !world.getBlockState(new BlockPos(x, y, z - 1)).isOpaqueCube()) - { + if (i == 3 && !world.getBlockState(new BlockPos(x, y, z - 1)).isOpaqueCube()) { particleZ = (double) z - d0; } - if (i == 4 && !world.getBlockState(new BlockPos(x + 1, y, z)).isOpaqueCube()) - { + if (i == 4 && !world.getBlockState(new BlockPos(x + 1, y, z)).isOpaqueCube()) { particleX = (double) (x + 1) + d0; } - if (i == 5 && !world.getBlockState(new BlockPos(x - 1, y, z)).isOpaqueCube()) - { + if (i == 5 && !world.getBlockState(new BlockPos(x - 1, y, z)).isOpaqueCube()) { particleX = (double) x - d0; } - if (particleX < (double) x || particleX > (double) (x + 1) || particleY < 0.0D || particleY > (double) (y + 1) || particleZ < (double) z || particleZ > (double) (z + 1)) - { + if (particleX < (double) x || particleX > (double) (x + 1) || particleY < 0.0D || particleY > (double) (y + 1) || particleZ < (double) z || particleZ > (double) (z + 1)) { world.spawnParticle(EnumParticleTypes.REDSTONE, particleX, particleY, particleZ, 0.0D, 0.0D, 0.0D); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockIncenseAltar.java b/src/main/java/WayofTime/bloodmagic/block/BlockIncenseAltar.java index 17d8693b..af051063 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockIncenseAltar.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockIncenseAltar.java @@ -1,8 +1,8 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.tile.TileIncenseAltar; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -13,22 +13,17 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.tile.TileIncenseAltar; - import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; -public class BlockIncenseAltar extends Block implements IVariantProvider, IBMBlock -{ +public class BlockIncenseAltar extends Block implements IVariantProvider, IBMBlock { protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.3F, 0F, 0.3F, 0.72F, 1F, 0.72F); - public BlockIncenseAltar() - { + public BlockIncenseAltar() { super(Material.ROCK); setUnlocalizedName(BloodMagic.MODID + ".incenseAltar"); @@ -39,44 +34,37 @@ public class BlockIncenseAltar extends Block implements IVariantProvider, IBMBlo } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return AABB; } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override - public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) - { + public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) { TileIncenseAltar TileIncenseAltar = (TileIncenseAltar) world.getTileEntity(blockPos); if (TileIncenseAltar != null) TileIncenseAltar.dropItems(); @@ -96,8 +84,7 @@ public class BlockIncenseAltar extends Block implements IVariantProvider, IBMBlo } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "normal")); return ret; diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockInputRoutingNode.java b/src/main/java/WayofTime/bloodmagic/block/BlockInputRoutingNode.java index 8fdf5607..848afb35 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockInputRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockInputRoutingNode.java @@ -1,5 +1,8 @@ package WayofTime.bloodmagic.block; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.tile.routing.TileInputRoutingNode; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; @@ -7,16 +10,11 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.tile.routing.TileInputRoutingNode; import javax.annotation.Nullable; -public class BlockInputRoutingNode extends BlockRoutingNode -{ - public BlockInputRoutingNode() - { +public class BlockInputRoutingNode extends BlockRoutingNode { + public BlockInputRoutingNode() { super(); setUnlocalizedName(BloodMagic.MODID + ".inputRouting"); @@ -24,11 +22,9 @@ public class BlockInputRoutingNode extends BlockRoutingNode @Override //TODO: Combine BlockInputRoutingNode and BlockInputRoutingNode so they have the same superclass - public void breakBlock(World world, BlockPos pos, IBlockState state) - { + public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileInputRoutingNode) - { + if (tile instanceof TileInputRoutingNode) { ((TileInputRoutingNode) tile).removeAllConnections(); ((TileInputRoutingNode) tile).dropItems(); } @@ -36,10 +32,8 @@ public class BlockInputRoutingNode extends BlockRoutingNode } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { - if (world.getTileEntity(pos) instanceof TileInputRoutingNode) - { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + if (world.getTileEntity(pos) instanceof TileInputRoutingNode) { player.openGui(BloodMagic.instance, Constants.Gui.ROUTING_NODE_GUI, world, pos.getX(), pos.getY(), pos.getZ()); } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockInversionPillar.java b/src/main/java/WayofTime/bloodmagic/block/BlockInversionPillar.java index 396c320d..03040157 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockInversionPillar.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockInversionPillar.java @@ -1,9 +1,9 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.block.base.BlockEnum; +import WayofTime.bloodmagic.block.enums.EnumSubWillType; +import WayofTime.bloodmagic.tile.TileInversionPillar; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.BlockStateContainer; @@ -14,19 +14,13 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.property.Properties; - -import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.block.enums.EnumSubWillType; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.tile.TileInversionPillar; +import java.util.ArrayList; +import java.util.List; -public class BlockInversionPillar extends BlockEnum -{ - public BlockInversionPillar() - { +public class BlockInversionPillar extends BlockEnum { + public BlockInversionPillar() { super(Material.ROCK, EnumSubWillType.class); setUnlocalizedName(BloodMagic.MODID + ".inversionpillar."); @@ -38,11 +32,9 @@ public class BlockInversionPillar extends BlockEnum } @Override - public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) - { + public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) { TileEntity tile = world.getTileEntity(blockPos); - if (tile instanceof TileInversionPillar) - { + if (tile instanceof TileInversionPillar) { TileInversionPillar tilePillar = (TileInversionPillar) world.getTileEntity(blockPos); tilePillar.removePillarFromMap(); } @@ -51,44 +43,37 @@ public class BlockInversionPillar extends BlockEnum } @Override - public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) - { + public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { return super.getActualState(state, world, pos).withProperty(Properties.StaticProperty, true); } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); for (int i = 0; i < this.getTypes().length; i++) ret.add(Pair.of(i, "static=false,type=" + this.getTypes()[i])); @@ -105,8 +90,7 @@ public class BlockInversionPillar extends BlockEnum return new TileInversionPillar(state.getValue(getProperty()).getType()); } - protected BlockStateContainer createStateContainer() - { + protected BlockStateContainer createStateContainer() { return new BlockStateContainer.Builder(this).add(getProperty(), Properties.StaticProperty).add(Properties.AnimationProperty).build(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockInversionPillarEnd.java b/src/main/java/WayofTime/bloodmagic/block/BlockInversionPillarEnd.java index 873e466a..9b0e3067 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockInversionPillarEnd.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockInversionPillarEnd.java @@ -1,27 +1,23 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.block.base.BlockEnum; +import WayofTime.bloodmagic.block.enums.EnumInversionCap; +import WayofTime.bloodmagic.client.IVariantProvider; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.block.base.BlockEnum; -import WayofTime.bloodmagic.block.enums.EnumInversionCap; -import WayofTime.bloodmagic.client.IVariantProvider; +import java.util.ArrayList; +import java.util.List; -public class BlockInversionPillarEnd extends BlockEnum implements IVariantProvider -{ - public BlockInversionPillarEnd() - { +public class BlockInversionPillarEnd extends BlockEnum implements IVariantProvider { + public BlockInversionPillarEnd() { super(Material.ROCK, EnumInversionCap.class); setUnlocalizedName(BloodMagic.MODID + ".inversionpillarend."); @@ -33,38 +29,32 @@ public class BlockInversionPillarEnd extends BlockEnum impleme } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); for (int i = 0; i < this.getTypes().length; i++) ret.add(new ImmutablePair(i, "type=" + this.getTypes()[i])); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockItemRoutingNode.java b/src/main/java/WayofTime/bloodmagic/block/BlockItemRoutingNode.java index 32dc9d79..1bb62034 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockItemRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockItemRoutingNode.java @@ -1,30 +1,26 @@ package WayofTime.bloodmagic.block; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.tile.routing.TileItemRoutingNode; +import WayofTime.bloodmagic.tile.routing.TileRoutingNode; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.tile.routing.TileItemRoutingNode; -import WayofTime.bloodmagic.tile.routing.TileRoutingNode; import javax.annotation.Nullable; -public class BlockItemRoutingNode extends BlockRoutingNode -{ - public BlockItemRoutingNode() - { +public class BlockItemRoutingNode extends BlockRoutingNode { + public BlockItemRoutingNode() { super(); setUnlocalizedName(BloodMagic.MODID + ".itemRouting"); } @Override - public void breakBlock(World world, BlockPos pos, IBlockState state) - { + public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileRoutingNode) - { + if (tile instanceof TileRoutingNode) { ((TileRoutingNode) tile).removeAllConnections(); } super.breakBlock(world, pos, state); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockLifeEssence.java b/src/main/java/WayofTime/bloodmagic/block/BlockLifeEssence.java index 51f7cb2b..44c1766c 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockLifeEssence.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockLifeEssence.java @@ -1,8 +1,8 @@ package WayofTime.bloodmagic.block; -import java.awt.Color; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.block.material.Material; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.ResourceLocation; @@ -12,15 +12,13 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class BlockLifeEssence extends BlockFluidClassic -{ +import java.awt.Color; + +public class BlockLifeEssence extends BlockFluidClassic { private static final Fluid LIFE_ESSENCE = new FluidLifeEssence(); - public BlockLifeEssence() - { + public BlockLifeEssence() { super(LIFE_ESSENCE, Material.WATER); setUnlocalizedName(BloodMagic.MODID + ".fluid.lifeEssence"); @@ -28,32 +26,27 @@ public class BlockLifeEssence extends BlockFluidClassic } @Override - public boolean canDisplace(IBlockAccess world, BlockPos blockPos) - { + public boolean canDisplace(IBlockAccess world, BlockPos blockPos) { return !world.getBlockState(blockPos).getBlock().getMaterial(world.getBlockState(blockPos)).isLiquid() && super.canDisplace(world, blockPos); } @Override - public boolean displaceIfPossible(World world, BlockPos blockPos) - { + public boolean displaceIfPossible(World world, BlockPos blockPos) { return !world.getBlockState(blockPos).getBlock().getMaterial(world.getBlockState(blockPos)).isLiquid() && super.displaceIfPossible(world, blockPos); } + @Override + public BlockRenderLayer getBlockLayer() { + return BlockRenderLayer.SOLID; + } + public static Fluid getLifeEssence() { return LIFE_ESSENCE; } - @Override - public BlockRenderLayer getBlockLayer() - { - return BlockRenderLayer.SOLID; - } + public static class FluidLifeEssence extends Fluid { - public static class FluidLifeEssence extends Fluid - { - - public FluidLifeEssence() - { + public FluidLifeEssence() { super("lifeEssence", new ResourceLocation(Constants.Mod.DOMAIN + "blocks/lifeEssenceStill"), new ResourceLocation(Constants.Mod.DOMAIN + "blocks/lifeEssenceFlowing")); setDensity(2000); @@ -61,14 +54,12 @@ public class BlockLifeEssence extends BlockFluidClassic } @Override - public int getColor() - { + public int getColor() { return Color.RED.getRGB(); } @Override - public String getLocalizedName(FluidStack fluidStack) - { + public String getLocalizedName(FluidStack fluidStack) { return TextHelper.localize("tile.bloodmagic.fluid.lifeEssence.name"); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockMasterRoutingNode.java b/src/main/java/WayofTime/bloodmagic/block/BlockMasterRoutingNode.java index eec3d1e4..d04ab3f2 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockMasterRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockMasterRoutingNode.java @@ -1,17 +1,15 @@ package WayofTime.bloodmagic.block; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.tile.routing.TileMasterRoutingNode; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.tile.routing.TileMasterRoutingNode; import javax.annotation.Nullable; -public class BlockMasterRoutingNode extends BlockRoutingNode -{ - public BlockMasterRoutingNode() - { +public class BlockMasterRoutingNode extends BlockRoutingNode { + public BlockMasterRoutingNode() { super(); setUnlocalizedName(BloodMagic.MODID + ".masterRouting"); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockMimic.java b/src/main/java/WayofTime/bloodmagic/block/BlockMimic.java index 19b6c3b2..a93df99e 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockMimic.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockMimic.java @@ -1,8 +1,13 @@ package WayofTime.bloodmagic.block; -import javax.annotation.Nullable; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.altar.EnumAltarComponent; +import WayofTime.bloodmagic.api.altar.IAltarComponent; import WayofTime.bloodmagic.block.base.BlockEnum; +import WayofTime.bloodmagic.block.enums.EnumMimic; +import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; +import WayofTime.bloodmagic.tile.TileMimic; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; @@ -23,20 +28,12 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.altar.EnumAltarComponent; -import WayofTime.bloodmagic.api.altar.IAltarComponent; -import WayofTime.bloodmagic.block.enums.EnumMimic; -import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; -import WayofTime.bloodmagic.tile.TileMimic; -import WayofTime.bloodmagic.util.Utils; +import javax.annotation.Nullable; -public class BlockMimic extends BlockEnum implements IAltarComponent -{ +public class BlockMimic extends BlockEnum implements IAltarComponent { public static final int sentientMimicMeta = 4; - public BlockMimic() - { + public BlockMimic() { super(Material.ROCK, EnumMimic.class); setUnlocalizedName(BloodMagic.MODID + ".mimic."); @@ -50,53 +47,43 @@ public class BlockMimic extends BlockEnum implements IAltarComponent @Nullable @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) - { - switch (this.getMetaFromState(state)) - { - case 1: - case 2: - case 3: - case 4: - TileMimic tileMimic = (TileMimic) world.getTileEntity(pos); - if (tileMimic != null && !tileMimic.getStackInSlot(0).isEmpty()) - { - Block mimicBlock = Block.getBlockFromItem(tileMimic.getStackInSlot(0).getItem()); - if (mimicBlock == Blocks.AIR) - { + public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { + switch (this.getMetaFromState(state)) { + case 1: + case 2: + case 3: + case 4: + TileMimic tileMimic = (TileMimic) world.getTileEntity(pos); + if (tileMimic != null && !tileMimic.getStackInSlot(0).isEmpty()) { + Block mimicBlock = Block.getBlockFromItem(tileMimic.getStackInSlot(0).getItem()); + if (mimicBlock == Blocks.AIR) { + return FULL_BLOCK_AABB; + } + IBlockState mimicState = mimicBlock.getStateFromMeta(tileMimic.metaOfReplacedBlock); + if (mimicBlock != this) { + return mimicState.getCollisionBoundingBox(world, pos); + } + } else { return FULL_BLOCK_AABB; } - IBlockState mimicState = mimicBlock.getStateFromMeta(tileMimic.metaOfReplacedBlock); - if (mimicBlock != this) - { - return mimicState.getCollisionBoundingBox(world, pos); - } - } else - { - return FULL_BLOCK_AABB; - } - case 0: - default: - return NULL_AABB; + case 0: + default: + return NULL_AABB; } } @Override @SideOnly(Side.CLIENT) - public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) - { + public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) { TileMimic tileMimic = (TileMimic) world.getTileEntity(pos); - if (tileMimic != null && !tileMimic.getStackInSlot(0).isEmpty()) - { + if (tileMimic != null && !tileMimic.getStackInSlot(0).isEmpty()) { Block mimicBlock = Block.getBlockFromItem(tileMimic.getStackInSlot(0).getItem()); - if (mimicBlock == Blocks.AIR) - { + if (mimicBlock == Blocks.AIR) { return FULL_BLOCK_AABB; } IBlockState mimicState = mimicBlock.getStateFromMeta(tileMimic.getStackInSlot(0).getItemDamage()); - if (mimicBlock != this) - { + if (mimicBlock != this) { return mimicState.getSelectedBoundingBox(world, pos); } } @@ -105,35 +92,29 @@ public class BlockMimic extends BlockEnum implements IAltarComponent } @Override - public int getLightOpacity(IBlockState state) - { - switch (this.getMetaFromState(state)) - { - case 2: - case 4: - return 0; - default: - return this.lightOpacity; + public int getLightOpacity(IBlockState state) { + switch (this.getMetaFromState(state)) { + case 2: + case 4: + return 0; + default: + return this.lightOpacity; } } @Override - public int getLightValue(IBlockState state) - { - switch (this.getMetaFromState(state)) - { - case 3: - return 15; - default: - return this.lightValue; + public int getLightValue(IBlockState state) { + switch (this.getMetaFromState(state)) { + case 3: + return 15; + default: + return this.lightValue; } } @Override - public int getMetaFromState(IBlockState state) - { - if (state.getBlock() == this) - { + public int getMetaFromState(IBlockState state) { + if (state.getBlock() == this) { return super.getMetaFromState(state); } @@ -148,21 +129,16 @@ public class BlockMimic extends BlockEnum implements IAltarComponent } @Override - public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) - { + public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileMimic) - { + if (tile instanceof TileMimic) { TileMimic mimic = (TileMimic) tile; ItemStack stack = mimic.getStackInSlot(0); - if (stack.getItem() instanceof ItemBlock) - { + if (stack.getItem() instanceof ItemBlock) { Block block = ((ItemBlock) stack.getItem()).getBlock(); IBlockState mimicState = block.getStateFromMeta(stack.getItemDamage()); - if (block != this) - { - if (block.getRenderType(mimicState) == EnumBlockRenderType.ENTITYBLOCK_ANIMATED) - { + if (block != this) { + if (block.getRenderType(mimicState) == EnumBlockRenderType.ENTITYBLOCK_ANIMATED) { return RegistrarBloodMagicBlocks.BLOOD_LIGHT.getDefaultState(); //Small and invisible-ish, basically this is returned in order to not render over the animated block (TESR) } @@ -174,41 +150,34 @@ public class BlockMimic extends BlockEnum implements IAltarComponent } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) - { + public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) { return layer == BlockRenderLayer.CUTOUT_MIPPED || layer == BlockRenderLayer.CUTOUT; } @Override - public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) - { + public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) { TileEntity tile = world.getTileEntity(blockPos); - if (tile instanceof TileMimic) - { + if (tile instanceof TileMimic) { TileMimic TileMimic = (TileMimic) world.getTileEntity(blockPos); if (TileMimic != null) TileMimic.dropItems(); @@ -231,21 +200,16 @@ public class BlockMimic extends BlockEnum implements IAltarComponent @Nullable @Override - public EnumAltarComponent getType(World world, IBlockState state, BlockPos pos) - { + public EnumAltarComponent getType(World world, IBlockState state, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileMimic) - { + if (tile instanceof TileMimic) { TileMimic mimic = (TileMimic) tile; ItemStack stack = mimic.getStackInSlot(0); - if (stack.getItem() instanceof ItemBlock) - { + if (stack.getItem() instanceof ItemBlock) { Block block = ((ItemBlock) stack.getItem()).getBlock(); - if (block instanceof IAltarComponent) - { + if (block instanceof IAltarComponent) { return ((IAltarComponent) block).getType(world, block.getStateFromMeta(mimic.metaOfReplacedBlock), pos); - } else - { + } else { for (EnumAltarComponent altarComponent : EnumAltarComponent.values()) if (block == Utils.getBlockForComponent(altarComponent)) return altarComponent; diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockOutputRoutingNode.java b/src/main/java/WayofTime/bloodmagic/block/BlockOutputRoutingNode.java index 3b65f42d..d3335a6f 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockOutputRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockOutputRoutingNode.java @@ -1,5 +1,8 @@ package WayofTime.bloodmagic.block; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.tile.routing.TileOutputRoutingNode; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; @@ -7,16 +10,11 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.tile.routing.TileOutputRoutingNode; import javax.annotation.Nullable; -public class BlockOutputRoutingNode extends BlockRoutingNode -{ - public BlockOutputRoutingNode() - { +public class BlockOutputRoutingNode extends BlockRoutingNode { + public BlockOutputRoutingNode() { super(); setUnlocalizedName(BloodMagic.MODID + ".outputRouting"); @@ -24,11 +22,9 @@ public class BlockOutputRoutingNode extends BlockRoutingNode @Override //TODO: Combine BlockOutputRoutingNode and BlockInputRoutingNode so they have the same superclass - public void breakBlock(World world, BlockPos pos, IBlockState state) - { + public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileOutputRoutingNode) - { + if (tile instanceof TileOutputRoutingNode) { ((TileOutputRoutingNode) tile).removeAllConnections(); ((TileOutputRoutingNode) tile).dropItems(); } @@ -36,10 +32,8 @@ public class BlockOutputRoutingNode extends BlockRoutingNode } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { - if (world.getTileEntity(pos) instanceof TileOutputRoutingNode) - { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + if (world.getTileEntity(pos) instanceof TileOutputRoutingNode) { player.openGui(BloodMagic.instance, Constants.Gui.ROUTING_NODE_GUI, world, pos.getX(), pos.getY(), pos.getZ()); } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockPath.java b/src/main/java/WayofTime/bloodmagic/block/BlockPath.java index 4e5099f1..69333f47 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockPath.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockPath.java @@ -1,32 +1,23 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; - import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.incense.IIncensePath; import WayofTime.bloodmagic.block.base.BlockEnum; import WayofTime.bloodmagic.block.enums.EnumPath; -import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.util.helper.TextHelper; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; -public class BlockPath extends BlockEnum implements IIncensePath -{ +import java.util.List; - public BlockPath() - { +public class BlockPath extends BlockEnum implements IIncensePath { + + public BlockPath() { super(Material.ROCK, EnumPath.class); setUnlocalizedName(BloodMagic.MODID + ".path."); @@ -46,31 +37,28 @@ public class BlockPath extends BlockEnum implements IIncensePath } @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag tooltipFlag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag tooltipFlag) { tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.decoration.safe")); super.addInformation(stack, world, tooltip, tooltipFlag); } @Override - public int getLevelOfPath(World world, BlockPos pos, IBlockState state) - { - switch (this.getMetaFromState(state)) - { - case 0: - case 1: - return 2; - case 2: - case 3: - return 4; - case 4: - case 5: - return 6; - case 6: - case 7: - return 8; - default: - return 0; + public int getLevelOfPath(World world, BlockPos pos, IBlockState state) { + switch (this.getMetaFromState(state)) { + case 0: + case 1: + return 2; + case 2: + case 3: + return 4; + case 4: + case 5: + return 6; + case 6: + case 7: + return 8; + default: + return 0; } } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockPhantom.java b/src/main/java/WayofTime/bloodmagic/block/BlockPhantom.java index 257d417e..b488e046 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockPhantom.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockPhantom.java @@ -1,9 +1,8 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.tile.TilePhantomBlock; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -16,20 +15,16 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.tile.TilePhantomBlock; - import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; -public class BlockPhantom extends Block implements IVariantProvider -{ - public BlockPhantom() - { +public class BlockPhantom extends Block implements IVariantProvider { + public BlockPhantom() { super(Material.CLOTH); setUnlocalizedName(BloodMagic.MODID + ".phantom"); @@ -37,52 +32,44 @@ public class BlockPhantom extends Block implements IVariantProvider } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override @SideOnly(Side.CLIENT) - public BlockRenderLayer getBlockLayer() - { + public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.TRANSLUCENT; } @Override @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) - { + public boolean shouldSideBeRendered(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { return world.getBlockState(pos.offset(side)) != state || state.getBlock() != this && super.shouldSideBeRendered(state, world, pos, side); } @Override - public int quantityDropped(Random par1Random) - { + public int quantityDropped(Random par1Random) { return 0; } @@ -98,8 +85,7 @@ public class BlockPhantom extends Block implements IVariantProvider } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "normal")); return ret; diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockRitualController.java b/src/main/java/WayofTime/bloodmagic/block/BlockRitualController.java index 16c12687..0449705c 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockRitualController.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockRitualController.java @@ -1,10 +1,20 @@ package WayofTime.bloodmagic.block; -import javax.annotation.Nullable; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.BlockStack; import WayofTime.bloodmagic.api.iface.IBindable; -import com.google.common.base.Strings; +import WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry; +import WayofTime.bloodmagic.api.registry.RitualRegistry; +import WayofTime.bloodmagic.api.ritual.Ritual; +import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual; +import WayofTime.bloodmagic.api.util.helper.RitualHelper; import WayofTime.bloodmagic.block.base.BlockEnum; +import WayofTime.bloodmagic.block.enums.EnumRitualController; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.tile.TileImperfectRitualStone; +import WayofTime.bloodmagic.tile.TileMasterRitualStone; +import amerifrance.guideapi.api.IGuideLinked; +import com.google.common.base.Strings; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -19,23 +29,10 @@ import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.Explosion; import net.minecraft.world.World; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.BlockStack; -import WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry; -import WayofTime.bloodmagic.api.registry.RitualRegistry; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual; -import WayofTime.bloodmagic.api.util.helper.RitualHelper; -import WayofTime.bloodmagic.block.enums.EnumRitualController; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.tile.TileImperfectRitualStone; -import WayofTime.bloodmagic.tile.TileMasterRitualStone; -import amerifrance.guideapi.api.IGuideLinked; +import javax.annotation.Nullable; -public class BlockRitualController extends BlockEnum implements IGuideLinked -{ - public BlockRitualController() - { +public class BlockRitualController extends BlockEnum implements IGuideLinked { + public BlockRitualController() { super(Material.ROCK, EnumRitualController.class); setUnlocalizedName(BloodMagic.MODID + ".stone.ritual."); @@ -47,15 +44,12 @@ public class BlockRitualController extends BlockEnum imple } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack heldItem = player.getHeldItem(hand); TileEntity tile = world.getTileEntity(pos); - if (state.getValue(getProperty()) != EnumRitualController.IMPERFECT && tile instanceof TileMasterRitualStone) - { - if (heldItem.getItem() == RegistrarBloodMagicItems.ACTIVATION_CRYSTAL) - { + if (state.getValue(getProperty()) != EnumRitualController.IMPERFECT && tile instanceof TileMasterRitualStone) { + if (heldItem.getItem() == RegistrarBloodMagicItems.ACTIVATION_CRYSTAL) { IBindable bindable = (IBindable) heldItem.getItem(); if (Strings.isNullOrEmpty(bindable.getOwnerName(heldItem))) return false; @@ -63,21 +57,17 @@ public class BlockRitualController extends BlockEnum imple String key = RitualHelper.getValidRitual(world, pos); EnumFacing direction = RitualHelper.getDirectionOfRitual(world, pos, key); // TODO: Give a message stating that this ritual is not a valid ritual. - if (!key.isEmpty() && direction != null && RitualHelper.checkValidRitual(world, pos, key, direction)) - { - if (((TileMasterRitualStone) tile).activateRitual(heldItem, player, RitualRegistry.getRitualForId(key))) - { + if (!key.isEmpty() && direction != null && RitualHelper.checkValidRitual(world, pos, key, direction)) { + if (((TileMasterRitualStone) tile).activateRitual(heldItem, player, RitualRegistry.getRitualForId(key))) { ((TileMasterRitualStone) tile).setDirection(direction); if (state.getValue(getProperty()) == EnumRitualController.INVERTED) ((TileMasterRitualStone) tile).setInverted(true); } - } else - { + } else { player.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.notValid"), true); } } - } else if (state.getValue(getProperty()) == EnumRitualController.IMPERFECT && tile instanceof TileImperfectRitualStone) - { + } else if (state.getValue(getProperty()) == EnumRitualController.IMPERFECT && tile instanceof TileImperfectRitualStone) { IBlockState determinerState = world.getBlockState(pos.up()); BlockStack determiner = new BlockStack(determinerState.getBlock(), determinerState.getBlock().getMetaFromState(determinerState)); @@ -89,8 +79,7 @@ public class BlockRitualController extends BlockEnum imple } @Override - public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) - { + public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) { TileEntity tile = world.getTileEntity(pos); if (getMetaFromState(state) == 0 && tile instanceof TileMasterRitualStone) @@ -98,8 +87,7 @@ public class BlockRitualController extends BlockEnum imple } @Override - public void onBlockDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) - { + public void onBlockDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) { TileEntity tile = world.getTileEntity(pos); if (tile instanceof TileMasterRitualStone) @@ -107,14 +95,12 @@ public class BlockRitualController extends BlockEnum imple } @Override - public boolean hasTileEntity(IBlockState state) - { + public boolean hasTileEntity(IBlockState state) { return true; } @Override - public TileEntity createTileEntity(World world, IBlockState state) - { + public TileEntity createTileEntity(World world, IBlockState state) { return state.getValue(getProperty()) != EnumRitualController.IMPERFECT ? new TileMasterRitualStone() : new TileImperfectRitualStone(); } @@ -122,18 +108,15 @@ public class BlockRitualController extends BlockEnum imple @Override @Nullable - public ResourceLocation getLinkedEntry(World world, BlockPos pos, EntityPlayer player, ItemStack stack) - { + public ResourceLocation getLinkedEntry(World world, BlockPos pos, EntityPlayer player, ItemStack stack) { IBlockState state = world.getBlockState(pos); - if (state.getValue(getProperty()).equals(EnumRitualController.MASTER)) - { + if (state.getValue(getProperty()).equals(EnumRitualController.MASTER)) { TileMasterRitualStone mrs = (TileMasterRitualStone) world.getTileEntity(pos); if (mrs == null || mrs.getCurrentRitual() == null) return null; else return new ResourceLocation("bloodmagic", "ritual_" + mrs.getCurrentRitual().getName()); - } else if (state.getValue(getProperty()).equals(EnumRitualController.IMPERFECT)) - { + } else if (state.getValue(getProperty()).equals(EnumRitualController.IMPERFECT)) { ImperfectRitual imperfectRitual = ImperfectRitualRegistry.getRitualForBlock(BlockStack.getStackFromPos(world, pos.up())); if (imperfectRitual != null) return new ResourceLocation("bloodmagic", "ritual_" + imperfectRitual.getName()); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockRitualStone.java b/src/main/java/WayofTime/bloodmagic/block/BlockRitualStone.java index 6bb21812..1a573969 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockRitualStone.java @@ -1,7 +1,11 @@ package WayofTime.bloodmagic.block; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.ritual.EnumRuneType; +import WayofTime.bloodmagic.api.ritual.IRitualStone; +import WayofTime.bloodmagic.block.base.BlockEnum; +import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -10,21 +14,13 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; - import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IRitualStone; -import WayofTime.bloodmagic.block.base.BlockEnum; -import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; -import WayofTime.bloodmagic.util.helper.TextHelper; +import java.util.List; -public class BlockRitualStone extends BlockEnum implements IRitualStone -{ - public BlockRitualStone() - { +public class BlockRitualStone extends BlockEnum implements IRitualStone { + public BlockRitualStone() { super(Material.IRON, EnumRuneType.class); setUnlocalizedName(BloodMagic.MODID + ".ritualStone."); @@ -37,33 +33,28 @@ public class BlockRitualStone extends BlockEnum implements IRitual @SideOnly(Side.CLIENT) @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag tooltipFlag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag tooltipFlag) { tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.decoration.safe")); super.addInformation(stack, world, tooltip, tooltipFlag); } @Override - public int damageDropped(IBlockState state) - { + public int damageDropped(IBlockState state) { return 0; } @Override - public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) - { + public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) { return false; } @Override - public boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType) - { + public boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType) { return runeType == this.getTypes()[getMetaFromState(world.getBlockState(pos))]; } @Override - public void setRuneType(World world, BlockPos pos, EnumRuneType runeType) - { + public void setRuneType(World world, BlockPos pos, EnumRuneType runeType) { int meta = runeType.ordinal(); IBlockState newState = RegistrarBloodMagicBlocks.RITUAL_STONE.getStateFromMeta(meta); world.setBlockState(pos, newState); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockRoutingNode.java b/src/main/java/WayofTime/bloodmagic/block/BlockRoutingNode.java index 1234bab3..30426072 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockRoutingNode.java @@ -1,5 +1,8 @@ package WayofTime.bloodmagic.block; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.tile.routing.TileMasterRoutingNode; +import WayofTime.bloodmagic.tile.routing.TileRoutingNode; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyBool; @@ -14,23 +17,17 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.tile.routing.TileMasterRoutingNode; -import WayofTime.bloodmagic.tile.routing.TileRoutingNode; - -public class BlockRoutingNode extends Block implements IBMBlock -{ - protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.378F, 0.378F, 0.378F, 0.625F, 0.625F, 0.625F); +public class BlockRoutingNode extends Block implements IBMBlock { public static final PropertyBool UP = PropertyBool.create("up"); public static final PropertyBool DOWN = PropertyBool.create("down"); public static final PropertyBool NORTH = PropertyBool.create("north"); public static final PropertyBool EAST = PropertyBool.create("east"); public static final PropertyBool SOUTH = PropertyBool.create("south"); public static final PropertyBool WEST = PropertyBool.create("west"); + protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.378F, 0.378F, 0.378F, 0.625F, 0.625F, 0.625F); - public BlockRoutingNode() - { + public BlockRoutingNode() { super(Material.ROCK); setCreativeTab(BloodMagic.TAB_BM); @@ -42,56 +39,47 @@ public class BlockRoutingNode extends Block implements IBMBlock } @Override - public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) - { + public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { return true; } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return AABB; } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override - public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) - { + public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) { return layer == BlockRenderLayer.CUTOUT_MIPPED || layer == BlockRenderLayer.TRANSLUCENT; } @Override - public IBlockState getStateFromMeta(int meta) - { + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState(); } @@ -99,41 +87,33 @@ public class BlockRoutingNode extends Block implements IBMBlock * Convert the BlockState into the correct metadata value */ @Override - public int getMetaFromState(IBlockState state) - { + public int getMetaFromState(IBlockState state) { return 0; } @Override - public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) - { + public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { return state.withProperty(UP, this.shouldConnect(state, worldIn, pos.up(), EnumFacing.DOWN)).withProperty(DOWN, this.shouldConnect(state, worldIn, pos.down(), EnumFacing.UP)).withProperty(NORTH, this.shouldConnect(state, worldIn, pos.north(), EnumFacing.SOUTH)).withProperty(EAST, this.shouldConnect(state, worldIn, pos.east(), EnumFacing.WEST)).withProperty(SOUTH, this.shouldConnect(state, worldIn, pos.south(), EnumFacing.NORTH)).withProperty(WEST, this.shouldConnect(state, worldIn, pos.west(), EnumFacing.EAST)); } @Override - protected BlockStateContainer createBlockState() - { + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, UP, DOWN, NORTH, EAST, WEST, SOUTH); } - public boolean shouldConnect(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing attachedSide) - { + public boolean shouldConnect(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing attachedSide) { IBlockState blockState = world.getBlockState(pos); Block block = blockState.getBlock(); return block.getMaterial(blockState).isOpaque() && blockState.isFullCube(); } @Override - public void breakBlock(World world, BlockPos pos, IBlockState blockState) - { - if (!world.isRemote) - { + public void breakBlock(World world, BlockPos pos, IBlockState blockState) { + if (!world.isRemote) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileRoutingNode) - { + if (tile instanceof TileRoutingNode) { ((TileRoutingNode) tile).removeAllConnections(); - } else if (tile instanceof TileMasterRoutingNode) - { + } else if (tile instanceof TileMasterRoutingNode) { ((TileMasterRoutingNode) tile).removeAllConnections(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockSoulForge.java b/src/main/java/WayofTime/bloodmagic/block/BlockSoulForge.java index afece925..2c200c2c 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockSoulForge.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockSoulForge.java @@ -1,8 +1,9 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.tile.TileSoulForge; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; @@ -17,23 +18,17 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.tile.TileSoulForge; - import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; -public class BlockSoulForge extends Block implements IVariantProvider, IBMBlock -{ +public class BlockSoulForge extends Block implements IVariantProvider, IBMBlock { protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.06F, 0.0F, 0.06F, 0.94F, 0.75F, 0.94F); - public BlockSoulForge() - { + public BlockSoulForge() { super(Material.IRON); setUnlocalizedName(BloodMagic.MODID + ".soulForge"); @@ -45,44 +40,37 @@ public class BlockSoulForge extends Block implements IVariantProvider, IBMBlock } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return AABB; } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (world.getTileEntity(pos) instanceof TileSoulForge) player.openGui(BloodMagic.instance, Constants.Gui.SOUL_FORGE_GUI, world, pos.getX(), pos.getY(), pos.getZ()); @@ -90,8 +78,7 @@ public class BlockSoulForge extends Block implements IVariantProvider, IBMBlock } @Override - public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) - { + public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) { TileSoulForge tileSoulForge = (TileSoulForge) world.getTileEntity(blockPos); if (tileSoulForge != null) tileSoulForge.dropItems(); @@ -111,8 +98,7 @@ public class BlockSoulForge extends Block implements IVariantProvider, IBMBlock } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "normal")); return ret; diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockSpectral.java b/src/main/java/WayofTime/bloodmagic/block/BlockSpectral.java index 6f70bee1..7a001100 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockSpectral.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockSpectral.java @@ -1,11 +1,9 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.ConfigHandler; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.tile.TileSpectralBlock; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -18,98 +16,83 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.tile.TileSpectralBlock; - import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; -public class BlockSpectral extends Block implements IVariantProvider -{ +public class BlockSpectral extends Block implements IVariantProvider { protected static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 0, 0, 0); - public BlockSpectral() - { + public BlockSpectral() { super(Material.CLOTH); setUnlocalizedName(BloodMagic.MODID + ".spectral"); } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return AABB; } @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) - { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean causesSuffocation(IBlockState state) - { + public boolean causesSuffocation(IBlockState state) { return false; } @SideOnly(Side.CLIENT) @Override - public BlockRenderLayer getBlockLayer() - { + public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.TRANSLUCENT; } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return ConfigHandler.invisibleSpectralBlocks ? EnumBlockRenderType.INVISIBLE : EnumBlockRenderType.MODEL; } @Override @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) - { + public boolean shouldSideBeRendered(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { return world.getBlockState(pos.offset(side)) != state || state.getBlock() != this && super.shouldSideBeRendered(state, world, pos, side); } @Override - public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB mask, List list, Entity collidingEntity, boolean bool) - { + public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB mask, List list, Entity collidingEntity, boolean bool) { } @Override - public int quantityDropped(Random par1Random) - { + public int quantityDropped(Random par1Random) { return 0; } @Override - public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos) - { + public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos) { return true; } @Override - public boolean isAir(IBlockState state, IBlockAccess world, BlockPos blockPos) - { + public boolean isAir(IBlockState state, IBlockAccess world, BlockPos blockPos) { return true; } @@ -125,8 +108,7 @@ public class BlockSpectral extends Block implements IVariantProvider } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "normal")); return ret; diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockTeleposer.java b/src/main/java/WayofTime/bloodmagic/block/BlockTeleposer.java index 0c374de0..6ac92d99 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockTeleposer.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockTeleposer.java @@ -1,8 +1,10 @@ package WayofTime.bloodmagic.block; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.item.ItemTelepositionFocus; +import WayofTime.bloodmagic.tile.TileTeleposer; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -15,20 +17,14 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.item.ItemTelepositionFocus; -import WayofTime.bloodmagic.tile.TileTeleposer; +import java.util.ArrayList; +import java.util.List; -public class BlockTeleposer extends BlockContainer implements IVariantProvider, IBMBlock -{ - public BlockTeleposer() - { +public class BlockTeleposer extends BlockContainer implements IVariantProvider, IBMBlock { + public BlockTeleposer() { super(Material.ROCK); setCreativeTab(BloodMagic.TAB_BM); @@ -38,14 +34,12 @@ public class BlockTeleposer extends BlockContainer implements IVariantProvider, } @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack playerItem = player.getHeldItem(hand); if (playerItem.getItem() instanceof ItemTelepositionFocus) @@ -57,8 +51,7 @@ public class BlockTeleposer extends BlockContainer implements IVariantProvider, } @Override - public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) - { + public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) { TileTeleposer tileTeleposer = (TileTeleposer) world.getTileEntity(blockPos); if (tileTeleposer != null) tileTeleposer.dropItems(); @@ -67,14 +60,12 @@ public class BlockTeleposer extends BlockContainer implements IVariantProvider, } @Override - public TileEntity createNewTileEntity(World worldIn, int meta) - { + public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileTeleposer(); } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "normal")); return ret; diff --git a/src/main/java/WayofTime/bloodmagic/block/base/BlockEnum.java b/src/main/java/WayofTime/bloodmagic/block/base/BlockEnum.java index 451ec2a8..2691f724 100644 --- a/src/main/java/WayofTime/bloodmagic/block/base/BlockEnum.java +++ b/src/main/java/WayofTime/bloodmagic/block/base/BlockEnum.java @@ -18,14 +18,12 @@ import org.apache.commons.lang3.tuple.Pair; import java.util.List; -public class BlockEnum & IStringSerializable> extends Block implements IBMBlock, IVariantProvider -{ +public class BlockEnum & IStringSerializable> extends Block implements IBMBlock, IVariantProvider { private final E[] types; private final PropertyEnum property; private final BlockStateContainer realStateContainer; - public BlockEnum(Material material, Class enumClass, String propName) - { + public BlockEnum(Material material, Class enumClass, String propName) { super(material); this.types = enumClass.getEnumConstants(); @@ -34,50 +32,42 @@ public class BlockEnum & IStringSerializable> extends Block im setDefaultState(getBlockState().getBaseState()); } - public BlockEnum(Material material, Class enumClass) - { + public BlockEnum(Material material, Class enumClass) { this(material, enumClass, "type"); } @Override - protected final BlockStateContainer createBlockState() - { + protected final BlockStateContainer createBlockState() { return new BlockStateContainer.Builder(this).build(); // Blank to avoid crashes } @Override - public final BlockStateContainer getBlockState() - { + public final BlockStateContainer getBlockState() { return realStateContainer; } @Override - public IBlockState getStateFromMeta(int meta) - { + public IBlockState getStateFromMeta(int meta) { return getDefaultState().withProperty(property, types[meta]); } @Override - public int getMetaFromState(IBlockState state) - { + public int getMetaFromState(IBlockState state) { return state.getValue(property).ordinal(); } @Override - public int damageDropped(IBlockState state) - { + public int damageDropped(IBlockState state) { return getMetaFromState(state); } @Override - public void getSubBlocks(CreativeTabs tab, NonNullList subBlocks) - { + public void getSubBlocks(CreativeTabs tab, NonNullList subBlocks) { for (E type : types) subBlocks.add(new ItemStack(this, 1, type.ordinal())); } - protected BlockStateContainer createStateContainer() - { + protected BlockStateContainer createStateContainer() { return new BlockStateContainer.Builder(this).add(property).build(); } diff --git a/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumPillar.java b/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumPillar.java index 3b8cc9a6..418c8de7 100644 --- a/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumPillar.java +++ b/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumPillar.java @@ -15,84 +15,71 @@ import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; - import org.apache.commons.lang3.ArrayUtils; -public class BlockEnumPillar & IStringSerializable> extends BlockEnum -{ - public BlockEnumPillar(Material material, Class enumClass, String propName) - { +public class BlockEnumPillar & IStringSerializable> extends BlockEnum { + public BlockEnumPillar(Material material, Class enumClass, String propName) { super(material, enumClass, propName); } - public BlockEnumPillar(Material material, Class enumClass) - { + public BlockEnumPillar(Material material, Class enumClass) { this(material, enumClass, "type"); } @Override - protected BlockStateContainer createStateContainer() - { + protected BlockStateContainer createStateContainer() { return new BlockStateContainer.Builder(this).add(getProperty(), BlockRotatedPillar.AXIS).build(); } @Override - public IBlockState getStateFromMeta(int meta) - { + public IBlockState getStateFromMeta(int meta) { IBlockState state = getBlockState().getBaseState().withProperty(this.getProperty(), getTypes()[meta % 5]); - switch (meta / 5) - { - case 0: - state = state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Y); - break; - case 1: - state = state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.X); - break; - case 2: - state = state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Z); - break; - default: - state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Y); - break; + switch (meta / 5) { + case 0: + state = state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Y); + break; + case 1: + state = state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.X); + break; + case 2: + state = state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Z); + break; + default: + state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Y); + break; } return state; } @Override - public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) - { + public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(this, 1, damageDropped(state)); } @SuppressWarnings("incomplete-switch") @Override - public int getMetaFromState(IBlockState state) - { + public int getMetaFromState(IBlockState state) { int i = ArrayUtils.indexOf(getTypes(), state.getValue(getProperty())); - switch (state.getValue(BlockRotatedPillar.AXIS)) - { - case X: - i = i + 5; - break; - case Z: - i = i + 10; - break; + switch (state.getValue(BlockRotatedPillar.AXIS)) { + case X: + i = i + 5; + break; + case Z: + i = i + 10; + break; } return i; } @Override - public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) - { + public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) { IBlockState state = world.getBlockState(pos); - for (IProperty prop : state.getProperties().keySet()) - { - if (prop == BlockRotatedPillar.AXIS) - { + for (IProperty prop : state.getProperties().keySet()) { + if (prop == BlockRotatedPillar.AXIS) { world.setBlockState(pos, state.cycleProperty(prop)); return true; } @@ -101,44 +88,37 @@ public class BlockEnumPillar & IStringSerializable> extends Bl } @Override - public IBlockState withRotation(IBlockState state, Rotation rot) - { - switch (rot) - { - case COUNTERCLOCKWISE_90: - case CLOCKWISE_90: - switch (state.getValue(BlockRotatedPillar.AXIS)) - { - case X: - return state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Z); - case Z: - return state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.X); + public IBlockState withRotation(IBlockState state, Rotation rot) { + switch (rot) { + case COUNTERCLOCKWISE_90: + case CLOCKWISE_90: + switch (state.getValue(BlockRotatedPillar.AXIS)) { + case X: + return state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Z); + case Z: + return state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.X); + default: + return state; + } + default: return state; - } - - default: - return state; } } @Override - protected ItemStack getSilkTouchDrop(IBlockState state) - { + protected ItemStack getSilkTouchDrop(IBlockState state) { return new ItemStack(this, 1, damageDropped(state)); } - @Override - public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) - { + public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand).withProperty(BlockRotatedPillar.AXIS, facing.getAxis()); } @Override - public int damageDropped(IBlockState state) - { + public int damageDropped(IBlockState state) { return super.getMetaFromState(state); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumPillarCap.java b/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumPillarCap.java index e9b1b736..365dd875 100644 --- a/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumPillarCap.java +++ b/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumPillarCap.java @@ -11,76 +11,63 @@ import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; - import org.apache.commons.lang3.ArrayUtils; -public class BlockEnumPillarCap & IStringSerializable> extends BlockEnum -{ +public class BlockEnumPillarCap & IStringSerializable> extends BlockEnum { public static final PropertyDirection FACING = PropertyDirection.create("facing"); - public BlockEnumPillarCap(Material material, Class enumClass, String propName) - { + public BlockEnumPillarCap(Material material, Class enumClass, String propName) { super(material, enumClass, propName); } - public BlockEnumPillarCap(Material material, Class enumClass) - { + public BlockEnumPillarCap(Material material, Class enumClass) { this(material, enumClass, "type"); } @Override - protected BlockStateContainer createStateContainer() - { + protected BlockStateContainer createStateContainer() { return new BlockStateContainer.Builder(this).add(getProperty(), FACING).build(); } @Override - public IBlockState getStateFromMeta(int meta) - { + public IBlockState getStateFromMeta(int meta) { IBlockState state = getBlockState().getBaseState().withProperty(this.getProperty(), getTypes()[meta % 2]); return state.withProperty(FACING, EnumFacing.getFront(meta / 2)); } @Override - public int getMetaFromState(IBlockState state) - { + public int getMetaFromState(IBlockState state) { int i = ArrayUtils.indexOf(getTypes(), state.getValue(getProperty())); return i + 2 * state.getValue(FACING).getIndex(); } @Override - public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) - { + public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(this, 1, damageDropped(state)); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot) - { + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate(state.getValue(FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirrorIn) - { + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation(state.getValue(FACING))); } @Override - protected ItemStack getSilkTouchDrop(IBlockState state) - { + protected ItemStack getSilkTouchDrop(IBlockState state) { return new ItemStack(this, 1, damageDropped(state)); } @Override - public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) - { + public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand).withProperty(FACING, facing); } @Override - public int damageDropped(IBlockState state) - { + public int damageDropped(IBlockState state) { return super.getMetaFromState(state); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumStairs.java b/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumStairs.java index 271c5b76..7a0203c4 100644 --- a/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumStairs.java +++ b/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumStairs.java @@ -1,9 +1,6 @@ package WayofTime.bloodmagic.block.base; -import java.util.List; - -import javax.annotation.Nullable; - +import com.google.common.collect.Lists; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.BlockStairs; import net.minecraft.block.BlockStairs.EnumHalf; @@ -23,16 +20,13 @@ import net.minecraft.util.math.RayTraceResult; 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; +import javax.annotation.Nullable; +import java.util.List; -import com.google.common.collect.Lists; - -public class BlockEnumStairs & IStringSerializable> extends BlockEnum -{ +public class BlockEnumStairs & IStringSerializable> extends BlockEnum { public static final PropertyDirection FACING = BlockHorizontal.FACING; protected static final AxisAlignedBB AABB_SLAB_TOP = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 1.0D, 1.0D, 1.0D); @@ -54,149 +48,61 @@ public class BlockEnumStairs & IStringSerializable> extends Bl protected static final AxisAlignedBB AABB_OCT_BOT_SW = new AxisAlignedBB(0.0D, 0.0D, 0.5D, 0.5D, 0.5D, 1.0D); protected static final AxisAlignedBB AABB_OCT_BOT_SE = new AxisAlignedBB(0.5D, 0.0D, 0.5D, 1.0D, 0.5D, 1.0D); - public BlockEnumStairs(Material material, Class enumClass, String propName) - { + public BlockEnumStairs(Material material, Class enumClass, String propName) { super(material, enumClass, propName); } - public BlockEnumStairs(Material material, Class enumClass) - { + public BlockEnumStairs(Material material, Class enumClass) { this(material, enumClass, "type"); } @Override - protected BlockStateContainer createStateContainer() - { + protected BlockStateContainer createStateContainer() { return new BlockStateContainer.Builder(this).add(getProperty(), FACING, BlockStairs.HALF, BlockStairs.SHAPE).build(); } @Override - public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entityIn, boolean bool) - { + public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entityIn, boolean bool) { state = this.getActualState(state, worldIn, pos); - for (AxisAlignedBB axisalignedbb : getCollisionBoxList(state)) - { + for (AxisAlignedBB axisalignedbb : getCollisionBoxList(state)) { addCollisionBoxToList(pos, entityBox, collidingBoxes, axisalignedbb); } } - private static List getCollisionBoxList(IBlockState state) - { - List list = Lists.newArrayList(); - boolean flag = state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP; - list.add(flag ? AABB_SLAB_TOP : AABB_SLAB_BOTTOM); - BlockStairs.EnumShape stairShape = state.getValue(BlockStairs.SHAPE); - - if (stairShape == BlockStairs.EnumShape.STRAIGHT || stairShape == BlockStairs.EnumShape.INNER_LEFT || stairShape == BlockStairs.EnumShape.INNER_RIGHT) - { - list.add(getCollQuarterBlock(state)); - } - - if (stairShape != BlockStairs.EnumShape.STRAIGHT) - { - list.add(getCollEighthBlock(state)); - } - - return list; - } - - private static AxisAlignedBB getCollQuarterBlock(IBlockState state) - { - boolean flag = state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP; - - switch (state.getValue(FACING)) - { - case NORTH: - default: - return flag ? AABB_QTR_BOT_NORTH : AABB_QTR_TOP_NORTH; - case SOUTH: - return flag ? AABB_QTR_BOT_SOUTH : AABB_QTR_TOP_SOUTH; - case WEST: - return flag ? AABB_QTR_BOT_WEST : AABB_QTR_TOP_WEST; - case EAST: - return flag ? AABB_QTR_BOT_EAST : AABB_QTR_TOP_EAST; - } - } - - private static AxisAlignedBB getCollEighthBlock(IBlockState state) - { - EnumFacing facing = state.getValue(FACING); - EnumFacing newFacing; - - switch (state.getValue(BlockStairs.SHAPE)) - { - case OUTER_LEFT: - default: - newFacing = facing; - break; - case OUTER_RIGHT: - newFacing = facing.rotateY(); - break; - case INNER_RIGHT: - newFacing = facing.getOpposite(); - break; - case INNER_LEFT: - newFacing = facing.rotateYCCW(); - } - - boolean isTop = state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP; - - switch (newFacing) - { - case NORTH: - default: - return isTop ? AABB_OCT_BOT_NW : AABB_OCT_TOP_NW; - case SOUTH: - return isTop ? AABB_OCT_BOT_SE : AABB_OCT_TOP_SE; - case WEST: - return isTop ? AABB_OCT_BOT_SW : AABB_OCT_TOP_SW; - case EAST: - return isTop ? AABB_OCT_BOT_NE : AABB_OCT_TOP_NE; - } - } - @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } @Override - public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) - { + public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { IBlockState state = super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand); state = state.withProperty(FACING, placer.getHorizontalFacing()).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.STRAIGHT); return facing != EnumFacing.DOWN && (facing == EnumFacing.UP || (double) hitY <= 0.5D) ? state.withProperty(BlockStairs.HALF, BlockStairs.EnumHalf.BOTTOM) : state.withProperty(BlockStairs.HALF, BlockStairs.EnumHalf.TOP); } @Override - public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) - { + public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) { List list = Lists.newArrayList(); - for (AxisAlignedBB axisalignedbb : getCollisionBoxList(this.getActualState(blockState, worldIn, pos))) - { + for (AxisAlignedBB axisalignedbb : getCollisionBoxList(this.getActualState(blockState, worldIn, pos))) { list.add(this.rayTrace(pos, start, end, axisalignedbb)); } RayTraceResult rayTrace = null; double d1 = 0.0D; - for (RayTraceResult raytraceresult : list) - { - if (raytraceresult != null) - { + for (RayTraceResult raytraceresult : list) { + if (raytraceresult != null) { double d0 = raytraceresult.hitVec.squareDistanceTo(end); - if (d0 > d1) - { + if (d0 > d1) { rayTrace = raytraceresult; d1 = d0; } @@ -208,8 +114,7 @@ public class BlockEnumStairs & IStringSerializable> extends Bl // Meta looks like: {1|11|1} = {HALF|FACING|TYPE} @Override - public IBlockState getStateFromMeta(int meta) - { + public IBlockState getStateFromMeta(int meta) { IBlockState state = getBlockState().getBaseState().withProperty(BlockStairs.HALF, (meta & 8) > 0 ? BlockStairs.EnumHalf.TOP : BlockStairs.EnumHalf.BOTTOM); state = state.withProperty(FACING, EnumFacing.getFront(5 - (meta & 6) / 2)).withProperty(this.getProperty(), getTypes()[meta % 2]); return state; @@ -217,12 +122,10 @@ public class BlockEnumStairs & IStringSerializable> extends Bl // Meta looks like: {1|11|1} = {HALF|FACING|TYPE} @Override - public int getMetaFromState(IBlockState state) - { + public int getMetaFromState(IBlockState state) { int i = 0; - if (state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP) - { + if (state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP) { i |= 4; } @@ -231,141 +134,78 @@ public class BlockEnumStairs & IStringSerializable> extends Bl } @Override - public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) - { + public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { return state.withProperty(BlockStairs.SHAPE, getStairsShape(state, worldIn, pos)); } - private static BlockStairs.EnumShape getStairsShape(IBlockState state, IBlockAccess world, BlockPos pos) - { - EnumFacing facing = state.getValue(FACING); - IBlockState offsetState = world.getBlockState(pos.offset(facing)); - - if (isBlockStairs(offsetState) && state.getValue(BlockStairs.HALF) == offsetState.getValue(BlockStairs.HALF)) - { - EnumFacing offsetFacing = offsetState.getValue(FACING); - - if (offsetFacing.getAxis() != state.getValue(FACING).getAxis() && isDifferentStairs(state, world, pos, offsetFacing.getOpposite())) - { - if (offsetFacing == facing.rotateYCCW()) - { - return BlockStairs.EnumShape.OUTER_LEFT; - } - - return BlockStairs.EnumShape.OUTER_RIGHT; - } - } - - IBlockState oppositeOffsetState = world.getBlockState(pos.offset(facing.getOpposite())); - - if (isBlockStairs(oppositeOffsetState) && state.getValue(BlockStairs.HALF) == oppositeOffsetState.getValue(BlockStairs.HALF)) - { - EnumFacing oppositeOffsetFacing = oppositeOffsetState.getValue(FACING); - - if (oppositeOffsetFacing.getAxis() != (state.getValue(FACING)).getAxis() && isDifferentStairs(state, world, pos, oppositeOffsetFacing)) - { - if (oppositeOffsetFacing == facing.rotateYCCW()) - { - return BlockStairs.EnumShape.INNER_LEFT; - } - - return BlockStairs.EnumShape.INNER_RIGHT; - } - } - - return BlockStairs.EnumShape.STRAIGHT; - } - - private static boolean isDifferentStairs(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing facing) - { - IBlockState offsetState = world.getBlockState(pos.offset(facing)); - return !isBlockStairs(offsetState) || offsetState.getValue(FACING) != state.getValue(FACING) || offsetState.getValue(BlockStairs.HALF) != state.getValue(BlockStairs.HALF); - } - - public static boolean isBlockStairs(IBlockState state) - { - return state.getBlock() instanceof BlockStairs || state.getBlock() instanceof BlockEnumStairs; - } - @Override - public IBlockState withRotation(IBlockState state, Rotation rot) - { + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate(state.getValue(FACING))); } @SuppressWarnings("incomplete-switch") @Override - public IBlockState withMirror(IBlockState state, Mirror mirrorIn) - { + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { EnumFacing facing = state.getValue(FACING); BlockStairs.EnumShape stairShape = state.getValue(BlockStairs.SHAPE); - switch (mirrorIn) - { - case LEFT_RIGHT: + switch (mirrorIn) { + case LEFT_RIGHT: - if (facing.getAxis() == EnumFacing.Axis.Z) - { - switch (stairShape) - { - case OUTER_LEFT: - return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.OUTER_RIGHT); - case OUTER_RIGHT: - return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.OUTER_LEFT); - case INNER_RIGHT: - return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.INNER_LEFT); - case INNER_LEFT: - return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.INNER_RIGHT); - default: - return state.withRotation(Rotation.CLOCKWISE_180); + if (facing.getAxis() == EnumFacing.Axis.Z) { + switch (stairShape) { + case OUTER_LEFT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.OUTER_RIGHT); + case OUTER_RIGHT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.OUTER_LEFT); + case INNER_RIGHT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.INNER_LEFT); + case INNER_LEFT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.INNER_RIGHT); + default: + return state.withRotation(Rotation.CLOCKWISE_180); + } } - } - break; - case FRONT_BACK: + break; + case FRONT_BACK: - if (facing.getAxis() == EnumFacing.Axis.X) - { - switch (stairShape) - { - case OUTER_LEFT: - return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.OUTER_RIGHT); - case OUTER_RIGHT: - return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.OUTER_LEFT); - case INNER_RIGHT: - return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.INNER_RIGHT); - case INNER_LEFT: - return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.INNER_LEFT); - case STRAIGHT: - return state.withRotation(Rotation.CLOCKWISE_180); + if (facing.getAxis() == EnumFacing.Axis.X) { + switch (stairShape) { + case OUTER_LEFT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.OUTER_RIGHT); + case OUTER_RIGHT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.OUTER_LEFT); + case INNER_RIGHT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.INNER_RIGHT); + case INNER_LEFT: + return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.INNER_LEFT); + case STRAIGHT: + return state.withRotation(Rotation.CLOCKWISE_180); + } } - } } return super.withMirror(state, mirrorIn); } @Override - protected ItemStack getSilkTouchDrop(IBlockState state) - { + protected ItemStack getSilkTouchDrop(IBlockState state) { return new ItemStack(this, 1, damageDropped(state)); } @Override - public int damageDropped(IBlockState state) - { + public int damageDropped(IBlockState state) { return super.getMetaFromState(state); } @Override - public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) - { + public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(this, 1, damageDropped(state)); } @Override - public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) - { + public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) { if (ForgeModContainer.disableStairSlabCulling) return super.doesSideBlockRendering(state, world, pos, face); @@ -391,4 +231,113 @@ public class BlockEnumStairs & IStringSerializable> extends Bl return true; return false; } + + private static List getCollisionBoxList(IBlockState state) { + List list = Lists.newArrayList(); + boolean flag = state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP; + list.add(flag ? AABB_SLAB_TOP : AABB_SLAB_BOTTOM); + BlockStairs.EnumShape stairShape = state.getValue(BlockStairs.SHAPE); + + if (stairShape == BlockStairs.EnumShape.STRAIGHT || stairShape == BlockStairs.EnumShape.INNER_LEFT || stairShape == BlockStairs.EnumShape.INNER_RIGHT) { + list.add(getCollQuarterBlock(state)); + } + + if (stairShape != BlockStairs.EnumShape.STRAIGHT) { + list.add(getCollEighthBlock(state)); + } + + return list; + } + + private static AxisAlignedBB getCollQuarterBlock(IBlockState state) { + boolean flag = state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP; + + switch (state.getValue(FACING)) { + case NORTH: + default: + return flag ? AABB_QTR_BOT_NORTH : AABB_QTR_TOP_NORTH; + case SOUTH: + return flag ? AABB_QTR_BOT_SOUTH : AABB_QTR_TOP_SOUTH; + case WEST: + return flag ? AABB_QTR_BOT_WEST : AABB_QTR_TOP_WEST; + case EAST: + return flag ? AABB_QTR_BOT_EAST : AABB_QTR_TOP_EAST; + } + } + + private static AxisAlignedBB getCollEighthBlock(IBlockState state) { + EnumFacing facing = state.getValue(FACING); + EnumFacing newFacing; + + switch (state.getValue(BlockStairs.SHAPE)) { + case OUTER_LEFT: + default: + newFacing = facing; + break; + case OUTER_RIGHT: + newFacing = facing.rotateY(); + break; + case INNER_RIGHT: + newFacing = facing.getOpposite(); + break; + case INNER_LEFT: + newFacing = facing.rotateYCCW(); + } + + boolean isTop = state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP; + + switch (newFacing) { + case NORTH: + default: + return isTop ? AABB_OCT_BOT_NW : AABB_OCT_TOP_NW; + case SOUTH: + return isTop ? AABB_OCT_BOT_SE : AABB_OCT_TOP_SE; + case WEST: + return isTop ? AABB_OCT_BOT_SW : AABB_OCT_TOP_SW; + case EAST: + return isTop ? AABB_OCT_BOT_NE : AABB_OCT_TOP_NE; + } + } + + private static BlockStairs.EnumShape getStairsShape(IBlockState state, IBlockAccess world, BlockPos pos) { + EnumFacing facing = state.getValue(FACING); + IBlockState offsetState = world.getBlockState(pos.offset(facing)); + + if (isBlockStairs(offsetState) && state.getValue(BlockStairs.HALF) == offsetState.getValue(BlockStairs.HALF)) { + EnumFacing offsetFacing = offsetState.getValue(FACING); + + if (offsetFacing.getAxis() != state.getValue(FACING).getAxis() && isDifferentStairs(state, world, pos, offsetFacing.getOpposite())) { + if (offsetFacing == facing.rotateYCCW()) { + return BlockStairs.EnumShape.OUTER_LEFT; + } + + return BlockStairs.EnumShape.OUTER_RIGHT; + } + } + + IBlockState oppositeOffsetState = world.getBlockState(pos.offset(facing.getOpposite())); + + if (isBlockStairs(oppositeOffsetState) && state.getValue(BlockStairs.HALF) == oppositeOffsetState.getValue(BlockStairs.HALF)) { + EnumFacing oppositeOffsetFacing = oppositeOffsetState.getValue(FACING); + + if (oppositeOffsetFacing.getAxis() != (state.getValue(FACING)).getAxis() && isDifferentStairs(state, world, pos, oppositeOffsetFacing)) { + if (oppositeOffsetFacing == facing.rotateYCCW()) { + return BlockStairs.EnumShape.INNER_LEFT; + } + + return BlockStairs.EnumShape.INNER_RIGHT; + } + } + + return BlockStairs.EnumShape.STRAIGHT; + } + + private static boolean isDifferentStairs(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing facing) { + IBlockState offsetState = world.getBlockState(pos.offset(facing)); + return !isBlockStairs(offsetState) || offsetState.getValue(FACING) != state.getValue(FACING) || offsetState.getValue(BlockStairs.HALF) != state.getValue(BlockStairs.HALF); + } + + public static boolean isBlockStairs(IBlockState state) { + return state.getBlock() instanceof BlockStairs || state.getBlock() instanceof BlockEnumStairs; + } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumWall.java b/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumWall.java index 321d75c5..325689e6 100644 --- a/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumWall.java +++ b/src/main/java/WayofTime/bloodmagic/block/base/BlockEnumWall.java @@ -16,94 +16,57 @@ import net.minecraft.world.IBlockAccess; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class BlockEnumWall & IStringSerializable> extends BlockEnum -{ +public class BlockEnumWall & IStringSerializable> extends BlockEnum { public static final PropertyBool UP = PropertyBool.create("up"); public static final PropertyBool NORTH = PropertyBool.create("north"); public static final PropertyBool EAST = PropertyBool.create("east"); public static final PropertyBool SOUTH = PropertyBool.create("south"); public static final PropertyBool WEST = PropertyBool.create("west"); - protected static final AxisAlignedBB[] AABB_BY_INDEX = new AxisAlignedBB[] { new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.3125D, 0.0D, 0.0D, 0.6875D, 0.875D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 1.0D), - new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.3125D, 1.0D, 0.875D, 0.6875D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D) }; - protected static final AxisAlignedBB[] CLIP_AABB_BY_INDEX = new AxisAlignedBB[] { AABB_BY_INDEX[0].setMaxY(1.5D), AABB_BY_INDEX[1].setMaxY(1.5D), AABB_BY_INDEX[2].setMaxY(1.5D), AABB_BY_INDEX[3].setMaxY(1.5D), AABB_BY_INDEX[4].setMaxY(1.5D), AABB_BY_INDEX[5].setMaxY(1.5D), AABB_BY_INDEX[6].setMaxY(1.5D), AABB_BY_INDEX[7].setMaxY(1.5D), AABB_BY_INDEX[8].setMaxY(1.5D), AABB_BY_INDEX[9].setMaxY(1.5D), AABB_BY_INDEX[10].setMaxY(1.5D), AABB_BY_INDEX[11].setMaxY(1.5D), AABB_BY_INDEX[12].setMaxY(1.5D), AABB_BY_INDEX[13].setMaxY(1.5D), AABB_BY_INDEX[14].setMaxY(1.5D), - AABB_BY_INDEX[15].setMaxY(1.5D) }; + protected static final AxisAlignedBB[] AABB_BY_INDEX = new AxisAlignedBB[]{new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.3125D, 0.0D, 0.0D, 0.6875D, 0.875D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 1.0D), + new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.3125D, 1.0D, 0.875D, 0.6875D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D)}; + protected static final AxisAlignedBB[] CLIP_AABB_BY_INDEX = new AxisAlignedBB[]{AABB_BY_INDEX[0].setMaxY(1.5D), AABB_BY_INDEX[1].setMaxY(1.5D), AABB_BY_INDEX[2].setMaxY(1.5D), AABB_BY_INDEX[3].setMaxY(1.5D), AABB_BY_INDEX[4].setMaxY(1.5D), AABB_BY_INDEX[5].setMaxY(1.5D), AABB_BY_INDEX[6].setMaxY(1.5D), AABB_BY_INDEX[7].setMaxY(1.5D), AABB_BY_INDEX[8].setMaxY(1.5D), AABB_BY_INDEX[9].setMaxY(1.5D), AABB_BY_INDEX[10].setMaxY(1.5D), AABB_BY_INDEX[11].setMaxY(1.5D), AABB_BY_INDEX[12].setMaxY(1.5D), AABB_BY_INDEX[13].setMaxY(1.5D), AABB_BY_INDEX[14].setMaxY(1.5D), + AABB_BY_INDEX[15].setMaxY(1.5D)}; // Most of this is copied from BlockWall - if there is an issue when porting, look there first. - public BlockEnumWall(Material material, Class enumClass, String propName) - { + public BlockEnumWall(Material material, Class enumClass, String propName) { super(material, enumClass, propName); } - public BlockEnumWall(Material material, Class enumClass) - { + public BlockEnumWall(Material material, Class enumClass) { this(material, enumClass, "type"); } @Override - protected BlockStateContainer createStateContainer() - { + protected BlockStateContainer createStateContainer() { return new BlockStateContainer.Builder(this).add(getProperty(), UP, NORTH, EAST, SOUTH, WEST).build(); } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { state = state.getActualState(source, pos); return AABB_BY_INDEX[getAABBIndex(state)]; } @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) - { + public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { blockState = blockState.getActualState(worldIn, pos); return CLIP_AABB_BY_INDEX[getAABBIndex(blockState)]; } - private static int getAABBIndex(IBlockState state) - { - int i = 0; - - if (state.getValue(NORTH)) - { - i |= 1 << EnumFacing.NORTH.getHorizontalIndex(); - } - - if (state.getValue(EAST)) - { - i |= 1 << EnumFacing.EAST.getHorizontalIndex(); - } - - if (state.getValue(SOUTH)) - { - i |= 1 << EnumFacing.SOUTH.getHorizontalIndex(); - } - - if (state.getValue(WEST)) - { - i |= 1 << EnumFacing.WEST.getHorizontalIndex(); - } - - return i; - } - - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } - public boolean isPassable(IBlockAccess worldIn, BlockPos pos) - { + public boolean isPassable(IBlockAccess worldIn, BlockPos pos) { return false; } @Override - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } - private boolean canConnectTo(IBlockAccess worldIn, BlockPos pos) - { + private boolean canConnectTo(IBlockAccess worldIn, BlockPos pos) { IBlockState worldState = worldIn.getBlockState(pos); Block block = worldState.getBlock(); return block != Blocks.BARRIER && (!(block != this && !(block instanceof BlockFenceGate)) || ((worldState.getMaterial().isOpaque() && worldState.isFullCube()) && worldState.getMaterial() != Material.GOURD)); @@ -111,14 +74,12 @@ public class BlockEnumWall & IStringSerializable> extends Bloc @SideOnly(Side.CLIENT) @Override - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) - { + public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { return side != EnumFacing.DOWN || super.shouldSideBeRendered(blockState, blockAccess, pos, side); } @Override - public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) - { + public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { boolean canNorth = this.canConnectTo(worldIn, pos.north()); boolean canEast = this.canConnectTo(worldIn, pos.east()); boolean canSouth = this.canConnectTo(worldIn, pos.south()); @@ -128,14 +89,34 @@ public class BlockEnumWall & IStringSerializable> extends Bloc } @Override - protected ItemStack getSilkTouchDrop(IBlockState state) - { + protected ItemStack getSilkTouchDrop(IBlockState state) { return new ItemStack(this, 1, damageDropped(state)); } @Override - public int damageDropped(IBlockState state) - { + public int damageDropped(IBlockState state) { return super.getMetaFromState(state); } + + private static int getAABBIndex(IBlockState state) { + int i = 0; + + if (state.getValue(NORTH)) { + i |= 1 << EnumFacing.NORTH.getHorizontalIndex(); + } + + if (state.getValue(EAST)) { + i |= 1 << EnumFacing.EAST.getHorizontalIndex(); + } + + if (state.getValue(SOUTH)) { + i |= 1 << EnumFacing.SOUTH.getHorizontalIndex(); + } + + if (state.getValue(WEST)) { + i |= 1 << EnumFacing.WEST.getHorizontalIndex(); + } + + return i; + } } diff --git a/src/main/java/WayofTime/bloodmagic/block/base/BlockInteger.java b/src/main/java/WayofTime/bloodmagic/block/base/BlockInteger.java index 1e3fcd0e..3e2a13f9 100644 --- a/src/main/java/WayofTime/bloodmagic/block/base/BlockInteger.java +++ b/src/main/java/WayofTime/bloodmagic/block/base/BlockInteger.java @@ -6,25 +6,20 @@ import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; /** * Creates a block that has multiple meta-based states. - * + *

* These states will be numbered 0 through {@code maxMeta}. */ -public class BlockInteger extends Block -{ +public class BlockInteger extends Block { private final int maxMeta; private final PropertyInteger property; private final BlockStateContainer realStateContainer; - public BlockInteger(Material material, int maxMeta, String propName) - { + public BlockInteger(Material material, int maxMeta, String propName) { super(material); this.maxMeta = maxMeta; @@ -33,8 +28,7 @@ public class BlockInteger extends Block setDefaultState(getBlockState().getBaseState()); } - public BlockInteger(Material material, int maxMeta) - { + public BlockInteger(Material material, int maxMeta) { this(material, maxMeta, "meta"); } diff --git a/src/main/java/WayofTime/bloodmagic/block/base/BlockString.java b/src/main/java/WayofTime/bloodmagic/block/base/BlockString.java index 9b989e9a..7afab9bd 100644 --- a/src/main/java/WayofTime/bloodmagic/block/base/BlockString.java +++ b/src/main/java/WayofTime/bloodmagic/block/base/BlockString.java @@ -1,13 +1,12 @@ package WayofTime.bloodmagic.block.base; +import WayofTime.bloodmagic.block.property.PropertyString; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import WayofTime.bloodmagic.block.property.PropertyString; import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -15,20 +14,18 @@ import org.apache.commons.lang3.ArrayUtils; /** * Creates a block that has multiple meta-based states. - * + *

* These states will be named after the given string array. Somewhere along the * way, each value is {@code toLowerCase()}'ed, so the blockstate JSON needs all * values to be lowercase. */ -public class BlockString extends Block -{ +public class BlockString extends Block { private final int maxMeta; private final String[] types; private final PropertyString property; private final BlockStateContainer realStateContainer; - public BlockString(Material material, String[] values, String propName) - { + public BlockString(Material material, String[] values, String propName) { super(material); this.maxMeta = values.length; @@ -39,51 +36,43 @@ public class BlockString extends Block setDefaultState(getBlockState().getBaseState()); } - public BlockString(Material material, String[] values) - { + public BlockString(Material material, String[] values) { this(material, values, "type"); } @Override - protected final BlockStateContainer createBlockState() - { + protected final BlockStateContainer createBlockState() { return new BlockStateContainer.Builder(this).build(); // Blank to avoid crashes } @Override - public final BlockStateContainer getBlockState() - { + public final BlockStateContainer getBlockState() { return realStateContainer; } @Override - public IBlockState getStateFromMeta(int meta) - { + public IBlockState getStateFromMeta(int meta) { return getDefaultState().withProperty(property, types[meta]); } @Override - public int getMetaFromState(IBlockState state) - { + public int getMetaFromState(IBlockState state) { return ArrayUtils.indexOf(types, state.getValue(property)); } @Override - public int damageDropped(IBlockState state) - { + public int damageDropped(IBlockState state) { return getMetaFromState(state); } @SideOnly(Side.CLIENT) @Override - public void getSubBlocks(CreativeTabs tab, NonNullList subBlocks) - { + public void getSubBlocks(CreativeTabs tab, NonNullList subBlocks) { for (int i = 0; i < maxMeta; i++) subBlocks.add(new ItemStack(this, 1, i)); } - protected BlockStateContainer createStateContainer() - { + protected BlockStateContainer createStateContainer() { System.out.println(""); BlockStateContainer ctn = new BlockStateContainer.Builder(this).add(property).build(); System.out.println("Number of states: " + ctn.getValidStates().size()); diff --git a/src/main/java/WayofTime/bloodmagic/block/enums/EnumBloodRune.java b/src/main/java/WayofTime/bloodmagic/block/enums/EnumBloodRune.java index 41221936..a9c04bd1 100644 --- a/src/main/java/WayofTime/bloodmagic/block/enums/EnumBloodRune.java +++ b/src/main/java/WayofTime/bloodmagic/block/enums/EnumBloodRune.java @@ -1,11 +1,10 @@ package WayofTime.bloodmagic.block.enums; -import java.util.Locale; - import net.minecraft.util.IStringSerializable; -public enum EnumBloodRune implements IStringSerializable -{ +import java.util.Locale; + +public enum EnumBloodRune implements IStringSerializable { BLANK, SPEED, EFFICIENCY, @@ -19,14 +18,12 @@ public enum EnumBloodRune implements IStringSerializable CHARGING; @Override - public String toString() - { + public String toString() { return name().toLowerCase(Locale.ENGLISH); } @Override - public String getName() - { + public String getName() { return this.toString(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/enums/EnumDecorative.java b/src/main/java/WayofTime/bloodmagic/block/enums/EnumDecorative.java index c9ae8947..d9cdcdff 100644 --- a/src/main/java/WayofTime/bloodmagic/block/enums/EnumDecorative.java +++ b/src/main/java/WayofTime/bloodmagic/block/enums/EnumDecorative.java @@ -1,26 +1,22 @@ package WayofTime.bloodmagic.block.enums; -import java.util.Locale; - import net.minecraft.util.IStringSerializable; -public enum EnumDecorative implements IStringSerializable -{ +import java.util.Locale; + +public enum EnumDecorative implements IStringSerializable { BLOODSTONE_TILE, BLOODSTONE_BRICK, CRYSTAL_TILE, - CRYSTAL_BRICK, - ; + CRYSTAL_BRICK,; @Override - public String toString() - { + public String toString() { return name().toLowerCase(Locale.ROOT); } @Override - public String getName() - { + public String getName() { return toString(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/enums/EnumDemonBlock1.java b/src/main/java/WayofTime/bloodmagic/block/enums/EnumDemonBlock1.java index 5d532c2c..84b42602 100644 --- a/src/main/java/WayofTime/bloodmagic/block/enums/EnumDemonBlock1.java +++ b/src/main/java/WayofTime/bloodmagic/block/enums/EnumDemonBlock1.java @@ -1,11 +1,10 @@ package WayofTime.bloodmagic.block.enums; -import java.util.Locale; - import net.minecraft.util.IStringSerializable; -public enum EnumDemonBlock1 implements IStringSerializable -{ +import java.util.Locale; + +public enum EnumDemonBlock1 implements IStringSerializable { BRICK1_RAW, BRICK1_CORROSIVE, BRICK1_DESTRUCTIVE, @@ -13,14 +12,12 @@ public enum EnumDemonBlock1 implements IStringSerializable BRICK1_STEADFAST; @Override - public String toString() - { + public String toString() { return name().toLowerCase(Locale.ENGLISH); } @Override - public String getName() - { + public String getName() { return this.toString(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/enums/EnumDemonBlock2.java b/src/main/java/WayofTime/bloodmagic/block/enums/EnumDemonBlock2.java index bd3407dc..b9a35aab 100644 --- a/src/main/java/WayofTime/bloodmagic/block/enums/EnumDemonBlock2.java +++ b/src/main/java/WayofTime/bloodmagic/block/enums/EnumDemonBlock2.java @@ -1,11 +1,10 @@ package WayofTime.bloodmagic.block.enums; -import java.util.Locale; - import net.minecraft.util.IStringSerializable; -public enum EnumDemonBlock2 implements IStringSerializable -{ +import java.util.Locale; + +public enum EnumDemonBlock2 implements IStringSerializable { SMALLBRICK_RAW, SMALLBRICK_CORROSIVE, SMALLBRICK_DESTRUCTIVE, @@ -23,14 +22,12 @@ public enum EnumDemonBlock2 implements IStringSerializable TILESPECIAL_STEADFAST; @Override - public String toString() - { + public String toString() { return name().toLowerCase(Locale.ENGLISH); } @Override - public String getName() - { + public String getName() { return this.toString(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/enums/EnumDemonBlock3.java b/src/main/java/WayofTime/bloodmagic/block/enums/EnumDemonBlock3.java index b76c9363..c7a54ac6 100644 --- a/src/main/java/WayofTime/bloodmagic/block/enums/EnumDemonBlock3.java +++ b/src/main/java/WayofTime/bloodmagic/block/enums/EnumDemonBlock3.java @@ -1,11 +1,10 @@ package WayofTime.bloodmagic.block.enums; -import java.util.Locale; - import net.minecraft.util.IStringSerializable; -public enum EnumDemonBlock3 implements IStringSerializable -{ +import java.util.Locale; + +public enum EnumDemonBlock3 implements IStringSerializable { STONE_RAW, STONE_CORROSIVE, STONE_DESTRUCTIVE, @@ -23,14 +22,12 @@ public enum EnumDemonBlock3 implements IStringSerializable METAL_STEADFAST; @Override - public String toString() - { + public String toString() { return name().toLowerCase(Locale.ENGLISH); } @Override - public String getName() - { + public String getName() { return this.toString(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/enums/EnumInversionCap.java b/src/main/java/WayofTime/bloodmagic/block/enums/EnumInversionCap.java index 3f13bf45..b760a46b 100644 --- a/src/main/java/WayofTime/bloodmagic/block/enums/EnumInversionCap.java +++ b/src/main/java/WayofTime/bloodmagic/block/enums/EnumInversionCap.java @@ -1,11 +1,10 @@ package WayofTime.bloodmagic.block.enums; -import java.util.Locale; - import net.minecraft.util.IStringSerializable; -public enum EnumInversionCap implements IStringSerializable -{ +import java.util.Locale; + +public enum EnumInversionCap implements IStringSerializable { RAW_BOTTOM, RAW_TOP, CORROSIVE_BOTTOM, @@ -18,14 +17,12 @@ public enum EnumInversionCap implements IStringSerializable STEADFAST_TOP; @Override - public String toString() - { + public String toString() { return name().toLowerCase(Locale.ENGLISH); } @Override - public String getName() - { + public String getName() { return this.toString(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/enums/EnumMimic.java b/src/main/java/WayofTime/bloodmagic/block/enums/EnumMimic.java index b933ff88..18e2053e 100644 --- a/src/main/java/WayofTime/bloodmagic/block/enums/EnumMimic.java +++ b/src/main/java/WayofTime/bloodmagic/block/enums/EnumMimic.java @@ -1,11 +1,10 @@ package WayofTime.bloodmagic.block.enums; -import java.util.Locale; - import net.minecraft.util.IStringSerializable; -public enum EnumMimic implements IStringSerializable -{ +import java.util.Locale; + +public enum EnumMimic implements IStringSerializable { NOHITBOX, SOLIDOPAQUE, SOLIDCLEAR, @@ -13,14 +12,12 @@ public enum EnumMimic implements IStringSerializable SENTIENT; @Override - public String toString() - { + public String toString() { return name().toLowerCase(Locale.ENGLISH); } @Override - public String getName() - { + public String getName() { return this.toString(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/enums/EnumPath.java b/src/main/java/WayofTime/bloodmagic/block/enums/EnumPath.java index 787bfc42..79c768bb 100644 --- a/src/main/java/WayofTime/bloodmagic/block/enums/EnumPath.java +++ b/src/main/java/WayofTime/bloodmagic/block/enums/EnumPath.java @@ -1,11 +1,10 @@ package WayofTime.bloodmagic.block.enums; -import java.util.Locale; - import net.minecraft.util.IStringSerializable; -public enum EnumPath implements IStringSerializable -{ +import java.util.Locale; + +public enum EnumPath implements IStringSerializable { WOOD, WOODTILE, STONE, @@ -16,14 +15,12 @@ public enum EnumPath implements IStringSerializable OBSIDIANTILE; @Override - public String toString() - { + public String toString() { return name().toLowerCase(Locale.ENGLISH); } @Override - public String getName() - { + public String getName() { return this.toString(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/enums/EnumRitualController.java b/src/main/java/WayofTime/bloodmagic/block/enums/EnumRitualController.java index 46250f3a..531ab6a2 100644 --- a/src/main/java/WayofTime/bloodmagic/block/enums/EnumRitualController.java +++ b/src/main/java/WayofTime/bloodmagic/block/enums/EnumRitualController.java @@ -1,25 +1,21 @@ package WayofTime.bloodmagic.block.enums; -import java.util.Locale; - import net.minecraft.util.IStringSerializable; -public enum EnumRitualController implements IStringSerializable -{ +import java.util.Locale; + +public enum EnumRitualController implements IStringSerializable { MASTER, IMPERFECT, - INVERTED, - ; + INVERTED,; @Override - public String toString() - { + public String toString() { return name().toLowerCase(Locale.ENGLISH); } @Override - public String getName() - { + public String getName() { return this.toString(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType.java b/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType.java index d42e974c..9f5f9c52 100644 --- a/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType.java +++ b/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType.java @@ -1,12 +1,11 @@ package WayofTime.bloodmagic.block.enums; -import java.util.Locale; - import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import net.minecraft.util.IStringSerializable; -public enum EnumSubWillType implements IStringSerializable -{ +import java.util.Locale; + +public enum EnumSubWillType implements IStringSerializable { RAW, CORROSIVE, DESTRUCTIVE, @@ -14,14 +13,12 @@ public enum EnumSubWillType implements IStringSerializable STEADFAST; @Override - public String toString() - { + public String toString() { return name().toLowerCase(Locale.ENGLISH); } @Override - public String getName() - { + public String getName() { return this.toString(); } diff --git a/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType1.java b/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType1.java index ede1ec40..4f51f8e8 100644 --- a/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType1.java +++ b/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType1.java @@ -1,23 +1,20 @@ package WayofTime.bloodmagic.block.enums; -import java.util.Locale; - import net.minecraft.util.IStringSerializable; -public enum EnumSubWillType1 implements IStringSerializable -{ +import java.util.Locale; + +public enum EnumSubWillType1 implements IStringSerializable { RAW, CORROSIVE; @Override - public String toString() - { + public String toString() { return name().toLowerCase(Locale.ENGLISH); } @Override - public String getName() - { + public String getName() { return this.toString(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType2.java b/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType2.java index ab1e7d10..5f1a6aca 100644 --- a/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType2.java +++ b/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType2.java @@ -1,23 +1,20 @@ package WayofTime.bloodmagic.block.enums; -import java.util.Locale; - import net.minecraft.util.IStringSerializable; -public enum EnumSubWillType2 implements IStringSerializable -{ +import java.util.Locale; + +public enum EnumSubWillType2 implements IStringSerializable { DESTRUCTIVE, VENGEFUL; @Override - public String toString() - { + public String toString() { return name().toLowerCase(Locale.ENGLISH); } @Override - public String getName() - { + public String getName() { return this.toString(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType3.java b/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType3.java index 63c17562..963704e8 100644 --- a/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType3.java +++ b/src/main/java/WayofTime/bloodmagic/block/enums/EnumSubWillType3.java @@ -1,22 +1,19 @@ package WayofTime.bloodmagic.block.enums; -import java.util.Locale; - import net.minecraft.util.IStringSerializable; -public enum EnumSubWillType3 implements IStringSerializable -{ +import java.util.Locale; + +public enum EnumSubWillType3 implements IStringSerializable { STEADFAST; @Override - public String toString() - { + public String toString() { return name().toLowerCase(Locale.ENGLISH); } @Override - public String getName() - { + public String getName() { return this.toString(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/enums/EnumWillWall.java b/src/main/java/WayofTime/bloodmagic/block/enums/EnumWillWall.java index 7d20db59..172c6d2b 100644 --- a/src/main/java/WayofTime/bloodmagic/block/enums/EnumWillWall.java +++ b/src/main/java/WayofTime/bloodmagic/block/enums/EnumWillWall.java @@ -1,11 +1,10 @@ package WayofTime.bloodmagic.block.enums; -import java.util.Locale; - import net.minecraft.util.IStringSerializable; -public enum EnumWillWall implements IStringSerializable -{ +import java.util.Locale; + +public enum EnumWillWall implements IStringSerializable { BRICK_RAW, BRICK_CORROSIVE, BRICK_DESTRUCTIVE, @@ -23,14 +22,12 @@ public enum EnumWillWall implements IStringSerializable LARGE_STEADFAST; @Override - public String toString() - { + public String toString() { return name().toLowerCase(Locale.ENGLISH); } @Override - public String getName() - { + public String getName() { return this.toString(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/property/PropertyString.java b/src/main/java/WayofTime/bloodmagic/block/property/PropertyString.java index 1fa570bc..1706dcb4 100644 --- a/src/main/java/WayofTime/bloodmagic/block/property/PropertyString.java +++ b/src/main/java/WayofTime/bloodmagic/block/property/PropertyString.java @@ -2,50 +2,40 @@ package WayofTime.bloodmagic.block.property; import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; import net.minecraft.block.properties.PropertyHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.Arrays; import java.util.Collection; -import java.util.HashSet; -public class PropertyString extends PropertyHelper -{ +public class PropertyString extends PropertyHelper { private final ImmutableSet allowedValues; - protected PropertyString(String name, String[] values) - { + protected PropertyString(String name, String[] values) { super(name, String.class); allowedValues = ImmutableSet.copyOf(values); } @SideOnly(Side.CLIENT) - public Optional parseValue(String value) - { + public Optional parseValue(String value) { return allowedValues.contains(value) ? Optional.of(value) : Optional.absent(); } - public static PropertyString create(String name, String[] values) - { - return new PropertyString(name, values); - } - @Override - public Collection getAllowedValues() - { + public Collection getAllowedValues() { return allowedValues; } - public String getName0(String value) - { + public String getName0(String value) { return value; } @Override - public String getName(String value) - { + public String getName(String value) { return this.getName0(value); } + + public static PropertyString create(String name, String[] values) { + return new PropertyString(name, values); + } } diff --git a/src/main/java/WayofTime/bloodmagic/client/IMeshProvider.java b/src/main/java/WayofTime/bloodmagic/client/IMeshProvider.java index ac10d288..d697da6f 100644 --- a/src/main/java/WayofTime/bloodmagic/client/IMeshProvider.java +++ b/src/main/java/WayofTime/bloodmagic/client/IMeshProvider.java @@ -12,11 +12,10 @@ import java.util.List; * Provides a custom {@link ItemMeshDefinition} for automatic registration of * renders. */ -public interface IMeshProvider -{ +public interface IMeshProvider { /** * Gets the custom ItemMeshDefinition to use for the item. - * + * * @return - the custom ItemMeshDefinition to use for the item. */ @SideOnly(Side.CLIENT) @@ -24,16 +23,16 @@ public interface IMeshProvider /** * Gets all possible variants for this item - * + * * @return - All possible variants for this item */ List getVariants(); /** * If a custom ResourceLocation is required, return it here. - * + *

* Can be null if unneeded. - * + * * @return - The custom ResourceLocation */ @Nullable diff --git a/src/main/java/WayofTime/bloodmagic/client/IVariantProvider.java b/src/main/java/WayofTime/bloodmagic/client/IVariantProvider.java index 18ba5fd0..c37d9958 100644 --- a/src/main/java/WayofTime/bloodmagic/client/IVariantProvider.java +++ b/src/main/java/WayofTime/bloodmagic/client/IVariantProvider.java @@ -4,7 +4,6 @@ import org.apache.commons.lang3.tuple.Pair; import java.util.List; -public interface IVariantProvider -{ +public interface IVariantProvider { List> getVariants(); } diff --git a/src/main/java/WayofTime/bloodmagic/client/gui/GuiAlchemyTable.java b/src/main/java/WayofTime/bloodmagic/client/gui/GuiAlchemyTable.java index 4c0d214f..8fe326dc 100644 --- a/src/main/java/WayofTime/bloodmagic/client/gui/GuiAlchemyTable.java +++ b/src/main/java/WayofTime/bloodmagic/client/gui/GuiAlchemyTable.java @@ -1,6 +1,9 @@ package WayofTime.bloodmagic.client.gui; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.tile.TileAlchemyTable; +import WayofTime.bloodmagic.tile.container.ContainerAlchemyTable; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.InventoryPlayer; @@ -9,17 +12,12 @@ import net.minecraft.inventory.Slot; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.tile.TileAlchemyTable; -import WayofTime.bloodmagic.tile.container.ContainerAlchemyTable; -import WayofTime.bloodmagic.util.helper.TextHelper; @SideOnly(Side.CLIENT) -public class GuiAlchemyTable extends GuiContainer -{ +public class GuiAlchemyTable extends GuiContainer { public IInventory tileTable; - public GuiAlchemyTable(InventoryPlayer playerInventory, IInventory tileTable) - { + public GuiAlchemyTable(InventoryPlayer playerInventory, IInventory tileTable) { super(new ContainerAlchemyTable(playerInventory, tileTable)); this.tileTable = tileTable; this.xSize = 176; @@ -27,15 +25,13 @@ public class GuiAlchemyTable extends GuiContainer } @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { this.fontRenderer.drawString(TextHelper.localize("tile.bloodmagic.alchemyTable.name"), 8, 5, 4210752); this.fontRenderer.drawString(TextHelper.localize("container.inventory"), 8, 111, 4210752); } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ResourceLocation soulForgeGuiTextures = new ResourceLocation(BloodMagic.MODID + ":textures/gui/alchemyTable.png"); this.mc.getTextureManager().bindTexture(soulForgeGuiTextures); @@ -46,10 +42,8 @@ public class GuiAlchemyTable extends GuiContainer int l = this.getCookProgressScaled(90); this.drawTexturedModalRect(i + 115, j + 14 + 90 - l, 176, 90 - l, 18, l); - for (int slotId = 0; slotId < 6; slotId++) - { - if (!((TileAlchemyTable) tileTable).isInputSlotAccessible(slotId)) - { + for (int slotId = 0; slotId < 6; slotId++) { + if (!((TileAlchemyTable) tileTable).isInputSlotAccessible(slotId)) { Slot slot = this.inventorySlots.getSlot(slotId); this.drawTexturedModalRect(i + slot.xPos, j + slot.yPos, 195, 1, 16, 16); @@ -57,8 +51,7 @@ public class GuiAlchemyTable extends GuiContainer } } - public int getCookProgressScaled(int scale) - { + public int getCookProgressScaled(int scale) { double progress = ((TileAlchemyTable) tileTable).getProgressForGui(); return (int) (progress * scale); } diff --git a/src/main/java/WayofTime/bloodmagic/client/gui/GuiHandler.java b/src/main/java/WayofTime/bloodmagic/client/gui/GuiHandler.java index e2ed6ef1..e2b95ea5 100644 --- a/src/main/java/WayofTime/bloodmagic/client/gui/GuiHandler.java +++ b/src/main/java/WayofTime/bloodmagic/client/gui/GuiHandler.java @@ -1,71 +1,61 @@ package WayofTime.bloodmagic.client.gui; +import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.item.inventory.ContainerHolding; import WayofTime.bloodmagic.item.inventory.InventoryHolding; +import WayofTime.bloodmagic.tile.TileAlchemyTable; +import WayofTime.bloodmagic.tile.TileSoulForge; +import WayofTime.bloodmagic.tile.TileTeleposer; +import WayofTime.bloodmagic.tile.container.*; +import WayofTime.bloodmagic.tile.routing.TileFilteredRoutingNode; +import WayofTime.bloodmagic.tile.routing.TileMasterRoutingNode; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.tile.TileAlchemyTable; -import WayofTime.bloodmagic.tile.TileSoulForge; -import WayofTime.bloodmagic.tile.TileTeleposer; -import WayofTime.bloodmagic.tile.container.ContainerAlchemyTable; -import WayofTime.bloodmagic.tile.container.ContainerItemRoutingNode; -import WayofTime.bloodmagic.tile.container.ContainerMasterRoutingNode; -import WayofTime.bloodmagic.tile.container.ContainerSoulForge; -import WayofTime.bloodmagic.tile.container.ContainerTeleposer; -import WayofTime.bloodmagic.tile.routing.TileFilteredRoutingNode; -import WayofTime.bloodmagic.tile.routing.TileMasterRoutingNode; -public class GuiHandler implements IGuiHandler -{ +public class GuiHandler implements IGuiHandler { @Override - public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) - { + public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { BlockPos pos = new BlockPos(x, y, z); - switch (id) - { - case Constants.Gui.TELEPOSER_GUI: - return new ContainerTeleposer(player.inventory, (TileTeleposer) world.getTileEntity(pos)); - case Constants.Gui.SOUL_FORGE_GUI: - return new ContainerSoulForge(player.inventory, (TileSoulForge) world.getTileEntity(pos)); - case Constants.Gui.ROUTING_NODE_GUI: - return new ContainerItemRoutingNode(player.inventory, (TileFilteredRoutingNode) world.getTileEntity(pos)); - case Constants.Gui.MASTER_ROUTING_NODE_GUI: - return new ContainerMasterRoutingNode(player.inventory, (TileMasterRoutingNode) world.getTileEntity(pos)); - case Constants.Gui.ALCHEMY_TABLE_GUI: - return new ContainerAlchemyTable(player.inventory, (TileAlchemyTable) world.getTileEntity(pos)); - case Constants.Gui.SIGIL_HOLDING_GUI: - return new ContainerHolding(player, new InventoryHolding(player.getHeldItemMainhand())); + switch (id) { + case Constants.Gui.TELEPOSER_GUI: + return new ContainerTeleposer(player.inventory, (TileTeleposer) world.getTileEntity(pos)); + case Constants.Gui.SOUL_FORGE_GUI: + return new ContainerSoulForge(player.inventory, (TileSoulForge) world.getTileEntity(pos)); + case Constants.Gui.ROUTING_NODE_GUI: + return new ContainerItemRoutingNode(player.inventory, (TileFilteredRoutingNode) world.getTileEntity(pos)); + case Constants.Gui.MASTER_ROUTING_NODE_GUI: + return new ContainerMasterRoutingNode(player.inventory, (TileMasterRoutingNode) world.getTileEntity(pos)); + case Constants.Gui.ALCHEMY_TABLE_GUI: + return new ContainerAlchemyTable(player.inventory, (TileAlchemyTable) world.getTileEntity(pos)); + case Constants.Gui.SIGIL_HOLDING_GUI: + return new ContainerHolding(player, new InventoryHolding(player.getHeldItemMainhand())); } return null; } @Override - public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) - { - if (world instanceof WorldClient) - { + public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { + if (world instanceof WorldClient) { BlockPos pos = new BlockPos(x, y, z); - switch (id) - { - case Constants.Gui.TELEPOSER_GUI: - return new GuiTeleposer(player.inventory, (TileTeleposer) world.getTileEntity(pos)); - case Constants.Gui.SOUL_FORGE_GUI: - return new GuiSoulForge(player.inventory, (TileSoulForge) world.getTileEntity(pos)); - case Constants.Gui.ROUTING_NODE_GUI: - return new GuiItemRoutingNode(player.inventory, (TileFilteredRoutingNode) world.getTileEntity(pos)); - case Constants.Gui.MASTER_ROUTING_NODE_GUI: - return new GuiMasterRoutingNode(player.inventory, (TileMasterRoutingNode) world.getTileEntity(pos)); - case Constants.Gui.ALCHEMY_TABLE_GUI: - return new GuiAlchemyTable(player.inventory, (TileAlchemyTable) world.getTileEntity(pos)); - case Constants.Gui.SIGIL_HOLDING_GUI: - return new GuiHolding(player, new InventoryHolding(player.getHeldItemMainhand())); + switch (id) { + case Constants.Gui.TELEPOSER_GUI: + return new GuiTeleposer(player.inventory, (TileTeleposer) world.getTileEntity(pos)); + case Constants.Gui.SOUL_FORGE_GUI: + return new GuiSoulForge(player.inventory, (TileSoulForge) world.getTileEntity(pos)); + case Constants.Gui.ROUTING_NODE_GUI: + return new GuiItemRoutingNode(player.inventory, (TileFilteredRoutingNode) world.getTileEntity(pos)); + case Constants.Gui.MASTER_ROUTING_NODE_GUI: + return new GuiMasterRoutingNode(player.inventory, (TileMasterRoutingNode) world.getTileEntity(pos)); + case Constants.Gui.ALCHEMY_TABLE_GUI: + return new GuiAlchemyTable(player.inventory, (TileAlchemyTable) world.getTileEntity(pos)); + case Constants.Gui.SIGIL_HOLDING_GUI: + return new GuiHolding(player, new InventoryHolding(player.getHeldItemMainhand())); } } diff --git a/src/main/java/WayofTime/bloodmagic/client/gui/GuiHolding.java b/src/main/java/WayofTime/bloodmagic/client/gui/GuiHolding.java index f68ef440..04ddecb4 100644 --- a/src/main/java/WayofTime/bloodmagic/client/gui/GuiHolding.java +++ b/src/main/java/WayofTime/bloodmagic/client/gui/GuiHolding.java @@ -1,10 +1,10 @@ package WayofTime.bloodmagic.client.gui; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import WayofTime.bloodmagic.item.inventory.ContainerHolding; import WayofTime.bloodmagic.item.inventory.InventoryHolding; import WayofTime.bloodmagic.item.sigil.ItemSigilHolding; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; @@ -14,13 +14,11 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiHolding extends GuiContainer -{ +public class GuiHolding extends GuiContainer { private ResourceLocation texture = new ResourceLocation(BloodMagic.MODID, "gui/SigilHolding.png"); private EntityPlayer player; - public GuiHolding(EntityPlayer player, InventoryHolding inventoryHolding) - { + public GuiHolding(EntityPlayer player, InventoryHolding inventoryHolding) { super(new ContainerHolding(player, inventoryHolding)); xSize = 176; ySize = 121; @@ -28,23 +26,20 @@ public class GuiHolding extends GuiContainer } @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { //the parameters for drawString are: string, x, y, color fontRenderer.drawString(TextHelper.localize("item.bloodmagic.sigil.holding.name"), 53, 4, 4210752); } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouse) - { + protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouse) { //draw your Gui here, only thing you need to change is the path GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(texture); int x = (width - xSize) / 2; int y = (height - ySize) / 2; this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - if (player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() == RegistrarBloodMagicItems.SIGIL_HOLDING) - { + if (player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() == RegistrarBloodMagicItems.SIGIL_HOLDING) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.drawTexturedModalRect(4 + x + 36 * ItemSigilHolding.getCurrentItemOrdinal(player.getHeldItemMainhand()), y + 13, 0, 123, 24, 24); } diff --git a/src/main/java/WayofTime/bloodmagic/client/gui/GuiItemRoutingNode.java b/src/main/java/WayofTime/bloodmagic/client/gui/GuiItemRoutingNode.java index 1f4d9a13..8c0a2bc2 100644 --- a/src/main/java/WayofTime/bloodmagic/client/gui/GuiItemRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/client/gui/GuiItemRoutingNode.java @@ -1,8 +1,12 @@ package WayofTime.bloodmagic.client.gui; -import java.io.IOException; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.network.BloodMagicPacketHandler; +import WayofTime.bloodmagic.network.ItemRouterAmountPacketProcessor; +import WayofTime.bloodmagic.network.ItemRouterButtonPacketProcessor; +import WayofTime.bloodmagic.tile.container.ContainerItemRoutingNode; +import WayofTime.bloodmagic.tile.routing.TileFilteredRoutingNode; +import WayofTime.bloodmagic.util.GhostItemHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; @@ -16,16 +20,11 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.network.BloodMagicPacketHandler; -import WayofTime.bloodmagic.network.ItemRouterAmountPacketProcessor; -import WayofTime.bloodmagic.network.ItemRouterButtonPacketProcessor; -import WayofTime.bloodmagic.tile.container.ContainerItemRoutingNode; -import WayofTime.bloodmagic.tile.routing.TileFilteredRoutingNode; -import WayofTime.bloodmagic.util.GhostItemHelper; + +import java.io.IOException; @SideOnly(Side.CLIENT) -public class GuiItemRoutingNode extends GuiContainer -{ +public class GuiItemRoutingNode extends GuiContainer { private GuiButton downButton; private GuiButton upButton; private GuiButton northButton; @@ -42,8 +41,7 @@ public class GuiItemRoutingNode extends GuiContainer private int left, top; - public GuiItemRoutingNode(InventoryPlayer playerInventory, IInventory tileRoutingNode) - { + public GuiItemRoutingNode(InventoryPlayer playerInventory, IInventory tileRoutingNode) { super(new ContainerItemRoutingNode(playerInventory, tileRoutingNode)); this.xSize = 201; this.ySize = 169; @@ -51,11 +49,9 @@ public class GuiItemRoutingNode extends GuiContainer container = (ContainerItemRoutingNode) this.inventorySlots; } - private int getCurrentActiveSlotPriority() - { + private int getCurrentActiveSlotPriority() { EnumFacing direction = EnumFacing.getFront(inventory.currentActiveSlot); - if (direction != null) - { + if (direction != null) { return inventory.getPriority(direction); } @@ -63,8 +59,7 @@ public class GuiItemRoutingNode extends GuiContainer } @Override - public void initGui() - { + public void initGui() { super.initGui(); left = (this.width - this.xSize) / 2; top = (this.height - this.ySize) / 2; @@ -86,41 +81,32 @@ public class GuiItemRoutingNode extends GuiContainer } @Override - protected void keyTyped(char typedChar, int keyCode) throws IOException - { - if (this.textBox.textboxKeyTyped(typedChar, keyCode)) - { - if (container.lastGhostSlotClicked != -1) - { + protected void keyTyped(char typedChar, int keyCode) throws IOException { + if (this.textBox.textboxKeyTyped(typedChar, keyCode)) { + if (container.lastGhostSlotClicked != -1) { // this.renameItem(); String str = this.textBox.getText(); int amount = 0; - if (!str.isEmpty()) - { - try - { + if (!str.isEmpty()) { + try { Integer testVal = Integer.decode(str); - if (testVal != null) - { + if (testVal != null) { amount = testVal.intValue(); } - } catch (NumberFormatException d) - { + } catch (NumberFormatException d) { } } // inventory.setGhostItemAmount(container.lastGhostSlotClicked, amount); setValueOfGhostItemInSlot(container.lastGhostSlotClicked, amount); } - } else - { + } else { super.keyTyped(typedChar, keyCode); } } - private void setValueOfGhostItemInSlot(int ghostItemSlot, int amount) - { + private void setValueOfGhostItemInSlot(int ghostItemSlot, int amount) { BloodMagicPacketHandler.INSTANCE.sendToServer(new ItemRouterAmountPacketProcessor(ghostItemSlot, amount, inventory.getPos(), inventory.getWorld())); } @@ -128,20 +114,16 @@ public class GuiItemRoutingNode extends GuiContainer * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton */ @Override - protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException - { + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); this.textBox.mouseClicked(mouseX, mouseY, mouseButton); - if (container.lastGhostSlotClicked != -1) - { + if (container.lastGhostSlotClicked != -1) { Slot slot = container.getSlot(container.lastGhostSlotClicked + 1); ItemStack stack = slot.getStack(); - if (stack != null) - { + if (stack != null) { int amount = GhostItemHelper.getItemGhostAmount(stack); this.textBox.setText("" + amount); - } else - { + } else { this.textBox.setText(""); } } @@ -151,8 +133,7 @@ public class GuiItemRoutingNode extends GuiContainer * Draws the screen and all the components in it. */ @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) - { + public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); Minecraft.getMinecraft().fontRenderer.drawString(inventory.getName(), xSize, ySize / 4, 4210752); @@ -163,13 +144,10 @@ public class GuiItemRoutingNode extends GuiContainer * for buttons) */ @Override - protected void actionPerformed(GuiButton button) throws IOException - { - if (button.enabled) - { + protected void actionPerformed(GuiButton button) throws IOException { + if (button.enabled) { BloodMagicPacketHandler.INSTANCE.sendToServer(new ItemRouterButtonPacketProcessor(button.id, inventory.getPos(), inventory.getWorld())); - if (button.id < 6) - { + if (button.id < 6) { inventory.currentActiveSlot = button.id; enableAllDirectionalButtons(); button.enabled = false; @@ -177,29 +155,23 @@ public class GuiItemRoutingNode extends GuiContainer } } - private void enableAllDirectionalButtons() - { - for (GuiButton button : this.buttonList) - { + private void enableAllDirectionalButtons() { + for (GuiButton button : this.buttonList) { button.enabled = true; } } - private void disableDirectionalButton(int id) - { + private void disableDirectionalButton(int id) { this.buttonList.get(id).enabled = false; } @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { this.fontRenderer.drawString("" + getCurrentActiveSlotPriority(), 143 + 5, 51 + 4, 0xFFFFFF); String s = ""; - if (container.lastGhostSlotClicked != -1) - { + if (container.lastGhostSlotClicked != -1) { ItemStack clickedStack = inventorySlots.getSlot(1 + container.lastGhostSlotClicked).getStack(); - if (clickedStack != null) - { + if (clickedStack != null) { s = clickedStack.getDisplayName(); } } @@ -208,8 +180,7 @@ public class GuiItemRoutingNode extends GuiContainer } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ResourceLocation soulForgeGuiTextures = new ResourceLocation(BloodMagic.MODID + ":textures/gui/routingNode.png"); this.mc.getTextureManager().bindTexture(soulForgeGuiTextures); diff --git a/src/main/java/WayofTime/bloodmagic/client/gui/GuiMasterRoutingNode.java b/src/main/java/WayofTime/bloodmagic/client/gui/GuiMasterRoutingNode.java index d8f0c3bb..dd49555e 100644 --- a/src/main/java/WayofTime/bloodmagic/client/gui/GuiMasterRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/client/gui/GuiMasterRoutingNode.java @@ -12,12 +12,10 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiMasterRoutingNode extends GuiContainer -{ +public class GuiMasterRoutingNode extends GuiContainer { private TileEntity inventory; - public GuiMasterRoutingNode(InventoryPlayer playerInventory, IInventory tileRoutingNode) - { + public GuiMasterRoutingNode(InventoryPlayer playerInventory, IInventory tileRoutingNode) { super(new ContainerMasterRoutingNode(playerInventory, tileRoutingNode)); this.xSize = 216; this.ySize = 216; @@ -25,15 +23,13 @@ public class GuiMasterRoutingNode extends GuiContainer } @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { // this.fontRendererObj.drawString(TextHelper.localize("tile.bloodmagic.soulForge.name"), 8, 5, 4210752); // this.fontRendererObj.drawString(TextHelper.localize("container.inventory"), 8, 111, 4210752); } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ResourceLocation soulForgeGuiTextures = new ResourceLocation(BloodMagic.MODID + ":textures/gui/masterRoutingNode.png"); this.mc.getTextureManager().bindTexture(soulForgeGuiTextures); diff --git a/src/main/java/WayofTime/bloodmagic/client/gui/GuiSoulForge.java b/src/main/java/WayofTime/bloodmagic/client/gui/GuiSoulForge.java index a383f96d..1d5ddf05 100644 --- a/src/main/java/WayofTime/bloodmagic/client/gui/GuiSoulForge.java +++ b/src/main/java/WayofTime/bloodmagic/client/gui/GuiSoulForge.java @@ -13,12 +13,10 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiSoulForge extends GuiContainer -{ +public class GuiSoulForge extends GuiContainer { public IInventory tileSoulForge; - public GuiSoulForge(InventoryPlayer playerInventory, IInventory tileSoulForge) - { + public GuiSoulForge(InventoryPlayer playerInventory, IInventory tileSoulForge) { super(new ContainerSoulForge(playerInventory, tileSoulForge)); this.tileSoulForge = tileSoulForge; this.xSize = 176; @@ -26,15 +24,13 @@ public class GuiSoulForge extends GuiContainer } @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { this.fontRenderer.drawString(TextHelper.localize("tile.bloodmagic.soulForge.name"), 8, 5, 4210752); this.fontRenderer.drawString(TextHelper.localize("container.inventory"), 8, 111, 4210752); } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ResourceLocation soulForgeGuiTextures = new ResourceLocation(BloodMagic.MODID + ":textures/gui/soulForge.png"); this.mc.getTextureManager().bindTexture(soulForgeGuiTextures); @@ -46,8 +42,7 @@ public class GuiSoulForge extends GuiContainer this.drawTexturedModalRect(i + 115, j + 14 + 90 - l, 176, 90 - l, 18, l); } - public int getCookProgressScaled(int scale) - { + public int getCookProgressScaled(int scale) { double progress = ((TileSoulForge) tileSoulForge).getProgressForGui(); return (int) (progress * scale); } diff --git a/src/main/java/WayofTime/bloodmagic/client/gui/GuiTeleposer.java b/src/main/java/WayofTime/bloodmagic/client/gui/GuiTeleposer.java index 2220e04b..828a0805 100644 --- a/src/main/java/WayofTime/bloodmagic/client/gui/GuiTeleposer.java +++ b/src/main/java/WayofTime/bloodmagic/client/gui/GuiTeleposer.java @@ -12,23 +12,19 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiTeleposer extends GuiContainer -{ - public GuiTeleposer(InventoryPlayer playerInventory, IInventory tileTeleposer) - { +public class GuiTeleposer extends GuiContainer { + public GuiTeleposer(InventoryPlayer playerInventory, IInventory tileTeleposer) { super(new ContainerTeleposer(playerInventory, tileTeleposer)); } @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { this.fontRenderer.drawString(TextHelper.localize("tile.bloodmagic.teleposer.name"), 64, 23, 4210752); this.fontRenderer.drawString(TextHelper.localize("container.inventory"), 8, 47, 4210752); } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ResourceLocation teleposerGuiTextures = new ResourceLocation(BloodMagic.MODID + ":textures/gui/teleposer.png"); this.mc.getTextureManager().bindTexture(teleposerGuiTextures); diff --git a/src/main/java/WayofTime/bloodmagic/client/gui/config/ConfigGui.java b/src/main/java/WayofTime/bloodmagic/client/gui/config/ConfigGui.java index c535ebd0..9013d8ea 100644 --- a/src/main/java/WayofTime/bloodmagic/client/gui/config/ConfigGui.java +++ b/src/main/java/WayofTime/bloodmagic/client/gui/config/ConfigGui.java @@ -10,17 +10,14 @@ import net.minecraftforge.fml.client.config.IConfigElement; import java.util.ArrayList; import java.util.List; -public class ConfigGui extends GuiConfig -{ +public class ConfigGui extends GuiConfig { - public ConfigGui(GuiScreen parentScreen) - { + public ConfigGui(GuiScreen parentScreen) { super(parentScreen, getConfigElements(parentScreen), BloodMagic.MODID, false, false, "BloodMagic Configuration"); } @SuppressWarnings("rawtypes") - private static List getConfigElements(GuiScreen parent) - { + private static List getConfigElements(GuiScreen parent) { List list = new ArrayList(); // adds sections declared in ConfigHandler. toLowerCase() is used diff --git a/src/main/java/WayofTime/bloodmagic/client/gui/config/ConfigGuiFactory.java b/src/main/java/WayofTime/bloodmagic/client/gui/config/ConfigGuiFactory.java index 8b2e4598..2f968574 100644 --- a/src/main/java/WayofTime/bloodmagic/client/gui/config/ConfigGuiFactory.java +++ b/src/main/java/WayofTime/bloodmagic/client/gui/config/ConfigGuiFactory.java @@ -6,8 +6,7 @@ import net.minecraftforge.fml.client.IModGuiFactory; import java.util.Set; -public class ConfigGuiFactory implements IModGuiFactory -{ +public class ConfigGuiFactory implements IModGuiFactory { @Override public void initialize(Minecraft minecraftInstance) { diff --git a/src/main/java/WayofTime/bloodmagic/client/helper/ShaderHelper.java b/src/main/java/WayofTime/bloodmagic/client/helper/ShaderHelper.java index 501958a6..a268d9f9 100644 --- a/src/main/java/WayofTime/bloodmagic/client/helper/ShaderHelper.java +++ b/src/main/java/WayofTime/bloodmagic/client/helper/ShaderHelper.java @@ -2,10 +2,10 @@ * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania - * + *

* Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * + *

* File Created @ [Apr 9, 2014, 11:20:26 PM (GMT)] */ package WayofTime.bloodmagic.client.helper; @@ -22,8 +22,7 @@ import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; -public final class ShaderHelper -{ +public final class ShaderHelper { private static final int VERT_ST = ARBVertexShader.GL_VERTEX_SHADER_ARB; private static final int FRAG_ST = ARBFragmentShader.GL_FRAGMENT_SHADER_ARB; @@ -35,40 +34,34 @@ public final class ShaderHelper public static int psiBar; - public static void init() - { + public static void init() { if (!useShaders()) return; psiBar = createProgram("/assets/bloodmagic/shaders/beam", FRAG); } - public static void useShader(int shader, int ticks) - { + public static void useShader(int shader, int ticks) { if (!useShaders()) return; ARBShaderObjects.glUseProgramObjectARB(shader); - if (shader != 0) - { + if (shader != 0) { int time = ARBShaderObjects.glGetUniformLocationARB(shader, "time"); ARBShaderObjects.glUniform1iARB(time, ticks); } } - public static void releaseShader() - { + public static void releaseShader() { useShader(0, 0); } - public static boolean useShaders() - { + public static boolean useShaders() { return OpenGlHelper.shadersSupported; } - private static int createProgram(String s, int sides) - { + private static int createProgram(String s, int sides) { boolean vert = (sides & VERT) != 0; boolean frag = (sides & FRAG) != 0; @@ -78,8 +71,7 @@ public final class ShaderHelper // Most of the code taken from the LWJGL wiki // http://lwjgl.org/wiki/index.php?title=GLSL_Shaders_with_LWJGL - private static int createProgram(String vert, String frag) - { + private static int createProgram(String vert, String frag) { int vertId = 0, fragId = 0, program = 0; if (vert != null) vertId = createShader(vert, VERT_ST); @@ -96,15 +88,13 @@ public final class ShaderHelper ARBShaderObjects.glAttachObjectARB(program, fragId); ARBShaderObjects.glLinkProgramARB(program); - if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) - { + if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) { FMLLog.log(Level.ERROR, getLogInfo(program)); return 0; } ARBShaderObjects.glValidateProgramARB(program); - if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) - { + if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) { FMLLog.log(Level.ERROR, getLogInfo(program)); return 0; } @@ -112,11 +102,9 @@ public final class ShaderHelper return program; } - private static int createShader(String filename, int shaderType) - { + private static int createShader(String filename, int shaderType) { int shader = 0; - try - { + try { shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType); if (shader == 0) @@ -129,21 +117,18 @@ public final class ShaderHelper throw new RuntimeException("Error creating shader: " + getLogInfo(shader)); return shader; - } catch (Exception e) - { + } catch (Exception e) { ARBShaderObjects.glDeleteObjectARB(shader); e.printStackTrace(); return -1; } } - private static String getLogInfo(int obj) - { + private static String getLogInfo(int obj) { return ARBShaderObjects.glGetInfoLogARB(obj, ARBShaderObjects.glGetObjectParameteriARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB)); } - private static String readFileAsString(String filename) throws Exception - { + private static String readFileAsString(String filename) throws Exception { StringBuilder source = new StringBuilder(); InputStream in = ShaderHelper.class.getResourceAsStream(filename); Exception exception = null; @@ -152,26 +137,20 @@ public final class ShaderHelper if (in == null) return ""; - try - { + try { reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); Exception innerExc = null; - try - { + try { String line; while ((line = reader.readLine()) != null) source.append(line).append('\n'); - } catch (Exception exc) - { + } catch (Exception exc) { exception = exc; - } finally - { - try - { + } finally { + try { reader.close(); - } catch (Exception exc) - { + } catch (Exception exc) { if (innerExc == null) innerExc = exc; else @@ -181,16 +160,12 @@ public final class ShaderHelper if (innerExc != null) throw innerExc; - } catch (Exception exc) - { + } catch (Exception exc) { exception = exc; - } finally - { - try - { + } finally { + try { in.close(); - } catch (Exception exc) - { + } catch (Exception exc) { if (exception == null) exception = exc; else diff --git a/src/main/java/WayofTime/bloodmagic/client/hud/HUDElement.java b/src/main/java/WayofTime/bloodmagic/client/hud/HUDElement.java index 7aea273b..c9a605a5 100644 --- a/src/main/java/WayofTime/bloodmagic/client/hud/HUDElement.java +++ b/src/main/java/WayofTime/bloodmagic/client/hud/HUDElement.java @@ -8,16 +8,14 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraftforge.client.event.RenderGameOverlayEvent; -public abstract class HUDElement -{ - private int xOffset; - private int yOffset; +public abstract class HUDElement { private final int xOffsetDefault; private final int yOffsetDefault; private final RenderGameOverlayEvent.ElementType elementType; + private int xOffset; + private int yOffset; - public HUDElement(int xOffset, int yOffset, RenderGameOverlayEvent.ElementType elementType) - { + public HUDElement(int xOffset, int yOffset, RenderGameOverlayEvent.ElementType elementType) { this.xOffset = xOffset; this.xOffsetDefault = xOffset; this.yOffset = yOffset; @@ -31,19 +29,16 @@ public abstract class HUDElement public abstract boolean shouldRender(Minecraft minecraft); - public void onPositionChanged() - { + public void onPositionChanged() { } - public void resetToDefault() - { + public void resetToDefault() { this.xOffset = xOffsetDefault; this.yOffset = yOffsetDefault; } - public void drawTexturedModalRect(double x, double y, double textureX, double textureY, double width, double height) - { + public void drawTexturedModalRect(double x, double y, double textureX, double textureY, double width, double height) { float f = 0.00390625F; float f1 = 0.00390625F; Tessellator tessellator = Tessellator.getInstance(); diff --git a/src/main/java/WayofTime/bloodmagic/client/hud/HUDElementDemonWillAura.java b/src/main/java/WayofTime/bloodmagic/client/hud/HUDElementDemonWillAura.java index f7f195e0..946b2ca0 100644 --- a/src/main/java/WayofTime/bloodmagic/client/hud/HUDElementDemonWillAura.java +++ b/src/main/java/WayofTime/bloodmagic/client/hud/HUDElementDemonWillAura.java @@ -1,25 +1,23 @@ package WayofTime.bloodmagic.client.hud; -import java.util.ArrayList; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.proxy.ClientProxy; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderGameOverlayEvent; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.proxy.ClientProxy; -import WayofTime.bloodmagic.util.Utils; -public class HUDElementDemonWillAura extends HUDElement -{ +import java.util.ArrayList; +import java.util.List; + +public class HUDElementDemonWillAura extends HUDElement { protected List barOrder = new ArrayList(); - public HUDElementDemonWillAura() - { + public HUDElementDemonWillAura() { super(5, 5, RenderGameOverlayEvent.ElementType.HOTBAR); barOrder.add(EnumDemonWillType.DEFAULT); @@ -30,12 +28,10 @@ public class HUDElementDemonWillAura extends HUDElement } @Override - public void render(Minecraft minecraft, ScaledResolution resolution, float partialTicks) - { + public void render(Minecraft minecraft, ScaledResolution resolution, float partialTicks) { EntityPlayer player = minecraft.player; - if (!Utils.canPlayerSeeDemonWill(player)) - { + if (!Utils.canPlayerSeeDemonWill(player)) { return; } @@ -46,8 +42,7 @@ public class HUDElementDemonWillAura extends HUDElement double maxAmount = Utils.getDemonWillResolution(player); int i = 0; - for (EnumDemonWillType type : barOrder) - { + for (EnumDemonWillType type : barOrder) { i++; GlStateManager.color(1.0F, 1.0F, 1.0F); minecraft.getTextureManager().bindTexture(new ResourceLocation(BloodMagic.MODID, "textures/hud/bars.png")); @@ -67,8 +62,7 @@ public class HUDElementDemonWillAura extends HUDElement this.drawTexturedModalRect(x, y, textureX, textureY, width, height); - if (player.isSneaking()) - { + if (player.isSneaking()) { GlStateManager.pushMatrix(); String value = "" + (int) amount; GlStateManager.translate(x - 2 * textureXOffset - value.length() * 0 + 70, (y - 1), 0); @@ -80,8 +74,7 @@ public class HUDElementDemonWillAura extends HUDElement } @Override - public boolean shouldRender(Minecraft minecraft) - { + public boolean shouldRender(Minecraft minecraft) { return true; } } diff --git a/src/main/java/WayofTime/bloodmagic/client/hud/HUDElementHolding.java b/src/main/java/WayofTime/bloodmagic/client/hud/HUDElementHolding.java index 9914bbf1..5524e074 100644 --- a/src/main/java/WayofTime/bloodmagic/client/hud/HUDElementHolding.java +++ b/src/main/java/WayofTime/bloodmagic/client/hud/HUDElementHolding.java @@ -1,8 +1,8 @@ package WayofTime.bloodmagic.client.hud; import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.item.sigil.ItemSigilHolding; import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.item.sigil.ItemSigilHolding; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; @@ -15,17 +15,14 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent; import java.util.List; -public class HUDElementHolding extends HUDElement -{ +public class HUDElementHolding extends HUDElement { - public HUDElementHolding() - { + public HUDElementHolding() { super(0, 0, RenderGameOverlayEvent.ElementType.HOTBAR); } @Override - public void render(Minecraft minecraft, ScaledResolution resolution, float partialTicks) - { + public void render(Minecraft minecraft, ScaledResolution resolution, float partialTicks) { ItemStack sigilHolding = minecraft.player.getHeldItemMainhand(); // Check mainhand for Sigil of Holding if (!(sigilHolding.getItem() == RegistrarBloodMagicItems.SIGIL_HOLDING)) @@ -45,8 +42,7 @@ public class HUDElementHolding extends HUDElement RenderHelper.enableGUIStandardItemLighting(); List holdingInv = ItemSigilHolding.getInternalInventory(sigilHolding); int xOffset = 0; - for (ItemStack sigil : holdingInv) - { + for (ItemStack sigil : holdingInv) { renderHotbarItem(resolution.getScaledWidth() / 2 + 103 + xOffset + getXOffset(), resolution.getScaledHeight() - 18 + getYOffset(), partialTicks, minecraft.player, sigil); xOffset += 20; } @@ -55,19 +51,15 @@ public class HUDElementHolding extends HUDElement } @Override - public boolean shouldRender(Minecraft minecraft) - { + public boolean shouldRender(Minecraft minecraft) { return true; } - protected void renderHotbarItem(int x, int y, float partialTicks, EntityPlayer player, ItemStack stack) - { - if (!stack.isEmpty()) - { + protected void renderHotbarItem(int x, int y, float partialTicks, EntityPlayer player, ItemStack stack) { + if (!stack.isEmpty()) { float animation = (float) stack.getAnimationsToGo() - partialTicks; - if (animation > 0.0F) - { + if (animation > 0.0F) { GlStateManager.pushMatrix(); float f1 = 1.0F + animation / 5.0F; GlStateManager.translate((float) (x + 8), (float) (y + 12), 0.0F); diff --git a/src/main/java/WayofTime/bloodmagic/client/key/IKeybindable.java b/src/main/java/WayofTime/bloodmagic/client/key/IKeybindable.java index f2b99fbc..c325019f 100644 --- a/src/main/java/WayofTime/bloodmagic/client/key/IKeybindable.java +++ b/src/main/java/WayofTime/bloodmagic/client/key/IKeybindable.java @@ -3,7 +3,6 @@ package WayofTime.bloodmagic.client.key; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -public interface IKeybindable -{ +public interface IKeybindable { void onKeyPressed(ItemStack stack, EntityPlayer player, KeyBindings key, boolean showInChat); } diff --git a/src/main/java/WayofTime/bloodmagic/client/key/KeyBindingBloodMagic.java b/src/main/java/WayofTime/bloodmagic/client/key/KeyBindingBloodMagic.java index 6d2ba73b..b1b18335 100644 --- a/src/main/java/WayofTime/bloodmagic/client/key/KeyBindingBloodMagic.java +++ b/src/main/java/WayofTime/bloodmagic/client/key/KeyBindingBloodMagic.java @@ -7,10 +7,8 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class KeyBindingBloodMagic extends KeyBinding -{ - public KeyBindingBloodMagic(KeyBindings key) - { +public class KeyBindingBloodMagic extends KeyBinding { + public KeyBindingBloodMagic(KeyBindings key) { super(key.getDescription(), key.getKeyConflictContext(), key.getKeyModifier(), key.getKeyCode(), BloodMagic.NAME); ClientRegistry.registerKeyBinding(this); diff --git a/src/main/java/WayofTime/bloodmagic/client/key/KeyBindings.java b/src/main/java/WayofTime/bloodmagic/client/key/KeyBindings.java index d10e0897..a9d8a8af 100644 --- a/src/main/java/WayofTime/bloodmagic/client/key/KeyBindings.java +++ b/src/main/java/WayofTime/bloodmagic/client/key/KeyBindings.java @@ -18,43 +18,35 @@ import org.lwjgl.input.Keyboard; import java.util.Locale; -public enum KeyBindings -{ +public enum KeyBindings { // @formatter:off - OPEN_HOLDING(KeyConflictContext.IN_GAME, KeyModifier.NONE, Keyboard.KEY_H) - { + OPEN_HOLDING(KeyConflictContext.IN_GAME, KeyModifier.NONE, Keyboard.KEY_H) { @SideOnly(Side.CLIENT) @Override - public void handleKeybind() - { + public void handleKeybind() { ItemStack itemStack = ClientHandler.minecraft.player.getHeldItemMainhand(); if (itemStack.getItem() instanceof IKeybindable) BloodMagicPacketHandler.INSTANCE.sendToServer(new KeyProcessor(this, false)); } }, - CYCLE_HOLDING_POS(KeyConflictContext.IN_GAME, KeyModifier.SHIFT, Keyboard.KEY_EQUALS) - { + CYCLE_HOLDING_POS(KeyConflictContext.IN_GAME, KeyModifier.SHIFT, Keyboard.KEY_EQUALS) { @SideOnly(Side.CLIENT) @Override - public void handleKeybind() - { + public void handleKeybind() { EntityPlayerSP player = Minecraft.getMinecraft().player; if (player.getHeldItemMainhand().getItem() instanceof ItemSigilHolding) ClientHandler.cycleSigil(player.getHeldItemMainhand(), player, -1); } }, - CYCLE_HOLDING_NEG(KeyConflictContext.IN_GAME, KeyModifier.SHIFT, Keyboard.KEY_MINUS) - { + CYCLE_HOLDING_NEG(KeyConflictContext.IN_GAME, KeyModifier.SHIFT, Keyboard.KEY_MINUS) { @SideOnly(Side.CLIENT) @Override - public void handleKeybind() - { + public void handleKeybind() { EntityPlayerSP player = Minecraft.getMinecraft().player; if (player.getHeldItemMainhand().getItem() instanceof ItemSigilHolding) ClientHandler.cycleSigil(player.getHeldItemMainhand(), player, 1); } - }, - ; + },; // @formatter:on private final IKeyConflictContext keyConflictContext; @@ -64,8 +56,7 @@ public enum KeyBindings @SideOnly(Side.CLIENT) private KeyBinding key; - KeyBindings(IKeyConflictContext keyConflictContext, KeyModifier keyModifier, int keyCode) - { + KeyBindings(IKeyConflictContext keyConflictContext, KeyModifier keyModifier, int keyCode) { this.keyConflictContext = keyConflictContext; this.keyModifier = keyModifier; this.keyCode = keyCode; @@ -74,24 +65,20 @@ public enum KeyBindings @SideOnly(Side.CLIENT) public abstract void handleKeybind(); - public IKeyConflictContext getKeyConflictContext() - { + public IKeyConflictContext getKeyConflictContext() { return keyConflictContext; } - public KeyModifier getKeyModifier() - { + public KeyModifier getKeyModifier() { return keyModifier; } - public int getKeyCode() - { + public int getKeyCode() { return keyCode; } @SideOnly(Side.CLIENT) - public KeyBinding getKey() - { + public KeyBinding getKey() { if (key == null) key = new KeyBindingBloodMagic(this); @@ -99,13 +86,11 @@ public enum KeyBindings } @SideOnly(Side.CLIENT) - public void setKey(KeyBinding key) - { + public void setKey(KeyBinding key) { this.key = key; } - public String getDescription() - { + public String getDescription() { return BloodMagic.MODID + ".keybind." + name().toLowerCase(Locale.ENGLISH); } } diff --git a/src/main/java/WayofTime/bloodmagic/client/mesh/CustomMeshDefinitionActivatable.java b/src/main/java/WayofTime/bloodmagic/client/mesh/CustomMeshDefinitionActivatable.java index add94841..f7576cd2 100644 --- a/src/main/java/WayofTime/bloodmagic/client/mesh/CustomMeshDefinitionActivatable.java +++ b/src/main/java/WayofTime/bloodmagic/client/mesh/CustomMeshDefinitionActivatable.java @@ -7,18 +7,15 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -public class CustomMeshDefinitionActivatable implements ItemMeshDefinition -{ +public class CustomMeshDefinitionActivatable implements ItemMeshDefinition { private final String name; - public CustomMeshDefinitionActivatable(String name) - { + public CustomMeshDefinitionActivatable(String name) { this.name = name; } @Override - public ModelResourceLocation getModelLocation(ItemStack stack) - { + public ModelResourceLocation getModelLocation(ItemStack stack) { if (!stack.isEmpty() && stack.getItem() instanceof IActivatable) if (((IActivatable) stack.getItem()).getActivated(stack)) return new ModelResourceLocation(new ResourceLocation(BloodMagic.MODID, "item/" + name), "active=true"); diff --git a/src/main/java/WayofTime/bloodmagic/client/mesh/CustomMeshDefinitionMultiWill.java b/src/main/java/WayofTime/bloodmagic/client/mesh/CustomMeshDefinitionMultiWill.java index 283f5358..57c5cd8f 100644 --- a/src/main/java/WayofTime/bloodmagic/client/mesh/CustomMeshDefinitionMultiWill.java +++ b/src/main/java/WayofTime/bloodmagic/client/mesh/CustomMeshDefinitionMultiWill.java @@ -1,27 +1,23 @@ package WayofTime.bloodmagic.client.mesh; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.iface.IMultiWillTool; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import WayofTime.bloodmagic.api.iface.IMultiWillTool; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -public class CustomMeshDefinitionMultiWill implements ItemMeshDefinition -{ +public class CustomMeshDefinitionMultiWill implements ItemMeshDefinition { private final String name; - public CustomMeshDefinitionMultiWill(String name) - { + public CustomMeshDefinitionMultiWill(String name) { this.name = name; } @Override - public ModelResourceLocation getModelLocation(ItemStack stack) - { - if (!stack.isEmpty() && stack.getItem() instanceof IMultiWillTool) - { + public ModelResourceLocation getModelLocation(ItemStack stack) { + if (!stack.isEmpty() && stack.getItem() instanceof IMultiWillTool) { EnumDemonWillType type = ((IMultiWillTool) stack.getItem()).getCurrentType(stack); return new ModelResourceLocation(new ResourceLocation(BloodMagic.MODID, "item/" + name), "type=" + type.getName().toLowerCase()); } diff --git a/src/main/java/WayofTime/bloodmagic/client/mesh/CustomMeshDefinitionWillGem.java b/src/main/java/WayofTime/bloodmagic/client/mesh/CustomMeshDefinitionWillGem.java index 45e4af99..907a6cea 100644 --- a/src/main/java/WayofTime/bloodmagic/client/mesh/CustomMeshDefinitionWillGem.java +++ b/src/main/java/WayofTime/bloodmagic/client/mesh/CustomMeshDefinitionWillGem.java @@ -1,28 +1,24 @@ package WayofTime.bloodmagic.client.mesh; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.item.soul.ItemSoulGem; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.item.soul.ItemSoulGem; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -public class CustomMeshDefinitionWillGem implements ItemMeshDefinition -{ +public class CustomMeshDefinitionWillGem implements ItemMeshDefinition { private final String name; - public CustomMeshDefinitionWillGem(String name) - { + public CustomMeshDefinitionWillGem(String name) { this.name = name; } @Override - public ModelResourceLocation getModelLocation(ItemStack stack) - { - if (!stack.isEmpty() && stack.getItem() == RegistrarBloodMagicItems.SOUL_GEM) - { + public ModelResourceLocation getModelLocation(ItemStack stack) { + if (!stack.isEmpty() && stack.getItem() == RegistrarBloodMagicItems.SOUL_GEM) { EnumDemonWillType type = ((ItemSoulGem) stack.getItem()).getCurrentType(stack); return new ModelResourceLocation(new ResourceLocation(BloodMagic.MODID, "item/" + name), "type=" + ItemSoulGem.names[stack.getItemDamage()] + "_" + type.getName().toLowerCase()); } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/LayerBloodElytra.java b/src/main/java/WayofTime/bloodmagic/client/render/LayerBloodElytra.java index 08186d3b..25a9d228 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/LayerBloodElytra.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/LayerBloodElytra.java @@ -13,26 +13,21 @@ import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -public class LayerBloodElytra implements LayerRenderer -{ +public class LayerBloodElytra implements LayerRenderer { private static final ResourceLocation TEXTURE_BLOOD_ELYTRA = new ResourceLocation("bloodmagic", "textures/entities/bloodElytra.png"); private final RenderPlayer renderPlayer; private final ModelElytra modelElytra = new ModelElytra(); - public LayerBloodElytra(RenderPlayer renderPlayer) - { + public LayerBloodElytra(RenderPlayer renderPlayer) { this.renderPlayer = renderPlayer; } @Override - public void doRenderLayer(AbstractClientPlayer clientPlayer, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) - { - if (LivingArmour.hasFullSet(clientPlayer)) - { + public void doRenderLayer(AbstractClientPlayer clientPlayer, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + if (LivingArmour.hasFullSet(clientPlayer)) { ItemStack chestStack = clientPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST); - if (ItemLivingArmour.hasUpgrade(BloodMagic.MODID + ".upgrade.elytra", chestStack)) - { + if (ItemLivingArmour.hasUpgrade(BloodMagic.MODID + ".upgrade.elytra", chestStack)) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.enableBlend(); @@ -52,8 +47,7 @@ public class LayerBloodElytra implements LayerRenderer } @Override - public boolean shouldCombineTextures() - { + public boolean shouldCombineTextures() { return false; } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/AttractorAlchemyCircleRenderer.java b/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/AttractorAlchemyCircleRenderer.java index b8af70c5..41fdcf94 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/AttractorAlchemyCircleRenderer.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/AttractorAlchemyCircleRenderer.java @@ -1,5 +1,7 @@ package WayofTime.bloodmagic.client.render.alchemyArray; +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer; +import WayofTime.bloodmagic.tile.TileAlchemyArray; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; @@ -8,33 +10,25 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer; -import WayofTime.bloodmagic.tile.TileAlchemyArray; -public class AttractorAlchemyCircleRenderer extends AlchemyCircleRenderer -{ - public AttractorAlchemyCircleRenderer() - { +public class AttractorAlchemyCircleRenderer extends AlchemyCircleRenderer { + public AttractorAlchemyCircleRenderer() { this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/ZombieBeacon.png")); } - public AttractorAlchemyCircleRenderer(ResourceLocation resourceLocation) - { + public AttractorAlchemyCircleRenderer(ResourceLocation resourceLocation) { super(resourceLocation); } @Override - public float getSizeModifier(float craftTime) - { + public float getSizeModifier(float craftTime) { return 1; } @Override - public float getRotation(float craftTime) - { + public float getRotation(float craftTime) { float offset = 2; - if (craftTime >= offset) - { + if (craftTime >= offset) { float modifier = (craftTime - offset) * 5f; return modifier * 1f; } @@ -42,18 +36,14 @@ public class AttractorAlchemyCircleRenderer extends AlchemyCircleRenderer } @Override - public float getSecondaryRotation(float craftTime) - { + public float getSecondaryRotation(float craftTime) { float offset = 50; float secondaryOffset = 150; - if (craftTime >= offset) - { - if (craftTime < secondaryOffset) - { + if (craftTime >= offset) { + if (craftTime < secondaryOffset) { float modifier = 90 * (craftTime - offset) / (secondaryOffset - offset); return modifier; - } else - { + } else { return 90; } } @@ -61,10 +51,8 @@ public class AttractorAlchemyCircleRenderer extends AlchemyCircleRenderer } @Override - public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) - { - if (!(tile instanceof TileAlchemyArray)) - { + public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) { + if (!(tile instanceof TileAlchemyArray)) { return; } @@ -95,30 +83,29 @@ public class AttractorAlchemyCircleRenderer extends AlchemyCircleRenderer GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace); - switch (sideHit) - { - case DOWN: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(-90.0f, 1, 0, 0); - break; - case EAST: - GlStateManager.rotate(-90.0f, 0, 1, 0); - GlStateManager.translate(0, 0, -1); - break; - case NORTH: - break; - case SOUTH: - GlStateManager.rotate(180.0f, 0, 1, 0); - GlStateManager.translate(-1, 0, -1); - break; - case UP: - GlStateManager.translate(0, 1, 0); - GlStateManager.rotate(90.0f, 1, 0, 0); - break; - case WEST: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(90.0f, 0, 1, 0); - break; + switch (sideHit) { + case DOWN: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(-90.0f, 1, 0, 0); + break; + case EAST: + GlStateManager.rotate(-90.0f, 0, 1, 0); + GlStateManager.translate(0, 0, -1); + break; + case NORTH: + break; + case SOUTH: + GlStateManager.rotate(180.0f, 0, 1, 0); + GlStateManager.translate(-1, 0, -1); + break; + case UP: + GlStateManager.translate(0, 1, 0); + GlStateManager.rotate(90.0f, 1, 0, 0); + break; + case WEST: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(90.0f, 0, 1, 0); + break; } GlStateManager.pushMatrix(); diff --git a/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/BindingAlchemyCircleRenderer.java b/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/BindingAlchemyCircleRenderer.java index 208ca594..2df29bc5 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/BindingAlchemyCircleRenderer.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/BindingAlchemyCircleRenderer.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.client.render.alchemyArray; +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; @@ -8,26 +9,19 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer; - -public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer -{ - public float offsetFromFace = -0.9f; - public final ResourceLocation[] arraysResources; +public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer { public static final int numberOfSweeps = 5; public static final int startTime = 50; public static final int sweepTime = 40; - public static final int inwardRotationTime = 50; - public static final float arcLength = (float) Math.sqrt(2 * (2 * 2) - 2 * 2 * 2 * Math.cos(2 * Math.PI * 2 / 5)); public static final float theta2 = (float) (18f * Math.PI / 180f); - public static final int endTime = 300; + public final ResourceLocation[] arraysResources; + public float offsetFromFace = -0.9f; - public BindingAlchemyCircleRenderer() - { + public BindingAlchemyCircleRenderer() { super(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingArray.png")); arraysResources = new ResourceLocation[5]; arraysResources[0] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png"); @@ -37,97 +31,33 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer arraysResources[4] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png"); } - public static float getAngleOfCircle(int circle, float craftTime) - { - if (circle >= 0 && circle <= 4) - { - float originalAngle = (float) (circle * 2 * Math.PI / 5d); - - double sweep = (craftTime - startTime) / sweepTime; - if (sweep >= 0 && sweep < numberOfSweeps) - { - float offset = ((int) sweep) * sweepTime + startTime; - originalAngle += 2 * Math.PI * 2 / 5 * (int) sweep + getAngle(craftTime - offset, (int) sweep); - } else if (sweep >= numberOfSweeps) - { - originalAngle += 2 * Math.PI * 2 / 5 * numberOfSweeps + (craftTime - 5 * sweepTime - startTime) * 2 * Math.PI * 2 / 5 / sweepTime; - } - - return originalAngle; - } - - return 0; - } - - public static float getAngle(float craftTime, int sweep) - { - float rDP = craftTime / sweepTime * arcLength; - float rEnd = (float) Math.sqrt(rDP * rDP + 2 * 2 - 2 * rDP * 2 * Math.cos(theta2)); - return (float) (Math.acos((2 * 2 + rEnd * rEnd - rDP * rDP) / (2 * rEnd * 2))); - } - - /** - * Returns the center-to-center distance of this circle. - */ - public static float getDistanceOfCircle(int circle, float craftTime) - { // TODO Change this so it doesn't use angle, since it is a constant speed. - double sweep = (craftTime - startTime) / sweepTime; - if (sweep >= 0 && sweep < numberOfSweeps) - { - float offset = ((int) sweep) * sweepTime + startTime; - float angle = getAngle(craftTime - offset, (int) sweep); - float thetaPrime = (float) (Math.PI - theta2 - angle); - // if(thetaPrime > 0 && thetaPrime < Math.PI) { - return (float) (2 * Math.sin(theta2) / Math.sin(thetaPrime)); - // } - } else if (sweep >= numberOfSweeps && craftTime < endTime) - { - return 2 - 2 * (craftTime - startTime - numberOfSweeps * sweepTime) / (endTime - startTime - numberOfSweeps * sweepTime); - } else if (craftTime >= endTime) - { - return 0; - } - - return 2; - } - - public float getRotation(int circle, float craftTime) - { + public float getRotation(int circle, float craftTime) { float offset = 2; - if (circle == -1) - { + if (circle == -1) { return craftTime * 360 * 2 / 5 / sweepTime; } - if (craftTime >= offset) - { + if (craftTime >= offset) { float modifier = (float) Math.pow(craftTime - offset, 1.5); return modifier * 0.5f; } return 0; } - public float getSecondaryRotation(int circle, float craftTime) - { + public float getSecondaryRotation(int circle, float craftTime) { float offset = 50; - if (craftTime >= offset) - { + if (craftTime >= offset) { float modifier = (float) Math.pow(craftTime - offset, 1.7); return modifier * 0.5f; } return 0; } - public float getVerticalOffset(int circle, float craftTime) - { - if (circle >= 0 && circle <= 4) - { - if (craftTime >= 5) - { - if (craftTime <= 40) - { + public float getVerticalOffset(int circle, float craftTime) { + if (circle >= 0 && circle <= 4) { + if (craftTime >= 5) { + if (craftTime <= 40) { return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3)); - } else - { + } else { return -0.4f; } } @@ -135,29 +65,22 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer return 0; } - if (craftTime >= 5) - { - if (craftTime <= 40) - { + if (craftTime >= 5) { + if (craftTime <= 40) { return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3)); - } else - { + } else { return -0.4f; } } return 0; } - public float getInwardRotation(int circle, float craftTime) - { + public float getInwardRotation(int circle, float craftTime) { float offset = startTime + numberOfSweeps * sweepTime; - if (craftTime >= offset) - { - if (craftTime <= offset + inwardRotationTime) - { + if (craftTime >= offset) { + if (craftTime <= offset + inwardRotationTime) { return 90f / inwardRotationTime * (craftTime - offset); - } else - { + } else { return 90; } } @@ -165,8 +88,7 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer return 0; } - public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) - { + public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder wr = tessellator.getBuffer(); @@ -189,30 +111,29 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer EnumFacing sideHit = EnumFacing.UP; GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace); - switch (sideHit) - { - case DOWN: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(-90.0f, 1, 0, 0); - break; - case EAST: - GlStateManager.rotate(-90.0f, 0, 1, 0); - GlStateManager.translate(0, 0, -1); - break; - case NORTH: - break; - case SOUTH: - GlStateManager.rotate(180.0f, 0, 1, 0); - GlStateManager.translate(-1, 0, -1); - break; - case UP: - GlStateManager.translate(0, 1, 0); - GlStateManager.rotate(90.0f, 1, 0, 0); - break; - case WEST: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(90.0f, 0, 1, 0); - break; + switch (sideHit) { + case DOWN: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(-90.0f, 1, 0, 0); + break; + case EAST: + GlStateManager.rotate(-90.0f, 0, 1, 0); + GlStateManager.translate(0, 0, -1); + break; + case NORTH: + break; + case SOUTH: + GlStateManager.rotate(180.0f, 0, 1, 0); + GlStateManager.translate(-1, 0, -1); + break; + case UP: + GlStateManager.translate(0, 1, 0); + GlStateManager.rotate(90.0f, 1, 0, 0); + break; + case WEST: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(90.0f, 0, 1, 0); + break; } GlStateManager.pushMatrix(); @@ -236,8 +157,7 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer tessellator.draw(); GlStateManager.popMatrix(); - for (int i = 0; i < 5; i++) - { + for (int i = 0; i < 5; i++) { GlStateManager.pushMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(arraysResources[i]); float newSize = 1; @@ -268,4 +188,49 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer GlStateManager.popMatrix(); } + + public static float getAngleOfCircle(int circle, float craftTime) { + if (circle >= 0 && circle <= 4) { + float originalAngle = (float) (circle * 2 * Math.PI / 5d); + + double sweep = (craftTime - startTime) / sweepTime; + if (sweep >= 0 && sweep < numberOfSweeps) { + float offset = ((int) sweep) * sweepTime + startTime; + originalAngle += 2 * Math.PI * 2 / 5 * (int) sweep + getAngle(craftTime - offset, (int) sweep); + } else if (sweep >= numberOfSweeps) { + originalAngle += 2 * Math.PI * 2 / 5 * numberOfSweeps + (craftTime - 5 * sweepTime - startTime) * 2 * Math.PI * 2 / 5 / sweepTime; + } + + return originalAngle; + } + + return 0; + } + + public static float getAngle(float craftTime, int sweep) { + float rDP = craftTime / sweepTime * arcLength; + float rEnd = (float) Math.sqrt(rDP * rDP + 2 * 2 - 2 * rDP * 2 * Math.cos(theta2)); + return (float) (Math.acos((2 * 2 + rEnd * rEnd - rDP * rDP) / (2 * rEnd * 2))); + } + + /** + * Returns the center-to-center distance of this circle. + */ + public static float getDistanceOfCircle(int circle, float craftTime) { // TODO Change this so it doesn't use angle, since it is a constant speed. + double sweep = (craftTime - startTime) / sweepTime; + if (sweep >= 0 && sweep < numberOfSweeps) { + float offset = ((int) sweep) * sweepTime + startTime; + float angle = getAngle(craftTime - offset, (int) sweep); + float thetaPrime = (float) (Math.PI - theta2 - angle); + // if(thetaPrime > 0 && thetaPrime < Math.PI) { + return (float) (2 * Math.sin(theta2) / Math.sin(thetaPrime)); + // } + } else if (sweep >= numberOfSweeps && craftTime < endTime) { + return 2 - 2 * (craftTime - startTime - numberOfSweeps * sweepTime) / (endTime - startTime - numberOfSweeps * sweepTime); + } else if (craftTime >= endTime) { + return 0; + } + + return 2; + } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/DualAlchemyCircleRenderer.java b/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/DualAlchemyCircleRenderer.java index f9d62120..4e334205 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/DualAlchemyCircleRenderer.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/DualAlchemyCircleRenderer.java @@ -1,5 +1,7 @@ package WayofTime.bloodmagic.client.render.alchemyArray; +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer; +import WayofTime.bloodmagic.tile.TileAlchemyArray; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; @@ -8,37 +10,29 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer; -import WayofTime.bloodmagic.tile.TileAlchemyArray; -public class DualAlchemyCircleRenderer extends AlchemyCircleRenderer -{ - public float offsetFromFace = -0.9f; +public class DualAlchemyCircleRenderer extends AlchemyCircleRenderer { public final ResourceLocation secondaryArrayResource; + public float offsetFromFace = -0.9f; - public DualAlchemyCircleRenderer() - { + public DualAlchemyCircleRenderer() { this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SkeletonTurret1.png"), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SkeletonTurret2.png")); } - public DualAlchemyCircleRenderer(ResourceLocation arrayResource, ResourceLocation secondaryArrayResource) - { + public DualAlchemyCircleRenderer(ResourceLocation arrayResource, ResourceLocation secondaryArrayResource) { super(arrayResource); this.secondaryArrayResource = secondaryArrayResource; } @Override - public float getSizeModifier(float craftTime) - { + public float getSizeModifier(float craftTime) { return 1; } @Override - public float getRotation(float craftTime) - { + public float getRotation(float craftTime) { float offset = 2; - if (craftTime >= offset) - { + if (craftTime >= offset) { float modifier = (craftTime - offset) * 2f; return modifier * 1f; } @@ -46,10 +40,8 @@ public class DualAlchemyCircleRenderer extends AlchemyCircleRenderer } @Override - public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) - { - if (!(tile instanceof TileAlchemyArray)) - { + public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) { + if (!(tile instanceof TileAlchemyArray)) { return; } @@ -77,30 +69,29 @@ public class DualAlchemyCircleRenderer extends AlchemyCircleRenderer GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace); - switch (sideHit) - { - case DOWN: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(-90.0f, 1, 0, 0); - break; - case EAST: - GlStateManager.rotate(-90.0f, 0, 1, 0); - GlStateManager.translate(0, 0, -1); - break; - case NORTH: - break; - case SOUTH: - GlStateManager.rotate(180.0f, 0, 1, 0); - GlStateManager.translate(-1, 0, -1); - break; - case UP: - GlStateManager.translate(0, 1, 0); - GlStateManager.rotate(90.0f, 1, 0, 0); - break; - case WEST: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(90.0f, 0, 1, 0); - break; + switch (sideHit) { + case DOWN: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(-90.0f, 1, 0, 0); + break; + case EAST: + GlStateManager.rotate(-90.0f, 0, 1, 0); + GlStateManager.translate(0, 0, -1); + break; + case NORTH: + break; + case SOUTH: + GlStateManager.rotate(180.0f, 0, 1, 0); + GlStateManager.translate(-1, 0, -1); + break; + case UP: + GlStateManager.translate(0, 1, 0); + GlStateManager.rotate(90.0f, 1, 0, 0); + break; + case WEST: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(90.0f, 0, 1, 0); + break; } GlStateManager.pushMatrix(); diff --git a/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/SingleAlchemyCircleRenderer.java b/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/SingleAlchemyCircleRenderer.java index b4c2059c..3bd566f0 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/SingleAlchemyCircleRenderer.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/SingleAlchemyCircleRenderer.java @@ -1,5 +1,7 @@ package WayofTime.bloodmagic.client.render.alchemyArray; +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer; +import WayofTime.bloodmagic.tile.TileAlchemyArray; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; @@ -8,35 +10,27 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer; -import WayofTime.bloodmagic.tile.TileAlchemyArray; -public class SingleAlchemyCircleRenderer extends AlchemyCircleRenderer -{ +public class SingleAlchemyCircleRenderer extends AlchemyCircleRenderer { public float offsetFromFace = -0.9f; - public SingleAlchemyCircleRenderer() - { + public SingleAlchemyCircleRenderer() { this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SkeletonTurret1.png")); } - public SingleAlchemyCircleRenderer(ResourceLocation arrayResource) - { + public SingleAlchemyCircleRenderer(ResourceLocation arrayResource) { super(arrayResource); } @Override - public float getSizeModifier(float craftTime) - { + public float getSizeModifier(float craftTime) { return 1; } @Override - public float getRotation(float craftTime) - { + public float getRotation(float craftTime) { float offset = 2; - if (craftTime >= offset) - { + if (craftTime >= offset) { float modifier = (craftTime - offset) * 2f; return modifier * 1f; } @@ -44,10 +38,8 @@ public class SingleAlchemyCircleRenderer extends AlchemyCircleRenderer } @Override - public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) - { - if (!(tile instanceof TileAlchemyArray)) - { + public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) { + if (!(tile instanceof TileAlchemyArray)) { return; } @@ -75,30 +67,29 @@ public class SingleAlchemyCircleRenderer extends AlchemyCircleRenderer GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace); - switch (sideHit) - { - case DOWN: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(-90.0f, 1, 0, 0); - break; - case EAST: - GlStateManager.rotate(-90.0f, 0, 1, 0); - GlStateManager.translate(0, 0, -1); - break; - case NORTH: - break; - case SOUTH: - GlStateManager.rotate(180.0f, 0, 1, 0); - GlStateManager.translate(-1, 0, -1); - break; - case UP: - GlStateManager.translate(0, 1, 0); - GlStateManager.rotate(90.0f, 1, 0, 0); - break; - case WEST: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(90.0f, 0, 1, 0); - break; + switch (sideHit) { + case DOWN: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(-90.0f, 1, 0, 0); + break; + case EAST: + GlStateManager.rotate(-90.0f, 0, 1, 0); + GlStateManager.translate(0, 0, -1); + break; + case NORTH: + break; + case SOUTH: + GlStateManager.rotate(180.0f, 0, 1, 0); + GlStateManager.translate(-1, 0, -1); + break; + case UP: + GlStateManager.translate(0, 1, 0); + GlStateManager.rotate(90.0f, 1, 0, 0); + break; + case WEST: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(90.0f, 0, 1, 0); + break; } GlStateManager.pushMatrix(); diff --git a/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/StaticAlchemyCircleRenderer.java b/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/StaticAlchemyCircleRenderer.java index ea243639..5e3e3ff5 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/StaticAlchemyCircleRenderer.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/StaticAlchemyCircleRenderer.java @@ -1,5 +1,7 @@ package WayofTime.bloodmagic.client.render.alchemyArray; +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer; +import WayofTime.bloodmagic.tile.TileAlchemyArray; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; @@ -8,33 +10,25 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer; -import WayofTime.bloodmagic.tile.TileAlchemyArray; -public class StaticAlchemyCircleRenderer extends AlchemyCircleRenderer -{ - public StaticAlchemyCircleRenderer(ResourceLocation location) - { +public class StaticAlchemyCircleRenderer extends AlchemyCircleRenderer { + public StaticAlchemyCircleRenderer(ResourceLocation location) { super(location); } - public StaticAlchemyCircleRenderer() - { + public StaticAlchemyCircleRenderer() { this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/MovementArray.png")); } @Override - public float getSizeModifier(float craftTime) - { + public float getSizeModifier(float craftTime) { return 1; } @Override - public float getRotation(float craftTime) - { + public float getRotation(float craftTime) { float offset = 50; - if (craftTime >= offset) - { + if (craftTime >= offset) { float modifier = (craftTime - offset) * 5f; return modifier * 1f; } @@ -42,16 +36,13 @@ public class StaticAlchemyCircleRenderer extends AlchemyCircleRenderer } @Override - public float getSecondaryRotation(float craftTime) - { + public float getSecondaryRotation(float craftTime) { return 0; } @Override - public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) - { - if (!(tile instanceof TileAlchemyArray)) - { + public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) { + if (!(tile instanceof TileAlchemyArray)) { return; } @@ -81,30 +72,29 @@ public class StaticAlchemyCircleRenderer extends AlchemyCircleRenderer GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace); - switch (sideHit) - { - case DOWN: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(-90.0f, 1, 0, 0); - break; - case EAST: - GlStateManager.rotate(-90.0f, 0, 1, 0); - GlStateManager.translate(0, 0, -1); - break; - case NORTH: - break; - case SOUTH: - GlStateManager.rotate(180.0f, 0, 1, 0); - GlStateManager.translate(-1, 0, -1); - break; - case UP: - GlStateManager.translate(0, 1, 0); - GlStateManager.rotate(90.0f, 1, 0, 0); - break; - case WEST: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(90.0f, 0, 1, 0); - break; + switch (sideHit) { + case DOWN: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(-90.0f, 1, 0, 0); + break; + case EAST: + GlStateManager.rotate(-90.0f, 0, 1, 0); + GlStateManager.translate(0, 0, -1); + break; + case NORTH: + break; + case SOUTH: + GlStateManager.rotate(180.0f, 0, 1, 0); + GlStateManager.translate(-1, 0, -1); + break; + case UP: + GlStateManager.translate(0, 1, 0); + GlStateManager.rotate(90.0f, 1, 0, 0); + break; + case WEST: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(90.0f, 0, 1, 0); + break; } GlStateManager.pushMatrix(); diff --git a/src/main/java/WayofTime/bloodmagic/client/render/block/RenderAlchemyArray.java b/src/main/java/WayofTime/bloodmagic/client/render/block/RenderAlchemyArray.java index 61e4d563..13700c19 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/block/RenderAlchemyArray.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/block/RenderAlchemyArray.java @@ -6,11 +6,9 @@ import WayofTime.bloodmagic.tile.TileAlchemyArray; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.item.ItemStack; -public class RenderAlchemyArray extends TileEntitySpecialRenderer -{ +public class RenderAlchemyArray extends TileEntitySpecialRenderer { @Override - public void render(TileAlchemyArray alchemyArray, double x, double y, double z, float partialTicks, int destroyStage, float alpha) - { + public void render(TileAlchemyArray alchemyArray, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { ItemStack inputStack = alchemyArray.getStackInSlot(0); ItemStack catalystStack = alchemyArray.getStackInSlot(1); int craftTime = alchemyArray.activeCounter; diff --git a/src/main/java/WayofTime/bloodmagic/client/render/block/RenderAltar.java b/src/main/java/WayofTime/bloodmagic/client/render/block/RenderAltar.java index e51545d7..b471e4f4 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/block/RenderAltar.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/block/RenderAltar.java @@ -22,16 +22,14 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11; -public class RenderAltar extends TileEntitySpecialRenderer -{ +public class RenderAltar extends TileEntitySpecialRenderer { public static Minecraft mc = Minecraft.getMinecraft(); public static ResourceLocation resource = new ResourceLocation("bloodmagic", "textures/blocks/lifeEssenceStill.png"); public static float minHeight = 0.499f; public static float maxHeight = 0.745f; @Override - public void render(TileAltar tileAltar, double x, double y, double z, float partialTicks, int destroyStage, float alpha) - { + public void render(TileAltar tileAltar, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { ItemStack inputStack = tileAltar.getStackInSlot(0); float level = ((float) tileAltar.getCurrentBlood()) / (float) tileAltar.getCapacity(); @@ -43,14 +41,12 @@ public class RenderAltar extends TileEntitySpecialRenderer this.renderItem(tileAltar.getWorld(), inputStack); GlStateManager.popMatrix(); - if (tileAltar.getCurrentTierDisplayed() != EnumAltarTier.ONE) - { + if (tileAltar.getCurrentTierDisplayed() != EnumAltarTier.ONE) { renderHologram(tileAltar, tileAltar.getCurrentTierDisplayed(), partialTicks); } } - private void renderFluid(World world, float fluidLevel) - { + private void renderFluid(World world, float fluidLevel) { GlStateManager.pushMatrix(); Fluid fluid = BlockLifeEssence.getLifeEssence(); @@ -86,20 +82,9 @@ public class RenderAltar extends TileEntitySpecialRenderer GlStateManager.popMatrix(); } - private static void setGLColorFromInt(int color) - { - float red = (color >> 16 & 0xFF) / 255.0F; - float green = (color >> 8 & 0xFF) / 255.0F; - float blue = (color & 0xFF) / 255.0F; - - GlStateManager.color(red, green, blue, 1.0F); - } - - private void renderItem(World world, ItemStack stack) - { + private void renderItem(World world, ItemStack stack) { RenderItem itemRenderer = mc.getRenderItem(); - if (!stack.isEmpty()) - { + if (!stack.isEmpty()) { GlStateManager.translate(0.5, 1, 0.5); EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, stack); entityitem.getItem().setCount(1); @@ -122,8 +107,7 @@ public class RenderAltar extends TileEntitySpecialRenderer } } - private void renderHologram(TileAltar altar, EnumAltarTier tier, float partialTicks) - { + private void renderHologram(TileAltar altar, EnumAltarTier tier, float partialTicks) { EntityPlayerSP player = mc.player; World world = player.world; @@ -141,37 +125,34 @@ public class RenderAltar extends TileEntitySpecialRenderer double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks; double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks; - for (AltarComponent altarComponent : tier.getAltarComponents()) - { + for (AltarComponent altarComponent : tier.getAltarComponents()) { vX = vec3.add(altarComponent.getOffset()); double minX = vX.getX() - posX; double minY = vX.getY() - posY; double minZ = vX.getZ() - posZ; - if (!world.getBlockState(vX).isOpaqueCube()) - { + if (!world.getBlockState(vX).isOpaqueCube()) { TextureAtlasSprite texture = null; - switch (altarComponent.getComponent()) - { - case BLOODRUNE: - texture = ClientHandler.blankBloodRune; - break; - case NOTAIR: - texture = ClientHandler.stoneBrick; - break; - case GLOWSTONE: - texture = ClientHandler.glowstone; - break; - case BLOODSTONE: - texture = ClientHandler.bloodStoneBrick; - break; - case BEACON: - texture = ClientHandler.beacon; - break; - case CRYSTAL: - texture = ClientHandler.crystalCluster; - break; + switch (altarComponent.getComponent()) { + case BLOODRUNE: + texture = ClientHandler.blankBloodRune; + break; + case NOTAIR: + texture = ClientHandler.stoneBrick; + break; + case GLOWSTONE: + texture = ClientHandler.glowstone; + break; + case BLOODSTONE: + texture = ClientHandler.bloodStoneBrick; + break; + case BEACON: + texture = ClientHandler.beacon; + break; + case CRYSTAL: + texture = ClientHandler.crystalCluster; + break; } RenderFakeBlocks.drawFakeBlock(texture, minX, minY, minZ); @@ -180,4 +161,12 @@ public class RenderAltar extends TileEntitySpecialRenderer GlStateManager.popMatrix(); } + + private static void setGLColorFromInt(int color) { + float red = (color >> 16 & 0xFF) / 255.0F; + float green = (color >> 8 & 0xFF) / 255.0F; + float blue = (color & 0xFF) / 255.0F; + + GlStateManager.color(red, green, blue, 1.0F); + } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/block/RenderBloodTank.java b/src/main/java/WayofTime/bloodmagic/client/render/block/RenderBloodTank.java index 844d41ce..235fb836 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/block/RenderBloodTank.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/block/RenderBloodTank.java @@ -16,13 +16,11 @@ import net.minecraftforge.fml.relauncher.SideOnly; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class RenderBloodTank extends TileEntitySpecialRenderer -{ +public class RenderBloodTank extends TileEntitySpecialRenderer { private static final Minecraft mc = Minecraft.getMinecraft(); @Override - public void render(TileBloodTank bloodTank, double x, double y, double z, float partialTicks, int destroyStage, float alpha) - { + public void render(TileBloodTank bloodTank, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { if (bloodTank == null) return; @@ -39,8 +37,7 @@ public class RenderBloodTank extends TileEntitySpecialRenderer GlStateManager.popMatrix(); } - public void renderFluid(float maxHeight, Fluid renderFluid, double x, double y, double z) - { + public void renderFluid(float maxHeight, Fluid renderFluid, double x, double y, double z) { maxHeight = maxHeight * 0.575F; GlStateManager.translate(x, y, z); diff --git a/src/main/java/WayofTime/bloodmagic/client/render/block/RenderDemonCrucible.java b/src/main/java/WayofTime/bloodmagic/client/render/block/RenderDemonCrucible.java index 9b7ed869..439b9618 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/block/RenderDemonCrucible.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/block/RenderDemonCrucible.java @@ -12,16 +12,14 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -public class RenderDemonCrucible extends TileEntitySpecialRenderer -{ +public class RenderDemonCrucible extends TileEntitySpecialRenderer { public static Minecraft mc = Minecraft.getMinecraft(); public static ResourceLocation resource = new ResourceLocation("bloodmagic", "textures/blocks/lifeEssenceStill.png"); public static float minHeight = 0.6497f; public static float maxHeight = 0.79f; @Override - public void render(TileDemonCrucible tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) - { + public void render(TileDemonCrucible tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { ItemStack inputStack = tile.getStackInSlot(0); GlStateManager.pushMatrix(); @@ -30,11 +28,9 @@ public class RenderDemonCrucible extends TileEntitySpecialRenderer -{ +public class RenderItemRoutingNode extends TileEntitySpecialRenderer { private static final ResourceLocation beamTexture = new ResourceLocation(BloodMagic.MODID, "textures/entities/nodeBeam.png"); private static final Minecraft mc = Minecraft.getMinecraft(); @Override - public void render(TileRoutingNode tileNode, double x, double y, double z, float partialTicks, int destroyStage, float alpha) - { - if (mc.player.getHeldItemMainhand().getItem() instanceof INodeRenderer || ConfigHandler.alwaysRenderRoutingLines) - { + public void render(TileRoutingNode tileNode, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { + if (mc.player.getHeldItemMainhand().getItem() instanceof INodeRenderer || ConfigHandler.alwaysRenderRoutingLines) { List connectionList = tileNode.getConnected(); - for (BlockPos wantedPos : connectionList) - { + for (BlockPos wantedPos : connectionList) { BlockPos offsetPos = wantedPos.subtract(tileNode.getPos()); //The beam renders towards the east by default. diff --git a/src/main/java/WayofTime/bloodmagic/client/render/block/RenderMimic.java b/src/main/java/WayofTime/bloodmagic/client/render/block/RenderMimic.java index b96e6ee4..8909df07 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/block/RenderMimic.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/block/RenderMimic.java @@ -1,22 +1,18 @@ package WayofTime.bloodmagic.client.render.block; +import WayofTime.bloodmagic.tile.TileMimic; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.tile.TileMimic; @SideOnly(Side.CLIENT) -public class RenderMimic extends TileEntitySpecialRenderer -{ - public void render(TileMimic mimic, double x, double y, double z, float partialTicks, int destroyStage, float alpha) - { - if (mimic.getStackInSlot(0) != null) - { +public class RenderMimic extends TileEntitySpecialRenderer { + public void render(TileMimic mimic, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { + if (mimic.getStackInSlot(0) != null) { TileEntity testTile = mimic.mimicedTile; - if (mimic != null) - { + if (mimic != null) { TileEntityRendererDispatcher.instance.render(testTile, x, y, z, partialTicks, destroyStage); } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/BloodLightRenderFactory.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/BloodLightRenderFactory.java index 3c064e44..1237c0c7 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/BloodLightRenderFactory.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/BloodLightRenderFactory.java @@ -5,11 +5,9 @@ import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraftforge.fml.client.registry.IRenderFactory; -public class BloodLightRenderFactory implements IRenderFactory -{ +public class BloodLightRenderFactory implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) - { + public Render createRenderFor(RenderManager manager) { return new RenderEntityBloodLight(manager); } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedChickenRenderFactory.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedChickenRenderFactory.java index 0705375f..6429a137 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedChickenRenderFactory.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedChickenRenderFactory.java @@ -1,15 +1,13 @@ package WayofTime.bloodmagic.client.render.entity; +import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraftforge.fml.client.registry.IRenderFactory; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken; -public class CorruptedChickenRenderFactory implements IRenderFactory -{ +public class CorruptedChickenRenderFactory implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) - { + public Render createRenderFor(RenderManager manager) { return new RenderCorruptedChicken(manager); } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedSheepRenderFactory.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedSheepRenderFactory.java index 42986d10..20c9c2c9 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedSheepRenderFactory.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedSheepRenderFactory.java @@ -1,15 +1,13 @@ package WayofTime.bloodmagic.client.render.entity; +import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraftforge.fml.client.registry.IRenderFactory; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; -public class CorruptedSheepRenderFactory implements IRenderFactory -{ +public class CorruptedSheepRenderFactory implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) - { + public Render createRenderFor(RenderManager manager) { return new RenderCorruptedSheep(manager); } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedSpiderRenderFactory.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedSpiderRenderFactory.java index eb0d211f..95debc39 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedSpiderRenderFactory.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedSpiderRenderFactory.java @@ -1,15 +1,13 @@ package WayofTime.bloodmagic.client.render.entity; +import WayofTime.bloodmagic.entity.mob.EntityCorruptedSpider; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraftforge.fml.client.registry.IRenderFactory; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedSpider; -public class CorruptedSpiderRenderFactory implements IRenderFactory -{ +public class CorruptedSpiderRenderFactory implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) - { + public Render createRenderFor(RenderManager manager) { return new RenderCorruptedSpider(manager); } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedZombieRenderFactory.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedZombieRenderFactory.java index 9626ee9a..2e29c50e 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedZombieRenderFactory.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/CorruptedZombieRenderFactory.java @@ -1,15 +1,13 @@ package WayofTime.bloodmagic.client.render.entity; +import WayofTime.bloodmagic.entity.mob.EntityCorruptedZombie; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraftforge.fml.client.registry.IRenderFactory; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedZombie; -public class CorruptedZombieRenderFactory implements IRenderFactory -{ +public class CorruptedZombieRenderFactory implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) - { + public Render createRenderFor(RenderManager manager) { return new RenderCorruptedZombie(manager); } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/MeteorRenderFactory.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/MeteorRenderFactory.java index a55f4559..5b57d12d 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/MeteorRenderFactory.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/MeteorRenderFactory.java @@ -1,15 +1,13 @@ package WayofTime.bloodmagic.client.render.entity; +import WayofTime.bloodmagic.entity.projectile.EntityMeteor; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraftforge.fml.client.registry.IRenderFactory; -import WayofTime.bloodmagic.entity.projectile.EntityMeteor; -public class MeteorRenderFactory implements IRenderFactory -{ +public class MeteorRenderFactory implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) - { + public Render createRenderFor(RenderManager manager) { return new RenderEntityMeteor(manager); } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/MimicRenderFactory.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/MimicRenderFactory.java index 00d5f642..bc015688 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/MimicRenderFactory.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/MimicRenderFactory.java @@ -1,15 +1,13 @@ package WayofTime.bloodmagic.client.render.entity; +import WayofTime.bloodmagic.entity.mob.EntityMimic; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraftforge.fml.client.registry.IRenderFactory; -import WayofTime.bloodmagic.entity.mob.EntityMimic; -public class MimicRenderFactory implements IRenderFactory -{ +public class MimicRenderFactory implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) - { + public Render createRenderFor(RenderManager manager) { return new RenderEntityMimic(manager); } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedChicken.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedChicken.java index e919f5cc..44db0152 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedChicken.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedChicken.java @@ -1,35 +1,31 @@ package WayofTime.bloodmagic.client.render.entity; +import WayofTime.bloodmagic.client.render.entity.layer.LayerWill; +import WayofTime.bloodmagic.client.render.model.ModelCorruptedChicken; +import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.client.render.entity.layer.LayerWill; -import WayofTime.bloodmagic.client.render.model.ModelCorruptedChicken; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken; @SideOnly(Side.CLIENT) -public class RenderCorruptedChicken extends RenderLiving -{ +public class RenderCorruptedChicken extends RenderLiving { private static final ResourceLocation CHICKEN_TEXTURES = new ResourceLocation("textures/entity/chicken.png"); - public RenderCorruptedChicken(RenderManager renderManagerIn) - { + public RenderCorruptedChicken(RenderManager renderManagerIn) { super(renderManagerIn, new ModelCorruptedChicken(0), 0.3f); this.addLayer(new LayerWill(this, new ModelCorruptedChicken(1.1f))); } @Override - protected ResourceLocation getEntityTexture(EntityCorruptedChicken entity) - { + protected ResourceLocation getEntityTexture(EntityCorruptedChicken entity) { return CHICKEN_TEXTURES; } @Override - protected float handleRotationFloat(EntityCorruptedChicken livingBase, float partialTicks) - { + protected float handleRotationFloat(EntityCorruptedChicken livingBase, float partialTicks) { float f = livingBase.oFlap + (livingBase.wingRotation - livingBase.oFlap) * partialTicks; float f1 = livingBase.oFlapSpeed + (livingBase.destPos - livingBase.oFlapSpeed) * partialTicks; return (MathHelper.sin(f) + 1.0F) * f1; diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedSheep.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedSheep.java index 111d222b..11529425 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedSheep.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedSheep.java @@ -1,24 +1,22 @@ package WayofTime.bloodmagic.client.render.entity; -import net.minecraft.client.renderer.entity.RenderLiving; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import WayofTime.bloodmagic.client.render.entity.layer.LayerAlchemyCircle; import WayofTime.bloodmagic.client.render.entity.layer.LayerCorruptedSheepWool; import WayofTime.bloodmagic.client.render.entity.layer.LayerWill; import WayofTime.bloodmagic.client.render.model.ModelCorruptedSheep; import WayofTime.bloodmagic.client.render.model.ModelCorruptedSheep2; import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class RenderCorruptedSheep extends RenderLiving -{ +public class RenderCorruptedSheep extends RenderLiving { private static final ResourceLocation SHEARED_SHEEP_TEXTURES = new ResourceLocation("textures/entity/sheep/sheep.png"); - public RenderCorruptedSheep(RenderManager renderManagerIn) - { + public RenderCorruptedSheep(RenderManager renderManagerIn) { super(renderManagerIn, new ModelCorruptedSheep2(0), 0.7F); this.addLayer(new LayerCorruptedSheepWool(this)); this.addLayer(new LayerWill(this, new ModelCorruptedSheep(1.1f))); @@ -27,8 +25,7 @@ public class RenderCorruptedSheep extends RenderLiving } @Override - protected ResourceLocation getEntityTexture(EntityCorruptedSheep entity) - { + protected ResourceLocation getEntityTexture(EntityCorruptedSheep entity) { return SHEARED_SHEEP_TEXTURES; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedSpider.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedSpider.java index e118403b..343a459c 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedSpider.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedSpider.java @@ -1,30 +1,27 @@ package WayofTime.bloodmagic.client.render.entity; +import WayofTime.bloodmagic.client.render.entity.layer.LayerCorruptedSpiderEyes; +import WayofTime.bloodmagic.client.render.entity.layer.LayerWill; +import WayofTime.bloodmagic.client.render.model.ModelCorruptedSpider; +import WayofTime.bloodmagic.entity.mob.EntityCorruptedSpider; import net.minecraft.client.model.ModelSpider; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.client.render.entity.layer.LayerCorruptedSpiderEyes; -import WayofTime.bloodmagic.client.render.entity.layer.LayerWill; -import WayofTime.bloodmagic.client.render.model.ModelCorruptedSpider; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedSpider; @SideOnly(Side.CLIENT) -public class RenderCorruptedSpider extends RenderLiving -{ +public class RenderCorruptedSpider extends RenderLiving { private static final ResourceLocation SPIDER_TEXTURES = new ResourceLocation("textures/entity/spider/spider.png"); - public RenderCorruptedSpider(RenderManager renderManagerIn) - { + public RenderCorruptedSpider(RenderManager renderManagerIn) { super(renderManagerIn, new ModelSpider(), 1.0F); this.addLayer(new LayerCorruptedSpiderEyes(this)); this.addLayer(new LayerWill(this, new ModelCorruptedSpider(1.1f))); } - protected float getDeathMaxRotation(EntityCorruptedSpider entityLivingBaseIn) - { + protected float getDeathMaxRotation(EntityCorruptedSpider entityLivingBaseIn) { return 180.0F; } @@ -32,8 +29,7 @@ public class RenderCorruptedSpider extends RenderLiving * Returns the location of an entity's texture. Doesn't seem to be called * unless you call Render.bindEntityTexture. */ - protected ResourceLocation getEntityTexture(EntityCorruptedSpider entity) - { + protected ResourceLocation getEntityTexture(EntityCorruptedSpider entity) { return SPIDER_TEXTURES; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedZombie.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedZombie.java index 70c94eaa..57475a5f 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedZombie.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderCorruptedZombie.java @@ -1,5 +1,7 @@ package WayofTime.bloodmagic.client.render.entity; +import WayofTime.bloodmagic.client.render.entity.layer.LayerWill; +import WayofTime.bloodmagic.entity.mob.EntityCorruptedZombie; import net.minecraft.client.model.ModelZombie; import net.minecraft.client.model.ModelZombieVillager; import net.minecraft.client.renderer.entity.RenderBiped; @@ -11,33 +13,26 @@ import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.client.render.entity.layer.LayerWill; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedZombie; @SideOnly(Side.CLIENT) -public class RenderCorruptedZombie extends RenderBiped -{ +public class RenderCorruptedZombie extends RenderBiped { private static final ResourceLocation ZOMBIE_TEXTURES = new ResourceLocation("textures/entity/zombie/zombie.png"); private final ModelZombieVillager zombieVillagerModel; - public RenderCorruptedZombie(RenderManager renderManagerIn) - { + public RenderCorruptedZombie(RenderManager renderManagerIn) { super(renderManagerIn, new ModelZombie(), 0.5F); LayerRenderer layerrenderer = this.layerRenderers.get(0); this.zombieVillagerModel = new ModelZombieVillager(); this.addLayer(new LayerHeldItem(this)); - LayerBipedArmor layerbipedarmor = new LayerBipedArmor(this) - { - protected void initArmor() - { + LayerBipedArmor layerbipedarmor = new LayerBipedArmor(this) { + protected void initArmor() { this.modelLeggings = new ModelZombie(0.5F, true); this.modelArmor = new ModelZombie(1.0F, true); } }; this.addLayer(layerbipedarmor); - if (layerrenderer instanceof LayerCustomHead) - { + if (layerrenderer instanceof LayerCustomHead) { layerRenderers.remove(layerrenderer); this.addLayer(new LayerCustomHead(this.zombieVillagerModel.bipedHead)); } @@ -50,16 +45,14 @@ public class RenderCorruptedZombie extends RenderBiped * Allows the render to do state modifications necessary before the model is * rendered. */ - protected void preRenderCallback(EntityCorruptedZombie entitylivingbaseIn, float partialTickTime) - { + protected void preRenderCallback(EntityCorruptedZombie entitylivingbaseIn, float partialTickTime) { super.preRenderCallback(entitylivingbaseIn, partialTickTime); } /** * Renders the desired {@code T} type Entity. */ - public void doRender(EntityCorruptedZombie entity, double x, double y, double z, float entityYaw, float partialTicks) - { + public void doRender(EntityCorruptedZombie entity, double x, double y, double z, float entityYaw, float partialTicks) { super.doRender(entity, x, y, z, entityYaw, partialTicks); } @@ -67,8 +60,7 @@ public class RenderCorruptedZombie extends RenderBiped * Returns the location of an entity's texture. Doesn't seem to be called * unless you call Render.bindEntityTexture. */ - protected ResourceLocation getEntityTexture(EntityCorruptedZombie entity) - { + protected ResourceLocation getEntityTexture(EntityCorruptedZombie entity) { return ZOMBIE_TEXTURES; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntityBloodLight.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntityBloodLight.java index ba8f3131..5d74c644 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntityBloodLight.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntityBloodLight.java @@ -11,17 +11,14 @@ import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.ResourceLocation; -public class RenderEntityBloodLight extends Render -{ +public class RenderEntityBloodLight extends Render { private final RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); - public RenderEntityBloodLight(RenderManager renderManagerIn) - { + public RenderEntityBloodLight(RenderManager renderManagerIn) { super(renderManagerIn); } - public void doRender(EntityBloodLight entity, double x, double y, double z, float entityYaw, float partialTicks) - { + public void doRender(EntityBloodLight entity, double x, double y, double z, float entityYaw, float partialTicks) { GlStateManager.pushMatrix(); GlStateManager.translate((float) x, (float) y, (float) z); GlStateManager.enableRescaleNormal(); @@ -35,8 +32,7 @@ public class RenderEntityBloodLight extends Render super.doRender(entity, x, y, z, entityYaw, partialTicks); } - protected ResourceLocation getEntityTexture(EntityBloodLight entity) - { + protected ResourceLocation getEntityTexture(EntityBloodLight entity) { return TextureMap.LOCATION_BLOCKS_TEXTURE; } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntityMeteor.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntityMeteor.java index 6aa13082..f1cf5f9f 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntityMeteor.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntityMeteor.java @@ -1,28 +1,25 @@ package WayofTime.bloodmagic.client.render.entity; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.client.render.model.ModelMeteor; +import WayofTime.bloodmagic.entity.projectile.EntityMeteor; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.util.ResourceLocation; -import WayofTime.bloodmagic.client.render.model.ModelMeteor; -import WayofTime.bloodmagic.entity.projectile.EntityMeteor; -public class RenderEntityMeteor extends Render -{ +public class RenderEntityMeteor extends Render { + private static final ResourceLocation resource = new ResourceLocation(BloodMagic.MODID, "textures/models/Meteor.png"); public ModelBase model = new ModelMeteor(); private float scale = 1; - private static final ResourceLocation resource = new ResourceLocation(BloodMagic.MODID, "textures/models/Meteor.png"); - public RenderEntityMeteor(RenderManager renderManagerIn) - { + public RenderEntityMeteor(RenderManager renderManagerIn) { super(renderManagerIn); } @Override - public void doRender(EntityMeteor entity, double x, double y, double z, float entityYaw, float partialTicks) - { + public void doRender(EntityMeteor entity, double x, double y, double z, float entityYaw, float partialTicks) { // GlStateManager.pushMatrix(); // GlStateManager.translate((float) x, (float) y, (float) z); // GlStateManager.enableRescaleNormal(); @@ -49,8 +46,7 @@ public class RenderEntityMeteor extends Render } @Override - protected ResourceLocation getEntityTexture(EntityMeteor entity) - { + protected ResourceLocation getEntityTexture(EntityMeteor entity) { return resource; } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntityMimic.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntityMimic.java index 08e6f26f..27a39056 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntityMimic.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntityMimic.java @@ -1,7 +1,8 @@ package WayofTime.bloodmagic.client.render.entity; -import java.util.UUID; - +import WayofTime.bloodmagic.client.render.model.ModelMimic; +import WayofTime.bloodmagic.entity.mob.EntityMimic; +import com.mojang.authlib.GameProfile; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; @@ -21,34 +22,25 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StringUtils; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.client.render.model.ModelMimic; -import WayofTime.bloodmagic.entity.mob.EntityMimic; - -import com.mojang.authlib.GameProfile; @SideOnly(Side.CLIENT) -public class RenderEntityMimic extends RenderLiving -{ +public class RenderEntityMimic extends RenderLiving { private static final ResourceLocation SPIDER_TEXTURES = new ResourceLocation("textures/entity/spider/spider.png"); Minecraft minecraft = Minecraft.getMinecraft(); - public RenderEntityMimic(RenderManager renderManagerIn) - { + public RenderEntityMimic(RenderManager renderManagerIn) { super(renderManagerIn, new ModelMimic(), 1.0F); } @Override - public void doRender(EntityMimic mimic, double x, double y, double z, float entityYaw, float partialTicks) - { + public void doRender(EntityMimic mimic, double x, double y, double z, float entityYaw, float partialTicks) { super.doRender(mimic, x, y, z, entityYaw, partialTicks); GlStateManager.pushMatrix(); - if (mimic.getMimicItemStack() != null) - { + if (mimic.getMimicItemStack() != null) { GlStateManager.pushMatrix(); - if (this.renderOutlines) - { + if (this.renderOutlines) { GlStateManager.enableColorMaterial(); GlStateManager.enableOutlineMode(this.getTeamColor(mimic)); } @@ -62,26 +54,21 @@ public class RenderEntityMimic extends RenderLiving GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - if (item == Items.SKULL) - { + if (item == Items.SKULL) { float f2 = 1.1875F; GlStateManager.scale(1.1875F, -1.1875F, -1.1875F); GameProfile gameprofile = null; - if (itemstack.hasTagCompound()) - { + if (itemstack.hasTagCompound()) { NBTTagCompound nbttagcompound = itemstack.getTagCompound(); - if (nbttagcompound.hasKey("SkullOwner", 10)) - { + if (nbttagcompound.hasKey("SkullOwner", 10)) { gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner")); - } else if (nbttagcompound.hasKey("SkullOwner", 8)) - { + } else if (nbttagcompound.hasKey("SkullOwner", 8)) { String s = nbttagcompound.getString("SkullOwner"); - if (!StringUtils.isNullOrEmpty(s)) - { + if (!StringUtils.isNullOrEmpty(s)) { gameprofile = TileEntitySkull.updateGameprofile(new GameProfile(null, s)); nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile)); } @@ -89,8 +76,7 @@ public class RenderEntityMimic extends RenderLiving } TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.5F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), gameprofile, -1, 0); - } else if (!(item instanceof ItemArmor) || ((ItemArmor) item).getEquipmentSlot() != EntityEquipmentSlot.HEAD) - { + } else if (!(item instanceof ItemArmor) || ((ItemArmor) item).getEquipmentSlot() != EntityEquipmentSlot.HEAD) { GlStateManager.translate(0, 0.5f, 0); GlStateManager.rotate(-(mimic.prevRotationYawHead + partialTicks * (mimic.rotationYawHead - mimic.prevRotationYawHead)) - 180, 0, 1, 0); @@ -99,8 +85,7 @@ public class RenderEntityMimic extends RenderLiving GlStateManager.popMatrix(); - if (this.renderOutlines) - { + if (this.renderOutlines) { GlStateManager.disableOutlineMode(); GlStateManager.disableColorMaterial(); } @@ -111,15 +96,13 @@ public class RenderEntityMimic extends RenderLiving } GlStateManager.popMatrix(); - if (!this.renderOutlines) - { + if (!this.renderOutlines) { this.renderLeash(mimic, x, y, z, entityYaw, partialTicks); } } @Override - protected float getDeathMaxRotation(EntityMimic mimic) - { + protected float getDeathMaxRotation(EntityMimic mimic) { return 180.0F; } @@ -128,8 +111,7 @@ public class RenderEntityMimic extends RenderLiving * unless you call Render.bindEntityTexture. */ @Override - protected ResourceLocation getEntityTexture(EntityMimic mimic) - { + protected ResourceLocation getEntityTexture(EntityMimic mimic) { return SPIDER_TEXTURES; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntitySentientArrow.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntitySentientArrow.java index 7667e9f5..c0a2a618 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntitySentientArrow.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntitySentientArrow.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.client.render.entity; +import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; @@ -10,27 +11,21 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.lwjgl.opengl.GL11; -import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow; - @SideOnly(Side.CLIENT) -public class RenderEntitySentientArrow extends Render -{ +public class RenderEntitySentientArrow extends Render { private static final ResourceLocation defaultTexture = new ResourceLocation("bloodmagic:textures/entities/soulArrow.png"); private static final ResourceLocation corrosiveTexture = new ResourceLocation("bloodmagic:textures/entities/soulArrow_corrosive.png"); private static final ResourceLocation vengefulTexture = new ResourceLocation("bloodmagic:textures/entities/soulArrow_vengeful.png"); private static final ResourceLocation destructiveTexture = new ResourceLocation("bloodmagic:textures/entities/soulArrow_destructive.png"); private static final ResourceLocation steadfastTexture = new ResourceLocation("bloodmagic:textures/entities/soulArrow_steadfast.png"); - public RenderEntitySentientArrow(RenderManager renderManagerIn) - { + public RenderEntitySentientArrow(RenderManager renderManagerIn) { super(renderManagerIn); } - public void doRender(EntitySentientArrow entity, double x, double y, double z, float entityYaw, float partialTicks) - { + public void doRender(EntitySentientArrow entity, double x, double y, double z, float entityYaw, float partialTicks) { this.bindEntityTexture(entity); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.pushMatrix(); @@ -52,8 +47,7 @@ public class RenderEntitySentientArrow extends Render GlStateManager.enableRescaleNormal(); float f9 = (float) entity.arrowShake - partialTicks; - if (f9 > 0.0F) - { + if (f9 > 0.0F) { float f10 = -MathHelper.sin(f9 * 3.0F) * f9; GlStateManager.rotate(f10, 0.0F, 0.0F, 1.0F); } @@ -76,8 +70,7 @@ public class RenderEntitySentientArrow extends Render worldrenderer.pos(-7.0D, -2.0D, -2.0D).tex((double) f4, (double) f7).endVertex(); tessellator.draw(); - for (int j = 0; j < 4; ++j) - { + for (int j = 0; j < 4; ++j) { GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); GL11.glNormal3f(0.0F, 0.0F, f8); worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); @@ -97,21 +90,19 @@ public class RenderEntitySentientArrow extends Render * Returns the location of an entity's texture. Doesn't seem to be called * unless you call Render.bindEntityTexture. */ - protected ResourceLocation getEntityTexture(EntitySentientArrow entity) - { - switch (entity.type) - { - case CORROSIVE: - return corrosiveTexture; - case DESTRUCTIVE: - return destructiveTexture; - case STEADFAST: - return steadfastTexture; - case VENGEFUL: - return vengefulTexture; - case DEFAULT: - default: - return defaultTexture; + protected ResourceLocation getEntityTexture(EntitySentientArrow entity) { + switch (entity.type) { + case CORROSIVE: + return corrosiveTexture; + case DESTRUCTIVE: + return destructiveTexture; + case STEADFAST: + return steadfastTexture; + case VENGEFUL: + return vengefulTexture; + case DEFAULT: + default: + return defaultTexture; } } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntitySoulSnare.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntitySoulSnare.java index 9e42137d..cfe46aed 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntitySoulSnare.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntitySoulSnare.java @@ -1,7 +1,7 @@ package WayofTime.bloodmagic.client.render.entity; -import WayofTime.bloodmagic.entity.projectile.EntitySoulSnare; import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.entity.projectile.EntitySoulSnare; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderItem; @@ -12,17 +12,14 @@ import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -public class RenderEntitySoulSnare extends Render -{ +public class RenderEntitySoulSnare extends Render { private final RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); - public RenderEntitySoulSnare(RenderManager renderManagerIn) - { + public RenderEntitySoulSnare(RenderManager renderManagerIn) { super(renderManagerIn); } - public void doRender(EntitySoulSnare entity, double x, double y, double z, float entityYaw, float partialTicks) - { + public void doRender(EntitySoulSnare entity, double x, double y, double z, float entityYaw, float partialTicks) { GlStateManager.pushMatrix(); GlStateManager.translate((float) x, (float) y, (float) z); GlStateManager.enableRescaleNormal(); @@ -36,8 +33,7 @@ public class RenderEntitySoulSnare extends Render super.doRender(entity, x, y, z, entityYaw, partialTicks); } - protected ResourceLocation getEntityTexture(EntitySoulSnare entity) - { + protected ResourceLocation getEntityTexture(EntitySoulSnare entity) { return TextureMap.LOCATION_BLOCKS_TEXTURE; } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderSentientSpecter.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderSentientSpecter.java index 2dc7df63..4c8ab7fe 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderSentientSpecter.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderSentientSpecter.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.client.render.entity; +import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderBiped; @@ -14,15 +15,12 @@ import net.minecraft.util.EnumHandSide; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; @SideOnly(Side.CLIENT) -public class RenderSentientSpecter extends RenderBiped -{ +public class RenderSentientSpecter extends RenderBiped { public static final ResourceLocation texture = new ResourceLocation("bloodmagic", "textures/entities/specter.png"); - public RenderSentientSpecter(RenderManager renderManager) - { + public RenderSentientSpecter(RenderManager renderManager) { super(renderManager, new ModelBiped(0.0F), 0); this.addLayer(new LayerBipedArmor(this)); this.addLayer(new LayerHeldItem(this)); @@ -30,22 +28,19 @@ public class RenderSentientSpecter extends RenderBiped this.addLayer(new LayerCustomHead(this.getMainModel().bipedHead)); } - public ModelBiped getMainModel() - { + public ModelBiped getMainModel() { return (ModelBiped) super.getMainModel(); } /** * Renders the desired {@code T} type Entity. */ - public void doRender(EntitySentientSpecter entity, double x, double y, double z, float entityYaw, float partialTicks) - { + public void doRender(EntitySentientSpecter entity, double x, double y, double z, float entityYaw, float partialTicks) { this.setModelVisibilities(entity); super.doRender(entity, x, y, z, entityYaw, partialTicks); } - private void setModelVisibilities(EntitySentientSpecter clientPlayer) - { + private void setModelVisibilities(EntitySentientSpecter clientPlayer) { ModelBiped modelplayer = this.getMainModel(); ItemStack itemstack = clientPlayer.getHeldItemMainhand(); @@ -56,45 +51,36 @@ public class RenderSentientSpecter extends RenderBiped ModelBiped.ArmPose modelbiped$armpose = ModelBiped.ArmPose.EMPTY; ModelBiped.ArmPose modelbiped$armpose1 = ModelBiped.ArmPose.EMPTY; - if (!itemstack.isEmpty()) - { + if (!itemstack.isEmpty()) { modelbiped$armpose = ModelBiped.ArmPose.ITEM; - if (clientPlayer.getItemInUseCount() > 0) - { + if (clientPlayer.getItemInUseCount() > 0) { EnumAction enumaction = itemstack.getItemUseAction(); - if (enumaction == EnumAction.BLOCK) - { + if (enumaction == EnumAction.BLOCK) { modelbiped$armpose = ModelBiped.ArmPose.BLOCK; - } else if (enumaction == EnumAction.BOW) - { + } else if (enumaction == EnumAction.BOW) { modelbiped$armpose = ModelBiped.ArmPose.BOW_AND_ARROW; } } } - if (!itemstack1.isEmpty()) - { + if (!itemstack1.isEmpty()) { modelbiped$armpose1 = ModelBiped.ArmPose.ITEM; - if (clientPlayer.getItemInUseCount() > 0) - { + if (clientPlayer.getItemInUseCount() > 0) { EnumAction enumaction1 = itemstack1.getItemUseAction(); - if (enumaction1 == EnumAction.BLOCK) - { + if (enumaction1 == EnumAction.BLOCK) { modelbiped$armpose1 = ModelBiped.ArmPose.BLOCK; } } } - if (clientPlayer.getPrimaryHand() == EnumHandSide.RIGHT) - { + if (clientPlayer.getPrimaryHand() == EnumHandSide.RIGHT) { modelplayer.rightArmPose = modelbiped$armpose; modelplayer.leftArmPose = modelbiped$armpose1; - } else - { + } else { modelplayer.rightArmPose = modelbiped$armpose1; modelplayer.leftArmPose = modelbiped$armpose; } @@ -105,13 +91,11 @@ public class RenderSentientSpecter extends RenderBiped * Returns the location of an entity's texture. Doesn't seem to be called * unless you call Render.bindEntityTexture. */ - protected ResourceLocation getEntityTexture(EntitySentientSpecter entity) - { + protected ResourceLocation getEntityTexture(EntitySentientSpecter entity) { return texture; } - public void transformHeldFull3DItemLayer() - { + public void transformHeldFull3DItemLayer() { GlStateManager.translate(0.0F, 0.1875F, 0.0F); } @@ -119,8 +103,7 @@ public class RenderSentientSpecter extends RenderBiped * Allows the render to do state modifications necessary before the model is * rendered. */ - protected void preRenderCallback(EntitySentientSpecter entitylivingbaseIn, float partialTickTime) - { + protected void preRenderCallback(EntitySentientSpecter entitylivingbaseIn, float partialTickTime) { float f = 0.9375F; GlStateManager.scale(0.9375F, 0.9375F, 0.9375F); } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/SentientArrowRenderFactory.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/SentientArrowRenderFactory.java index 1d821634..49ec7093 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/SentientArrowRenderFactory.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/SentientArrowRenderFactory.java @@ -5,11 +5,9 @@ import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraftforge.fml.client.registry.IRenderFactory; -public class SentientArrowRenderFactory implements IRenderFactory -{ +public class SentientArrowRenderFactory implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) - { + public Render createRenderFor(RenderManager manager) { return new RenderEntitySentientArrow(manager); } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/SentientSpecterRenderFactory.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/SentientSpecterRenderFactory.java index e06af0c2..8e92253c 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/SentientSpecterRenderFactory.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/SentientSpecterRenderFactory.java @@ -1,15 +1,13 @@ package WayofTime.bloodmagic.client.render.entity; +import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraftforge.fml.client.registry.IRenderFactory; -import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; -public class SentientSpecterRenderFactory implements IRenderFactory -{ +public class SentientSpecterRenderFactory implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) - { + public Render createRenderFor(RenderManager manager) { return new RenderSentientSpecter(manager); } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/SoulSnareRenderFactory.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/SoulSnareRenderFactory.java index cb755a27..0ced4e40 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/SoulSnareRenderFactory.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/SoulSnareRenderFactory.java @@ -5,11 +5,9 @@ import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraftforge.fml.client.registry.IRenderFactory; -public class SoulSnareRenderFactory implements IRenderFactory -{ +public class SoulSnareRenderFactory implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) - { + public Render createRenderFor(RenderManager manager) { return new RenderEntitySoulSnare(manager); } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/layer/LayerAlchemyCircle.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/layer/LayerAlchemyCircle.java index 26d3fdc9..5e5da140 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/layer/LayerAlchemyCircle.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/layer/LayerAlchemyCircle.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.client.render.entity.layer; +import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; @@ -9,25 +10,20 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; @SideOnly(Side.CLIENT) -public class LayerAlchemyCircle implements LayerRenderer -{ +public class LayerAlchemyCircle implements LayerRenderer { private static final ResourceLocation ARRAY_TEXTURE = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/FastMinerSigil.png"); float rotationspeed = 10; - public LayerAlchemyCircle() - { + public LayerAlchemyCircle() { } @Override - public void doRenderLayer(EntityCorruptedSheep demon, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) - { - if (demon.getCastTimer() <= 0) - { + public void doRenderLayer(EntityCorruptedSheep demon, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + if (demon.getCastTimer() <= 0) { return; } @@ -80,8 +76,7 @@ public class LayerAlchemyCircle implements Layer } @Override - public boolean shouldCombineTextures() - { + public boolean shouldCombineTextures() { return false; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/layer/LayerCorruptedSheepWool.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/layer/LayerCorruptedSheepWool.java index d66c2ea3..92c55940 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/layer/LayerCorruptedSheepWool.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/layer/LayerCorruptedSheepWool.java @@ -1,35 +1,30 @@ package WayofTime.bloodmagic.client.render.entity.layer; +import WayofTime.bloodmagic.client.render.entity.RenderCorruptedSheep; +import WayofTime.bloodmagic.client.render.model.ModelCorruptedSheep; +import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.item.EnumDyeColor; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.client.render.entity.RenderCorruptedSheep; -import WayofTime.bloodmagic.client.render.model.ModelCorruptedSheep; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; @SideOnly(Side.CLIENT) -public class LayerCorruptedSheepWool implements LayerRenderer -{ +public class LayerCorruptedSheepWool implements LayerRenderer { private static final ResourceLocation TEXTURE = new ResourceLocation("textures/entity/sheep/sheep_fur.png"); private final RenderCorruptedSheep sheepRenderer; private final ModelCorruptedSheep sheepModel = new ModelCorruptedSheep(1); - public LayerCorruptedSheepWool(RenderCorruptedSheep renderCorruptedSheep) - { + public LayerCorruptedSheepWool(RenderCorruptedSheep renderCorruptedSheep) { this.sheepRenderer = renderCorruptedSheep; } - public void doRenderLayer(EntityCorruptedSheep entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) - { - if (!entitylivingbaseIn.getSheared() && !entitylivingbaseIn.isInvisible()) - { + public void doRenderLayer(EntityCorruptedSheep entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + if (!entitylivingbaseIn.getSheared() && !entitylivingbaseIn.isInvisible()) { this.sheepRenderer.bindTexture(TEXTURE); - if (entitylivingbaseIn.hasCustomName() && "jeb_".equals(entitylivingbaseIn.getCustomNameTag())) - { + if (entitylivingbaseIn.hasCustomName() && "jeb_".equals(entitylivingbaseIn.getCustomNameTag())) { int i1 = 25; int i = entitylivingbaseIn.ticksExisted / 25 + entitylivingbaseIn.getEntityId(); int j = EnumDyeColor.values().length; @@ -39,8 +34,7 @@ public class LayerCorruptedSheepWool implements LayerRenderer -{ +public class LayerCorruptedSpiderEyes implements LayerRenderer { private static final ResourceLocation SPIDER_EYES = new ResourceLocation("textures/entity/spider_eyes.png"); private final RenderCorruptedSpider spiderRenderer; - public LayerCorruptedSpiderEyes(RenderCorruptedSpider spiderRendererIn) - { + public LayerCorruptedSpiderEyes(RenderCorruptedSpider spiderRendererIn) { this.spiderRenderer = spiderRendererIn; } - public void doRenderLayer(EntityCorruptedSpider entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) - { + public void doRenderLayer(EntityCorruptedSpider entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { this.spiderRenderer.bindTexture(SPIDER_EYES); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE); - if (entitylivingbaseIn.isInvisible()) - { + if (entitylivingbaseIn.isInvisible()) { GlStateManager.depthMask(false); - } else - { + } else { GlStateManager.depthMask(true); } @@ -50,8 +45,7 @@ public class LayerCorruptedSpiderEyes implements LayerRenderer implements LayerRenderer -{ +public class LayerWill implements LayerRenderer { private static final ResourceLocation RAW_TEXTURE = new ResourceLocation("bloodmagic", "textures/entities/overlay/overlay_raw.png"); private final RenderLiving renderer; private final ModelBase model; - public LayerWill(RenderLiving rendererIn, ModelBase model) - { + public LayerWill(RenderLiving rendererIn, ModelBase model) { this.renderer = rendererIn; this.model = model; } @Override - public void doRenderLayer(EntityDemonBase demon, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) - { + public void doRenderLayer(EntityDemonBase demon, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { // if (demon.getPowered()) - if (demon.isInvisible()) - { + if (demon.isInvisible()) { return; //TODO: Make this also check if the demon wants the Will layer } @@ -56,8 +52,7 @@ public class LayerWill implements LayerRenderer } @Override - public boolean shouldCombineTextures() - { + public boolean shouldCombineTextures() { return false; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedChicken.java b/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedChicken.java index 8b498781..578cac99 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedChicken.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedChicken.java @@ -9,8 +9,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class ModelCorruptedChicken extends ModelBase -{ +public class ModelCorruptedChicken extends ModelBase { public ModelRenderer head; public ModelRenderer body; public ModelRenderer rightLeg; @@ -20,8 +19,7 @@ public class ModelCorruptedChicken extends ModelBase public ModelRenderer bill; public ModelRenderer chin; - public ModelCorruptedChicken(float scale) - { + public ModelCorruptedChicken(float scale) { this.head = new ModelRenderer(this, 0, 0); this.head.addBox(-2.0F, -6.0F, -2.0F, 4, 6, 3, scale); this.head.setRotationPoint(0.0F, 15.0F, -4.0F); @@ -51,12 +49,10 @@ public class ModelCorruptedChicken extends ModelBase /** * Sets the models various rotation angles then renders the model. */ - public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) - { + public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { this.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entityIn); - if (this.isChild) - { + if (this.isChild) { GlStateManager.pushMatrix(); GlStateManager.translate(0.0F, 5.0F * scale, 2.0F * scale); this.head.render(scale); @@ -72,8 +68,7 @@ public class ModelCorruptedChicken extends ModelBase this.rightWing.render(scale); this.leftWing.render(scale); GlStateManager.popMatrix(); - } else - { + } else { this.head.render(scale); this.bill.render(scale); this.chin.render(scale); @@ -91,8 +86,7 @@ public class ModelCorruptedChicken extends ModelBase * the time(so that arms and legs swing back and forth) and par2 represents * how "far" arms and legs can swing at most. */ - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) - { + public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { this.head.rotateAngleX = headPitch * 0.017453292F; this.head.rotateAngleY = netHeadYaw * 0.017453292F; this.bill.rotateAngleX = this.head.rotateAngleX; diff --git a/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedSheep.java b/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedSheep.java index 6e631c50..a1c27e01 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedSheep.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedSheep.java @@ -1,20 +1,18 @@ package WayofTime.bloodmagic.client.render.model; +import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; import net.minecraft.client.model.ModelQuadruped; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; @SideOnly(Side.CLIENT) -public class ModelCorruptedSheep extends ModelQuadruped -{ +public class ModelCorruptedSheep extends ModelQuadruped { private float headRotationAngleX; - public ModelCorruptedSheep(float scale) - { + public ModelCorruptedSheep(float scale) { super(12, scale); this.head = new ModelRenderer(this, 0, 0); this.head.addBox(-3.0F, -4.0F, -4.0F, 6, 6, 6, 0.6F * scale); @@ -42,8 +40,7 @@ public class ModelCorruptedSheep extends ModelQuadruped * float params here are the same second and third as in the * setRotationAngles method. */ - public void setLivingAnimations(EntityLivingBase entitylivingbaseIn, float p_78086_2_, float p_78086_3_, float partialTickTime) - { + public void setLivingAnimations(EntityLivingBase entitylivingbaseIn, float p_78086_2_, float p_78086_3_, float partialTickTime) { super.setLivingAnimations(entitylivingbaseIn, p_78086_2_, p_78086_3_, partialTickTime); this.head.rotationPointY = 6.0F + ((EntityCorruptedSheep) entitylivingbaseIn).getHeadRotationPointY(partialTickTime) * 9.0F; this.headRotationAngleX = ((EntityCorruptedSheep) entitylivingbaseIn).getHeadRotationAngleX(partialTickTime); @@ -55,8 +52,7 @@ public class ModelCorruptedSheep extends ModelQuadruped * the time(so that arms and legs swing back and forth) and par2 represents * how "far" arms and legs can swing at most. */ - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) - { + public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); this.head.rotateAngleX = this.headRotationAngleX; } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedSheep2.java b/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedSheep2.java index f9f5ec19..fb5d5497 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedSheep2.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedSheep2.java @@ -1,20 +1,18 @@ package WayofTime.bloodmagic.client.render.model; +import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; import net.minecraft.client.model.ModelQuadruped; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; @SideOnly(Side.CLIENT) -public class ModelCorruptedSheep2 extends ModelQuadruped -{ +public class ModelCorruptedSheep2 extends ModelQuadruped { private float headRotationAngleX; - public ModelCorruptedSheep2(float scale) - { + public ModelCorruptedSheep2(float scale) { super(12, scale); this.head = new ModelRenderer(this, 0, 0); this.head.addBox(-3.0F, -4.0F, -6.0F, 6, 6, 8, scale); @@ -29,8 +27,7 @@ public class ModelCorruptedSheep2 extends ModelQuadruped * float params here are the same second and third as in the * setRotationAngles method. */ - public void setLivingAnimations(EntityLivingBase entitylivingbaseIn, float p_78086_2_, float p_78086_3_, float partialTickTime) - { + public void setLivingAnimations(EntityLivingBase entitylivingbaseIn, float p_78086_2_, float p_78086_3_, float partialTickTime) { super.setLivingAnimations(entitylivingbaseIn, p_78086_2_, p_78086_3_, partialTickTime); this.head.rotationPointY = 6.0F + ((EntityCorruptedSheep) entitylivingbaseIn).getHeadRotationPointY(partialTickTime) * 9.0F; this.headRotationAngleX = ((EntityCorruptedSheep) entitylivingbaseIn).getHeadRotationAngleX(partialTickTime); @@ -42,8 +39,7 @@ public class ModelCorruptedSheep2 extends ModelQuadruped * the time(so that arms and legs swing back and forth) and par2 represents * how "far" arms and legs can swing at most. */ - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) - { + public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); this.head.rotateAngleX = this.headRotationAngleX; } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedSpider.java b/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedSpider.java index 4c000ba8..3f92fad3 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedSpider.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/model/ModelCorruptedSpider.java @@ -8,33 +8,53 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class ModelCorruptedSpider extends ModelBase -{ - /** The spider's head box */ +public class ModelCorruptedSpider extends ModelBase { + /** + * The spider's head box + */ public ModelRenderer spiderHead; - /** The spider's neck box */ + /** + * The spider's neck box + */ public ModelRenderer spiderNeck; - /** The spider's body box */ + /** + * The spider's body box + */ public ModelRenderer spiderBody; - /** Spider's first leg */ + /** + * Spider's first leg + */ public ModelRenderer spiderLeg1; - /** Spider's second leg */ + /** + * Spider's second leg + */ public ModelRenderer spiderLeg2; - /** Spider's third leg */ + /** + * Spider's third leg + */ public ModelRenderer spiderLeg3; - /** Spider's fourth leg */ + /** + * Spider's fourth leg + */ public ModelRenderer spiderLeg4; - /** Spider's fifth leg */ + /** + * Spider's fifth leg + */ public ModelRenderer spiderLeg5; - /** Spider's sixth leg */ + /** + * Spider's sixth leg + */ public ModelRenderer spiderLeg6; - /** Spider's seventh leg */ + /** + * Spider's seventh leg + */ public ModelRenderer spiderLeg7; - /** Spider's eight leg */ + /** + * Spider's eight leg + */ public ModelRenderer spiderLeg8; - public ModelCorruptedSpider(float scale) - { + public ModelCorruptedSpider(float scale) { float f = 0.0F; int i = 15; this.spiderHead = new ModelRenderer(this, 32, 4); @@ -75,8 +95,7 @@ public class ModelCorruptedSpider extends ModelBase /** * Sets the models various rotation angles then renders the model. */ - public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) - { + public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { this.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entityIn); this.spiderHead.render(scale); this.spiderNeck.render(scale); @@ -97,8 +116,7 @@ public class ModelCorruptedSpider extends ModelBase * the time(so that arms and legs swing back and forth) and par2 represents * how "far" arms and legs can swing at most. */ - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) - { + public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { this.spiderHead.rotateAngleY = netHeadYaw * 0.017453292F; this.spiderHead.rotateAngleX = headPitch * 0.017453292F; float f = ((float) Math.PI / 4F); diff --git a/src/main/java/WayofTime/bloodmagic/client/render/model/ModelMeteor.java b/src/main/java/WayofTime/bloodmagic/client/render/model/ModelMeteor.java index 3e62353c..8e75b6c8 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/model/ModelMeteor.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/model/ModelMeteor.java @@ -7,10 +7,8 @@ import net.minecraft.entity.Entity; /** * This is a direct copy of the meteor model from 1.7.10. As such it probably * needs to be... better. - * */ -public class ModelMeteor extends ModelBase -{ +public class ModelMeteor extends ModelBase { //fields ModelRenderer Shape1; ModelRenderer Shape2; @@ -20,8 +18,7 @@ public class ModelMeteor extends ModelBase ModelRenderer Shape6; ModelRenderer Shape7; - public ModelMeteor() - { + public ModelMeteor() { textureWidth = 64; textureHeight = 64; Shape1 = new ModelRenderer(this, 0, 0); @@ -68,8 +65,7 @@ public class ModelMeteor extends ModelBase setRotation(Shape7, 0F, 0F, 0F); } - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); Shape1.render(f5); @@ -81,15 +77,13 @@ public class ModelMeteor extends ModelBase Shape7.render(f5); } - private void setRotation(ModelRenderer model, float x, float y, float z) - { + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) - { + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/client/render/model/ModelMimic.java b/src/main/java/WayofTime/bloodmagic/client/render/model/ModelMimic.java index cc1d3914..e06c1220 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/model/ModelMimic.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/model/ModelMimic.java @@ -8,27 +8,41 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class ModelMimic extends ModelBase -{ - /** Spider's first leg */ +public class ModelMimic extends ModelBase { + /** + * Spider's first leg + */ public ModelRenderer mimicLeg1; - /** Spider's second leg */ + /** + * Spider's second leg + */ public ModelRenderer mimicLeg2; - /** Spider's third leg */ + /** + * Spider's third leg + */ public ModelRenderer mimicLeg3; - /** Spider's fourth leg */ + /** + * Spider's fourth leg + */ public ModelRenderer mimicLeg4; - /** Spider's fifth leg */ + /** + * Spider's fifth leg + */ public ModelRenderer mimicLeg5; - /** Spider's sixth leg */ + /** + * Spider's sixth leg + */ public ModelRenderer mimicLeg6; - /** Spider's seventh leg */ + /** + * Spider's seventh leg + */ public ModelRenderer mimicLeg7; - /** Spider's eight leg */ + /** + * Spider's eight leg + */ public ModelRenderer mimicLeg8; - public ModelMimic() - { + public ModelMimic() { this.mimicLeg1 = new ModelRenderer(this, 18, 0); this.mimicLeg1.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, 0.0F); this.mimicLeg1.setRotationPoint(-4.0F, 15.0F, 2.0F); @@ -58,8 +72,7 @@ public class ModelMimic extends ModelBase /** * Sets the models various rotation angles then renders the model. */ - public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) - { + public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { this.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entityIn); this.mimicLeg1.render(scale); this.mimicLeg2.render(scale); @@ -77,8 +90,7 @@ public class ModelMimic extends ModelBase * the time(so that arms and legs swing back and forth) and par2 represents * how "far" arms and legs can swing at most. */ - public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) - { + public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { this.mimicLeg1.rotateAngleZ = -((float) Math.PI / 4F); this.mimicLeg2.rotateAngleZ = ((float) Math.PI / 4F); this.mimicLeg3.rotateAngleZ = -0.58119464F; diff --git a/src/main/java/WayofTime/bloodmagic/command/CommandBloodMagic.java b/src/main/java/WayofTime/bloodmagic/command/CommandBloodMagic.java index dd92000e..81eb9063 100644 --- a/src/main/java/WayofTime/bloodmagic/command/CommandBloodMagic.java +++ b/src/main/java/WayofTime/bloodmagic/command/CommandBloodMagic.java @@ -8,45 +8,37 @@ import net.minecraft.command.ICommandSender; import net.minecraft.util.text.TextComponentString; import net.minecraftforge.server.command.CommandTreeBase; -public class CommandBloodMagic extends CommandTreeBase -{ - public CommandBloodMagic() - { +public class CommandBloodMagic extends CommandTreeBase { + public CommandBloodMagic() { addSubcommand(new SubCommandBind()); addSubcommand(new SubCommandNetwork()); addSubcommand(new SubCommandOrb()); } @Override - public String getName() - { + public String getName() { return "bloodmagic"; } @Override - public String getUsage(ICommandSender sender) - { + public String getUsage(ICommandSender sender) { return "/bloodmagic help"; } @Override - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return 2; } - public static void displayHelpString(ICommandSender commandSender, String display, Object... info) - { + public static void displayHelpString(ICommandSender commandSender, String display, Object... info) { commandSender.sendMessage(new TextComponentString(TextHelper.localizeEffect(display, info))); } - public static void displayErrorString(ICommandSender commandSender, String display, Object... info) - { + public static void displayErrorString(ICommandSender commandSender, String display, Object... info) { commandSender.sendMessage(new TextComponentString(TextHelper.localizeEffect(display, info))); } - public static void displaySuccessString(ICommandSender commandSender, String display, Object... info) - { + public static void displaySuccessString(ICommandSender commandSender, String display, Object... info) { commandSender.sendMessage(new TextComponentString(TextHelper.localizeEffect(display, info))); } } diff --git a/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandBind.java b/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandBind.java index 0798f3fe..3e5cbb48 100644 --- a/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandBind.java +++ b/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandBind.java @@ -6,90 +6,78 @@ import WayofTime.bloodmagic.api.util.helper.BindableHelper; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.util.helper.TextHelper; import com.google.common.base.Strings; -import net.minecraft.command.*; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.PlayerNotFoundException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; import net.minecraft.util.text.TextComponentTranslation; -public class SubCommandBind extends CommandBase -{ +public class SubCommandBind extends CommandBase { @Override - public String getName() - { + public String getName() { return "bind"; } @Override - public String getUsage(ICommandSender commandSender) - { + public String getUsage(ICommandSender commandSender) { return TextHelper.localizeEffect("commands.bind.usage"); } @Override - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return 2; } @Override - public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException - { + public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException { if (commandSender.getEntityWorld().isRemote) return; - try - { + try { EntityPlayer player = CommandBase.getCommandSenderAsPlayer(commandSender); String playerName = player.getName(); String uuid = PlayerHelper.getUUIDFromPlayer(player).toString(); ItemStack held = player.getHeldItemMainhand(); boolean bind = true; - if (held.getItem() instanceof IBindable) - { - if (args.length > 0) - { + if (held.getItem() instanceof IBindable) { + if (args.length > 0) { if (args[0].equalsIgnoreCase("help")) return; - if (isBoolean(args[0])) - { + if (isBoolean(args[0])) { bind = Boolean.parseBoolean(args[0]); if (args.length > 2) playerName = args[1]; - } else - { + } else { playerName = args[0]; uuid = PlayerHelper.getUUIDFromPlayer(CommandBase.getPlayer(server, commandSender, playerName)).toString(); } } - if (bind) - { + if (bind) { BindableHelper.setItemOwnerName(held, playerName); BindableHelper.setItemOwnerUUID(held, uuid); commandSender.sendMessage(new TextComponentTranslation("commands.bind.success")); - } else - { - if (!Strings.isNullOrEmpty(((IBindable) held.getItem()).getOwnerUUID(held))) - { + } else { + if (!Strings.isNullOrEmpty(((IBindable) held.getItem()).getOwnerUUID(held))) { held.getTagCompound().removeTag(Constants.NBT.OWNER_UUID); held.getTagCompound().removeTag(Constants.NBT.OWNER_NAME); commandSender.sendMessage(new TextComponentTranslation("commands.bind.remove.success")); } } } - } catch (PlayerNotFoundException e) - { + } catch (PlayerNotFoundException e) { commandSender.sendMessage(new TextComponentTranslation(TextHelper.localizeEffect("commands.error.404"))); } } - private boolean isBoolean(String string) - { + private boolean isBoolean(String string) { return string.equalsIgnoreCase("true") || string.equalsIgnoreCase("false"); } } diff --git a/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandNetwork.java b/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandNetwork.java index f874d954..21717206 100644 --- a/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandNetwork.java +++ b/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandNetwork.java @@ -5,159 +5,127 @@ import WayofTime.bloodmagic.api.util.helper.NetworkHelper; import WayofTime.bloodmagic.command.CommandBloodMagic; import WayofTime.bloodmagic.util.Utils; import WayofTime.bloodmagic.util.helper.TextHelper; -import net.minecraft.command.*; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.PlayerNotFoundException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.server.MinecraftServer; import net.minecraft.util.text.TextComponentString; import java.util.Locale; -public class SubCommandNetwork extends CommandBase -{ +public class SubCommandNetwork extends CommandBase { @Override public String getName() { return "network"; } @Override - public String getUsage(ICommandSender commandSender) - { + public String getUsage(ICommandSender commandSender) { return TextHelper.localizeEffect("commands.network.usage"); } @Override - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return 2; } @Override - public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException - { - if (args.length > 1) - { + public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException { + if (args.length > 1) { if (args[0].equalsIgnoreCase("help")) return; - try - { + try { EntityPlayer player = CommandBase.getPlayer(server, commandSender, args[1]); - try - { + try { ValidCommands command = ValidCommands.valueOf(args[0].toUpperCase(Locale.ENGLISH)); command.run(player, commandSender, args.length > 0 && args.length < 2, args); - } catch (IllegalArgumentException e) - { + } catch (IllegalArgumentException e) { } - } catch (PlayerNotFoundException e) - { + } catch (PlayerNotFoundException e) { CommandBloodMagic.displayErrorString(commandSender, e.getLocalizedMessage()); } - } else - { + } else { CommandBloodMagic.displayErrorString(commandSender, "commands.error.arg.missing"); } } - private enum ValidCommands - { - SYPHON("commands.network.syphon.help") - { + private enum ValidCommands { + SYPHON("commands.network.syphon.help") { @Override - public void run(EntityPlayer player, ICommandSender sender, boolean displayHelp, String... args) - { - if (displayHelp) - { + public void run(EntityPlayer player, ICommandSender sender, boolean displayHelp, String... args) { + if (displayHelp) { CommandBloodMagic.displayHelpString(sender, this.help); return; } - if (args.length == 3) - { - if (Utils.isInteger(args[2])) - { + if (args.length == 3) { + if (Utils.isInteger(args[2])) { int amount = Integer.parseInt(args[2]); NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, amount); CommandBloodMagic.displaySuccessString(sender, "commands.network.syphon.success", amount, player.getDisplayName().getFormattedText()); - } else - { + } else { CommandBloodMagic.displayErrorString(sender, "commands.error.arg.invalid"); } - } else - { + } else { CommandBloodMagic.displayErrorString(sender, "commands.error.arg.missing"); } } }, - ADD("commands.network.add.help") - { + ADD("commands.network.add.help") { @Override - public void run(EntityPlayer player, ICommandSender sender, boolean displayHelp, String... args) - { - if (displayHelp) - { + public void run(EntityPlayer player, ICommandSender sender, boolean displayHelp, String... args) { + if (displayHelp) { CommandBloodMagic.displayHelpString(sender, this.help); return; } SoulNetwork network = NetworkHelper.getSoulNetwork(player); - if (args.length == 3) - { - if (Utils.isInteger(args[2])) - { + if (args.length == 3) { + if (Utils.isInteger(args[2])) { int amount = Integer.parseInt(args[2]); int maxOrb = NetworkHelper.getMaximumForTier(network.getOrbTier()); CommandBloodMagic.displaySuccessString(sender, "commands.network.add.success", network.add(amount, maxOrb), player.getDisplayName().getFormattedText()); - } else - { + } else { CommandBloodMagic.displayErrorString(sender, "commands.error.arg.invalid"); } - } else - { + } else { CommandBloodMagic.displayErrorString(sender, "commands.error.arg.missing"); } } }, - SET("commands.network.set.help") - { + SET("commands.network.set.help") { @Override - public void run(EntityPlayer player, ICommandSender sender, boolean displayHelp, String... args) - { - if (displayHelp) - { + public void run(EntityPlayer player, ICommandSender sender, boolean displayHelp, String... args) { + if (displayHelp) { CommandBloodMagic.displayHelpString(sender, this.help); return; } SoulNetwork network = NetworkHelper.getSoulNetwork(player); - if (args.length == 3) - { - if (Utils.isInteger(args[2])) - { + if (args.length == 3) { + if (Utils.isInteger(args[2])) { int amount = Integer.parseInt(args[2]); network.setCurrentEssence(amount); CommandBloodMagic.displaySuccessString(sender, "commands.network.set.success", player.getDisplayName().getFormattedText(), amount); - } else - { + } else { CommandBloodMagic.displayErrorString(sender, "commands.error.arg.invalid"); } - } else - { + } else { CommandBloodMagic.displayErrorString(sender, "commands.error.arg.missing"); } } }, - GET("commands.network.get.help") - { + GET("commands.network.get.help") { @Override - public void run(EntityPlayer player, ICommandSender sender, boolean displayHelp, String... args) - { - if (displayHelp) - { + public void run(EntityPlayer player, ICommandSender sender, boolean displayHelp, String... args) { + if (displayHelp) { CommandBloodMagic.displayHelpString(sender, this.help); return; } @@ -169,53 +137,43 @@ public class SubCommandNetwork extends CommandBase } }, - FILL("commands.network.fill.help") - { + FILL("commands.network.fill.help") { @Override - public void run(EntityPlayer player, ICommandSender sender, boolean displayHelp, String... args) - { - if (displayHelp) - { + public void run(EntityPlayer player, ICommandSender sender, boolean displayHelp, String... args) { + if (displayHelp) { CommandBloodMagic.displayHelpString(sender, this.help, Integer.MAX_VALUE); return; } SoulNetwork network = NetworkHelper.getSoulNetwork(player); - if (args.length > 1) - { + if (args.length > 1) { network.setCurrentEssence(Integer.MAX_VALUE); CommandBloodMagic.displaySuccessString(sender, "commands.network.fill.success", player.getDisplayName().getFormattedText()); } } }, - CAP("commands.network.cap.help") - { + CAP("commands.network.cap.help") { @Override - public void run(EntityPlayer player, ICommandSender sender, boolean displayHelp, String... args) - { - if (displayHelp) - { + public void run(EntityPlayer player, ICommandSender sender, boolean displayHelp, String... args) { + if (displayHelp) { CommandBloodMagic.displayHelpString(sender, this.help); return; } SoulNetwork network = NetworkHelper.getSoulNetwork(player); - if (args.length > 1) - { + if (args.length > 1) { int maxOrb = NetworkHelper.getMaximumForTier(network.getOrbTier()); network.setCurrentEssence(maxOrb); CommandBloodMagic.displaySuccessString(sender, "commands.network.cap.success", player.getDisplayName().getFormattedText()); } } - }, - ; + },; public String help; - ValidCommands(String help) - { + ValidCommands(String help) { this.help = help; } diff --git a/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandOrb.java b/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandOrb.java index 58c5396c..6fac129d 100644 --- a/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandOrb.java +++ b/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandOrb.java @@ -6,43 +6,40 @@ import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.command.CommandBloodMagic; import WayofTime.bloodmagic.util.Utils; import WayofTime.bloodmagic.util.helper.TextHelper; -import net.minecraft.command.*; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.PlayerNotFoundException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.server.MinecraftServer; import net.minecraft.util.text.TextComponentString; import java.util.Locale; -public class SubCommandOrb extends CommandBase -{ +public class SubCommandOrb extends CommandBase { @Override public String getName() { return "orb"; } @Override - public String getUsage(ICommandSender commandSender) - { + public String getUsage(ICommandSender commandSender) { return TextHelper.localizeEffect("commands.orb.usage"); } @Override - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return 2; } @Override - public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException - { - if (args.length > 0) - { + public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException { + if (args.length > 0) { if (args[0].equalsIgnoreCase("help")) return; - try - { + try { String givenName = commandSender.getName(); if (args.length > 1) @@ -54,70 +51,56 @@ public class SubCommandOrb extends CommandBase boolean displayHelp = args.length > 0 && args.length < 2; - try - { - switch (ValidCommands.valueOf(args[0].toUpperCase(Locale.ENGLISH))) - { - case SET: - { - if (displayHelp) - { - CommandBloodMagic.displayHelpString(commandSender, ValidCommands.SET.help); - break; - } - - if (args.length == 3) - { - if (Utils.isInteger(args[2])) - { - int amount = Integer.parseInt(args[2]); - network.setOrbTier(amount); - CommandBloodMagic.displaySuccessString(commandSender, "commands.success"); - } else - { - CommandBloodMagic.displayErrorString(commandSender, "commands.error.arg.invalid"); + try { + switch (ValidCommands.valueOf(args[0].toUpperCase(Locale.ENGLISH))) { + case SET: { + if (displayHelp) { + CommandBloodMagic.displayHelpString(commandSender, ValidCommands.SET.help); + break; + } + + if (args.length == 3) { + if (Utils.isInteger(args[2])) { + int amount = Integer.parseInt(args[2]); + network.setOrbTier(amount); + CommandBloodMagic.displaySuccessString(commandSender, "commands.success"); + } else { + CommandBloodMagic.displayErrorString(commandSender, "commands.error.arg.invalid"); + } + } else { + CommandBloodMagic.displayErrorString(commandSender, "commands.error.arg.missing"); } - } else - { - CommandBloodMagic.displayErrorString(commandSender, "commands.error.arg.missing"); - } - break; - } - case GET: - { - if (displayHelp) - { - CommandBloodMagic.displayHelpString(commandSender, ValidCommands.GET.help); break; } + case GET: { + if (displayHelp) { + CommandBloodMagic.displayHelpString(commandSender, ValidCommands.GET.help); + break; + } - if (args.length > 1) - commandSender.sendMessage(new TextComponentString(TextHelper.localizeEffect("message.orb.currenttier", network.getOrbTier()))); + if (args.length > 1) + commandSender.sendMessage(new TextComponentString(TextHelper.localizeEffect("message.orb.currenttier", network.getOrbTier()))); - break; + break; + } } - } - } catch (IllegalArgumentException e) - { + } catch (IllegalArgumentException e) { CommandBloodMagic.displayErrorString(commandSender, "commands.error.404"); } - } catch (PlayerNotFoundException e) - { + } catch (PlayerNotFoundException e) { CommandBloodMagic.displayErrorString(commandSender, "commands.error.404"); } } } - private enum ValidCommands - { + private enum ValidCommands { SET("commands.orb.set.help"), GET("commands.orb.get.help"); public String help; - ValidCommands(String help) - { + ValidCommands(String help) { this.help = help; } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/guideapi/BookUtils.java b/src/main/java/WayofTime/bloodmagic/compat/guideapi/BookUtils.java index 2b87114b..0c70656d 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/guideapi/BookUtils.java +++ b/src/main/java/WayofTime/bloodmagic/compat/guideapi/BookUtils.java @@ -1,37 +1,32 @@ package WayofTime.bloodmagic.compat.guideapi; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.ResourceLocation; import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer; import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry; import WayofTime.bloodmagic.client.render.alchemyArray.DualAlchemyCircleRenderer; import WayofTime.bloodmagic.compat.guideapi.page.PageAlchemyArray; import amerifrance.guideapi.page.PageIRecipe; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.ResourceLocation; -public class BookUtils -{ +import java.util.ArrayList; +import java.util.List; - public static PageAlchemyArray getAlchemyPage(String key) - { +public class BookUtils { + + public static PageAlchemyArray getAlchemyPage(String key) { ItemStack[] recipe = AlchemyArrayRecipeRegistry.getRecipeForArrayEffect(key); - if (recipe[0] != null) - { + if (recipe[0] != null) { ItemStack inputStack = recipe[0]; ItemStack catalystStack = recipe[1]; AlchemyCircleRenderer renderer = AlchemyArrayRecipeRegistry.getAlchemyCircleRenderer(inputStack, catalystStack); - if (renderer instanceof DualAlchemyCircleRenderer) - { + if (renderer instanceof DualAlchemyCircleRenderer) { List resources = new ArrayList(); resources.add(((DualAlchemyCircleRenderer) renderer).arrayResource); resources.add(((DualAlchemyCircleRenderer) renderer).secondaryArrayResource); return new PageAlchemyArray(resources, inputStack, catalystStack); - } else - { + } else { return new PageAlchemyArray(renderer.arrayResource, inputStack, catalystStack); } } @@ -39,25 +34,20 @@ public class BookUtils return null; } - public static PageAlchemyArray getAlchemyPage(ItemStack outputStack) - { + public static PageAlchemyArray getAlchemyPage(ItemStack outputStack) { ItemStack[] recipe = AlchemyArrayRecipeRegistry.getRecipeForOutputStack(outputStack); - if (recipe[0] != null) - { + if (recipe[0] != null) { ItemStack inputStack = recipe[0]; ItemStack catalystStack = recipe[1]; AlchemyCircleRenderer renderer = AlchemyArrayRecipeRegistry.getAlchemyCircleRenderer(inputStack, catalystStack); - if (renderer != null) - { - if (renderer instanceof DualAlchemyCircleRenderer) - { + if (renderer != null) { + if (renderer instanceof DualAlchemyCircleRenderer) { List resources = new ArrayList(); resources.add(((DualAlchemyCircleRenderer) renderer).arrayResource); resources.add(((DualAlchemyCircleRenderer) renderer).secondaryArrayResource); return new PageAlchemyArray(resources, inputStack, catalystStack, outputStack); - } else - { + } else { return new PageAlchemyArray(renderer.arrayResource, inputStack, catalystStack, outputStack); } } @@ -66,8 +56,7 @@ public class BookUtils return null; } - public static PageIRecipe getPageForRecipe(IRecipe recipe) - { + public static PageIRecipe getPageForRecipe(IRecipe recipe) { return new PageIRecipe(recipe); } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/guideapi/GuideBloodMagic.java b/src/main/java/WayofTime/bloodmagic/compat/guideapi/GuideBloodMagic.java index a3ee7f1a..39319de7 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/guideapi/GuideBloodMagic.java +++ b/src/main/java/WayofTime/bloodmagic/compat/guideapi/GuideBloodMagic.java @@ -1,7 +1,10 @@ package WayofTime.bloodmagic.compat.guideapi; import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.compat.guideapi.book.*; +import WayofTime.bloodmagic.compat.guideapi.book.CategoryAlchemy; +import WayofTime.bloodmagic.compat.guideapi.book.CategoryArchitect; +import WayofTime.bloodmagic.compat.guideapi.book.CategoryDemon; +import WayofTime.bloodmagic.compat.guideapi.book.CategoryRitual; import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import amerifrance.guideapi.api.GuideAPI; diff --git a/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryAlchemy.java b/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryAlchemy.java index 3e6f6549..a161cb2c 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryAlchemy.java +++ b/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryAlchemy.java @@ -22,10 +22,8 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -public class CategoryAlchemy -{ - public static Map buildCategory() - { +public class CategoryAlchemy { + public static Map buildCategory() { Map entries = new LinkedHashMap(); String keyBase = "guide." + BloodMagic.MODID + ".entry.alchemy."; @@ -36,8 +34,7 @@ public class CategoryAlchemy List ashPages = new ArrayList(); TartaricForgeRecipe ashRecipe = RecipeHelper.getForgeRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.ARCANE_ASHES)); - if (ashRecipe != null) - { + if (ashRecipe != null) { ashPages.add(new PageTartaricForgeRecipe(ashRecipe)); } ashPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "ash" + ".info"), 370)); @@ -46,8 +43,7 @@ public class CategoryAlchemy List speedPages = new ArrayList(); PageAlchemyArray speedRecipePage = BookUtils.getAlchemyPage("movement"); - if (speedRecipePage != null) - { + if (speedRecipePage != null) { speedPages.add(speedRecipePage); } speedPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "speed" + ".info"), 370)); @@ -56,8 +52,7 @@ public class CategoryAlchemy List updraftPages = new ArrayList(); PageAlchemyArray updraftRecipePage = BookUtils.getAlchemyPage("updraft"); - if (updraftRecipePage != null) - { + if (updraftRecipePage != null) { updraftPages.add(updraftRecipePage); } updraftPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "updraft" + ".info"), 370)); @@ -66,8 +61,7 @@ public class CategoryAlchemy List turretPages = new ArrayList(); PageAlchemyArray turretRecipePage = BookUtils.getAlchemyPage("skeletonTurret"); - if (turretRecipePage != null) - { + if (turretRecipePage != null) { turretPages.add(turretRecipePage); } turretPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "turret" + ".info"), 370)); @@ -76,8 +70,7 @@ public class CategoryAlchemy List bouncePages = new ArrayList(); PageAlchemyArray bounceRecipePage = BookUtils.getAlchemyPage("bounce"); - if (bounceRecipePage != null) - { + if (bounceRecipePage != null) { bouncePages.add(bounceRecipePage); } bouncePages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "bounce" + ".info"), 370)); @@ -91,19 +84,15 @@ public class CategoryAlchemy List fastMinerPages = new ArrayList(); PageAlchemyArray fastMinerRecipePage = BookUtils.getAlchemyPage("fastMiner"); - if (fastMinerRecipePage != null) - { + if (fastMinerRecipePage != null) { fastMinerPages.add(fastMinerRecipePage); } fastMinerPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "fastMiner" + ".info"), 370)); entries.put(new ResourceLocation(keyBase + "fastMiner"), new EntryText(fastMinerPages, TextHelper.localize(keyBase + "fastMiner"), true)); - for (Entry entry : entries.entrySet()) - { - for (IPage page : entry.getValue().pageList) - { - if (page instanceof PageText) - { + for (Entry entry : entries.entrySet()) { + for (IPage page : entry.getValue().pageList) { + if (page instanceof PageText) { ((PageText) page).setUnicodeFlag(true); } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryArchitect.java b/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryArchitect.java index a3c6f9e8..25ce9177 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryArchitect.java +++ b/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryArchitect.java @@ -1,16 +1,6 @@ package WayofTime.bloodmagic.compat.guideapi.book; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.core.RegistrarBloodMagic; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.ResourceLocation; import WayofTime.bloodmagic.api.recipe.TartaricForgeRecipe; import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry.AltarRecipe; import WayofTime.bloodmagic.api.registry.OrbRegistry; @@ -19,20 +9,28 @@ import WayofTime.bloodmagic.compat.guideapi.entry.EntryText; import WayofTime.bloodmagic.compat.guideapi.page.PageAlchemyArray; import WayofTime.bloodmagic.compat.guideapi.page.PageAltarRecipe; import WayofTime.bloodmagic.compat.guideapi.page.PageTartaricForgeRecipe; -import WayofTime.bloodmagic.item.ItemComponent; +import WayofTime.bloodmagic.core.RegistrarBloodMagic; import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.item.ItemComponent; import WayofTime.bloodmagic.util.helper.RecipeHelper; import WayofTime.bloodmagic.util.helper.TextHelper; import amerifrance.guideapi.api.IPage; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.api.util.PageHelper; import amerifrance.guideapi.page.PageText; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.ResourceLocation; -public class CategoryArchitect -{ - public static Map buildCategory() - { +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +public class CategoryArchitect { + public static Map buildCategory() { Map entries = new LinkedHashMap(); String keyBase = "guide." + BloodMagic.MODID + ".entry.architect."; @@ -44,16 +42,14 @@ public class CategoryArchitect List altarPages = new ArrayList(); IRecipe altarRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.ALTAR)); - if (altarRecipe != null) - { + if (altarRecipe != null) { altarPages.add(BookUtils.getPageForRecipe(altarRecipe)); } altarPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "bloodaltar" + ".info.1"), 370)); IRecipe daggerRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.SACRIFICIAL_DAGGER)); - if (daggerRecipe != null) - { + if (daggerRecipe != null) { altarPages.add(BookUtils.getPageForRecipe(daggerRecipe)); } @@ -63,8 +59,7 @@ public class CategoryArchitect List ashPages = new ArrayList(); TartaricForgeRecipe ashRecipe = RecipeHelper.getForgeRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.ARCANE_ASHES)); - if (ashRecipe != null) - { + if (ashRecipe != null) { ashPages.add(new PageTartaricForgeRecipe(ashRecipe)); } ashPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "ash" + ".info"), 370)); @@ -73,8 +68,7 @@ public class CategoryArchitect List divinationPages = new ArrayList(); PageAlchemyArray divinationRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_DIVINATION)); - if (divinationRecipePage != null) - { + if (divinationRecipePage != null) { divinationPages.add(divinationRecipePage); } @@ -90,8 +84,7 @@ public class CategoryArchitect weakorbPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "weakorb" + ".info.1"), 370)); AltarRecipe weakorbRecipe = RecipeHelper.getAltarRecipeForOutput(OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_WEAK)); - if (weakorbRecipe != null) - { + if (weakorbRecipe != null) { weakorbPages.add(new PageAltarRecipe(weakorbRecipe)); } @@ -101,16 +94,14 @@ public class CategoryArchitect List incensePages = new ArrayList(); IRecipe incenseRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.INCENSE_ALTAR)); - if (incenseRecipe != null) - { + if (incenseRecipe != null) { incensePages.add(BookUtils.getPageForRecipe(incenseRecipe)); } incensePages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "incense" + ".info.1"), 370)); IRecipe woodPathRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.PATH, 1, 0)); - if (woodPathRecipe != null) - { + if (woodPathRecipe != null) { incensePages.add(BookUtils.getPageForRecipe(woodPathRecipe)); } @@ -120,8 +111,7 @@ public class CategoryArchitect List runePages = new ArrayList(); IRecipe runeRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.BLOOD_RUNE, 1, 0)); - if (runeRecipe != null) - { + if (runeRecipe != null) { runePages.add(BookUtils.getPageForRecipe(runeRecipe)); } @@ -131,8 +121,7 @@ public class CategoryArchitect List inspectPages = new ArrayList(); AltarRecipe inspectRecipe = RecipeHelper.getAltarRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.SANGUINE_BOOK)); - if (inspectRecipe != null) - { + if (inspectRecipe != null) { inspectPages.add(new PageAltarRecipe(inspectRecipe)); } @@ -142,8 +131,7 @@ public class CategoryArchitect List speedRunePages = new ArrayList(); IRecipe speedRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.BLOOD_RUNE, 1, 1)); - if (speedRecipe != null) - { + if (speedRecipe != null) { speedRunePages.add(BookUtils.getPageForRecipe(speedRecipe)); } @@ -153,14 +141,12 @@ public class CategoryArchitect List waterPages = new ArrayList(); TartaricForgeRecipe waterRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_WATER)); - if (waterRecipe != null) - { + if (waterRecipe != null) { waterPages.add(new PageTartaricForgeRecipe(waterRecipe)); } PageAlchemyArray waterRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_WATER)); - if (waterRecipePage != null) - { + if (waterRecipePage != null) { waterPages.add(waterRecipePage); } @@ -170,14 +156,12 @@ public class CategoryArchitect List lavaPages = new ArrayList(); TartaricForgeRecipe lavaRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_LAVA)); - if (lavaRecipe != null) - { + if (lavaRecipe != null) { lavaPages.add(new PageTartaricForgeRecipe(lavaRecipe)); } PageAlchemyArray lavaRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_LAVA)); - if (lavaRecipePage != null) - { + if (lavaRecipePage != null) { lavaPages.add(lavaRecipePage); } @@ -187,8 +171,7 @@ public class CategoryArchitect List lavaCrystalPages = new ArrayList(); IRecipe lavaCrystalRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.LAVA_CRYSTAL)); - if (lavaCrystalRecipe != null) - { + if (lavaCrystalRecipe != null) { lavaCrystalPages.add(BookUtils.getPageForRecipe(lavaCrystalRecipe)); } @@ -198,8 +181,7 @@ public class CategoryArchitect List apprenticeorbPages = new ArrayList(); AltarRecipe apprenticeorbRecipe = RecipeHelper.getAltarRecipeForOutput(OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_APPRENTICE)); - if (apprenticeorbRecipe != null) - { + if (apprenticeorbRecipe != null) { apprenticeorbPages.add(new PageAltarRecipe(apprenticeorbRecipe)); } @@ -209,8 +191,7 @@ public class CategoryArchitect List daggerPages = new ArrayList(); AltarRecipe daggerOfSacrificeRecipe = RecipeHelper.getAltarRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.DAGGER_OF_SACRIFICE)); - if (daggerOfSacrificeRecipe != null) - { + if (daggerOfSacrificeRecipe != null) { daggerPages.add(new PageAltarRecipe(daggerOfSacrificeRecipe)); } @@ -220,8 +201,7 @@ public class CategoryArchitect List runeSacrificePages = new ArrayList(); IRecipe runeSacrificeRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.BLOOD_RUNE, 1, 3)); - if (runeSacrificeRecipe != null) - { + if (runeSacrificeRecipe != null) { runeSacrificePages.add(BookUtils.getPageForRecipe(runeSacrificeRecipe)); } @@ -231,8 +211,7 @@ public class CategoryArchitect List runeSelfSacrificePages = new ArrayList(); IRecipe runeSelfSacrificeRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.BLOOD_RUNE, 1, 4)); - if (runeSelfSacrificeRecipe != null) - { + if (runeSelfSacrificeRecipe != null) { runeSelfSacrificePages.add(BookUtils.getPageForRecipe(runeSelfSacrificeRecipe)); } @@ -242,14 +221,12 @@ public class CategoryArchitect List holdingPages = new ArrayList(); TartaricForgeRecipe holdingRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_HOLDING)); - if (holdingRecipe != null) - { + if (holdingRecipe != null) { holdingPages.add(new PageTartaricForgeRecipe(holdingRecipe)); } PageAlchemyArray holdingRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_HOLDING)); - if (holdingRecipePage != null) - { + if (holdingRecipePage != null) { holdingPages.add(holdingRecipePage); } @@ -259,14 +236,12 @@ public class CategoryArchitect List airPages = new ArrayList(); TartaricForgeRecipe airRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_AIR)); - if (airRecipe != null) - { + if (airRecipe != null) { airPages.add(new PageTartaricForgeRecipe(airRecipe)); } PageAlchemyArray airRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_AIR)); - if (airRecipePage != null) - { + if (airRecipePage != null) { airPages.add(airRecipePage); } @@ -276,14 +251,12 @@ public class CategoryArchitect List voidPages = new ArrayList(); TartaricForgeRecipe voidRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_VOID)); - if (voidRecipe != null) - { + if (voidRecipe != null) { voidPages.add(new PageTartaricForgeRecipe(voidRecipe)); } PageAlchemyArray voidRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_VOID)); - if (voidRecipePage != null) - { + if (voidRecipePage != null) { voidPages.add(voidRecipePage); } @@ -293,14 +266,12 @@ public class CategoryArchitect List greenGrovePages = new ArrayList(); TartaricForgeRecipe greenGroveRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_GROWTH)); - if (greenGroveRecipe != null) - { + if (greenGroveRecipe != null) { greenGrovePages.add(new PageTartaricForgeRecipe(greenGroveRecipe)); } PageAlchemyArray greenGroveRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_GREEN_GROVE)); - if (greenGroveRecipePage != null) - { + if (greenGroveRecipePage != null) { greenGrovePages.add(greenGroveRecipePage); } @@ -310,14 +281,12 @@ public class CategoryArchitect List fastMinerPages = new ArrayList(); TartaricForgeRecipe fastMinerRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_FASTMINER)); - if (fastMinerRecipe != null) - { + if (fastMinerRecipe != null) { fastMinerPages.add(new PageTartaricForgeRecipe(fastMinerRecipe)); } PageAlchemyArray fastMinerRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_FAST_MINER)); - if (fastMinerRecipePage != null) - { + if (fastMinerRecipePage != null) { fastMinerPages.add(fastMinerRecipePage); } @@ -327,14 +296,12 @@ public class CategoryArchitect List seerPages = new ArrayList(); TartaricForgeRecipe seerRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_SIGHT)); - if (seerRecipe != null) - { + if (seerRecipe != null) { seerPages.add(new PageTartaricForgeRecipe(seerRecipe)); } PageAlchemyArray seerRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_SEER)); - if (seerRecipePage != null) - { + if (seerRecipePage != null) { seerPages.add(seerRecipePage); } @@ -344,8 +311,7 @@ public class CategoryArchitect List magicianOrbPages = new ArrayList(); AltarRecipe magicianOrbRecipe = RecipeHelper.getAltarRecipeForOutput(OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_MAGICIAN)); - if (magicianOrbRecipe != null) - { + if (magicianOrbRecipe != null) { magicianOrbPages.add(new PageAltarRecipe(magicianOrbRecipe)); } @@ -355,8 +321,7 @@ public class CategoryArchitect List capacityPages = new ArrayList(); IRecipe capacityRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.BLOOD_RUNE, 1, 4)); - if (capacityRecipe != null) - { + if (capacityRecipe != null) { capacityPages.add(BookUtils.getPageForRecipe(capacityRecipe)); } @@ -366,8 +331,7 @@ public class CategoryArchitect List displacementPages = new ArrayList(); IRecipe displacementRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.BLOOD_RUNE, 1, 4)); - if (displacementRecipe != null) - { + if (displacementRecipe != null) { displacementPages.add(BookUtils.getPageForRecipe(displacementRecipe)); } @@ -377,14 +341,12 @@ public class CategoryArchitect List affinityPages = new ArrayList(); TartaricForgeRecipe affinityRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_AFFINITY)); - if (affinityRecipe != null) - { + if (affinityRecipe != null) { affinityPages.add(new PageTartaricForgeRecipe(affinityRecipe)); } PageAlchemyArray affinityRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_ELEMENTAL_AFFINITY)); - if (affinityRecipePage != null) - { + if (affinityRecipePage != null) { affinityPages.add(affinityRecipePage); } @@ -394,14 +356,12 @@ public class CategoryArchitect List lampPages = new ArrayList(); TartaricForgeRecipe lampRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_BLOODLIGHT)); - if (lampRecipe != null) - { + if (lampRecipe != null) { lampPages.add(new PageTartaricForgeRecipe(lampRecipe)); } PageAlchemyArray lampRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_BLOOD_LIGHT)); - if (lampRecipePage != null) - { + if (lampRecipePage != null) { lampPages.add(lampRecipePage); } @@ -411,14 +371,12 @@ public class CategoryArchitect List magnetismPages = new ArrayList(); TartaricForgeRecipe magnetismRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_MAGNETISM)); - if (magnetismRecipe != null) - { + if (magnetismRecipe != null) { magnetismPages.add(new PageTartaricForgeRecipe(magnetismRecipe)); } PageAlchemyArray magnetismRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_MAGNETISM)); - if (magnetismRecipePage != null) - { + if (magnetismRecipePage != null) { magnetismPages.add(magnetismRecipePage); } @@ -428,8 +386,7 @@ public class CategoryArchitect List peritiaPages = new ArrayList(); IRecipe peritiaRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.EXPERIENCE_TOME)); - if (peritiaRecipe != null) - { + if (peritiaRecipe != null) { peritiaPages.add(BookUtils.getPageForRecipe(peritiaRecipe)); } @@ -439,32 +396,27 @@ public class CategoryArchitect List livingArmourPages = new ArrayList(); TartaricForgeRecipe bindingRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_BINDING)); - if (bindingRecipe != null) - { + if (bindingRecipe != null) { livingArmourPages.add(new PageTartaricForgeRecipe(bindingRecipe)); } PageAlchemyArray bindingRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)); - if (bindingRecipePage != null) - { + if (bindingRecipePage != null) { livingArmourPages.add(bindingRecipePage); } bindingRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET)); - if (bindingRecipePage != null) - { + if (bindingRecipePage != null) { livingArmourPages.add(bindingRecipePage); } bindingRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS)); - if (bindingRecipePage != null) - { + if (bindingRecipePage != null) { livingArmourPages.add(bindingRecipePage); } bindingRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS)); - if (bindingRecipePage != null) - { + if (bindingRecipePage != null) { livingArmourPages.add(bindingRecipePage); } @@ -484,14 +436,12 @@ public class CategoryArchitect List teleposerPages = new ArrayList(); AltarRecipe teleposerFocusRecipe = RecipeHelper.getAltarRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.TELEPOSITION_FOCUS)); - if (teleposerFocusRecipe != null) - { + if (teleposerFocusRecipe != null) { teleposerPages.add(new PageAltarRecipe(teleposerFocusRecipe)); } IRecipe teleposerRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.TELEPOSER)); - if (teleposerRecipe != null) - { + if (teleposerRecipe != null) { teleposerPages.add(BookUtils.getPageForRecipe(teleposerRecipe)); } @@ -501,8 +451,7 @@ public class CategoryArchitect List boundBladePages = new ArrayList(); PageAlchemyArray boundBladePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.BOUND_SWORD)); - if (boundBladePage != null) - { + if (boundBladePage != null) { boundBladePages.add(boundBladePage); } @@ -512,20 +461,17 @@ public class CategoryArchitect List boundToolPages = new ArrayList(); PageAlchemyArray boundToolPage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.BOUND_PICKAXE)); - if (boundToolPage != null) - { + if (boundToolPage != null) { boundToolPages.add(boundToolPage); } boundToolPage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.BOUND_AXE)); - if (boundToolPage != null) - { + if (boundToolPage != null) { boundToolPages.add(boundToolPage); } boundToolPage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.BOUND_SHOVEL)); - if (boundToolPage != null) - { + if (boundToolPage != null) { boundToolPages.add(boundToolPage); } @@ -540,8 +486,7 @@ public class CategoryArchitect List masterOrbPages = new ArrayList(); AltarRecipe masterOrbRecipe = RecipeHelper.getAltarRecipeForOutput(OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_MASTER)); - if (magicianOrbRecipe != null) - { + if (magicianOrbRecipe != null) { masterOrbPages.add(new PageAltarRecipe(masterOrbRecipe)); } @@ -551,8 +496,7 @@ public class CategoryArchitect List orbRunePages = new ArrayList(); IRecipe orbRuneRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.BLOOD_RUNE, 1, 8)); - if (orbRuneRecipe != null) - { + if (orbRuneRecipe != null) { orbRunePages.add(BookUtils.getPageForRecipe(orbRuneRecipe)); } @@ -562,8 +506,7 @@ public class CategoryArchitect List augmentedCapacityPages = new ArrayList(); IRecipe augmentedCapacityRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.BLOOD_RUNE, 1, 7)); - if (orbRuneRecipe != null) - { + if (orbRuneRecipe != null) { augmentedCapacityPages.add(BookUtils.getPageForRecipe(augmentedCapacityRecipe)); } @@ -573,8 +516,7 @@ public class CategoryArchitect List chargingPages = new ArrayList(); IRecipe chargingRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.BLOOD_RUNE, 1, 10)); - if (orbRuneRecipe != null) - { + if (orbRuneRecipe != null) { chargingPages.add(BookUtils.getPageForRecipe(chargingRecipe)); } @@ -584,8 +526,7 @@ public class CategoryArchitect List accelerationPages = new ArrayList(); IRecipe accelerationRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.BLOOD_RUNE, 1, 9)); - if (orbRuneRecipe != null) - { + if (orbRuneRecipe != null) { accelerationPages.add(BookUtils.getPageForRecipe(accelerationRecipe)); } @@ -595,14 +536,12 @@ public class CategoryArchitect List suppressionPages = new ArrayList(); TartaricForgeRecipe suppressionRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_SUPPRESSION)); - if (suppressionRecipe != null) - { + if (suppressionRecipe != null) { suppressionPages.add(new PageTartaricForgeRecipe(suppressionRecipe)); } PageAlchemyArray suppressionRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_SUPPRESSION)); - if (suppressionRecipePage != null) - { + if (suppressionRecipePage != null) { suppressionPages.add(suppressionRecipePage); } @@ -612,14 +551,12 @@ public class CategoryArchitect List hastePages = new ArrayList(); TartaricForgeRecipe hasteRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_HASTE)); - if (hasteRecipe != null) - { + if (hasteRecipe != null) { hastePages.add(new PageTartaricForgeRecipe(hasteRecipe)); } PageAlchemyArray hasteRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_HASTE)); - if (hasteRecipePage != null) - { + if (hasteRecipePage != null) { hastePages.add(hasteRecipePage); } @@ -629,14 +566,12 @@ public class CategoryArchitect List severancePages = new ArrayList(); TartaricForgeRecipe severanceRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_SEVERANCE)); - if (severanceRecipe != null) - { + if (severanceRecipe != null) { severancePages.add(new PageTartaricForgeRecipe(severanceRecipe)); } PageAlchemyArray severanceRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_ENDER_SEVERANCE)); - if (severanceRecipePage != null) - { + if (severanceRecipePage != null) { severancePages.add(severanceRecipePage); } @@ -646,14 +581,12 @@ public class CategoryArchitect List telepositionPages = new ArrayList(); TartaricForgeRecipe telepositionRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_TELEPOSITION)); - if (telepositionRecipe != null) - { + if (telepositionRecipe != null) { telepositionPages.add(new PageTartaricForgeRecipe(telepositionRecipe)); } PageAlchemyArray telepositionRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_TELEPOSITION)); - if (telepositionRecipePage != null) - { + if (telepositionRecipePage != null) { telepositionPages.add(telepositionRecipePage); } @@ -663,14 +596,12 @@ public class CategoryArchitect List compressionPages = new ArrayList(); TartaricForgeRecipe compressionRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_COMPRESSION)); - if (compressionRecipe != null) - { + if (compressionRecipe != null) { compressionPages.add(new PageTartaricForgeRecipe(compressionRecipe)); } PageAlchemyArray compressionRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_COMPRESSION)); - if (compressionRecipePage != null) - { + if (compressionRecipePage != null) { compressionPages.add(compressionRecipePage); } @@ -680,14 +611,12 @@ public class CategoryArchitect List bridgePages = new ArrayList(); TartaricForgeRecipe bridgeRecipe = RecipeHelper.getForgeRecipeForOutput(ItemComponent.getStack(ItemComponent.REAGENT_BRIDGE)); - if (bridgeRecipe != null) - { + if (bridgeRecipe != null) { bridgePages.add(new PageTartaricForgeRecipe(bridgeRecipe)); } PageAlchemyArray bridgeRecipePage = BookUtils.getAlchemyPage(new ItemStack(RegistrarBloodMagicItems.SIGIL_PHANTOM_BRIDGE)); - if (bridgeRecipePage != null) - { + if (bridgeRecipePage != null) { bridgePages.add(bridgeRecipePage); } @@ -697,20 +626,16 @@ public class CategoryArchitect List mimicPages = new ArrayList(); IRecipe mimicRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.MIMIC, 1, 1)); - if (mimicRecipe != null) - { + if (mimicRecipe != null) { mimicPages.add(BookUtils.getPageForRecipe(mimicRecipe)); } mimicPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "mimic" + ".info.1"), 370)); entries.put(new ResourceLocation(keyBase + "mimic"), new EntryText(mimicPages, TextHelper.localize(keyBase + "mimic"), true)); - for (Entry entry : entries.entrySet()) - { - for (IPage page : entry.getValue().pageList) - { - if (page instanceof PageText) - { + for (Entry entry : entries.entrySet()) { + for (IPage page : entry.getValue().pageList) { + if (page instanceof PageText) { ((PageText) page).setUnicodeFlag(true); } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryDemon.java b/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryDemon.java index c64ca7fc..3c5c338d 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryDemon.java +++ b/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryDemon.java @@ -1,15 +1,6 @@ package WayofTime.bloodmagic.compat.guideapi.book; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.ResourceLocation; import WayofTime.bloodmagic.api.recipe.TartaricForgeRecipe; import WayofTime.bloodmagic.compat.guideapi.BookUtils; import WayofTime.bloodmagic.compat.guideapi.entry.EntryText; @@ -22,12 +13,19 @@ import amerifrance.guideapi.api.IPage; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.api.util.PageHelper; import amerifrance.guideapi.page.PageText; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.ResourceLocation; -public class CategoryDemon -{ +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +public class CategoryDemon { //TODO: Add Forge recipe pages - public static Map buildCategory() - { + public static Map buildCategory() { Map entries = new LinkedHashMap(); String keyBase = "guide." + BloodMagic.MODID + ".entry.demon."; @@ -40,8 +38,7 @@ public class CategoryDemon snarePages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "snare" + ".info.1"), 370)); IRecipe snareRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.SOUL_SNARE)); - if (snareRecipe != null) - { + if (snareRecipe != null) { snarePages.add(BookUtils.getPageForRecipe(snareRecipe)); } @@ -52,8 +49,7 @@ public class CategoryDemon forgePages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "forge" + ".info.1"), 370)); IRecipe forgeRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.SOUL_FORGE)); - if (forgeRecipe != null) - { + if (forgeRecipe != null) { forgePages.add(BookUtils.getPageForRecipe(forgeRecipe)); } @@ -63,8 +59,7 @@ public class CategoryDemon List pettyPages = new ArrayList(); pettyPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "petty" + ".info.1"), 370)); TartaricForgeRecipe pettyRecipe = RecipeHelper.getForgeRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.SOUL_GEM)); - if (pettyRecipe != null) - { + if (pettyRecipe != null) { pettyPages.add(new PageTartaricForgeRecipe(pettyRecipe)); } pettyPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "petty" + ".info.2"), 370)); @@ -73,8 +68,7 @@ public class CategoryDemon List swordPages = new ArrayList(); swordPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "sword" + ".info.1"), 370)); TartaricForgeRecipe swordRecipe = RecipeHelper.getForgeRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.SENTIENT_SWORD)); - if (swordRecipe != null) - { + if (swordRecipe != null) { swordPages.add(new PageTartaricForgeRecipe(swordRecipe)); } swordPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "sword" + ".info.2"), 370)); @@ -83,8 +77,7 @@ public class CategoryDemon List lesserPages = new ArrayList(); lesserPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "lesser" + ".info.1"), 370)); TartaricForgeRecipe lesserRecipe = RecipeHelper.getForgeRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 1)); - if (lesserRecipe != null) - { + if (lesserRecipe != null) { lesserPages.add(new PageTartaricForgeRecipe(lesserRecipe)); } lesserPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "lesser" + ".info.2"), 370)); @@ -101,29 +94,24 @@ public class CategoryDemon List routingPages = new ArrayList(); TartaricForgeRecipe nodeRecipe = RecipeHelper.getForgeRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.ITEM_ROUTING_NODE)); - if (nodeRecipe != null) - { + if (nodeRecipe != null) { routingPages.add(new PageTartaricForgeRecipe(nodeRecipe)); } TartaricForgeRecipe inputNodeRecipe = RecipeHelper.getForgeRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.INPUT_ROUTING_NODE)); - if (inputNodeRecipe != null) - { + if (inputNodeRecipe != null) { routingPages.add(new PageTartaricForgeRecipe(inputNodeRecipe)); } TartaricForgeRecipe outputNodeRecipe = RecipeHelper.getForgeRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.OUTPUT_ROUTING_NODE)); - if (outputNodeRecipe != null) - { + if (outputNodeRecipe != null) { routingPages.add(new PageTartaricForgeRecipe(outputNodeRecipe)); } TartaricForgeRecipe masterNodeRecipe = RecipeHelper.getForgeRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.MASTER_ROUTING_NODE)); - if (masterNodeRecipe != null) - { + if (masterNodeRecipe != null) { routingPages.add(new PageTartaricForgeRecipe(masterNodeRecipe)); } TartaricForgeRecipe nodeRouterRecipe = RecipeHelper.getForgeRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.NODE_ROUTER)); - if (nodeRouterRecipe != null) - { + if (nodeRouterRecipe != null) { routingPages.add(new PageTartaricForgeRecipe(nodeRouterRecipe)); } @@ -143,8 +131,7 @@ public class CategoryDemon List cruciblePages = new ArrayList(); TartaricForgeRecipe crucibleRecipe = RecipeHelper.getForgeRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.DEMON_CRUCIBLE)); - if (crucibleRecipe != null) - { + if (crucibleRecipe != null) { cruciblePages.add(new PageTartaricForgeRecipe(crucibleRecipe)); } @@ -154,8 +141,7 @@ public class CategoryDemon List crystallizerPages = new ArrayList(); TartaricForgeRecipe crystallizerRecipe = RecipeHelper.getForgeRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.DEMON_CRYSTALLIZER)); - if (crystallizerRecipe != null) - { + if (crystallizerRecipe != null) { crystallizerPages.add(new PageTartaricForgeRecipe(crystallizerRecipe)); } @@ -165,8 +151,7 @@ public class CategoryDemon List clusterPages = new ArrayList(); TartaricForgeRecipe clusterRecipe = RecipeHelper.getForgeRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.DEMON_CRYSTAL)); - if (clusterRecipe != null) - { + if (clusterRecipe != null) { clusterPages.add(new PageTartaricForgeRecipe(clusterRecipe)); } @@ -176,8 +161,7 @@ public class CategoryDemon List pylonPages = new ArrayList(); TartaricForgeRecipe pylonRecipe = RecipeHelper.getForgeRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.DEMON_PYLON)); - if (pylonRecipe != null) - { + if (pylonRecipe != null) { pylonPages.add(new PageTartaricForgeRecipe(pylonRecipe)); } @@ -187,20 +171,16 @@ public class CategoryDemon List gaugePages = new ArrayList(); TartaricForgeRecipe gaugeRecipe = RecipeHelper.getForgeRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.DEMON_WILL_GAUGE)); - if (gaugeRecipe != null) - { + if (gaugeRecipe != null) { gaugePages.add(new PageTartaricForgeRecipe(gaugeRecipe)); } gaugePages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "gauge" + ".info"), 370)); entries.put(new ResourceLocation(keyBase + "gauge"), new EntryText(gaugePages, TextHelper.localize(keyBase + "gauge"), true)); - for (Entry entry : entries.entrySet()) - { - for (IPage page : entry.getValue().pageList) - { - if (page instanceof PageText) - { + for (Entry entry : entries.entrySet()) { + for (IPage page : entry.getValue().pageList) { + if (page instanceof PageText) { ((PageText) page).setUnicodeFlag(true); } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryRitual.java b/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryRitual.java index 62b1cf94..a294a615 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryRitual.java +++ b/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategoryRitual.java @@ -1,15 +1,6 @@ package WayofTime.bloodmagic.compat.guideapi.book; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.ResourceLocation; import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry.AltarRecipe; import WayofTime.bloodmagic.api.ritual.EnumRuneType; import WayofTime.bloodmagic.compat.guideapi.BookUtils; @@ -23,13 +14,20 @@ import amerifrance.guideapi.api.IPage; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.api.util.PageHelper; import amerifrance.guideapi.page.PageText; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.ResourceLocation; -public class CategoryRitual -{ +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +public class CategoryRitual { static String keyBase = "guide." + BloodMagic.MODID + ".entry.ritual."; - public static Map buildCategory() - { + public static Map buildCategory() { Map entries = new LinkedHashMap(); addRitualPagesToEntries("intro", entries); @@ -38,19 +36,16 @@ public class CategoryRitual List ritualStonePages = new ArrayList(); IRecipe ritualStoneRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.RITUAL_STONE)); - if (ritualStoneRecipe != null) - { + if (ritualStoneRecipe != null) { ritualStonePages.add(BookUtils.getPageForRecipe(ritualStoneRecipe)); } ritualStonePages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "ritualStone" + ".info.1"), 370)); - for (int i = 1; i < 5; i++) - { + for (int i = 1; i < 5; i++) { EnumRuneType type = EnumRuneType.values()[i]; AltarRecipe scribeRecipe = RecipeHelper.getAltarRecipeForOutput(type.getScribeStack()); - if (scribeRecipe != null) - { + if (scribeRecipe != null) { ritualStonePages.add(new PageAltarRecipe(scribeRecipe)); } } @@ -61,8 +56,7 @@ public class CategoryRitual List masterRitualStonePages = new ArrayList(); IRecipe masterRitualStoneRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicBlocks.RITUAL_CONTROLLER, 1, 0)); - if (masterRitualStoneRecipe != null) - { + if (masterRitualStoneRecipe != null) { masterRitualStonePages.add(BookUtils.getPageForRecipe(masterRitualStoneRecipe)); } @@ -74,8 +68,7 @@ public class CategoryRitual activationCrystalPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "activationCrystal" + ".info.1"), 370)); AltarRecipe crystalRecipe = RecipeHelper.getAltarRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.ACTIVATION_CRYSTAL)); - if (crystalRecipe != null) - { + if (crystalRecipe != null) { activationCrystalPages.add(new PageAltarRecipe(crystalRecipe)); } @@ -87,8 +80,7 @@ public class CategoryRitual divinerPages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + "diviner" + ".info.1"), 370)); IRecipe divinerRecipe = RecipeHelper.getRecipeForOutput(new ItemStack(RegistrarBloodMagicItems.RITUAL_DIVINER)); - if (divinerRecipe != null) - { + if (divinerRecipe != null) { divinerPages.add(BookUtils.getPageForRecipe(divinerRecipe)); } @@ -116,12 +108,9 @@ public class CategoryRitual addRitualPagesToEntries("meteor", entries); addRitualPagesToEntries("downgrade", entries); - for (Entry entry : entries.entrySet()) - { - for (IPage page : entry.getValue().pageList) - { - if (page instanceof PageText) - { + for (Entry entry : entries.entrySet()) { + for (IPage page : entry.getValue().pageList) { + if (page instanceof PageText) { ((PageText) page).setUnicodeFlag(true); } } @@ -130,8 +119,7 @@ public class CategoryRitual return entries; } - public static void addRitualPagesToEntries(String name, Map entries) - { + public static void addRitualPagesToEntries(String name, Map entries) { List pages = new ArrayList(); pages.addAll(PageHelper.pagesForLongText(TextHelper.localize(keyBase + name + ".info"), 370)); entries.put(new ResourceLocation(keyBase + name), new EntryText(pages, TextHelper.localize(keyBase + name), true)); diff --git a/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategorySpell.java b/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategorySpell.java index 52aaa64d..765791a1 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategorySpell.java +++ b/src/main/java/WayofTime/bloodmagic/compat/guideapi/book/CategorySpell.java @@ -4,14 +4,11 @@ import WayofTime.bloodmagic.api.Constants; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import net.minecraft.util.ResourceLocation; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; -public class CategorySpell -{ - public static Map buildCategory() - { +public class CategorySpell { + public static Map buildCategory() { Map entries = new LinkedHashMap(); String keyBase = Constants.Mod.DOMAIN + "spell_"; diff --git a/src/main/java/WayofTime/bloodmagic/compat/guideapi/entry/EntryText.java b/src/main/java/WayofTime/bloodmagic/compat/guideapi/entry/EntryText.java index f14b372f..577e4f85 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/guideapi/entry/EntryText.java +++ b/src/main/java/WayofTime/bloodmagic/compat/guideapi/entry/EntryText.java @@ -8,7 +8,6 @@ import amerifrance.guideapi.entry.EntryResourceLocation; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -16,23 +15,19 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.Collections; import java.util.List; -public class EntryText extends EntryResourceLocation -{ +public class EntryText extends EntryResourceLocation { - public EntryText(List pageList, String unlocEntryName, boolean unicode) - { + public EntryText(List pageList, String unlocEntryName, boolean unicode) { super(pageList, unlocEntryName, new ResourceLocation("bloodmagicguide", "textures/gui/bullet_point.png"), unicode); } - public EntryText(List pageList, String unlocEntryName) - { + public EntryText(List pageList, String unlocEntryName) { this(pageList, unlocEntryName, false); } @Override @SideOnly(Side.CLIENT) - public void drawExtras(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) - { + public void drawExtras(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { Minecraft.getMinecraft().getTextureManager().bindTexture(image); GuiHelper.drawSizedIconWithoutColor(entryX + 4, entryY + 2, 8, 8, 1F); @@ -46,8 +41,7 @@ public class EntryText extends EntryResourceLocation if (strWidth > guiBase.xSize - 80 && strWidth > fontRendererObj.getStringWidth("...")) cutString = true; - if (GuiHelper.isMouseBetween(mouseX, mouseY, entryX, entryY, entryWidth, entryHeight) && cutString) - { + if (GuiHelper.isMouseBetween(mouseX, mouseY, entryX, entryY, entryWidth, entryHeight) && cutString) { guiBase.drawHoveringText(Collections.singletonList(getLocalizedName()), entryX, entryY + 12); fontRendererObj.setUnicodeFlag(unicode); 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 3c5479de..8529425f 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageAlchemyArray.java +++ b/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageAlchemyArray.java @@ -1,17 +1,5 @@ package WayofTime.bloodmagic.compat.guideapi.page; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import WayofTime.bloodmagic.util.helper.TextHelper; import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.api.impl.Page; @@ -19,15 +7,24 @@ import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.gui.GuiBase; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; -public class PageAlchemyArray extends Page -{ +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class PageAlchemyArray extends Page { public static final double scale = 58d / 256d; - public List arrayResources = new ArrayList(); public final ItemStack inputStack; public final ItemStack catalystStack; - public final ItemStack outputStack; + public List arrayResources = new ArrayList(); public PageAlchemyArray(List arrayResources, ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack) { this.arrayResources = arrayResources; @@ -36,25 +33,21 @@ public class PageAlchemyArray extends Page this.outputStack = outputStack; } - public PageAlchemyArray(List resources, ItemStack inputStack, ItemStack catalystStack) - { + public PageAlchemyArray(List resources, ItemStack inputStack, ItemStack catalystStack) { this(resources, inputStack, catalystStack, ItemStack.EMPTY); } - public PageAlchemyArray(ResourceLocation resource, ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack) - { + public PageAlchemyArray(ResourceLocation resource, ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack) { this(Collections.singletonList(resource), inputStack, catalystStack, outputStack); } - public PageAlchemyArray(ResourceLocation resource, ItemStack inputStack, ItemStack catalystStack) - { + public PageAlchemyArray(ResourceLocation resource, ItemStack inputStack, ItemStack catalystStack) { this(Collections.singletonList(resource), inputStack, catalystStack); } @Override @SideOnly(Side.CLIENT) - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRenderer) - { + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRenderer) { int x = guiLeft + 65; int y = guiTop + 30; @@ -63,8 +56,7 @@ public class PageAlchemyArray extends Page guiBase.drawCenteredString(fontRenderer, TextHelper.localize("guide.bloodmagic.page.alchemyArray"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0); - for (ResourceLocation arrayResource : arrayResources) - { + for (ResourceLocation arrayResource : arrayResources) { Minecraft.getMinecraft().getTextureManager().bindTexture(arrayResource); GlStateManager.pushMatrix(); GlStateManager.translate(x + 2, y + 28, 0); @@ -81,24 +73,20 @@ public class PageAlchemyArray extends Page int catalystY = y + 3; GuiHelper.drawItemStack(catalystStack, catalystX, catalystY); - if (GuiHelper.isMouseBetween(mouseX, mouseY, inputX, inputY, 15, 15)) - { + if (GuiHelper.isMouseBetween(mouseX, mouseY, inputX, inputY, 15, 15)) { guiBase.renderToolTip(inputStack, mouseX, mouseY); } - if (GuiHelper.isMouseBetween(mouseX, mouseY, catalystX, catalystY, 15, 15)) - { + if (GuiHelper.isMouseBetween(mouseX, mouseY, catalystX, catalystY, 15, 15)) { guiBase.renderToolTip(catalystStack, mouseX, mouseY); } - if (!outputStack.isEmpty()) - { + if (!outputStack.isEmpty()) { int outputX = x + 43; int outputY = y + 95; GuiHelper.drawItemStack(outputStack, outputX, outputY); - if (GuiHelper.isMouseBetween(mouseX, mouseY, outputX, outputY, 15, 15)) - { + if (GuiHelper.isMouseBetween(mouseX, mouseY, outputX, outputY, 15, 15)) { guiBase.renderToolTip(outputStack, mouseX, mouseY); } } 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 a8402b0a..6117a981 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageAltarRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageAltarRecipe.java @@ -20,16 +20,14 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class PageAltarRecipe extends Page -{ +public class PageAltarRecipe extends Page { public List input; public ItemStack output; public int tier; public int bloodRequired; - public PageAltarRecipe(AltarRecipeRegistry.AltarRecipe recipe) - { + public PageAltarRecipe(AltarRecipeRegistry.AltarRecipe recipe) { this.input = ItemStackWrapper.toStackList(recipe.getInput()); this.output = recipe.getOutput(); this.tier = recipe.getMinTier().toInt(); @@ -38,8 +36,7 @@ public class PageAltarRecipe extends Page @Override @SideOnly(Side.CLIENT) - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRenderer) - { + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRenderer) { Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("bloodmagicguide" + ":textures/gui/altar.png")); guiBase.drawTexturedModalRect(guiLeft + 42, guiTop + 53, 0, 0, 146, 104); @@ -48,25 +45,21 @@ public class PageAltarRecipe extends Page int inputX = (1 + 1) * 20 + (guiLeft + guiBase.xSize / 7) + 1; int inputY = (20) + (guiTop + guiBase.ySize / 5) - 1; //1 * 20 GuiHelper.drawItemStack(input.get(0), inputX, inputY); - if (GuiHelper.isMouseBetween(mouseX, mouseY, inputX, inputY, 15, 15)) - { + if (GuiHelper.isMouseBetween(mouseX, mouseY, inputX, inputY, 15, 15)) { guiBase.renderToolTip(input.get(0), mouseX, mouseY); } - if (output.isEmpty()) - { + if (output.isEmpty()) { output = new ItemStack(Blocks.BARRIER); } int outputX = (5 * 20) + (guiLeft + guiBase.xSize / 7) + 1; int outputY = (20) + (guiTop + guiBase.xSize / 5) - 1; // 1 * 20 GuiHelper.drawItemStack(output, outputX, outputY); - if (GuiHelper.isMouseBetween(mouseX, mouseY, outputX, outputY, 15, 15)) - { + if (GuiHelper.isMouseBetween(mouseX, mouseY, outputX, outputY, 15, 15)) { guiBase.renderToolTip(output, outputX, outputY); } - if (output.getItem() == Item.getItemFromBlock(Blocks.BARRIER)) - { + if (output.getItem() == Item.getItemFromBlock(Blocks.BARRIER)) { guiBase.drawCenteredString(fontRenderer, TextHelper.localize("text.furnace.error"), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6, 0xED073D); guiBase.drawCenteredString(fontRenderer, TextHelper.localize("bm.string.tier") + ": " + String.valueOf(tier), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6 + 15, 0); guiBase.drawCenteredString(fontRenderer, "LP: " + String.valueOf(bloodRequired), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6 + 30, 0); diff --git a/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageTartaricForgeRecipe.java b/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageTartaricForgeRecipe.java index 51021663..7f52af4a 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageTartaricForgeRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/compat/guideapi/page/PageTartaricForgeRecipe.java @@ -1,17 +1,5 @@ package WayofTime.bloodmagic.compat.guideapi.page; -import java.util.List; -import java.util.Random; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.oredict.OreDictionary; import WayofTime.bloodmagic.api.recipe.TartaricForgeRecipe; import WayofTime.bloodmagic.api.registry.OrbRegistry; import WayofTime.bloodmagic.util.helper.TextHelper; @@ -21,9 +9,20 @@ import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.gui.GuiBase; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.oredict.OreDictionary; -public class PageTartaricForgeRecipe extends Page -{ +import java.util.List; +import java.util.Random; + +public class PageTartaricForgeRecipe extends Page { public List input; public ItemStack output; public int tier; @@ -33,8 +32,7 @@ public class PageTartaricForgeRecipe extends Page private int cycleIdx = 0; private Random rand = new Random(); - public PageTartaricForgeRecipe(TartaricForgeRecipe recipe) - { + public PageTartaricForgeRecipe(TartaricForgeRecipe recipe) { this.input = recipe.getInput(); this.output = recipe.getRecipeOutput(); this.tier = 0; @@ -45,8 +43,7 @@ public class PageTartaricForgeRecipe extends Page @SuppressWarnings("unchecked") @Override @SideOnly(Side.CLIENT) - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRenderer) - { + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRenderer) { Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("bloodmagicguide" + ":textures/gui/soulForge.png")); guiBase.drawTexturedModalRect(guiLeft + 42, guiTop + 53, 0, 0, 146, 104); @@ -55,49 +52,38 @@ public class PageTartaricForgeRecipe extends Page // int inputX = (1 + 1) * 20 + (guiLeft + guiBase.xSize / 7) + 1; // int inputY = (20) + (guiTop + guiBase.ySize / 5) - 1; //1 * 20 - for (int y = 0; y < 2; y++) - { - for (int x = 0; x < 2; x++) - { + for (int y = 0; y < 2; y++) { + for (int x = 0; x < 2; x++) { int stackX = (x + 1) * 20 + (guiLeft + guiBase.xSize / 7) + 1; int stackY = (y + 1) * 20 + (guiTop + guiBase.ySize / 5) - 1; Object component = input.size() > y * 2 + x ? input.get(y * 2 + x) : null;//recipe.getInput()[y * 2 + x]; - if (component != null) - { - if (component instanceof ItemStack) - { + if (component != null) { + if (component instanceof ItemStack) { ItemStack input = (ItemStack) component; if (input.getItemDamage() == OreDictionary.WILDCARD_VALUE) input.setItemDamage(0); GuiHelper.drawItemStack((ItemStack) component, stackX, stackY); - if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) - { + if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) { // tooltips = GuiHelper.getTooltip((ItemStack) component); guiBase.renderToolTip((ItemStack) component, mouseX, mouseY); } - } else if (component instanceof Integer) - { + } else if (component instanceof Integer) { List list = OrbRegistry.getOrbsDownToTier((Integer) component); - if (!list.isEmpty()) - { + if (!list.isEmpty()) { ItemStack stack = list.get(getRandomizedCycle(x + (y * 2), list.size())); GuiHelper.drawItemStack(stack, stackX, stackY); - if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) - { + if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) { // tooltips = GuiHelper.getTooltip(stack); guiBase.renderToolTip(stack, mouseX, mouseY); } } - } else - { + } else { List list = (List) component; - if (!list.isEmpty()) - { + if (!list.isEmpty()) { ItemStack stack = list.get(getRandomizedCycle(x + (y * 2), list.size())); GuiHelper.drawItemStack(stack, stackX, stackY); - if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) - { + if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) { // tooltips = GuiHelper.getTooltip(stack); guiBase.renderToolTip(stack, mouseX, mouseY); } @@ -113,20 +99,17 @@ public class PageTartaricForgeRecipe extends Page // guiBase.renderToolTip(input.get(0), mouseX, mouseY); // } - if (output == null) - { + if (output == null) { output = new ItemStack(Blocks.BARRIER); } int outputX = (5 * 20) + (guiLeft + guiBase.xSize / 7) + 1; int outputY = (20) + (guiTop + guiBase.xSize / 5) + 10; // 1 * 20 GuiHelper.drawItemStack(output, outputX, outputY); - if (GuiHelper.isMouseBetween(mouseX, mouseY, outputX, outputY, 15, 15)) - { + if (GuiHelper.isMouseBetween(mouseX, mouseY, outputX, outputY, 15, 15)) { guiBase.renderToolTip(output, outputX, outputY); } - if (output.getItem() == Item.getItemFromBlock(Blocks.BARRIER)) - { + if (output.getItem() == Item.getItemFromBlock(Blocks.BARRIER)) { guiBase.drawCenteredString(fontRenderer, TextHelper.localize("text.furnace.error"), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6, 0xED073D); guiBase.drawCenteredString(fontRenderer, TextHelper.localize("bm.string.tier") + ": " + String.valueOf(tier), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6 + 15, 0); // guiBase.drawCenteredString(fontRenderer, "LP: " + String.valueOf(bloodRequired), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6 + 30, 0); @@ -135,8 +118,7 @@ public class PageTartaricForgeRecipe extends Page guiBase.drawCenteredString(fontRenderer, TextHelper.localize("guide.bloodmagic.page.drainedWill", String.valueOf(drainedWill)), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6, 0); } - protected int getRandomizedCycle(int index, int max) - { + protected int getRandomizedCycle(int index, int max) { rand.setSeed(index); return (index + rand.nextInt(max) + cycleIdx) % max; } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicPlugin.java b/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicPlugin.java index 1a1de334..11c3f80a 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicPlugin.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicPlugin.java @@ -1,12 +1,5 @@ package WayofTime.bloodmagic.compat.jei; -import java.util.Map; - -import javax.annotation.Nonnull; - -import mezz.jei.api.*; -import mezz.jei.api.recipe.IRecipeCategoryRegistration; -import net.minecraft.item.ItemStack; import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler; import WayofTime.bloodmagic.api.util.helper.ItemHelper.LivingUpgrades; @@ -31,15 +24,19 @@ import WayofTime.bloodmagic.compat.jei.forge.TartaricForgeRecipeHandler; import WayofTime.bloodmagic.compat.jei.forge.TartaricForgeRecipeMaker; import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import mezz.jei.api.*; +import mezz.jei.api.recipe.IRecipeCategoryRegistration; +import net.minecraft.item.ItemStack; + +import javax.annotation.Nonnull; +import java.util.Map; @JEIPlugin -public class BloodMagicPlugin extends BlankModPlugin -{ +public class BloodMagicPlugin extends BlankModPlugin { public static IJeiHelpers jeiHelper; @Override - public void register(@Nonnull IModRegistry registry) - { + public void register(@Nonnull IModRegistry registry) { jeiHelper = registry.getJeiHelpers(); registry.addRecipeHandlers( @@ -61,12 +58,10 @@ public class BloodMagicPlugin extends BlankModPlugin registry.addIngredientInfo(new ItemStack(RegistrarBloodMagicItems.ALTAR_MAKER), ItemStack.class, "jei.bloodmagic.desc.altarBuilder"); registry.addIngredientInfo(new ItemStack(RegistrarBloodMagicItems.MONSTER_SOUL), ItemStack.class, "jei.bloodmagic.desc.demonicWill"); - for (Map.Entry entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet()) - { + for (Map.Entry entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet()) { String key = entry.getKey(); int maxLevel = entry.getValue(); - for (int i = 0; i < maxLevel - 1; i++) - { + for (int i = 0; i < maxLevel - 1; i++) { ItemStack stack = new ItemStack(RegistrarBloodMagicItems.UPGRADE_TOME); LivingUpgrades.setKey(stack, key); LivingUpgrades.setLevel(stack, i); 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 dbafede6..5b9b8e22 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingCategory.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingCategory.java @@ -1,9 +1,9 @@ package WayofTime.bloodmagic.compat.jei.alchemyArray; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin; +import WayofTime.bloodmagic.util.helper.TextHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; @@ -12,12 +12,11 @@ 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; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class AlchemyArrayCraftingCategory implements IRecipeCategory -{ +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class AlchemyArrayCraftingCategory implements IRecipeCategory { private static final int INPUT_SLOT = 0; private static final int CATALYST_SLOT = 1; private static final int OUTPUT_SLOT = 2; @@ -29,47 +28,40 @@ public class AlchemyArrayCraftingCategory implements IRecipeCategory @Nonnull @Override - public String getUid() - { + public String getUid() { return Constants.Compat.JEI_CATEGORY_ALCHEMYARRAY; } @Nonnull @Override - public String getTitle() - { + public String getTitle() { return localizedName; } @Nonnull @Override - public IDrawable getBackground() - { + public IDrawable getBackground() { return background; } @Override - public void drawExtras(Minecraft minecraft) - { + public void drawExtras(Minecraft minecraft) { } @Nullable @Override - public IDrawable getIcon() - { + public IDrawable getIcon() { return null; } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) - { + 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); recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 73, 5); - if (recipeWrapper instanceof AlchemyArrayCraftingRecipeJEI) - { + if (recipeWrapper instanceof AlchemyArrayCraftingRecipeJEI) { recipeLayout.getItemStacks().set(INPUT_SLOT, ingredients.getInputs(ItemStack.class).get(0)); recipeLayout.getItemStacks().set(CATALYST_SLOT, ingredients.getInputs(ItemStack.class).get(ingredients.getInputs(ItemStack.class).size() - 1)); recipeLayout.getItemStacks().set(OUTPUT_SLOT, ingredients.getOutputs(ItemStack.class).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 61eb4548..4a0168a5 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeHandler.java @@ -1,36 +1,31 @@ package WayofTime.bloodmagic.compat.jei.alchemyArray; +import WayofTime.bloodmagic.api.Constants; +import mezz.jei.api.recipe.IRecipeHandler; +import mezz.jei.api.recipe.IRecipeWrapper; + import javax.annotation.Nonnull; -import mezz.jei.api.recipe.IRecipeHandler; -import mezz.jei.api.recipe.IRecipeWrapper; -import WayofTime.bloodmagic.api.Constants; - -public class AlchemyArrayCraftingRecipeHandler implements IRecipeHandler -{ +public class AlchemyArrayCraftingRecipeHandler implements IRecipeHandler { @Nonnull @Override - public Class getRecipeClass() - { + public Class getRecipeClass() { return AlchemyArrayCraftingRecipeJEI.class; } @Override - public String getRecipeCategoryUid(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) - { + public String getRecipeCategoryUid(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) { return Constants.Compat.JEI_CATEGORY_ALCHEMYARRAY; } @Nonnull @Override - public IRecipeWrapper getRecipeWrapper(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) - { + public IRecipeWrapper getRecipeWrapper(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) { return recipe; } @Override - public boolean isRecipeValid(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) - { + public boolean isRecipeValid(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) { return true; } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeJEI.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeJEI.java index 1dbb5f98..9cd323b9 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeJEI.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeJEI.java @@ -1,17 +1,15 @@ package WayofTime.bloodmagic.compat.jei.alchemyArray; -import java.util.List; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import com.google.common.collect.Lists; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeWrapper; import net.minecraft.item.ItemStack; -public class AlchemyArrayCraftingRecipeJEI extends BlankRecipeWrapper -{ +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.List; + +public class AlchemyArrayCraftingRecipeJEI extends BlankRecipeWrapper { @Nonnull private final List inputs; @Nullable @@ -19,15 +17,13 @@ public class AlchemyArrayCraftingRecipeJEI extends BlankRecipeWrapper @Nonnull private final ItemStack output; - public AlchemyArrayCraftingRecipeJEI(@Nonnull List input, @Nullable ItemStack catalyst, @Nonnull ItemStack output) - { + public AlchemyArrayCraftingRecipeJEI(@Nonnull List input, @Nullable ItemStack catalyst, @Nonnull ItemStack output) { this.inputs = input; this.catalyst = catalyst; this.output = output; } - public ItemStack getCatalyst() - { + public ItemStack getCatalyst() { return catalyst; } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeMaker.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeMaker.java index 80490fc7..23fc84db 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeMaker.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeMaker.java @@ -1,38 +1,31 @@ package WayofTime.bloodmagic.compat.jei.alchemyArray; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; import WayofTime.bloodmagic.api.ItemStackWrapper; import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting; import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry; - import com.google.common.collect.BiMap; +import net.minecraft.item.ItemStack; -public class AlchemyArrayCraftingRecipeMaker -{ +import javax.annotation.Nonnull; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class AlchemyArrayCraftingRecipeMaker { @Nonnull - public static List getRecipes() - { + public static List getRecipes() { Map, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> alchemyArrayRecipeMap = AlchemyArrayRecipeRegistry.getRecipes(); ArrayList recipes = new ArrayList(); - for (Map.Entry, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet()) - { + for (Map.Entry, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet()) { List input = itemStackAlchemyArrayRecipeEntry.getValue().getInput(); BiMap catalystMap = itemStackAlchemyArrayRecipeEntry.getValue().catalystMap; - for (Map.Entry entry : catalystMap.entrySet()) - { + for (Map.Entry entry : catalystMap.entrySet()) { ItemStack catalyst = entry.getKey().toStack(); - if (AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(input, catalyst) instanceof AlchemyArrayEffectCrafting) - { + if (AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(input, catalyst) instanceof AlchemyArrayEffectCrafting) { ItemStack output = ((AlchemyArrayEffectCrafting) itemStackAlchemyArrayRecipeEntry.getValue().getAlchemyArrayEffectForCatalyst(catalyst)).outputStack; AlchemyArrayCraftingRecipeJEI recipe = new AlchemyArrayCraftingRecipeJEI(input, catalyst, output); 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 de1ceca0..4ade8678 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeCategory.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeCategory.java @@ -1,9 +1,10 @@ package WayofTime.bloodmagic.compat.jei.alchemyTable; -import javax.annotation.Nonnull; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.registry.OrbRegistry; +import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin; +import WayofTime.bloodmagic.util.helper.TextHelper; import mezz.jei.api.gui.ICraftingGridHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; @@ -12,12 +13,10 @@ import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeCategory; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class AlchemyTableRecipeCategory extends BlankRecipeCategory -{ +import javax.annotation.Nonnull; + +public class AlchemyTableRecipeCategory extends BlankRecipeCategory { private static final int OUTPUT_SLOT = 0; private static final int ORB_SLOT = 1; private static final int INPUT_SLOT = 2; @@ -29,44 +28,37 @@ public class AlchemyTableRecipeCategory extends BlankRecipeCategory -{ +public class AlchemyTableRecipeHandler implements IRecipeHandler { @Nonnull @Override - public Class getRecipeClass() - { + public Class getRecipeClass() { return AlchemyTableRecipeJEI.class; } @Override - public String getRecipeCategoryUid(@Nonnull AlchemyTableRecipeJEI recipe) - { + public String getRecipeCategoryUid(@Nonnull AlchemyTableRecipeJEI recipe) { return Constants.Compat.JEI_CATEGORY_ALCHEMYTABLE; } @Nonnull @Override - public IRecipeWrapper getRecipeWrapper(@Nonnull AlchemyTableRecipeJEI recipe) - { + public IRecipeWrapper getRecipeWrapper(@Nonnull AlchemyTableRecipeJEI recipe) { return recipe; } @Override - public boolean isRecipeValid(@Nonnull AlchemyTableRecipeJEI recipe) - { + public boolean isRecipeValid(@Nonnull AlchemyTableRecipeJEI recipe) { return true; } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeJEI.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeJEI.java index 18709a97..0079d60a 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeJEI.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeJEI.java @@ -1,22 +1,20 @@ package WayofTime.bloodmagic.compat.jei.alchemyTable; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe; import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin; +import WayofTime.bloodmagic.util.helper.TextHelper; import com.google.common.collect.Lists; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeWrapper; import net.minecraft.item.ItemStack; -import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class AlchemyTableRecipeJEI extends BlankRecipeWrapper -{ +import java.util.ArrayList; +import java.util.List; + +public class AlchemyTableRecipeJEI extends BlankRecipeWrapper { private AlchemyTableRecipe recipe; - public AlchemyTableRecipeJEI(AlchemyTableRecipe recipe) - { + public AlchemyTableRecipeJEI(AlchemyTableRecipe recipe) { this.recipe = recipe; } @@ -28,11 +26,9 @@ public class AlchemyTableRecipeJEI extends BlankRecipeWrapper } @Override - public List getTooltipStrings(int mouseX, int mouseY) - { + public List getTooltipStrings(int mouseX, int mouseY) { ArrayList ret = new ArrayList(); - if (mouseX >= 58 && mouseX <= 78 && mouseY >= 21 && mouseY <= 34) - { + if (mouseX >= 58 && mouseX <= 78 && mouseY >= 21 && mouseY <= 34) { ret.add(TextHelper.localize("tooltip.bloodmagic.tier", recipe.getTierRequired())); ret.add(TextHelper.localize("jei.bloodmagic.recipe.lpDrained", recipe.getLpDrained())); ret.add(TextHelper.localize("jei.bloodmagic.recipe.ticksRequired", recipe.getTicksRequired())); diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeMaker.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeMaker.java index 8dae28f8..e526d182 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeMaker.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyTable/AlchemyTableRecipeMaker.java @@ -1,18 +1,15 @@ package WayofTime.bloodmagic.compat.jei.alchemyTable; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nonnull; - import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe; import WayofTime.bloodmagic.api.registry.AlchemyTableRecipeRegistry; -public class AlchemyTableRecipeMaker -{ +import javax.annotation.Nonnull; +import java.util.ArrayList; +import java.util.List; + +public class AlchemyTableRecipeMaker { @Nonnull - public static List getRecipes() - { + public static List getRecipes() { List recipeList = AlchemyTableRecipeRegistry.getRecipeList(); ArrayList recipes = new ArrayList(); 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 e69d8427..482b98ab 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,9 @@ package WayofTime.bloodmagic.compat.jei.altar; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin; +import WayofTime.bloodmagic.util.helper.TextHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; @@ -14,12 +12,11 @@ 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; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class AltarRecipeCategory implements IRecipeCategory -{ +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class AltarRecipeCategory implements IRecipeCategory { private static final int INPUT_SLOT = 0; private static final int OUTPUT_SLOT = 1; @@ -30,28 +27,24 @@ public class AltarRecipeCategory implements IRecipeCategory @Nonnull @Override - public String getUid() - { + public String getUid() { return Constants.Compat.JEI_CATEGORY_ALTAR; } @Nonnull @Override - public String getTitle() - { + public String getTitle() { return localizedName; } @Nonnull @Override - public IDrawable getBackground() - { + public IDrawable getBackground() { return background; } @Override - public void drawExtras(Minecraft minecraft) - { + public void drawExtras(Minecraft minecraft) { } @@ -62,13 +55,11 @@ public class AltarRecipeCategory implements IRecipeCategory } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) - { + 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); - if (recipeWrapper instanceof AltarRecipeJEI) - { + if (recipeWrapper instanceof AltarRecipeJEI) { recipeLayout.getItemStacks().set(INPUT_SLOT, ingredients.getInputs(ItemStack.class).get(0)); 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 bb421437..efd8c457 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeHandler.java @@ -1,36 +1,31 @@ package WayofTime.bloodmagic.compat.jei.altar; +import WayofTime.bloodmagic.api.Constants; +import mezz.jei.api.recipe.IRecipeHandler; +import mezz.jei.api.recipe.IRecipeWrapper; + import javax.annotation.Nonnull; -import mezz.jei.api.recipe.IRecipeHandler; -import mezz.jei.api.recipe.IRecipeWrapper; -import WayofTime.bloodmagic.api.Constants; - -public class AltarRecipeHandler implements IRecipeHandler -{ +public class AltarRecipeHandler implements IRecipeHandler { @Nonnull @Override - public Class getRecipeClass() - { + public Class getRecipeClass() { return AltarRecipeJEI.class; } @Override - public String getRecipeCategoryUid(@Nonnull AltarRecipeJEI recipe) - { + public String getRecipeCategoryUid(@Nonnull AltarRecipeJEI recipe) { return Constants.Compat.JEI_CATEGORY_ALTAR; } @Nonnull @Override - public IRecipeWrapper getRecipeWrapper(@Nonnull AltarRecipeJEI recipe) - { + public IRecipeWrapper getRecipeWrapper(@Nonnull AltarRecipeJEI recipe) { return recipe; } @Override - public boolean isRecipeValid(@Nonnull AltarRecipeJEI recipe) - { + public boolean isRecipeValid(@Nonnull AltarRecipeJEI recipe) { return true; } } 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 dbf9808d..d7de9b3d 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeJEI.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeJEI.java @@ -1,20 +1,18 @@ package WayofTime.bloodmagic.compat.jei.altar; -import java.awt.Color; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nonnull; - import WayofTime.bloodmagic.util.helper.NumeralHelper; +import WayofTime.bloodmagic.util.helper.TextHelper; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class AltarRecipeJEI extends BlankRecipeWrapper -{ +import javax.annotation.Nonnull; +import java.awt.Color; +import java.util.ArrayList; +import java.util.List; + +public class AltarRecipeJEI extends BlankRecipeWrapper { @Nonnull private final List input; @Nonnull @@ -24,12 +22,11 @@ public class AltarRecipeJEI extends BlankRecipeWrapper private final int consumptionRate; private final int drainRate; - public AltarRecipeJEI(@Nonnull List input, @Nonnull ItemStack output, int tier, int requiredLP, int consumptionRate, int drainRate) - { + public AltarRecipeJEI(@Nonnull List input, @Nonnull ItemStack output, int tier, int requiredLP, int consumptionRate, int drainRate) { this.input = input; this.output = output; - this.infoString = new String[] { TextHelper.localize("jei.bloodmagic.recipe.requiredTier", NumeralHelper.toRoman(tier)), TextHelper.localize("jei.bloodmagic.recipe.requiredLP", requiredLP) }; + this.infoString = new String[]{TextHelper.localize("jei.bloodmagic.recipe.requiredTier", NumeralHelper.toRoman(tier)), TextHelper.localize("jei.bloodmagic.recipe.requiredLP", requiredLP)}; this.consumptionRate = consumptionRate; this.drainRate = drainRate; } @@ -41,11 +38,9 @@ public class AltarRecipeJEI extends BlankRecipeWrapper } @Override - public List getTooltipStrings(int mouseX, int mouseY) - { + public List getTooltipStrings(int mouseX, int mouseY) { ArrayList ret = new ArrayList(); - if (mouseX >= 13 && mouseX <= 64 && mouseY >= 27 && mouseY <= 58) - { + if (mouseX >= 13 && mouseX <= 64 && mouseY >= 27 && mouseY <= 58) { ret.add(TextHelper.localize("jei.bloodmagic.recipe.consumptionRate", consumptionRate)); ret.add(TextHelper.localize("jei.bloodmagic.recipe.drainRate", drainRate)); } @@ -53,8 +48,7 @@ public class AltarRecipeJEI extends BlankRecipeWrapper } @Override - public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) - { + public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { minecraft.fontRenderer.drawString(infoString[0], 90 - minecraft.fontRenderer.getStringWidth(infoString[0]) / 2, 0, Color.gray.getRGB()); minecraft.fontRenderer.drawString(infoString[1], 90 - minecraft.fontRenderer.getStringWidth(infoString[1]) / 2, 10, Color.gray.getRGB()); } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeMaker.java b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeMaker.java index 0d9b3b92..760852b2 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeMaker.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeMaker.java @@ -1,35 +1,30 @@ package WayofTime.bloodmagic.compat.jei.altar; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.annotation.Nonnull; - import WayofTime.bloodmagic.api.ItemStackWrapper; -import WayofTime.bloodmagic.block.BlockLifeEssence; -import net.minecraft.item.ItemStack; import WayofTime.bloodmagic.api.orb.IBloodOrb; import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry; +import WayofTime.bloodmagic.block.BlockLifeEssence; +import net.minecraft.item.ItemStack; import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidUtil; -public class AltarRecipeMaker -{ +import javax.annotation.Nonnull; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class AltarRecipeMaker { @Nonnull - public static List getRecipes() - { + public static List getRecipes() { Map, AltarRecipeRegistry.AltarRecipe> altarMap = AltarRecipeRegistry.getRecipes(); ArrayList recipes = new ArrayList(); - for (Map.Entry, AltarRecipeRegistry.AltarRecipe> itemStackAltarRecipeEntry : altarMap.entrySet()) - { + for (Map.Entry, AltarRecipeRegistry.AltarRecipe> itemStackAltarRecipeEntry : altarMap.entrySet()) { // Make sure input is not a Blood Orb. If it is, the recipe is for a filling orb, and we don't want that. - if (!(itemStackAltarRecipeEntry.getKey().get(0).toStack().getItem() instanceof IBloodOrb)) - { + if (!(itemStackAltarRecipeEntry.getKey().get(0).toStack().getItem() instanceof IBloodOrb)) { List input = ItemStackWrapper.toStackList(itemStackAltarRecipeEntry.getValue().getInput()); ItemStack output = itemStackAltarRecipeEntry.getValue().getOutput(); int requiredTier = itemStackAltarRecipeEntry.getValue().getMinTier().toInt(); 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 c914208a..f8a93172 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeCategory.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeCategory.java @@ -1,9 +1,9 @@ package WayofTime.bloodmagic.compat.jei.armourDowngrade; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin; +import WayofTime.bloodmagic.util.helper.TextHelper; import mezz.jei.api.gui.ICraftingGridHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; @@ -14,12 +14,11 @@ 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; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class ArmourDowngradeRecipeCategory implements IRecipeCategory -{ +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class ArmourDowngradeRecipeCategory implements IRecipeCategory { private static final int OUTPUT_SLOT = 0; private static final int KEY_SLOT = 1; private static final int INPUT_SLOT = 2; @@ -31,35 +30,30 @@ public class ArmourDowngradeRecipeCategory implements IRecipeCategory @Nonnull private final ICraftingGridHelper craftingGridHelper; - public ArmourDowngradeRecipeCategory() - { + public ArmourDowngradeRecipeCategory() { craftingGridHelper = BloodMagicPlugin.jeiHelper.getGuiHelper().createCraftingGridHelper(INPUT_SLOT, OUTPUT_SLOT); } @Nonnull @Override - public String getUid() - { + public String getUid() { return Constants.Compat.JEI_CATEGORY_ARMOURDOWNGRADE; } @Nonnull @Override - public String getTitle() - { + public String getTitle() { return localizedName; } @Nonnull @Override - public IDrawable getBackground() - { + public IDrawable getBackground() { return background; } @Override - public void drawExtras(Minecraft minecraft) - { + public void drawExtras(Minecraft minecraft) { } @@ -71,24 +65,20 @@ public class ArmourDowngradeRecipeCategory implements IRecipeCategory @Override @SuppressWarnings("unchecked") - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper, IIngredients ingredients) - { + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper, IIngredients ingredients) { IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); guiItemStacks.init(OUTPUT_SLOT, false, 91, 13); guiItemStacks.init(KEY_SLOT, true, 60, 0); - for (int y = 0; y < 3; ++y) - { - for (int x = 0; x < 3; ++x) - { + for (int y = 0; y < 3; ++y) { + for (int x = 0; x < 3; ++x) { int index = INPUT_SLOT + x + (y * 3); guiItemStacks.init(index, true, x * 18, y * 18 - 18); } } - if (recipeWrapper instanceof ArmourDowngradeRecipeJEI) - { + if (recipeWrapper instanceof ArmourDowngradeRecipeJEI) { guiItemStacks.set(KEY_SLOT, ingredients.getInputs(ItemStack.class).get(ingredients.getInputs(ItemStack.class).size() - 1)); ingredients.getInputs(ItemStack.class).remove(ingredients.getInputs(ItemStack.class).size() - 1); guiItemStacks.set(OUTPUT_SLOT, ingredients.getOutputs(ItemStack.class).get(0)); 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 b532e9ea..233f7ee5 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeHandler.java @@ -1,37 +1,32 @@ package WayofTime.bloodmagic.compat.jei.armourDowngrade; +import WayofTime.bloodmagic.api.Constants; +import mezz.jei.api.recipe.IRecipeHandler; +import mezz.jei.api.recipe.IRecipeWrapper; + import javax.annotation.Nonnull; -import mezz.jei.api.recipe.IRecipeHandler; -import mezz.jei.api.recipe.IRecipeWrapper; -import WayofTime.bloodmagic.api.Constants; - -public class ArmourDowngradeRecipeHandler implements IRecipeHandler -{ +public class ArmourDowngradeRecipeHandler implements IRecipeHandler { @Nonnull @Override - public Class getRecipeClass() - { + public Class getRecipeClass() { return ArmourDowngradeRecipeJEI.class; } @Nonnull @Override - public String getRecipeCategoryUid(ArmourDowngradeRecipeJEI recipe) - { + public String getRecipeCategoryUid(ArmourDowngradeRecipeJEI recipe) { return Constants.Compat.JEI_CATEGORY_ARMOURDOWNGRADE; } @Nonnull @Override - public IRecipeWrapper getRecipeWrapper(@Nonnull ArmourDowngradeRecipeJEI recipe) - { + public IRecipeWrapper getRecipeWrapper(@Nonnull ArmourDowngradeRecipeJEI recipe) { return recipe; } @Override - public boolean isRecipeValid(@Nonnull ArmourDowngradeRecipeJEI recipe) - { + public boolean isRecipeValid(@Nonnull ArmourDowngradeRecipeJEI recipe) { 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 e3d5835f..d8155ace 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeJEI.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeJEI.java @@ -1,22 +1,20 @@ package WayofTime.bloodmagic.compat.jei.armourDowngrade; +import WayofTime.bloodmagic.api.recipe.LivingArmourDowngradeRecipe; +import WayofTime.bloodmagic.api.util.helper.ItemHelper.LivingUpgrades; import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import com.google.common.collect.Lists; 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.core.RegistrarBloodMagicItems; import java.util.List; -public class ArmourDowngradeRecipeJEI extends BlankRecipeWrapper -{ +public class ArmourDowngradeRecipeJEI extends BlankRecipeWrapper { private LivingArmourDowngradeRecipe recipe; - public ArmourDowngradeRecipeJEI(LivingArmourDowngradeRecipe recipe) - { + public ArmourDowngradeRecipeJEI(LivingArmourDowngradeRecipe recipe) { this.recipe = recipe; } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeMaker.java b/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeMaker.java index 5f28f6c3..4aeafbef 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeMaker.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/armourDowngrade/ArmourDowngradeRecipeMaker.java @@ -1,18 +1,15 @@ package WayofTime.bloodmagic.compat.jei.armourDowngrade; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nonnull; - import WayofTime.bloodmagic.api.recipe.LivingArmourDowngradeRecipe; import WayofTime.bloodmagic.api.registry.LivingArmourDowngradeRecipeRegistry; -public class ArmourDowngradeRecipeMaker -{ +import javax.annotation.Nonnull; +import java.util.ArrayList; +import java.util.List; + +public class ArmourDowngradeRecipeMaker { @Nonnull - public static List getRecipes() - { + public static List getRecipes() { List recipeList = LivingArmourDowngradeRecipeRegistry.getRecipeList(); ArrayList recipes = new ArrayList(); diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeCategory.java b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeCategory.java index efb7019a..c511fa04 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeCategory.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeCategory.java @@ -1,9 +1,9 @@ package WayofTime.bloodmagic.compat.jei.binding; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin; +import WayofTime.bloodmagic.util.helper.TextHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; @@ -12,12 +12,11 @@ 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; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class BindingRecipeCategory implements IRecipeCategory -{ +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class BindingRecipeCategory implements IRecipeCategory { private static final int INPUT_SLOT = 0; private static final int CATALYST_SLOT = 1; private static final int OUTPUT_SLOT = 2; @@ -29,28 +28,24 @@ public class BindingRecipeCategory implements IRecipeCategory @Nonnull @Override - public String getUid() - { + public String getUid() { return Constants.Compat.JEI_CATEGORY_BINDING; } @Nonnull @Override - public String getTitle() - { + public String getTitle() { return localizedName; } @Nonnull @Override - public IDrawable getBackground() - { + public IDrawable getBackground() { return background; } @Override - public void drawExtras(Minecraft minecraft) - { + public void drawExtras(Minecraft minecraft) { } @@ -66,8 +61,7 @@ public class BindingRecipeCategory implements IRecipeCategory recipeLayout.getItemStacks().init(CATALYST_SLOT, true, 29, 3); recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 73, 5); - if (recipeWrapper instanceof BindingRecipeJEI) - { + if (recipeWrapper instanceof BindingRecipeJEI) { recipeLayout.getItemStacks().set(INPUT_SLOT, ingredients.getInputs(ItemStack.class).get(0)); recipeLayout.getItemStacks().set(CATALYST_SLOT, ingredients.getInputs(ItemStack.class).get(1)); recipeLayout.getItemStacks().set(OUTPUT_SLOT, ingredients.getOutputs(ItemStack.class).get(0)); diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeHandler.java b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeHandler.java index c8703a1e..ce2fad06 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeHandler.java @@ -1,36 +1,31 @@ package WayofTime.bloodmagic.compat.jei.binding; +import WayofTime.bloodmagic.api.Constants; +import mezz.jei.api.recipe.IRecipeHandler; +import mezz.jei.api.recipe.IRecipeWrapper; + import javax.annotation.Nonnull; -import mezz.jei.api.recipe.IRecipeHandler; -import mezz.jei.api.recipe.IRecipeWrapper; -import WayofTime.bloodmagic.api.Constants; - -public class BindingRecipeHandler implements IRecipeHandler -{ +public class BindingRecipeHandler implements IRecipeHandler { @Nonnull @Override - public Class getRecipeClass() - { + public Class getRecipeClass() { return BindingRecipeJEI.class; } @Override - public String getRecipeCategoryUid(@Nonnull BindingRecipeJEI recipe) - { + public String getRecipeCategoryUid(@Nonnull BindingRecipeJEI recipe) { return Constants.Compat.JEI_CATEGORY_BINDING; } @Nonnull @Override - public IRecipeWrapper getRecipeWrapper(@Nonnull BindingRecipeJEI recipe) - { + public IRecipeWrapper getRecipeWrapper(@Nonnull BindingRecipeJEI recipe) { return recipe; } @Override - public boolean isRecipeValid(@Nonnull BindingRecipeJEI recipe) - { + public boolean isRecipeValid(@Nonnull BindingRecipeJEI recipe) { return true; } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeJEI.java b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeJEI.java index b73dce1b..8a4adb82 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeJEI.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeJEI.java @@ -1,16 +1,14 @@ package WayofTime.bloodmagic.compat.jei.binding; -import java.util.List; - -import javax.annotation.Nonnull; - import com.google.common.collect.Lists; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeWrapper; import net.minecraft.item.ItemStack; -public class BindingRecipeJEI extends BlankRecipeWrapper -{ +import javax.annotation.Nonnull; +import java.util.List; + +public class BindingRecipeJEI extends BlankRecipeWrapper { @Nonnull private final List inputs; @@ -21,8 +19,7 @@ public class BindingRecipeJEI extends BlankRecipeWrapper private final ItemStack output; @SuppressWarnings("unchecked") - public BindingRecipeJEI(@Nonnull List input, @Nonnull ItemStack catalyst, @Nonnull ItemStack output) - { + public BindingRecipeJEI(@Nonnull List input, @Nonnull ItemStack catalyst, @Nonnull ItemStack output) { this.inputs = input; this.catalyst = catalyst; this.output = output; diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeMaker.java b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeMaker.java index b3aa8747..561f6b21 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeMaker.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeMaker.java @@ -1,38 +1,31 @@ package WayofTime.bloodmagic.compat.jei.binding; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectBinding; import WayofTime.bloodmagic.api.ItemStackWrapper; import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry; - import com.google.common.collect.BiMap; +import net.minecraft.item.ItemStack; -public class BindingRecipeMaker -{ +import javax.annotation.Nonnull; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class BindingRecipeMaker { @Nonnull - public static List getRecipes() - { + public static List getRecipes() { Map, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> alchemyArrayRecipeMap = AlchemyArrayRecipeRegistry.getRecipes(); ArrayList recipes = new ArrayList(); - for (Map.Entry, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet()) - { + for (Map.Entry, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet()) { List input = itemStackAlchemyArrayRecipeEntry.getValue().getInput(); BiMap catalystMap = itemStackAlchemyArrayRecipeEntry.getValue().catalystMap; - for (Map.Entry entry : catalystMap.entrySet()) - { + for (Map.Entry entry : catalystMap.entrySet()) { ItemStack catalyst = entry.getKey().toStack(); - if (AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(input, catalyst) instanceof AlchemyArrayEffectBinding) - { + if (AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(input, catalyst) instanceof AlchemyArrayEffectBinding) { ItemStack output = ((AlchemyArrayEffectBinding) itemStackAlchemyArrayRecipeEntry.getValue().getAlchemyArrayEffectForCatalyst(catalyst)).outputStack; BindingRecipeJEI recipe = new BindingRecipeJEI(input, catalyst, output); diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeCategory.java b/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeCategory.java index df8f2d17..ceee68d8 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeCategory.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeCategory.java @@ -1,11 +1,9 @@ package WayofTime.bloodmagic.compat.jei.forge; -import java.util.List; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin; +import WayofTime.bloodmagic.util.helper.TextHelper; import mezz.jei.api.gui.ICraftingGridHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; @@ -16,12 +14,12 @@ 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; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class TartaricForgeRecipeCategory implements IRecipeCategory -{ +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.List; + +public class TartaricForgeRecipeCategory implements IRecipeCategory { private static final int OUTPUT_SLOT = 0; private static final int GEM_SLOT = 1; private static final int INPUT_SLOT = 2; @@ -33,57 +31,48 @@ public class TartaricForgeRecipeCategory implements IRecipeCategory @Nonnull private final ICraftingGridHelper craftingGridHelper; - public TartaricForgeRecipeCategory() - { + public TartaricForgeRecipeCategory() { craftingGridHelper = BloodMagicPlugin.jeiHelper.getGuiHelper().createCraftingGridHelper(INPUT_SLOT, OUTPUT_SLOT); } @Nonnull @Override - public String getUid() - { + public String getUid() { return Constants.Compat.JEI_CATEGORY_SOULFORGE; } @Nonnull @Override - public String getTitle() - { + public String getTitle() { return localizedName; } @Nonnull @Override - public IDrawable getBackground() - { + public IDrawable getBackground() { return background; } @Override - public void drawExtras(Minecraft minecraft) - { + public void drawExtras(Minecraft minecraft) { } @Nullable @Override - public IDrawable getIcon() - { + public IDrawable getIcon() { return null; } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) - { + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); guiItemStacks.init(OUTPUT_SLOT, false, 73, 13); guiItemStacks.init(GEM_SLOT, true, 42, 0); - for (int y = 0; y < 3; ++y) - { - for (int x = 0; x < 3; ++x) - { + for (int y = 0; y < 3; ++y) { + for (int x = 0; x < 3; ++x) { int index = INPUT_SLOT + x + (y * 3); guiItemStacks.init(index, true, x * 18, y * 18); } @@ -92,8 +81,7 @@ public class TartaricForgeRecipeCategory implements IRecipeCategory List> inputs = ingredients.getInputs(ItemStack.class); List> outputs = ingredients.getOutputs(ItemStack.class); - if (recipeWrapper instanceof TartaricForgeRecipeJEI) - { + if (recipeWrapper instanceof TartaricForgeRecipeJEI) { TartaricForgeRecipeJEI recipe = (TartaricForgeRecipeJEI) recipeWrapper; guiItemStacks.set(GEM_SLOT, ingredients.getInputs(ItemStack.class).get(ingredients.getInputs(ItemStack.class).size() - 1)); inputs.remove(ingredients.getInputs(ItemStack.class).size() - 1); diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeHandler.java b/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeHandler.java index d435eee9..608d97be 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeHandler.java @@ -6,31 +6,26 @@ import mezz.jei.api.recipe.IRecipeWrapper; import javax.annotation.Nonnull; -public class TartaricForgeRecipeHandler implements IRecipeHandler -{ +public class TartaricForgeRecipeHandler implements IRecipeHandler { @Nonnull @Override - public Class getRecipeClass() - { + public Class getRecipeClass() { return TartaricForgeRecipeJEI.class; } @Override - public String getRecipeCategoryUid(@Nonnull TartaricForgeRecipeJEI recipe) - { + public String getRecipeCategoryUid(@Nonnull TartaricForgeRecipeJEI recipe) { return Constants.Compat.JEI_CATEGORY_SOULFORGE; } @Nonnull @Override - public IRecipeWrapper getRecipeWrapper(@Nonnull TartaricForgeRecipeJEI recipe) - { + public IRecipeWrapper getRecipeWrapper(@Nonnull TartaricForgeRecipeJEI recipe) { return recipe; } @Override - public boolean isRecipeValid(@Nonnull TartaricForgeRecipeJEI recipe) - { + public boolean isRecipeValid(@Nonnull TartaricForgeRecipeJEI recipe) { return true; } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeJEI.java b/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeJEI.java index fb222d2f..9919a733 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeJEI.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeJEI.java @@ -1,25 +1,22 @@ package WayofTime.bloodmagic.compat.jei.forge; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nullable; - +import WayofTime.bloodmagic.api.recipe.TartaricForgeRecipe; import WayofTime.bloodmagic.compat.jei.BloodMagicPlugin; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.util.helper.TextHelper; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeWrapper; import net.minecraft.item.ItemStack; -import WayofTime.bloodmagic.api.recipe.TartaricForgeRecipe; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class TartaricForgeRecipeJEI extends BlankRecipeWrapper -{ +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; + +public class TartaricForgeRecipeJEI extends BlankRecipeWrapper { private TartaricForgeRecipe recipe; private List validGems = new ArrayList(); - public TartaricForgeRecipeJEI(TartaricForgeRecipe recipe) - { + public TartaricForgeRecipeJEI(TartaricForgeRecipe recipe) { this.recipe = recipe; for (DefaultWill will : DefaultWill.values()) @@ -37,11 +34,9 @@ public class TartaricForgeRecipeJEI extends BlankRecipeWrapper @Nullable @Override - public List getTooltipStrings(int mouseX, int mouseY) - { + public List getTooltipStrings(int mouseX, int mouseY) { ArrayList ret = new ArrayList(); - if (mouseX >= 40 && mouseX <= 60 && mouseY >= 21 && mouseY <= 34) - { + if (mouseX >= 40 && mouseX <= 60 && mouseY >= 21 && mouseY <= 34) { ret.add(TextHelper.localize("jei.bloodmagic.recipe.minimumSouls", recipe.getMinimumSouls())); ret.add(TextHelper.localize("jei.bloodmagic.recipe.soulsDrained", recipe.getSoulsDrained())); return ret; @@ -49,8 +44,15 @@ public class TartaricForgeRecipeJEI extends BlankRecipeWrapper return null; } - public enum DefaultWill - { + public TartaricForgeRecipe getRecipe() { + return recipe; + } + + public List getValidGems() { + return validGems; + } + + public enum DefaultWill { SOUL(new ItemStack(RegistrarBloodMagicItems.MONSTER_SOUL, 1, 0), 64), PETTY(new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 0), 64), LESSER(new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 1), 256), @@ -61,18 +63,9 @@ public class TartaricForgeRecipeJEI extends BlankRecipeWrapper public final ItemStack willStack; public final double minSouls; - DefaultWill(ItemStack willStack, double minSouls) - { + DefaultWill(ItemStack willStack, double minSouls) { this.willStack = willStack; this.minSouls = minSouls; } } - - public TartaricForgeRecipe getRecipe() { - return recipe; - } - - public List getValidGems() { - return validGems; - } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeMaker.java b/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeMaker.java index f8577cc8..9f66cc27 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeMaker.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/forge/TartaricForgeRecipeMaker.java @@ -1,18 +1,15 @@ package WayofTime.bloodmagic.compat.jei.forge; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nonnull; - import WayofTime.bloodmagic.api.recipe.TartaricForgeRecipe; import WayofTime.bloodmagic.api.registry.TartaricForgeRecipeRegistry; -public class TartaricForgeRecipeMaker -{ +import javax.annotation.Nonnull; +import java.util.ArrayList; +import java.util.List; + +public class TartaricForgeRecipeMaker { @Nonnull - public static List getRecipes() - { + public static List getRecipes() { List recipeList = TartaricForgeRecipeRegistry.getRecipeList(); ArrayList recipes = new ArrayList(); diff --git a/src/main/java/WayofTime/bloodmagic/compat/waila/WailaPluginBloodMagic.java b/src/main/java/WayofTime/bloodmagic/compat/waila/WailaPluginBloodMagic.java index 07b7226a..5cfd9622 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/waila/WailaPluginBloodMagic.java +++ b/src/main/java/WayofTime/bloodmagic/compat/waila/WailaPluginBloodMagic.java @@ -1,11 +1,11 @@ package WayofTime.bloodmagic.compat.waila; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.block.*; import WayofTime.bloodmagic.compat.waila.provider.*; import mcp.mobius.waila.api.IWailaPlugin; import mcp.mobius.waila.api.IWailaRegistrar; -import WayofTime.bloodmagic.api.Constants; import mcp.mobius.waila.api.WailaPlugin; @WailaPlugin 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 01f993dd..a11aae07 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderAlchemyArray.java +++ b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderAlchemyArray.java @@ -1,7 +1,10 @@ package WayofTime.bloodmagic.compat.waila.provider; -import java.util.List; - +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.tile.TileAlchemyArray; +import WayofTime.bloodmagic.util.helper.TextHelper; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import mcp.mobius.waila.api.IWailaDataProvider; @@ -11,37 +14,28 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.tile.TileAlchemyArray; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class DataProviderAlchemyArray implements IWailaDataProvider -{ +import java.util.List; + +public class DataProviderAlchemyArray implements IWailaDataProvider { @Override - public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) - { + public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { return new ItemStack(RegistrarBloodMagicItems.ARCANE_ASHES).setStackDisplayName(TextHelper.getFormattedText(RegistrarBloodMagicBlocks.ALCHEMY_ARRAY.getLocalizedName())); } @Override - public List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { + 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) - { + public List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { if (!config.getConfig(Constants.Compat.WAILA_CONFIG_ARRAY)) return currenttip; - if (accessor.getPlayer().isSneaking() || config.getConfig(Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK)) - { + if (accessor.getPlayer().isSneaking() || config.getConfig(Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK)) { TileEntity tile = accessor.getTileEntity(); - if (tile instanceof TileAlchemyArray) - { + if (tile instanceof TileAlchemyArray) { TileAlchemyArray tileArray = (TileAlchemyArray) tile; if (!tileArray.getStackInSlot(0).isEmpty()) currenttip.add(TextHelper.localize("waila.bloodmagic.array.reagent", tileArray.getStackInSlot(0).getDisplayName())); @@ -49,8 +43,7 @@ public class DataProviderAlchemyArray implements IWailaDataProvider if (!tileArray.getStackInSlot(1).isEmpty()) currenttip.add(TextHelper.localize("waila.bloodmagic.array.catalyst", tileArray.getStackInSlot(1).getDisplayName())); } - } else - { + } else { currenttip.add(TextHelper.localizeEffect("waila.bloodmagic.sneak")); } @@ -58,14 +51,12 @@ public class DataProviderAlchemyArray implements IWailaDataProvider } @Override - public List getWailaTail(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { + 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) - { + 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/DataProviderBloodAltar.java b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderBloodAltar.java index 22960cf1..8affc801 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderBloodAltar.java +++ b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderBloodAltar.java @@ -1,7 +1,13 @@ package WayofTime.bloodmagic.compat.waila.provider; -import java.util.List; - +import WayofTime.bloodmagic.ConfigHandler; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.block.BlockAltar; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.item.sigil.ItemSigilDivination; +import WayofTime.bloodmagic.item.sigil.ItemSigilSeer; +import WayofTime.bloodmagic.tile.TileAltar; +import WayofTime.bloodmagic.util.helper.TextHelper; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import mcp.mobius.waila.api.IWailaDataProvider; @@ -12,94 +18,75 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.ConfigHandler; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.block.BlockAltar; -import WayofTime.bloodmagic.item.sigil.ItemSigilDivination; -import WayofTime.bloodmagic.item.sigil.ItemSigilSeer; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.tile.TileAltar; -import WayofTime.bloodmagic.util.helper.TextHelper; + +import java.util.List; /** * Integrated from WailaPlugins by tterrag1098. Originally implemented * in ImLookingAtBlood by Pokefenn. */ -public class DataProviderBloodAltar implements IWailaDataProvider -{ +public class DataProviderBloodAltar implements IWailaDataProvider { @Override - public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) - { + public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { return null; } @Override - public List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { + 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) - { + public List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { if (!config.getConfig(Constants.Compat.WAILA_CONFIG_ALTAR)) return currenttip; boolean hasSigil = false; boolean hasSeer = false; - switch (ConfigHandler.wailaAltarDisplayMode) - { - case 0: - { - hasSigil = hasSeer = true; - break; - } - case 1: - { - hasSeer = holdingSeerSigil(accessor.getPlayer()); - hasSigil = hasSeer || holdingDivinationSigil(accessor.getPlayer()); - break; - } - case 2: - { - hasSeer = hasStack(new ItemStack(RegistrarBloodMagicItems.SIGIL_SEER), accessor.getPlayer()); - hasSigil = hasSeer || hasStack(new ItemStack(RegistrarBloodMagicItems.SIGIL_DIVINATION), accessor.getPlayer()); - break; - } - default: - { - break; - } + switch (ConfigHandler.wailaAltarDisplayMode) { + case 0: { + hasSigil = hasSeer = true; + break; + } + case 1: { + hasSeer = holdingSeerSigil(accessor.getPlayer()); + hasSigil = hasSeer || holdingDivinationSigil(accessor.getPlayer()); + break; + } + case 2: { + hasSeer = hasStack(new ItemStack(RegistrarBloodMagicItems.SIGIL_SEER), accessor.getPlayer()); + hasSigil = hasSeer || hasStack(new ItemStack(RegistrarBloodMagicItems.SIGIL_DIVINATION), accessor.getPlayer()); + break; + } + default: { + break; + } } if (!hasSeer && !hasSigil) return currenttip; - if (accessor.getPlayer().isSneaking() || config.getConfig(Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK)) - { - if (accessor.getBlock() instanceof BlockAltar && accessor.getTileEntity() instanceof TileAltar) - { + if (accessor.getPlayer().isSneaking() || config.getConfig(Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK)) { + if (accessor.getBlock() instanceof BlockAltar && accessor.getTileEntity() instanceof TileAltar) { TileAltar altar = (TileAltar) accessor.getTileEntity(); currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.seer.currentAltarTier", altar.getTier().toInt())); currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.seer.currentAltarCapacity", altar.getCapacity())); currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.seer.currentEssence", altar.getCurrentBlood())); - if (hasSeer) - { + if (hasSeer) { int charge = accessor.getNBTData().getCompoundTag("bloodAltar").getInteger(Constants.NBT.ALTAR_TOTAL_CHARGE); int progress = accessor.getNBTData().getCompoundTag("bloodAltar").getInteger(Constants.NBT.ALTAR_PROGRESS); int liquidRequired = accessor.getNBTData().getCompoundTag("bloodAltar").getInteger(Constants.NBT.ALTAR_LIQUID_REQ); int craftAmount = 1; if (accessor.getNBTData().getTagList("Items", 10).get(0).getId() == 10) - craftAmount = ((NBTTagCompound)accessor.getNBTData().getTagList("Items", 10).get(0)).getByte("Count"); + craftAmount = ((NBTTagCompound) accessor.getNBTData().getTagList("Items", 10).get(0)).getByte("Count"); currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.seer.currentAltarProgress.percent", (int) (((double) progress / (double) liquidRequired * 100) / craftAmount) + "%")); currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.seer.currentCharge", charge)); } } - } else - { + } else { currenttip.add(TextHelper.localizeEffect("waila.bloodmagic.sneak")); } @@ -107,21 +94,18 @@ public class DataProviderBloodAltar implements IWailaDataProvider } @Override - public List getWailaTail(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { + 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) - { + public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) { if (te != null) te.writeToNBT(tag); return tag; } - public static boolean hasStack(ItemStack stack, EntityPlayer player) - { + public static boolean hasStack(ItemStack stack, EntityPlayer player) { for (ItemStack inventoryStack : player.inventory.mainInventory) if (inventoryStack != null && inventoryStack.isItemEqual(stack)) return true; @@ -129,8 +113,7 @@ public class DataProviderBloodAltar implements IWailaDataProvider return false; } - private static boolean holdingSeerSigil(EntityPlayer player) - { + private static boolean holdingSeerSigil(EntityPlayer player) { if (player.getHeldItemMainhand().getItem() instanceof ItemSigilSeer) return true; @@ -140,8 +123,7 @@ public class DataProviderBloodAltar implements IWailaDataProvider return false; } - private static boolean holdingDivinationSigil(EntityPlayer player) - { + private static boolean holdingDivinationSigil(EntityPlayer player) { if (player.getHeldItemMainhand().getItem() instanceof ItemSigilDivination) return true; 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 81c2891d..7bd19ddd 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderBloodTank.java +++ b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderBloodTank.java @@ -4,7 +4,6 @@ import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.block.BlockBloodTank; import WayofTime.bloodmagic.tile.TileBloodTank; import WayofTime.bloodmagic.util.helper.TextHelper; -import com.google.common.base.Strings; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import mcp.mobius.waila.api.IWailaDataProvider; @@ -18,30 +17,24 @@ import net.minecraftforge.fluids.FluidStack; import java.util.List; -public class DataProviderBloodTank implements IWailaDataProvider -{ +public class DataProviderBloodTank implements IWailaDataProvider { @Override - public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) - { + public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { return null; } @Override - public List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { + 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) - { + public List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { 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)) - { - if (accessor.getBlock() instanceof BlockBloodTank && accessor.getTileEntity() instanceof TileBloodTank) - { + if (accessor.getPlayer().isSneaking() || config.getConfig(Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK)) { + if (accessor.getBlock() instanceof BlockBloodTank && accessor.getTileEntity() instanceof TileBloodTank) { TileBloodTank bloodTank = (TileBloodTank) accessor.getTileEntity(); NBTTagCompound tag = accessor.getNBTData(); int capacity = accessor.getNBTData().getInteger(Constants.NBT.ALTAR_CAPACITY); @@ -49,15 +42,12 @@ public class DataProviderBloodTank implements IWailaDataProvider currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.fluid.capacity", capacity)); FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(tag.getCompoundTag(Constants.NBT.TANK)); - if (fluidStack != null) - { + if (fluidStack != null) { currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.fluid.type", fluidStack.getLocalizedName())); currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.fluid.amount", fluidStack.amount, capacity)); } } - } - else - { + } else { currenttip.add(TextHelper.localizeEffect("waila.bloodmagic.sneak")); } @@ -65,14 +55,12 @@ public class DataProviderBloodTank implements IWailaDataProvider } @Override - public List getWailaTail(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { + 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) - { + public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) { if (te != null) te.writeToNBT(tag); return tag; 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 1ce57020..96594bde 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderMimic.java +++ b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderMimic.java @@ -13,12 +13,10 @@ import net.minecraft.world.World; import java.util.List; -public class DataProviderMimic implements IWailaDataProvider -{ +public class DataProviderMimic implements IWailaDataProvider { @Override - public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) - { + public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { if (accessor.getNBTData().getBoolean("hasItem")) return new ItemStack(accessor.getNBTData()); @@ -26,28 +24,23 @@ public class DataProviderMimic implements IWailaDataProvider } @Override - public List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { + 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) - { + 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) - { + 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) - { - if (te instanceof TileMimic && ((TileMimic) te).getStackInSlot(0) != null) - { + public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) { + if (te instanceof TileMimic && ((TileMimic) te).getStackInSlot(0) != null) { tag.setBoolean("hasItem", true); ((TileMimic) te).getStackInSlot(0).writeToNBT(tag); } 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 60100dad..8e1c8868 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderRitualController.java +++ b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderRitualController.java @@ -1,17 +1,5 @@ package WayofTime.bloodmagic.compat.waila.provider; -import java.util.List; - -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; -import mcp.mobius.waila.api.IWailaDataProvider; -import net.minecraft.block.Block; -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 WayofTime.bloodmagic.api.BlockStack; import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry; @@ -22,60 +10,60 @@ import WayofTime.bloodmagic.block.BlockRitualController; import WayofTime.bloodmagic.tile.TileImperfectRitualStone; import WayofTime.bloodmagic.tile.TileMasterRitualStone; import WayofTime.bloodmagic.util.helper.TextHelper; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; +import mcp.mobius.waila.api.IWailaDataProvider; +import net.minecraft.block.Block; +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; -public class DataProviderRitualController implements IWailaDataProvider -{ +import java.util.List; + +public class DataProviderRitualController implements IWailaDataProvider { @Override - public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) - { + public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { return null; } @Override - public List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { + 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) - { + public List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { if (!config.getConfig(Constants.Compat.WAILA_CONFIG_RITUAL)) return currenttip; - if (accessor.getPlayer().isSneaking() || config.getConfig(Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK)) - { - if (accessor.getBlock() instanceof BlockRitualController) - { + if (accessor.getPlayer().isSneaking() || config.getConfig(Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK)) { + if (accessor.getBlock() instanceof BlockRitualController) { int controllerMeta = accessor.getBlock().getMetaFromState(accessor.getBlockState()); - if ((controllerMeta == 0 || controllerMeta == 2) && accessor.getTileEntity() instanceof TileMasterRitualStone) - { + if ((controllerMeta == 0 || controllerMeta == 2) && accessor.getTileEntity() instanceof TileMasterRitualStone) { TileMasterRitualStone mrs = (TileMasterRitualStone) accessor.getTileEntity(); - if (mrs.getCurrentRitual() != null && mrs.isActive()) - { + if (mrs.getCurrentRitual() != null && mrs.isActive()) { currenttip.add(TextHelper.localizeEffect(mrs.getCurrentRitual().getUnlocalizedName())); currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentOwner", PlayerHelper.getUsernameFromUUID(mrs.getOwner()))); if (!RitualRegistry.ritualEnabled(mrs.getCurrentRitual())) currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.config.disabled")); - } else - { + } else { currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.deactivated")); } } - if (controllerMeta == 1 && accessor.getTileEntity() instanceof TileImperfectRitualStone) - { - if (accessor.getWorld().isAirBlock(accessor.getPosition().up())) - { + if (controllerMeta == 1 && accessor.getTileEntity() instanceof TileImperfectRitualStone) { + 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())); BlockStack blockStack = new BlockStack(up, meta); ImperfectRitual ritual = ImperfectRitualRegistry.getRitualForBlock(blockStack); - if (ritual != null) - { + if (ritual != null) { currenttip.add(TextHelper.localizeEffect(ritual.getUnlocalizedName())); if (!ImperfectRitualRegistry.ritualEnabled(ritual)) currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.config.disabled")); @@ -83,8 +71,7 @@ public class DataProviderRitualController implements IWailaDataProvider } } } - } else - { + } else { currenttip.add(TextHelper.localizeEffect("waila.bloodmagic.sneak")); } @@ -92,14 +79,12 @@ public class DataProviderRitualController implements IWailaDataProvider } @Override - public List getWailaTail(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { + 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) - { + 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/DataProviderTeleposer.java b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderTeleposer.java index 1b5b9078..d76f0043 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderTeleposer.java +++ b/src/main/java/WayofTime/bloodmagic/compat/waila/provider/DataProviderTeleposer.java @@ -1,7 +1,10 @@ package WayofTime.bloodmagic.compat.waila.provider; -import java.util.List; - +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.block.BlockTeleposer; +import WayofTime.bloodmagic.item.ItemTelepositionFocus; +import WayofTime.bloodmagic.tile.TileTeleposer; +import WayofTime.bloodmagic.util.helper.TextHelper; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import mcp.mobius.waila.api.IWailaDataProvider; @@ -11,39 +14,29 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.block.BlockTeleposer; -import WayofTime.bloodmagic.item.ItemTelepositionFocus; -import WayofTime.bloodmagic.tile.TileTeleposer; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class DataProviderTeleposer implements IWailaDataProvider -{ +import java.util.List; + +public class DataProviderTeleposer implements IWailaDataProvider { @Override - public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) - { + public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { return null; } @Override - public List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { + 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) - { + public List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { if (!config.getConfig(Constants.Compat.WAILA_CONFIG_TELEPOSER)) return currenttip; - if (accessor.getPlayer().isSneaking() || config.getConfig(Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK)) - { - if (accessor.getBlock() instanceof BlockTeleposer && accessor.getTileEntity() instanceof TileTeleposer) - { + if (accessor.getPlayer().isSneaking() || config.getConfig(Constants.Compat.WAILA_CONFIG_BYPASS_SNEAK)) { + if (accessor.getBlock() instanceof BlockTeleposer && accessor.getTileEntity() instanceof TileTeleposer) { TileTeleposer teleposer = (TileTeleposer) accessor.getTileEntity(); - if (!teleposer.getStackInSlot(0).isEmpty()) - { + if (!teleposer.getStackInSlot(0).isEmpty()) { ItemStack contained = teleposer.getStackInSlot(0); BlockPos toPos = ((ItemTelepositionFocus) contained.getItem()).getBlockPos(contained); int dimensionID = contained.getTagCompound().getInteger(Constants.NBT.DIMENSION_ID); @@ -52,8 +45,7 @@ public class DataProviderTeleposer implements IWailaDataProvider currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.dimension", dimensionID)); } } - } else - { + } else { currenttip.add(TextHelper.localizeEffect("waila.bloodmagic.sneak")); } @@ -61,14 +53,12 @@ public class DataProviderTeleposer implements IWailaDataProvider } @Override - public List getWailaTail(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { + 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) - { + public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) { return null; } } diff --git a/src/main/java/WayofTime/bloodmagic/compress/AdvancedCompressionHandler.java b/src/main/java/WayofTime/bloodmagic/compress/AdvancedCompressionHandler.java index 9c681f00..fc018d59 100644 --- a/src/main/java/WayofTime/bloodmagic/compress/AdvancedCompressionHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compress/AdvancedCompressionHandler.java @@ -8,34 +8,26 @@ import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public class AdvancedCompressionHandler extends CompressionHandler -{ +public class AdvancedCompressionHandler extends CompressionHandler { @Override - public ItemStack compressInventory(ItemStack[] inv, World world) - { + public ItemStack compressInventory(ItemStack[] inv, World world) { return test(inv, true, world); } - public ItemStack test(ItemStack[] inv, boolean doDrain, World world) - { - for (ItemStack invStack : inv) - { - if (invStack.isEmpty()) - { + public ItemStack test(ItemStack[] inv, boolean doDrain, World world) { + for (ItemStack invStack : inv) { + if (invStack.isEmpty()) { continue; } - for (int i = 2; i <= 3; i++) - { + for (int i = 2; i <= 3; i++) { ItemStack stack = getRecipe(invStack, world, i); - if (!stack.isEmpty()) - { + if (!stack.isEmpty()) { int threshold = CompressionRegistry.getItemThreshold(invStack); int needed = i * i; int neededLeft = iterateThroughInventory(invStack, threshold + invStack.getMaxStackSize() - needed, inv, needed, false); - if (neededLeft <= 0) - { + if (neededLeft <= 0) { iterateThroughInventory(invStack, 0, inv, needed, true); return stack; } @@ -46,39 +38,31 @@ public class AdvancedCompressionHandler extends CompressionHandler return ItemStack.EMPTY; } - public int iterateThroughInventory(ItemStack required, int kept, ItemStack[] inv, int needed, boolean doDrain) - { + public int iterateThroughInventory(ItemStack required, int kept, ItemStack[] inv, int needed, boolean doDrain) { int i = -1; - for (ItemStack invStack : inv) - { + for (ItemStack invStack : inv) { i++; - if (invStack.isEmpty()) - { + if (invStack.isEmpty()) { continue; } - if (invStack.isItemEqual(required) && (invStack.getTagCompound() == null ? required.getTagCompound() == null : invStack.getTagCompound().equals(required.getTagCompound()))) - { + if (invStack.isItemEqual(required) && (invStack.getTagCompound() == null ? required.getTagCompound() == null : invStack.getTagCompound().equals(required.getTagCompound()))) { int stackSize = invStack.getCount(); int used = 0; - if (kept > 0) - { + if (kept > 0) { int remainingFromStack = Math.max(stackSize - kept, 0); used += stackSize - remainingFromStack; } kept -= used; - if (kept <= 0 && needed > 0) - { + if (kept <= 0 && needed > 0) { int remainingFromStack = Math.max(stackSize - used - needed, 0); - if (doDrain) - { + if (doDrain) { invStack.setCount(remainingFromStack + used); - if (invStack.isEmpty()) - { + if (invStack.isEmpty()) { inv[i] = ItemStack.EMPTY; } } @@ -86,8 +70,7 @@ public class AdvancedCompressionHandler extends CompressionHandler needed -= (stackSize - used - remainingFromStack); } - if (needed <= 0) - { + if (needed <= 0) { return 0; } } @@ -96,16 +79,12 @@ public class AdvancedCompressionHandler extends CompressionHandler return needed; } - public static boolean isResultStackReversible(ItemStack stack, int gridSize, World world) - { - if (stack.isEmpty()) - { + public static boolean isResultStackReversible(ItemStack stack, int gridSize, World world) { + if (stack.isEmpty()) { return false; } - InventoryCrafting inventory = new InventoryCrafting(new Container() - { - public boolean canInteractWith(EntityPlayer player) - { + InventoryCrafting inventory = new InventoryCrafting(new Container() { + public boolean canInteractWith(EntityPlayer player) { return false; } }, 2, 2); @@ -113,59 +92,49 @@ public class AdvancedCompressionHandler extends CompressionHandler inventory.setInventorySlotContents(0, stack); ItemStack returnStack = StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world); - if (returnStack.isEmpty()) - { + if (returnStack.isEmpty()) { return false; } ItemStack compressedStack = ItemStack.EMPTY; - switch (gridSize) - { - case 2: - compressedStack = get22Recipe(returnStack, world); - break; - case 3: - compressedStack = get33Recipe(returnStack, world); - break; + switch (gridSize) { + case 2: + compressedStack = get22Recipe(returnStack, world); + break; + case 3: + compressedStack = get33Recipe(returnStack, world); + break; } return !compressedStack.isEmpty() && CompressionRegistry.areItemStacksEqual(stack, compressedStack); } - public static ItemStack getRecipe(ItemStack stack, World world, int gridSize) - { - InventoryCrafting inventory = new InventoryCrafting(new Container() - { - public boolean canInteractWith(EntityPlayer player) - { + public static ItemStack getRecipe(ItemStack stack, World world, int gridSize) { + InventoryCrafting inventory = new InventoryCrafting(new Container() { + public boolean canInteractWith(EntityPlayer player) { return false; } }, gridSize, gridSize); - for (int i = 0; i < inventory.getSizeInventory(); i++) - { + for (int i = 0; i < inventory.getSizeInventory(); i++) { inventory.setInventorySlotContents(i, stack); } return StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world); } - public static boolean has22Recipe(ItemStack stack, World world) - { + public static boolean has22Recipe(ItemStack stack, World world) { return !get22Recipe(stack, world).isEmpty(); } - public static ItemStack get22Recipe(ItemStack stack, World world) - { + public static ItemStack get22Recipe(ItemStack stack, World world) { return getRecipe(stack, world, 2); } - public static boolean has33Recipe(ItemStack stack, World world) - { + public static boolean has33Recipe(ItemStack stack, World world) { return !get33Recipe(stack, world).isEmpty(); } - public static ItemStack get33Recipe(ItemStack stack, World world) - { + public static ItemStack get33Recipe(ItemStack stack, World world) { return getRecipe(stack, world, 3); } } diff --git a/src/main/java/WayofTime/bloodmagic/compress/BaseCompressionHandler.java b/src/main/java/WayofTime/bloodmagic/compress/BaseCompressionHandler.java index 4573bde1..00dd6361 100644 --- a/src/main/java/WayofTime/bloodmagic/compress/BaseCompressionHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compress/BaseCompressionHandler.java @@ -4,36 +4,30 @@ import WayofTime.bloodmagic.api.compress.CompressionHandler; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public class BaseCompressionHandler extends CompressionHandler -{ +public class BaseCompressionHandler extends CompressionHandler { private final ItemStack required; private final ItemStack result; private final int leftover; - public BaseCompressionHandler(ItemStack requested, ItemStack result, int leftover) - { + public BaseCompressionHandler(ItemStack requested, ItemStack result, int leftover) { super(); this.required = requested; this.result = result; this.leftover = leftover; } - public ItemStack getResultStack() - { + public ItemStack getResultStack() { return this.result.copy(); } - public ItemStack getRequiredStack() - { + public ItemStack getRequiredStack() { return this.required.copy(); } @Override - public ItemStack compressInventory(ItemStack[] inv, World world) - { + public ItemStack compressInventory(ItemStack[] inv, World world) { int remaining = this.getRemainingNeeded(inv); - if (remaining <= 0) - { + if (remaining <= 0) { this.drainInventory(inv); return this.getResultStack(); } @@ -41,51 +35,41 @@ public class BaseCompressionHandler extends CompressionHandler return ItemStack.EMPTY; } - public int getRemainingNeeded(ItemStack[] inv) - { + public int getRemainingNeeded(ItemStack[] inv) { return iterateThroughInventory(inv, false); } - public int drainInventory(ItemStack[] inv) - { + public int drainInventory(ItemStack[] inv) { return iterateThroughInventory(inv, true); } - public int iterateThroughInventory(ItemStack[] inv, boolean doDrain) - { + public int iterateThroughInventory(ItemStack[] inv, boolean doDrain) { int needed = this.required.getCount(); int kept = this.getLeftover(); int i = -1; - for (ItemStack invStack : inv) - { + for (ItemStack invStack : inv) { i++; - if (invStack == null) - { + if (invStack == null) { continue; } - if (invStack.isItemEqual(this.required) && (invStack.getTagCompound() == null ? this.required.getTagCompound() == null : invStack.getTagCompound().equals(this.required.getTagCompound()))) - { + if (invStack.isItemEqual(this.required) && (invStack.getTagCompound() == null ? this.required.getTagCompound() == null : invStack.getTagCompound().equals(this.required.getTagCompound()))) { int stackSize = invStack.getCount(); int used = 0; - if (kept > 0) - { + if (kept > 0) { int remainingFromStack = Math.max(stackSize - kept, 0); used += stackSize - remainingFromStack; } kept -= used; - if (kept <= 0 && needed > 0) - { + if (kept <= 0 && needed > 0) { int remainingFromStack = Math.max(stackSize - used - needed, 0); - if (doDrain) - { + if (doDrain) { invStack.setCount(remainingFromStack + used); - if (invStack.isEmpty()) - { + if (invStack.isEmpty()) { inv[i] = ItemStack.EMPTY; } } @@ -93,8 +77,7 @@ public class BaseCompressionHandler extends CompressionHandler needed -= (stackSize - used - remainingFromStack); } - if (needed <= 0) - { + if (needed <= 0) { return 0; } } @@ -103,8 +86,7 @@ public class BaseCompressionHandler extends CompressionHandler return needed; } - public int getLeftover() - { + public int getLeftover() { return this.leftover; } } diff --git a/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingManager.java b/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingManager.java index 46730d7b..093dbff0 100644 --- a/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingManager.java +++ b/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingManager.java @@ -13,121 +13,35 @@ import net.minecraft.world.World; import java.util.LinkedList; import java.util.List; -public class StorageBlockCraftingManager -{ +public class StorageBlockCraftingManager { private static final StorageBlockCraftingManager instance = new StorageBlockCraftingManager(); private List recipes = new LinkedList(); - public static StorageBlockCraftingManager getInstance() - { - return instance; - } - - public void addStorageBlockRecipes() - { + public void addStorageBlockRecipes() { // this.recipes = new StorageBlockCraftingRecipeAssimilator().getPackingRecipes(); BloodMagic.instance.logger.info("Total number of compression recipes: " + this.recipes.size()); } - private static boolean isResultStackReversible(ItemStack stack, int gridSize, World world, List list) - { - if (stack.isEmpty()) - { - return false; - } - InventoryCrafting inventory = new InventoryCrafting(new Container() - { - public boolean canInteractWith(EntityPlayer player) - { - return false; - } - }, 2, 2); - - inventory.setInventorySlotContents(0, stack); - - ItemStack returnStack = StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world, list); - if (returnStack.isEmpty()) - { - return false; - } - - ItemStack compressedStack = ItemStack.EMPTY; - switch (gridSize) - { - case 2: - compressedStack = get22Recipe(returnStack, world, list); - break; - case 3: - compressedStack = get33Recipe(returnStack, world, list); - break; - } - - return !compressedStack.isEmpty() && CompressionRegistry.areItemStacksEqual(stack, compressedStack); - } - - private static ItemStack getRecipe(ItemStack stack, World world, int gridSize, List list) - { - InventoryCrafting inventory = new InventoryCrafting(new Container() - { - public boolean canInteractWith(EntityPlayer player) - { - return false; - } - }, gridSize, gridSize); - for (int i = 0; i < inventory.getSizeInventory(); i++) - { - inventory.setInventorySlotContents(i, stack); - } - - return StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world, list); - } - - private static boolean has22Recipe(ItemStack stack, World world, List list) - { - return !get22Recipe(stack, world, list).isEmpty(); - } - - private static ItemStack get22Recipe(ItemStack stack, World world, List list) - { - return getRecipe(stack, world, 2, list); - } - - private static boolean has33Recipe(ItemStack stack, World world, List list) - { - return !get33Recipe(stack, world, list).isEmpty(); - } - - private static ItemStack get33Recipe(ItemStack stack, World world, List list) - { - return getRecipe(stack, world, 3, list); - } - - public ItemStack findMatchingRecipe(InventoryCrafting craftingInventory, World world) - { + public ItemStack findMatchingRecipe(InventoryCrafting craftingInventory, World world) { return this.findMatchingRecipe(craftingInventory, world, this.recipes); } - private ItemStack findMatchingRecipe(InventoryCrafting craftingInventory, World world, List list) - { + private ItemStack findMatchingRecipe(InventoryCrafting craftingInventory, World world, List list) { int i = 0; ItemStack itemstack = ItemStack.EMPTY; ItemStack itemstack1 = ItemStack.EMPTY; int j; - for (j = 0; j < craftingInventory.getSizeInventory(); ++j) - { + for (j = 0; j < craftingInventory.getSizeInventory(); ++j) { ItemStack itemstack2 = craftingInventory.getStackInSlot(j); - if (!itemstack2.isEmpty()) - { - if (i == 0) - { + if (!itemstack2.isEmpty()) { + if (i == 0) { itemstack = itemstack2; } - if (i == 1) - { + if (i == 1) { itemstack1 = itemstack2; } @@ -135,28 +49,23 @@ public class StorageBlockCraftingManager } } - if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.getCount() == 1 && itemstack1.getCount() == 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) - 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) - { + if (i1 < 0) { i1 = 0; } return new ItemStack(itemstack.getItem(), 1, i1); - } else - { - for (j = 0; j < list.size(); ++j) - { + } else { + for (j = 0; j < list.size(); ++j) { IRecipe irecipe = (IRecipe) list.get(j); - if (irecipe.matches(craftingInventory, world)) - { + if (irecipe.matches(craftingInventory, world)) { return irecipe.getCraftingResult(craftingInventory); } } @@ -164,4 +73,67 @@ public class StorageBlockCraftingManager return ItemStack.EMPTY; } } + + public static StorageBlockCraftingManager getInstance() { + return instance; + } + + private static boolean isResultStackReversible(ItemStack stack, int gridSize, World world, List list) { + if (stack.isEmpty()) { + return false; + } + InventoryCrafting inventory = new InventoryCrafting(new Container() { + public boolean canInteractWith(EntityPlayer player) { + return false; + } + }, 2, 2); + + inventory.setInventorySlotContents(0, stack); + + ItemStack returnStack = StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world, list); + if (returnStack.isEmpty()) { + return false; + } + + ItemStack compressedStack = ItemStack.EMPTY; + switch (gridSize) { + case 2: + compressedStack = get22Recipe(returnStack, world, list); + break; + case 3: + compressedStack = get33Recipe(returnStack, world, list); + break; + } + + return !compressedStack.isEmpty() && CompressionRegistry.areItemStacksEqual(stack, compressedStack); + } + + private static ItemStack getRecipe(ItemStack stack, World world, int gridSize, List list) { + InventoryCrafting inventory = new InventoryCrafting(new Container() { + public boolean canInteractWith(EntityPlayer player) { + return false; + } + }, gridSize, gridSize); + for (int i = 0; i < inventory.getSizeInventory(); i++) { + inventory.setInventorySlotContents(i, stack); + } + + return StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world, list); + } + + private static boolean has22Recipe(ItemStack stack, World world, List list) { + return !get22Recipe(stack, world, list).isEmpty(); + } + + private static ItemStack get22Recipe(ItemStack stack, World world, List list) { + return getRecipe(stack, world, 2, list); + } + + private static boolean has33Recipe(ItemStack stack, World world, List list) { + return !get33Recipe(stack, world, list).isEmpty(); + } + + private static ItemStack get33Recipe(ItemStack stack, World world, List list) { + return getRecipe(stack, world, 3, list); + } } diff --git a/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingRecipeAssimilator.java b/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingRecipeAssimilator.java index f119e102..b5870b6d 100644 --- a/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingRecipeAssimilator.java +++ b/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingRecipeAssimilator.java @@ -1,21 +1,6 @@ package WayofTime.bloodmagic.compress; -import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.*; -import net.minecraft.world.World; -import net.minecraftforge.fml.common.registry.ForgeRegistries; -import net.minecraftforge.oredict.OreDictionary; -import net.minecraftforge.oredict.ShapedOreRecipe; -import net.minecraftforge.oredict.ShapelessOreRecipe; - -import java.util.*; - -public class StorageBlockCraftingRecipeAssimilator -{ +public class StorageBlockCraftingRecipeAssimilator { // public static final List ignore = new ArrayList(); // // public List getPackingRecipes() diff --git a/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagic.java b/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagic.java index 074f188a..a3184496 100644 --- a/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagic.java +++ b/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagic.java @@ -4,7 +4,10 @@ import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.orb.BloodOrb; import WayofTime.bloodmagic.api.registry.OrbRegistry; import WayofTime.bloodmagic.entity.mob.*; -import WayofTime.bloodmagic.entity.projectile.*; +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 WayofTime.bloodmagic.potion.PotionBloodMagic; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.init.MobEffects; @@ -87,16 +90,16 @@ public class RegistrarBloodMagic { @SubscribeEvent public static void registerEntities(RegistryEvent.Register event) { int entities = 0; - EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "blood_light"), EntityBloodLight.class, "BloodLight", ++entities, BloodMagic.instance, 16*4, 3, true); - EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "soul_snare"), EntitySoulSnare.class, "SoulSnare", ++entities, BloodMagic.instance, 16*4, 3, true); - EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "soul_arrow"), EntitySentientArrow.class, "SoulArrow", ++entities, BloodMagic.instance, 16*4, 3, true); - EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "meteor"), EntityMeteor.class, "Meteor", ++entities, BloodMagic.instance, 16*4, 3, true); - EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "sentient_specter"), EntitySentientSpecter.class, "SentientSpecter", ++entities, BloodMagic.instance, 16*4, 3, true); - EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "mimic"), EntityMimic.class, "Mimic", ++entities, BloodMagic.instance, 16*4, 3, true); - EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "corrupted_zombie"), EntityCorruptedZombie.class, "CorruptedZombie", ++entities, BloodMagic.instance, 16*4, 3, true); - EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "corrupted_sheep"), EntityCorruptedSheep.class, "CorruptedSheep", ++entities, BloodMagic.instance, 16*4, 3, true); - EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "corrupted_chicken"), EntityCorruptedChicken.class, "CorruptedChicken", ++entities, BloodMagic.instance, 16*4, 3, true); - EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "corrupted_spider"), EntityCorruptedSpider.class, "CorruptedSpider", ++entities, BloodMagic.instance, 16*4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "blood_light"), EntityBloodLight.class, "BloodLight", ++entities, BloodMagic.instance, 16 * 4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "soul_snare"), EntitySoulSnare.class, "SoulSnare", ++entities, BloodMagic.instance, 16 * 4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "soul_arrow"), EntitySentientArrow.class, "SoulArrow", ++entities, BloodMagic.instance, 16 * 4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "meteor"), EntityMeteor.class, "Meteor", ++entities, BloodMagic.instance, 16 * 4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "sentient_specter"), EntitySentientSpecter.class, "SentientSpecter", ++entities, BloodMagic.instance, 16 * 4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "mimic"), EntityMimic.class, "Mimic", ++entities, BloodMagic.instance, 16 * 4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "corrupted_zombie"), EntityCorruptedZombie.class, "CorruptedZombie", ++entities, BloodMagic.instance, 16 * 4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "corrupted_sheep"), EntityCorruptedSheep.class, "CorruptedSheep", ++entities, BloodMagic.instance, 16 * 4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "corrupted_chicken"), EntityCorruptedChicken.class, "CorruptedChicken", ++entities, BloodMagic.instance, 16 * 4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(BloodMagic.MODID, "corrupted_spider"), EntityCorruptedSpider.class, "CorruptedSpider", ++entities, BloodMagic.instance, 16 * 4, 3, true); } @SubscribeEvent diff --git a/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicBlocks.java b/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicBlocks.java index 0f2d063d..58e11bc8 100644 --- a/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicBlocks.java +++ b/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicBlocks.java @@ -1,6 +1,13 @@ package WayofTime.bloodmagic.core; +import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.block.*; +import WayofTime.bloodmagic.block.enums.*; +import WayofTime.bloodmagic.tile.*; +import WayofTime.bloodmagic.tile.routing.TileInputRoutingNode; +import WayofTime.bloodmagic.tile.routing.TileItemRoutingNode; +import WayofTime.bloodmagic.tile.routing.TileMasterRoutingNode; +import WayofTime.bloodmagic.tile.routing.TileOutputRoutingNode; import com.google.common.collect.Sets; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -10,45 +17,13 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.block.enums.EnumDemonBlock1; -import WayofTime.bloodmagic.block.enums.EnumDemonBlock2; -import WayofTime.bloodmagic.block.enums.EnumDemonBlock3; -import WayofTime.bloodmagic.block.enums.EnumSubWillType; -import WayofTime.bloodmagic.block.enums.EnumSubWillType1; -import WayofTime.bloodmagic.block.enums.EnumSubWillType2; -import WayofTime.bloodmagic.block.enums.EnumSubWillType3; -import WayofTime.bloodmagic.block.enums.EnumWillWall; -import WayofTime.bloodmagic.tile.TileAlchemyArray; -import WayofTime.bloodmagic.tile.TileAlchemyTable; -import WayofTime.bloodmagic.tile.TileAltar; -import WayofTime.bloodmagic.tile.TileBloodTank; -import WayofTime.bloodmagic.tile.TileDemonCrucible; -import WayofTime.bloodmagic.tile.TileDemonCrystal; -import WayofTime.bloodmagic.tile.TileDemonCrystallizer; -import WayofTime.bloodmagic.tile.TileDemonPylon; -import WayofTime.bloodmagic.tile.TileDimensionalPortal; -import WayofTime.bloodmagic.tile.TileImperfectRitualStone; -import WayofTime.bloodmagic.tile.TileIncenseAltar; -import WayofTime.bloodmagic.tile.TileInversionPillar; -import WayofTime.bloodmagic.tile.TileMasterRitualStone; -import WayofTime.bloodmagic.tile.TileMimic; -import WayofTime.bloodmagic.tile.TilePhantomBlock; -import WayofTime.bloodmagic.tile.TileSoulForge; -import WayofTime.bloodmagic.tile.TileSpectralBlock; -import WayofTime.bloodmagic.tile.TileTeleposer; -import WayofTime.bloodmagic.tile.routing.TileInputRoutingNode; -import WayofTime.bloodmagic.tile.routing.TileItemRoutingNode; -import WayofTime.bloodmagic.tile.routing.TileMasterRoutingNode; -import WayofTime.bloodmagic.tile.routing.TileOutputRoutingNode; import java.util.Set; @Mod.EventBusSubscriber(modid = BloodMagic.MODID) @GameRegistry.ObjectHolder(BloodMagic.MODID) @SuppressWarnings("unused") -public class RegistrarBloodMagicBlocks -{ +public class RegistrarBloodMagicBlocks { public static final Block ALTAR = Blocks.AIR; public static final Block BLOOD_RUNE = Blocks.AIR; public static final Block RITUAL_CONTROLLER = Blocks.AIR; @@ -94,11 +69,10 @@ public class RegistrarBloodMagicBlocks static Set blocks; @SubscribeEvent - public static void registerBlocks(RegistryEvent.Register event) - { + public static void registerBlocks(RegistryEvent.Register event) { FluidRegistry.registerFluid(BlockLifeEssence.getLifeEssence()); FluidRegistry.addBucketForFluid(BlockLifeEssence.getLifeEssence()); - + blocks = Sets.newHashSet( new BlockAltar().setRegistryName("altar"), new BlockBloodRune().setRegistryName("blood_rune"), diff --git a/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicItems.java b/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicItems.java index 644c7b1a..1cc3cd7c 100644 --- a/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicItems.java +++ b/src/main/java/WayofTime/bloodmagic/core/RegistrarBloodMagicItems.java @@ -1,25 +1,8 @@ package WayofTime.bloodmagic.core; +import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.block.IBMBlock; import WayofTime.bloodmagic.client.IVariantProvider; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; -import net.minecraft.client.renderer.block.model.ModelResourceLocation; -import net.minecraft.init.Items; -import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.event.ModelRegistryEvent; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.common.util.EnumHelper; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.registry.GameRegistry; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.item.*; import WayofTime.bloodmagic.item.alchemy.ItemCuttingFluid; import WayofTime.bloodmagic.item.alchemy.ItemLivingArmourPointsUpgrade; @@ -32,17 +15,29 @@ import WayofTime.bloodmagic.item.routing.ItemNodeRouter; import WayofTime.bloodmagic.item.routing.ItemRouterFilter; import WayofTime.bloodmagic.item.sigil.*; import WayofTime.bloodmagic.item.soul.*; +import com.google.common.collect.Lists; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.init.Items; +import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.item.Item; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.ModelRegistryEvent; +import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.common.util.EnumHelper; +import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.commons.lang3.tuple.Pair; -import java.util.Comparator; import java.util.List; -import java.util.Set; @Mod.EventBusSubscriber(modid = BloodMagic.MODID) @GameRegistry.ObjectHolder(BloodMagic.MODID) @SuppressWarnings("unchecked") -public class RegistrarBloodMagicItems -{ +public class RegistrarBloodMagicItems { public static final Item BLOOD_ORB = Items.AIR; public static final Item ACTIVATION_CRYSTAL = Items.AIR; public static final Item SLATE = Items.AIR; @@ -122,8 +117,7 @@ public class RegistrarBloodMagicItems public static List items; @SubscribeEvent - public static void registerItems(RegistryEvent.Register event) - { + public static void registerItems(RegistryEvent.Register event) { items = Lists.newArrayList(); RegistrarBloodMagicBlocks.blocks.stream().filter(block -> block instanceof IBMBlock && ((IBMBlock) block).getItem() != null).forEach(block -> { @@ -211,8 +205,7 @@ public class RegistrarBloodMagicItems @SideOnly(Side.CLIENT) @SubscribeEvent - public static void registerRenders(ModelRegistryEvent event) - { + public static void registerRenders(ModelRegistryEvent event) { items.stream().filter(i -> i instanceof IVariantProvider).forEach(item -> { IVariantProvider variantProvider = (IVariantProvider) item; for (Pair variant : variantProvider.getVariants()) diff --git a/src/main/java/WayofTime/bloodmagic/demonAura/PosXY.java b/src/main/java/WayofTime/bloodmagic/demonAura/PosXY.java index 8a478e7d..f2b3f4c3 100644 --- a/src/main/java/WayofTime/bloodmagic/demonAura/PosXY.java +++ b/src/main/java/WayofTime/bloodmagic/demonAura/PosXY.java @@ -2,8 +2,7 @@ package WayofTime.bloodmagic.demonAura; import org.apache.commons.lang3.builder.ToStringBuilder; -public class PosXY implements Comparable -{ +public class PosXY implements Comparable { public int x; public int y; @@ -16,20 +15,17 @@ public class PosXY implements Comparable } @Override - public int compareTo(PosXY c) - { + public int compareTo(PosXY c) { return this.y == c.y ? this.x - c.x : this.y - c.y; } - public float getDistanceSquared(int x, int z) - { + public float getDistanceSquared(int x, int z) { float f = this.x - x; float f2 = this.y - z; return f * f + f2 * f2; } - public float getDistanceSquaredToChunkCoordinates(PosXY c) - { + public float getDistanceSquaredToChunkCoordinates(PosXY c) { return getDistanceSquared(c.x, c.y); } diff --git a/src/main/java/WayofTime/bloodmagic/demonAura/WillChunk.java b/src/main/java/WayofTime/bloodmagic/demonAura/WillChunk.java index bf0c4f6e..01547e6f 100644 --- a/src/main/java/WayofTime/bloodmagic/demonAura/WillChunk.java +++ b/src/main/java/WayofTime/bloodmagic/demonAura/WillChunk.java @@ -5,20 +5,17 @@ import net.minecraft.world.chunk.Chunk; import java.lang.ref.WeakReference; -public class WillChunk -{ +public class WillChunk { PosXY loc; private short base; private DemonWillHolder currentWill = new DemonWillHolder(); private WeakReference chunkRef; - public WillChunk(PosXY loc) - { + public WillChunk(PosXY loc) { this.loc = loc; } - public WillChunk(Chunk chunk, short base, DemonWillHolder currentWill) - { + public WillChunk(Chunk chunk, short base, DemonWillHolder currentWill) { this.loc = new PosXY(chunk.x, chunk.z); this.chunkRef = new WeakReference(chunk); this.base = base; diff --git a/src/main/java/WayofTime/bloodmagic/demonAura/WillWorld.java b/src/main/java/WayofTime/bloodmagic/demonAura/WillWorld.java index 3d3f0164..bf587940 100644 --- a/src/main/java/WayofTime/bloodmagic/demonAura/WillWorld.java +++ b/src/main/java/WayofTime/bloodmagic/demonAura/WillWorld.java @@ -2,25 +2,21 @@ package WayofTime.bloodmagic.demonAura; import java.util.concurrent.ConcurrentHashMap; -public class WillWorld -{ +public class WillWorld { int dim; ConcurrentHashMap willChunks = new ConcurrentHashMap(); // private static ConcurrentHashMap nodeTickets = new ConcurrentHashMap(); - public WillWorld(int dim) - { + public WillWorld(int dim) { this.dim = dim; } - public WillChunk getWillChunkAt(int x, int y) - { + public WillChunk getWillChunkAt(int x, int y) { return getWillChunkAt(new PosXY(x, y)); } - public WillChunk getWillChunkAt(PosXY loc) - { + public WillChunk getWillChunkAt(PosXY loc) { return this.willChunks.get(loc); } diff --git a/src/main/java/WayofTime/bloodmagic/demonAura/WorldDemonWillHandler.java b/src/main/java/WayofTime/bloodmagic/demonAura/WorldDemonWillHandler.java index 65f783ab..98201ee6 100644 --- a/src/main/java/WayofTime/bloodmagic/demonAura/WorldDemonWillHandler.java +++ b/src/main/java/WayofTime/bloodmagic/demonAura/WorldDemonWillHandler.java @@ -11,64 +11,52 @@ import javax.annotation.Nullable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; -public class WorldDemonWillHandler -{ - static ConcurrentHashMap containedWills = new ConcurrentHashMap(); +public class WorldDemonWillHandler { public static ConcurrentHashMap> dirtyChunks = new ConcurrentHashMap>(); + static ConcurrentHashMap containedWills = new ConcurrentHashMap(); @Nullable - public static DemonWillHolder getWillHolder(int dim, int x, int y) - { + public static DemonWillHolder getWillHolder(int dim, int x, int y) { WillChunk chunk = getWillChunk(dim, x, y); - if (chunk != null) - { + if (chunk != null) { return chunk.getCurrentWill(); } return null; } - public static DemonWillHolder getWillHolder(World world, BlockPos pos) - { + public static DemonWillHolder getWillHolder(World world, BlockPos pos) { return getWillHolder(world.provider.getDimension(), pos.getX() >> 4, pos.getZ() >> 4); } - public static WillWorld getWillWorld(int dim) - { + public static WillWorld getWillWorld(int dim) { return containedWills.get(dim); } @Nullable - public static WillChunk getWillChunk(int dim, int x, int y) - { - if (!containedWills.containsKey(dim)) - { + public static WillChunk getWillChunk(int dim, int x, int y) { + if (!containedWills.containsKey(dim)) { addWillWorld(dim); } return (containedWills.get(dim)).getWillChunkAt(x, y); } - public static void addWillWorld(int dim) - { - if (!containedWills.containsKey(dim)) - { + public static void addWillWorld(int dim) { + if (!containedWills.containsKey(dim)) { containedWills.put(dim, new WillWorld(dim)); BloodMagicAPI.logger.info("Creating demon will cache for world " + dim); } } - public static void removeWillWorld(int dim) - { + public static void removeWillWorld(int dim) { containedWills.remove(dim); BloodMagicAPI.logger.info("Removing demon will cache for world " + dim); } - public static void addWillChunk(int dim, Chunk chunk, short base, DemonWillHolder currentWill) - { + public static void addWillChunk(int dim, Chunk chunk, short base, DemonWillHolder currentWill) { WillWorld aw = containedWills.get(dim); - if (aw == null) - { + if (aw == null) { aw = new WillWorld(dim); } aw.getWillChunks().put(new PosXY(chunk.x, chunk.z), new WillChunk(chunk, base, currentWill)); @@ -76,31 +64,25 @@ public class WorldDemonWillHandler containedWills.put(dim, aw); } - public static void removeWillChunk(int dim, int x, int y) - { + public static void removeWillChunk(int dim, int x, int y) { WillWorld aw = containedWills.get(dim); - if (aw != null) - { + if (aw != null) { WillChunk chunk = aw.getWillChunks().remove(new PosXY(x, y)); - if (chunk != null) - { + if (chunk != null) { markChunkAsDirty(chunk, dim); } } } - public static EnumDemonWillType getHighestDemonWillType(World world, BlockPos pos) - { + public static EnumDemonWillType getHighestDemonWillType(World world, BlockPos pos) { double currentMax = 0; EnumDemonWillType currentHighest = EnumDemonWillType.DEFAULT; WillChunk willChunk = getWillChunk(world, pos); DemonWillHolder currentWill = willChunk.getCurrentWill(); - for (EnumDemonWillType type : EnumDemonWillType.values()) - { - if (currentWill.getWill(type) > currentMax) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { + if (currentWill.getWill(type) > currentMax) { currentMax = currentWill.getWill(type); currentHighest = type; } @@ -109,14 +91,12 @@ public class WorldDemonWillHandler return currentHighest; } - public static double drainWill(World world, BlockPos pos, EnumDemonWillType type, double amount, boolean doDrain) - { + public static double drainWill(World world, BlockPos pos, EnumDemonWillType type, double amount, boolean doDrain) { WillChunk willChunk = getWillChunk(world, pos); DemonWillHolder currentWill = willChunk.getCurrentWill(); double drain = Math.min(currentWill.getWill(type), amount); - if (!doDrain) - { + if (!doDrain) { return drain; } @@ -126,14 +106,12 @@ public class WorldDemonWillHandler return drain; } - public static double fillWillToMaximum(World world, BlockPos pos, EnumDemonWillType type, double amount, double max, boolean doFill) - { + public static double fillWillToMaximum(World world, BlockPos pos, EnumDemonWillType type, double amount, double max, boolean doFill) { WillChunk willChunk = getWillChunk(world, pos); DemonWillHolder currentWill = willChunk.getCurrentWill(); double fill = Math.min(amount, max - currentWill.getWill(type)); - if (!doFill || fill <= 0) - { + if (!doFill || fill <= 0) { return fill > 0 ? fill : 0; } @@ -143,13 +121,11 @@ public class WorldDemonWillHandler return fill; } - public static double fillWill(World world, BlockPos pos, EnumDemonWillType type, double amount, boolean doFill) - { + public static double fillWill(World world, BlockPos pos, EnumDemonWillType type, double amount, boolean doFill) { WillChunk willChunk = getWillChunk(world, pos); DemonWillHolder currentWill = willChunk.getCurrentWill(); - if (!doFill) - { + if (!doFill) { return amount; } @@ -159,11 +135,9 @@ public class WorldDemonWillHandler return amount; } - public static WillChunk getWillChunk(World world, BlockPos pos) - { + public static WillChunk getWillChunk(World world, BlockPos pos) { WillChunk willChunk = getWillChunk(world.provider.getDimension(), pos.getX() >> 4, pos.getZ() >> 4); - if (willChunk == null) - { + if (willChunk == null) { Chunk chunk = world.getChunkFromBlockCoords(pos); generateWill(chunk); @@ -173,12 +147,10 @@ public class WorldDemonWillHandler return willChunk; } - public static double getCurrentWill(World world, BlockPos pos, EnumDemonWillType type) - { + public static double getCurrentWill(World world, BlockPos pos, EnumDemonWillType type) { WillChunk willChunk = getWillChunk(world, pos); - if (willChunk == null) - { + if (willChunk == null) { return 0; } @@ -186,26 +158,21 @@ public class WorldDemonWillHandler return currentWill.getWill(type); } - private static void markChunkAsDirty(WillChunk chunk, int dim) - { - if (chunk.isModified()) - { + private static void markChunkAsDirty(WillChunk chunk, int dim) { + if (chunk.isModified()) { return; } PosXY pos = new PosXY(chunk.loc.x, chunk.loc.y); - if (!dirtyChunks.containsKey(dim)) - { + if (!dirtyChunks.containsKey(dim)) { dirtyChunks.put(dim, new CopyOnWriteArrayList()); } CopyOnWriteArrayList dc = dirtyChunks.get(dim); - if (!dc.contains(pos)) - { + if (!dc.contains(pos)) { dc.add(pos); } } - public static void generateWill(Chunk chunk) - { + public static void generateWill(Chunk chunk) { addWillChunk(chunk.getWorld().provider.getDimension(), chunk, (short) 1, new DemonWillHolder()); } } diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackRangedBow.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackRangedBow.java index deb2f90c..21416e37 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackRangedBow.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackRangedBow.java @@ -1,25 +1,23 @@ package WayofTime.bloodmagic.entity.ai; +import WayofTime.bloodmagic.entity.mob.EntityDemonBase; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.item.ItemBow; import net.minecraft.util.EnumHand; -import WayofTime.bloodmagic.entity.mob.EntityDemonBase; -public class EntityAIAttackRangedBow extends EntityAIBase -{ +public class EntityAIAttackRangedBow extends EntityAIBase { private final EntityDemonBase entity; private final double moveSpeedAmp; - private int attackCooldown; private final float maxAttackDistance; + private int attackCooldown; private int attackTime = -1; private int seeTime; private boolean strafingClockwise; private boolean strafingBackwards; private int strafingTime = -1; - public EntityAIAttackRangedBow(EntityDemonBase entityDemonBase, double speedAmplifier, int delay, float maxDistance) - { + public EntityAIAttackRangedBow(EntityDemonBase entityDemonBase, double speedAmplifier, int delay, float maxDistance) { this.entity = entityDemonBase; this.moveSpeedAmp = speedAmplifier; this.attackCooldown = delay; @@ -27,45 +25,39 @@ public class EntityAIAttackRangedBow extends EntityAIBase this.setMutexBits(3); } - public void setAttackCooldown(int p_189428_1_) - { + public void setAttackCooldown(int p_189428_1_) { this.attackCooldown = p_189428_1_; } /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { + public boolean shouldExecute() { return this.entity.getAttackTarget() != null && this.isBowInMainhand(); } - protected boolean isBowInMainhand() - { + protected boolean isBowInMainhand() { return this.entity.getHeldItemMainhand().getItem() instanceof ItemBow; } /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { + public boolean continueExecuting() { return (this.shouldExecute() || !this.entity.getNavigator().noPath()) && this.isBowInMainhand(); } /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { super.startExecuting(); } /** * Resets the task */ - public void resetTask() - { + public void resetTask() { super.startExecuting(); this.seeTime = 0; this.attackTime = -1; @@ -75,89 +67,70 @@ public class EntityAIAttackRangedBow extends EntityAIBase /** * Updates the task */ - public void updateTask() - { + public void updateTask() { EntityLivingBase entitylivingbase = this.entity.getAttackTarget(); - if (entitylivingbase != null) - { + if (entitylivingbase != null) { double d0 = this.entity.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ); boolean flag = this.entity.getEntitySenses().canSee(entitylivingbase); boolean flag1 = this.seeTime > 0; - if (flag != flag1) - { + if (flag != flag1) { this.seeTime = 0; } - if (flag) - { + if (flag) { ++this.seeTime; - } else - { + } else { --this.seeTime; } - if (d0 <= (double) this.maxAttackDistance && this.seeTime >= 20) - { + if (d0 <= (double) this.maxAttackDistance && this.seeTime >= 20) { this.entity.getNavigator().clearPathEntity(); ++this.strafingTime; - } else - { + } else { this.entity.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.moveSpeedAmp); this.strafingTime = -1; } - if (this.strafingTime >= 20) - { - if ((double) this.entity.getRNG().nextFloat() < 0.3D) - { + if (this.strafingTime >= 20) { + if ((double) this.entity.getRNG().nextFloat() < 0.3D) { this.strafingClockwise = !this.strafingClockwise; } - if ((double) this.entity.getRNG().nextFloat() < 0.3D) - { + if ((double) this.entity.getRNG().nextFloat() < 0.3D) { this.strafingBackwards = !this.strafingBackwards; } this.strafingTime = 0; } - if (this.strafingTime > -1) - { - if (d0 > (double) (this.maxAttackDistance * 0.75F)) - { + if (this.strafingTime > -1) { + if (d0 > (double) (this.maxAttackDistance * 0.75F)) { this.strafingBackwards = false; - } else if (d0 < (double) (this.maxAttackDistance * 0.25F)) - { + } else if (d0 < (double) (this.maxAttackDistance * 0.25F)) { this.strafingBackwards = true; } this.entity.getMoveHelper().strafe(this.strafingBackwards ? -0.5F : 0.5F, this.strafingClockwise ? 0.5F : -0.5F); this.entity.faceEntity(entitylivingbase, 30.0F, 30.0F); - } else - { + } else { this.entity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F); } - if (this.entity.isHandActive()) - { - if (!flag && this.seeTime < -60) - { + if (this.entity.isHandActive()) { + if (!flag && this.seeTime < -60) { this.entity.resetActiveHand(); - } else if (flag) - { + } else if (flag) { int i = this.entity.getItemInUseMaxCount(); - if (i >= 20) - { + if (i >= 20) { this.entity.resetActiveHand(); this.entity.attackEntityWithRangedAttack(entitylivingbase, ItemBow.getArrowVelocity(i)); this.attackTime = this.attackCooldown; } } - } else if (--this.attackTime <= 0 && this.seeTime >= -60) - { + } else if (--this.attackTime <= 0 && this.seeTime >= -60) { this.entity.setActiveHand(EnumHand.MAIN_HAND); } } diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackStealthMelee.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackStealthMelee.java index 066033ac..0a2df18c 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackStealthMelee.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackStealthMelee.java @@ -1,41 +1,42 @@ package WayofTime.bloodmagic.entity.ai; +import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.pathfinding.Path; import net.minecraft.util.EnumHand; import net.minecraft.world.World; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken; -public class EntityAIAttackStealthMelee extends EntityAIBase -{ +public class EntityAIAttackStealthMelee extends EntityAIBase { + protected final int attackInterval = 20; protected EntityCorruptedChicken chicken; - - World worldObj; /** * An amount of decrementing ticks that allows the entity to attack once the * tick reaches 0. */ protected int attackTick; - /** The speed with which the mob will approach the target */ + World worldObj; + /** + * The speed with which the mob will approach the target + */ double speedTowardsTarget; /** * When true, the mob will continue chasing its target, even if it can't * find a path to them right now. */ boolean longMemory; - /** The PathEntity of our entity. */ + /** + * The PathEntity of our entity. + */ Path entityPathEntity; private int delayCounter; private double targetX; private double targetY; private double targetZ; - protected final int attackInterval = 20; private int failedPathFindingPenalty = 0; private boolean canPenalize = false; - public EntityAIAttackStealthMelee(EntityCorruptedChicken creature, double speedIn, boolean useLongMemory) - { + public EntityAIAttackStealthMelee(EntityCorruptedChicken creature, double speedIn, boolean useLongMemory) { this.chicken = creature; this.worldObj = creature.getEntityWorld(); this.speedTowardsTarget = speedIn; @@ -44,32 +45,24 @@ public class EntityAIAttackStealthMelee extends EntityAIBase } @Override - public boolean shouldExecute() - { - if (chicken.attackStateMachine != 1) - { + public boolean shouldExecute() { + if (chicken.attackStateMachine != 1) { return false; } EntityLivingBase entitylivingbase = this.chicken.getAttackTarget(); - if (entitylivingbase == null) - { + if (entitylivingbase == null) { return false; - } else if (!entitylivingbase.isEntityAlive()) - { + } else if (!entitylivingbase.isEntityAlive()) { return false; - } else - { - if (canPenalize) - { - if (--this.delayCounter <= 0) - { + } else { + if (canPenalize) { + if (--this.delayCounter <= 0) { this.entityPathEntity = this.chicken.getNavigator().getPathToEntityLiving(entitylivingbase); this.delayCounter = 4 + this.chicken.getRNG().nextInt(7); return this.entityPathEntity != null; - } else - { + } else { return true; } } @@ -79,61 +72,50 @@ public class EntityAIAttackStealthMelee extends EntityAIBase } @Override - public boolean shouldContinueExecuting() - { + public boolean shouldContinueExecuting() { return chicken.attackStateMachine == 1 && super.shouldContinueExecuting(); } @Override - public void resetTask() - { - if (chicken.attackStateMachine == 1) - { + public void resetTask() { + if (chicken.attackStateMachine == 1) { chicken.attackStateMachine = 0; } } @Override - public void updateTask() - { + public void updateTask() { EntityLivingBase entitylivingbase = this.chicken.getAttackTarget(); this.chicken.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F); double d0 = this.chicken.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ); --this.delayCounter; - if ((this.longMemory || this.chicken.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.chicken.getRNG().nextFloat() < 0.05F)) - { + if ((this.longMemory || this.chicken.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.chicken.getRNG().nextFloat() < 0.05F)) { this.targetX = entitylivingbase.posX; this.targetY = entitylivingbase.getEntityBoundingBox().minY; this.targetZ = entitylivingbase.posZ; this.delayCounter = 4 + this.chicken.getRNG().nextInt(7); - if (this.canPenalize) - { + if (this.canPenalize) { this.delayCounter += failedPathFindingPenalty; - if (this.chicken.getNavigator().getPath() != null) - { + if (this.chicken.getNavigator().getPath() != null) { net.minecraft.pathfinding.PathPoint finalPathPoint = this.chicken.getNavigator().getPath().getFinalPathPoint(); if (finalPathPoint != null && entitylivingbase.getDistanceSq(finalPathPoint.x, finalPathPoint.y, finalPathPoint.z) < 1) failedPathFindingPenalty = 0; else failedPathFindingPenalty += 10; - } else - { + } else { failedPathFindingPenalty += 10; } } - if (d0 > 1024.0D) - { + if (d0 > 1024.0D) { this.delayCounter += 10; - } else if (d0 > 256.0D) - { + } else if (d0 > 256.0D) { this.delayCounter += 5; } - if (!this.chicken.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget)) - { + if (!this.chicken.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget)) { this.delayCounter += 15; } } @@ -142,12 +124,10 @@ public class EntityAIAttackStealthMelee extends EntityAIBase this.attackEntity(entitylivingbase, d0); } - protected void attackEntity(EntityLivingBase attacked, double distance) - { + protected void attackEntity(EntityLivingBase attacked, double distance) { double d0 = this.getAttackReachSqr(attacked); - if (distance <= d0 && this.attackTick <= 0) - { + if (distance <= d0 && this.attackTick <= 0) { this.attackTick = 20; this.chicken.swingArm(EnumHand.MAIN_HAND); this.chicken.attackEntityAsMob(attacked); @@ -156,8 +136,7 @@ public class EntityAIAttackStealthMelee extends EntityAIBase } } - protected double getAttackReachSqr(EntityLivingBase attackTarget) - { + protected double getAttackReachSqr(EntityLivingBase attackTarget) { return (double) (this.chicken.width * 2.0F * this.chicken.width * 2.0F + attackTarget.width); } } diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIEatAndCorruptBlock.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIEatAndCorruptBlock.java index 288fc685..44337f13 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIEatAndCorruptBlock.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIEatAndCorruptBlock.java @@ -1,24 +1,28 @@ package WayofTime.bloodmagic.entity.ai; +import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase; +import WayofTime.bloodmagic.inversion.CorruptionHandler; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase; -import WayofTime.bloodmagic.inversion.CorruptionHandler; -public class EntityAIEatAndCorruptBlock extends EntityAIBase -{ - /** The entity owner of this AITask */ +public class EntityAIEatAndCorruptBlock extends EntityAIBase { + /** + * The entity owner of this AITask + */ private final EntityAspectedDemonBase grassEaterEntity; - /** The world the grass eater entity is eating from */ + /** + * The world the grass eater entity is eating from + */ private final World world; - /** Number of ticks since the entity started to eat grass */ + /** + * Number of ticks since the entity started to eat grass + */ int eatingGrassTimer; - public EntityAIEatAndCorruptBlock(EntityAspectedDemonBase entity) - { + public EntityAIEatAndCorruptBlock(EntityAspectedDemonBase entity) { this.grassEaterEntity = entity; this.world = entity.getEntityWorld(); this.setMutexBits(7); @@ -27,13 +31,10 @@ public class EntityAIEatAndCorruptBlock extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { - if (this.grassEaterEntity.getRNG().nextInt(50) != 0) - { + public boolean shouldExecute() { + if (this.grassEaterEntity.getRNG().nextInt(50) != 0) { return false; - } else - { + } else { BlockPos pos = new BlockPos(this.grassEaterEntity.posX, this.grassEaterEntity.posY, this.grassEaterEntity.posZ).down(); IBlockState offsetState = world.getBlockState(pos); Block offsetBlock = offsetState.getBlock(); @@ -44,8 +45,7 @@ public class EntityAIEatAndCorruptBlock extends EntityAIBase /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { this.eatingGrassTimer = 40; this.world.setEntityState(this.grassEaterEntity, (byte) 10); this.grassEaterEntity.getNavigator().clearPathEntity(); @@ -54,44 +54,38 @@ public class EntityAIEatAndCorruptBlock extends EntityAIBase /** * Resets the task */ - public void resetTask() - { + public void resetTask() { this.eatingGrassTimer = 0; } /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { + public boolean continueExecuting() { return this.eatingGrassTimer > 0; } /** * Number of ticks since the entity started to eat grass */ - public int getEatingGrassTimer() - { + public int getEatingGrassTimer() { return this.eatingGrassTimer; } /** * Updates the task */ - public void updateTask() - { + public void updateTask() { this.eatingGrassTimer = Math.max(0, this.eatingGrassTimer - 1); - if (this.eatingGrassTimer == 4) - { + if (this.eatingGrassTimer == 4) { BlockPos blockpos = new BlockPos(this.grassEaterEntity.posX, this.grassEaterEntity.posY, this.grassEaterEntity.posZ); BlockPos offsetPos = blockpos.down(); IBlockState offsetState = world.getBlockState(offsetPos); Block offsetBlock = offsetState.getBlock(); - if (CorruptionHandler.isBlockCorruptible(world, grassEaterEntity.getType(), offsetPos, offsetState, offsetBlock)) - { + if (CorruptionHandler.isBlockCorruptible(world, grassEaterEntity.getType(), offsetPos, offsetState, offsetBlock)) { // if (this.world.getGameRules().getBoolean("mobGriefing")) { this.world.playEvent(2001, offsetPos, Block.getIdFromBlock(offsetBlock)); diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIFollowOwner.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIFollowOwner.java index 92e7bebb..73d08ea2 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIFollowOwner.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIFollowOwner.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.entity.ai; +import WayofTime.bloodmagic.entity.mob.EntityDemonBase; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; @@ -12,22 +13,19 @@ import net.minecraft.pathfinding.PathNodeType; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; -import WayofTime.bloodmagic.entity.mob.EntityDemonBase; -public class EntityAIFollowOwner extends EntityAIBase -{ +public class EntityAIFollowOwner extends EntityAIBase { + World theWorld; + float maxDist; + float minDist; private EntityDemonBase thePet; private EntityLivingBase theOwner; - World theWorld; private double followSpeed; private PathNavigate petPathfinder; private int timeToRecalcPath; - float maxDist; - float minDist; private float oldWaterCost; - public EntityAIFollowOwner(EntityDemonBase thePetIn, double followSpeedIn, float minDistIn, float maxDistIn) - { + public EntityAIFollowOwner(EntityDemonBase thePetIn, double followSpeedIn, float minDistIn, float maxDistIn) { this.thePet = thePetIn; this.theWorld = thePetIn.getEntityWorld(); this.followSpeed = followSpeedIn; @@ -36,8 +34,7 @@ public class EntityAIFollowOwner extends EntityAIBase this.maxDist = maxDistIn; this.setMutexBits(3); - if (!(thePetIn.getNavigator() instanceof PathNavigateGround)) - { + if (!(thePetIn.getNavigator() instanceof PathNavigateGround)) { throw new IllegalArgumentException("Unsupported mob type for FollowOwnerGoal"); } } @@ -45,24 +42,18 @@ public class EntityAIFollowOwner extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { + public boolean shouldExecute() { EntityLivingBase entitylivingbase = this.thePet.getOwner(); - if (entitylivingbase == null) - { + if (entitylivingbase == null) { return false; - } else if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer) entitylivingbase).isSpectator()) - { + } else if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer) entitylivingbase).isSpectator()) { return false; - } else if (this.thePet.isStationary()) - { + } else if (this.thePet.isStationary()) { return false; - } else if (this.thePet.getDistanceSqToEntity(entitylivingbase) < (double) (this.minDist * this.minDist)) - { + } else if (this.thePet.getDistanceSqToEntity(entitylivingbase) < (double) (this.minDist * this.minDist)) { return false; - } else - { + } else { this.theOwner = entitylivingbase; return true; } @@ -71,16 +62,14 @@ public class EntityAIFollowOwner extends EntityAIBase /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { + public boolean continueExecuting() { return !this.petPathfinder.noPath() && this.thePet.getDistanceSqToEntity(this.theOwner) > (double) (this.maxDist * this.maxDist) && !this.thePet.isStationary(); } /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { this.timeToRecalcPath = 0; this.oldWaterCost = this.thePet.getPathPriority(PathNodeType.WATER); this.thePet.setPathPriority(PathNodeType.WATER, 0.0F); @@ -89,15 +78,13 @@ public class EntityAIFollowOwner extends EntityAIBase /** * Resets the task */ - public void resetTask() - { + public void resetTask() { this.theOwner = null; this.petPathfinder.clearPathEntity(); this.thePet.setPathPriority(PathNodeType.WATER, this.oldWaterCost); } - private boolean isEmptyBlock(BlockPos pos) - { + private boolean isEmptyBlock(BlockPos pos) { IBlockState iblockstate = this.theWorld.getBlockState(pos); Block block = iblockstate.getBlock(); return block == Blocks.AIR || !iblockstate.isFullCube(); @@ -106,32 +93,23 @@ public class EntityAIFollowOwner extends EntityAIBase /** * Updates the task */ - public void updateTask() - { + public void updateTask() { this.thePet.getLookHelper().setLookPositionWithEntity(this.theOwner, 10.0F, (float) this.thePet.getVerticalFaceSpeed()); - if (!this.thePet.isStationary()) - { - if (--this.timeToRecalcPath <= 0) - { + if (!this.thePet.isStationary()) { + if (--this.timeToRecalcPath <= 0) { this.timeToRecalcPath = 10; - if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.followSpeed)) - { - if (!this.thePet.getLeashed()) - { - if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D) - { + if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.followSpeed)) { + if (!this.thePet.getLeashed()) { + if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D) { 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) - { - for (int i1 = 0; i1 <= 4; ++i1) - { - if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.theWorld.getBlockState(new BlockPos(i + l, k - 1, j + i1)).isTopSolid() && this.isEmptyBlock(new BlockPos(i + l, k, j + i1)) && this.isEmptyBlock(new BlockPos(i + l, k + 1, j + i1))) - { + for (int l = 0; l <= 4; ++l) { + for (int i1 = 0; i1 <= 4; ++i1) { + if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.theWorld.getBlockState(new BlockPos(i + l, k - 1, j + i1)).isTopSolid() && this.isEmptyBlock(new BlockPos(i + l, k, j + i1)) && this.isEmptyBlock(new BlockPos(i + l, k + 1, j + i1))) { this.thePet.setLocationAndAngles((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.thePet.rotationYaw, this.thePet.rotationPitch); this.petPathfinder.clearPathEntity(); return; diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIGrabEffectsFromOwner.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIGrabEffectsFromOwner.java index 364506fc..3ff28996 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIGrabEffectsFromOwner.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIGrabEffectsFromOwner.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.entity.ai; +import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; @@ -12,25 +13,22 @@ import net.minecraft.pathfinding.PathNodeType; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; -import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; -public class EntityAIGrabEffectsFromOwner extends EntityAIBase -{ +public class EntityAIGrabEffectsFromOwner extends EntityAIBase { + World theWorld; + float minDist; private EntitySentientSpecter thePet; private EntityLivingBase theOwner; - World theWorld; private double followSpeed; private PathNavigate petPathfinder; private int timeToRecalcPath; - float minDist; private float oldWaterCost; /** * In order to steal effects from the owner, the mob has to be close to the * owner. */ - public EntityAIGrabEffectsFromOwner(EntitySentientSpecter thePetIn, double followSpeedIn, float minDistIn) - { + public EntityAIGrabEffectsFromOwner(EntitySentientSpecter thePetIn, double followSpeedIn, float minDistIn) { this.thePet = thePetIn; this.theWorld = thePetIn.getEntityWorld(); this.followSpeed = followSpeedIn; @@ -38,8 +36,7 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase this.minDist = minDistIn; this.setMutexBits(3); - if (!(thePetIn.getNavigator() instanceof PathNavigateGround)) - { + if (!(thePetIn.getNavigator() instanceof PathNavigateGround)) { throw new IllegalArgumentException("Unsupported mob type for FollowOwnerGoal"); } } @@ -47,27 +44,21 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { + public boolean shouldExecute() { EntityLivingBase entitylivingbase = this.thePet.getOwner(); - if (entitylivingbase == null) - { + if (entitylivingbase == null) { return false; - } else if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer) entitylivingbase).isSpectator()) - { + } else if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer) entitylivingbase).isSpectator()) { return false; - } else if (this.thePet.isStationary()) - { + } else if (this.thePet.isStationary()) { return false; // } else if (this.thePet.getDistanceSqToEntity(entitylivingbase) < (double) (this.minDist * this.minDist)) // { // return false; - } else if (!this.thePet.canStealEffectFromOwner(entitylivingbase)) - { + } else if (!this.thePet.canStealEffectFromOwner(entitylivingbase)) { return false; - } else - { + } else { this.theOwner = entitylivingbase; return true; } @@ -76,16 +67,14 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { + public boolean continueExecuting() { return this.thePet.canStealEffectFromOwner(theOwner);// || !this.petPathfinder.noPath() && this.thePet.getDistanceSqToEntity(this.theOwner) > (double) (this.minDist * this.minDist) && !this.thePet.isStationary(); } /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { this.timeToRecalcPath = 0; this.oldWaterCost = this.thePet.getPathPriority(PathNodeType.WATER); this.thePet.setPathPriority(PathNodeType.WATER, 0.0F); @@ -94,15 +83,13 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase /** * Resets the task */ - public void resetTask() - { + public void resetTask() { this.theOwner = null; this.petPathfinder.clearPathEntity(); this.thePet.setPathPriority(PathNodeType.WATER, this.oldWaterCost); } - private boolean isEmptyBlock(BlockPos pos) - { + private boolean isEmptyBlock(BlockPos pos) { IBlockState iblockstate = this.theWorld.getBlockState(pos); Block block = iblockstate.getBlock(); return block == Blocks.AIR || !iblockstate.isFullCube(); @@ -111,40 +98,29 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase /** * Updates the task */ - public void updateTask() - { + public void updateTask() { this.thePet.getLookHelper().setLookPositionWithEntity(this.theOwner, 10.0F, (float) this.thePet.getVerticalFaceSpeed()); - if (this.thePet.getDistanceSqToEntity(theOwner) < this.minDist * this.minDist) - { - if (this.thePet.stealEffectsFromOwner(theOwner)) - { + if (this.thePet.getDistanceSqToEntity(theOwner) < this.minDist * this.minDist) { + if (this.thePet.stealEffectsFromOwner(theOwner)) { return; } } - if (!this.thePet.isStationary()) - { - if (--this.timeToRecalcPath <= 0) - { + if (!this.thePet.isStationary()) { + if (--this.timeToRecalcPath <= 0) { this.timeToRecalcPath = 10; - if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.followSpeed)) - { - if (!this.thePet.getLeashed()) - { - if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D) - { + if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.followSpeed)) { + if (!this.thePet.getLeashed()) { + if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D) { 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) - { - for (int i1 = 0; i1 <= 4; ++i1) - { - if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.theWorld.getBlockState(new BlockPos(i + l, k - 1, j + i1)).isTopSolid() && this.isEmptyBlock(new BlockPos(i + l, k, j + i1)) && this.isEmptyBlock(new BlockPos(i + l, k + 1, j + i1))) - { + for (int l = 0; l <= 4; ++l) { + for (int i1 = 0; i1 <= 4; ++i1) { + if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.theWorld.getBlockState(new BlockPos(i + l, k - 1, j + i1)).isTopSolid() && this.isEmptyBlock(new BlockPos(i + l, k, j + i1)) && this.isEmptyBlock(new BlockPos(i + l, k + 1, j + i1))) { this.thePet.setLocationAndAngles((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.thePet.rotationYaw, this.thePet.rotationPitch); this.petPathfinder.clearPathEntity(); return; diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIHurtByTargetIgnoreTamed.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIHurtByTargetIgnoreTamed.java index 061d0bf9..371ed1be 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIHurtByTargetIgnoreTamed.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIHurtByTargetIgnoreTamed.java @@ -1,28 +1,23 @@ package WayofTime.bloodmagic.entity.ai; -import java.util.UUID; - import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IEntityOwnable; import net.minecraft.entity.ai.EntityAIHurtByTarget; -public class EntityAIHurtByTargetIgnoreTamed extends EntityAIHurtByTarget -{ - public EntityAIHurtByTargetIgnoreTamed(EntityCreature creatureIn, boolean entityCallsForHelpIn, Class... targetClassesIn) - { +import java.util.UUID; + +public class EntityAIHurtByTargetIgnoreTamed extends EntityAIHurtByTarget { + public EntityAIHurtByTargetIgnoreTamed(EntityCreature creatureIn, boolean entityCallsForHelpIn, Class... targetClassesIn) { super(creatureIn, true, targetClassesIn); } @Override - public boolean isSuitableTarget(EntityLivingBase target, boolean includeInvincibles) - { - if (this.taskOwner instanceof IEntityOwnable && target instanceof IEntityOwnable) - { + public boolean isSuitableTarget(EntityLivingBase target, boolean includeInvincibles) { + if (this.taskOwner instanceof IEntityOwnable && target instanceof IEntityOwnable) { UUID thisId = ((IEntityOwnable) this.taskOwner).getOwnerId(); UUID targetId = ((IEntityOwnable) target).getOwnerId(); - if (thisId != null && targetId != null && thisId.equals(targetId)) - { + if (thisId != null && targetId != null && thisId.equals(targetId)) { return false; } } diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIMimicReform.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIMimicReform.java index b7e63c30..cf35ee3b 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIMimicReform.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIMimicReform.java @@ -1,31 +1,26 @@ package WayofTime.bloodmagic.entity.ai; +import WayofTime.bloodmagic.entity.mob.EntityMimic; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.util.math.BlockPos; -import WayofTime.bloodmagic.entity.mob.EntityMimic; -public class EntityAIMimicReform extends EntityAIBase -{ +public class EntityAIMimicReform extends EntityAIBase { private final EntityMimic theEntity; - public EntityAIMimicReform(EntityMimic creatureIn) - { + public EntityAIMimicReform(EntityMimic creatureIn) { this.theEntity = creatureIn; this.setMutexBits(2); } @Override - public boolean shouldExecute() - { + public boolean shouldExecute() { return this.theEntity.ticksExisted > 100 && this.theEntity.hasHome() && this.theEntity.isWithinHomeDistanceCurrentPosition(); } @Override - public void startExecuting() - { + public void startExecuting() { BlockPos homePos = this.theEntity.getHomePosition(); - if (theEntity.reformIntoMimicBlock(homePos)) - { + if (theEntity.reformIntoMimicBlock(homePos)) { this.theEntity.setDead(); } } diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIOwnerHurtByTarget.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIOwnerHurtByTarget.java index 37213741..42bfb5fa 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIOwnerHurtByTarget.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIOwnerHurtByTarget.java @@ -1,17 +1,15 @@ package WayofTime.bloodmagic.entity.ai; +import WayofTime.bloodmagic.entity.mob.EntityDemonBase; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAITarget; -import WayofTime.bloodmagic.entity.mob.EntityDemonBase; -public class EntityAIOwnerHurtByTarget extends EntityAITarget -{ +public class EntityAIOwnerHurtByTarget extends EntityAITarget { EntityDemonBase theDefendingTameable; EntityLivingBase theOwnerAttacker; private int timestamp; - public EntityAIOwnerHurtByTarget(EntityDemonBase theDefendingTameableIn) - { + public EntityAIOwnerHurtByTarget(EntityDemonBase theDefendingTameableIn) { super(theDefendingTameableIn, false); this.theDefendingTameable = theDefendingTameableIn; this.setMutexBits(1); @@ -20,20 +18,15 @@ public class EntityAIOwnerHurtByTarget extends EntityAITarget /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { - if (!this.theDefendingTameable.isTamed()) - { + public boolean shouldExecute() { + if (!this.theDefendingTameable.isTamed()) { return false; - } else - { + } else { EntityLivingBase owner = this.theDefendingTameable.getOwner(); - if (owner == null) - { + if (owner == null) { return false; - } else - { + } else { this.theOwnerAttacker = owner.getRevengeTarget(); int i = owner.getRevengeTimer(); return i != this.timestamp && this.isSuitableTarget(this.theOwnerAttacker, false) && this.theDefendingTameable.shouldAttackEntity(this.theOwnerAttacker, owner); @@ -44,13 +37,11 @@ public class EntityAIOwnerHurtByTarget extends EntityAITarget /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { this.taskOwner.setAttackTarget(this.theOwnerAttacker); EntityLivingBase owner = this.theDefendingTameable.getOwner(); - if (owner != null) - { + if (owner != null) { this.timestamp = owner.getRevengeTimer(); } diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIOwnerHurtTarget.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIOwnerHurtTarget.java index 70980372..20ee7204 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIOwnerHurtTarget.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIOwnerHurtTarget.java @@ -1,17 +1,15 @@ package WayofTime.bloodmagic.entity.ai; +import WayofTime.bloodmagic.entity.mob.EntityDemonBase; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAITarget; -import WayofTime.bloodmagic.entity.mob.EntityDemonBase; -public class EntityAIOwnerHurtTarget extends EntityAITarget -{ +public class EntityAIOwnerHurtTarget extends EntityAITarget { EntityDemonBase theEntityDemonBase; EntityLivingBase theTarget; private int timestamp; - public EntityAIOwnerHurtTarget(EntityDemonBase theEntityDemonBaseIn) - { + public EntityAIOwnerHurtTarget(EntityDemonBase theEntityDemonBaseIn) { super(theEntityDemonBaseIn, false); this.theEntityDemonBase = theEntityDemonBaseIn; this.setMutexBits(1); @@ -20,20 +18,15 @@ public class EntityAIOwnerHurtTarget extends EntityAITarget /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { - if (!this.theEntityDemonBase.isTamed()) - { + public boolean shouldExecute() { + if (!this.theEntityDemonBase.isTamed()) { return false; - } else - { + } else { EntityLivingBase entitylivingbase = this.theEntityDemonBase.getOwner(); - if (entitylivingbase == null) - { + if (entitylivingbase == null) { return false; - } else - { + } else { this.theTarget = entitylivingbase.getLastAttackedEntity(); int i = entitylivingbase.getLastAttackedEntityTime(); return i != this.timestamp && this.isSuitableTarget(this.theTarget, false) && this.theEntityDemonBase.shouldAttackEntity(this.theTarget, entitylivingbase); @@ -44,13 +37,11 @@ public class EntityAIOwnerHurtTarget extends EntityAITarget /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { this.taskOwner.setAttackTarget(this.theTarget); EntityLivingBase entitylivingbase = this.theEntityDemonBase.getOwner(); - if (entitylivingbase != null) - { + if (entitylivingbase != null) { this.timestamp = entitylivingbase.getLastAttackedEntityTime(); } diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIPickUpAlly.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIPickUpAlly.java index 427f4ae3..b7e370b4 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIPickUpAlly.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIPickUpAlly.java @@ -1,44 +1,46 @@ package WayofTime.bloodmagic.entity.ai; -import java.util.List; - +import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.pathfinding.Path; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.World; -import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase; -public class EntityAIPickUpAlly extends EntityAIBase -{ - World worldObj; +import java.util.List; + +public class EntityAIPickUpAlly extends EntityAIBase { + protected final int attackInterval = 20; protected EntityAspectedDemonBase entity; /** * An amount of decrementing ticks that allows the entity to attack once the * tick reaches 0. */ protected int attackTick; - /** The speed with which the mob will approach the target */ + World worldObj; + /** + * The speed with which the mob will approach the target + */ double speedTowardsTarget; /** * When true, the mob will continue chasing its target, even if it can't * find a path to them right now. */ boolean longMemory; - /** The PathEntity of our entity. */ + /** + * The PathEntity of our entity. + */ Path entityPathEntity; private int delayCounter; private double targetX; private double targetY; private double targetZ; - protected final int attackInterval = 20; private int failedPathFindingPenalty = 0; private boolean canPenalize = false; private EntityLivingBase pickupTarget = null; - public EntityAIPickUpAlly(EntityAspectedDemonBase creature, double speedIn, boolean useLongMemory) - { + public EntityAIPickUpAlly(EntityAspectedDemonBase creature, double speedIn, boolean useLongMemory) { this.entity = creature; this.worldObj = creature.getEntityWorld(); this.speedTowardsTarget = speedIn; @@ -49,22 +51,17 @@ public class EntityAIPickUpAlly extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { - if (this.entity.getRidingEntity() != null) - { + public boolean shouldExecute() { + if (this.entity.getRidingEntity() != null) { return false; } 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).grow(5); List list = this.entity.getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, bb, new EntityAspectedDemonBase.WillTypePredicate(entity.getType())); - for (EntityLivingBase testEntity : list) - { - if (testEntity != this.entity) - { + for (EntityLivingBase testEntity : list) { + if (testEntity != this.entity) { Path path = this.entity.getNavigator().getPathToEntityLiving(testEntity); - if (path != null) - { + if (path != null) { this.entityPathEntity = path; this.pickupTarget = testEntity; return true; @@ -78,16 +75,14 @@ public class EntityAIPickUpAlly extends EntityAIBase /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { + public boolean continueExecuting() { return this.entity.getRidingEntity() != null; } /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { this.entity.getNavigator().setPath(this.entityPathEntity, this.speedTowardsTarget); this.delayCounter = 0; } @@ -95,8 +90,7 @@ public class EntityAIPickUpAlly extends EntityAIBase /** * Resets the task */ - public void resetTask() - { + public void resetTask() { this.entity.getNavigator().clearPathEntity(); this.pickupTarget = null; } @@ -104,46 +98,38 @@ public class EntityAIPickUpAlly extends EntityAIBase /** * Updates the task */ - public void updateTask() - { + public void updateTask() { EntityLivingBase entitylivingbase = this.pickupTarget; this.entity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F); double d0 = this.entity.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ); --this.delayCounter; - if ((this.longMemory || this.entity.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.entity.getRNG().nextFloat() < 0.05F)) - { + if ((this.longMemory || this.entity.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.entity.getRNG().nextFloat() < 0.05F)) { this.targetX = entitylivingbase.posX; this.targetY = entitylivingbase.getEntityBoundingBox().minY; this.targetZ = entitylivingbase.posZ; this.delayCounter = 4 + this.entity.getRNG().nextInt(7); - if (this.canPenalize) - { + if (this.canPenalize) { this.delayCounter += failedPathFindingPenalty; - if (this.entity.getNavigator().getPath() != null) - { + if (this.entity.getNavigator().getPath() != null) { net.minecraft.pathfinding.PathPoint finalPathPoint = this.entity.getNavigator().getPath().getFinalPathPoint(); if (finalPathPoint != null && entitylivingbase.getDistanceSq(finalPathPoint.x, finalPathPoint.y, finalPathPoint.z) < 1) failedPathFindingPenalty = 0; else failedPathFindingPenalty += 10; - } else - { + } else { failedPathFindingPenalty += 10; } } - if (d0 > 1024.0D) - { + if (d0 > 1024.0D) { this.delayCounter += 10; - } else if (d0 > 256.0D) - { + } else if (d0 > 256.0D) { this.delayCounter += 5; } - if (!this.entity.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget)) - { + if (!this.entity.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget)) { this.delayCounter += 15; } } @@ -152,19 +138,16 @@ public class EntityAIPickUpAlly extends EntityAIBase this.pickUpEntity(entitylivingbase, d0); } - protected void pickUpEntity(EntityLivingBase potentialPickup, double distance) - { + protected void pickUpEntity(EntityLivingBase potentialPickup, double distance) { double d0 = this.getAttackReachSqr(potentialPickup); - if (distance <= d0 && this.attackTick <= 0 && !potentialPickup.isRiding()) - { + if (distance <= d0 && this.attackTick <= 0 && !potentialPickup.isRiding()) { System.out.println("Hai!"); potentialPickup.startRiding(this.entity, true); } } - protected double getAttackReachSqr(EntityLivingBase attackTarget) - { + protected double getAttackReachSqr(EntityLivingBase attackTarget) { return (double) (this.entity.width * 2.0F * this.entity.width * 2.0F + attackTarget.width); } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIProtectAlly.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIProtectAlly.java index 93e64955..b4012277 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIProtectAlly.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIProtectAlly.java @@ -1,32 +1,35 @@ package WayofTime.bloodmagic.entity.ai; -import java.util.List; - +import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase; +import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.World; -import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; -public class EntityAIProtectAlly extends EntityAIBase -{ - /** The entity owner of this AITask */ +import java.util.List; + +public class EntityAIProtectAlly extends EntityAIBase { + /** + * The entity owner of this AITask + */ private final EntityCorruptedSheep entity; - /** The world the grass eater entity is eating from */ + /** + * The world the grass eater entity is eating from + */ private final World world; - /** Number of ticks since the entity started to eat grass */ + /** + * Number of ticks since the entity started to eat grass + */ int castTimer; - public EntityAIProtectAlly(EntityCorruptedSheep entity) - { + public EntityAIProtectAlly(EntityCorruptedSheep entity) { this.entity = entity; this.world = entity.getEntityWorld(); this.setMutexBits(7); } - public int getCastTimer() - { + public int getCastTimer() { return this.castTimer; } @@ -34,16 +37,12 @@ public class EntityAIProtectAlly extends EntityAIBase * Returns whether the EntityAIBase should begin execution. */ @Override - public boolean shouldExecute() - { + public boolean shouldExecute() { 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).grow(5); List list = world.getEntitiesWithinAABB(EntityLivingBase.class, bb, new EntityAspectedDemonBase.WillTypePredicate(entity.getType())); - for (EntityLivingBase testEntity : list) - { - if (testEntity != this.entity) - { - if (this.entity.canProtectAlly(testEntity)) - { + for (EntityLivingBase testEntity : list) { + if (testEntity != this.entity) { + if (this.entity.canProtectAlly(testEntity)) { return true; } } @@ -56,8 +55,7 @@ public class EntityAIProtectAlly extends EntityAIBase * Execute a one shot task or start executing a continuous task */ @Override - public void startExecuting() - { + public void startExecuting() { this.castTimer = 100; this.world.setEntityState(this.entity, (byte) 53); this.entity.getNavigator().clearPathEntity(); @@ -67,8 +65,7 @@ public class EntityAIProtectAlly extends EntityAIBase * Resets the task */ @Override - public void resetTask() - { + public void resetTask() { this.castTimer = 0; } @@ -76,8 +73,7 @@ public class EntityAIProtectAlly extends EntityAIBase * Returns whether an in-progress EntityAIBase should continue executing */ @Override - public boolean shouldContinueExecuting() - { + public boolean shouldContinueExecuting() { return castTimer > 0; } @@ -85,19 +81,14 @@ public class EntityAIProtectAlly extends EntityAIBase * Updates the task */ @Override - public void updateTask() - { + public void updateTask() { this.castTimer = Math.max(0, this.castTimer - 1); - if (castTimer == 0) - { + if (castTimer == 0) { 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).grow(5); List list = world.getEntitiesWithinAABB(EntityLivingBase.class, bb, new EntityAspectedDemonBase.WillTypePredicate(entity.getType())); - for (EntityLivingBase testEntity : list) - { - if (testEntity != this.entity) - { - if (this.entity.applyProtectionToAlly(testEntity)) - { + for (EntityLivingBase testEntity : list) { + if (testEntity != this.entity) { + if (this.entity.applyProtectionToAlly(testEntity)) { return; } } diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIRetreatToHeal.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIRetreatToHeal.java index 69b30960..f077ac20 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIRetreatToHeal.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIRetreatToHeal.java @@ -1,9 +1,8 @@ package WayofTime.bloodmagic.entity.ai; -import java.util.List; - -import javax.annotation.Nullable; - +import WayofTime.bloodmagic.entity.mob.EntityDemonBase; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import net.minecraft.entity.Entity; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.RandomPositionGenerator; @@ -11,35 +10,36 @@ import net.minecraft.pathfinding.Path; import net.minecraft.pathfinding.PathNavigate; import net.minecraft.util.EntitySelectors; import net.minecraft.util.math.Vec3d; -import WayofTime.bloodmagic.entity.mob.EntityDemonBase; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; +import java.util.List; -public class EntityAIRetreatToHeal extends EntityAIBase -{ +public class EntityAIRetreatToHeal extends EntityAIBase { private final Predicate canBeSeenSelector; - /** The entity we are attached to */ + /** + * The entity we are attached to + */ protected EntityDemonBase theEntity; + protected T closestLivingEntity; private double farSpeed; private double nearSpeed; private double safeHealDistance = 3; - protected T closestLivingEntity; private float avoidDistance; - /** The PathEntity of our entity */ + /** + * The PathEntity of our entity + */ private Path entityPathEntity; - /** The PathNavigate of our entity */ + /** + * The PathNavigate of our entity + */ private PathNavigate entityPathNavigate; private Class classToAvoid; private Predicate avoidTargetSelector; - public EntityAIRetreatToHeal(EntityDemonBase theEntityIn, Class classToAvoidIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn) - { + public EntityAIRetreatToHeal(EntityDemonBase theEntityIn, Class classToAvoidIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn) { this(theEntityIn, classToAvoidIn, Predicates.alwaysTrue(), avoidDistanceIn, farSpeedIn, nearSpeedIn); } - public EntityAIRetreatToHeal(EntityDemonBase theEntityIn, Class classToAvoidIn, Predicate avoidTargetSelectorIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn) - { + public EntityAIRetreatToHeal(EntityDemonBase theEntityIn, Class classToAvoidIn, Predicate avoidTargetSelectorIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn) { this.canBeSeenSelector = p_apply_1_ -> p_apply_1_.isEntityAlive() && EntityAIRetreatToHeal.this.theEntity.getEntitySenses().canSee(p_apply_1_); this.theEntity = theEntityIn; this.classToAvoid = classToAvoidIn; @@ -55,32 +55,25 @@ public class EntityAIRetreatToHeal extends EntityAIBase * Returns whether the EntityAIBase should begin execution. */ @Override - public boolean shouldExecute() - { - if (!this.theEntity.shouldEmergencyHeal()) - { + public boolean shouldExecute() { + if (!this.theEntity.shouldEmergencyHeal()) { return false; } //This part almost doesn't matter List list = this.theEntity.getEntityWorld().getEntitiesWithinAABB(this.classToAvoid, this.theEntity.getEntityBoundingBox().expand((double) this.avoidDistance, 3.0D, (double) this.avoidDistance), Predicates.and(EntitySelectors.CAN_AI_TARGET, this.canBeSeenSelector, this.avoidTargetSelector)); - if (list.isEmpty()) - { + if (list.isEmpty()) { return true; //No entities nearby, so I can freely heal - } else - { + } else { this.closestLivingEntity = list.get(0); Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.theEntity, 16, 7, new Vec3d(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ)); - if (vec3d == null) - { + if (vec3d == null) { return false; //Nowhere to run, gotta fight! - } else if (this.closestLivingEntity.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity)) - { + } else if (this.closestLivingEntity.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity)) { return false; //I'll be headed off if I choose this direction. - } else - { + } else { this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3d.x, vec3d.y, vec3d.z); return this.entityPathEntity != null; } @@ -91,8 +84,7 @@ public class EntityAIRetreatToHeal extends EntityAIBase * Returns whether an in-progress EntityAIBase should continue executing */ @Override - public boolean shouldContinueExecuting() - { + public boolean shouldContinueExecuting() { return this.theEntity.shouldEmergencyHeal();//!this.entityPathNavigate.noPath(); } @@ -100,10 +92,8 @@ public class EntityAIRetreatToHeal extends EntityAIBase * Execute a one shot task or start executing a continuous task */ @Override - public void startExecuting() - { - if (this.entityPathEntity != null) - { + public void startExecuting() { + if (this.entityPathEntity != null) { this.entityPathNavigate.setPath(this.entityPathEntity, this.farSpeed); } } @@ -112,8 +102,7 @@ public class EntityAIRetreatToHeal extends EntityAIBase * Resets the task */ @Override - public void resetTask() - { + public void resetTask() { this.closestLivingEntity = null; } @@ -121,33 +110,26 @@ public class EntityAIRetreatToHeal extends EntityAIBase * Updates the task */ @Override - public void updateTask() - { - if (this.closestLivingEntity != null) - { - if (this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) < 49.0D) - { + public void updateTask() { + if (this.closestLivingEntity != null) { + if (this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) < 49.0D) { this.theEntity.getNavigator().setSpeed(this.nearSpeed); - } else - { + } else { this.theEntity.getNavigator().setSpeed(this.farSpeed); } - if (this.theEntity.ticksExisted % 20 == 0 && this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) >= safeHealDistance * safeHealDistance) - { + if (this.theEntity.ticksExisted % 20 == 0 && this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) >= safeHealDistance * safeHealDistance) { healEntity(); return; } } - if (this.theEntity.ticksExisted % 20 == 0) - { + if (this.theEntity.ticksExisted % 20 == 0) { healEntity(); } } - public void healEntity() - { + public void healEntity() { this.theEntity.performEmergencyHeal(2); } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIStealthRetreat.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIStealthRetreat.java index 5f8b5e33..bf7e5540 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIStealthRetreat.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIStealthRetreat.java @@ -1,29 +1,32 @@ package WayofTime.bloodmagic.entity.ai; +import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.RandomPositionGenerator; import net.minecraft.pathfinding.Path; import net.minecraft.pathfinding.PathNavigate; import net.minecraft.util.math.Vec3d; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken; -public class EntityAIStealthRetreat extends EntityAIBase -{ - /** The entity we are attached to */ - protected EntityCorruptedChicken entity; +public class EntityAIStealthRetreat extends EntityAIBase { private final double farSpeed; private final double nearSpeed; private final float avoidDistance; - /** The PathEntity of our entity */ - private Path entityPathEntity; - /** The PathNavigate of our entity */ + /** + * The PathNavigate of our entity + */ private final PathNavigate entityPathNavigate; - + /** + * The entity we are attached to + */ + protected EntityCorruptedChicken entity; + /** + * The PathEntity of our entity + */ + private Path entityPathEntity; private int ticksLeft = 0; - public EntityAIStealthRetreat(EntityCorruptedChicken theEntityIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn) - { + public EntityAIStealthRetreat(EntityCorruptedChicken theEntityIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn) { this.entity = theEntityIn; this.avoidDistance = avoidDistanceIn; this.farSpeed = farSpeedIn; @@ -33,26 +36,20 @@ public class EntityAIStealthRetreat extends EntityAIBase } @Override - public boolean shouldExecute() - { - if (this.entity.attackStateMachine == 2) - { + public boolean shouldExecute() { + if (this.entity.attackStateMachine == 2) { EntityLivingBase attacked = this.entity.getAttackTarget(); - if (attacked == null) - { + if (attacked == null) { return false; } Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.entity, 16, 7, new Vec3d(attacked.posX, attacked.posY, attacked.posZ)); - if (vec3d == null) - { + if (vec3d == null) { return false; - } else if (attacked.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) < attacked.getDistanceSqToEntity(this.entity)) - { + } else if (attacked.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) < attacked.getDistanceSqToEntity(this.entity)) { return false; - } else - { + } else { this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3d.x, vec3d.y, vec3d.z); return this.entityPathEntity != null; } @@ -62,10 +59,8 @@ public class EntityAIStealthRetreat extends EntityAIBase } @Override - public boolean shouldContinueExecuting() - { - if (this.entityPathNavigate.noPath()) - { + public boolean shouldContinueExecuting() { + if (this.entityPathNavigate.noPath()) { this.entity.attackStateMachine = 0; return false; } @@ -74,33 +69,27 @@ public class EntityAIStealthRetreat extends EntityAIBase } @Override - public void resetTask() - { + public void resetTask() { ticksLeft = 0; } @Override - public void startExecuting() - { + public void startExecuting() { ticksLeft = this.entity.getEntityWorld().rand.nextInt(100) + 100; this.entityPathNavigate.setPath(this.entityPathEntity, this.farSpeed); } @Override - public void updateTask() - { + public void updateTask() { ticksLeft--; - if (ticksLeft <= 0 || this.entity.getAttackTarget() == null) - { + if (ticksLeft <= 0 || this.entity.getAttackTarget() == null) { this.entity.attackStateMachine = 0; return; } - if (this.entity.getDistanceSqToEntity(this.entity.getAttackTarget()) < 49.0D) - { + if (this.entity.getDistanceSqToEntity(this.entity.getAttackTarget()) < 49.0D) { this.entity.getNavigator().setSpeed(this.nearSpeed); - } else - { + } else { this.entity.getNavigator().setSpeed(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 11ac1534..74dd9ba6 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIStealthTowardsTarget.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIStealthTowardsTarget.java @@ -1,52 +1,43 @@ package WayofTime.bloodmagic.entity.ai; +import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.RandomPositionGenerator; import net.minecraft.util.math.Vec3d; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken; -public class EntityAIStealthTowardsTarget extends EntityAIBase -{ +public class EntityAIStealthTowardsTarget extends EntityAIBase { private final EntityCorruptedChicken entity; + private final double speed; private double xPosition; private double yPosition; private double zPosition; - private final double speed; - private int ticksLeft = 0; - public EntityAIStealthTowardsTarget(EntityCorruptedChicken creatureIn, double speedIn) - { + public EntityAIStealthTowardsTarget(EntityCorruptedChicken creatureIn, double speedIn) { this.entity = creatureIn; this.speed = speedIn; this.setMutexBits(1); } @Override - public boolean shouldExecute() - { - if (this.entity.attackStateMachine != 0 || this.entity.getAttackTarget() == null) - { + public boolean shouldExecute() { + if (this.entity.attackStateMachine != 0 || this.entity.getAttackTarget() == null) { return false; } EntityLivingBase target = this.entity.getAttackTarget(); Vec3d vec3d = null; - if (target instanceof EntityCreature) - { + if (target instanceof EntityCreature) { vec3d = RandomPositionGenerator.findRandomTarget((EntityCreature) target, 10, 7); - } else - { + } else { vec3d = RandomPositionGenerator.findRandomTarget(this.entity, 10, 7); } - if (vec3d == null) - { + if (vec3d == null) { return false; - } else - { + } else { ticksLeft = this.entity.getEntityWorld().rand.nextInt(200) + 100; this.xPosition = vec3d.x; this.yPosition = vec3d.y; @@ -56,36 +47,29 @@ public class EntityAIStealthTowardsTarget extends EntityAIBase } @Override - public void resetTask() - { + public void resetTask() { ticksLeft = 0; } @Override - public boolean shouldContinueExecuting() - { + public boolean shouldContinueExecuting() { ticksLeft--; - if (ticksLeft <= 0) - { + if (ticksLeft <= 0) { this.entity.attackStateMachine = 1; } this.entity.cloak(); - if (this.entity.getNavigator().noPath()) - { + if (this.entity.getNavigator().noPath()) { EntityLivingBase target = this.entity.getAttackTarget(); Vec3d vec3d; - if (target instanceof EntityCreature) - { + if (target instanceof EntityCreature) { vec3d = RandomPositionGenerator.findRandomTarget((EntityCreature) target, 10, 7); - } else - { + } else { vec3d = RandomPositionGenerator.findRandomTarget(this.entity, 10, 7); } - if (vec3d != null) - { + if (vec3d != null) { this.xPosition = vec3d.x; this.yPosition = vec3d.y; this.zPosition = vec3d.z; @@ -97,8 +81,7 @@ public class EntityAIStealthTowardsTarget extends EntityAIBase } @Override - public void startExecuting() - { + public void startExecuting() { this.entity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, this.speed); } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityAspectedDemonBase.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityAspectedDemonBase.java index caeedfd3..69b5ceac 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityAspectedDemonBase.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityAspectedDemonBase.java @@ -1,5 +1,9 @@ package WayofTime.bloodmagic.entity.mob; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.gson.Serializers; +import com.google.common.base.Predicate; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.nbt.NBTTagCompound; @@ -8,161 +12,139 @@ import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.util.DamageSource; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.gson.Serializers; - -import com.google.common.base.Predicate; import java.util.Locale; -public abstract class EntityAspectedDemonBase extends EntityDemonBase -{ +public abstract class EntityAspectedDemonBase extends EntityDemonBase { protected static final DataParameter TYPE = EntityDataManager.createKey(EntityAspectedDemonBase.class, Serializers.WILL_TYPE_SERIALIZER); - public EntityAspectedDemonBase(World worldIn) - { + public EntityAspectedDemonBase(World worldIn) { super(worldIn); } @Override - protected void entityInit() - { + protected void entityInit() { super.entityInit(); this.dataManager.register(TYPE, EnumDemonWillType.DEFAULT); } - public double getMeleeResist() - { + public double getMeleeResist() { return 0; } - public double getProjectileResist() - { + public double getProjectileResist() { return 0; } - public double getMagicResist() - { + public double getMagicResist() { return 0; } - public double getBaseHP(EnumDemonWillType type) - { + public double getBaseHP(EnumDemonWillType type) { double baseHP = 40; - switch (type) - { - case DEFAULT: - break; - case CORROSIVE: - break; - case DESTRUCTIVE: - break; - case VENGEFUL: - baseHP *= 0.8; - break; - case STEADFAST: - baseHP *= 1.25; - break; + switch (type) { + case DEFAULT: + break; + case CORROSIVE: + break; + case DESTRUCTIVE: + break; + case VENGEFUL: + baseHP *= 0.8; + break; + case STEADFAST: + baseHP *= 1.25; + break; } return baseHP; } - public double getBaseMeleeDamage(EnumDemonWillType type) - { + public double getBaseMeleeDamage(EnumDemonWillType type) { double baseDamage = 8; - switch (type) - { - case DEFAULT: - break; - case CORROSIVE: - baseDamage *= 0.8; - break; - case DESTRUCTIVE: - baseDamage *= 1.5; - break; - case VENGEFUL: - baseDamage *= 0.8; - break; - case STEADFAST: - baseDamage *= 0.6; - break; + switch (type) { + case DEFAULT: + break; + case CORROSIVE: + baseDamage *= 0.8; + break; + case DESTRUCTIVE: + baseDamage *= 1.5; + break; + case VENGEFUL: + baseDamage *= 0.8; + break; + case STEADFAST: + baseDamage *= 0.6; + break; } return baseDamage; } - public double getBaseSpeed(EnumDemonWillType type) - { + public double getBaseSpeed(EnumDemonWillType type) { double baseSpeed = 0.27; - switch (type) - { - case DEFAULT: - break; - case CORROSIVE: - break; - case DESTRUCTIVE: - break; - case VENGEFUL: - baseSpeed *= 1.3; - break; - case STEADFAST: - break; + switch (type) { + case DEFAULT: + break; + case CORROSIVE: + break; + case DESTRUCTIVE: + break; + case VENGEFUL: + baseSpeed *= 1.3; + break; + case STEADFAST: + break; } return baseSpeed; } - public double getBaseSprintModifier(EnumDemonWillType type) - { + public double getBaseSprintModifier(EnumDemonWillType type) { double baseSprint = 1; - switch (type) - { - case DEFAULT: - break; - case CORROSIVE: - break; - case DESTRUCTIVE: - break; - case VENGEFUL: - baseSprint *= 1.2; - break; - case STEADFAST: - break; + switch (type) { + case DEFAULT: + break; + case CORROSIVE: + break; + case DESTRUCTIVE: + break; + case VENGEFUL: + baseSprint *= 1.2; + break; + case STEADFAST: + break; } return baseSprint; } - public double getBaseKnockbackResist(EnumDemonWillType type) - { + public double getBaseKnockbackResist(EnumDemonWillType type) { double baseKnockback = 0; - switch (type) - { - case DEFAULT: - break; - case CORROSIVE: - break; - case DESTRUCTIVE: - break; - case VENGEFUL: - break; - case STEADFAST: - baseKnockback += 0.35; - break; + switch (type) { + case DEFAULT: + break; + case CORROSIVE: + break; + case DESTRUCTIVE: + break; + case VENGEFUL: + break; + case STEADFAST: + baseKnockback += 0.35; + break; } return baseKnockback; } - public void applyEntityAttributes(EnumDemonWillType type) - { + public void applyEntityAttributes(EnumDemonWillType type) { this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(this.getBaseHP(type)); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(this.getBaseSpeed(type)); this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(this.getBaseMeleeDamage(type)); @@ -170,24 +152,18 @@ public abstract class EntityAspectedDemonBase extends EntityDemonBase } @Override - public boolean attackEntityFrom(DamageSource source, float amount) - { - if (this.isEntityInvulnerable(source)) - { + public boolean attackEntityFrom(DamageSource source, float amount) { + if (this.isEntityInvulnerable(source)) { return false; - } else - { + } else { float newAmount = amount; - if (source.isProjectile()) - { + if (source.isProjectile()) { newAmount *= MathHelper.clamp(1 - getProjectileResist(), 0, 1); - } else - { + } else { newAmount *= MathHelper.clamp(1 - getMeleeResist(), 0, 1); } - if (source.isMagicDamage()) - { + if (source.isMagicDamage()) { newAmount *= MathHelper.clamp(1 - getMagicResist(), 0, 1); } @@ -195,83 +171,47 @@ public abstract class EntityAspectedDemonBase extends EntityDemonBase } } - public EnumDemonWillType getType() - { + public EnumDemonWillType getType() { return this.dataManager.get(TYPE); } - public void setType(EnumDemonWillType type) - { + public void setType(EnumDemonWillType type) { this.dataManager.set(TYPE, type); this.applyEntityAttributes(type); this.setCombatTask(); } @Override - public void writeEntityToNBT(NBTTagCompound tag) - { + public void writeEntityToNBT(NBTTagCompound tag) { super.writeEntityToNBT(tag); tag.setString(Constants.NBT.WILL_TYPE, this.getType().toString()); } @Override - public void readEntityFromNBT(NBTTagCompound tag) - { + public void readEntityFromNBT(NBTTagCompound tag) { super.readEntityFromNBT(tag); - if (!tag.hasKey(Constants.NBT.WILL_TYPE)) - { + if (!tag.hasKey(Constants.NBT.WILL_TYPE)) { setType(EnumDemonWillType.DEFAULT); - } else - { + } else { setType(EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH))); } } - public class TeamAttackPredicate implements Predicate - { - private final EntityAspectedDemonBase demon; - - public TeamAttackPredicate(EntityAspectedDemonBase demon) - { - this.demon = demon; - } - - //Returns true if this mob can attack the inputted mob. - @Override - public boolean apply(EntityLivingBase input) - { - if (input instanceof EntityAspectedDemonBase) - { - if (((EntityAspectedDemonBase) input).getType() == demon.getType()) - { - return false; - } - } - - return input != null; - } - } - //Returns true if the inputted mob is on the same team. - public static class WillTypePredicate implements Predicate - { + public static class WillTypePredicate implements Predicate { private final EnumDemonWillType type; - public WillTypePredicate(EnumDemonWillType type) - { + public WillTypePredicate(EnumDemonWillType type) { this.type = type; } //Returns true if this mob is the same type. @Override - public boolean apply(EntityLivingBase input) - { - if (input instanceof EntityAspectedDemonBase) - { - if (((EntityAspectedDemonBase) input).getType() == type) - { + public boolean apply(EntityLivingBase input) { + if (input instanceof EntityAspectedDemonBase) { + if (((EntityAspectedDemonBase) input).getType() == type) { return true; } } @@ -279,4 +219,24 @@ public abstract class EntityAspectedDemonBase extends EntityDemonBase return false; } } + + public class TeamAttackPredicate implements Predicate { + private final EntityAspectedDemonBase demon; + + public TeamAttackPredicate(EntityAspectedDemonBase demon) { + this.demon = demon; + } + + //Returns true if this mob can attack the inputted mob. + @Override + public boolean apply(EntityLivingBase input) { + if (input instanceof EntityAspectedDemonBase) { + if (((EntityAspectedDemonBase) input).getType() == demon.getType()) { + return false; + } + } + + return input != null; + } + } } diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedChicken.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedChicken.java index 77058576..ca6ec8be 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedChicken.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedChicken.java @@ -1,13 +1,13 @@ package WayofTime.bloodmagic.entity.mob; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.entity.ai.EntityAIAttackStealthMelee; +import WayofTime.bloodmagic.entity.ai.EntityAIStealthRetreat; +import WayofTime.bloodmagic.entity.ai.EntityAIStealthTowardsTarget; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.ai.EntityAILookIdle; -import net.minecraft.entity.ai.EntityAINearestAttackableTarget; -import net.minecraft.entity.ai.EntityAISwimming; -import net.minecraft.entity.ai.EntityAIWander; -import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.*; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.init.MobEffects; @@ -19,24 +19,18 @@ import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.entity.ai.EntityAIAttackStealthMelee; -import WayofTime.bloodmagic.entity.ai.EntityAIStealthRetreat; -import WayofTime.bloodmagic.entity.ai.EntityAIStealthTowardsTarget; -public class EntityCorruptedChicken extends EntityAspectedDemonBase -{ - private EntityAIAttackStealthMelee aiAttackOnCollide; +public class EntityCorruptedChicken extends EntityAspectedDemonBase { private final int attackPriority = 3; - public float wingRotation; public float destPos; public float oFlapSpeed; public float oFlap; public float wingRotDelta = 1.0F; - /** The time until the next egg is spawned. */ + /** + * The time until the next egg is spawned. + */ public int timeUntilNextEgg; - /* * 0 means the chicken is casting stealth on itself when targeted, running * to a random location near the target. 1 means the chicken is running @@ -45,14 +39,13 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase * state 0. */ public int attackStateMachine = 0; + private EntityAIAttackStealthMelee aiAttackOnCollide; - public EntityCorruptedChicken(World world) - { + public EntityCorruptedChicken(World world) { this(world, EnumDemonWillType.DEFAULT); } - public EntityCorruptedChicken(World world, EnumDemonWillType type) - { + public EntityCorruptedChicken(World world, EnumDemonWillType type) { super(world); this.setSize(0.4F, 0.7F); this.timeUntilNextEgg = this.rand.nextInt(600) + 600; @@ -61,8 +54,7 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase this.setType(type); } - protected void initEntityAI() - { + protected void initEntityAI() { this.tasks.addTask(0, new EntityAISwimming(this)); // this.tasks.addTask(1, new EntityAIPanic(this, 1.4D)); this.tasks.addTask(attackPriority, new EntityAIStealthTowardsTarget(this, 1)); @@ -76,10 +68,8 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase } @Override - public void setCombatTask() - { - if (aiAttackOnCollide != null) - { + public void setCombatTask() { + if (aiAttackOnCollide != null) { this.tasks.removeTask(aiAttackOnCollide); } @@ -87,50 +77,42 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase this.tasks.addTask(attackPriority, aiAttackOnCollide); } - public void cloak() - { + public void cloak() { this.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 50, 0, false, false)); } @Override - public double getBaseHP(EnumDemonWillType type) - { + public double getBaseHP(EnumDemonWillType type) { return super.getBaseHP(type) * 0.5; } @Override - public double getBaseMeleeDamage(EnumDemonWillType type) - { + public double getBaseMeleeDamage(EnumDemonWillType type) { return super.getBaseMeleeDamage(type) * 2.5; } @Override - public double getBaseSpeed(EnumDemonWillType type) - { + public double getBaseSpeed(EnumDemonWillType type) { return super.getBaseSpeed(type); } @Override - public double getBaseSprintModifier(EnumDemonWillType type) - { + public double getBaseSprintModifier(EnumDemonWillType type) { return super.getBaseSprintModifier(type); } @Override - public double getBaseKnockbackResist(EnumDemonWillType type) - { + public double getBaseKnockbackResist(EnumDemonWillType type) { return super.getBaseKnockbackResist(type); } @Override - public float getEyeHeight() - { + public float getEyeHeight() { return this.height; } @Override - public void onLivingUpdate() - { + public void onLivingUpdate() { super.onLivingUpdate(); // if (!worldObj.isRemote) @@ -141,22 +123,19 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase this.destPos = (float) ((double) this.destPos + (double) (this.onGround ? -1 : 4) * 0.3D); this.destPos = MathHelper.clamp(this.destPos, 0.0F, 1.0F); - if (!this.onGround && this.wingRotDelta < 1.0F) - { + if (!this.onGround && this.wingRotDelta < 1.0F) { this.wingRotDelta = 1.0F; } this.wingRotDelta = (float) ((double) this.wingRotDelta * 0.9D); - if (!this.onGround && this.motionY < 0.0D) - { + if (!this.onGround && this.motionY < 0.0D) { this.motionY *= 0.6D; } this.wingRotation += this.wingRotDelta * 2.0F; - if (!this.getEntityWorld().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); this.timeUntilNextEgg = this.rand.nextInt(600) + 600; @@ -164,61 +143,51 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase } @Override - public void fall(float distance, float damageMultiplier) - { + public void fall(float distance, float damageMultiplier) { } @Override - protected SoundEvent getAmbientSound() - { + protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_CHICKEN_AMBIENT; } @Override - protected SoundEvent getHurtSound() - { + protected SoundEvent getHurtSound() { return SoundEvents.ENTITY_CHICKEN_HURT; } @Override - protected SoundEvent getDeathSound() - { + protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_CHICKEN_DEATH; } @Override - protected float getSoundPitch() - { + protected float getSoundPitch() { return super.getSoundPitch() * 0.5f; } @Override - protected void playStepSound(BlockPos pos, Block blockIn) - { + protected void playStepSound(BlockPos pos, Block blockIn) { this.playSound(SoundEvents.ENTITY_CHICKEN_STEP, 0.15F, 1.0F); } @Override - public void readEntityFromNBT(NBTTagCompound compound) - { + public void readEntityFromNBT(NBTTagCompound compound) { super.readEntityFromNBT(compound); - if (compound.hasKey("EggLayTime")) - { + if (compound.hasKey("EggLayTime")) { this.timeUntilNextEgg = compound.getInteger("EggLayTime"); } } @Override - public void writeEntityToNBT(NBTTagCompound compound) - { + public void writeEntityToNBT(NBTTagCompound compound) { super.writeEntityToNBT(compound); compound.setInteger("EggLayTime", this.timeUntilNextEgg); } @Override - public void updatePassenger(Entity passenger) - { + public void updatePassenger(Entity passenger) { super.updatePassenger(passenger); float f = MathHelper.sin(this.renderYawOffset * 0.017453292F); float f1 = MathHelper.cos(this.renderYawOffset * 0.017453292F); @@ -226,8 +195,7 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase float f3 = 0.0F; passenger.setPosition(this.posX + (double) (0.1F * f), this.posY + (double) (this.height * 0.5F) + passenger.getYOffset() + 0.0D, this.posZ - (double) (0.1F * f1)); - if (passenger instanceof EntityLivingBase) - { + if (passenger instanceof EntityLivingBase) { ((EntityLivingBase) passenger).renderYawOffset = this.renderYawOffset; } } diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSheep.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSheep.java index b9e3e3c0..cf128414 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSheep.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSheep.java @@ -1,20 +1,13 @@ package WayofTime.bloodmagic.entity.mob; -import java.util.List; -import java.util.Map; -import java.util.Random; - -import javax.annotation.Nullable; - +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.entity.ai.EntityAIEatAndCorruptBlock; +import WayofTime.bloodmagic.entity.ai.EntityAIProtectAlly; +import com.google.common.collect.Maps; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IEntityLivingData; -import net.minecraft.entity.ai.EntityAIAttackMelee; -import net.minecraft.entity.ai.EntityAILookIdle; -import net.minecraft.entity.ai.EntityAINearestAttackableTarget; -import net.minecraft.entity.ai.EntityAISwimming; -import net.minecraft.entity.ai.EntityAIWander; -import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.*; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.MobEffects; @@ -35,53 +28,61 @@ import net.minecraft.world.World; import net.minecraftforge.common.IShearable; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.entity.ai.EntityAIEatAndCorruptBlock; -import WayofTime.bloodmagic.entity.ai.EntityAIProtectAlly; -import com.google.common.collect.Maps; +import javax.annotation.Nullable; +import java.util.List; +import java.util.Map; +import java.util.Random; -public class EntityCorruptedSheep extends EntityAspectedDemonBase implements IShearable -{ +public class EntityCorruptedSheep extends EntityAspectedDemonBase implements IShearable { private static final DataParameter DYE_COLOR = EntityDataManager.createKey(EntityCorruptedSheep.class, DataSerializers.BYTE); private static final Map DYE_TO_RGB = Maps.newEnumMap(EnumDyeColor.class); + public static int maxProtectionCooldown = 90 * 20; //90 second cooldown + + static { + DYE_TO_RGB.put(EnumDyeColor.WHITE, new float[]{1.0F, 1.0F, 1.0F}); + DYE_TO_RGB.put(EnumDyeColor.ORANGE, new float[]{0.85F, 0.5F, 0.2F}); + DYE_TO_RGB.put(EnumDyeColor.MAGENTA, new float[]{0.7F, 0.3F, 0.85F}); + DYE_TO_RGB.put(EnumDyeColor.LIGHT_BLUE, new float[]{0.4F, 0.6F, 0.85F}); + DYE_TO_RGB.put(EnumDyeColor.YELLOW, new float[]{0.9F, 0.9F, 0.2F}); + DYE_TO_RGB.put(EnumDyeColor.LIME, new float[]{0.5F, 0.8F, 0.1F}); + DYE_TO_RGB.put(EnumDyeColor.PINK, new float[]{0.95F, 0.5F, 0.65F}); + DYE_TO_RGB.put(EnumDyeColor.GRAY, new float[]{0.3F, 0.3F, 0.3F}); + DYE_TO_RGB.put(EnumDyeColor.SILVER, new float[]{0.6F, 0.6F, 0.6F}); + DYE_TO_RGB.put(EnumDyeColor.CYAN, new float[]{0.3F, 0.5F, 0.6F}); + DYE_TO_RGB.put(EnumDyeColor.PURPLE, new float[]{0.5F, 0.25F, 0.7F}); + DYE_TO_RGB.put(EnumDyeColor.BLUE, new float[]{0.2F, 0.3F, 0.7F}); + DYE_TO_RGB.put(EnumDyeColor.BROWN, new float[]{0.4F, 0.3F, 0.2F}); + DYE_TO_RGB.put(EnumDyeColor.GREEN, new float[]{0.4F, 0.5F, 0.2F}); + DYE_TO_RGB.put(EnumDyeColor.RED, new float[]{0.6F, 0.2F, 0.2F}); + DYE_TO_RGB.put(EnumDyeColor.BLACK, new float[]{0.1F, 0.1F, 0.1F}); + } + + private final int attackPriority = 3; + public int protectionCooldown = 0; /** * Used to control movement as well as wool regrowth. Set to 40 on * handleHealthUpdate and counts down with each tick. */ private int sheepTimer; - private int castTimer = 0; private EntityAIEatAndCorruptBlock entityAIEatGrass; private EntityAIProtectAlly entityAIProtectAlly; private EntityAIAttackMelee aiAttackOnCollide; - private final int attackPriority = 3; - - public int protectionCooldown = 0; - public static int maxProtectionCooldown = 90 * 20; //90 second cooldown - - public static float[] getDyeRgb(EnumDyeColor dyeColor) - { - return DYE_TO_RGB.get(dyeColor); - } - - public EntityCorruptedSheep(World world) - { + public EntityCorruptedSheep(World world) { this(world, EnumDemonWillType.DEFAULT); } - public EntityCorruptedSheep(World world, EnumDemonWillType type) - { + public EntityCorruptedSheep(World world, EnumDemonWillType type) { super(world); this.setSize(0.9F, 1.3F); this.setType(type); } - protected void initEntityAI() - { + protected void initEntityAI() { this.entityAIEatGrass = new EntityAIEatAndCorruptBlock(this); this.entityAIProtectAlly = new EntityAIProtectAlly(this); @@ -97,10 +98,8 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh } @Override - public void setCombatTask() - { - if (aiAttackOnCollide != null) - { + public void setCombatTask() { + if (aiAttackOnCollide != null) { this.tasks.removeTask(aiAttackOnCollide); } @@ -109,22 +108,18 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh } @Override - protected void updateAITasks() - { + protected void updateAITasks() { this.sheepTimer = this.entityAIEatGrass.getEatingGrassTimer(); this.castTimer = this.entityAIProtectAlly.getCastTimer(); super.updateAITasks(); } @Override - public void onLivingUpdate() - { - if (this.getEntityWorld().isRemote) - { + public void onLivingUpdate() { + if (this.getEntityWorld().isRemote) { this.sheepTimer = Math.max(0, this.sheepTimer - 1); this.castTimer = Math.max(0, castTimer - 1); - if (this.castTimer == 70) - { + if (this.castTimer == 70) { this.playSound(this.getHurtSound(), this.getSoundVolume() * 2, this.getSoundPitch()); } } @@ -134,15 +129,12 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh super.onLivingUpdate(); } - public boolean canProtectAlly(EntityLivingBase entity) - { + public boolean canProtectAlly(EntityLivingBase entity) { return this.protectionCooldown <= 0 && entity.getHealth() < entity.getMaxHealth() && !entity.isPotionActive(MobEffects.RESISTANCE); } - public boolean applyProtectionToAlly(EntityLivingBase entity) - { - if (canProtectAlly(entity)) - { + public boolean applyProtectionToAlly(EntityLivingBase entity) { + if (canProtectAlly(entity)) { entity.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 20 * 20, 3)); this.protectionCooldown = maxProtectionCooldown; } @@ -151,92 +143,75 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh } @Override - public double getBaseHP(EnumDemonWillType type) - { + public double getBaseHP(EnumDemonWillType type) { return super.getBaseHP(type) * 0.75; } @Override - public double getBaseMeleeDamage(EnumDemonWillType type) - { + public double getBaseMeleeDamage(EnumDemonWillType type) { return super.getBaseMeleeDamage(type) * 0.75; } @Override - public double getBaseSpeed(EnumDemonWillType type) - { + public double getBaseSpeed(EnumDemonWillType type) { return super.getBaseSpeed(type); } @Override - public double getBaseSprintModifier(EnumDemonWillType type) - { + public double getBaseSprintModifier(EnumDemonWillType type) { return super.getBaseSprintModifier(type); } @Override - public double getBaseKnockbackResist(EnumDemonWillType type) - { + public double getBaseKnockbackResist(EnumDemonWillType type) { return super.getBaseKnockbackResist(type) + 0.2; } @Override - public double getMeleeResist() - { + public double getMeleeResist() { return 0.2; } @Override - public double getProjectileResist() - { + public double getProjectileResist() { return 0.6; } @Override - protected void entityInit() - { + protected void entityInit() { super.entityInit(); this.dataManager.register(DYE_COLOR, Byte.valueOf((byte) 0)); } @Override @SideOnly(Side.CLIENT) - public void handleStatusUpdate(byte id) - { - if (id == 10) - { + public void handleStatusUpdate(byte id) { + if (id == 10) { this.sheepTimer = 40; - } else if (id == 53) - { + } else if (id == 53) { this.castTimer = 100; - } else - { + } else { super.handleStatusUpdate(id); } } @SideOnly(Side.CLIENT) - public float getHeadRotationPointY(float partialTick) - { + public float getHeadRotationPointY(float partialTick) { return this.sheepTimer <= 0 ? 0.0F : (this.sheepTimer >= 4 && this.sheepTimer <= 36 ? 1.0F : (this.sheepTimer < 4 ? ((float) this.sheepTimer - partialTick) / 4.0F : -((float) (this.sheepTimer - 40) - partialTick) / 4.0F)); } @SideOnly(Side.CLIENT) - public float getHeadRotationAngleX(float partialTick) - { - if (this.sheepTimer > 4 && this.sheepTimer <= 36) - { + public float getHeadRotationAngleX(float partialTick) { + if (this.sheepTimer > 4 && this.sheepTimer <= 36) { float f = ((float) (this.sheepTimer - 4) - partialTick) / 32.0F; return ((float) Math.PI / 5F) + ((float) Math.PI * 7F / 100F) * MathHelper.sin(f * 28.7F); - } else - { + } else { return this.sheepTimer > 0 ? ((float) Math.PI / 5F) : this.rotationPitch * 0.017453292F; } } @Override - public void writeEntityToNBT(NBTTagCompound tag) - { + public void writeEntityToNBT(NBTTagCompound tag) { super.writeEntityToNBT(tag); tag.setBoolean("Sheared", this.getSheared()); tag.setByte("Color", (byte) this.getFleeceColor().getMetadata()); @@ -244,8 +219,7 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh } @Override - public void readEntityFromNBT(NBTTagCompound tag) - { + public void readEntityFromNBT(NBTTagCompound tag) { super.readEntityFromNBT(tag); this.setSheared(tag.getBoolean("Sheared")); this.setFleeceColor(EnumDyeColor.byMetadata(tag.getByte("Color"))); @@ -253,48 +227,41 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh } @Override - protected SoundEvent getAmbientSound() - { + protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_SHEEP_AMBIENT; } @Override - protected SoundEvent getHurtSound() - { + protected SoundEvent getHurtSound() { return SoundEvents.ENTITY_SHEEP_HURT; } @Override - protected SoundEvent getDeathSound() - { + protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_SHEEP_DEATH; } @Override - protected float getSoundPitch() - { + protected float getSoundPitch() { return super.getSoundPitch() * 0.5f; } @Override - protected void playStepSound(BlockPos pos, Block blockIn) - { + protected void playStepSound(BlockPos pos, Block blockIn) { this.playSound(SoundEvents.ENTITY_SHEEP_STEP, 0.15F, 1.0F); } /** * Gets the wool color of this sheep. */ - public EnumDyeColor getFleeceColor() - { + public EnumDyeColor getFleeceColor() { return EnumDyeColor.byMetadata(this.dataManager.get(DYE_COLOR).byteValue() & 15); } /** * Sets the wool color of this sheep */ - public void setFleeceColor(EnumDyeColor color) - { + public void setFleeceColor(EnumDyeColor color) { byte b0 = this.dataManager.get(DYE_COLOR).byteValue(); this.dataManager.set(DYE_COLOR, Byte.valueOf((byte) (b0 & 240 | color.getMetadata() & 15))); } @@ -302,48 +269,33 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh /** * returns true if a sheeps wool has been sheared */ - public boolean getSheared() - { + public boolean getSheared() { return (this.dataManager.get(DYE_COLOR).byteValue() & 16) != 0; } /** * make a sheep sheared if set to true */ - public void setSheared(boolean sheared) - { + public void setSheared(boolean sheared) { byte b0 = this.dataManager.get(DYE_COLOR).byteValue(); - if (sheared) - { + if (sheared) { this.dataManager.set(DYE_COLOR, Byte.valueOf((byte) (b0 | 16))); - } else - { + } else { this.dataManager.set(DYE_COLOR, Byte.valueOf((byte) (b0 & -17))); } } - /** - * Chooses a "vanilla" sheep color based on the provided random. - */ - public static EnumDyeColor getRandomSheepColor(Random random) - { - int i = random.nextInt(100); - return i < 5 ? EnumDyeColor.BLACK : (i < 10 ? EnumDyeColor.GRAY : (i < 15 ? EnumDyeColor.SILVER : (i < 18 ? EnumDyeColor.BROWN : (random.nextInt(500) == 0 ? EnumDyeColor.PINK : EnumDyeColor.WHITE)))); - } - /** * This function applies the benefits of growing back wool and faster * growing up to the acting entity. (This function is used in the * AIEatGrass) */ @Override - public void eatGrassBonus() - { + public void eatGrassBonus() { this.setSheared(false); - if (this.isChild()) - { + if (this.isChild()) { this.heal(3); } } @@ -354,48 +306,24 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh * from nbt. Mainly used for initializing attributes and inventory */ @Override - public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) - { + public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); this.setFleeceColor(getRandomSheepColor(this.getEntityWorld().rand)); return livingdata; } @Override - public float getEyeHeight() - { + public float getEyeHeight() { return 0.95F * this.height; } - static - { - DYE_TO_RGB.put(EnumDyeColor.WHITE, new float[] { 1.0F, 1.0F, 1.0F }); - DYE_TO_RGB.put(EnumDyeColor.ORANGE, new float[] { 0.85F, 0.5F, 0.2F }); - DYE_TO_RGB.put(EnumDyeColor.MAGENTA, new float[] { 0.7F, 0.3F, 0.85F }); - DYE_TO_RGB.put(EnumDyeColor.LIGHT_BLUE, new float[] { 0.4F, 0.6F, 0.85F }); - DYE_TO_RGB.put(EnumDyeColor.YELLOW, new float[] { 0.9F, 0.9F, 0.2F }); - DYE_TO_RGB.put(EnumDyeColor.LIME, new float[] { 0.5F, 0.8F, 0.1F }); - DYE_TO_RGB.put(EnumDyeColor.PINK, new float[] { 0.95F, 0.5F, 0.65F }); - DYE_TO_RGB.put(EnumDyeColor.GRAY, new float[] { 0.3F, 0.3F, 0.3F }); - DYE_TO_RGB.put(EnumDyeColor.SILVER, new float[] { 0.6F, 0.6F, 0.6F }); - DYE_TO_RGB.put(EnumDyeColor.CYAN, new float[] { 0.3F, 0.5F, 0.6F }); - DYE_TO_RGB.put(EnumDyeColor.PURPLE, new float[] { 0.5F, 0.25F, 0.7F }); - DYE_TO_RGB.put(EnumDyeColor.BLUE, new float[] { 0.2F, 0.3F, 0.7F }); - DYE_TO_RGB.put(EnumDyeColor.BROWN, new float[] { 0.4F, 0.3F, 0.2F }); - DYE_TO_RGB.put(EnumDyeColor.GREEN, new float[] { 0.4F, 0.5F, 0.2F }); - DYE_TO_RGB.put(EnumDyeColor.RED, new float[] { 0.6F, 0.2F, 0.2F }); - DYE_TO_RGB.put(EnumDyeColor.BLACK, new float[] { 0.1F, 0.1F, 0.1F }); - } - @Override - public boolean isShearable(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos) - { + public boolean isShearable(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos) { return !this.getSheared() && !this.isChild(); } @Override - public List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) - { + public List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) { this.setSheared(true); int i = 1 + this.rand.nextInt(3); @@ -410,4 +338,16 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh public int getCastTimer() { return castTimer; } + + public static float[] getDyeRgb(EnumDyeColor dyeColor) { + return DYE_TO_RGB.get(dyeColor); + } + + /** + * Chooses a "vanilla" sheep color based on the provided random. + */ + public static EnumDyeColor getRandomSheepColor(Random random) { + int i = random.nextInt(100); + return i < 5 ? EnumDyeColor.BLACK : (i < 10 ? EnumDyeColor.GRAY : (i < 15 ? EnumDyeColor.SILVER : (i < 18 ? EnumDyeColor.BROWN : (random.nextInt(500) == 0 ? EnumDyeColor.PINK : EnumDyeColor.WHITE)))); + } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSpider.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSpider.java index 05957123..5e8c75b0 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSpider.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedSpider.java @@ -1,16 +1,11 @@ package WayofTime.bloodmagic.entity.mob; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.entity.ai.EntityAIPickUpAlly; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureAttribute; -import net.minecraft.entity.ai.EntityAIAttackMelee; -import net.minecraft.entity.ai.EntityAIHurtByTarget; -import net.minecraft.entity.ai.EntityAILeapAtTarget; -import net.minecraft.entity.ai.EntityAILookIdle; -import net.minecraft.entity.ai.EntityAINearestAttackableTarget; -import net.minecraft.entity.ai.EntityAISwimming; -import net.minecraft.entity.ai.EntityAIWander; -import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.*; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.init.SoundEvents; @@ -23,28 +18,22 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.entity.ai.EntityAIPickUpAlly; -public class EntityCorruptedSpider extends EntityAspectedDemonBase -{ +public class EntityCorruptedSpider extends EntityAspectedDemonBase { private static final DataParameter CLIMBING = EntityDataManager.createKey(EntityCorruptedSpider.class, DataSerializers.BYTE); - public EntityCorruptedSpider(World world) - { + public EntityCorruptedSpider(World world) { this(world, EnumDemonWillType.DEFAULT); } - public EntityCorruptedSpider(World world, EnumDemonWillType type) - { + public EntityCorruptedSpider(World world, EnumDemonWillType type) { super(world); this.setSize(1.4F, 0.9F); this.setType(type); } - protected void initEntityAI() - { + protected void initEntityAI() { this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); this.tasks.addTask(3, new EntityAIPickUpAlly(this, 1, true)); @@ -59,132 +48,109 @@ public class EntityCorruptedSpider extends EntityAspectedDemonBase } @Override - public double getBaseHP(EnumDemonWillType type) - { + public double getBaseHP(EnumDemonWillType type) { return super.getBaseHP(type); } @Override - public double getBaseMeleeDamage(EnumDemonWillType type) - { + public double getBaseMeleeDamage(EnumDemonWillType type) { return super.getBaseMeleeDamage(type); } @Override - public double getBaseSpeed(EnumDemonWillType type) - { + public double getBaseSpeed(EnumDemonWillType type) { return super.getBaseSpeed(type); } @Override - public double getBaseSprintModifier(EnumDemonWillType type) - { + public double getBaseSprintModifier(EnumDemonWillType type) { return super.getBaseSprintModifier(type); } @Override - public double getBaseKnockbackResist(EnumDemonWillType type) - { + public double getBaseKnockbackResist(EnumDemonWillType type) { return super.getBaseKnockbackResist(type); } @Override - public double getMountedYOffset() - { + public double getMountedYOffset() { return (double) (this.height * 0.5F); } @Override - protected PathNavigate createNavigator(World worldIn) - { + protected PathNavigate createNavigator(World worldIn) { return new PathNavigateClimber(this, worldIn); } @Override - protected void entityInit() - { + protected void entityInit() { super.entityInit(); this.dataManager.register(CLIMBING, (byte) 0); } @Override - public void onUpdate() - { + public void onUpdate() { super.onUpdate(); - if (!this.getEntityWorld().isRemote) - { + if (!this.getEntityWorld().isRemote) { this.setBesideClimbableBlock(this.isCollidedHorizontally); } } @Override - protected SoundEvent getAmbientSound() - { + protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_SPIDER_AMBIENT; } @Override - protected SoundEvent getHurtSound() - { + protected SoundEvent getHurtSound() { return SoundEvents.ENTITY_SPIDER_HURT; } @Override - protected SoundEvent getDeathSound() - { + protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_SPIDER_DEATH; } @Override - protected float getSoundPitch() - { + protected float getSoundPitch() { return super.getSoundPitch() * 0.5f; } @Override - protected void playStepSound(BlockPos pos, Block blockIn) - { + protected void playStepSound(BlockPos pos, Block blockIn) { this.playSound(SoundEvents.ENTITY_SPIDER_STEP, 0.15F, 1.0F); } @Override - public boolean isOnLadder() - { + public boolean isOnLadder() { return this.isBesideClimbableBlock(); } @Override - public void setInWeb() - { + public void setInWeb() { } @Override - public EnumCreatureAttribute getCreatureAttribute() - { + public EnumCreatureAttribute getCreatureAttribute() { return EnumCreatureAttribute.ARTHROPOD; } @Override - public boolean isPotionApplicable(PotionEffect potioneffectIn) - { + public boolean isPotionApplicable(PotionEffect potioneffectIn) { return potioneffectIn.getPotion() != MobEffects.POISON && super.isPotionApplicable(potioneffectIn); } - public boolean isBesideClimbableBlock() - { + public boolean isBesideClimbableBlock() { return (this.dataManager.get(CLIMBING) & 1) != 0; } - public void setBesideClimbableBlock(boolean climbing) - { + public void setBesideClimbableBlock(boolean climbing) { byte b0 = this.dataManager.get(CLIMBING); - if (climbing) - { + if (climbing) { b0 = (byte) (b0 | 1); - } else - { + } else { b0 = (byte) (b0 & -2); } @@ -192,53 +158,43 @@ public class EntityCorruptedSpider extends EntityAspectedDemonBase } @Override - public float getEyeHeight() - { + public float getEyeHeight() { return 0.65F; } - static class AISpiderAttack extends EntityAIAttackMelee - { - public AISpiderAttack(EntityCorruptedSpider spider) - { + static class AISpiderAttack extends EntityAIAttackMelee { + public AISpiderAttack(EntityCorruptedSpider spider) { super(spider, 1.0D, true); } /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean shouldContinueExecuting() - { + public boolean shouldContinueExecuting() { float f = this.attacker.getBrightness(); - if (f >= 0.5F && this.attacker.getRNG().nextInt(100) == 0) - { + if (f >= 0.5F && this.attacker.getRNG().nextInt(100) == 0) { this.attacker.setAttackTarget(null); return false; - } else - { + } else { return super.shouldContinueExecuting(); } } - protected double getAttackReachSqr(EntityLivingBase attackTarget) - { + protected double getAttackReachSqr(EntityLivingBase attackTarget) { return (double) (4.0F + attackTarget.width); } } - static class AISpiderTarget extends EntityAINearestAttackableTarget - { - public AISpiderTarget(EntityCorruptedSpider spider, Class classTarget) - { + static class AISpiderTarget extends EntityAINearestAttackableTarget { + public AISpiderTarget(EntityCorruptedSpider spider, Class classTarget) { super(spider, classTarget, true); } /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { + public boolean shouldExecute() { float f = this.taskOwner.getBrightness(); return !(f >= 0.5F) && super.shouldExecute(); } diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedZombie.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedZombie.java index 3e96d17b..f9927f48 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedZombie.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityCorruptedZombie.java @@ -1,18 +1,12 @@ package WayofTime.bloodmagic.entity.mob; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; +import WayofTime.bloodmagic.entity.ai.EntityAIAttackRangedBow; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.EntityAIAttackMelee; -import net.minecraft.entity.ai.EntityAIHurtByTarget; -import net.minecraft.entity.ai.EntityAILookIdle; -import net.minecraft.entity.ai.EntityAIMoveThroughVillage; -import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; -import net.minecraft.entity.ai.EntityAINearestAttackableTarget; -import net.minecraft.entity.ai.EntityAISwimming; -import net.minecraft.entity.ai.EntityAIWander; -import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.*; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.monster.EntityGhast; import net.minecraft.entity.monster.EntityIronGolem; @@ -27,18 +21,14 @@ import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -import WayofTime.bloodmagic.entity.ai.EntityAIAttackRangedBow; -public class EntityCorruptedZombie extends EntityAspectedDemonBase -{ +public class EntityCorruptedZombie extends EntityAspectedDemonBase { private final EntityAIAttackRangedBow aiArrowAttack = new EntityAIAttackRangedBow(this, 1.0D, 20, 15.0F); private final EntityAIAttackMelee aiAttackOnCollide = new EntityAIAttackMelee(this, 1.0D, false); private final int attackPriority = 3; - public EntityCorruptedZombie(World worldIn) - { + public EntityCorruptedZombie(World worldIn) { super(worldIn); this.setSize(0.6F, 1.95F); // ((PathNavigateGround) getNavigator()).setCanSwim(false); @@ -60,8 +50,7 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase } @Override - protected void applyEntityAttributes() - { + protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(35.0D); getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(40.0D); @@ -71,35 +60,29 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase } @Override - public void setCombatTask() - { - if (!this.getEntityWorld().isRemote) - { + public void setCombatTask() { + if (!this.getEntityWorld().isRemote) { this.tasks.removeTask(this.aiAttackOnCollide); this.tasks.removeTask(this.aiArrowAttack); ItemStack itemstack = this.getHeldItemMainhand(); - if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow) - { + if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow) { int i = 20; - if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD) - { + if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD) { i = 40; } this.aiArrowAttack.setAttackCooldown(i); this.tasks.addTask(attackPriority, this.aiArrowAttack); - } else - { + } else { this.tasks.addTask(attackPriority, this.aiAttackOnCollide); } } } @Override - public boolean attackEntityFrom(DamageSource source, float amount) - { + public boolean attackEntityFrom(DamageSource source, float amount) { return !this.isEntityInvulnerable(source) && super.attackEntityFrom(source, amount); } @@ -107,17 +90,14 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase * Redone from EntityMob to prevent despawning on peaceful. */ @Override - public boolean attackEntityAsMob(Entity attackedEntity) - { + public boolean attackEntityAsMob(Entity attackedEntity) { boolean flag = super.attackEntityAsMob(attackedEntity); - if (flag) - { + if (flag) { //EMPTY return true; - } else - { + } else { return false; } } @@ -126,24 +106,20 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase * @param toHeal * @return Amount of Will consumed from the Aura to heal */ - public double absorbWillFromAuraToHeal(double toHeal) - { - if (getEntityWorld().isRemote) - { + public double absorbWillFromAuraToHeal(double toHeal) { + if (getEntityWorld().isRemote) { return 0; } double healthMissing = this.getMaxHealth() - this.getHealth(); - if (healthMissing <= 0) - { + if (healthMissing <= 0) { return 0; } double will = WorldDemonWillHandler.getCurrentWill(getEntityWorld(), getPosition(), getType()); toHeal = Math.min(healthMissing, Math.min(toHeal, will / getWillToHealth())); - if (toHeal > 0) - { + if (toHeal > 0) { this.heal((float) toHeal); return WorldDemonWillHandler.drainWill(getEntityWorld(), getPosition(), getType(), toHeal * getWillToHealth(), true); } @@ -151,21 +127,17 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase return 0; } - public double getWillToHealth() - { + public double getWillToHealth() { return 2; } @Override - protected boolean canDespawn() - { + protected boolean canDespawn() { return !this.isTamed() && super.canDespawn(); } - public void onUpdate() - { - if (!this.getEntityWorld().isRemote && this.ticksExisted % 20 == 0) - { + public void onUpdate() { + if (!this.getEntityWorld().isRemote && this.ticksExisted % 20 == 0) { absorbWillFromAuraToHeal(2); } @@ -179,32 +151,27 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase } @Override - protected float getSoundPitch() - { + protected float getSoundPitch() { return super.getSoundPitch() * 0.5f; } @Override - protected SoundEvent getAmbientSound() - { + protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_ZOMBIE_AMBIENT; } @Override - protected SoundEvent getHurtSound() - { + protected SoundEvent getHurtSound() { return SoundEvents.ENTITY_ZOMBIE_HURT; } @Override - protected SoundEvent getDeathSound() - { + protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_ZOMBIE_DEATH; } @Override - protected void playStepSound(BlockPos pos, Block block) - { + protected void playStepSound(BlockPos pos, Block block) { this.playSound(SoundEvents.ENTITY_ZOMBIE_STEP, 0.15F, 1.0F); } @@ -212,8 +179,7 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase * Returns the volume for the sounds this mob makes. */ @Override - protected float getSoundVolume() - { + protected float getSoundVolume() { return 0.4F; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityDemonBase.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityDemonBase.java index 0aad0e12..2df10d5e 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityDemonBase.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityDemonBase.java @@ -1,14 +1,10 @@ package WayofTime.bloodmagic.entity.mob; -import java.util.UUID; - +import com.google.common.base.Optional; +import com.google.common.base.Predicate; import net.minecraft.block.Block; import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityCreature; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.IEntityOwnable; -import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.*; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.monster.EntityGhast; import net.minecraft.entity.monster.EntityMob; @@ -34,58 +30,48 @@ import net.minecraft.world.Explosion; import net.minecraft.world.World; import net.minecraft.world.WorldServer; -import com.google.common.base.Optional; -import com.google.common.base.Predicate; - import javax.annotation.Nullable; +import java.util.UUID; -public class EntityDemonBase extends EntityCreature implements IEntityOwnable -{ +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); - public EntityDemonBase(World worldIn) - { + public EntityDemonBase(World worldIn) { super(worldIn); } @Override - protected void entityInit() - { + protected void entityInit() { super.entityInit(); this.dataManager.register(TAMED, (byte) 0); this.dataManager.register(OWNER_UNIQUE_ID, Optional.absent()); } @Override - protected void applyEntityAttributes() - { + protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE); } - public void setCombatTask() - { + public void setCombatTask() { } @Override - public boolean isPotionApplicable(PotionEffect effect) - { + public boolean isPotionApplicable(PotionEffect effect) { return super.isPotionApplicable(effect); } @Override - public void onLivingUpdate() - { + public void onLivingUpdate() { this.updateArmSwingProgress(); super.onLivingUpdate(); } @Override - public boolean attackEntityFrom(DamageSource source, float amount) - { + public boolean attackEntityFrom(DamageSource source, float amount) { return !this.isEntityInvulnerable(source) && super.attackEntityFrom(source, amount); } @@ -93,23 +79,19 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable * Redone from EntityMob to prevent despawning on peaceful. */ @Override - public boolean attackEntityAsMob(Entity attackedEntity) - { + public boolean attackEntityAsMob(Entity attackedEntity) { float f = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue(); int i = 0; - if (attackedEntity instanceof EntityLivingBase) - { + if (attackedEntity instanceof EntityLivingBase) { f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase) attackedEntity).getCreatureAttribute()); i += EnchantmentHelper.getKnockbackModifier(this); } boolean flag = attackedEntity.attackEntityFrom(DamageSource.causeMobDamage(this), f); - if (flag) - { - if (i > 0) - { + if (flag) { + 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; this.motionZ *= 0.6D; @@ -117,23 +99,19 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable int j = EnchantmentHelper.getFireAspectModifier(this); - if (j > 0) - { + if (j > 0) { attackedEntity.setFire(j * 4); } - if (attackedEntity instanceof EntityPlayer) - { + if (attackedEntity instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) attackedEntity; ItemStack itemstack = this.getHeldItemMainhand(); ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : ItemStack.EMPTY; - if (!itemstack.isEmpty() && !itemstack1.isEmpty() && 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) - { + if (this.rand.nextFloat() < f1) { entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100); this.getEntityWorld().setEntityState(entityplayer, (byte) 30); } @@ -147,87 +125,70 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable } @Override - public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack) - { + public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack) { super.setItemStackToSlot(slotIn, stack); - if (!this.getEntityWorld().isRemote && slotIn == EntityEquipmentSlot.MAINHAND) - { + if (!this.getEntityWorld().isRemote && slotIn == EntityEquipmentSlot.MAINHAND) { this.setCombatTask(); } } - public boolean isStationary() - { + public boolean isStationary() { return false; } - public boolean absorbExplosion(Explosion explosion) - { + public boolean absorbExplosion(Explosion explosion) { return false; } - public void performEmergencyHeal(double toHeal) - { + public void performEmergencyHeal(double toHeal) { this.heal((float) toHeal); - if (getEntityWorld() instanceof WorldServer) - { + if (getEntityWorld() instanceof WorldServer) { 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); } } - public boolean shouldEmergencyHeal() - { + public boolean shouldEmergencyHeal() { return this.getHealth() < this.getMaxHealth() * 0.5; } @Override - protected boolean canDespawn() - { + protected boolean canDespawn() { return !this.isTamed() && super.canDespawn(); } @Override - public void writeEntityToNBT(NBTTagCompound tag) - { + public void writeEntityToNBT(NBTTagCompound tag) { super.writeEntityToNBT(tag); - if (this.getOwnerId() == null) - { + if (this.getOwnerId() == null) { tag.setString("OwnerUUID", ""); - } else - { + } else { tag.setString("OwnerUUID", this.getOwnerId().toString()); } } @Override - public void readEntityFromNBT(NBTTagCompound tag) - { + public void readEntityFromNBT(NBTTagCompound tag) { super.readEntityFromNBT(tag); String s; - if (tag.hasKey("OwnerUUID", 8)) - { + if (tag.hasKey("OwnerUUID", 8)) { s = tag.getString("OwnerUUID"); - } else - { + } else { String s1 = tag.getString("Owner"); s = PreYggdrasilConverter.convertMobOwnerIfNeeded(this.getServer(), s1); } - if (!s.isEmpty()) - { - try - { + if (!s.isEmpty()) { + try { this.setOwnerId(UUID.fromString(s)); this.setTamed(true); - } catch (Throwable var4) - { + } catch (Throwable var4) { this.setTamed(false); } } @@ -236,46 +197,36 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable } //TODO: Change to fit the given AI - public boolean shouldAttackEntity(EntityLivingBase attacker, EntityLivingBase owner) - { - if (!(attacker instanceof EntityCreeper) && !(attacker instanceof EntityGhast)) - { - if (attacker instanceof IEntityOwnable) - { + public boolean shouldAttackEntity(EntityLivingBase attacker, EntityLivingBase owner) { + if (!(attacker instanceof EntityCreeper) && !(attacker instanceof EntityGhast)) { + if (attacker instanceof IEntityOwnable) { IEntityOwnable entityOwnable = (IEntityOwnable) attacker; - if (entityOwnable.getOwner() == owner) - { + if (entityOwnable.getOwner() == owner) { return false; } } return !(attacker instanceof EntityPlayer && owner instanceof EntityPlayer && !((EntityPlayer) owner).canAttackPlayer((EntityPlayer) attacker)) && (!(attacker instanceof EntityHorse) || !((EntityHorse) attacker).isTame()); - } else - { + } else { return false; } } - public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity) - { + public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity) { } - public boolean isTamed() - { + public boolean isTamed() { return (this.dataManager.get(TAMED) & 4) != 0; } - public void setTamed(boolean tamed) - { + public void setTamed(boolean tamed) { byte b0 = this.dataManager.get(TAMED); - if (tamed) - { + if (tamed) { this.dataManager.set(TAMED, (byte) (b0 | 4)); - } else - { + } else { this.dataManager.set(TAMED, (byte) (b0 & -5)); } @@ -283,8 +234,7 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable } @Override - protected SoundEvent getAmbientSound() - { + protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_COW_AMBIENT; } @@ -294,20 +244,17 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable return getHurtSound(); } - protected SoundEvent getHurtSound() - { + protected SoundEvent getHurtSound() { return SoundEvents.ENTITY_COW_HURT; } @Override - protected SoundEvent getDeathSound() - { + protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_COW_DEATH; } @Override - protected void playStepSound(BlockPos pos, Block block) - { + protected void playStepSound(BlockPos pos, Block block) { this.playSound(SoundEvents.ENTITY_COW_STEP, 0.15F, 1.0F); } @@ -315,52 +262,42 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable * Returns the volume for the sounds this mob makes. */ @Override - protected float getSoundVolume() - { + protected float getSoundVolume() { return 0.4F; } @Override - public UUID getOwnerId() - { + public UUID getOwnerId() { return (this.dataManager.get(OWNER_UNIQUE_ID)).orNull(); } - public void setOwnerId(UUID uuid) - { + public void setOwnerId(UUID uuid) { this.dataManager.set(OWNER_UNIQUE_ID, Optional.fromNullable(uuid)); } @Override - public EntityLivingBase getOwner() - { - try - { + public EntityLivingBase getOwner() { + try { UUID uuid = this.getOwnerId(); return uuid == null ? null : this.getEntityWorld().getPlayerEntityByUUID(uuid); - } catch (IllegalArgumentException var2) - { + } catch (IllegalArgumentException var2) { return null; } } - public void setOwner(EntityPlayer player) - { + public void setOwner(EntityPlayer player) { setOwnerId(player.getUniqueID()); } - public class TargetPredicate implements Predicate - { + public class TargetPredicate implements Predicate { EntityDemonBase entity; - public TargetPredicate(EntityDemonBase entity) - { + public TargetPredicate(EntityDemonBase entity) { this.entity = entity; } @Override - public boolean apply(EntityMob input) - { + public boolean apply(EntityMob input) { return entity.shouldAttackEntity(input, this.entity.getOwner()); } } diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityMimic.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityMimic.java index 890c3392..2fdb7dd0 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntityMimic.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntityMimic.java @@ -1,19 +1,15 @@ package WayofTime.bloodmagic.entity.mob; +import WayofTime.bloodmagic.block.BlockMimic; +import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; +import WayofTime.bloodmagic.entity.ai.EntityAIMimicReform; +import WayofTime.bloodmagic.tile.TileMimic; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureAttribute; import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.EntityAIAttackMelee; -import net.minecraft.entity.ai.EntityAIHurtByTarget; -import net.minecraft.entity.ai.EntityAILeapAtTarget; -import net.minecraft.entity.ai.EntityAILookIdle; -import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; -import net.minecraft.entity.ai.EntityAINearestAttackableTarget; -import net.minecraft.entity.ai.EntityAISwimming; -import net.minecraft.entity.ai.EntityAIWander; -import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.*; import net.minecraft.entity.monster.EntityIronGolem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; @@ -33,13 +29,8 @@ import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; -import WayofTime.bloodmagic.block.BlockMimic; -import WayofTime.bloodmagic.entity.ai.EntityAIMimicReform; -import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; -import WayofTime.bloodmagic.tile.TileMimic; -public class EntityMimic extends EntityDemonBase -{ +public class EntityMimic extends EntityDemonBase { /** * Copy of EntitySpider's AI (should be pretty evident...) */ @@ -50,8 +41,7 @@ public class EntityMimic extends EntityDemonBase public int metaOfReplacedBlock = 0; public int playerCheckRadius = 5; - public EntityMimic(World worldIn) - { + public EntityMimic(World worldIn) { super(worldIn); this.setSize(0.9F, 0.9F); @@ -70,8 +60,7 @@ public class EntityMimic extends EntityDemonBase } @Override - public void writeEntityToNBT(NBTTagCompound tag) - { + public void writeEntityToNBT(NBTTagCompound tag) { super.writeEntityToNBT(tag); tag.setBoolean("dropItemsOnBreak", dropItemsOnBreak); @@ -81,8 +70,7 @@ public class EntityMimic extends EntityDemonBase } @Override - public void readEntityFromNBT(NBTTagCompound tag) - { + public void readEntityFromNBT(NBTTagCompound tag) { super.readEntityFromNBT(tag); dropItemsOnBreak = tag.getBoolean("dropItemsOnBreak"); @@ -91,30 +79,24 @@ public class EntityMimic extends EntityDemonBase playerCheckRadius = tag.getInteger("playerCheckRadius"); } - public ItemStack getMimicItemStack() - { + public ItemStack getMimicItemStack() { return this.getItemStackFromSlot(EntityEquipmentSlot.CHEST); } - public void setMimicItemStack(ItemStack stack) - { + public void setMimicItemStack(ItemStack stack) { this.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack); } - public boolean spawnHeldBlockOnDeath(World world, BlockPos pos) - { + public boolean spawnHeldBlockOnDeath(World world, BlockPos pos) { return world.isAirBlock(pos) && TileMimic.replaceMimicWithBlockActual(world, pos, getMimicItemStack(), tileTag, metaOfReplacedBlock); } - public boolean spawnMimicBlockAtPosition(World world, BlockPos pos) - { - if (world.isAirBlock(pos)) - { + public boolean spawnMimicBlockAtPosition(World world, BlockPos pos) { + if (world.isAirBlock(pos)) { IBlockState mimicState = RegistrarBloodMagicBlocks.MIMIC.getStateFromMeta(BlockMimic.sentientMimicMeta); world.setBlockState(pos, mimicState, 3); TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileMimic) - { + if (tile instanceof TileMimic) { TileMimic mimic = (TileMimic) tile; mimic.metaOfReplacedBlock = metaOfReplacedBlock; mimic.tileTag = tileTag; @@ -129,8 +111,7 @@ public class EntityMimic extends EntityDemonBase return false; } - public void initializeMimic(ItemStack heldStack, NBTTagCompound tileTag, boolean dropItemsOnBreak, int metaOfReplacedBlock, int playerCheckRadius, BlockPos homePosition) - { + public void initializeMimic(ItemStack heldStack, NBTTagCompound tileTag, boolean dropItemsOnBreak, int metaOfReplacedBlock, int playerCheckRadius, BlockPos homePosition) { this.setMimicItemStack(heldStack); this.tileTag = tileTag; this.dropItemsOnBreak = dropItemsOnBreak; @@ -139,29 +120,21 @@ public class EntityMimic extends EntityDemonBase this.setHomePosAndDistance(homePosition, 2); //TODO: Save this. } - public boolean reformIntoMimicBlock(BlockPos centerPos) - { + public boolean reformIntoMimicBlock(BlockPos centerPos) { int horizontalRadius = 1; int verticalRadius = 1; - for (int hR = 0; hR <= horizontalRadius; hR++) - { - for (int vR = 0; vR <= verticalRadius; vR++) - { - for (int i = -hR; i <= hR; i++) - { - for (int k = -hR; k <= hR; k++) - { - for (int j = -vR; j <= vR; j += 2 * vR + (vR > 0 ? 0 : 1)) - { - if (!(Math.abs(i) == hR || Math.abs(k) == hR)) - { + for (int hR = 0; hR <= horizontalRadius; hR++) { + for (int vR = 0; vR <= verticalRadius; vR++) { + for (int i = -hR; i <= hR; i++) { + for (int k = -hR; k <= hR; k++) { + for (int j = -vR; j <= vR; j += 2 * vR + (vR > 0 ? 0 : 1)) { + if (!(Math.abs(i) == hR || Math.abs(k) == hR)) { continue; } BlockPos newPos = centerPos.add(i, j, k); - if (spawnMimicBlockAtPosition(getEntityWorld(), newPos)) - { + if (spawnMimicBlockAtPosition(getEntityWorld(), newPos)) { return true; } } @@ -174,35 +147,26 @@ public class EntityMimic extends EntityDemonBase } @Override - public void onDeath(DamageSource cause) - { + public void onDeath(DamageSource cause) { super.onDeath(cause); - if (!getEntityWorld().isRemote) - { + if (!getEntityWorld().isRemote) { BlockPos centerPos = this.getPosition(); int horizontalRadius = 1; int verticalRadius = 1; - for (int hR = 0; hR <= horizontalRadius; hR++) - { - for (int vR = 0; vR <= verticalRadius; vR++) - { - for (int i = -hR; i <= hR; i++) - { - for (int k = -hR; k <= hR; k++) - { - for (int j = -vR; j <= vR; j += 2 * vR + (vR > 0 ? 0 : 1)) - { - if (!(Math.abs(i) == hR || Math.abs(k) == hR)) - { + for (int hR = 0; hR <= horizontalRadius; hR++) { + for (int vR = 0; vR <= verticalRadius; vR++) { + for (int i = -hR; i <= hR; i++) { + for (int k = -hR; k <= hR; k++) { + for (int j = -vR; j <= vR; j += 2 * vR + (vR > 0 ? 0 : 1)) { + if (!(Math.abs(i) == hR || Math.abs(k) == hR)) { continue; } BlockPos newPos = centerPos.add(i, j, k); - if (spawnHeldBlockOnDeath(getEntityWorld(), newPos)) - { + if (spawnHeldBlockOnDeath(getEntityWorld(), newPos)) { return; } } @@ -218,8 +182,7 @@ public class EntityMimic extends EntityDemonBase * this one. */ @Override - public double getMountedYOffset() - { + public double getMountedYOffset() { return (double) (this.height * 0.5F); } @@ -227,14 +190,12 @@ public class EntityMimic extends EntityDemonBase * Returns new PathNavigateGround instance */ @Override - protected PathNavigate createNavigator(World worldIn) - { + protected PathNavigate createNavigator(World worldIn) { return new PathNavigateClimber(this, worldIn); } @Override - protected void entityInit() - { + protected void entityInit() { super.entityInit(); this.dataManager.register(CLIMBING, (byte) 0); // this.dataManager.register(ITEMSTACK, null); @@ -244,53 +205,44 @@ public class EntityMimic extends EntityDemonBase * Called to update the entity's position/logic. */ @Override - public void onUpdate() - { - if (!this.getEntityWorld().isRemote && this.getEntityWorld().getDifficulty() == EnumDifficulty.PEACEFUL) - { - if (reformIntoMimicBlock(this.getPosition())) - { + public void onUpdate() { + if (!this.getEntityWorld().isRemote && this.getEntityWorld().getDifficulty() == EnumDifficulty.PEACEFUL) { + if (reformIntoMimicBlock(this.getPosition())) { this.setDead(); } } super.onUpdate(); - if (!this.getEntityWorld().isRemote) - { + if (!this.getEntityWorld().isRemote) { this.setBesideClimbableBlock(this.isCollidedHorizontally); } } @Override - protected void applyEntityAttributes() - { + protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(16.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3D); } @Override - protected SoundEvent getAmbientSound() - { + protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_SPIDER_AMBIENT; } @Override - protected SoundEvent getHurtSound() - { + protected SoundEvent getHurtSound() { return SoundEvents.ENTITY_SPIDER_HURT; } @Override - protected SoundEvent getDeathSound() - { + protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_SPIDER_DEATH; } @Override - protected void playStepSound(BlockPos pos, Block blockIn) - { + protected void playStepSound(BlockPos pos, Block blockIn) { this.playSound(SoundEvents.ENTITY_SPIDER_STEP, 0.15F, 1.0F); } @@ -298,8 +250,7 @@ public class EntityMimic extends EntityDemonBase * returns true if this entity is by a ladder, false otherwise */ @Override - public boolean isOnLadder() - { + public boolean isOnLadder() { return this.isBesideClimbableBlock(); } @@ -307,8 +258,7 @@ public class EntityMimic extends EntityDemonBase * Sets the Entity inside a web block. */ @Override - public void setInWeb() - { + public void setInWeb() { } @@ -316,14 +266,12 @@ public class EntityMimic extends EntityDemonBase * Get this Entity's EnumCreatureAttribute */ @Override - public EnumCreatureAttribute getCreatureAttribute() - { + public EnumCreatureAttribute getCreatureAttribute() { return EnumCreatureAttribute.ARTHROPOD; } @Override - public boolean isPotionApplicable(PotionEffect potioneffectIn) - { + public boolean isPotionApplicable(PotionEffect potioneffectIn) { return potioneffectIn.getPotion() != MobEffects.POISON && super.isPotionApplicable(potioneffectIn); } @@ -331,8 +279,7 @@ public class EntityMimic extends EntityDemonBase * Returns true if the WatchableObject (Byte) is 0x01 otherwise returns * false. The WatchableObject is updated using setBesideClimableBlock. */ - public boolean isBesideClimbableBlock() - { + public boolean isBesideClimbableBlock() { return (this.dataManager.get(CLIMBING) & 1) != 0; } @@ -340,44 +287,35 @@ public class EntityMimic extends EntityDemonBase * Updates the WatchableObject (Byte) created in entityInit(), setting it to * 0x01 if par1 is true or 0x00 if it is false. */ - public void setBesideClimbableBlock(boolean climbing) - { + public void setBesideClimbableBlock(boolean climbing) { byte b0 = this.dataManager.get(CLIMBING); - if (climbing) - { + if (climbing) { b0 = (byte) (b0 | 1); - } else - { + } else { b0 = (byte) (b0 & -2); } this.dataManager.set(CLIMBING, b0); } - public float getEyeHeight() - { + public float getEyeHeight() { return 0.65F; } - static class AISpiderAttack extends EntityAIAttackMelee - { - public AISpiderAttack(EntityMimic spider) - { + static class AISpiderAttack extends EntityAIAttackMelee { + public AISpiderAttack(EntityMimic spider) { super(spider, 1.0D, true); } @Override - protected double getAttackReachSqr(EntityLivingBase attackTarget) - { + protected double getAttackReachSqr(EntityLivingBase attackTarget) { return (double) (4.0F + attackTarget.width); } } - static class AISpiderTarget extends EntityAINearestAttackableTarget - { - public AISpiderTarget(EntityMimic spider, Class classTarget) - { + static class AISpiderTarget extends EntityAINearestAttackableTarget { + public AISpiderTarget(EntityMimic spider, Class classTarget) { super(spider, classTarget, true); } } diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntitySentientSpecter.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntitySentientSpecter.java index 670addf3..95557f14 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntitySentientSpecter.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntitySentientSpecter.java @@ -1,21 +1,22 @@ package WayofTime.bloodmagic.entity.mob; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; +import WayofTime.bloodmagic.entity.ai.EntityAIAttackRangedBow; +import WayofTime.bloodmagic.entity.ai.EntityAIFollowOwner; +import WayofTime.bloodmagic.entity.ai.*; +import WayofTime.bloodmagic.entity.ai.EntityAIOwnerHurtByTarget; +import WayofTime.bloodmagic.entity.ai.EntityAIOwnerHurtTarget; +import WayofTime.bloodmagic.item.soul.ItemSentientBow; import net.minecraft.block.Block; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.EntityAIAttackMelee; -import net.minecraft.entity.ai.EntityAILookIdle; -import net.minecraft.entity.ai.EntityAINearestAttackableTarget; -import net.minecraft.entity.ai.EntityAISwimming; -import net.minecraft.entity.ai.EntityAIWander; -import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.*; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.monster.EntityGhast; import net.minecraft.entity.player.EntityPlayer; @@ -39,31 +40,19 @@ import net.minecraft.world.EnumDifficulty; import net.minecraft.world.Explosion; import net.minecraft.world.World; import net.minecraft.world.WorldServer; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -import WayofTime.bloodmagic.entity.ai.EntityAIAttackRangedBow; -import WayofTime.bloodmagic.entity.ai.EntityAIFollowOwner; -import WayofTime.bloodmagic.entity.ai.EntityAIGrabEffectsFromOwner; -import WayofTime.bloodmagic.entity.ai.EntityAIHurtByTargetIgnoreTamed; -import WayofTime.bloodmagic.entity.ai.EntityAIOwnerHurtByTarget; -import WayofTime.bloodmagic.entity.ai.EntityAIOwnerHurtTarget; -import WayofTime.bloodmagic.entity.ai.EntityAIRetreatToHeal; -import WayofTime.bloodmagic.item.soul.ItemSentientBow; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -public class EntitySentientSpecter extends EntityDemonBase -{ +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +public class EntitySentientSpecter extends EntityDemonBase { + private final EntityAIAttackRangedBow aiArrowAttack = new EntityAIAttackRangedBow(this, 1.0D, 20, 15.0F); + private final EntityAIAttackMelee aiAttackOnCollide = new EntityAIAttackMelee(this, 1.0D, false); + private final int attackPriority = 3; protected EnumDemonWillType type = EnumDemonWillType.DESTRUCTIVE; protected boolean wasGivenSentientArmour = false; - private final EntityAIAttackRangedBow aiArrowAttack = new EntityAIAttackRangedBow(this, 1.0D, 20, 15.0F); - private final EntityAIAttackMelee aiAttackOnCollide = new EntityAIAttackMelee(this, 1.0D, false); - - private final int attackPriority = 3; - - public EntitySentientSpecter(World worldIn) - { + public EntitySentientSpecter(World worldIn) { super(worldIn); this.setSize(0.6F, 1.95F); // ((PathNavigateGround) getNavigator()).setCanSwim(false); @@ -87,8 +76,7 @@ public class EntitySentientSpecter extends EntityDemonBase } @Override - protected void applyEntityAttributes() - { + protected void applyEntityAttributes() { super.applyEntityAttributes(); getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(40.0D); getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D); @@ -96,27 +84,22 @@ public class EntitySentientSpecter extends EntityDemonBase } @Override - public void setCombatTask() - { - if (!this.getEntityWorld().isRemote) - { + public void setCombatTask() { + if (!this.getEntityWorld().isRemote) { this.tasks.removeTask(this.aiAttackOnCollide); this.tasks.removeTask(this.aiArrowAttack); ItemStack itemstack = this.getHeldItemMainhand(); - if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow) - { + if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow) { int i = 20; - if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD) - { + if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD) { i = 40; } this.aiArrowAttack.setAttackCooldown(i); this.tasks.addTask(attackPriority, this.aiArrowAttack); - } else - { + } else { this.tasks.addTask(attackPriority, this.aiAttackOnCollide); } } @@ -130,22 +113,17 @@ public class EntitySentientSpecter extends EntityDemonBase return !(potion == MobEffects.REGENERATION || potion == MobEffects.INSTANT_HEALTH) && super.isPotionApplicable(effect); } - public boolean canStealEffectFromOwner(EntityLivingBase owner, PotionEffect effect) - { + public boolean canStealEffectFromOwner(EntityLivingBase owner, PotionEffect effect) { return effect.getPotion().isBadEffect() && this.type == EnumDemonWillType.CORROSIVE; } - public boolean canStealEffectFromOwner(EntityLivingBase owner) - { - if (this.type != EnumDemonWillType.CORROSIVE) - { + public boolean canStealEffectFromOwner(EntityLivingBase owner) { + if (this.type != EnumDemonWillType.CORROSIVE) { return false; } - for (PotionEffect eff : owner.getActivePotionEffects()) - { - if (canStealEffectFromOwner(owner, eff)) - { + for (PotionEffect eff : owner.getActivePotionEffects()) { + if (canStealEffectFromOwner(owner, eff)) { return true; } } @@ -153,10 +131,8 @@ public class EntitySentientSpecter extends EntityDemonBase return false; } - public boolean stealEffectsFromOwner(EntityLivingBase owner) - { - if (this.type != EnumDemonWillType.CORROSIVE) - { + public boolean stealEffectsFromOwner(EntityLivingBase owner) { + if (this.type != EnumDemonWillType.CORROSIVE) { return false; } @@ -164,17 +140,14 @@ public class EntitySentientSpecter extends EntityDemonBase List removedEffects = new ArrayList(); - for (PotionEffect eff : owner.getActivePotionEffects()) - { - if (canStealEffectFromOwner(owner, eff)) - { + for (PotionEffect eff : owner.getActivePotionEffects()) { + if (canStealEffectFromOwner(owner, eff)) { removedEffects.add(eff); hasStolenEffect = true; } } - for (PotionEffect eff : removedEffects) - { + for (PotionEffect eff : removedEffects) { owner.removePotionEffect(eff.getPotion()); this.addPotionEffect(eff); } @@ -182,23 +155,17 @@ public class EntitySentientSpecter extends EntityDemonBase return hasStolenEffect; } - public boolean applyNegativeEffectsToAttacked(EntityLivingBase attackedEntity, float percentTransmitted) - { + public boolean applyNegativeEffectsToAttacked(EntityLivingBase attackedEntity, float percentTransmitted) { boolean hasProvidedEffect = false; List removedEffects = new ArrayList(); - for (PotionEffect eff : this.getActivePotionEffects()) - { - if (eff.getPotion().isBadEffect() && attackedEntity.isPotionApplicable(eff)) - { - if (!attackedEntity.isPotionActive(eff.getPotion())) - { + for (PotionEffect eff : this.getActivePotionEffects()) { + if (eff.getPotion().isBadEffect() && attackedEntity.isPotionApplicable(eff)) { + if (!attackedEntity.isPotionActive(eff.getPotion())) { removedEffects.add(eff); hasProvidedEffect = true; - } else - { + } else { PotionEffect activeEffect = attackedEntity.getActivePotionEffect(eff.getPotion()); - if (activeEffect.getAmplifier() < eff.getAmplifier() || activeEffect.getDuration() < eff.getDuration() * percentTransmitted) - { + if (activeEffect.getAmplifier() < eff.getAmplifier() || activeEffect.getDuration() < eff.getDuration() * percentTransmitted) { removedEffects.add(eff); hasProvidedEffect = true; } @@ -206,18 +173,15 @@ public class EntitySentientSpecter extends EntityDemonBase } } - for (PotionEffect eff : removedEffects) - { - if (!attackedEntity.isPotionActive(eff.getPotion())) - { + for (PotionEffect eff : removedEffects) { + if (!attackedEntity.isPotionActive(eff.getPotion())) { PotionEffect newEffect = new PotionEffect(eff.getPotion(), (int) (eff.getDuration() * percentTransmitted), eff.getAmplifier(), eff.getIsAmbient(), eff.doesShowParticles()); attackedEntity.addPotionEffect(newEffect); PotionEffect newSentientEffect = new PotionEffect(eff.getPotion(), (int) (eff.getDuration() * (1 - percentTransmitted)), eff.getAmplifier(), eff.getIsAmbient(), eff.doesShowParticles()); this.removePotionEffect(eff.getPotion()); this.addPotionEffect(newSentientEffect); - } else - { + } else { PotionEffect activeEffect = attackedEntity.getActivePotionEffect(eff.getPotion()); PotionEffect newEffect = new PotionEffect(eff.getPotion(), (int) (eff.getDuration() * percentTransmitted), eff.getAmplifier(), activeEffect.getIsAmbient(), activeEffect.doesShowParticles()); @@ -232,26 +196,21 @@ public class EntitySentientSpecter extends EntityDemonBase return hasProvidedEffect; } - public List getPotionEffectsForArrowRemovingDuration(float percentTransmitted) - { + public List getPotionEffectsForArrowRemovingDuration(float percentTransmitted) { List arrowEffects = new ArrayList(); - if (type != EnumDemonWillType.CORROSIVE) - { + if (type != EnumDemonWillType.CORROSIVE) { return arrowEffects; } List removedEffects = new ArrayList(); - for (PotionEffect eff : this.getActivePotionEffects()) - { - if (eff.getPotion().isBadEffect()) - { + for (PotionEffect eff : this.getActivePotionEffects()) { + if (eff.getPotion().isBadEffect()) { removedEffects.add(eff); } } - for (PotionEffect eff : removedEffects) - { + for (PotionEffect eff : removedEffects) { PotionEffect newEffect = new PotionEffect(eff.getPotion(), (int) (eff.getDuration() * percentTransmitted), eff.getAmplifier(), eff.getIsAmbient(), eff.doesShowParticles()); arrowEffects.add(newEffect); @@ -264,8 +223,7 @@ public class EntitySentientSpecter extends EntityDemonBase } @Override - public boolean attackEntityFrom(DamageSource source, float amount) - { + public boolean attackEntityFrom(DamageSource source, float amount) { return !this.isEntityInvulnerable(source) && super.attackEntityFrom(source, amount); } @@ -273,47 +231,38 @@ public class EntitySentientSpecter extends EntityDemonBase * Redone from EntityMob to prevent despawning on peaceful. */ @Override - public boolean attackEntityAsMob(Entity attackedEntity) - { + public boolean attackEntityAsMob(Entity attackedEntity) { boolean flag = super.attackEntityAsMob(attackedEntity); - if (flag) - { - if (this.type == EnumDemonWillType.CORROSIVE && attackedEntity instanceof EntityLivingBase) - { + if (flag) { + if (this.type == EnumDemonWillType.CORROSIVE && attackedEntity instanceof EntityLivingBase) { // ((EntityLivingBase) attackedEntity).addPotionEffect(new PotionEffect(MobEffects.WITHER, 200)); applyNegativeEffectsToAttacked((EntityLivingBase) attackedEntity, 1); } return true; - } else - { + } else { return false; } } @Override - public void onDeath(DamageSource cause) - { + public void onDeath(DamageSource cause) { super.onDeath(cause); - if (!getEntityWorld().isRemote && !getHeldItemMainhand().isEmpty()) - { + if (!getEntityWorld().isRemote && !getHeldItemMainhand().isEmpty()) { this.entityDropItem(getHeldItemMainhand(), 0); } } @Override - public boolean isStationary() - { + public boolean isStationary() { return false; } @Override - public boolean absorbExplosion(Explosion explosion) - { - if (this.type == EnumDemonWillType.DESTRUCTIVE) - { + public boolean absorbExplosion(Explosion explosion) { + if (this.type == EnumDemonWillType.DESTRUCTIVE) { this.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 600, 1)); explosion.doExplosionB(true); @@ -325,27 +274,21 @@ public class EntitySentientSpecter extends EntityDemonBase } @Override - public boolean processInteract(EntityPlayer player, EnumHand hand) - { + public boolean processInteract(EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if (this.isTamed() && player.equals(this.getOwner()) && hand == EnumHand.MAIN_HAND) - { + if (this.isTamed() && player.equals(this.getOwner()) && hand == EnumHand.MAIN_HAND) { if (stack.isEmpty() && player.isSneaking()) //Should return to the entity { - if (!getEntityWorld().isRemote) - { - if (!getHeldItemMainhand().isEmpty()) - { + if (!getEntityWorld().isRemote) { + if (!getHeldItemMainhand().isEmpty()) { this.entityDropItem(getHeldItemMainhand(), 0); } - if (!getHeldItemOffhand().isEmpty()) - { + if (!getHeldItemOffhand().isEmpty()) { this.entityDropItem(getHeldItemOffhand(), 0); } - if (wasGivenSentientArmour) - { + if (wasGivenSentientArmour) { this.entityDropItem(new ItemStack(RegistrarBloodMagicItems.SENTIENT_ARMOUR_GEM), 0); } @@ -357,46 +300,38 @@ public class EntitySentientSpecter extends EntityDemonBase return super.processInteract(player, hand); } - public boolean isEntityInvulnerable(DamageSource source) - { + public boolean isEntityInvulnerable(DamageSource source) { return super.isEntityInvulnerable(source) && (this.type == EnumDemonWillType.DESTRUCTIVE && source.isExplosion()); } @Override - public void performEmergencyHeal(double toHeal) - { + public void performEmergencyHeal(double toHeal) { this.heal((float) toHeal); - if (getEntityWorld() instanceof WorldServer) - { + if (getEntityWorld() instanceof WorldServer) { 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]); } } /** - * * @param toHeal * @return Amount of Will consumed from the Aura to heal */ - public double absorbWillFromAuraToHeal(double toHeal) - { - if (getEntityWorld().isRemote) - { + public double absorbWillFromAuraToHeal(double toHeal) { + if (getEntityWorld().isRemote) { return 0; } double healthMissing = this.getMaxHealth() - this.getHealth(); - if (healthMissing <= 0) - { + if (healthMissing <= 0) { return 0; } double will = WorldDemonWillHandler.getCurrentWill(getEntityWorld(), getPosition(), getType()); toHeal = Math.min(healthMissing, Math.min(toHeal, will / getWillToHealth())); - if (toHeal > 0) - { + if (toHeal > 0) { this.heal((float) toHeal); return WorldDemonWillHandler.drainWill(getEntityWorld(), getPosition(), getType(), toHeal * getWillToHealth(), true); } @@ -404,21 +339,17 @@ public class EntitySentientSpecter extends EntityDemonBase return 0; } - public double getWillToHealth() - { + public double getWillToHealth() { return 2; } @Override - protected boolean canDespawn() - { + protected boolean canDespawn() { return !this.isTamed() && super.canDespawn(); } - public void onUpdate() - { - if (!this.getEntityWorld().isRemote && this.ticksExisted % 20 == 0) - { + public void onUpdate() { + if (!this.getEntityWorld().isRemote && this.ticksExisted % 20 == 0) { absorbWillFromAuraToHeal(2); } @@ -426,8 +357,7 @@ public class EntitySentientSpecter extends EntityDemonBase } @Override - public void writeEntityToNBT(NBTTagCompound tag) - { + public void writeEntityToNBT(NBTTagCompound tag) { super.writeEntityToNBT(tag); tag.setString(Constants.NBT.WILL_TYPE, type.toString()); @@ -436,15 +366,12 @@ public class EntitySentientSpecter extends EntityDemonBase } @Override - public void readEntityFromNBT(NBTTagCompound tag) - { + public void readEntityFromNBT(NBTTagCompound tag) { super.readEntityFromNBT(tag); - if (!tag.hasKey(Constants.NBT.WILL_TYPE)) - { + if (!tag.hasKey(Constants.NBT.WILL_TYPE)) { type = EnumDemonWillType.DEFAULT; - } else - { + } else { type = EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH)); } @@ -455,37 +382,29 @@ public class EntitySentientSpecter extends EntityDemonBase //TODO: Change to fit the given AI @Override - public boolean shouldAttackEntity(EntityLivingBase attacker, EntityLivingBase owner) - { - if (!(attacker instanceof EntityCreeper) && !(attacker instanceof EntityGhast)) - { + public boolean shouldAttackEntity(EntityLivingBase attacker, EntityLivingBase owner) { + if (!(attacker instanceof EntityCreeper) && !(attacker instanceof EntityGhast)) { return super.shouldAttackEntity(attacker, owner); - } else - { + } else { return false; } } @Override - public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity) - { + public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity) { ItemStack heldStack = this.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND); - if (!heldStack.isEmpty() && heldStack.getItem() == RegistrarBloodMagicItems.SENTIENT_BOW) - { + if (!heldStack.isEmpty() && heldStack.getItem() == RegistrarBloodMagicItems.SENTIENT_BOW) { EntityTippedArrow arrowEntity = ((ItemSentientBow) heldStack.getItem()).getArrowEntity(getEntityWorld(), heldStack, target, this, velocity); - if (arrowEntity != null) - { + if (arrowEntity != null) { List effects = getPotionEffectsForArrowRemovingDuration(0.2f); - for (PotionEffect eff : effects) - { + for (PotionEffect eff : effects) { arrowEntity.addEffect(eff); } this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.getEntityWorld().spawnEntity(arrowEntity); } - } else - { + } else { 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; @@ -496,21 +415,18 @@ public class EntitySentientSpecter extends EntityDemonBase int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this); entitytippedarrow.setDamage((double) (velocity * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.getEntityWorld().getDifficulty().getDifficultyId() * 0.11F)); - if (i > 0) - { + if (i > 0) { entitytippedarrow.setDamage(entitytippedarrow.getDamage() + (double) i * 0.5D + 0.5D); } - if (j > 0) - { + if (j > 0) { entitytippedarrow.setKnockbackStrength(j); } boolean burning = this.isBurning(); burning = burning || EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FLAME, this) > 0; - if (burning) - { + if (burning) { entitytippedarrow.setFire(100); } @@ -525,26 +441,22 @@ public class EntitySentientSpecter extends EntityDemonBase } @Override - protected SoundEvent getAmbientSound() - { + protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_COW_AMBIENT; } @Override - protected SoundEvent getHurtSound() - { + protected SoundEvent getHurtSound() { return SoundEvents.ENTITY_COW_HURT; } @Override - protected SoundEvent getDeathSound() - { + protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_COW_DEATH; } @Override - protected void playStepSound(BlockPos pos, Block block) - { + protected void playStepSound(BlockPos pos, Block block) { this.playSound(SoundEvents.ENTITY_COW_STEP, 0.15F, 1.0F); } @@ -552,8 +464,7 @@ public class EntitySentientSpecter extends EntityDemonBase * Returns the volume for the sounds this mob makes. */ @Override - protected float getSoundVolume() - { + protected float getSoundVolume() { return 0.4F; } diff --git a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityBloodLight.java b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityBloodLight.java index 534f94dc..712a9f98 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityBloodLight.java +++ b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityBloodLight.java @@ -8,7 +8,8 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.*; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; @@ -16,27 +17,23 @@ import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.common.registry.IThrowableEntity; -public class EntityBloodLight extends EntityThrowable implements IThrowableEntity, IEntityAdditionalSpawnData -{ +public class EntityBloodLight extends EntityThrowable implements IThrowableEntity, IEntityAdditionalSpawnData { public EntityLivingBase shootingEntity; protected int ticksInAir = 0; protected int maxTicksInAir = 600; - public EntityBloodLight(World world) - { + public EntityBloodLight(World world) { super(world); this.setSize(0.5F, 0.5F); } - public EntityBloodLight(World world, double x, double y, double z) - { + public EntityBloodLight(World world, double x, double y, double z) { super(world); this.setSize(0.5F, 0.5F); this.setPosition(x, y, z); } - public EntityBloodLight(World world, EntityLivingBase player) - { + public EntityBloodLight(World world, EntityLivingBase player) { super(world, player); shootingEntity = player; float par3 = 0.8F; @@ -53,14 +50,12 @@ public class EntityBloodLight extends EntityThrowable implements IThrowableEntit } @Override - protected float getGravityVelocity() - { + protected float getGravityVelocity() { return 0F; } @Override - public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8) - { + public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8) { float var9 = MathHelper.sqrt(var1 * var1 + var3 * var3 + var5 * var5); var1 /= var9; var3 /= var9; @@ -80,33 +75,26 @@ public class EntityBloodLight extends EntityThrowable implements IThrowableEntit } @Override - public void onUpdate() - { + public void onUpdate() { super.onUpdate(); - if (this.ticksExisted > this.maxTicksInAir) - { + if (this.ticksExisted > this.maxTicksInAir) { setDead(); } } @Override - protected void onImpact(RayTraceResult mop) - { - if (mop.typeOfHit == RayTraceResult.Type.ENTITY && mop.entityHit != null) - { - if (mop.entityHit == shootingEntity) - { + protected void onImpact(RayTraceResult mop) { + if (mop.typeOfHit == RayTraceResult.Type.ENTITY && mop.entityHit != null) { + if (mop.entityHit == shootingEntity) { return; } this.onImpact(mop.entityHit); - } else if (mop.typeOfHit == RayTraceResult.Type.BLOCK) - { + } else if (mop.typeOfHit == RayTraceResult.Type.BLOCK) { EnumFacing sideHit = mop.sideHit; BlockPos blockPos = mop.getBlockPos().offset(sideHit); - if (getEntityWorld().isAirBlock(blockPos)) - { + if (getEntityWorld().isAirBlock(blockPos)) { getEntityWorld().setBlockState(blockPos, RegistrarBloodMagicBlocks.BLOOD_LIGHT.getDefaultState()); } } @@ -114,23 +102,18 @@ public class EntityBloodLight extends EntityThrowable implements IThrowableEntit this.setDead(); } - protected void onImpact(Entity mop) - { - if (mop == shootingEntity && ticksInAir > 3) - { + protected void onImpact(Entity mop) { + if (mop == shootingEntity && ticksInAir > 3) { shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1); this.setDead(); - } else - { - if (mop instanceof EntityLivingBase) - { + } else { + if (mop instanceof EntityLivingBase) { ((EntityLivingBase) mop).setRevengeTarget(shootingEntity); doDamage(1, mop); } } - if (getEntityWorld().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))) { getEntityWorld().setBlockState(new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ), Blocks.FIRE.getDefaultState()); } @@ -138,59 +121,50 @@ public class EntityBloodLight extends EntityThrowable implements IThrowableEntit this.setDead(); } - protected void doDamage(int i, Entity mop) - { + protected void doDamage(int i, Entity mop) { mop.attackEntityFrom(this.getDamageSource(), i); } - public DamageSource getDamageSource() - { + public DamageSource getDamageSource() { return DamageSource.causeMobDamage(shootingEntity); } @Override - public void writeSpawnData(ByteBuf data) - { + public void writeSpawnData(ByteBuf data) { data.writeByte(this.ticksInAir); } @Override - public void readSpawnData(ByteBuf data) - { + public void readSpawnData(ByteBuf data) { this.ticksInAir = data.readByte(); } @Override - public void writeEntityToNBT(NBTTagCompound nbt) - { + public void writeEntityToNBT(NBTTagCompound nbt) { super.writeEntityToNBT(nbt); nbt.setInteger(Constants.NBT.PROJECTILE_TICKS_IN_AIR, ticksInAir); nbt.setInteger(Constants.NBT.PROJECTILE_MAX_TICKS_IN_AIR, maxTicksInAir); } @Override - public void readEntityFromNBT(NBTTagCompound nbt) - { + public void readEntityFromNBT(NBTTagCompound nbt) { super.readEntityFromNBT(nbt); ticksInAir = nbt.getInteger(Constants.NBT.PROJECTILE_TICKS_IN_AIR); maxTicksInAir = nbt.getInteger(Constants.NBT.PROJECTILE_MAX_TICKS_IN_AIR); } @Override - protected boolean canTriggerWalking() - { + protected boolean canTriggerWalking() { return false; } @Override - public boolean canBeCollidedWith() - { + public boolean canBeCollidedWith() { return false; } @Override - public void setThrower(Entity entity) - { + public void setThrower(Entity entity) { if (entity instanceof EntityLivingBase) this.shootingEntity = (EntityLivingBase) entity; } diff --git a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityMeteor.java b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityMeteor.java index 51e4aee6..bfbbe0e8 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityMeteor.java +++ b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityMeteor.java @@ -1,5 +1,7 @@ package WayofTime.bloodmagic.entity.projectile; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.meteor.MeteorRegistry; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.projectile.EntityThrowable; @@ -11,27 +13,20 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.IThrowableEntity; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.meteor.MeteorRegistry; -public class EntityMeteor extends EntityThrowable implements IThrowableEntity -{ +public class EntityMeteor extends EntityThrowable implements IThrowableEntity { + public ItemStack meteorStack = ItemStack.EMPTY; protected int ticksInAir = 0; protected int maxTicksInAir = 600; - protected double radiusModifier = 1; protected double explosionModifier = 1; protected double fillerChance = 0; - public ItemStack meteorStack = ItemStack.EMPTY; - - public EntityMeteor(World world) - { + public EntityMeteor(World world) { super(world); } - public EntityMeteor(World world, double x, double y, double z, double velX, double velY, double velZ, double radiusModifier, double explosionModifier, double fillerChance) - { + public EntityMeteor(World world, double x, double y, double z, double velX, double velY, double velZ, double radiusModifier, double explosionModifier, double fillerChance) { super(world); this.setSize(1F, 1F); this.setPosition(x, y, z); @@ -44,39 +39,31 @@ public class EntityMeteor extends EntityThrowable implements IThrowableEntity } @Override - protected float getGravityVelocity() - { + protected float getGravityVelocity() { return 0.03F; } @Override - public void onUpdate() - { + public void onUpdate() { super.onUpdate(); - if (this.ticksExisted > this.maxTicksInAir) - { + if (this.ticksExisted > this.maxTicksInAir) { setDead(); } } @Override - protected void onImpact(RayTraceResult mop) - { - if (mop.typeOfHit == RayTraceResult.Type.ENTITY && mop.entityHit != null) - { + protected void onImpact(RayTraceResult mop) { + if (mop.typeOfHit == RayTraceResult.Type.ENTITY && mop.entityHit != null) { this.onImpact(mop.entityHit); - } else if (mop.typeOfHit == RayTraceResult.Type.BLOCK) - { + } else if (mop.typeOfHit == RayTraceResult.Type.BLOCK) { generateMeteor(mop.getBlockPos()); } this.setDead(); } - protected void onImpact(Entity mop) - { - if (mop instanceof EntityLivingBase) - { + protected void onImpact(Entity mop) { + if (mop instanceof EntityLivingBase) { doDamage(100, mop); } @@ -86,24 +73,20 @@ public class EntityMeteor extends EntityThrowable implements IThrowableEntity this.setDead(); } - protected void doDamage(int i, Entity mop) - { + protected void doDamage(int i, Entity mop) { mop.attackEntityFrom(this.getDamageSource(), i); } - public void generateMeteor(BlockPos pos) - { + public void generateMeteor(BlockPos pos) { MeteorRegistry.generateMeteorForItem(meteorStack, getEntityWorld(), pos, Blocks.STONE.getDefaultState(), radiusModifier, explosionModifier, fillerChance); } - public DamageSource getDamageSource() - { + public DamageSource getDamageSource() { return DamageSource.ANVIL; } @Override - public void writeEntityToNBT(NBTTagCompound nbt) - { + public void writeEntityToNBT(NBTTagCompound nbt) { super.writeEntityToNBT(nbt); nbt.setInteger(Constants.NBT.PROJECTILE_TICKS_IN_AIR, ticksInAir); nbt.setInteger(Constants.NBT.PROJECTILE_MAX_TICKS_IN_AIR, maxTicksInAir); @@ -117,8 +100,7 @@ public class EntityMeteor extends EntityThrowable implements IThrowableEntity } @Override - public void readEntityFromNBT(NBTTagCompound nbt) - { + public void readEntityFromNBT(NBTTagCompound nbt) { super.readEntityFromNBT(nbt); ticksInAir = nbt.getInteger(Constants.NBT.PROJECTILE_TICKS_IN_AIR); maxTicksInAir = nbt.getInteger(Constants.NBT.PROJECTILE_MAX_TICKS_IN_AIR); @@ -132,20 +114,17 @@ public class EntityMeteor extends EntityThrowable implements IThrowableEntity } @Override - protected boolean canTriggerWalking() - { + protected boolean canTriggerWalking() { return false; } @Override - public boolean canBeCollidedWith() - { + public boolean canBeCollidedWith() { return false; } @Override - public void setThrower(Entity entity) - { + public void setThrower(Entity entity) { } diff --git a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java index c6cf622f..8946d035 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java +++ b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java @@ -1,5 +1,8 @@ package WayofTime.bloodmagic.entity.projectile; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.player.EntityPlayer; @@ -9,40 +12,30 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; import java.util.Locale; -public class EntitySentientArrow extends EntityTippedArrow -{ +public class EntitySentientArrow extends EntityTippedArrow { public double reimbursedAmountOnHit = 0; public EnumDemonWillType type = EnumDemonWillType.DEFAULT; - public EntitySentientArrow(World worldIn) - { + public EntitySentientArrow(World worldIn) { super(worldIn); } - public EntitySentientArrow(World worldIn, double x, double y, double z) - { + public EntitySentientArrow(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } - public EntitySentientArrow(World worldIn, EntityLivingBase shooter, EnumDemonWillType type, double reinburseAmount) - { + public EntitySentientArrow(World worldIn, EntityLivingBase shooter, EnumDemonWillType type, double reinburseAmount) { super(worldIn, shooter); this.reimbursedAmountOnHit = reinburseAmount; this.type = type; } - public void reimbursePlayer(EntityLivingBase hitEntity, float damage) - { - if (this.shootingEntity instanceof EntityPlayer) - { - if (hitEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(hitEntity instanceof IMob)) - { + public void reimbursePlayer(EntityLivingBase hitEntity, float damage) { + if (this.shootingEntity instanceof EntityPlayer) { + if (hitEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(hitEntity instanceof IMob)) { return; } @@ -51,8 +44,7 @@ public class EntitySentientArrow extends EntityTippedArrow } @Override - public void writeEntityToNBT(NBTTagCompound tag) - { + public void writeEntityToNBT(NBTTagCompound tag) { super.writeEntityToNBT(tag); tag.setDouble("reimbursement", reimbursedAmountOnHit); @@ -60,8 +52,7 @@ public class EntitySentientArrow extends EntityTippedArrow } @Override - public void readEntityFromNBT(NBTTagCompound tag) - { + public void readEntityFromNBT(NBTTagCompound tag) { super.readEntityFromNBT(tag); reimbursedAmountOnHit = tag.getDouble("reimbursement"); @@ -69,8 +60,7 @@ public class EntitySentientArrow extends EntityTippedArrow } @Override - protected ItemStack getArrowStack() - { + protected ItemStack getArrowStack() { return new ItemStack(Items.ARROW); } } diff --git a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySoulSnare.java b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySoulSnare.java index efbfb5c4..2be580f8 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySoulSnare.java +++ b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySoulSnare.java @@ -9,20 +9,16 @@ import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; -public class EntitySoulSnare extends EntityThrowable -{ - public EntitySoulSnare(World worldIn) - { +public class EntitySoulSnare extends EntityThrowable { + public EntitySoulSnare(World worldIn) { super(worldIn); } - public EntitySoulSnare(World worldIn, EntityLivingBase throwerIn) - { + public EntitySoulSnare(World worldIn, EntityLivingBase throwerIn) { super(worldIn, throwerIn); } - public EntitySoulSnare(World worldIn, double x, double y, double z) - { + public EntitySoulSnare(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } @@ -30,30 +26,24 @@ public class EntitySoulSnare extends EntityThrowable * Called when this EntityThrowable hits a block or entity. */ @Override - protected void onImpact(RayTraceResult result) - { - if (result.entityHit == this.getThrower() && this.ticksExisted < 20) - { + protected void onImpact(RayTraceResult result) { + if (result.entityHit == this.getThrower() && this.ticksExisted < 20) { return; } - if (result.entityHit != null && result.entityHit != this.getThrower()) - { - if (result.entityHit instanceof EntityLivingBase && result.entityHit.getEntityWorld().rand.nextDouble() < 0.25) - { + if (result.entityHit != null && result.entityHit != this.getThrower()) { + if (result.entityHit instanceof EntityLivingBase && result.entityHit.getEntityWorld().rand.nextDouble() < 0.25) { ((EntityLivingBase) result.entityHit).addPotionEffect(new PotionEffect(RegistrarBloodMagic.SOUL_SNARE, 300, 0)); } result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float) 0); } - for (int j = 0; j < 8; ++j) - { + for (int j = 0; j < 8; ++j) { this.getEntityWorld().spawnParticle(EnumParticleTypes.SNOWBALL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } - if (!this.getEntityWorld().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 7fba5008..eb33e3fe 100644 --- a/src/main/java/WayofTime/bloodmagic/fakePlayer/FakeNetHandlerPlayServer.java +++ b/src/main/java/WayofTime/bloodmagic/fakePlayer/FakeNetHandlerPlayServer.java @@ -15,182 +15,146 @@ import java.util.Set; /** * All credits for this go to CrazyPants, from EIO */ -public class FakeNetHandlerPlayServer extends NetHandlerPlayServer -{ - public FakeNetHandlerPlayServer(EntityPlayerMP p_i1530_3_) - { +public class FakeNetHandlerPlayServer extends NetHandlerPlayServer { + public FakeNetHandlerPlayServer(EntityPlayerMP p_i1530_3_) { super(FMLCommonHandler.instance().getMinecraftServerInstance(), new net.minecraft.network.NetworkManager(EnumPacketDirection.CLIENTBOUND), p_i1530_3_); } @Override - public NetworkManager getNetworkManager() - { + public NetworkManager getNetworkManager() { return null; } @Override - public void update() - { + public void update() { } @Override - public void disconnect(final ITextComponent textComponent) - { + public void disconnect(final ITextComponent textComponent) { } @Override - public void processVehicleMove(CPacketVehicleMove packetIn) - { + public void processVehicleMove(CPacketVehicleMove packetIn) { } @Override - public void processConfirmTeleport(CPacketConfirmTeleport packetIn) - { + public void processConfirmTeleport(CPacketConfirmTeleport packetIn) { } @Override - public void setPlayerLocation(double x, double y, double z, float yaw, float pitch, Set relativeSet) - { + public void setPlayerLocation(double x, double y, double z, float yaw, float pitch, Set relativeSet) { } @Override - public void processTryUseItemOnBlock(CPacketPlayerTryUseItemOnBlock packetIn) - { + public void processTryUseItemOnBlock(CPacketPlayerTryUseItemOnBlock packetIn) { } @Override - public void processTryUseItem(CPacketPlayerTryUseItem packetIn) - { + public void processTryUseItem(CPacketPlayerTryUseItem packetIn) { } @Override - public void processSteerBoat(CPacketSteerBoat packetIn) - { + public void processSteerBoat(CPacketSteerBoat packetIn) { } @Override - public void processCustomPayload(CPacketCustomPayload packetIn) - { + public void processCustomPayload(CPacketCustomPayload packetIn) { } @Override - public void processInput(CPacketInput p_147358_1_) - { + public void processInput(CPacketInput p_147358_1_) { } @Override - public void processPlayer(CPacketPlayer p_147347_1_) - { + public void processPlayer(CPacketPlayer p_147347_1_) { } @Override - public void setPlayerLocation(double p_147364_1_, double p_147364_3_, double p_147364_5_, float p_147364_7_, float p_147364_8_) - { + public void setPlayerLocation(double p_147364_1_, double p_147364_3_, double p_147364_5_, float p_147364_7_, float p_147364_8_) { } @Override - public void processPlayerDigging(CPacketPlayerDigging p_147345_1_) - { + public void processPlayerDigging(CPacketPlayerDigging p_147345_1_) { } @Override - public void onDisconnect(ITextComponent p_147231_1_) - { + public void onDisconnect(ITextComponent p_147231_1_) { } @Override - public void sendPacket(Packet p_147359_1_) - { + public void sendPacket(Packet p_147359_1_) { } @Override - public void processHeldItemChange(CPacketHeldItemChange p_147355_1_) - { + public void processHeldItemChange(CPacketHeldItemChange p_147355_1_) { } @Override - public void processChatMessage(CPacketChatMessage p_147354_1_) - { + public void processChatMessage(CPacketChatMessage p_147354_1_) { } @Override - public void handleAnimation(CPacketAnimation packetIn) - { + public void handleAnimation(CPacketAnimation packetIn) { } @Override - public void processEntityAction(CPacketEntityAction p_147357_1_) - { + public void processEntityAction(CPacketEntityAction p_147357_1_) { } @Override - public void processUseEntity(CPacketUseEntity p_147340_1_) - { + public void processUseEntity(CPacketUseEntity p_147340_1_) { } @Override - public void processClientStatus(CPacketClientStatus p_147342_1_) - { + public void processClientStatus(CPacketClientStatus p_147342_1_) { } @Override - public void processCloseWindow(CPacketCloseWindow p_147356_1_) - { + public void processCloseWindow(CPacketCloseWindow p_147356_1_) { } @Override - public void processClickWindow(CPacketClickWindow p_147351_1_) - { + public void processClickWindow(CPacketClickWindow p_147351_1_) { } @Override - public void processEnchantItem(CPacketEnchantItem p_147338_1_) - { + public void processEnchantItem(CPacketEnchantItem p_147338_1_) { } @Override - public void processCreativeInventoryAction(CPacketCreativeInventoryAction p_147344_1_) - { + public void processCreativeInventoryAction(CPacketCreativeInventoryAction p_147344_1_) { } @Override - public void processConfirmTransaction(CPacketConfirmTransaction p_147339_1_) - { + public void processConfirmTransaction(CPacketConfirmTransaction p_147339_1_) { } @Override - public void processUpdateSign(CPacketUpdateSign p_147343_1_) - { + public void processUpdateSign(CPacketUpdateSign p_147343_1_) { } @Override - public void processKeepAlive(CPacketKeepAlive p_147353_1_) - { + public void processKeepAlive(CPacketKeepAlive p_147353_1_) { } @Override - public void processPlayerAbilities(CPacketPlayerAbilities p_147348_1_) - { + public void processPlayerAbilities(CPacketPlayerAbilities p_147348_1_) { } @Override - public void processTabComplete(CPacketTabComplete p_147341_1_) - { + public void processTabComplete(CPacketTabComplete p_147341_1_) { } @Override - public void processClientSettings(CPacketClientSettings p_147352_1_) - { + public void processClientSettings(CPacketClientSettings p_147352_1_) { } @Override - public void handleSpectate(CPacketSpectate packetIn) - { + public void handleSpectate(CPacketSpectate packetIn) { } @Override - public void handleResourcePackStatus(CPacketResourcePackStatus packetIn) - { + public void handleResourcePackStatus(CPacketResourcePackStatus packetIn) { } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/fakePlayer/FakePlayerBM.java b/src/main/java/WayofTime/bloodmagic/fakePlayer/FakePlayerBM.java index dfe50f3c..03fc7b83 100644 --- a/src/main/java/WayofTime/bloodmagic/fakePlayer/FakePlayerBM.java +++ b/src/main/java/WayofTime/bloodmagic/fakePlayer/FakePlayerBM.java @@ -1,7 +1,6 @@ package WayofTime.bloodmagic.fakePlayer; -import javax.annotation.Nullable; - +import com.mojang.authlib.GameProfile; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.util.math.BlockPos; @@ -10,21 +9,19 @@ import net.minecraft.world.WorldServer; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.fml.common.FMLCommonHandler; -import com.mojang.authlib.GameProfile; +import javax.annotation.Nullable; /** * All credits for this go to CrazyPants, from EIO */ @SuppressWarnings("EntityConstructor") -public class FakePlayerBM extends FakePlayer -{ +public class FakePlayerBM extends FakePlayer { public FakePlayerBM(WorldServer world, GameProfile name) { super(world, name); } - public FakePlayerBM(World world, BlockPos pos, GameProfile profile) - { + public FakePlayerBM(World world, BlockPos pos, GameProfile profile) { super(FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(world.provider.getDimension()), profile); posX = pos.getX() + 0.5; posY = pos.getY() + 0.5; @@ -33,21 +30,17 @@ public class FakePlayerBM extends FakePlayer } @Override - protected void onNewPotionEffect(PotionEffect p_70670_1_) - { + protected void onNewPotionEffect(PotionEffect p_70670_1_) { } @Override - protected void onChangedPotionEffect(PotionEffect effect, boolean p_70695_2_) - { + protected void onChangedPotionEffect(PotionEffect effect, boolean p_70695_2_) { } @Override - protected void onFinishedPotionEffect(PotionEffect effect) - { + protected void onFinishedPotionEffect(PotionEffect effect) { } - protected void playEquipSound(@Nullable ItemStack stack) - { + protected void playEquipSound(@Nullable ItemStack stack) { } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/fuel/FuelHandler.java b/src/main/java/WayofTime/bloodmagic/fuel/FuelHandler.java index feca5d39..aae512d7 100644 --- a/src/main/java/WayofTime/bloodmagic/fuel/FuelHandler.java +++ b/src/main/java/WayofTime/bloodmagic/fuel/FuelHandler.java @@ -1,17 +1,14 @@ package WayofTime.bloodmagic.fuel; -import WayofTime.bloodmagic.item.ItemComponent; import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.item.ItemComponent; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.IFuelHandler; -public class FuelHandler implements IFuelHandler -{ +public class FuelHandler implements IFuelHandler { @Override - public int getBurnTime(ItemStack fuel) - { - if (fuel != null && fuel.getItem() == RegistrarBloodMagicItems.COMPONENT && fuel.getMetadata() == ItemComponent.getStack(ItemComponent.SAND_COAL).getMetadata()) - { + public int getBurnTime(ItemStack fuel) { + if (fuel != null && fuel.getItem() == RegistrarBloodMagicItems.COMPONENT && fuel.getMetadata() == ItemComponent.getStack(ItemComponent.SAND_COAL).getMetadata()) { return 1600; } diff --git a/src/main/java/WayofTime/bloodmagic/gson/SerializerBase.java b/src/main/java/WayofTime/bloodmagic/gson/SerializerBase.java index 089ea4f1..9b67708b 100644 --- a/src/main/java/WayofTime/bloodmagic/gson/SerializerBase.java +++ b/src/main/java/WayofTime/bloodmagic/gson/SerializerBase.java @@ -4,17 +4,14 @@ import com.google.gson.*; import java.lang.reflect.Type; -public abstract class SerializerBase implements JsonDeserializer, JsonSerializer -{ +public abstract class SerializerBase implements JsonDeserializer, JsonSerializer { @Override - public T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException - { + public T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return context.deserialize(json, getType()); } @Override - public JsonElement serialize(T src, Type typeOfSrc, JsonSerializationContext context) - { + public JsonElement serialize(T src, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(src); } diff --git a/src/main/java/WayofTime/bloodmagic/gson/Serializers.java b/src/main/java/WayofTime/bloodmagic/gson/Serializers.java index 709c66a8..1f947941 100644 --- a/src/main/java/WayofTime/bloodmagic/gson/Serializers.java +++ b/src/main/java/WayofTime/bloodmagic/gson/Serializers.java @@ -1,7 +1,7 @@ package WayofTime.bloodmagic.gson; -import java.lang.reflect.Type; - +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import com.google.gson.*; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; import net.minecraft.network.datasync.DataParameter; @@ -10,36 +10,24 @@ import net.minecraft.network.datasync.DataSerializers; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.registry.ForgeRegistries; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonSerializationContext; +import java.lang.reflect.Type; -public class Serializers -{ +public class Serializers { // Data serializers - public static final DataSerializer WILL_TYPE_SERIALIZER = new DataSerializer() - { + public static final DataSerializer WILL_TYPE_SERIALIZER = new DataSerializer() { @Override - public void write(PacketBuffer buf, EnumDemonWillType value) - { + public void write(PacketBuffer buf, EnumDemonWillType value) { buf.writeEnumValue(value); } @Override - public EnumDemonWillType read(PacketBuffer buf) - { + public EnumDemonWillType read(PacketBuffer buf) { return buf.readEnumValue(EnumDemonWillType.class); } @Override - public DataParameter createKey(int id) - { + public DataParameter createKey(int id) { return new DataParameter<>(id, this); } @@ -50,64 +38,53 @@ public class Serializers }; // Serializers - public static final SerializerBase FACING_SERIALIZER = new SerializerBase() - { + public static final SerializerBase FACING_SERIALIZER = new SerializerBase() { @Override - public Class getType() - { + public Class getType() { return EnumFacing.class; } @Override - public EnumFacing deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException - { + public EnumFacing deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return EnumFacing.byName(json.getAsString()); } }; - public static final SerializerBase RESOURCELOCATION_SERIALIZER = new SerializerBase() - { + public static final SerializerBase RESOURCELOCATION_SERIALIZER = new SerializerBase() { @Override - public Class getType() - { + public Class getType() { return ResourceLocation.class; } @Override - public ResourceLocation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException - { + public ResourceLocation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String domain = json.getAsJsonObject().get("domain").getAsString(); String path = json.getAsJsonObject().get("path").getAsString(); return new ResourceLocation(domain, path); } @Override - public JsonElement serialize(ResourceLocation src, Type typeOfSrc, JsonSerializationContext context) - { + public JsonElement serialize(ResourceLocation src, Type typeOfSrc, JsonSerializationContext context) { JsonObject object = new JsonObject(); object.addProperty("domain", src.getResourceDomain()); object.addProperty("path", src.getResourcePath()); return object; } }; - public static final SerializerBase ITEMMETA_SERIALIZER = new SerializerBase() - { + public static final SerializerBase ITEMMETA_SERIALIZER = new SerializerBase() { @Override - public Class getType() - { + public Class getType() { return ItemStack.class; } @Override - public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException - { + public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { ResourceLocation registryName = context.deserialize(json.getAsJsonObject().get("registryName").getAsJsonObject(), ResourceLocation.class); int meta = json.getAsJsonObject().get("meta").getAsInt(); return new ItemStack(ForgeRegistries.ITEMS.getValue(registryName), 1, meta); } @Override - public JsonElement serialize(ItemStack src, Type typeOfSrc, JsonSerializationContext context) - { + public JsonElement serialize(ItemStack src, Type typeOfSrc, JsonSerializationContext context) { JsonObject jsonObject = new JsonObject(); jsonObject.add("registryName", context.serialize(src.getItem().getRegistryName())); jsonObject.addProperty("meta", src.getItemDamage()); @@ -117,8 +94,7 @@ public class Serializers public static final Gson GSON = new GsonBuilder().serializeNulls().setPrettyPrinting().disableHtmlEscaping().registerTypeAdapter(FACING_SERIALIZER.getType(), FACING_SERIALIZER).registerTypeAdapter(RESOURCELOCATION_SERIALIZER.getType(), RESOURCELOCATION_SERIALIZER).registerTypeAdapter(ITEMMETA_SERIALIZER.getType(), ITEMMETA_SERIALIZER).create(); - static - { + static { DataSerializers.registerSerializer(WILL_TYPE_SERIALIZER); } } diff --git a/src/main/java/WayofTime/bloodmagic/incense/IncenseAltarComponent.java b/src/main/java/WayofTime/bloodmagic/incense/IncenseAltarComponent.java index 9c72bff4..b9ef76f0 100644 --- a/src/main/java/WayofTime/bloodmagic/incense/IncenseAltarComponent.java +++ b/src/main/java/WayofTime/bloodmagic/incense/IncenseAltarComponent.java @@ -5,59 +5,51 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; -public class IncenseAltarComponent -{ +public class IncenseAltarComponent { public final BlockPos offsetPos; public final Block block; public final IBlockState state; - public IncenseAltarComponent(BlockPos offsetPos, Block block, IBlockState state) - { + public IncenseAltarComponent(BlockPos offsetPos, Block block, IBlockState state) { this.offsetPos = offsetPos; this.block = block; this.state = state; } - public boolean doesBlockMatch(Block block, IBlockState state) - { + public boolean doesBlockMatch(Block block, IBlockState state) { return this.block == block && block.getMetaFromState(state) == this.block.getMetaFromState(this.state); } /** * Base rotation is north. */ - public BlockPos getOffset(EnumFacing rotation) - { + public BlockPos getOffset(EnumFacing rotation) { return new BlockPos(this.getX(rotation), offsetPos.getY(), this.getZ(rotation)); } - public int getX(EnumFacing direction) - { - switch (direction) - { - case EAST: - return -this.offsetPos.getZ(); - case SOUTH: - return -this.offsetPos.getX(); - case WEST: - return this.offsetPos.getZ(); - default: - return this.offsetPos.getX(); + public int getX(EnumFacing direction) { + switch (direction) { + case EAST: + return -this.offsetPos.getZ(); + case SOUTH: + return -this.offsetPos.getX(); + case WEST: + return this.offsetPos.getZ(); + default: + return this.offsetPos.getX(); } } - public int getZ(EnumFacing direction) - { - switch (direction) - { - case EAST: - return this.offsetPos.getX(); - case SOUTH: - return -this.offsetPos.getZ(); - case WEST: - return -this.offsetPos.getX(); - default: - return this.offsetPos.getZ(); + public int getZ(EnumFacing direction) { + switch (direction) { + case EAST: + return this.offsetPos.getX(); + case SOUTH: + return -this.offsetPos.getZ(); + case WEST: + return -this.offsetPos.getX(); + default: + return this.offsetPos.getZ(); } } } diff --git a/src/main/java/WayofTime/bloodmagic/incense/IncenseAltarHandler.java b/src/main/java/WayofTime/bloodmagic/incense/IncenseAltarHandler.java index ca874d2b..9f01f968 100644 --- a/src/main/java/WayofTime/bloodmagic/incense/IncenseAltarHandler.java +++ b/src/main/java/WayofTime/bloodmagic/incense/IncenseAltarHandler.java @@ -11,61 +11,48 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; -public class IncenseAltarHandler -{ +public class IncenseAltarHandler { public static Map> incenseComponentMap = new TreeMap>(); //Incense bonus maximum applied for the tier of blocks. - public static double[] incenseBonuses = new double[] { 0.2, 0.6, 1.2, 2, 3, 4.5 }; - public static double[] tranquilityRequired = new double[] { 0, 6, 14.14, 28, 44.09, 83.14 }; - public static int[] roadsRequired = new int[] { 0, 1, 4, 6, 8, 10, 12 }; //TODO: Change for when the roads are fully implemented + public static double[] incenseBonuses = new double[]{0.2, 0.6, 1.2, 2, 3, 4.5}; + public static double[] tranquilityRequired = new double[]{0, 6, 14.14, 28, 44.09, 83.14}; + public static int[] roadsRequired = new int[]{0, 1, 4, 6, 8, 10, 12}; //TODO: Change for when the roads are fully implemented - public static void registerIncenseComponent(int altarLevel, IncenseAltarComponent component) - { - if (incenseComponentMap.containsKey(altarLevel)) - { + public static void registerIncenseComponent(int altarLevel, IncenseAltarComponent component) { + if (incenseComponentMap.containsKey(altarLevel)) { incenseComponentMap.get(altarLevel).add(component); - } else - { + } else { List list = new ArrayList(); list.add(component); incenseComponentMap.put(altarLevel, list); } } - public static void registerIncenseComponent(int altarLevel, BlockPos offsetPos, Block block, IBlockState state) - { + public static void registerIncenseComponent(int altarLevel, BlockPos offsetPos, Block block, IBlockState state) { registerIncenseComponent(altarLevel, new IncenseAltarComponent(offsetPos, block, state)); } - public static double getMaxIncenseBonusFromComponents(World world, BlockPos pos) - { + public static double getMaxIncenseBonusFromComponents(World world, BlockPos pos) { double accumulatedBonus = 0; - for (int i = 0; i < incenseBonuses.length; i++) - { + for (int i = 0; i < incenseBonuses.length; i++) { double previousBonus = (i <= 0 ? 0 : incenseBonuses[i - 1]); double nextBonus = incenseBonuses[i]; - if (!incenseComponentMap.containsKey(i)) - { + if (!incenseComponentMap.containsKey(i)) { accumulatedBonus += (nextBonus - previousBonus); - } else - { + } else { boolean hasAllComponentsThisTier = true; - for (IncenseAltarComponent component : incenseComponentMap.get(i)) - { + for (IncenseAltarComponent component : incenseComponentMap.get(i)) { BlockPos offsetPos = pos.add(component.getOffset(EnumFacing.NORTH)); IBlockState state = world.getBlockState(offsetPos); Block block = state.getBlock(); - if (component.doesBlockMatch(block, state)) - { + if (component.doesBlockMatch(block, state)) { hasAllComponentsThisTier = false; - } else - { + } else { accumulatedBonus += (nextBonus - previousBonus) / incenseComponentMap.get(i).size(); } } - if (!hasAllComponentsThisTier) - { + if (!hasAllComponentsThisTier) { break; } } @@ -74,16 +61,12 @@ public class IncenseAltarHandler return accumulatedBonus; } - public static double getMaxIncenseBonusFromRoads(int roads) - { + public static double getMaxIncenseBonusFromRoads(int roads) { double previousBonus = 0; - for (int i = 0; i < incenseBonuses.length; i++) - { - if (roads >= roadsRequired[i]) - { + for (int i = 0; i < incenseBonuses.length; i++) { + if (roads >= roadsRequired[i]) { previousBonus = incenseBonuses[i]; - } else - { + } else { return previousBonus; } } @@ -91,18 +74,14 @@ public class IncenseAltarHandler return previousBonus; } - public static double getIncenseBonusFromComponents(World world, BlockPos pos, double tranquility, int roads) - { + public static double getIncenseBonusFromComponents(World world, BlockPos pos, double tranquility, int roads) { double maxBonus = Math.min(getMaxIncenseBonusFromComponents(world, pos), getMaxIncenseBonusFromRoads(roads)); double possibleBonus = 0; - for (int i = 0; i < incenseBonuses.length; i++) - { - if (tranquility >= tranquilityRequired[i]) - { + for (int i = 0; i < incenseBonuses.length; i++) { + if (tranquility >= tranquilityRequired[i]) { possibleBonus = incenseBonuses[i]; - } else if (i >= 1) - { + } else if (i >= 1) { possibleBonus += (incenseBonuses[i] - possibleBonus) * (tranquility - tranquilityRequired[i - 1]) / (tranquilityRequired[i] - tranquilityRequired[i - 1]); break; } diff --git a/src/main/java/WayofTime/bloodmagic/incense/TranquilityHandlers.java b/src/main/java/WayofTime/bloodmagic/incense/TranquilityHandlers.java index b5d6b14d..f6b01f98 100644 --- a/src/main/java/WayofTime/bloodmagic/incense/TranquilityHandlers.java +++ b/src/main/java/WayofTime/bloodmagic/incense/TranquilityHandlers.java @@ -10,16 +10,12 @@ import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class TranquilityHandlers -{ +public class TranquilityHandlers { - public static class Plant implements ITranquilityHandler - { + public static class Plant implements ITranquilityHandler { @Override - public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) - { - if (block instanceof BlockLeaves) - { + public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) { + if (block instanceof BlockLeaves) { return new TranquilityStack(EnumTranquilityType.PLANT, 1); } @@ -27,13 +23,10 @@ public class TranquilityHandlers } } - public static class Lava implements ITranquilityHandler - { + public static class Lava implements ITranquilityHandler { @Override - public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) - { - if (block == Blocks.LAVA || block == Blocks.FLOWING_LAVA) - { + public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) { + if (block == Blocks.LAVA || block == Blocks.FLOWING_LAVA) { return new TranquilityStack(EnumTranquilityType.LAVA, 1.2); } @@ -41,18 +34,14 @@ public class TranquilityHandlers } } - public static class Fire implements ITranquilityHandler - { + public static class Fire implements ITranquilityHandler { @Override - public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) - { - if (block instanceof BlockFire) - { + public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) { + if (block instanceof BlockFire) { return new TranquilityStack(EnumTranquilityType.FIRE, 1); } - if (block == Blocks.NETHERRACK) - { + if (block == Blocks.NETHERRACK) { return new TranquilityStack(EnumTranquilityType.FIRE, 0.5); } @@ -60,23 +49,18 @@ public class TranquilityHandlers } } - public static class Earth implements ITranquilityHandler - { + public static class Earth implements ITranquilityHandler { @Override - public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) - { - if (block == Blocks.DIRT) - { + public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) { + if (block == Blocks.DIRT) { return new TranquilityStack(EnumTranquilityType.EARTHEN, 0.25); } - if (block instanceof BlockGrass) - { + if (block instanceof BlockGrass) { return new TranquilityStack(EnumTranquilityType.EARTHEN, 0.5); } - if (block == Blocks.FARMLAND) - { + if (block == Blocks.FARMLAND) { return new TranquilityStack(EnumTranquilityType.EARTHEN, 1); } @@ -84,13 +68,10 @@ public class TranquilityHandlers } } - public static class Crop implements ITranquilityHandler - { + public static class Crop implements ITranquilityHandler { @Override - public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) - { - if (block == Blocks.POTATOES || block == Blocks.CARROTS || block == Blocks.WHEAT || block == Blocks.NETHER_WART || block == Blocks.BEETROOTS) - { + public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) { + if (block == Blocks.POTATOES || block == Blocks.CARROTS || block == Blocks.WHEAT || block == Blocks.NETHER_WART || block == Blocks.BEETROOTS) { return new TranquilityStack(EnumTranquilityType.CROP, 1); } @@ -98,13 +79,10 @@ public class TranquilityHandlers } } - public static class Tree implements ITranquilityHandler - { + public static class Tree implements ITranquilityHandler { @Override - public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) - { - if (block instanceof BlockLog) - { + public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) { + if (block instanceof BlockLog) { return new TranquilityStack(EnumTranquilityType.TREE, 1); } @@ -112,18 +90,14 @@ public class TranquilityHandlers } } - public static class Water implements ITranquilityHandler - { + public static class Water implements ITranquilityHandler { @Override - public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) - { - if (block == Blocks.WATER || block == Blocks.FLOWING_WATER) - { + public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) { + if (block == Blocks.WATER || block == Blocks.FLOWING_WATER) { return new TranquilityStack(EnumTranquilityType.WATER, 1); } - if (block == RegistrarBloodMagicBlocks.LIFE_ESSENCE) - { + if (block == RegistrarBloodMagicBlocks.LIFE_ESSENCE) { return new TranquilityStack(EnumTranquilityType.WATER, 1.5); } diff --git a/src/main/java/WayofTime/bloodmagic/inversion/CorruptionHandler.java b/src/main/java/WayofTime/bloodmagic/inversion/CorruptionHandler.java index 44b3af7e..c7b0abc7 100644 --- a/src/main/java/WayofTime/bloodmagic/inversion/CorruptionHandler.java +++ b/src/main/java/WayofTime/bloodmagic/inversion/CorruptionHandler.java @@ -1,42 +1,34 @@ package WayofTime.bloodmagic.inversion; -import java.util.HashMap; -import java.util.Map; - +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; - import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import java.util.HashMap; +import java.util.Map; -public class CorruptionHandler -{ +public class CorruptionHandler { public static Map, Map> corruptBlockMap = new HashMap, Map>(); - public static void registerBlockCorruption(EnumDemonWillType type, Block block, int meta, IBlockState corruptedState) - { + public static void registerBlockCorruption(EnumDemonWillType type, Block block, int meta, IBlockState corruptedState) { Pair pair = Pair.of(block, meta); - if (corruptBlockMap.containsKey(pair)) - { + if (corruptBlockMap.containsKey(pair)) { Map stateMap = corruptBlockMap.get(pair); stateMap.put(type, corruptedState); - } else - { + } else { Map stateMap = new HashMap(); stateMap.put(type, corruptedState); corruptBlockMap.put(pair, stateMap); } } - public static boolean isBlockCorruptible(World world, EnumDemonWillType type, BlockPos pos, IBlockState state, Block block) - { + public static boolean isBlockCorruptible(World world, EnumDemonWillType type, BlockPos pos, IBlockState state, Block block) { int meta = block.getMetaFromState(state); Pair pair = Pair.of(block, meta); - if (corruptBlockMap.containsKey(pair)) - { + if (corruptBlockMap.containsKey(pair)) { Map stateMap = corruptBlockMap.get(pair); return stateMap.containsKey(type); } @@ -44,15 +36,12 @@ public class CorruptionHandler return false; } - public static boolean corruptBlock(World world, EnumDemonWillType type, BlockPos pos, IBlockState state, Block block) - { + public static boolean corruptBlock(World world, EnumDemonWillType type, BlockPos pos, IBlockState state, Block block) { int meta = block.getMetaFromState(state); Pair pair = Pair.of(block, meta); - if (corruptBlockMap.containsKey(pair)) - { + if (corruptBlockMap.containsKey(pair)) { Map stateMap = corruptBlockMap.get(pair); - if (stateMap.containsKey(type)) - { + if (stateMap.containsKey(type)) { return world.setBlockState(pos, stateMap.get(type)); } } @@ -61,36 +50,27 @@ public class CorruptionHandler } /** - * * @param world * @param type * @param centerPos * @param radius - * @param featheringChance - * Chance that the block within the featheringDepth is NOT altered. + * @param featheringChance Chance that the block within the featheringDepth is NOT altered. * @param featheringDepth * @return */ - public static boolean corruptSurroundingBlocks(World world, EnumDemonWillType type, BlockPos centerPos, int radius, double featheringChance, double featheringDepth) - { - for (int i = -radius; i <= radius; i++) - { - for (int j = -radius; j <= radius; j++) - { - for (int k = -radius; k <= radius; k++) - { - if (i * i + j * j + k * k > (radius + 0.5) * (radius + 0.5)) - { + public static boolean corruptSurroundingBlocks(World world, EnumDemonWillType type, BlockPos centerPos, int radius, double featheringChance, double featheringDepth) { + for (int i = -radius; i <= radius; i++) { + for (int j = -radius; j <= radius; j++) { + for (int k = -radius; k <= radius; k++) { + if (i * i + j * j + k * k > (radius + 0.5) * (radius + 0.5)) { continue; } - if (featheringChance > 0 && i * i + j * j + k * k > (radius - featheringDepth + 0.5) * (radius - featheringDepth + 0.5) && world.rand.nextDouble() < featheringChance) - { + if (featheringChance > 0 && i * i + j * j + k * k > (radius - featheringDepth + 0.5) * (radius - featheringDepth + 0.5) && world.rand.nextDouble() < featheringChance) { continue; } - if (world.isAirBlock(centerPos)) - { + if (world.isAirBlock(centerPos)) { continue; } diff --git a/src/main/java/WayofTime/bloodmagic/inversion/InversionPillarHandler.java b/src/main/java/WayofTime/bloodmagic/inversion/InversionPillarHandler.java index 1a13c8f5..d1a1e9aa 100644 --- a/src/main/java/WayofTime/bloodmagic/inversion/InversionPillarHandler.java +++ b/src/main/java/WayofTime/bloodmagic/inversion/InversionPillarHandler.java @@ -1,48 +1,36 @@ package WayofTime.bloodmagic.inversion; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -public class InversionPillarHandler -{ +import java.util.*; + +public class InversionPillarHandler { public static final double farthestDistanceSquared = 16 * 16; public static Map>> pillarMap = new HashMap>>(); public static Map>>> nearPillarMap = new HashMap>>>(); - public static boolean addPillarToMap(World world, EnumDemonWillType type, BlockPos pos) - { + public static boolean addPillarToMap(World world, EnumDemonWillType type, BlockPos pos) { int dim = world.provider.getDimension(); - if (pillarMap.containsKey(dim)) - { + if (pillarMap.containsKey(dim)) { Map> willMap = pillarMap.get(dim); - if (willMap.containsKey(type)) - { - if (!willMap.get(type).contains(pos)) - { + if (willMap.containsKey(type)) { + if (!willMap.get(type).contains(pos)) { willMap.get(type).add(pos); onPillarAdded(world, type, pos); return true; - } else - { + } else { return false; } - } else - { + } else { List posList = new ArrayList(); posList.add(pos); willMap.put(type, posList); onPillarAdded(world, type, pos); return true; } - } else - { + } else { Map> willMap = new HashMap>(); List posList = new ArrayList(); posList.add(pos); @@ -54,44 +42,34 @@ public class InversionPillarHandler } } - public static boolean removePillarFromMap(World world, EnumDemonWillType type, BlockPos pos) - { + public static boolean removePillarFromMap(World world, EnumDemonWillType type, BlockPos pos) { int dim = world.provider.getDimension(); - if (pillarMap.containsKey(dim)) - { + if (pillarMap.containsKey(dim)) { Map> willMap = pillarMap.get(dim); - if (willMap.containsKey(type)) - { - if (willMap.get(type).contains(pos)) - { + if (willMap.containsKey(type)) { + if (willMap.get(type).contains(pos)) { onPillarRemoved(world, type, pos); return willMap.get(type).remove(pos); - } else - { + } else { return false; } - } else - { + } else { return false; } - } else - { + } else { return false; } } //Assume that it has been added already. - private static void onPillarAdded(World world, EnumDemonWillType type, BlockPos pos) - { + private static void onPillarAdded(World world, EnumDemonWillType type, BlockPos pos) { System.out.println("Adding..."); List closePosList = new ArrayList(); int dim = world.provider.getDimension(); - if (pillarMap.containsKey(dim)) - { + if (pillarMap.containsKey(dim)) { Map> willMap = pillarMap.get(dim); - if (willMap.containsKey(type)) - { + if (willMap.containsKey(type)) { List otherPosList = willMap.get(type); for (BlockPos closePos : otherPosList) { @@ -102,11 +80,9 @@ public class InversionPillarHandler } } - if (nearPillarMap.containsKey(dim)) - { + if (nearPillarMap.containsKey(dim)) { Map>> willMap = nearPillarMap.get(dim); - if (willMap.containsKey(type)) - { + if (willMap.containsKey(type)) { Map> posMap = willMap.get(type); for (BlockPos closePos : closePosList) { @@ -121,15 +97,13 @@ public class InversionPillarHandler } posMap.put(pos, closePosList); - } else - { + } else { Map> posMap = new HashMap>(); posMap.put(pos, closePosList); willMap.put(type, posMap); } - } else - { + } else { Map>> willMap = new HashMap>>(); Map> posMap = new HashMap>(); @@ -139,26 +113,20 @@ public class InversionPillarHandler } } - private static void onPillarRemoved(World world, EnumDemonWillType type, BlockPos pos) - { + private static void onPillarRemoved(World world, EnumDemonWillType type, BlockPos pos) { System.out.println("Removing..."); int dim = world.provider.getDimension(); - if (nearPillarMap.containsKey(dim)) - { + if (nearPillarMap.containsKey(dim)) { Map>> willMap = nearPillarMap.get(dim); - if (willMap.containsKey(type)) - { + if (willMap.containsKey(type)) { Map> posMap = willMap.get(type); List posList = posMap.get(pos); - if (posList != null) - { + if (posList != null) { Iterator itr = posList.iterator(); - while (itr.hasNext()) - { + while (itr.hasNext()) { BlockPos checkPos = itr.next(); List checkPosList = posMap.get(checkPos); - if (checkPosList != null) - { + if (checkPosList != null) { checkPosList.remove(pos); } } @@ -170,18 +138,14 @@ public class InversionPillarHandler } //TODO: Change to use the nearPillarMap. - public static List getNearbyPillars(World world, EnumDemonWillType type, BlockPos pos) - { + public static List getNearbyPillars(World world, EnumDemonWillType type, BlockPos pos) { int dim = world.provider.getDimension(); - if (nearPillarMap.containsKey(dim)) - { + if (nearPillarMap.containsKey(dim)) { Map>> willMap = nearPillarMap.get(dim); - if (willMap.containsKey(type)) - { + if (willMap.containsKey(type)) { Map> posMap = willMap.get(type); List posList = posMap.get(pos); - if (posList != null) - { + if (posList != null) { return posList; } } @@ -190,24 +154,20 @@ public class InversionPillarHandler return new ArrayList(); } - public static List getAllConnectedPillars(World world, EnumDemonWillType type, BlockPos pos) - { + public static List getAllConnectedPillars(World world, EnumDemonWillType type, BlockPos pos) { List checkedPosList = new ArrayList(); List uncheckedPosList = new ArrayList(); //Positions where we did not check their connections. uncheckedPosList.add(pos); int dim = world.provider.getDimension(); - if (nearPillarMap.containsKey(dim)) - { + if (nearPillarMap.containsKey(dim)) { Map>> willMap = nearPillarMap.get(dim); - if (willMap.containsKey(type)) - { + if (willMap.containsKey(type)) { Map> posMap = willMap.get(type); // This is where the magic happens. - while (!uncheckedPosList.isEmpty()) - { + while (!uncheckedPosList.isEmpty()) { //Positions that are new this iteration and need to be dumped into uncheckedPosList next iteration. List newPosList = new ArrayList(); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemActivationCrystal.java b/src/main/java/WayofTime/bloodmagic/item/ItemActivationCrystal.java index 2bb80bde..c0560ec7 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemActivationCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemActivationCrystal.java @@ -5,8 +5,6 @@ import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.world.World; @@ -18,12 +16,10 @@ import org.apache.commons.lang3.tuple.Pair; import java.util.ArrayList; import java.util.List; -public class ItemActivationCrystal extends ItemBindableBase implements IVariantProvider -{ - public static String[] names = { "weak", "awakened", "creative" }; +public class ItemActivationCrystal extends ItemBindableBase implements IVariantProvider { + public static String[] names = {"weak", "awakened", "creative"}; - public ItemActivationCrystal() - { + public ItemActivationCrystal() { super(); setUnlocalizedName(BloodMagic.MODID + ".activationCrystal."); @@ -31,15 +27,13 @@ public class ItemActivationCrystal extends ItemBindableBase implements IVariantP } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; @@ -49,16 +43,14 @@ public class ItemActivationCrystal extends ItemBindableBase implements IVariantP @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { tooltip.add(TextHelper.localize("tooltip.bloodmagic.activationCrystal." + names[stack.getItemDamage()])); super.addInformation(stack, world, tooltip, flag); } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=weak")); ret.add(new ImmutablePair(1, "type=demonic")); @@ -66,8 +58,7 @@ public class ItemActivationCrystal extends ItemBindableBase implements IVariantP return ret; } - public int getCrystalLevel(ItemStack stack) - { + public int getCrystalLevel(ItemStack stack) { return stack.getItemDamage() > 1 ? Integer.MAX_VALUE : stack.getItemDamage() + 1; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemAltarMaker.java b/src/main/java/WayofTime/bloodmagic/item/ItemAltarMaker.java index ebbc7239..123f06f1 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemAltarMaker.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemAltarMaker.java @@ -1,26 +1,5 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.List; - -import WayofTime.bloodmagic.util.helper.NumeralHelper; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; - import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.altar.BloodAltar; import WayofTime.bloodmagic.api.Constants; @@ -33,14 +12,31 @@ import WayofTime.bloodmagic.block.BlockAltar; import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.util.ChatUtil; import WayofTime.bloodmagic.util.Utils; +import WayofTime.bloodmagic.util.helper.NumeralHelper; import WayofTime.bloodmagic.util.helper.TextHelper; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; -public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantProvider -{ +import java.util.ArrayList; +import java.util.List; + +public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantProvider { private EnumAltarTier tierToBuild = EnumAltarTier.ONE; - public ItemAltarMaker() - { + public ItemAltarMaker() { super(); setUnlocalizedName(BloodMagic.MODID + ".altarMaker"); setCreativeTab(BloodMagic.TAB_BM); @@ -50,30 +46,26 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentTier", stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1)); } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (world.isRemote) return super.onItemRightClick(world, player, hand); - if (!player.capabilities.isCreativeMode) - { + if (!player.capabilities.isCreativeMode) { ChatUtil.sendNoSpam(player, TextHelper.localizeEffect("chat.bloodmagic.altarMaker.creativeOnly")); return super.onItemRightClick(world, player, hand); } stack = NBTHelper.checkNBT(stack); - if (player.isSneaking()) - { + if (player.isSneaking()) { if (stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) >= EnumAltarTier.MAXTIERS - 1) stack.getTagCompound().setInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER, 0); else @@ -88,8 +80,7 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP if (rayTrace == null || rayTrace.typeOfHit == RayTraceResult.Type.MISS || rayTrace.typeOfHit == RayTraceResult.Type.ENTITY) return super.onItemRightClick(world, player, hand); - if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK && world.getBlockState(rayTrace.getBlockPos()).getBlock() instanceof BlockAltar) - { + if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK && world.getBlockState(rayTrace.getBlockPos()).getBlock() instanceof BlockAltar) { ChatUtil.sendNoSpam(player, TextHelper.localizeEffect("chat.bloodmagic.altarMaker.building", NumeralHelper.toRoman(tierToBuild.toInt()))); buildAltar(world, rayTrace.getBlockPos()); IBlockState state = world.getBlockState(rayTrace.getBlockPos()); @@ -101,28 +92,24 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=altarmaker")); return ret; } - public void setTierToBuild(EnumAltarTier tierToBuild) - { + public void setTierToBuild(EnumAltarTier tierToBuild) { this.tierToBuild = tierToBuild; } - public void buildAltar(World world, BlockPos pos) - { + public void buildAltar(World world, BlockPos pos) { if (world.isRemote) return; if (tierToBuild == EnumAltarTier.ONE) return; - for (AltarComponent altarComponent : tierToBuild.getAltarComponents()) - { + for (AltarComponent altarComponent : tierToBuild.getAltarComponents()) { BlockPos componentPos = pos.add(altarComponent.getOffset()); Block blockForComponent = Utils.getBlockForComponent(altarComponent.getComponent()); @@ -132,8 +119,7 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP ((IBloodAltar) world.getTileEntity(pos)).checkTier(); } - public String destroyAltar(EntityPlayer player) - { + public String destroyAltar(EntityPlayer player) { World world = player.getEntityWorld(); if (world.isRemote) return ""; @@ -145,10 +131,8 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP if (altarTier.equals(EnumAltarTier.ONE)) return "" + altarTier.toInt(); - else - { - for (AltarComponent altarComponent : altarTier.getAltarComponents()) - { + else { + for (AltarComponent altarComponent : altarTier.getAltarComponents()) { BlockPos componentPos = pos.add(altarComponent.getOffset()); IBlockState componentState = world.getBlockState(pos); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemArcaneAshes.java b/src/main/java/WayofTime/bloodmagic/item/ItemArcaneAshes.java index c83f0634..4734f6f9 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemArcaneAshes.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemArcaneAshes.java @@ -1,8 +1,10 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; +import WayofTime.bloodmagic.tile.TileAlchemyArray; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -15,20 +17,14 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; -import WayofTime.bloodmagic.tile.TileAlchemyArray; -import WayofTime.bloodmagic.util.helper.TextHelper; +import java.util.ArrayList; +import java.util.List; -public class ItemArcaneAshes extends Item implements IVariantProvider -{ - public ItemArcaneAshes() - { +public class ItemArcaneAshes extends Item implements IVariantProvider { + public ItemArcaneAshes() { setUnlocalizedName(BloodMagic.MODID + ".arcaneAshes"); setMaxStackSize(1); setMaxDamage(19); //Allows for 20 uses @@ -37,26 +33,21 @@ public class ItemArcaneAshes extends Item implements IVariantProvider @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.arcaneAshes")); } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); BlockPos newPos = blockPos.offset(side); - if (world.isAirBlock(newPos)) - { - if (!world.isRemote) - { + if (world.isAirBlock(newPos)) { + if (!world.isRemote) { EnumFacing rotation = EnumFacing.fromAngle(player.getRotationYawHead()); world.setBlockState(newPos, RegistrarBloodMagicBlocks.ALCHEMY_ARRAY.getDefaultState()); TileEntity tile = world.getTileEntity(newPos); - if (tile instanceof TileAlchemyArray) - { + if (tile instanceof TileAlchemyArray) { ((TileAlchemyArray) tile).setRotation(rotation); } @@ -70,8 +61,7 @@ public class ItemArcaneAshes extends Item implements IVariantProvider } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=arcaneashes")); return ret; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBindableBase.java b/src/main/java/WayofTime/bloodmagic/item/ItemBindableBase.java index 1aa5d370..195be959 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBindableBase.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBindableBase.java @@ -6,7 +6,6 @@ import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.util.helper.TextHelper; import com.google.common.base.Strings; import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -14,10 +13,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class ItemBindableBase extends ItemBindable -{ - public ItemBindableBase() - { +public class ItemBindableBase extends ItemBindable { + public ItemBindableBase() { super(); setCreativeTab(BloodMagic.TAB_BM); @@ -25,8 +22,7 @@ public class ItemBindableBase extends ItemBindable @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java b/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java index d071fbc4..46f441da 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java @@ -1,9 +1,14 @@ package WayofTime.bloodmagic.item; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.iface.IBindable; +import WayofTime.bloodmagic.api.orb.BloodOrb; +import WayofTime.bloodmagic.api.orb.IBloodOrb; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; +import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.core.RegistrarBloodMagic; +import WayofTime.bloodmagic.util.helper.TextHelper; +import com.google.common.base.Strings; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -14,29 +19,19 @@ import net.minecraft.util.*; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.api.iface.IBindable; -import WayofTime.bloodmagic.api.orb.BloodOrb; -import WayofTime.bloodmagic.api.orb.IBloodOrb; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -import WayofTime.bloodmagic.api.util.helper.PlayerHelper; -import WayofTime.bloodmagic.util.helper.TextHelper; - -import com.google.common.base.Strings; import javax.annotation.Nullable; +import java.util.List; -public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindable -{ - public ItemBloodOrb() - { +public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindable { + public ItemBloodOrb() { setUnlocalizedName(BloodMagic.MODID + ".orb"); this.setMaxDamage(0); setHasSubtypes(true); } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { BloodOrb orb = getOrb(stack); if (orb == null) return super.getUnlocalizedName(stack); @@ -45,8 +40,7 @@ public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindab } @Override - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; @@ -60,8 +54,7 @@ public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindab } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); BloodOrb orb = getOrb(stack); @@ -76,8 +69,7 @@ public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindab if (PlayerHelper.isFakePlayer(player)) return super.onItemRightClick(world, player, hand); - if (!stack.hasTagCompound()) - { + if (!stack.hasTagCompound()) { return super.onItemRightClick(world, player, hand); } @@ -97,8 +89,7 @@ public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindab @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.orb.desc")); BloodOrb orb = getOrb(stack); @@ -109,22 +100,19 @@ public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindab } @Override - public ItemStack getContainerItem(ItemStack stack) - { + public ItemStack getContainerItem(ItemStack stack) { return stack.copy(); } @Override - public boolean hasContainerItem(ItemStack stack) - { + public boolean hasContainerItem(ItemStack stack) { return true; } // IBindable @Override - public boolean onBind(EntityPlayer player, ItemStack stack) - { + public boolean onBind(EntityPlayer player, ItemStack stack) { return true; } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBloodShard.java b/src/main/java/WayofTime/bloodmagic/item/ItemBloodShard.java index bf9f9f78..acbf2214 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBloodShard.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBloodShard.java @@ -14,12 +14,10 @@ import org.apache.commons.lang3.tuple.Pair; import java.util.ArrayList; import java.util.List; -public class ItemBloodShard extends Item implements IVariantProvider -{ - public String[] names = { "weak", "demon" }; +public class ItemBloodShard extends Item implements IVariantProvider { + public String[] names = {"weak", "demon"}; - public ItemBloodShard() - { + public ItemBloodShard() { super(); setCreativeTab(BloodMagic.TAB_BM); @@ -29,8 +27,7 @@ public class ItemBloodShard extends Item implements IVariantProvider @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; @@ -39,14 +36,12 @@ public class ItemBloodShard extends Item implements IVariantProvider } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=weak")); ret.add(new ImmutablePair(1, "type=demonic")); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java index b76723ca..47d13a14 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java @@ -1,11 +1,13 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import javax.annotation.Nullable; - +import WayofTime.bloodmagic.api.BlockStack; +import WayofTime.bloodmagic.api.ItemStackWrapper; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; +import WayofTime.bloodmagic.client.IMeshProvider; +import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Multimap; +import com.google.common.collect.Sets; import net.minecraft.block.Block; import net.minecraft.block.BlockLeaves; import net.minecraft.block.material.Material; @@ -28,40 +30,31 @@ import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.api.BlockStack; -import WayofTime.bloodmagic.api.ItemStackWrapper; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -import WayofTime.bloodmagic.client.IMeshProvider; -import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; -import com.google.common.collect.HashMultiset; -import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; -public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider -{ +public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider { private static final Set EFFECTIVE_ON = Sets.newHashSet(Blocks.PLANKS, Blocks.BOOKSHELF, Blocks.LOG, Blocks.LOG2, Blocks.CHEST, Blocks.PUMPKIN, Blocks.LIT_PUMPKIN, Blocks.MELON_BLOCK, Blocks.LADDER); - public ItemBoundAxe() - { + public ItemBoundAxe() { super("axe", 7, EFFECTIVE_ON); } @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) - { + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { return true; } @Override - public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) - { + public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) { return true; } @Override - protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) - { + protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) { if (world.isRemote) return; @@ -73,12 +66,9 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider BlockPos playerPos = player.getPosition(); - for (int i = -range; i <= range; i++) - { - for (int j = 0; j <= 2 * range; j++) - { - for (int k = -range; k <= range; k++) - { + for (int i = -range; i <= range; i++) { + for (int j = 0; j <= 2 * range; j++) { + for (int k = -range; k <= range; k++) { BlockPos blockPos = playerPos.add(i, j, k); BlockStack blockStack = BlockStack.getStackFromPos(world, blockPos); @@ -92,16 +82,13 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) continue; - if (blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1.0F) - { + if (blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1.0F) { float strengthVsBlock = getStrVsBlock(stack, blockStack.getState()); - if (strengthVsBlock > 1.1F || blockStack.getBlock() instanceof BlockLeaves && world.canMineBlockBody(player, blockPos)) - { + if (strengthVsBlock > 1.1F || blockStack.getBlock() instanceof BlockLeaves && world.canMineBlockBody(player, blockPos)) { if (silkTouch && blockStack.getBlock().canSilkHarvest(world, blockPos, world.getBlockState(blockPos), player)) drops.add(new ItemStackWrapper(blockStack)); - else - { + else { List itemDrops = blockStack.getBlock().getDrops(world, blockPos, world.getBlockState(blockPos), fortuneLvl); for (ItemStack stacks : itemDrops) @@ -121,11 +108,9 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider } @Override - public Multimap getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack) - { + public Multimap getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack) { Multimap multimap = super.getItemAttributeModifiers(equipmentSlot); - if (equipmentSlot == EntityEquipmentSlot.MAINHAND) - { + if (equipmentSlot == EntityEquipmentSlot.MAINHAND) { multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getActivated(stack) ? 11 : 2, 0)); multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -3.0, 0)); } @@ -134,21 +119,18 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider @Override @SideOnly(Side.CLIENT) - public ItemMeshDefinition getMeshDefinition() - { + public ItemMeshDefinition getMeshDefinition() { return new CustomMeshDefinitionActivatable("ItemBoundAxe"); } @Nullable @Override - public ResourceLocation getCustomLocation() - { + public ResourceLocation getCustomLocation() { return null; } @Override - public List getVariants() - { + public List getVariants() { List ret = new ArrayList(); ret.add("active=true"); ret.add("active=false"); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java index c5587491..bb1a1ccf 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java @@ -1,9 +1,13 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - +import WayofTime.bloodmagic.api.BlockStack; +import WayofTime.bloodmagic.api.ItemStackWrapper; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; +import WayofTime.bloodmagic.client.IMeshProvider; +import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Multimap; +import com.google.common.collect.Sets; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -25,50 +29,38 @@ import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.api.BlockStack; -import WayofTime.bloodmagic.api.ItemStackWrapper; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -import WayofTime.bloodmagic.client.IMeshProvider; -import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; - -import com.google.common.collect.HashMultiset; -import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; -public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider -{ +public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider { private static final Set EFFECTIVE_ON = Sets.newHashSet(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.STONE_SLAB, Blocks.GOLDEN_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.LIT_REDSTONE_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.STONE_SLAB); - public ItemBoundPickaxe() - { + public ItemBoundPickaxe() { super("pickaxe", 5, EFFECTIVE_ON); } @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) - { + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { return true; } @Override - public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) - { + public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) { return true; } @Override - public boolean canHarvestBlock(IBlockState blockIn) - { + public boolean canHarvestBlock(IBlockState blockIn) { return blockIn == Blocks.OBSIDIAN ? this.toolMaterial.getHarvestLevel() == 3 : (blockIn != Blocks.DIAMOND_BLOCK && blockIn != Blocks.DIAMOND_ORE ? (blockIn != Blocks.EMERALD_ORE && blockIn != Blocks.EMERALD_BLOCK ? (blockIn != Blocks.GOLD_BLOCK && blockIn != Blocks.GOLD_ORE ? (blockIn != Blocks.IRON_BLOCK && blockIn != Blocks.IRON_ORE ? (blockIn != Blocks.LAPIS_BLOCK && blockIn != Blocks.LAPIS_ORE ? (blockIn != Blocks.REDSTONE_ORE && blockIn != Blocks.LIT_REDSTONE_ORE ? (blockIn.getMaterial() == Material.ROCK || (blockIn.getMaterial() == Material.IRON || blockIn.getMaterial() == Material.ANVIL)) : this.toolMaterial.getHarvestLevel() >= 2) - : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2); + : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2); } @Override - public float getStrVsBlock(ItemStack stack, IBlockState state) - { + public float getStrVsBlock(ItemStack stack, IBlockState state) { if (!getActivated(stack)) return 1.0F; @@ -76,8 +68,7 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider } @Override - protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) - { + protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) { if (world.isRemote) return; @@ -89,12 +80,9 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider BlockPos playerPos = player.getPosition(); - for (int i = -range; i <= range; i++) - { - for (int j = 0; j <= 2 * range; j++) - { - for (int k = -range; k <= range; k++) - { + for (int i = -range; i <= range; i++) { + for (int j = 0; j <= 2 * range; j++) { + for (int k = -range; k <= range; k++) { BlockPos blockPos = playerPos.add(i, j, k); BlockStack blockStack = BlockStack.getStackFromPos(world, blockPos); @@ -108,16 +96,13 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) continue; - if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1) - { + if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1) { float strengthVsBlock = getStrVsBlock(stack, blockStack.getState()); - if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos)) - { + if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos)) { if (silkTouch && blockStack.getBlock().canSilkHarvest(world, blockPos, world.getBlockState(blockPos), player)) drops.add(new ItemStackWrapper(blockStack)); - else - { + else { List itemDrops = blockStack.getBlock().getDrops(world, blockPos, world.getBlockState(blockPos), fortuneLvl); for (ItemStack stacks : itemDrops) drops.add(ItemStackWrapper.getHolder(stacks)); @@ -136,11 +121,9 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider } @Override - public Multimap getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack) - { + public Multimap getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack) { Multimap multimap = super.getItemAttributeModifiers(equipmentSlot); - if (equipmentSlot == EntityEquipmentSlot.MAINHAND) - { + if (equipmentSlot == EntityEquipmentSlot.MAINHAND) { multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getActivated(stack) ? 5 : 2, 0)); multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -2.5, 0)); } @@ -149,21 +132,18 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider @Override @SideOnly(Side.CLIENT) - public ItemMeshDefinition getMeshDefinition() - { + public ItemMeshDefinition getMeshDefinition() { return new CustomMeshDefinitionActivatable("ItemBoundPickaxe"); } @Nullable @Override - public ResourceLocation getCustomLocation() - { + public ResourceLocation getCustomLocation() { return null; } @Override - public List getVariants() - { + public List getVariants() { List ret = new ArrayList(); ret.add("active=true"); ret.add("active=false"); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java index 16e3d7ac..1f621468 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java @@ -1,9 +1,13 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - +import WayofTime.bloodmagic.api.BlockStack; +import WayofTime.bloodmagic.api.ItemStackWrapper; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; +import WayofTime.bloodmagic.client.IMeshProvider; +import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Multimap; +import com.google.common.collect.Sets; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -25,42 +29,31 @@ import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.api.BlockStack; -import WayofTime.bloodmagic.api.ItemStackWrapper; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -import WayofTime.bloodmagic.client.IMeshProvider; -import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; - -import com.google.common.collect.HashMultiset; -import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; -public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider -{ +public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider { private static final Set EFFECTIVE_ON = Sets.newHashSet(Blocks.CLAY, Blocks.DIRT, Blocks.FARMLAND, Blocks.GRASS, Blocks.GRAVEL, Blocks.MYCELIUM, Blocks.SAND, Blocks.SNOW, Blocks.SNOW_LAYER, Blocks.SOUL_SAND); - public ItemBoundShovel() - { + public ItemBoundShovel() { super("shovel", 1, EFFECTIVE_ON); } @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) - { + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { return true; } @Override - public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) - { + public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) { return true; } @Override - protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) - { + protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) { if (world.isRemote) return; @@ -72,12 +65,9 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider BlockPos playerPos = player.getPosition(); - for (int i = -range; i <= range; i++) - { - for (int j = 0; j <= 2 * range; j++) - { - for (int k = -range; k <= range; k++) - { + for (int i = -range; i <= range; i++) { + for (int j = 0; j <= 2 * range; j++) { + for (int k = -range; k <= range; k++) { BlockPos blockPos = playerPos.add(i, j, k); BlockStack blockStack = BlockStack.getStackFromPos(world, blockPos); @@ -92,16 +82,13 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) continue; - if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1) - { + if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1) { float strengthVsBlock = getStrVsBlock(stack, blockStack.getState()); - if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos)) - { + if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos)) { if (silkTouch && blockStack.getBlock().canSilkHarvest(world, blockPos, world.getBlockState(blockPos), player)) drops.add(new ItemStackWrapper(blockStack)); - else - { + else { List itemDrops = blockStack.getBlock().getDrops(world, blockPos, world.getBlockState(blockPos), fortuneLvl); for (ItemStack stacks : itemDrops) drops.add(ItemStackWrapper.getHolder(stacks)); @@ -120,11 +107,9 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider } @Override - public Multimap getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) - { + public Multimap getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) { Multimap multimap = super.getItemAttributeModifiers(equipmentSlot); - if (equipmentSlot == EntityEquipmentSlot.MAINHAND) - { + if (equipmentSlot == EntityEquipmentSlot.MAINHAND) { multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 5, 0)); multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -2.5, 0)); } @@ -133,21 +118,18 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider @Override @SideOnly(Side.CLIENT) - public ItemMeshDefinition getMeshDefinition() - { + public ItemMeshDefinition getMeshDefinition() { return new CustomMeshDefinitionActivatable("ItemBoundShovel"); } @Nullable @Override - public ResourceLocation getCustomLocation() - { + public ResourceLocation getCustomLocation() { return null; } @Override - public List getVariants() - { + public List getVariants() { List ret = new ArrayList(); ret.add("active=true"); ret.add("active=false"); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java index 056afef8..339d6d9b 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java @@ -1,12 +1,20 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nullable; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.iface.IActivatable; +import WayofTime.bloodmagic.api.iface.IBindable; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; import WayofTime.bloodmagic.api.util.helper.NetworkHelper; +import WayofTime.bloodmagic.api.util.helper.PlayerHelper; +import WayofTime.bloodmagic.client.IMeshProvider; +import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import WayofTime.bloodmagic.util.Utils; +import WayofTime.bloodmagic.util.helper.TextHelper; +import com.google.common.base.Strings; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.util.ITooltipFlag; @@ -17,7 +25,6 @@ import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.util.ActionResult; @@ -28,25 +35,13 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.iface.IActivatable; -import WayofTime.bloodmagic.api.iface.IBindable; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.api.util.helper.PlayerHelper; -import WayofTime.bloodmagic.client.IMeshProvider; -import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.util.helper.TextHelper; -import com.google.common.base.Strings; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; -public class ItemBoundSword extends ItemSword implements IBindable, IActivatable, IMeshProvider -{ - public ItemBoundSword() - { +public class ItemBoundSword extends ItemSword implements IBindable, IActivatable, IMeshProvider { + public ItemBoundSword() { super(RegistrarBloodMagicItems.BOUND_TOOL_MATERIAL); setUnlocalizedName(BloodMagic.MODID + ".bound.sword"); @@ -54,8 +49,7 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (player.isSneaking()) setActivatedState(stack, !getActivated(stack)); @@ -74,8 +68,7 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable } @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) - { + public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) { if (Strings.isNullOrEmpty(getOwnerUUID(stack))) { setActivatedState(stack, false); return; @@ -86,27 +79,23 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable } @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) - { + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { return true; } @Override - public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) - { + public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) { return true; } @Override - public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) - { + public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { return oldStack.getItem() != newStack.getItem(); } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs tab, NonNullList subItems) - { + public void getSubItems(CreativeTabs tab, NonNullList subItems) { if (!isInCreativeTab(tab)) return; @@ -115,8 +104,7 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; @@ -130,11 +118,9 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable } @Override - public Multimap getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack) - { + public Multimap getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack) { Multimap multimap = HashMultimap.create(); - if (equipmentSlot == EntityEquipmentSlot.MAINHAND) - { + if (equipmentSlot == EntityEquipmentSlot.MAINHAND) { multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getActivated(stack) ? 8 : 2, 0)); multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4, 0)); } @@ -143,21 +129,18 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable @Override @SideOnly(Side.CLIENT) - public ItemMeshDefinition getMeshDefinition() - { + public ItemMeshDefinition getMeshDefinition() { return new CustomMeshDefinitionActivatable("ItemBoundSword"); } @Nullable @Override - public ResourceLocation getCustomLocation() - { + public ResourceLocation getCustomLocation() { return null; } @Override - public List getVariants() - { + public List getVariants() { List ret = new ArrayList(); ret.add("active=true"); ret.add("active=false"); @@ -167,36 +150,30 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable // IBindable @Override - public boolean onBind(EntityPlayer player, ItemStack stack) - { + public boolean onBind(EntityPlayer player, ItemStack stack) { return true; } @Override - public String getOwnerName(ItemStack stack) - { + public String getOwnerName(ItemStack stack) { return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getString(Constants.NBT.OWNER_NAME) : null; } @Override - public String getOwnerUUID(ItemStack stack) - { + public String getOwnerUUID(ItemStack stack) { return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getString(Constants.NBT.OWNER_UUID) : null; } // IActivatable @Override - public boolean getActivated(ItemStack stack) - { + public boolean getActivated(ItemStack stack) { return stack != null && NBTHelper.checkNBT(stack).getTagCompound().getBoolean(Constants.NBT.ACTIVATED); } @Override - public ItemStack setActivatedState(ItemStack stack, boolean activated) - { - if (stack != null) - { + public ItemStack setActivatedState(ItemStack stack, boolean activated) { + if (stack != null) { NBTHelper.checkNBT(stack).getTagCompound().setBoolean(Constants.NBT.ACTIVATED, activated); return stack; } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java index d5ea23b5..3ce61755 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java @@ -1,17 +1,22 @@ package WayofTime.bloodmagic.item; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.ItemStackWrapper; +import WayofTime.bloodmagic.api.event.BoundToolEvent; +import WayofTime.bloodmagic.api.iface.IActivatable; +import WayofTime.bloodmagic.api.iface.IBindable; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; import WayofTime.bloodmagic.api.util.helper.NetworkHelper; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import WayofTime.bloodmagic.util.Utils; +import WayofTime.bloodmagic.util.helper.TextHelper; import com.google.common.base.Strings; import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; +import com.google.common.collect.Multiset; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.util.ITooltipFlag; @@ -23,7 +28,6 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.EnumAction; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; import net.minecraft.util.ActionResult; @@ -35,30 +39,20 @@ import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.ItemStackWrapper; -import WayofTime.bloodmagic.api.event.BoundToolEvent; -import WayofTime.bloodmagic.api.iface.IActivatable; -import WayofTime.bloodmagic.api.iface.IBindable; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.util.helper.TextHelper; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Multiset; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; -public class ItemBoundTool extends ItemTool implements IBindable, IActivatable -{ +public class ItemBoundTool extends ItemTool implements IBindable, IActivatable { + public final int chargeTime = 30; protected final String tooltipBase; private final String name; - public Map heldDownMap = new HashMap(); public Map heldDownCountMap = new HashMap(); - public final int chargeTime = 30; - - public ItemBoundTool(String name, float damage, Set effectiveBlocks) - { + public ItemBoundTool(String name, float damage, Set effectiveBlocks) { super(damage, 1, RegistrarBloodMagicItems.BOUND_TOOL_MATERIAL, effectiveBlocks); setUnlocalizedName(BloodMagic.MODID + ".bound." + name); setCreativeTab(BloodMagic.TAB_BM); @@ -69,20 +63,17 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable } @Override - public float getStrVsBlock(ItemStack stack, IBlockState state) - { + public float getStrVsBlock(ItemStack stack, IBlockState state) { return getActivated(stack) ? toolMaterial.getEfficiencyOnProperMaterial() : 1.0F; } @Override - public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) - { + public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { return slotChanged; } @Override - public void getSubItems(CreativeTabs tab, NonNullList subItems) - { + public void getSubItems(CreativeTabs tab, NonNullList subItems) { if (isInCreativeTab(tab)) return; @@ -90,19 +81,16 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable } @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) - { + public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) { if (Strings.isNullOrEmpty(getOwnerUUID(stack))) { setActivatedState(stack, false); return; } - if (entity instanceof EntityPlayer && getActivated(stack) && isSelected && getBeingHeldDown(stack) && stack == ((EntityPlayer) entity).getActiveItemStack()) - { + if (entity instanceof EntityPlayer && getActivated(stack) && isSelected && getBeingHeldDown(stack) && stack == ((EntityPlayer) entity).getActiveItemStack()) { EntityPlayer player = (EntityPlayer) entity; setHeldDownCount(stack, Math.min(player.getItemInUseCount(), chargeTime)); - } else if (!isSelected) - { + } else if (!isSelected) { setBeingHeldDown(stack, false); } @@ -110,41 +98,35 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage((EntityPlayer) entity, 20); } - protected int getHeldDownCount(ItemStack stack) - { + protected int getHeldDownCount(ItemStack stack) { if (!heldDownCountMap.containsKey(stack)) return 0; return heldDownCountMap.get(stack); } - protected void setHeldDownCount(ItemStack stack, int count) - { + protected void setHeldDownCount(ItemStack stack, int count) { heldDownCountMap.put(stack, count); } - protected boolean getBeingHeldDown(ItemStack stack) - { + protected boolean getBeingHeldDown(ItemStack stack) { if (!heldDownMap.containsKey(stack)) return false; return heldDownMap.get(stack); } - protected void setBeingHeldDown(ItemStack stack, boolean heldDown) - { + protected void setBeingHeldDown(ItemStack stack, boolean heldDown) { heldDownMap.put(stack, heldDown); } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (player.isSneaking()) setActivatedState(stack, !getActivated(stack)); - if (!player.isSneaking() && getActivated(stack)) - { + if (!player.isSneaking() && getActivated(stack)) { BoundToolEvent.Charge event = new BoundToolEvent.Charge(player, stack); if (MinecraftForge.EVENT_BUS.post(event)) return new ActionResult<>(EnumActionResult.FAIL, event.result); @@ -157,13 +139,10 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable } @Override - public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) - { - if (entityLiving instanceof EntityPlayer) - { + public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) { + if (entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entityLiving; - if (!player.isSneaking() && getActivated(stack)) - { + if (!player.isSneaking() && getActivated(stack)) { int i = this.getMaxItemUseDuration(stack) - timeLeft; BoundToolEvent.Release event = new BoundToolEvent.Release(player, stack, i); if (MinecraftForge.EVENT_BUS.post(event)) @@ -177,39 +156,33 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable } } - protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) - { + protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) { } @Override - public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entityLiving) - { + public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entityLiving) { return stack; } @Override - public int getMaxItemUseDuration(ItemStack stack) - { + public int getMaxItemUseDuration(ItemStack stack) { return 72000; } @Override - public EnumAction getItemUseAction(ItemStack stack) - { + public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.BOW; } @Override - public int getItemEnchantability() - { + public int getItemEnchantability() { return 50; } @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (TextHelper.canTranslate(tooltipBase + "desc")) tooltip.add(TextHelper.localizeEffect(tooltipBase + "desc")); @@ -225,80 +198,51 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable } @Override - public Set getToolClasses(ItemStack stack) - { + public Set getToolClasses(ItemStack stack) { return ImmutableSet.of(name); } - public Multimap getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) - { + public Multimap getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) { return ArrayListMultimap.create(); // No-op } @Override - public boolean showDurabilityBar(ItemStack stack) - { + public boolean showDurabilityBar(ItemStack stack) { return getActivated(stack) && getBeingHeldDown(stack); } @Override - public double getDurabilityForDisplay(ItemStack stack) - { + public double getDurabilityForDisplay(ItemStack stack) { return ((double) -Math.min(getHeldDownCount(stack), chargeTime) / chargeTime) + 1; } - protected static void dropStacks(Multiset drops, World world, BlockPos posToDrop) - { - for (Multiset.Entry entry : drops.entrySet()) - { - int count = entry.getCount(); - ItemStackWrapper stack = entry.getElement(); - int maxStackSize = stack.item.getItemStackLimit(stack.toStack(1)); - - while (count >= maxStackSize) - { - world.spawnEntity(new EntityItem(world, posToDrop.getX(), posToDrop.getY(), posToDrop.getZ(), stack.toStack(maxStackSize))); - count -= maxStackSize; - } - - if (count > 0) - world.spawnEntity(new EntityItem(world, posToDrop.getX(), posToDrop.getY(), posToDrop.getZ(), stack.toStack(count))); - } + @Override + public String getOwnerName(ItemStack stack) { + return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getString(Constants.NBT.OWNER_NAME) : null; } // IBindable @Override - public String getOwnerName(ItemStack stack) - { - return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getString(Constants.NBT.OWNER_NAME) : null; - } - - @Override - public String getOwnerUUID(ItemStack stack) - { + public String getOwnerUUID(ItemStack stack) { return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getString(Constants.NBT.OWNER_UUID) : null; } @Override - public boolean onBind(EntityPlayer player, ItemStack stack) - { + public boolean onBind(EntityPlayer player, ItemStack stack) { return true; } + @Override + public boolean getActivated(ItemStack stack) { + return stack != null && NBTHelper.checkNBT(stack).getTagCompound().getBoolean(Constants.NBT.ACTIVATED); + } + // IActivatable @Override - public boolean getActivated(ItemStack stack) - { - return stack != null && NBTHelper.checkNBT(stack).getTagCompound().getBoolean(Constants.NBT.ACTIVATED); - } - - @Override - public ItemStack setActivatedState(ItemStack stack, boolean activated) - { - if (stack != null) - { + public ItemStack setActivatedState(ItemStack stack, boolean activated) { + if (stack != null) { NBTHelper.checkNBT(stack).getTagCompound().setBoolean(Constants.NBT.ACTIVATED, activated); return stack; } @@ -325,4 +269,20 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable public int getChargeTime() { return chargeTime; } + + protected static void dropStacks(Multiset drops, World world, BlockPos posToDrop) { + for (Multiset.Entry entry : drops.entrySet()) { + int count = entry.getCount(); + ItemStackWrapper stack = entry.getElement(); + int maxStackSize = stack.item.getItemStackLimit(stack.toStack(1)); + + while (count >= maxStackSize) { + world.spawnEntity(new EntityItem(world, posToDrop.getX(), posToDrop.getY(), posToDrop.getZ(), stack.toStack(maxStackSize))); + count -= maxStackSize; + } + + if (count > 0) + world.spawnEntity(new EntityItem(world, posToDrop.getX(), posToDrop.getY(), posToDrop.getZ(), stack.toStack(count))); + } + } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemComponent.java b/src/main/java/WayofTime/bloodmagic/item/ItemComponent.java index eee18546..4363715e 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemComponent.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemComponent.java @@ -1,26 +1,21 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; - -public class ItemComponent extends Item implements IVariantProvider -{ - private static ArrayList names = new ArrayList(); +import java.util.ArrayList; +import java.util.List; +public class ItemComponent extends Item implements IVariantProvider { public static final String REAGENT_WATER = "reagentWater"; public static final String REAGENT_LAVA = "reagentLava"; public static final String REAGENT_AIR = "reagentAir"; @@ -54,9 +49,9 @@ public class ItemComponent extends Item implements IVariantProvider public static final String REAGENT_CLAW = "reagentClaw"; public static final String REAGENT_BOUNCE = "reagentBounce"; public static final String REAGENT_FROST = "reagentFrost"; + private static ArrayList names = new ArrayList(); - public ItemComponent() - { + public ItemComponent() { super(); setUnlocalizedName(BloodMagic.MODID + ".baseComponent."); @@ -66,8 +61,7 @@ public class ItemComponent extends Item implements IVariantProvider buildItemList(); } - private void buildItemList() - { + private void buildItemList() { names.add(0, REAGENT_WATER); names.add(1, REAGENT_LAVA); names.add(2, REAGENT_AIR); @@ -104,15 +98,13 @@ public class ItemComponent extends Item implements IVariantProvider } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names.get(stack.getItemDamage()); } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; @@ -120,22 +112,19 @@ public class ItemComponent extends Item implements IVariantProvider list.add(new ItemStack(this, 1, i)); } - public static ItemStack getStack(String name) - { - return new ItemStack(RegistrarBloodMagicItems.COMPONENT, 1, names.indexOf(name)); - } - @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); for (String name : names) ret.add(new ImmutablePair(names.indexOf(name), "type=" + name)); return ret; } - public static ItemStack getStack(String key, int stackSize) - { + public static ItemStack getStack(String name) { + return new ItemStack(RegistrarBloodMagicItems.COMPONENT, 1, names.indexOf(name)); + } + + public static ItemStack getStack(String key, int stackSize) { ItemStack stack = getStack(key); stack.setCount(stackSize); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemDaggerOfSacrifice.java b/src/main/java/WayofTime/bloodmagic/item/ItemDaggerOfSacrifice.java index eeca6902..b5cdb49c 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemDaggerOfSacrifice.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemDaggerOfSacrifice.java @@ -1,9 +1,10 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.util.helper.PlayerSacrificeHelper; +import WayofTime.bloodmagic.api.util.helper.PurificationHelper; import WayofTime.bloodmagic.api_impl.BloodMagicAPI; +import WayofTime.bloodmagic.client.IVariantProvider; import com.google.common.collect.Lists; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.IMob; @@ -14,23 +15,15 @@ import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.SoundCategory; - import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.fml.common.registry.EntityEntry; import net.minecraftforge.fml.common.registry.EntityRegistry; -import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.ConfigHandler; -import WayofTime.bloodmagic.api.util.helper.PlayerSacrificeHelper; -import WayofTime.bloodmagic.api.util.helper.PurificationHelper; -import WayofTime.bloodmagic.client.IVariantProvider; +import java.util.List; -public class ItemDaggerOfSacrifice extends Item implements IVariantProvider -{ - public ItemDaggerOfSacrifice() - { +public class ItemDaggerOfSacrifice extends Item implements IVariantProvider { + public ItemDaggerOfSacrifice() { super(); setUnlocalizedName(BloodMagic.MODID + ".daggerOfSacrifice"); setCreativeTab(BloodMagic.TAB_BM); @@ -39,8 +32,7 @@ public class ItemDaggerOfSacrifice extends Item implements IVariantProvider } @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) - { + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { if (attacker instanceof FakePlayer) return false; @@ -66,18 +58,15 @@ public class ItemDaggerOfSacrifice extends Item implements IVariantProvider return false; int lifeEssence = (int) (lifeEssenceRatio * target.getHealth()); - if (target instanceof EntityAnimal) - { + if (target instanceof EntityAnimal) { lifeEssence = (int) (lifeEssence * (1 + PurificationHelper.getCurrentPurity((EntityAnimal) target))); } - if (target.isChild()) - { + if (target.isChild()) { lifeEssence *= 0.5F; } - if (PlayerSacrificeHelper.findAndFillAltar(attacker.getEntityWorld(), target, lifeEssence, true)) - { + if (PlayerSacrificeHelper.findAndFillAltar(attacker.getEntityWorld(), target, lifeEssence, true)) { target.getEntityWorld().playSound(null, target.posX, target.posY, target.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (target.getEntityWorld().rand.nextFloat() - target.getEntityWorld().rand.nextFloat()) * 0.8F); target.setHealth(-1); target.onDeath(WayofTime.bloodmagic.api.BloodMagicAPI.damageSource); @@ -87,8 +76,7 @@ public class ItemDaggerOfSacrifice extends Item implements IVariantProvider } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = Lists.newArrayList(); ret.add(Pair.of(0, "type=normal")); return ret; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemDemonCrystal.java b/src/main/java/WayofTime/bloodmagic/item/ItemDemonCrystal.java index ee9c01a8..bd8143dc 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemDemonCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemDemonCrystal.java @@ -1,8 +1,10 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.soul.IDiscreteDemonWill; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import com.google.common.collect.Lists; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @@ -11,18 +13,13 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.MathHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.soul.IDiscreteDemonWill; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import java.util.ArrayList; +import java.util.List; -public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVariantProvider -{ +public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVariantProvider { public static final ArrayList NAMES = Lists.newArrayList(); public static final String CRYSTAL_DEFAULT = "crystalDefault"; @@ -31,8 +28,7 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria public static final String CRYSTAL_DESTRUCTIVE = "crystalDestructive"; public static final String CRYSTAL_STEADFAST = "crystalSteadfast"; - public ItemDemonCrystal() - { + public ItemDemonCrystal() { super(); setUnlocalizedName(BloodMagic.MODID + ".demonCrystal."); @@ -42,8 +38,7 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria buildItemList(); } - private void buildItemList() - { + private void buildItemList() { NAMES.add(0, CRYSTAL_DEFAULT); NAMES.add(1, CRYSTAL_CORROSIVE); NAMES.add(2, CRYSTAL_DESTRUCTIVE); @@ -52,15 +47,13 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + NAMES.get(stack.getItemDamage()); } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; @@ -68,25 +61,17 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria list.add(new ItemStack(this, 1, i)); } - public static ItemStack getStack(String name) - { - return new ItemStack(RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL, 1, NAMES.indexOf(name)); - } - @Override - public double getWill(ItemStack willStack) - { + public double getWill(ItemStack willStack) { return getDiscretization(willStack) * willStack.getCount(); } @Override - public double drainWill(ItemStack willStack, double drainAmount) - { + public double drainWill(ItemStack willStack, double drainAmount) { double discretization = getDiscretization(willStack); int drainedNumber = (int) Math.floor(Math.min(willStack.getCount() * discretization, drainAmount) / discretization); - if (drainedNumber > 0) - { + if (drainedNumber > 0) { willStack.shrink(drainedNumber); return drainedNumber * discretization; } @@ -95,23 +80,24 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria } @Override - public double getDiscretization(ItemStack willStack) - { + public double getDiscretization(ItemStack willStack) { return 50; } @Override - public EnumDemonWillType getType(ItemStack willStack) - { + public EnumDemonWillType getType(ItemStack willStack) { return EnumDemonWillType.values()[MathHelper.clamp(willStack.getMetadata(), 0, EnumDemonWillType.values().length - 1)]; } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); for (String name : NAMES) ret.add(new ImmutablePair(NAMES.indexOf(name), "type=" + name)); return ret; } + + public static ItemStack getStack(String name) { + return new ItemStack(RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL, 1, NAMES.indexOf(name)); + } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemDemonWillGauge.java b/src/main/java/WayofTime/bloodmagic/item/ItemDemonWillGauge.java index c46debd1..68dcc7cf 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemDemonWillGauge.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemDemonWillGauge.java @@ -1,9 +1,9 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.iface.IDemonWillViewer; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -11,19 +11,15 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.iface.IDemonWillViewer; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.util.helper.TextHelper; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; -public class ItemDemonWillGauge extends Item implements IVariantProvider, IDemonWillViewer -{ - public ItemDemonWillGauge() - { +public class ItemDemonWillGauge extends Item implements IVariantProvider, IDemonWillViewer { + public ItemDemonWillGauge() { setUnlocalizedName(BloodMagic.MODID + ".willGauge"); setMaxStackSize(1); setCreativeTab(BloodMagic.TAB_BM); @@ -31,28 +27,24 @@ public class ItemDemonWillGauge extends Item implements IVariantProvider, IDemon @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.willGauge")))); } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=willgauge")); return ret; } @Override - public boolean canSeeDemonWillAura(World world, ItemStack stack, EntityPlayer player) - { + public boolean canSeeDemonWillAura(World world, ItemStack stack, EntityPlayer player) { return true; } @Override - public int getDemonWillAuraResolution(World world, ItemStack stack, EntityPlayer player) - { + public int getDemonWillAuraResolution(World world, ItemStack stack, EntityPlayer player) { return 100; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemExperienceBook.java b/src/main/java/WayofTime/bloodmagic/item/ItemExperienceBook.java index 17282fd5..45fad002 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemExperienceBook.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemExperienceBook.java @@ -1,8 +1,9 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; @@ -15,19 +16,14 @@ import net.minecraft.util.EnumHand; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.util.helper.TextHelper; +import java.util.ArrayList; +import java.util.List; -public class ItemExperienceBook extends Item implements IVariantProvider -{ - public ItemExperienceBook() - { +public class ItemExperienceBook extends Item implements IVariantProvider { + public ItemExperienceBook() { setUnlocalizedName(BloodMagic.MODID + ".experienceTome"); setMaxStackSize(1); setCreativeTab(BloodMagic.TAB_BM); @@ -35,15 +31,13 @@ public class ItemExperienceBook extends Item implements IVariantProvider @Override @SideOnly(Side.CLIENT) - public boolean hasEffect(ItemStack stack) - { + public boolean hasEffect(ItemStack stack) { return true; } @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.experienceTome")); if (!stack.hasTagCompound()) @@ -56,11 +50,9 @@ public class ItemExperienceBook extends Item implements IVariantProvider } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if (!world.isRemote) - { + if (!world.isRemote) { if (player.isSneaking()) absorbOneLevelExpFromPlayer(stack, player); else @@ -71,15 +63,13 @@ public class ItemExperienceBook extends Item implements IVariantProvider } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=experiencetome")); return ret; } - public void giveOneLevelExpToPlayer(ItemStack stack, EntityPlayer player) - { + public void giveOneLevelExpToPlayer(ItemStack stack, EntityPlayer player) { float progress = player.experience; int expToNext = getExperienceForNextLevel(player.experienceLevel); @@ -88,37 +78,30 @@ public class ItemExperienceBook extends Item implements IVariantProvider System.out.println("Needed: " + neededExp + ", contained: " + containedExp + ", exp to next: " + expToNext); - if (containedExp >= neededExp) - { + if (containedExp >= neededExp) { setStoredExperience(stack, containedExp - neededExp); addPlayerXP(player, neededExp); - if (player.experienceLevel % 5 == 0) - { + if (player.experienceLevel % 5 == 0) { float f = player.experienceLevel > 30 ? 1.0F : (float) player.experienceLevel / 30.0F; player.getEntityWorld().playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_LEVELUP, player.getSoundCategory(), f * 0.75F, 1.0F); } - } else - { + } else { setStoredExperience(stack, 0); addPlayerXP(player, (int) containedExp); } } - public void absorbOneLevelExpFromPlayer(ItemStack stack, EntityPlayer player) - { + public void absorbOneLevelExpFromPlayer(ItemStack stack, EntityPlayer player) { float progress = player.experience; - if (progress > 0) - { + if (progress > 0) { int expDeduction = (int) getExperienceAcquiredToNext(player); - if (expDeduction > 0) - { + if (expDeduction > 0) { addPlayerXP(player, -expDeduction); addExperience(stack, expDeduction); } - } else if (progress == 0 && player.experienceLevel > 0) - { + } else if (progress == 0 && player.experienceLevel > 0) { int expDeduction = getExperienceForNextLevel(player.experienceLevel - 1); addPlayerXP(player, -expDeduction); addExperience(stack, expDeduction); @@ -126,13 +109,11 @@ public class ItemExperienceBook extends Item implements IVariantProvider } // Credits to Ender IO for some of the experience code, although now modified slightly for my convenience. - public static int getPlayerXP(EntityPlayer player) - { + public static int getPlayerXP(EntityPlayer player) { return (int) (getExperienceForLevel(player.experienceLevel) + (player.experience * player.xpBarCap())); } - public static void addPlayerXP(EntityPlayer player, int amount) - { + public static void addPlayerXP(EntityPlayer player, int amount) { int experience = Math.max(0, getPlayerXP(player) + amount); player.experienceTotal = experience; player.experienceLevel = getLevelForExperience(experience); @@ -140,8 +121,7 @@ public class ItemExperienceBook extends Item implements IVariantProvider player.experience = (float) (experience - expForLevel) / (float) player.xpBarCap(); } - public static void setStoredExperience(ItemStack stack, double exp) - { + public static void setStoredExperience(ItemStack stack, double exp) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -149,8 +129,7 @@ public class ItemExperienceBook extends Item implements IVariantProvider tag.setDouble("experience", exp); } - public static double getStoredExperience(ItemStack stack) - { + public static double getStoredExperience(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -158,65 +137,50 @@ public class ItemExperienceBook extends Item implements IVariantProvider return tag.getDouble("experience"); } - public static void addExperience(ItemStack stack, double exp) - { + public static void addExperience(ItemStack stack, double exp) { setStoredExperience(stack, getStoredExperience(stack) + exp); } - public static int getExperienceForNextLevel(int currentLevel) - { - if (currentLevel < 16) - { + public static int getExperienceForNextLevel(int currentLevel) { + if (currentLevel < 16) { return 2 * currentLevel + 7; - } else if (currentLevel < 31) - { + } else if (currentLevel < 31) { return 5 * currentLevel - 38; - } else - { + } else { return 9 * currentLevel - 158; } } //TODO: Change to calculation form. - public static int getExperienceForLevel(int level) - { - if (level >= 21863) - { + public static int getExperienceForLevel(int level) { + if (level >= 21863) { return Integer.MAX_VALUE; } - if (level == 0) - { + if (level == 0) { return 0; } int res = 0; - for (int i = 0; i < level; i++) - { + for (int i = 0; i < level; i++) { res += getExperienceForNextLevel(i); } return res; } - public static double getExperienceAcquiredToNext(EntityPlayer player) - { + public static double getExperienceAcquiredToNext(EntityPlayer player) { return player.experience * player.xpBarCap(); } - public static int getLevelForExperience(double exp) - { - if (exp <= 352) - { + public static int getLevelForExperience(double exp) { + if (exp <= 352) { return (int) Math.floor(solveParabola(1, 6, -exp)); - } else if (exp <= 1507) - { + } else if (exp <= 1507) { return (int) Math.floor(solveParabola(2.5, -40.5, 360 - exp)); - } else - { + } else { return (int) Math.floor(solveParabola(4.5, -162.5, 2220 - exp)); } } - public static double solveParabola(double a, double b, double c) - { + public static double solveParabola(double a, double b, double c) { return (-b + Math.sqrt(b * b - 4 * a * c)) / (2 * a); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemInscriptionTool.java b/src/main/java/WayofTime/bloodmagic/item/ItemInscriptionTool.java index b39f8814..4481c2a2 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemInscriptionTool.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemInscriptionTool.java @@ -1,15 +1,16 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.ritual.EnumRuneType; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.block.BlockRitualStone; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.block.state.IBlockState; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; @@ -20,21 +21,15 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.block.BlockRitualStone; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.util.helper.TextHelper; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; -public class ItemInscriptionTool extends ItemBindableBase implements IVariantProvider -{ - public ItemInscriptionTool() - { +public class ItemInscriptionTool extends ItemBindableBase implements IVariantProvider { + public ItemInscriptionTool() { super(); setUnlocalizedName(BloodMagic.MODID + ".scribe."); @@ -42,20 +37,17 @@ public class ItemInscriptionTool extends ItemBindableBase implements IVariantPro } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + EnumRuneType.values()[stack.getItemDamage()]; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; - for (int i = 1; i < EnumRuneType.values().length; i++) - { + for (int i = 1; i < EnumRuneType.values().length; i++) { ItemStack stack = NBTHelper.checkNBT(new ItemStack(this, 1, i)); stack.getTagCompound().setInteger(Constants.NBT.USES, 10); list.add(stack); @@ -63,19 +55,16 @@ public class ItemInscriptionTool extends ItemBindableBase implements IVariantPro } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) - { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); IBlockState state = world.getBlockState(pos); - if (state.getBlock() instanceof BlockRitualStone && !((BlockRitualStone) state.getBlock()).isRuneType(world, pos, getType(stack))) - { + if (state.getBlock() instanceof BlockRitualStone && !((BlockRitualStone) state.getBlock()).isRuneType(world, pos, getType(stack))) { stack = NBTHelper.checkNBT(stack); int uses = stack.getTagCompound().getInteger(Constants.NBT.USES); world.setBlockState(pos, state.withProperty(((BlockRitualStone) state.getBlock()).getProperty(), getType(stack))); - if (!player.capabilities.isCreativeMode) - { + if (!player.capabilities.isCreativeMode) { stack.getTagCompound().setInteger(Constants.NBT.USES, --uses); if (uses <= 0) player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY); @@ -87,46 +76,40 @@ public class ItemInscriptionTool extends ItemBindableBase implements IVariantPro } @Override - public boolean showDurabilityBar(ItemStack stack) - { + public boolean showDurabilityBar(ItemStack stack) { return stack.hasTagCompound(); } @Override - public double getDurabilityForDisplay(ItemStack stack) - { + public double getDurabilityForDisplay(ItemStack stack) { int uses = stack.getTagCompound().getInteger(Constants.NBT.USES); return 1.0 - ((double) uses / (double) 10); } @Override - public int getRGBDurabilityForDisplay(ItemStack stack) - { + public int getRGBDurabilityForDisplay(ItemStack stack) { int uses = stack.getTagCompound().getInteger(Constants.NBT.USES); - return MathHelper.hsvToRGB(Math.max(0.0F, (float)(uses) / 10) / 3.0F, 1.0F, 1.0F); + return MathHelper.hsvToRGB(Math.max(0.0F, (float) (uses) / 10) / 3.0F, 1.0F, 1.0F); } @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) { list.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.inscriber.desc")))); super.addInformation(stack, world, list, flag); } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); for (int i = 1; i < EnumRuneType.values().length; i++) ret.add(new ImmutablePair(i, "type=" + EnumRuneType.values()[i].name())); return ret; } - public EnumRuneType getType(ItemStack stack) - { + public EnumRuneType getType(ItemStack stack) { return EnumRuneType.values()[stack.getItemDamage()]; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java b/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java index f31b92e2..c224ea7d 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java @@ -1,31 +1,26 @@ package WayofTime.bloodmagic.item; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; +import WayofTime.bloodmagic.api.util.helper.PlayerHelper; +import WayofTime.bloodmagic.client.IVariantProvider; import com.google.common.collect.Lists; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; - import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -import WayofTime.bloodmagic.api.util.helper.PlayerHelper; -import WayofTime.bloodmagic.client.IVariantProvider; +import java.util.List; -public class ItemLavaCrystal extends ItemBindableBase implements IVariantProvider -{ - public ItemLavaCrystal() - { +public class ItemLavaCrystal extends ItemBindableBase implements IVariantProvider { + public ItemLavaCrystal() { super(); setUnlocalizedName(BloodMagic.MODID + ".lavaCrystal"); } @Override - public ItemStack getContainerItem(ItemStack itemStack) - { + public ItemStack getContainerItem(ItemStack itemStack) { NetworkHelper.getSoulNetwork(this.getOwnerUUID(itemStack)).syphon(25); ItemStack copiedStack = itemStack.copy(); copiedStack.setItemDamage(copiedStack.getItemDamage()); @@ -34,8 +29,7 @@ public class ItemLavaCrystal extends ItemBindableBase implements IVariantProvide } @Override - public boolean hasContainerItem(ItemStack itemStack) - { + public boolean hasContainerItem(ItemStack itemStack) { return true; } @@ -59,8 +53,7 @@ public class ItemLavaCrystal extends ItemBindableBase implements IVariantProvide } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = Lists.newArrayList(); ret.add(Pair.of(0, "type=normal")); return ret; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemPotionFlask.java b/src/main/java/WayofTime/bloodmagic/item/ItemPotionFlask.java index 7e14e342..4cd45ea4 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemPotionFlask.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemPotionFlask.java @@ -1,7 +1,6 @@ package WayofTime.bloodmagic.item; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.util.helper.NBTHelper; import WayofTime.bloodmagic.client.IMeshProvider; import WayofTime.bloodmagic.util.helper.TextHelper; @@ -25,14 +24,11 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; - import javax.annotation.Nullable; +import java.util.List; -public class ItemPotionFlask extends Item implements IMeshProvider -{ - public ItemPotionFlask() - { +public class ItemPotionFlask extends Item implements IMeshProvider { + public ItemPotionFlask() { setUnlocalizedName(BloodMagic.MODID + ".potionFlask"); setCreativeTab(BloodMagic.TAB_BM); setMaxStackSize(1); @@ -41,27 +37,22 @@ public class ItemPotionFlask extends Item implements IMeshProvider } @Override - public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entityLiving) - { + public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entityLiving) { EntityPlayer player = entityLiving instanceof EntityPlayer ? (EntityPlayer) entityLiving : null; int remainingUses = stack.getMaxDamage() - stack.getItemDamage(); - if (remainingUses <= 0) - { + if (remainingUses <= 0) { NBTHelper.checkNBT(stack); stack.getTagCompound().setBoolean("empty", true); return stack; } - if (player == null || !player.capabilities.isCreativeMode) - { + if (player == null || !player.capabilities.isCreativeMode) { stack.setItemDamage(stack.getItemDamage() + 1); } - if (!world.isRemote) - { - for (PotionEffect potioneffect : PotionUtils.getEffectsFromStack(stack)) - { + if (!world.isRemote) { + for (PotionEffect potioneffect : PotionUtils.getEffectsFromStack(stack)) { entityLiving.addPotionEffect(new PotionEffect(potioneffect)); } } @@ -70,20 +61,17 @@ public class ItemPotionFlask extends Item implements IMeshProvider } @Override - public int getMaxItemUseDuration(ItemStack stack) - { + public int getMaxItemUseDuration(ItemStack stack) { return 32; } @Override - public EnumAction getItemUseAction(ItemStack stack) - { + public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.DRINK; } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) - { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); int remainingUses = stack.getMaxDamage() - stack.getItemDamage(); if (remainingUses > 0 || !stack.hasTagCompound() || !stack.getTagCompound().hasKey("empty")) @@ -91,8 +79,7 @@ public class ItemPotionFlask extends Item implements IMeshProvider RayTraceResult trace = rayTrace(world, player, true); - if (trace.typeOfHit == RayTraceResult.Type.BLOCK && world.getBlockState(trace.getBlockPos()).getMaterial() == Material.WATER) - { + if (trace.typeOfHit == RayTraceResult.Type.BLOCK && world.getBlockState(trace.getBlockPos()).getMaterial() == Material.WATER) { world.playSound(player, player.posX, player.posY, player.posZ, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.NEUTRAL, 1.0F, 1.0F); player.setHeldItem(hand, new ItemStack(this)); return EnumActionResult.SUCCESS; @@ -102,12 +89,10 @@ public class ItemPotionFlask extends Item implements IMeshProvider } @Override - public ActionResult onItemRightClick(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) - { + if (remainingUses <= 0) { NBTHelper.checkNBT(stack); stack.getTagCompound().setBoolean("empty", true); return new ActionResult(EnumActionResult.PASS, stack); @@ -118,8 +103,7 @@ public class ItemPotionFlask extends Item implements IMeshProvider @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { PotionUtils.addPotionTooltip(stack, tooltip, 1.0F); tooltip.add(""); tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.potion.uses", stack.getMaxDamage() - stack.getItemDamage())); @@ -138,8 +122,7 @@ public class ItemPotionFlask extends Item implements IMeshProvider @SideOnly(Side.CLIENT) @Override - public ItemMeshDefinition getMeshDefinition() - { + public ItemMeshDefinition getMeshDefinition() { return stack -> { boolean full = true; if (stack.hasTagCompound() && stack.getTagCompound().hasKey("empty")) @@ -150,14 +133,12 @@ public class ItemPotionFlask extends Item implements IMeshProvider @Nullable @Override - public ResourceLocation getCustomLocation() - { + public ResourceLocation getCustomLocation() { return null; } @Override - public List getVariants() - { + public List getVariants() { return Lists.newArrayList("full=true", "full=false"); } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java b/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java index 5417cf22..616b01a2 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java @@ -1,9 +1,20 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.registry.RitualRegistry; +import WayofTime.bloodmagic.api.ritual.EnumRuneType; +import WayofTime.bloodmagic.api.ritual.Ritual; +import WayofTime.bloodmagic.api.ritual.RitualComponent; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.util.helper.RitualHelper; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; +import WayofTime.bloodmagic.tile.TileMasterRitualStone; +import WayofTime.bloodmagic.util.ChatUtil; +import WayofTime.bloodmagic.util.Utils; +import WayofTime.bloodmagic.util.handler.event.ClientHandler; +import WayofTime.bloodmagic.util.helper.TextHelper; import com.google.common.base.Strings; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -23,35 +34,19 @@ import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; import org.lwjgl.input.Keyboard; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.registry.RitualRegistry; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.util.helper.RitualHelper; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; -import WayofTime.bloodmagic.tile.TileMasterRitualStone; -import WayofTime.bloodmagic.util.ChatUtil; -import WayofTime.bloodmagic.util.Utils; -import WayofTime.bloodmagic.util.handler.event.ClientHandler; -import WayofTime.bloodmagic.util.helper.TextHelper; - -public class ItemRitualDiviner extends Item implements IVariantProvider -{ - public static String[] names = { "normal", "dusk", "dawn" }; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +public class ItemRitualDiviner extends Item implements IVariantProvider { public static final String tooltipBase = "tooltip.bloodmagic.diviner."; + public static String[] names = {"normal", "dusk", "dawn"}; - public ItemRitualDiviner() - { + public ItemRitualDiviner() { setUnlocalizedName(BloodMagic.MODID + ".ritualDiviner"); setCreativeTab(BloodMagic.TAB_BM); setHasSubtypes(true); @@ -59,14 +54,12 @@ public class ItemRitualDiviner extends Item implements IVariantProvider } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } @Override - public String getHighlightTip(ItemStack stack, String displayName) - { + public String getHighlightTip(ItemStack stack, String displayName) { if (Strings.isNullOrEmpty(getCurrentRitual(stack))) return displayName; @@ -79,8 +72,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; @@ -89,21 +81,16 @@ public class ItemRitualDiviner extends Item implements IVariantProvider } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) - { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); - if (player.isSneaking()) - { - if (world.isRemote) - { + if (player.isSneaking()) { + if (world.isRemote) { trySetDisplayedRitual(stack, world, pos); } return EnumActionResult.SUCCESS; - } else if (addRuneToRitual(stack, world, pos, player)) - { - if (world.isRemote) - { + } else if (addRuneToRitual(stack, world, pos, player)) { + if (world.isRemote) { spawnParticles(world, pos.up(), 15); } @@ -116,64 +103,47 @@ public class ItemRitualDiviner extends Item implements IVariantProvider /** * Adds a single rune to the ritual. - * - * @param stack - * - The Ritual Diviner stack - * @param world - * - The World - * @param pos - * - Block Position of the MRS. - * @param player - * - The Player attempting to place the ritual - * + * + * @param stack - The Ritual Diviner stack + * @param world - The World + * @param pos - Block Position of the MRS. + * @param player - The Player attempting to place the ritual * @return - True if a rune was successfully added */ - public boolean addRuneToRitual(ItemStack stack, World world, BlockPos pos, EntityPlayer player) - { + public boolean addRuneToRitual(ItemStack stack, World world, BlockPos pos, EntityPlayer player) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileMasterRitualStone) - { + if (tile instanceof TileMasterRitualStone) { Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(stack)); - if (ritual != null) - { + if (ritual != null) { EnumFacing direction = getDirection(stack); - for (RitualComponent component : ritual.getComponents()) - { - if (!canPlaceRitualStone(component.getRuneType(), stack)) - { + for (RitualComponent component : ritual.getComponents()) { + if (!canPlaceRitualStone(component.getRuneType(), stack)) { return false; } BlockPos offset = component.getOffset(direction); BlockPos newPos = pos.add(offset); IBlockState state = world.getBlockState(newPos); Block block = state.getBlock(); - if (RitualHelper.isRune(world, newPos)) - { - if (RitualHelper.isRuneType(world, newPos, component.getRuneType())) - { - if (world.isRemote) - { + if (RitualHelper.isRune(world, newPos)) { + if (RitualHelper.isRuneType(world, newPos, component.getRuneType())) { + if (world.isRemote) { undisplayHologram(); } - } else - { + } else { // Replace existing ritual stone RitualHelper.setRuneType(world, newPos, component.getRuneType()); return true; } - } else if (block.isAir(state, world, newPos) || block.isReplaceable(world, newPos)) - { - if (!consumeStone(stack, world, player)) - { + } else if (block.isAir(state, world, newPos) || block.isReplaceable(world, newPos)) { + if (!consumeStone(stack, world, player)) { return false; } int meta = component.getRuneType().ordinal(); IBlockState newState = RegistrarBloodMagicBlocks.RITUAL_STONE.getStateFromMeta(meta); world.setBlockState(newPos, newState); return true; - } else - { + } else { return false; // TODO: Possibly replace the block with a // ritual stone } @@ -185,17 +155,14 @@ public class ItemRitualDiviner extends Item implements IVariantProvider } @SideOnly(Side.CLIENT) - public void trySetDisplayedRitual(ItemStack itemStack, World world, BlockPos pos) - { + public void trySetDisplayedRitual(ItemStack itemStack, World world, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileMasterRitualStone) - { + if (tile instanceof TileMasterRitualStone) { Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(itemStack)); TileMasterRitualStone masterRitualStone = (TileMasterRitualStone) tile; - if (ritual != null) - { + if (ritual != null) { EnumFacing direction = getDirection(itemStack); ClientHandler.setRitualHolo(masterRitualStone, ritual, direction, true); } @@ -203,32 +170,26 @@ public class ItemRitualDiviner extends Item implements IVariantProvider } @SideOnly(Side.CLIENT) - public void undisplayHologram() - { + public void undisplayHologram() { ClientHandler.setRitualHoloToNull(); } // TODO: Make this work for any IRitualStone - public boolean consumeStone(ItemStack stack, World world, EntityPlayer player) - { - if (player.capabilities.isCreativeMode) - { + public boolean consumeStone(ItemStack stack, World world, EntityPlayer player) { + if (player.capabilities.isCreativeMode) { return true; } NonNullList inventory = player.inventory.mainInventory; - for (ItemStack newStack : inventory) - { + for (ItemStack newStack : inventory) { if (newStack.isEmpty()) { continue; } Item item = newStack.getItem(); - if (item instanceof ItemBlock) - { + if (item instanceof ItemBlock) { Block block = ((ItemBlock) item).getBlock(); - if (block == RegistrarBloodMagicBlocks.RITUAL_STONE) - { + if (block == RegistrarBloodMagicBlocks.RITUAL_STONE) { newStack.shrink(1); return true; } @@ -240,32 +201,26 @@ public class ItemRitualDiviner extends Item implements IVariantProvider @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(stack)); - if (ritual != null) - { + if (ritual != null) { tooltip.add(TextHelper.localize("tooltip.bloodmagic.diviner.currentRitual") + TextHelper.localize(ritual.getUnlocalizedName())); boolean sneaking = Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT); boolean extraInfo = sneaking && Keyboard.isKeyDown(Keyboard.KEY_M); - if (extraInfo) - { + if (extraInfo) { tooltip.add(""); - for (EnumDemonWillType type : EnumDemonWillType.values()) - { - if (TextHelper.canTranslate(ritual.getUnlocalizedName() + "." + type.getName().toLowerCase() + ".info")) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { + if (TextHelper.canTranslate(ritual.getUnlocalizedName() + "." + type.getName().toLowerCase() + ".info")) { tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect(ritual.getUnlocalizedName() + "." + type.getName().toLowerCase() + ".info")))); } } - } else if (sneaking) - { + } else if (sneaking) { tooltip.add(TextHelper.localize(tooltipBase + "currentDirection", Utils.toFancyCasing(getDirection(stack).getName()))); tooltip.add(""); ArrayList componentList = ritual.getComponents(); @@ -279,31 +234,29 @@ public class ItemRitualDiviner extends Item implements IVariantProvider int dawnRunes = 0; int totalRunes = componentList.size(); - for (RitualComponent component : componentList) - { - switch (component.getRuneType()) - { - case BLANK: - blankRunes++; - break; - case AIR: - airRunes++; - break; - case EARTH: - earthRunes++; - break; - case FIRE: - fireRunes++; - break; - case WATER: - waterRunes++; - break; - case DUSK: - duskRunes++; - break; - case DAWN: - dawnRunes++; - break; + for (RitualComponent component : componentList) { + switch (component.getRuneType()) { + case BLANK: + blankRunes++; + break; + case AIR: + airRunes++; + break; + case EARTH: + earthRunes++; + break; + case FIRE: + fireRunes++; + break; + case WATER: + waterRunes++; + break; + case DUSK: + duskRunes++; + break; + case DAWN: + dawnRunes++; + break; } } @@ -324,11 +277,9 @@ public class ItemRitualDiviner extends Item implements IVariantProvider tooltip.add(""); tooltip.add(TextHelper.localize(tooltipBase + "totalRune", totalRunes)); - } else - { + } else { tooltip.add(""); - if (TextHelper.canTranslate(ritual.getUnlocalizedName() + ".info")) - { + if (TextHelper.canTranslate(ritual.getUnlocalizedName() + ".info")) { tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect(ritual.getUnlocalizedName() + ".info")))); tooltip.add(""); } @@ -340,19 +291,15 @@ public class ItemRitualDiviner extends Item implements IVariantProvider } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); RayTraceResult ray = this.rayTrace(world, player, false); - if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) - { + if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) { return new ActionResult(EnumActionResult.PASS, stack); } - if (player.isSneaking()) - { - if (!world.isRemote) - { + if (player.isSneaking()) { + if (!world.isRemote) { cycleRitual(stack, player); } @@ -363,25 +310,19 @@ public class ItemRitualDiviner extends Item implements IVariantProvider } @Override - public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) - { - if (entityLiving instanceof EntityPlayer) - { + public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) { + if (entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entityLiving; RayTraceResult ray = this.rayTrace(player.getEntityWorld(), player, false); - if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) - { + if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) { return false; } - if (!player.isSwingInProgress) - { - if (player.isSneaking()) - { + if (!player.isSwingInProgress) { + if (player.isSneaking()) { cycleRitualBackwards(stack, player); - } else - { + } else { cycleDirection(stack, player); } } @@ -391,8 +332,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=basic")); ret.add(new ImmutablePair(1, "type=dusk")); @@ -400,41 +340,36 @@ public class ItemRitualDiviner extends Item implements IVariantProvider return ret; } - public void cycleDirection(ItemStack stack, EntityPlayer player) - { + public void cycleDirection(ItemStack stack, EntityPlayer player) { EnumFacing direction = getDirection(stack); EnumFacing newDirection; - switch (direction) - { - case NORTH: - newDirection = EnumFacing.EAST; - break; - case EAST: - newDirection = EnumFacing.SOUTH; - break; - case SOUTH: - newDirection = EnumFacing.WEST; - break; - case WEST: - newDirection = EnumFacing.NORTH; - break; - default: - newDirection = EnumFacing.NORTH; + switch (direction) { + case NORTH: + newDirection = EnumFacing.EAST; + break; + case EAST: + newDirection = EnumFacing.SOUTH; + break; + case SOUTH: + newDirection = EnumFacing.WEST; + break; + case WEST: + newDirection = EnumFacing.NORTH; + break; + default: + newDirection = EnumFacing.NORTH; } setDirection(stack, newDirection); notifyDirectionChange(newDirection, player); } - public void notifyDirectionChange(EnumFacing direction, EntityPlayer player) - { + public void notifyDirectionChange(EnumFacing direction, EntityPlayer player) { ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentDirection", Utils.toFancyCasing(direction.getName()))); } - public void setDirection(ItemStack stack, EnumFacing direction) - { - if (!stack.hasTagCompound()) - { + public void setDirection(ItemStack stack, EnumFacing direction) { + if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } @@ -443,10 +378,8 @@ public class ItemRitualDiviner extends Item implements IVariantProvider tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex()); } - public EnumFacing getDirection(ItemStack stack) - { - if (!stack.hasTagCompound()) - { + public EnumFacing getDirection(ItemStack stack) { + if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); return EnumFacing.NORTH; } @@ -454,8 +387,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider NBTTagCompound tag = stack.getTagCompound(); int dir = tag.getInteger(Constants.NBT.DIRECTION); - if (dir == 0) - { + if (dir == 0) { return EnumFacing.NORTH; } @@ -464,52 +396,42 @@ public class ItemRitualDiviner extends Item implements IVariantProvider /** * Cycles the selected ritual to the next available ritual that is enabled. - * - * @param stack - * - The ItemStack of the ritual diviner - * @param player - * - The player using the ritual diviner + * + * @param stack - The ItemStack of the ritual diviner + * @param player - The player using the ritual diviner */ - public void cycleRitual(ItemStack stack, EntityPlayer player) - { + public void cycleRitual(ItemStack stack, EntityPlayer player) { String key = getCurrentRitual(stack); List idList = RitualRegistry.getOrderedIds(); String firstId = ""; boolean foundId = false; boolean foundFirst = false; - for (String str : idList) - { + for (String str : idList) { Ritual ritual = RitualRegistry.getRitualForId(str); - if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual)) - { + if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual)) { continue; } - if (!foundFirst) - { + if (!foundFirst) { firstId = str; foundFirst = true; } - if (foundId) - { + if (foundId) { setCurrentRitual(stack, str); notifyRitualChange(str, player); return; - } else - { - if (str.equals(key)) - { + } else { + if (str.equals(key)) { foundId = true; continue; } } } - if (foundFirst) - { + if (foundFirst) { setCurrentRitual(stack, firstId); notifyRitualChange(firstId, player); } @@ -517,68 +439,56 @@ public class ItemRitualDiviner extends Item implements IVariantProvider /** * Does the same as cycleRitual but instead cycles backwards. - * + * * @param stack * @param player */ - public void cycleRitualBackwards(ItemStack stack, EntityPlayer player) - { + public void cycleRitualBackwards(ItemStack stack, EntityPlayer player) { String key = getCurrentRitual(stack); List idList = RitualRegistry.getOrderedIds(); String firstId = ""; boolean foundId = false; boolean foundFirst = false; - for (int i = idList.size() - 1; i >= 0; i--) - { + for (int i = idList.size() - 1; i >= 0; i--) { String str = idList.get(i); Ritual ritual = RitualRegistry.getRitualForId(str); - if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual)) - { + if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual)) { continue; } - if (!foundFirst) - { + if (!foundFirst) { firstId = str; foundFirst = true; } - if (foundId) - { + if (foundId) { setCurrentRitual(stack, str); notifyRitualChange(str, player); return; - } else - { - if (str.equals(key)) - { + } else { + if (str.equals(key)) { foundId = true; continue; } } } - if (foundFirst) - { + if (foundFirst) { setCurrentRitual(stack, firstId); notifyRitualChange(firstId, player); } } - public boolean canDivinerPerformRitual(ItemStack stack, Ritual ritual) - { - if (ritual == null) - { + public boolean canDivinerPerformRitual(ItemStack stack, Ritual ritual) { + if (ritual == null) { return false; } ArrayList components = ritual.getComponents(); - for (RitualComponent component : components) - { - if (!canPlaceRitualStone(component.getRuneType(), stack)) - { + for (RitualComponent component : components) { + if (!canPlaceRitualStone(component.getRuneType(), stack)) { return false; } } @@ -586,19 +496,15 @@ public class ItemRitualDiviner extends Item implements IVariantProvider return true; } - public void notifyRitualChange(String key, EntityPlayer player) - { + public void notifyRitualChange(String key, EntityPlayer player) { Ritual ritual = RitualRegistry.getRitualForId(key); - if (ritual != null) - { + if (ritual != null) { player.sendStatusMessage(new TextComponentTranslation(ritual.getUnlocalizedName()), true); } } - public void setCurrentRitual(ItemStack stack, String key) - { - if (!stack.hasTagCompound()) - { + public void setCurrentRitual(ItemStack stack, String key) { + if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } @@ -607,10 +513,8 @@ public class ItemRitualDiviner extends Item implements IVariantProvider tag.setString(Constants.NBT.CURRENT_RITUAL, key); } - public String getCurrentRitual(ItemStack stack) - { - if (!stack.hasTagCompound()) - { + public String getCurrentRitual(ItemStack stack) { + if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } @@ -618,44 +522,37 @@ public class ItemRitualDiviner extends Item implements IVariantProvider return tag.getString(Constants.NBT.CURRENT_RITUAL); } - public boolean canPlaceRitualStone(EnumRuneType rune, ItemStack stack) - { + public boolean canPlaceRitualStone(EnumRuneType rune, ItemStack stack) { int meta = stack.getItemDamage(); - switch (rune) - { - case BLANK: - case AIR: - case EARTH: - case FIRE: - case WATER: - return true; - case DUSK: - return meta >= 1; - case DAWN: - return meta >= 2; + switch (rune) { + case BLANK: + case AIR: + case EARTH: + case FIRE: + case WATER: + return true; + case DUSK: + return meta >= 1; + case DAWN: + return meta >= 2; } return false; } - public static void spawnParticles(World worldIn, BlockPos pos, int amount) - { + public static void spawnParticles(World worldIn, BlockPos pos, int amount) { IBlockState state = worldIn.getBlockState(pos); Block block = worldIn.getBlockState(pos).getBlock(); - if (block.isAir(state, worldIn, pos)) - { - for (int i = 0; i < amount; ++i) - { + if (block.isAir(state, worldIn, pos)) { + for (int i = 0; i < amount; ++i) { double d0 = itemRand.nextGaussian() * 0.02D; double d1 = itemRand.nextGaussian() * 0.02D; double d2 = itemRand.nextGaussian() * 0.02D; worldIn.spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, (double) ((float) pos.getX() + itemRand.nextFloat()), (double) pos.getY() + (double) itemRand.nextFloat(), (double) ((float) pos.getZ() + itemRand.nextFloat()), d0, d1, d2, new int[0]); } - } else - { - for (int i1 = 0; i1 < amount; ++i1) - { + } else { + for (int i1 = 0; i1 < amount; ++i1) { double d0 = itemRand.nextGaussian() * 0.02D; double d1 = itemRand.nextGaussian() * 0.02D; double d2 = itemRand.nextGaussian() * 0.02D; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemRitualReader.java b/src/main/java/WayofTime/bloodmagic/item/ItemRitualReader.java index 17f457dd..455e3f1c 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemRitualReader.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemRitualReader.java @@ -1,10 +1,15 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.ritual.EnumRitualReaderState; +import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.soul.IDiscreteDemonWill; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.util.ChatUtil; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -18,27 +23,18 @@ import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; import org.lwjgl.input.Keyboard; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.ritual.EnumRitualReaderState; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.soul.IDiscreteDemonWill; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.util.ChatUtil; -import WayofTime.bloodmagic.util.helper.TextHelper; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; -public class ItemRitualReader extends Item implements IVariantProvider -{ +public class ItemRitualReader extends Item implements IVariantProvider { public static final String tooltipBase = "tooltip.bloodmagic.ritualReader."; - public ItemRitualReader() - { + public ItemRitualReader() { super(); setUnlocalizedName(BloodMagic.MODID + ".ritualReader"); setMaxStackSize(1); @@ -46,8 +42,7 @@ public class ItemRitualReader extends Item implements IVariantProvider @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag tooltipFlag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag tooltipFlag) { if (!stack.hasTagCompound()) return; @@ -58,11 +53,9 @@ public class ItemRitualReader extends Item implements IVariantProvider boolean sneaking = Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT); - if (sneaking) - { + if (sneaking) { tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect(tooltipBase + "desc." + state.toString().toLowerCase())))); - } else - { + } else { tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.extraInfo")); } @@ -70,19 +63,15 @@ public class ItemRitualReader extends Item implements IVariantProvider } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); RayTraceResult ray = this.rayTrace(world, player, false); - if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) - { + if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) { return new ActionResult(EnumActionResult.PASS, stack); } - if (player.isSneaking()) - { - if (!world.isRemote) - { + if (player.isSneaking()) { + if (!world.isRemote) { cycleReader(stack, player); } @@ -93,80 +82,65 @@ public class ItemRitualReader extends Item implements IVariantProvider } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) - { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); - if (!world.isRemote) - { + if (!world.isRemote) { EnumRitualReaderState state = this.getState(stack); TileEntity tile = world.getTileEntity(pos); - if (tile instanceof IMasterRitualStone) - { + if (tile instanceof IMasterRitualStone) { IMasterRitualStone master = (IMasterRitualStone) tile; this.setMasterBlockPos(stack, pos); this.setBlockPos(stack, BlockPos.ORIGIN); - switch (state) - { - case INFORMATION: - master.provideInformationOfRitualToPlayer(player); - break; - case SET_AREA: - String range = this.getCurrentBlockRange(stack); - if (player.isSneaking()) - { - String newRange = master.getNextBlockRange(range); - range = newRange; - this.setCurrentBlockRange(stack, newRange); - } - - master.provideInformationOfRangeToPlayer(player, range); - break; - case SET_WILL_TYPES: - List typeList = new ArrayList(); - NonNullList inv = player.inventory.mainInventory; - for (int i = 0; i < 9; i++) - { - ItemStack testStack = inv.get(i); - if (testStack.isEmpty()) - { - continue; + switch (state) { + case INFORMATION: + master.provideInformationOfRitualToPlayer(player); + break; + case SET_AREA: + String range = this.getCurrentBlockRange(stack); + if (player.isSneaking()) { + String newRange = master.getNextBlockRange(range); + range = newRange; + this.setCurrentBlockRange(stack, newRange); } - if (testStack.getItem() instanceof IDiscreteDemonWill) - { - EnumDemonWillType type = ((IDiscreteDemonWill) testStack.getItem()).getType(testStack); - if (!typeList.contains(type)) - { - typeList.add(type); + master.provideInformationOfRangeToPlayer(player, range); + break; + case SET_WILL_TYPES: + List typeList = new ArrayList(); + NonNullList inv = player.inventory.mainInventory; + for (int i = 0; i < 9; i++) { + ItemStack testStack = inv.get(i); + if (testStack.isEmpty()) { + continue; + } + + if (testStack.getItem() instanceof IDiscreteDemonWill) { + EnumDemonWillType type = ((IDiscreteDemonWill) testStack.getItem()).getType(testStack); + if (!typeList.contains(type)) { + typeList.add(type); + } } } - } - master.setActiveWillConfig(player, typeList); - master.provideInformationOfWillConfigToPlayer(player, typeList); - break; + master.setActiveWillConfig(player, typeList); + master.provideInformationOfWillConfigToPlayer(player, typeList); + break; } return EnumActionResult.FAIL; - } else - { - if (state == EnumRitualReaderState.SET_AREA) - { + } else { + if (state == EnumRitualReaderState.SET_AREA) { BlockPos masterPos = this.getMasterBlockPos(stack); - if (!masterPos.equals(BlockPos.ORIGIN)) - { + if (!masterPos.equals(BlockPos.ORIGIN)) { BlockPos containedPos = getBlockPos(stack); - if (containedPos.equals(BlockPos.ORIGIN)) - { + if (containedPos.equals(BlockPos.ORIGIN)) { this.setBlockPos(stack, pos.subtract(masterPos)); ChatUtil.sendNoSpam(player, new TextComponentTranslation("ritual.bloodmagic.blockRange.firstBlock")); //TODO: Notify player. - } else - { + } else { tile = world.getTileEntity(masterPos); - if (tile instanceof IMasterRitualStone) - { + if (tile instanceof IMasterRitualStone) { IMasterRitualStone master = (IMasterRitualStone) tile; master.setBlockRangeByBounds(player, this.getCurrentBlockRange(stack), containedPos, pos.subtract(masterPos)); } @@ -181,14 +155,12 @@ public class ItemRitualReader extends Item implements IVariantProvider return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); } - public BlockPos getBlockPos(ItemStack stack) - { + public BlockPos getBlockPos(ItemStack stack) { stack = NBTHelper.checkNBT(stack); return new BlockPos(stack.getTagCompound().getInteger(Constants.NBT.X_COORD), stack.getTagCompound().getInteger(Constants.NBT.Y_COORD), stack.getTagCompound().getInteger(Constants.NBT.Z_COORD)); } - public ItemStack setBlockPos(ItemStack stack, BlockPos pos) - { + public ItemStack setBlockPos(ItemStack stack, BlockPos pos) { stack = NBTHelper.checkNBT(stack); NBTTagCompound itemTag = stack.getTagCompound(); itemTag.setInteger(Constants.NBT.X_COORD, pos.getX()); @@ -197,14 +169,12 @@ public class ItemRitualReader extends Item implements IVariantProvider return stack; } - public BlockPos getMasterBlockPos(ItemStack stack) - { + public BlockPos getMasterBlockPos(ItemStack stack) { stack = NBTHelper.checkNBT(stack); return new BlockPos(stack.getTagCompound().getInteger(Constants.NBT.X_COORD + "master"), stack.getTagCompound().getInteger(Constants.NBT.Y_COORD + "master"), stack.getTagCompound().getInteger(Constants.NBT.Z_COORD + "master")); } - public ItemStack setMasterBlockPos(ItemStack stack, BlockPos pos) - { + public ItemStack setMasterBlockPos(ItemStack stack, BlockPos pos) { stack = NBTHelper.checkNBT(stack); NBTTagCompound itemTag = stack.getTagCompound(); itemTag.setInteger(Constants.NBT.X_COORD + "master", pos.getX()); @@ -213,8 +183,7 @@ public class ItemRitualReader extends Item implements IVariantProvider return stack; } - public String getCurrentBlockRange(ItemStack stack) - { + public String getCurrentBlockRange(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -222,8 +191,7 @@ public class ItemRitualReader extends Item implements IVariantProvider return tag.getString("range"); } - public void setCurrentBlockRange(ItemStack stack, String range) - { + public void setCurrentBlockRange(ItemStack stack, String range) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -231,8 +199,7 @@ public class ItemRitualReader extends Item implements IVariantProvider tag.setString("range", range); } - public void cycleReader(ItemStack stack, EntityPlayer player) - { + public void cycleReader(ItemStack stack, EntityPlayer player) { EnumRitualReaderState prevState = getState(stack); int val = prevState.ordinal(); int nextVal = val + 1 >= EnumRitualReaderState.values().length ? 0 : val + 1; @@ -242,13 +209,11 @@ public class ItemRitualReader extends Item implements IVariantProvider notifyPlayerOfStateChange(nextState, player); } - public void notifyPlayerOfStateChange(EnumRitualReaderState state, EntityPlayer player) - { + public void notifyPlayerOfStateChange(EnumRitualReaderState state, EntityPlayer player) { ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentState", new TextComponentTranslation(tooltipBase + state.toString().toLowerCase()))); } - public void setState(ItemStack stack, EnumRitualReaderState state) - { + public void setState(ItemStack stack, EnumRitualReaderState state) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -256,10 +221,8 @@ public class ItemRitualReader extends Item implements IVariantProvider tag.setInteger(Constants.NBT.RITUAL_READER, state.ordinal()); } - public EnumRitualReaderState getState(ItemStack stack) - { - if (!stack.hasTagCompound()) - { + public EnumRitualReaderState getState(ItemStack stack) { + if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); return EnumRitualReaderState.INFORMATION; } @@ -270,8 +233,7 @@ public class ItemRitualReader extends Item implements IVariantProvider } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=normal")); return ret; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java b/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java index 72991095..e8c841ca 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java @@ -1,11 +1,16 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.ConfigHandler; +import WayofTime.bloodmagic.api.BloodMagicAPI; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.api.util.helper.PlayerHelper; +import WayofTime.bloodmagic.api.util.helper.PlayerSacrificeHelper; import WayofTime.bloodmagic.client.IMeshProvider; +import WayofTime.bloodmagic.tile.TileAltar; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.util.ITooltipFlag; @@ -25,24 +30,15 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.BloodMagicAPI; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.api.util.helper.PlayerHelper; -import WayofTime.bloodmagic.api.util.helper.PlayerSacrificeHelper; -import WayofTime.bloodmagic.tile.TileAltar; -import WayofTime.bloodmagic.util.helper.TextHelper; - import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; -public class ItemSacrificialDagger extends Item implements IMeshProvider -{ - public static String[] names = { "normal", "creative" }; +public class ItemSacrificialDagger extends Item implements IMeshProvider { + public static String[] names = {"normal", "creative"}; - public ItemSacrificialDagger() - { + public ItemSacrificialDagger() { super(); setUnlocalizedName(BloodMagic.MODID + ".sacrificialDagger."); @@ -53,15 +49,13 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; @@ -70,8 +64,7 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider } @Override - public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) { list.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.sacrificialDagger.desc")))); if (stack.getItemDamage() == 1) @@ -79,33 +72,28 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider } @Override - public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) - { + public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) { if (entityLiving instanceof EntityPlayer && !entityLiving.getEntityWorld().isRemote) PlayerSacrificeHelper.sacrificePlayerHealth((EntityPlayer) entityLiving); } @Override - public int getMaxItemUseDuration(ItemStack stack) - { + public int getMaxItemUseDuration(ItemStack stack) { return 72000; } @Override - public EnumAction getItemUseAction(ItemStack stack) - { + public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.BOW; } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (PlayerHelper.isFakePlayer(player)) return super.onItemRightClick(world, player, hand); - if (this.canUseForSacrifice(stack)) - { + if (this.canUseForSacrifice(stack)) { player.setActiveHand(hand); return new ActionResult(EnumActionResult.SUCCESS, stack); } @@ -113,27 +101,23 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider int lpAdded = ConfigHandler.sacrificialDaggerConversion * ConfigHandler.sacrificialDaggerDamage; RayTraceResult rayTrace = rayTrace(world, player, false); - if (rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) - { + if (rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) { TileEntity tile = world.getTileEntity(rayTrace.getBlockPos()); if (tile != null && tile instanceof TileAltar && stack.getItemDamage() == 1) lpAdded = ((TileAltar) tile).getCapacity(); } - if (!player.capabilities.isCreativeMode) - { + if (!player.capabilities.isCreativeMode) { SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(player, true, true, ConfigHandler.sacrificialDaggerDamage, lpAdded); if (MinecraftForge.EVENT_BUS.post(evt)) return super.onItemRightClick(world, player, hand); - if (evt.shouldDrainHealth) - { + if (evt.shouldDrainHealth) { player.hurtResistantTime = 0; player.attackEntityFrom(BloodMagicAPI.damageSource, 0.001F); player.setHealth(Math.max(player.getHealth() - ConfigHandler.sacrificialDaggerDamage, 0.0001f)); - if (player.getHealth() <= 0.001f) - { + if (player.getHealth() <= 0.001f) { player.onDeath(BloodMagicAPI.damageSource); player.setHealth(0); } @@ -164,38 +148,31 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider } @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) - { + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { if (!world.isRemote && entity instanceof EntityPlayer) this.setUseForSacrifice(stack, this.isPlayerPreparedForSacrifice(world, (EntityPlayer) entity)); } - public boolean isPlayerPreparedForSacrifice(World world, EntityPlayer player) - { + public boolean isPlayerPreparedForSacrifice(World world, EntityPlayer player) { return !world.isRemote && (PlayerSacrificeHelper.getPlayerIncense(player) > 0); } - public boolean canUseForSacrifice(ItemStack stack) - { + public boolean canUseForSacrifice(ItemStack stack) { stack = NBTHelper.checkNBT(stack); return stack.getTagCompound().getBoolean(Constants.NBT.SACRIFICE); } - public void setUseForSacrifice(ItemStack stack, boolean sacrifice) - { + public void setUseForSacrifice(ItemStack stack, boolean sacrifice) { stack = NBTHelper.checkNBT(stack); stack.getTagCompound().setBoolean(Constants.NBT.SACRIFICE, sacrifice); } @Override @SideOnly(Side.CLIENT) - public ItemMeshDefinition getMeshDefinition() - { - return new ItemMeshDefinition() - { + public ItemMeshDefinition getMeshDefinition() { + return new ItemMeshDefinition() { @Override - public ModelResourceLocation getModelLocation(ItemStack stack) - { + public ModelResourceLocation getModelLocation(ItemStack stack) { String variant = "type=normal"; if (stack.getItemDamage() != 0) variant = "type=creative"; @@ -209,8 +186,7 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider } @Override - public List getVariants() - { + public List getVariants() { List variants = new ArrayList(); variants.add("type=normal"); variants.add("type=creative"); @@ -220,8 +196,7 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider @Nullable @Override - public ResourceLocation getCustomLocation() - { + public ResourceLocation getCustomLocation() { return null; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemSanguineBook.java b/src/main/java/WayofTime/bloodmagic/item/ItemSanguineBook.java index f1e84cfd..f17328f6 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemSanguineBook.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemSanguineBook.java @@ -33,33 +33,27 @@ import org.apache.commons.lang3.tuple.Pair; import java.util.Collections; import java.util.List; -public class ItemSanguineBook extends Item implements IVariantProvider, IAltarManipulator -{ +public class ItemSanguineBook extends Item implements IVariantProvider, IAltarManipulator { private EnumAltarTier currentDisplayedTier = EnumAltarTier.ONE; - public ItemSanguineBook() - { + public ItemSanguineBook() { setUnlocalizedName(BloodMagic.MODID + ".sanguineBook"); setCreativeTab(BloodMagic.TAB_BM); setMaxStackSize(1); } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) - { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (world.isRemote) return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); IBlockState hitState = world.getBlockState(pos); - if (player.isSneaking()) - { - if (hitState.getBlock() instanceof IDocumentedBlock) - { + if (player.isSneaking()) { + if (hitState.getBlock() instanceof IDocumentedBlock) { trySetDisplayedTier(world, pos); IDocumentedBlock documentedBlock = (IDocumentedBlock) hitState.getBlock(); List docs = documentedBlock.getDocumentation(player, world, pos, hitState); - if (!docs.isEmpty()) - { + if (!docs.isEmpty()) { ChatUtil.sendNoSpam(player, docs.toArray(new ITextComponent[docs.size()])); return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); } @@ -70,8 +64,7 @@ public class ItemSanguineBook extends Item implements IVariantProvider, IAltarMa } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (world.isRemote) return super.onItemRightClick(world, player, hand); @@ -79,8 +72,7 @@ public class ItemSanguineBook extends Item implements IVariantProvider, IAltarMa stack = NBTHelper.checkNBT(stack); RayTraceResult rayTrace = rayTrace(world, player, false); - if (rayTrace == null || rayTrace.typeOfHit == RayTraceResult.Type.MISS || rayTrace.typeOfHit == RayTraceResult.Type.ENTITY) - { + if (rayTrace == null || rayTrace.typeOfHit == RayTraceResult.Type.MISS || rayTrace.typeOfHit == RayTraceResult.Type.ENTITY) { if (stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) >= EnumAltarTier.MAXTIERS - 1) stack.getTagCompound().setInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER, 0); else @@ -95,11 +87,9 @@ public class ItemSanguineBook extends Item implements IVariantProvider, IAltarMa return super.onItemRightClick(world, player, hand); } - public boolean trySetDisplayedTier(World world, BlockPos pos) - { + public boolean trySetDisplayedTier(World world, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileAltar) - { + if (tile instanceof TileAltar) { return !((TileAltar) tile).setCurrentTierDisplayed(currentDisplayedTier); } @@ -108,8 +98,7 @@ public class ItemSanguineBook extends Item implements IVariantProvider, IAltarMa @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.book.shifting")); @@ -120,8 +109,7 @@ public class ItemSanguineBook extends Item implements IVariantProvider, IAltarMa // IVariantProvider @Override - public List> getVariants() - { + public List> getVariants() { return Collections.singletonList(Pair.of(0, "type=normal")); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemSlate.java b/src/main/java/WayofTime/bloodmagic/item/ItemSlate.java index 4d746432..b2564ffb 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemSlate.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemSlate.java @@ -5,7 +5,6 @@ import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; @@ -19,12 +18,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -public class ItemSlate extends Item implements IVariantProvider -{ - public String[] names = { "blank", "reinforced", "imbued", "demonic", "ethereal" }; +public class ItemSlate extends Item implements IVariantProvider { + public String[] names = {"blank", "reinforced", "imbued", "demonic", "ethereal"}; - public ItemSlate() - { + public ItemSlate() { super(); setCreativeTab(BloodMagic.TAB_BM); @@ -34,8 +31,7 @@ public class ItemSlate extends Item implements IVariantProvider @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; @@ -44,21 +40,18 @@ public class ItemSlate extends Item implements IVariantProvider } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) { list.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.slate.desc")))); } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=blank")); ret.add(new ImmutablePair(1, "type=reinforced")); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemTelepositionFocus.java b/src/main/java/WayofTime/bloodmagic/item/ItemTelepositionFocus.java index e141b65c..64895638 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemTelepositionFocus.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemTelepositionFocus.java @@ -8,7 +8,6 @@ import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ActionResult; @@ -27,12 +26,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -public class ItemTelepositionFocus extends ItemBindableBase implements IVariantProvider -{ - public static String[] names = { "weak", "enhanced", "reinforced", "demonic" }; +public class ItemTelepositionFocus extends ItemBindableBase implements IVariantProvider { + public static String[] names = {"weak", "enhanced", "reinforced", "demonic"}; - public ItemTelepositionFocus() - { + public ItemTelepositionFocus() { super(); setUnlocalizedName(BloodMagic.MODID + ".focus."); @@ -42,15 +39,13 @@ public class ItemTelepositionFocus extends ItemBindableBase implements IVariantP } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; @@ -59,14 +54,11 @@ public class ItemTelepositionFocus extends ItemBindableBase implements IVariantP } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { - if (player.isSneaking()) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + if (player.isSneaking()) { RayTraceResult mop = rayTrace(world, player, false); - if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) - { + if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) { setBlockPos(player.getHeldItem(hand), world, mop.getBlockPos()); } } @@ -76,8 +68,7 @@ public class ItemTelepositionFocus extends ItemBindableBase implements IVariantP @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localize("tooltip.bloodmagic.telepositionFocus." + names[stack.getItemDamage()])))); super.addInformation(stack, world, tooltip, flag); @@ -89,16 +80,14 @@ public class ItemTelepositionFocus extends ItemBindableBase implements IVariantP NBTTagCompound tag = stack.getTagCompound(); BlockPos coords = getBlockPos(stack); - if (coords != null && tag != null) - { + if (coords != null && tag != null) { tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.coords", coords.getX(), coords.getY(), coords.getZ())); tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.dimension", tag.getInteger(Constants.NBT.DIMENSION_ID))); } } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=weak")); ret.add(new ImmutablePair(1, "type=enhanced")); @@ -107,20 +96,17 @@ public class ItemTelepositionFocus extends ItemBindableBase implements IVariantP return ret; } - public World getWorld(ItemStack stack) - { + public World getWorld(ItemStack stack) { stack = NBTHelper.checkNBT(stack); return DimensionManager.getWorld(stack.getTagCompound().getInteger(Constants.NBT.DIMENSION_ID)); } - public BlockPos getBlockPos(ItemStack stack) - { + public BlockPos getBlockPos(ItemStack stack) { stack = NBTHelper.checkNBT(stack); return new BlockPos(stack.getTagCompound().getInteger(Constants.NBT.X_COORD), stack.getTagCompound().getInteger(Constants.NBT.Y_COORD), stack.getTagCompound().getInteger(Constants.NBT.Z_COORD)); } - public ItemStack setBlockPos(ItemStack stack, World world, BlockPos pos) - { + public ItemStack setBlockPos(ItemStack stack, World world, BlockPos pos) { stack = NBTHelper.checkNBT(stack); NBTTagCompound itemTag = stack.getTagCompound(); itemTag.setInteger(Constants.NBT.X_COORD, pos.getX()); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTome.java b/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTome.java index f0de73dc..c7bd3f2c 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTome.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTome.java @@ -1,9 +1,13 @@ package WayofTime.bloodmagic.item; -import java.util.ArrayList; -import java.util.List; -import java.util.Map.Entry; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.api.util.helper.ItemHelper.LivingUpgrades; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.item.armour.ItemLivingArmour; +import WayofTime.bloodmagic.livingArmour.LivingArmour; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -16,23 +20,15 @@ import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.api.util.helper.ItemHelper.LivingUpgrades; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.item.armour.ItemLivingArmour; -import WayofTime.bloodmagic.livingArmour.LivingArmour; -import WayofTime.bloodmagic.util.helper.TextHelper; +import java.util.ArrayList; +import java.util.List; +import java.util.Map.Entry; -public class ItemUpgradeTome extends Item implements IVariantProvider -{ - public ItemUpgradeTome() - { +public class ItemUpgradeTome extends Item implements IVariantProvider { + public ItemUpgradeTome() { super(); setCreativeTab(BloodMagic.TAB_TOMES); @@ -42,31 +38,25 @@ public class ItemUpgradeTome extends Item implements IVariantProvider } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if (world.isRemote) - { + if (world.isRemote) { return super.onItemRightClick(world, player, hand); } LivingArmourUpgrade upgrade = LivingUpgrades.getUpgrade(stack); - if (upgrade == null) - { + if (upgrade == null) { return super.onItemRightClick(world, player, hand); } ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); - if (chestStack.getItem() instanceof ItemLivingArmour) - { + if (chestStack.getItem() instanceof ItemLivingArmour) { LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(chestStack); - if (armour == null) - { + if (armour == null) { return super.onItemRightClick(world, player, hand); } - if (armour.upgradeArmour(player, upgrade)) - { + if (armour.upgradeArmour(player, upgrade)) { ItemLivingArmour.setLivingArmour(chestStack, armour); // ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(stack, armour, false); stack.shrink(1); @@ -89,17 +79,14 @@ public class ItemUpgradeTome extends Item implements IVariantProvider @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; - for (Entry entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet()) - { + for (Entry entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet()) { String key = entry.getKey(); int maxLevel = entry.getValue(); - for (int i = 0; i < maxLevel; i++) - { + for (int i = 0; i < maxLevel; i++) { ItemStack stack = new ItemStack(this); LivingUpgrades.setKey(stack, key); LivingUpgrades.setLevel(stack, i); @@ -109,8 +96,7 @@ public class ItemUpgradeTome extends Item implements IVariantProvider } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=upgradetome")); return ret; @@ -118,13 +104,11 @@ public class ItemUpgradeTome extends Item implements IVariantProvider @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; LivingArmourUpgrade upgrade = LivingUpgrades.getUpgrade(stack); - if (upgrade != null) - { + if (upgrade != null) { tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmour.upgrade.level", TextHelper.localize(upgrade.getUnlocalizedName()), upgrade.getUpgradeLevel() + 1)); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTrainer.java b/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTrainer.java index 6198c6f5..f22ac3c0 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTrainer.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTrainer.java @@ -9,7 +9,6 @@ import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; @@ -23,10 +22,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; -public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVariantProvider -{ - public ItemUpgradeTrainer() - { +public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVariantProvider { + public ItemUpgradeTrainer() { super(); setCreativeTab(BloodMagic.TAB_TOMES); @@ -37,14 +34,12 @@ public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVarian @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; list.add(new ItemStack(this)); - for (Entry entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet()) - { + for (Entry entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet()) { String key = entry.getKey(); ItemStack stack = new ItemStack(this); LivingUpgrades.setKey(stack, key); @@ -54,26 +49,22 @@ public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVarian @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { // tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmour")))); if (!stack.hasTagCompound()) return; LivingArmourUpgrade upgrade = LivingUpgrades.getUpgrade(stack); - if (upgrade != null) - { + if (upgrade != null) { tooltip.add(TextHelper.localize(upgrade.getUnlocalizedName())); } } @Override - public List getTrainedUpgrades(ItemStack stack) - { + public List getTrainedUpgrades(ItemStack stack) { List keyList = new ArrayList(); String key = LivingUpgrades.getKey(stack); - if (!key.isEmpty()) - { + if (!key.isEmpty()) { keyList.add(key); } @@ -81,10 +72,8 @@ public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVarian } @Override - public boolean setTrainedUpgrades(ItemStack stack, List keys) - { - if (keys.isEmpty()) - { + public boolean setTrainedUpgrades(ItemStack stack, List keys) { + if (keys.isEmpty()) { return false; } @@ -93,8 +82,7 @@ public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVarian } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=upgradetrainer")); return ret; diff --git a/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemCuttingFluid.java b/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemCuttingFluid.java index d7cc1ebf..f65f891c 100644 --- a/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemCuttingFluid.java +++ b/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemCuttingFluid.java @@ -1,8 +1,11 @@ package WayofTime.bloodmagic.item.alchemy; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.iface.ICustomAlchemyConsumable; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @@ -12,26 +15,18 @@ import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.iface.ICustomAlchemyConsumable; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.util.helper.TextHelper; - -public class ItemCuttingFluid extends Item implements IVariantProvider, ICustomAlchemyConsumable -{ - private static ArrayList names = new ArrayList(); +import java.util.ArrayList; +import java.util.List; +public class ItemCuttingFluid extends Item implements IVariantProvider, ICustomAlchemyConsumable { public static final String BASIC = "basicCuttingFluid"; public static final String EXPLOSIVE = "explosive"; + private static ArrayList names = new ArrayList(); - public ItemCuttingFluid() - { + public ItemCuttingFluid() { super(); setUnlocalizedName(BloodMagic.MODID + ".cuttingFluid."); @@ -44,30 +39,26 @@ public class ItemCuttingFluid extends Item implements IVariantProvider, ICustomA @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; int max = getMaxUsesForFluid(stack); tooltip.add(TextHelper.localize("tooltip.bloodmagic.cuttingFluidRatio", max - getDamageOfFluid(stack), max)); } - private void buildItemList() - { + private void buildItemList() { names.add(0, BASIC); names.add(1, EXPLOSIVE); } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names.get(stack.getItemDamage()); } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; @@ -75,73 +66,63 @@ public class ItemCuttingFluid extends Item implements IVariantProvider, ICustomA list.add(new ItemStack(this, 1, i)); } - public static ItemStack getStack(String name) - { - return new ItemStack(RegistrarBloodMagicItems.CUTTING_FLUID, 1, names.indexOf(name)); - } - @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); for (String name : names) ret.add(new ImmutablePair(names.indexOf(name), "type=" + name)); return ret; } - public int getDamageOfFluid(ItemStack stack) - { + public int getDamageOfFluid(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getInteger("used"); } - public void applyDamageToFluid(ItemStack stack) - { + public void applyDamageToFluid(ItemStack stack) { int damage = Math.min(getDamageOfFluid(stack) + 1, getMaxUsesForFluid(stack)); NBTTagCompound tag = stack.getTagCompound(); tag.setInteger("used", damage); } - public int getMaxUsesForFluid(ItemStack stack) - { - switch (stack.getMetadata()) - { - case 0: - return 16; - case 1: - return 64; - default: - return 1; + public int getMaxUsesForFluid(ItemStack stack) { + switch (stack.getMetadata()) { + case 0: + return 16; + case 1: + return 64; + default: + return 1; } } @Override - public double getDurabilityForDisplay(ItemStack stack) - { + public double getDurabilityForDisplay(ItemStack stack) { return (double) (getDamageOfFluid(stack)) / (double) (getMaxUsesForFluid(stack)); } @Override - public boolean showDurabilityBar(ItemStack stack) - { + public boolean showDurabilityBar(ItemStack stack) { return getDamageOfFluid(stack) > 0; } @Override - public ItemStack drainUseOnAlchemyCraft(ItemStack stack) - { + public ItemStack drainUseOnAlchemyCraft(ItemStack stack) { applyDamageToFluid(stack); - if (getDamageOfFluid(stack) >= getMaxUsesForFluid(stack)) - { + if (getDamageOfFluid(stack) >= getMaxUsesForFluid(stack)) { return ItemStack.EMPTY; } return stack; } + public static ItemStack getStack(String name) { + return new ItemStack(RegistrarBloodMagicItems.CUTTING_FLUID, 1, names.indexOf(name)); + } + public static ArrayList getNames() { return names; } diff --git a/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemLivingArmourPointsUpgrade.java b/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemLivingArmourPointsUpgrade.java index 7c366b96..30e35efd 100644 --- a/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemLivingArmourPointsUpgrade.java +++ b/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemLivingArmourPointsUpgrade.java @@ -1,9 +1,12 @@ package WayofTime.bloodmagic.item.alchemy; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.item.armour.ItemLivingArmour; +import WayofTime.bloodmagic.livingArmour.LivingArmour; +import WayofTime.bloodmagic.util.helper.TextHelper; +import com.google.common.collect.Iterables; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; @@ -20,27 +23,18 @@ import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.item.armour.ItemLivingArmour; -import WayofTime.bloodmagic.livingArmour.LivingArmour; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.util.helper.TextHelper; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; -import com.google.common.collect.Iterables; - -public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvider -{ +public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvider { + public static final String DRAFT_ANGELUS = "draftAngelus"; private static ArrayList names = new ArrayList(); - public static final String DRAFT_ANGELUS = "draftAngelus"; - - public ItemLivingArmourPointsUpgrade() - { + public ItemLivingArmourPointsUpgrade() { super(); setUnlocalizedName(BloodMagic.MODID + ".livingPointUpgrade."); @@ -52,8 +46,7 @@ public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvi @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; @@ -61,29 +54,23 @@ public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvi } @Override - public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) - { + public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) { EntityPlayer player = entityLiving instanceof EntityPlayer ? (EntityPlayer) entityLiving : null; - if (player == null || !player.capabilities.isCreativeMode) - { + if (player == null || !player.capabilities.isCreativeMode) { stack.shrink(1); } - if (!worldIn.isRemote) - { + if (!worldIn.isRemote) { player.addPotionEffect(new PotionEffect(MobEffects.WITHER, 300, 5)); player.addPotionEffect(new PotionEffect(MobEffects.POISON, 300, 5)); player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 400, 1)); - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2]; LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { - if (armour.maxUpgradePoints < 200) - { + if (armour != null) { + if (armour.maxUpgradePoints < 200) { armour.maxUpgradePoints = 200; ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true); ItemLivingArmour.setLivingArmour(chestStack, armour); @@ -96,39 +83,33 @@ public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvi } @Override - public int getMaxItemUseDuration(ItemStack stack) - { + public int getMaxItemUseDuration(ItemStack stack) { return 32; } @Override - public EnumAction getItemUseAction(ItemStack stack) - { + public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.DRINK; } @Override - public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) - { + public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { playerIn.setActiveHand(hand); return new ActionResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand)); } - private void buildItemList() - { + private void buildItemList() { names.add(0, DRAFT_ANGELUS); } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names.get(stack.getItemDamage()); } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; @@ -136,22 +117,19 @@ public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvi list.add(new ItemStack(this, 1, i)); } - public static ItemStack getStack(String name) - { - return new ItemStack(RegistrarBloodMagicItems.POINTS_UPGRADE, 1, names.indexOf(name)); - } - @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); for (String name : names) ret.add(new ImmutablePair(names.indexOf(name), "type=" + name)); return ret; } - public static ItemStack getStack(String key, int stackSize) - { + public static ItemStack getStack(String name) { + return new ItemStack(RegistrarBloodMagicItems.POINTS_UPGRADE, 1, names.indexOf(name)); + } + + public static ItemStack getStack(String key, int stackSize) { ItemStack stack = getStack(key); stack.setCount(stackSize); diff --git a/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java b/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java index 9aa6c545..a7af1f03 100644 --- a/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java +++ b/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java @@ -1,13 +1,24 @@ package WayofTime.bloodmagic.item.armour; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.UUID; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.api.livingArmour.StatTracker; +import WayofTime.bloodmagic.api.saving.SoulNetwork; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; +import WayofTime.bloodmagic.client.IMeshProvider; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.item.ItemComponent; +import WayofTime.bloodmagic.livingArmour.LivingArmour; +import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerRepairing; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeElytra; +import WayofTime.bloodmagic.network.BloodMagicPacketHandler; +import WayofTime.bloodmagic.network.PlayerFallDistancePacketProcessor; +import WayofTime.bloodmagic.util.Utils; +import WayofTime.bloodmagic.util.helper.TextHelper; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelResourceLocation; @@ -29,46 +40,22 @@ import net.minecraftforge.common.ISpecialArmor; import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.lwjgl.input.Keyboard; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.api.livingArmour.StatTracker; -import WayofTime.bloodmagic.api.saving.SoulNetwork; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -import WayofTime.bloodmagic.client.IMeshProvider; -import WayofTime.bloodmagic.item.ItemComponent; -import WayofTime.bloodmagic.livingArmour.LivingArmour; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerRepairing; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeElytra; -import WayofTime.bloodmagic.network.BloodMagicPacketHandler; -import WayofTime.bloodmagic.network.PlayerFallDistancePacketProcessor; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.util.Utils; -import WayofTime.bloodmagic.util.helper.TextHelper; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - import javax.annotation.Nullable; +import java.lang.reflect.Field; +import java.util.*; +import java.util.Map.Entry; -public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshProvider -{ - private static Field _FLAGS = ReflectionHelper.findField(Entity.class, "FLAGS", "field_184240_ax"); - - private static DataParameter FLAGS = null; - public static String[] names = { "helmet", "chest", "legs", "boots" }; - +public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshProvider { public static final boolean useSpecialArmourCalculation = true; - + public static String[] names = {"helmet", "chest", "legs", "boots"}; //TODO: Save/delete cache periodically. public static Map armourMap = new HashMap(); + private static Field _FLAGS = ReflectionHelper.findField(Entity.class, "FLAGS", "field_184240_ax"); + private static DataParameter FLAGS = null; - public ItemLivingArmour(EntityEquipmentSlot armorType) - { + public ItemLivingArmour(EntityEquipmentSlot armorType) { super(ItemArmor.ArmorMaterial.IRON, 0, armorType); setUnlocalizedName(BloodMagic.MODID + ".livingArmour."); // setMaxDamage(250); @@ -77,27 +64,21 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP } @Override - public void onCreated(ItemStack stack, World world, EntityPlayer player) - { - if (stack != null && !world.isRemote && stack.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) - { + public void onCreated(ItemStack stack, World world, EntityPlayer player) { + if (stack != null && !world.isRemote && stack.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) { Utils.setUUID(stack); } } @Override - public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) - { - if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST || this == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET || this == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS) - { + public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) { + if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST || this == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET || this == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS) { return "bloodmagic:models/armor/livingArmour_layer_1.png"; } - if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS) - { + if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS) { return "bloodmagic:models/armor/livingArmour_layer_2.png"; - } else - { + } else { return null; } } @@ -115,25 +96,20 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP // } @Override - public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) - { + public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { return ItemStack.areItemsEqual(repair, ItemComponent.getStack(ItemComponent.REAGENT_BINDING)); } @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot) - { + public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot) { double armourReduction = 0.0; double damageAmount = 0.25; - if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS || this == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET) - { + if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS || this == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET) { damageAmount = 3d / 20d * 0.6; - } else if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS) - { + } else if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS) { damageAmount = 6d / 20d * 0.6; - } else if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) - { + } else if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) { damageAmount = 0.64; } @@ -141,42 +117,34 @@ 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.OUT_OF_WORLD)) - { + if (source.equals(DamageSource.OUT_OF_WORLD)) { return new ArmorProperties(-1, 0, 0); } - if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) - { + if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) { armourReduction = 0.24 / 0.64; // This values puts it at iron level ItemStack helmet = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD); ItemStack leggings = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS); ItemStack boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET); - if (helmet.isEmpty() || leggings.isEmpty() || boots.isEmpty()) - { + if (helmet.isEmpty() || leggings.isEmpty() || boots.isEmpty()) { damageAmount *= (armourReduction); return new ArmorProperties(-1, damageAmount, maxAbsorption); } - if (helmet.getItem() instanceof ItemLivingArmour && leggings.getItem() instanceof ItemLivingArmour && boots.getItem() instanceof ItemLivingArmour) - { + if (helmet.getItem() instanceof ItemLivingArmour && leggings.getItem() instanceof ItemLivingArmour && boots.getItem() instanceof ItemLivingArmour) { double remainder = 1; // Multiply this number by the armour upgrades for protection - if (hasLivingArmour(stack)) - { + if (hasLivingArmour(stack)) { LivingArmour armour = getLivingArmour(stack); - if (armour != null && isEnabled(stack)) - { - for (Entry entry : armour.upgradeMap.entrySet()) - { + if (armour != null && isEnabled(stack)) { + for (Entry entry : armour.upgradeMap.entrySet()) { LivingArmourUpgrade upgrade = entry.getValue(); remainder *= (1 - upgrade.getArmourProtection(player, source)); } @@ -193,10 +161,8 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP return new ArmorProperties(-1, source.isUnblockable() ? 1 - remainder : damageAmount, maxAbsorption); } - } else - { - if (source.isUnblockable()) - { + } else { + if (source.isUnblockable()) { return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption); } @@ -207,25 +173,20 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP } @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) - { - if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET) - { + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET) { return 3; } - if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) - { + if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) { return 8; } - if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS) - { + if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS) { return 6; } - if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS) - { + if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS) { return 3; } @@ -233,21 +194,16 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP } @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) - { - if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) - { + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) { int preDamage = stack.getItemDamage(); - if (source.isUnblockable()) - { + if (source.isUnblockable()) { return; } - if (damage > this.getMaxDamage(stack) - this.getDamage(stack)) - { + if (damage > this.getMaxDamage(stack) - this.getDamage(stack)) { //TODO: Syphon a load of LP. - if (entity.getEntityWorld().isRemote && entity instanceof EntityPlayer) - { + if (entity.getEntityWorld().isRemote && entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; SoulNetwork network = NetworkHelper.getSoulNetwork(player); network.syphonAndDamage(player, damage * 100); @@ -259,21 +215,17 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP stack.damageItem(damage, entity); int receivedDamage = stack.getItemDamage() - preDamage; - if (entity instanceof EntityPlayer) - { + if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { LivingArmour armour = ItemLivingArmour.getLivingArmour(stack); - if (armour != null) - { + if (armour != null) { StatTrackerRepairing.incrementCounter(armour, receivedDamage); } } } - } else - { + } else { stack.damageItem(damage, entity); } @@ -282,46 +234,36 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; - if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) - { + if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) { LivingArmour armour = getLivingArmourFromStack(stack); - for (Entry entry : armour.upgradeMap.entrySet()) - { + for (Entry entry : armour.upgradeMap.entrySet()) { LivingArmourUpgrade upgrade = entry.getValue(); - if (upgrade != null) - { - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M)) - { + if (upgrade != null) { + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M)) { StatTracker tracker = null; - for (StatTracker searchTracker : armour.trackerMap.values()) - { - if (searchTracker != null && searchTracker.providesUpgrade(upgrade.getUniqueIdentifier())) - { + for (StatTracker searchTracker : armour.trackerMap.values()) { + if (searchTracker != null && searchTracker.providesUpgrade(upgrade.getUniqueIdentifier())) { tracker = searchTracker; break; } } - if (tracker != null) - { + 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) (progress * 100D), 0, 100))); } - } else - { + } else { tooltip.add(TextHelper.localize("tooltip.bloodmagic.livingArmour.upgrade.level", TextHelper.localize(upgrade.getUnlocalizedName()), upgrade.getUpgradeLevel() + 1)); } } } tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmour.upgrade.points", armour.totalUpgradePoints, armour.maxUpgradePoints)); - if (!(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M))) - { + if (!(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M))) { tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmour.extraExtraInfo")); } } @@ -330,52 +272,39 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP } @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) - { + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { super.onArmorTick(world, player, stack); - if (world.isRemote && this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) - { + if (world.isRemote && this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) { if (player instanceof EntityPlayerSP) //Sanity check { EntityPlayerSP spPlayer = (EntityPlayerSP) player; - if (FLAGS == null) - { - try - { + if (FLAGS == null) { + try { FLAGS = (DataParameter) _FLAGS.get(null); - } catch (IllegalArgumentException e) - { + } catch (IllegalArgumentException e) { e.printStackTrace(); - } catch (IllegalAccessException e) - { + } catch (IllegalAccessException e) { e.printStackTrace(); } } - if (FLAGS != null) - { - if (LivingArmour.hasFullSet(player)) - { + if (FLAGS != null) { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgradeFromNBT(BloodMagic.MODID + ".upgrade.elytra", chestStack); - if (upgrade instanceof LivingArmourUpgradeElytra) - { - if (spPlayer.movementInput.jump && !spPlayer.onGround && spPlayer.motionY < 0.0D && !spPlayer.capabilities.isFlying) - { - if (spPlayer.motionY > -0.5D) - { + if (upgrade instanceof LivingArmourUpgradeElytra) { + if (spPlayer.movementInput.jump && !spPlayer.onGround && spPlayer.motionY < 0.0D && !spPlayer.capabilities.isFlying) { + if (spPlayer.motionY > -0.5D) { BloodMagicPacketHandler.INSTANCE.sendToServer(new PlayerFallDistancePacketProcessor(1)); } - if (!spPlayer.isElytraFlying()) - { + if (!spPlayer.isElytraFlying()) { byte b0 = player.getDataManager().get(FLAGS); player.getDataManager().set(FLAGS, (byte) (b0 | 1 << 7)); } - } else if (spPlayer.isElytraFlying() && !spPlayer.movementInput.jump && !spPlayer.onGround) - { + } else if (spPlayer.isElytraFlying() && !spPlayer.movementInput.jump && !spPlayer.onGround) { byte b0 = player.getDataManager().get(FLAGS); player.getDataManager().set(FLAGS, (byte) (b0 & ~(1 << 7))); } @@ -385,16 +314,13 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP } } - if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) - { - if (!hasLivingArmour(stack)) - { + if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) { + if (!hasLivingArmour(stack)) { setLivingArmour(stack, getLivingArmourFromStack(stack)); } LivingArmour armour = getLivingArmour(stack); - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { this.setIsEnabled(stack, true); armour.onTick(world, player); } @@ -404,10 +330,8 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP } @Override - public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) - { - if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST && isEnabled(stack) && slot == EntityEquipmentSlot.CHEST) - { + public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { + if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST && isEnabled(stack) && slot == EntityEquipmentSlot.CHEST) { LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(stack); return armour.getAttributeModifiers(); @@ -417,20 +341,16 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names[3 - armorType.getIndex()]; } @Override @SideOnly(Side.CLIENT) - public ItemMeshDefinition getMeshDefinition() - { - return new ItemMeshDefinition() - { + public ItemMeshDefinition getMeshDefinition() { + return new ItemMeshDefinition() { @Override - public ModelResourceLocation getModelLocation(ItemStack stack) - { + public ModelResourceLocation getModelLocation(ItemStack stack) { assert getCustomLocation() != null; if (stack.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET) return new ModelResourceLocation(getCustomLocation(), "armour=head"); @@ -445,14 +365,12 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP } @Override - public ResourceLocation getCustomLocation() - { + public ResourceLocation getCustomLocation() { return new ResourceLocation(BloodMagic.MODID, "item/ItemLivingArmour"); } @Override - public List getVariants() - { + public List getVariants() { List ret = new ArrayList(); ret.add("armour=head"); ret.add("armour=body"); @@ -461,48 +379,21 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP return ret; } - @Nullable - public static LivingArmour getLivingArmourFromStack(ItemStack stack) - { - NBTTagCompound livingTag = getArmourTag(stack); - - LivingArmour livingArmour = new LivingArmour(); - livingArmour.readFromNBT(livingTag); - - return livingArmour; - } - - public void setLivingArmour(ItemStack stack, LivingArmour armour, boolean forceWrite) - { + public void setLivingArmour(ItemStack stack, LivingArmour armour, boolean forceWrite) { NBTTagCompound livingTag = new NBTTagCompound(); - if (!forceWrite) - { + if (!forceWrite) { livingTag = getArmourTag(stack); armour.writeDirtyToNBT(livingTag); - } else - { + } else { armour.writeToNBT(livingTag); } setArmourTag(stack, livingTag); } - public static NBTTagCompound getArmourTag(ItemStack stack) - { - if (!stack.hasTagCompound()) - { - stack.setTagCompound(new NBTTagCompound()); - } - - NBTTagCompound tag = stack.getTagCompound(); - return tag.getCompoundTag(Constants.NBT.LIVING_ARMOUR); - } - - public void setArmourTag(ItemStack stack, NBTTagCompound livingTag) - { - if (!stack.hasTagCompound()) - { + public void setArmourTag(ItemStack stack, NBTTagCompound livingTag) { + if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } @@ -511,20 +402,59 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP tag.setTag(Constants.NBT.LIVING_ARMOUR, livingTag); } + public void setIsEnabled(ItemStack stack, boolean bool) { + NBTHelper.checkNBT(stack); + NBTTagCompound tag = stack.getTagCompound(); + tag.setBoolean("enabled", bool); + } + + public boolean isEnabled(ItemStack stack) { + NBTHelper.checkNBT(stack); + NBTTagCompound tag = stack.getTagCompound(); + return tag.getBoolean("enabled"); + } + + public void setIsElytra(ItemStack stack, boolean bool) { + NBTHelper.checkNBT(stack); + NBTTagCompound tag = stack.getTagCompound(); + tag.setBoolean("elytra", bool); + } + + public boolean isElytra(ItemStack stack) { + NBTHelper.checkNBT(stack); + NBTTagCompound tag = stack.getTagCompound(); + return tag.getBoolean("elytra"); + } + + @Nullable + public static LivingArmour getLivingArmourFromStack(ItemStack stack) { + NBTTagCompound livingTag = getArmourTag(stack); + + LivingArmour livingArmour = new LivingArmour(); + livingArmour.readFromNBT(livingTag); + + return livingArmour; + } + + public static NBTTagCompound getArmourTag(ItemStack stack) { + if (!stack.hasTagCompound()) { + stack.setTagCompound(new NBTTagCompound()); + } + + NBTTagCompound tag = stack.getTagCompound(); + return tag.getCompoundTag(Constants.NBT.LIVING_ARMOUR); + } + //TODO: Add the ability to have the armour give an upgrade with a higher level - public static LivingArmourUpgrade getUpgrade(String uniqueIdentifier, ItemStack stack) - { - if (!hasLivingArmour(stack)) - { + public static LivingArmourUpgrade getUpgrade(String uniqueIdentifier, ItemStack stack) { + if (!hasLivingArmour(stack)) { setLivingArmour(stack, getLivingArmourFromStack(stack)); } LivingArmour armour = getLivingArmour(stack); - for (Entry entry : armour.upgradeMap.entrySet()) - { - if (entry.getKey().equals(uniqueIdentifier)) - { + for (Entry entry : armour.upgradeMap.entrySet()) { + if (entry.getKey().equals(uniqueIdentifier)) { return entry.getValue(); } } @@ -532,14 +462,11 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP return null; } - public static LivingArmourUpgrade getUpgradeFromNBT(String uniqueIdentifier, ItemStack stack) - { + public static LivingArmourUpgrade getUpgradeFromNBT(String uniqueIdentifier, ItemStack stack) { LivingArmour armour = getLivingArmourFromStack(stack); - for (Entry entry : armour.upgradeMap.entrySet()) - { - if (entry.getKey().equals(uniqueIdentifier)) - { + for (Entry entry : armour.upgradeMap.entrySet()) { + if (entry.getKey().equals(uniqueIdentifier)) { return entry.getValue(); } } @@ -547,24 +474,20 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP return null; } - public static boolean hasLivingArmour(ItemStack stack) - { + public static boolean hasLivingArmour(ItemStack stack) { UUID uuid = Utils.getUUID(stack); return uuid != null && armourMap.containsKey(uuid); } @Nullable - public static LivingArmour getLivingArmour(ItemStack stack) - { + public static LivingArmour getLivingArmour(ItemStack stack) { UUID uuid = Utils.getUUID(stack); return armourMap.get(uuid); } - public static void setLivingArmour(ItemStack stack, LivingArmour armour) - { - if (!Utils.hasUUID(stack)) - { + public static void setLivingArmour(ItemStack stack, LivingArmour armour) { + if (!Utils.hasUUID(stack)) { Utils.setUUID(stack); } @@ -573,10 +496,8 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP armourMap.put(uuid, armour); } - public static boolean hasUpgrade(String id, ItemStack stack) - { - if (!hasLivingArmour(stack)) - { + public static boolean hasUpgrade(String id, ItemStack stack) { + if (!hasLivingArmour(stack)) { setLivingArmour(stack, getLivingArmourFromStack(stack)); } @@ -584,32 +505,4 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP return armour.upgradeMap.containsKey(id); } - - public void setIsEnabled(ItemStack stack, boolean bool) - { - NBTHelper.checkNBT(stack); - NBTTagCompound tag = stack.getTagCompound(); - tag.setBoolean("enabled", bool); - } - - public boolean isEnabled(ItemStack stack) - { - NBTHelper.checkNBT(stack); - NBTTagCompound tag = stack.getTagCompound(); - return tag.getBoolean("enabled"); - } - - public void setIsElytra(ItemStack stack, boolean bool) - { - NBTHelper.checkNBT(stack); - NBTTagCompound tag = stack.getTagCompound(); - tag.setBoolean("elytra", bool); - } - - public boolean isElytra(ItemStack stack) - { - NBTHelper.checkNBT(stack); - NBTTagCompound tag = stack.getTagCompound(); - return tag.getBoolean("elytra"); - } } diff --git a/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java b/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java index dc11df71..7933de3a 100644 --- a/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java +++ b/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java @@ -1,7 +1,15 @@ package WayofTime.bloodmagic.item.armour; -import java.util.*; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.iface.IMultiWillTool; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.client.IMeshProvider; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.enchantment.Enchantment; @@ -24,37 +32,26 @@ import net.minecraft.world.World; import net.minecraftforge.common.ISpecialArmor; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.iface.IMultiWillTool; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.client.IMeshProvider; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; +import java.util.*; -public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMeshProvider, IMultiWillTool -{ - public static String[] names = { "helmet", "chest", "legs", "boots" }; +public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMeshProvider, IMultiWillTool { + public static String[] names = {"helmet", "chest", "legs", "boots"}; - public static double[] willBracket = new double[] { 30, 200, 600, 1500, 4000, 6000, 8000, 16000 }; - public static double[] consumptionPerHit = new double[] { 0.1, 0.12, 0.15, 0.2, 0.3, 0.35, 0.4, 0.5 }; - public static double[] extraProtectionLevel = new double[] { 0, 0.25, 0.5, 0.6, 0.7, 0.75, 0.85, 0.9 }; - public static double[] steadfastProtectionLevel = new double[] { 0.25, 0.5, 0.6, 0.7, 0.75, 0.85, 0.9, 0.95 }; + public static double[] willBracket = new double[]{30, 200, 600, 1500, 4000, 6000, 8000, 16000}; + public static double[] consumptionPerHit = new double[]{0.1, 0.12, 0.15, 0.2, 0.3, 0.35, 0.4, 0.5}; + public static double[] extraProtectionLevel = new double[]{0, 0.25, 0.5, 0.6, 0.7, 0.75, 0.85, 0.9}; + public static double[] steadfastProtectionLevel = new double[]{0.25, 0.5, 0.6, 0.7, 0.75, 0.85, 0.9, 0.95}; //public static double[] healthBonus = new double[] { 3, 6, 9, 12, 15, 20, 25, 30 }; - public static double[] knockbackBonus = new double[] { 0.2, 0.4, 0.6, 0.8, 1, 1, 1, 1 }; + public static double[] knockbackBonus = new double[]{0.2, 0.4, 0.6, 0.8, 1, 1, 1, 1}; - public static double[] damageBoost = new double[] { 0.03, 0.06, 0.09, 0.12, 0.15, 0.18, 0.22, 0.25 }; - public static double[] attackSpeed = new double[] { -0.02, -0.04, -0.06, -0.08, -0.1, -0.12, -0.14, -0.16 }; + public static double[] damageBoost = new double[]{0.03, 0.06, 0.09, 0.12, 0.15, 0.18, 0.22, 0.25}; + public static double[] attackSpeed = new double[]{-0.02, -0.04, -0.06, -0.08, -0.1, -0.12, -0.14, -0.16}; - public static double[] speedBonus = new double[] { 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4 }; + public static double[] speedBonus = new double[]{0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4}; - public ItemSentientArmour(EntityEquipmentSlot armorType) - { + public ItemSentientArmour(EntityEquipmentSlot armorType) { super(ItemArmor.ArmorMaterial.IRON, 0, armorType); setUnlocalizedName(BloodMagic.MODID + ".sentientArmour."); setMaxDamage(250); @@ -62,111 +59,92 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes } @Override - public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) - { - if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS) - { - switch (this.getCurrentType(stack)) - { - case DEFAULT: - return "bloodmagic:models/armor/sentientArmour_layer_1.png"; - case CORROSIVE: - return "bloodmagic:models/armor/sentientArmour_corrosive_layer_1.png"; - case VENGEFUL: - return "bloodmagic:models/armor/sentientArmour_vengeful_layer_1.png"; - case DESTRUCTIVE: - return "bloodmagic:models/armor/sentientArmour_destructive_layer_1.png"; - case STEADFAST: - return "bloodmagic:models/armor/sentientArmour_steadfast_layer_1.png"; + public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) { + if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS) { + switch (this.getCurrentType(stack)) { + case DEFAULT: + return "bloodmagic:models/armor/sentientArmour_layer_1.png"; + case CORROSIVE: + return "bloodmagic:models/armor/sentientArmour_corrosive_layer_1.png"; + case VENGEFUL: + return "bloodmagic:models/armor/sentientArmour_vengeful_layer_1.png"; + case DESTRUCTIVE: + return "bloodmagic:models/armor/sentientArmour_destructive_layer_1.png"; + case STEADFAST: + return "bloodmagic:models/armor/sentientArmour_steadfast_layer_1.png"; } return "bloodmagic:models/armor/sentientArmour_layer_1.png"; } - if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS) - { - switch (this.getCurrentType(stack)) - { - case DEFAULT: - return "bloodmagic:models/armor/sentientArmour_layer_2.png"; - case CORROSIVE: - return "bloodmagic:models/armor/sentientArmour_corrosive_layer_2.png"; - case VENGEFUL: - return "bloodmagic:models/armor/sentientArmour_vengeful_layer_2.png"; - case DESTRUCTIVE: - return "bloodmagic:models/armor/sentientArmour_destructive_layer_2.png"; - case STEADFAST: - return "bloodmagic:models/armor/sentientArmour_steadfast_layer_2.png"; + if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS) { + switch (this.getCurrentType(stack)) { + case DEFAULT: + return "bloodmagic:models/armor/sentientArmour_layer_2.png"; + case CORROSIVE: + return "bloodmagic:models/armor/sentientArmour_corrosive_layer_2.png"; + case VENGEFUL: + return "bloodmagic:models/armor/sentientArmour_vengeful_layer_2.png"; + case DESTRUCTIVE: + return "bloodmagic:models/armor/sentientArmour_destructive_layer_2.png"; + case STEADFAST: + return "bloodmagic:models/armor/sentientArmour_steadfast_layer_2.png"; } return "bloodmagic:models/armor/sentientArmour_layer_1.png"; - } else - { + } else { return null; } } @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) - { - if (this.armorType == EntityEquipmentSlot.CHEST) - { + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + if (this.armorType == EntityEquipmentSlot.CHEST) { EnumDemonWillType type = this.getCurrentType(stack); - switch (type) - { - case CORROSIVE: - if (player.isPotionActive(MobEffects.POISON)) - { - player.removeActivePotionEffect(MobEffects.POISON); - } - if (player.isPotionActive(MobEffects.WITHER)) - { - player.removeActivePotionEffect(MobEffects.WITHER); - } - break; - default: + switch (type) { + case CORROSIVE: + if (player.isPotionActive(MobEffects.POISON)) { + player.removeActivePotionEffect(MobEffects.POISON); + } + if (player.isPotionActive(MobEffects.WITHER)) { + player.removeActivePotionEffect(MobEffects.WITHER); + } + break; + default: } } } - public void onPlayerAttacked(ItemStack stack, DamageSource source, EntityPlayer attackedPlayer) - { - if (source.getTrueSource() instanceof EntityLivingBase) - { + public void onPlayerAttacked(ItemStack stack, DamageSource source, EntityPlayer attackedPlayer) { + if (source.getTrueSource() instanceof EntityLivingBase) { EntityLivingBase attacker = (EntityLivingBase) source.getTrueSource(); EnumDemonWillType type = this.getCurrentType(stack); - switch (type) - { - case CORROSIVE: - if (!source.isProjectile()) - { - attacker.addPotionEffect(new PotionEffect(MobEffects.POISON, 100)); //TODO: customize duration - } - break; - case DEFAULT: - break; - case DESTRUCTIVE: - break; - case STEADFAST: - break; - case VENGEFUL: - break; + switch (type) { + case CORROSIVE: + if (!source.isProjectile()) { + attacker.addPotionEffect(new PotionEffect(MobEffects.POISON, 100)); //TODO: customize duration + } + break; + case DEFAULT: + break; + case DESTRUCTIVE: + break; + case STEADFAST: + break; + case VENGEFUL: + break; } } } @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot) - { + public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot) { double armourReduction = 0.0; double damageAmount = 0.25; - if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET) - { + if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET) { damageAmount = 3d / 20d * 0.6; - } else if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS) - { + } else if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS) { damageAmount = 6d / 20d * 0.6; - } else if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST) - { + } else if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST) { damageAmount = 0.64; } @@ -174,50 +152,42 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes int maxAbsorption = 100000; - if (source.equals(DamageSource.DROWN)) - { + if (source.equals(DamageSource.DROWN)) { return new ArmorProperties(-1, 0, 0); } - if (source.equals(DamageSource.OUT_OF_WORLD)) - { + if (source.equals(DamageSource.OUT_OF_WORLD)) { return new ArmorProperties(-1, 0, 0); } - if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST) - { + if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST) { armourReduction = 0.24 / 0.64; // This values puts it at iron level ItemStack helmet = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD); ItemStack leggings = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS); ItemStack boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET); - if (helmet.isEmpty() || leggings.isEmpty() || boots.isEmpty()) - { + if (helmet.isEmpty() || leggings.isEmpty() || boots.isEmpty()) { damageAmount *= (armourReduction); return new ArmorProperties(-1, damageAmount, maxAbsorption); } - if (helmet.getItem() instanceof ItemSentientArmour && leggings.getItem() instanceof ItemSentientArmour && boots.getItem() instanceof ItemSentientArmour) - { + if (helmet.getItem() instanceof ItemSentientArmour && leggings.getItem() instanceof ItemSentientArmour && boots.getItem() instanceof ItemSentientArmour) { double remainder = 1; // Multiply this number by the armour upgrades for protection remainder *= (1 - this.getArmourModifier(stack)); armourReduction = armourReduction + (1 - remainder) * (1 - armourReduction); damageAmount *= (armourReduction); - if (source.isUnblockable()) - { + if (source.isUnblockable()) { return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption); } return new ArmorProperties(-1, damageAmount, maxAbsorption); } - } else - { - if (source.isUnblockable()) - { + } else { + if (source.isUnblockable()) { return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption); } @@ -228,25 +198,20 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes } @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) - { - if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET) - { + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET) { return 3; } - if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST) - { + if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST) { return 8; } - if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS) - { + if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS) { return 6; } - if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS) - { + if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS) { return 3; } @@ -254,53 +219,45 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes } @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) - { - if (entity instanceof EntityPlayer) - { + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; EnumDemonWillType type = getCurrentType(stack); double willRequired = this.getCostModifier(stack) * damage; double willLeft = PlayerDemonWillHandler.getTotalDemonWill(type, player); - if (willLeft >= willRequired && canSustainArmour(type, willLeft)) - { + if (willLeft >= willRequired && canSustainArmour(type, willLeft)) { this.setAbilitiesOfArmour(type, willLeft - willRequired, stack); PlayerDemonWillHandler.consumeDemonWill(type, player, willRequired); - } else - { + } else { this.revertArmour(player, stack); } } } - public double getCostModifier(ItemStack stack) - { + public double getCostModifier(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble("costModifier"); } - public void setCostModifier(ItemStack stack, double modifier) - { + public void setCostModifier(ItemStack stack, double modifier) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); tag.setDouble("costModifier", modifier); } - public double getArmourModifier(ItemStack stack) - { + public double getArmourModifier(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble("armourModifier"); } - public void setArmourModifier(ItemStack stack, double modifier) - { + public void setArmourModifier(ItemStack stack, double modifier) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -308,26 +265,21 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names[3 - armorType.getIndex()]; } - public void revertArmour(EntityPlayer player, ItemStack itemStack) - { + public void revertArmour(EntityPlayer player, ItemStack itemStack) { ItemStack stack = this.getContainedArmourStack(itemStack); player.setItemStackToSlot(armorType, stack); } @Override @SideOnly(Side.CLIENT) - public ItemMeshDefinition getMeshDefinition() - { - return new ItemMeshDefinition() - { + public ItemMeshDefinition getMeshDefinition() { + return new ItemMeshDefinition() { @Override - public ModelResourceLocation getModelLocation(ItemStack stack) - { + public ModelResourceLocation getModelLocation(ItemStack stack) { assert getCustomLocation() != null; EnumDemonWillType type = ((ItemSentientArmour) RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET).getCurrentType(stack); String additional = "_" + type.getName().toLowerCase(); @@ -344,17 +296,14 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes } @Override - public ResourceLocation getCustomLocation() - { + public ResourceLocation getCustomLocation() { return new ResourceLocation(BloodMagic.MODID, "item/ItemSentientArmour"); } @Override - public List getVariants() - { + public List getVariants() { List ret = new ArrayList(); - for (EnumDemonWillType type : EnumDemonWillType.values()) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { String additional = "_" + type.getName().toLowerCase(); ret.add("armour=head" + additional); @@ -367,11 +316,9 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes } @Override - public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) - { + public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { Multimap multimap = HashMultimap.create(); - if (slot == EntityEquipmentSlot.CHEST) - { + if (slot == EntityEquipmentSlot.CHEST) { multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 318145), "Armor modifier", this.getHealthBonus(stack), 0)); multimap.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(new UUID(0, 8145), "Armor modifier", this.getKnockbackResistance(stack), 0)); multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(), new AttributeModifier(new UUID(0, 94021), "Armor modifier", this.getSpeedBoost(stack), 2)); @@ -381,22 +328,8 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes return multimap; } - public static void revertAllArmour(EntityPlayer player) - { - NonNullList armourInventory = player.inventory.armorInventory; - for (ItemStack stack : armourInventory) - { - if (stack != null && stack.getItem() instanceof ItemSentientArmour) - { - ((ItemSentientArmour) stack.getItem()).revertArmour(player, stack); - } - } - } - - public void setContainedArmourStack(ItemStack newArmour, ItemStack previousArmour) - { - if (newArmour == null || previousArmour == null) - { + public void setContainedArmourStack(ItemStack newArmour, ItemStack previousArmour) { + if (newArmour == null || previousArmour == null) { return; } @@ -404,8 +337,7 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes previousArmour.writeToNBT(tag); NBTTagCompound omegaTag = newArmour.getTagCompound(); - if (omegaTag == null) - { + if (omegaTag == null) { omegaTag = new NBTTagCompound(); newArmour.setTagCompound(omegaTag); } @@ -415,11 +347,9 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes EnchantmentHelper.setEnchantments(enchantmentMap, newArmour); } - public ItemStack getContainedArmourStack(ItemStack newArmour) - { + public ItemStack getContainedArmourStack(ItemStack newArmour) { NBTTagCompound omegaTag = newArmour.getTagCompound(); - if (omegaTag == null) - { + if (omegaTag == null) { return null; } @@ -427,10 +357,195 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes return new ItemStack(tag); } - public static boolean convertPlayerArmour(EnumDemonWillType type, double will, EntityPlayer player) - { - if (!canSustainArmour(type, will)) - { + public ItemStack getSubstituteStack(EnumDemonWillType type, double will, ItemStack previousArmour) { + ItemStack newArmour = new ItemStack(this); + + this.setContainedArmourStack(newArmour, previousArmour); + this.setAbilitiesOfArmour(type, will, newArmour); + + return newArmour; + } + + @Override + public EnumDemonWillType getCurrentType(ItemStack stack) { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + + if (!tag.hasKey(Constants.NBT.WILL_TYPE)) { + return EnumDemonWillType.DEFAULT; + } + + return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH)); + } + + public void setCurrentType(EnumDemonWillType type, ItemStack stack) { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + + tag.setString(Constants.NBT.WILL_TYPE, type.toString()); + } + + public void setAbilitiesOfArmour(EnumDemonWillType type, double willValue, ItemStack armourStack) { + int willBracket = getWillBracket(willValue); + if (willBracket >= 0) { + double recurringCost = consumptionPerHit[willBracket]; + + this.setCostModifier(armourStack, recurringCost); + this.setCurrentType(type, armourStack); + + if (this.armorType == EntityEquipmentSlot.CHEST) { + this.setArmourModifier(armourStack, getArmourModifier(type, willBracket)); + this.setHealthBonus(armourStack, this.getHealthModifier(type, willBracket)); + this.setKnockbackResistance(armourStack, getKnockbackModifier(type, willBracket)); + this.setSpeedBoost(armourStack, getSpeedModifier(type, willBracket)); + this.setDamageBoost(armourStack, getDamageModifier(type, willBracket)); + this.setAttackSpeedBoost(armourStack, getAttackSpeedModifier(type, willBracket)); + } + } + } + + public double getArmourModifier(EnumDemonWillType type, int willBracket) { + switch (type) { + case STEADFAST: + return steadfastProtectionLevel[willBracket]; + default: + return extraProtectionLevel[willBracket]; + } + } + + public double getHealthModifier(EnumDemonWillType type, int willBracket) { + switch (type) { + case STEADFAST: + //return healthBonus[willBracket]; + default: + return 0; + } + } + + public double getKnockbackModifier(EnumDemonWillType type, int willBracket) { + switch (type) { + case STEADFAST: + return knockbackBonus[willBracket]; + default: + return 0; + } + } + + public double getSpeedModifier(EnumDemonWillType type, int willBracket) { + switch (type) { + case VENGEFUL: + return speedBonus[willBracket]; + default: + return 0; + } + } + + public double getDamageModifier(EnumDemonWillType type, int willBracket) { + switch (type) { + case DESTRUCTIVE: + return damageBoost[willBracket]; + default: + return 0; + } + } + + public double getAttackSpeedModifier(EnumDemonWillType type, int willBracket) { + switch (type) { + case DESTRUCTIVE: + return attackSpeed[willBracket]; + default: + return 0; + } + } + + public double getHealthBonus(ItemStack stack) { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH); + } + + public void setHealthBonus(ItemStack stack, double hp) { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + + tag.setDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp); + } + + public double getKnockbackResistance(ItemStack stack) { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + return tag.getDouble("knockback"); + } + + public void setKnockbackResistance(ItemStack stack, double kb) { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + + tag.setDouble("knockback", kb); + } + + public double getSpeedBoost(ItemStack stack) { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + return tag.getDouble("speed"); + } + + public void setSpeedBoost(ItemStack stack, double speed) { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + + tag.setDouble("speed", speed); + } + + public double getDamageBoost(ItemStack stack) { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + return tag.getDouble("damage"); + } + + public void setDamageBoost(ItemStack stack, double damage) { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + + tag.setDouble("damage", damage); + } + + public double getAttackSpeedBoost(ItemStack stack) { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + return tag.getDouble("attackSpeed"); + } + + public void setAttackSpeedBoost(ItemStack stack, double attackSpeed) { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + + tag.setDouble("attackSpeed", attackSpeed); + } + + public static void revertAllArmour(EntityPlayer player) { + NonNullList armourInventory = player.inventory.armorInventory; + for (ItemStack stack : armourInventory) { + if (stack != null && stack.getItem() instanceof ItemSentientArmour) { + ((ItemSentientArmour) stack.getItem()).revertArmour(player, stack); + } + } + } + + public static boolean convertPlayerArmour(EnumDemonWillType type, double will, EntityPlayer player) { + if (!canSustainArmour(type, will)) { return false; } @@ -454,230 +569,19 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes } } - public ItemStack getSubstituteStack(EnumDemonWillType type, double will, ItemStack previousArmour) - { - ItemStack newArmour = new ItemStack(this); - - this.setContainedArmourStack(newArmour, previousArmour); - this.setAbilitiesOfArmour(type, will, newArmour); - - return newArmour; - } - - @Override - public EnumDemonWillType getCurrentType(ItemStack stack) - { - NBTHelper.checkNBT(stack); - - NBTTagCompound tag = stack.getTagCompound(); - - if (!tag.hasKey(Constants.NBT.WILL_TYPE)) - { - return EnumDemonWillType.DEFAULT; - } - - return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH)); - } - - public void setCurrentType(EnumDemonWillType type, ItemStack stack) - { - NBTHelper.checkNBT(stack); - - NBTTagCompound tag = stack.getTagCompound(); - - tag.setString(Constants.NBT.WILL_TYPE, type.toString()); - } - - public void setAbilitiesOfArmour(EnumDemonWillType type, double willValue, ItemStack armourStack) - { - int willBracket = getWillBracket(willValue); - if (willBracket >= 0) - { - double recurringCost = consumptionPerHit[willBracket]; - - this.setCostModifier(armourStack, recurringCost); - this.setCurrentType(type, armourStack); - - if (this.armorType == EntityEquipmentSlot.CHEST) - { - this.setArmourModifier(armourStack, getArmourModifier(type, willBracket)); - this.setHealthBonus(armourStack, this.getHealthModifier(type, willBracket)); - this.setKnockbackResistance(armourStack, getKnockbackModifier(type, willBracket)); - this.setSpeedBoost(armourStack, getSpeedModifier(type, willBracket)); - this.setDamageBoost(armourStack, getDamageModifier(type, willBracket)); - this.setAttackSpeedBoost(armourStack, getAttackSpeedModifier(type, willBracket)); - } - } - } - - public double getArmourModifier(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case STEADFAST: - return steadfastProtectionLevel[willBracket]; - default: - return extraProtectionLevel[willBracket]; - } - } - - public double getHealthModifier(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case STEADFAST: - //return healthBonus[willBracket]; - default: - return 0; - } - } - - public double getKnockbackModifier(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case STEADFAST: - return knockbackBonus[willBracket]; - default: - return 0; - } - } - - public double getSpeedModifier(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case VENGEFUL: - return speedBonus[willBracket]; - default: - return 0; - } - } - - public double getDamageModifier(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case DESTRUCTIVE: - return damageBoost[willBracket]; - default: - return 0; - } - } - - public double getAttackSpeedModifier(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case DESTRUCTIVE: - return attackSpeed[willBracket]; - default: - return 0; - } - } - - public static boolean canSustainArmour(EnumDemonWillType type, double willValue) - { + public static boolean canSustainArmour(EnumDemonWillType type, double willValue) { return getWillBracket(willValue) >= 0; } - public static int getWillBracket(double will) - { + public static int getWillBracket(double will) { int bracket = -1; - for (int i = 0; i < willBracket.length; i++) - { - if (will >= willBracket[i]) - { + for (int i = 0; i < willBracket.length; i++) { + if (will >= willBracket[i]) { bracket = i; } } return bracket; } - - public double getHealthBonus(ItemStack stack) - { - NBTHelper.checkNBT(stack); - - NBTTagCompound tag = stack.getTagCompound(); - return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH); - } - - public void setHealthBonus(ItemStack stack, double hp) - { - NBTHelper.checkNBT(stack); - - NBTTagCompound tag = stack.getTagCompound(); - - tag.setDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp); - } - - public double getKnockbackResistance(ItemStack stack) - { - NBTHelper.checkNBT(stack); - - NBTTagCompound tag = stack.getTagCompound(); - return tag.getDouble("knockback"); - } - - public void setKnockbackResistance(ItemStack stack, double kb) - { - NBTHelper.checkNBT(stack); - - NBTTagCompound tag = stack.getTagCompound(); - - tag.setDouble("knockback", kb); - } - - public double getSpeedBoost(ItemStack stack) - { - NBTHelper.checkNBT(stack); - - NBTTagCompound tag = stack.getTagCompound(); - return tag.getDouble("speed"); - } - - public void setSpeedBoost(ItemStack stack, double speed) - { - NBTHelper.checkNBT(stack); - - NBTTagCompound tag = stack.getTagCompound(); - - tag.setDouble("speed", speed); - } - - public double getDamageBoost(ItemStack stack) - { - NBTHelper.checkNBT(stack); - - NBTTagCompound tag = stack.getTagCompound(); - return tag.getDouble("damage"); - } - - public void setDamageBoost(ItemStack stack, double damage) - { - NBTHelper.checkNBT(stack); - - NBTTagCompound tag = stack.getTagCompound(); - - tag.setDouble("damage", damage); - } - - public double getAttackSpeedBoost(ItemStack stack) - { - NBTHelper.checkNBT(stack); - - NBTTagCompound tag = stack.getTagCompound(); - return tag.getDouble("attackSpeed"); - } - - public void setAttackSpeedBoost(ItemStack stack, double attackSpeed) - { - NBTHelper.checkNBT(stack); - - NBTTagCompound tag = stack.getTagCompound(); - - tag.setDouble("attackSpeed", attackSpeed); - } } diff --git a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockAlchemyTable.java b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockAlchemyTable.java index d92b04e1..c82c92e8 100644 --- a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockAlchemyTable.java +++ b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockAlchemyTable.java @@ -1,64 +1,53 @@ package WayofTime.bloodmagic.item.block; +import WayofTime.bloodmagic.tile.TileAlchemyTable; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.tile.TileAlchemyTable; -public class ItemBlockAlchemyTable extends ItemBlock -{ - public ItemBlockAlchemyTable(Block block) - { +public class ItemBlockAlchemyTable extends ItemBlock { + public ItemBlockAlchemyTable(Block block) { super(block); } @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) - { + public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) { float yaw = player.rotationYaw; EnumFacing direction = EnumFacing.fromAngle(yaw); - if (direction.getFrontOffsetY() != 0) - { + if (direction.getFrontOffsetY() != 0) { return false; } - if (!world.isAirBlock(pos.offset(direction))) - { + if (!world.isAirBlock(pos.offset(direction))) { return false; } // newState = block.getDefaultState().withProperty(BlockAlchemyTable.DIRECTION, direction).withProperty(BlockAlchemyTable.INVISIBLE, true); - if (!world.setBlockState(pos, newState, 3)) - { + if (!world.setBlockState(pos, newState, 3)) { return false; } - if (!world.setBlockState(pos.offset(direction), newState, 3)) - { + if (!world.setBlockState(pos.offset(direction), newState, 3)) { return false; } IBlockState state = world.getBlockState(pos); - if (state.getBlock() == this.block) - { + if (state.getBlock() == this.block) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileAlchemyTable) - { + if (tile instanceof TileAlchemyTable) { ((TileAlchemyTable) tile).setInitialTableParameters(direction, false, pos.offset(direction)); } TileEntity slaveTile = world.getTileEntity(pos.offset(direction)); - if (slaveTile instanceof TileAlchemyTable) - { + if (slaveTile instanceof TileAlchemyTable) { ((TileAlchemyTable) slaveTile).setInitialTableParameters(direction, true, pos); } diff --git a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodTank.java b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodTank.java index 8d3d0fb4..81a701a3 100644 --- a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodTank.java +++ b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodTank.java @@ -6,8 +6,6 @@ import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.block.Block; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -15,53 +13,44 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.fluids.*; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class ItemBlockBloodTank extends ItemBlock -{ - public ItemBlockBloodTank(Block block) - { +public class ItemBlockBloodTank extends ItemBlock { + public ItemBlockBloodTank(Block block) { super(block); setHasSubtypes(true); } @Override - public int getMetadata(int meta) - { + public int getMetadata(int meta) { return meta; } @Override - public String getItemStackDisplayName(ItemStack stack) - { + public String getItemStackDisplayName(ItemStack stack) { FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(stack.getTagCompound()); - if (fluidStack != null) - { + if (fluidStack != null) { return super.getItemStackDisplayName(stack) + " " + TextHelper.localizeEffect("tooltip.bloodmagic.tier", stack.getItemDamage() + 1) + " (" + fluidStack.getLocalizedName() + ")"; - } - else - { + } else { return super.getItemStackDisplayName(stack) + " " + TextHelper.localizeEffect("tooltip.bloodmagic.tier", stack.getItemDamage() + 1); } } @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.tier", stack.getItemDamage() + 1)); tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.fluid.capacity", getCapacity(stack))); - if (stack.hasTagCompound()) - { + if (stack.hasTagCompound()) { NBTTagCompound tag = stack.getTagCompound(); FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(tag); - if (fluidStack != null) - { + if (fluidStack != null) { tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.fluid.type", fluidStack.getLocalizedName())); tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.fluid.amount", fluidStack.amount, getCapacity(stack))); } @@ -70,23 +59,20 @@ public class ItemBlockBloodTank extends ItemBlock @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) - for (int i = 0; i < TileBloodTank.CAPACITIES.length; i++) - list.add(new ItemStack(this, 1, i)); + for (int i = 0; i < TileBloodTank.CAPACITIES.length; i++) + list.add(new ItemStack(this, 1, i)); } - public int getCapacity(ItemStack container) - { + public int getCapacity(ItemStack container) { int meta = MathHelper.clamp(container.getItemDamage(), 0, TileBloodTank.CAPACITIES.length - 1); return !container.isEmpty() && Block.getBlockFromItem(container.getItem()) instanceof BlockBloodTank ? TileBloodTank.CAPACITIES[meta] * Fluid.BUCKET_VOLUME : 0; } @Override - public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) - { + public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { return new FluidHandlerItemStack(stack, getCapacity(stack)); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockDemonCrystal.java b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockDemonCrystal.java index 51f523e5..611c8150 100644 --- a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockDemonCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockDemonCrystal.java @@ -14,34 +14,27 @@ import net.minecraft.world.World; import java.util.Locale; -public class ItemBlockDemonCrystal extends ItemBlock -{ - public ItemBlockDemonCrystal(Block block) - { +public class ItemBlockDemonCrystal extends ItemBlock { + public ItemBlockDemonCrystal(Block block) { super(block); setHasSubtypes(true); } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + EnumDemonWillType.values()[stack.getItemDamage()].toString().toLowerCase(Locale.ENGLISH); } @Override - public int getMetadata(int meta) - { + public int getMetadata(int meta) { return meta; } @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) - { - if (super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState)) - { + public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) { + if (super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState)) { TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileDemonCrystal) - { + if (tile instanceof TileDemonCrystal) { ((TileDemonCrystal) tile).setPlacement(side); } diff --git a/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockEnum.java b/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockEnum.java index 9efd5ff4..a241c1c9 100644 --- a/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockEnum.java +++ b/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockEnum.java @@ -6,11 +6,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IStringSerializable; import net.minecraft.util.math.MathHelper; -public class ItemBlockEnum & IStringSerializable> extends ItemBlock -{ +public class ItemBlockEnum & IStringSerializable> extends ItemBlock { - public ItemBlockEnum(BlockEnum block) - { + public ItemBlockEnum(BlockEnum block) { super(block); if (block.getTypes().length > 1) @@ -19,20 +17,17 @@ public class ItemBlockEnum & IStringSerializable> extends Item @SuppressWarnings("unchecked") @Override - public BlockEnum getBlock() - { + public BlockEnum getBlock() { return (BlockEnum) super.getBlock(); } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return getBlock().getUnlocalizedName() + getBlock().getTypes()[MathHelper.clamp(stack.getItemDamage(), 0, 15)].getName(); } @Override - public int getMetadata(int damage) - { + public int getMetadata(int damage) { return damage; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockString.java b/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockString.java index 37e51279..895b40c8 100644 --- a/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockString.java +++ b/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockString.java @@ -10,7 +10,7 @@ public class ItemBlockString extends ItemBlock { public ItemBlockString(BlockString block) { super(block); - if (block.getTypes().length> 1) + if (block.getTypes().length > 1) setHasSubtypes(true); } diff --git a/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSacrifice.java b/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSacrifice.java index 9bc0d2be..3abdfdce 100644 --- a/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSacrifice.java +++ b/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSacrifice.java @@ -26,12 +26,10 @@ import org.apache.commons.lang3.tuple.Pair; import java.util.ArrayList; import java.util.List; -public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, IItemLPContainer, IVariantProvider -{ +public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, IItemLPContainer, IVariantProvider { public final int CAPACITY = 10000; // Max LP storage - public ItemPackSacrifice() - { + public ItemPackSacrifice() { super(ArmorMaterial.CHAIN, 0, EntityEquipmentSlot.CHEST); setUnlocalizedName(BloodMagic.MODID + ".pack.sacrifice"); @@ -39,21 +37,17 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, I } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (world.isRemote) return ActionResult.newResult(EnumActionResult.FAIL, stack); RayTraceResult rayTrace = this.rayTrace(world, player, false); - if (rayTrace == null) - { + if (rayTrace == null) { return super.onItemRightClick(world, player, EnumHand.MAIN_HAND); - } else - { - if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) - { + } else { + if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) { TileEntity tile = world.getTileEntity(rayTrace.getBlockPos()); if (!(tile instanceof IBloodAltar)) @@ -67,15 +61,13 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, I } @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) - { + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { if (getStoredLP(stack) > CAPACITY) setStoredLP(stack, CAPACITY); } @Override - public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; @@ -84,8 +76,7 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, I } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=normal")); return ret; @@ -94,22 +85,18 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, I // IFillable @Override - public int getCapacity() - { + public int getCapacity() { return this.CAPACITY; } @Override - public int getStoredLP(ItemStack stack) - { + public int getStoredLP(ItemStack stack) { return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getInteger(Constants.NBT.STORED_LP) : 0; } @Override - public void setStoredLP(ItemStack stack, int lp) - { - if (stack != null) - { + public void setStoredLP(ItemStack stack, int lp) { + if (stack != null) { NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.STORED_LP, lp); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSelfSacrifice.java b/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSelfSacrifice.java index 35761c12..1dd19a4b 100644 --- a/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSelfSacrifice.java +++ b/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSelfSacrifice.java @@ -27,8 +27,7 @@ import org.apache.commons.lang3.tuple.Pair; import java.util.ArrayList; import java.util.List; -public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulator, IItemLPContainer, IVariantProvider -{ +public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulator, IItemLPContainer, IVariantProvider { /** * How much LP per half heart */ @@ -46,8 +45,7 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato */ public final float HEALTHREQ = 0.5f; - public ItemPackSelfSacrifice() - { + public ItemPackSelfSacrifice() { super(ArmorMaterial.CHAIN, 0, EntityEquipmentSlot.CHEST); setUnlocalizedName(BloodMagic.MODID + ".pack.selfSacrifice"); @@ -55,21 +53,17 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (world.isRemote) return ActionResult.newResult(EnumActionResult.FAIL, stack); RayTraceResult position = this.rayTrace(world, player, false); - if (position == null) - { + if (position == null) { return super.onItemRightClick(world, player, EnumHand.MAIN_HAND); - } else - { - if (position.typeOfHit == RayTraceResult.Type.BLOCK) - { + } else { + if (position.typeOfHit == RayTraceResult.Type.BLOCK) { TileEntity tile = world.getTileEntity(position.getBlockPos()); if (!(tile instanceof IBloodAltar)) @@ -83,15 +77,13 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato } @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) - { + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { if (world.isRemote || player.capabilities.isCreativeMode) return; boolean shouldSyphon = player.getHealth() / player.getMaxHealth() > HEALTHREQ && getStoredLP(stack) < CAPACITY; - if (shouldSyphon & world.getTotalWorldTime() % INTERVAL == 0) - { + if (shouldSyphon & world.getTotalWorldTime() % INTERVAL == 0) { NetworkHelper.getSoulNetwork(player).hurtPlayer(player, 1.0F); LPContainer.addLPToItem(stack, CONVERSION, CAPACITY); } @@ -101,8 +93,7 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato } @Override - public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; list.add(TextHelper.localize("tooltip.bloodmagic.pack.selfSacrifice.desc")); @@ -110,8 +101,7 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=normal")); return ret; @@ -120,22 +110,18 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato // IFillable @Override - public int getCapacity() - { + public int getCapacity() { return this.CAPACITY; } @Override - public int getStoredLP(ItemStack stack) - { + public int getStoredLP(ItemStack stack) { return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getInteger(Constants.NBT.STORED_LP) : 0; } @Override - public void setStoredLP(ItemStack stack, int lp) - { - if (stack != null) - { + public void setStoredLP(ItemStack stack, int lp) { + if (stack != null) { NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.STORED_LP, lp); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/inventory/ContainerHolding.java b/src/main/java/WayofTime/bloodmagic/item/inventory/ContainerHolding.java index 16d205d6..09508f3f 100644 --- a/src/main/java/WayofTime/bloodmagic/item/inventory/ContainerHolding.java +++ b/src/main/java/WayofTime/bloodmagic/item/inventory/ContainerHolding.java @@ -9,121 +9,94 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.FMLCommonHandler; -public class ContainerHolding extends Container -{ +public class ContainerHolding extends Container { + public final InventoryHolding inventoryHolding; private final int PLAYER_INVENTORY_ROWS = 3; private final int PLAYER_INVENTORY_COLUMNS = 9; - private final EntityPlayer player; - public final InventoryHolding inventoryHolding; - public ContainerHolding(EntityPlayer player, InventoryHolding inventoryHolding) - { + public ContainerHolding(EntityPlayer player, InventoryHolding inventoryHolding) { this.player = player; this.inventoryHolding = inventoryHolding; int currentSlotHeldIn = player.inventory.currentItem; - for (int columnIndex = 0; columnIndex < ItemSigilHolding.inventorySize; ++columnIndex) - { + for (int columnIndex = 0; columnIndex < ItemSigilHolding.inventorySize; ++columnIndex) { this.addSlotToContainer(new SlotHolding(this, inventoryHolding, player, columnIndex, 8 + columnIndex * 36, 17)); } - for (int rowIndex = 0; rowIndex < PLAYER_INVENTORY_ROWS; ++rowIndex) - { - for (int columnIndex = 0; columnIndex < PLAYER_INVENTORY_COLUMNS; ++columnIndex) - { + for (int rowIndex = 0; rowIndex < PLAYER_INVENTORY_ROWS; ++rowIndex) { + for (int columnIndex = 0; columnIndex < PLAYER_INVENTORY_COLUMNS; ++columnIndex) { this.addSlotToContainer(new Slot(player.inventory, columnIndex + rowIndex * 9 + 9, 8 + columnIndex * 18, 41 + rowIndex * 18)); } } - for (int actionBarIndex = 0; actionBarIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarIndex) - { - if (actionBarIndex == currentSlotHeldIn) - { + for (int actionBarIndex = 0; actionBarIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarIndex) { + if (actionBarIndex == currentSlotHeldIn) { this.addSlotToContainer(new SlotDisabled(player.inventory, actionBarIndex, 8 + actionBarIndex * 18, 99)); - } else - { + } else { this.addSlotToContainer(new Slot(player.inventory, actionBarIndex, 8 + actionBarIndex * 18, 99)); } } } @Override - public boolean canInteractWith(EntityPlayer entityPlayer) - { + public boolean canInteractWith(EntityPlayer entityPlayer) { return true; } @Override - public void onContainerClosed(EntityPlayer entityPlayer) - { + public void onContainerClosed(EntityPlayer entityPlayer) { super.onContainerClosed(entityPlayer); - if (!entityPlayer.getEntityWorld().isRemote) - { + if (!entityPlayer.getEntityWorld().isRemote) { saveInventory(entityPlayer); } } @Override - public void detectAndSendChanges() - { + public void detectAndSendChanges() { super.detectAndSendChanges(); - if (!player.getEntityWorld().isRemote) - { + if (!player.getEntityWorld().isRemote) { saveInventory(player); } } @Override - public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) - { + public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { ItemStack stack = ItemStack.EMPTY; Slot slotObject = inventorySlots.get(slotIndex); int slots = inventorySlots.size(); - if (slotObject != null && slotObject.getHasStack()) - { + if (slotObject != null && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); stack = stackInSlot.copy(); - if (stack.getItem() instanceof ISigil) - { - if (slotIndex < ItemSigilHolding.inventorySize) - { - if (!this.mergeItemStack(stackInSlot, ItemSigilHolding.inventorySize, slots, false)) - { + if (stack.getItem() instanceof ISigil) { + if (slotIndex < ItemSigilHolding.inventorySize) { + if (!this.mergeItemStack(stackInSlot, ItemSigilHolding.inventorySize, slots, false)) { return ItemStack.EMPTY; } - } else if (!this.mergeItemStack(stackInSlot, 0, ItemSigilHolding.inventorySize, false)) - { + } else if (!this.mergeItemStack(stackInSlot, 0, ItemSigilHolding.inventorySize, false)) { return ItemStack.EMPTY; } - } else if (stack.getItem() instanceof ItemSigilHolding) - { - if (slotIndex < ItemSigilHolding.inventorySize + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS)) - { - if (!this.mergeItemStack(stackInSlot, ItemSigilHolding.inventorySize + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), inventorySlots.size(), false)) - { + } else if (stack.getItem() instanceof ItemSigilHolding) { + if (slotIndex < ItemSigilHolding.inventorySize + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS)) { + if (!this.mergeItemStack(stackInSlot, ItemSigilHolding.inventorySize + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), inventorySlots.size(), false)) { return ItemStack.EMPTY; } - } else if (!this.mergeItemStack(stackInSlot, ItemSigilHolding.inventorySize, ItemSigilHolding.inventorySize + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), false)) - { + } else if (!this.mergeItemStack(stackInSlot, ItemSigilHolding.inventorySize, ItemSigilHolding.inventorySize + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), false)) { return ItemStack.EMPTY; } } - if (stackInSlot.isEmpty()) - { + if (stackInSlot.isEmpty()) { slotObject.putStack(ItemStack.EMPTY); - } else - { + } else { slotObject.onSlotChanged(); } - if (stackInSlot.getCount() == stack.getCount()) - { + if (stackInSlot.getCount() == stack.getCount()) { return ItemStack.EMPTY; } @@ -133,57 +106,47 @@ public class ContainerHolding extends Container return stack; } - public void saveInventory(EntityPlayer entityPlayer) - { + public void saveInventory(EntityPlayer entityPlayer) { inventoryHolding.onGuiSaved(entityPlayer); } - private class SlotHolding extends Slot - { + private class SlotHolding extends Slot { private final EntityPlayer player; private ContainerHolding containerHolding; - public SlotHolding(ContainerHolding containerHolding, IInventory inventory, EntityPlayer player, int slotIndex, int x, int y) - { + public SlotHolding(ContainerHolding containerHolding, IInventory inventory, EntityPlayer player, int slotIndex, int x, int y) { super(inventory, slotIndex, x, y); this.player = player; this.containerHolding = containerHolding; } @Override - public void onSlotChanged() - { + public void onSlotChanged() { super.onSlotChanged(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) - { + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { containerHolding.saveInventory(player); } } @Override - public boolean isItemValid(ItemStack itemStack) - { + public boolean isItemValid(ItemStack itemStack) { return itemStack.getItem() instanceof ISigil && !(itemStack.getItem() instanceof ItemSigilHolding); } } - private class SlotDisabled extends Slot - { - public SlotDisabled(IInventory inventory, int slotIndex, int x, int y) - { + private class SlotDisabled extends Slot { + public SlotDisabled(IInventory inventory, int slotIndex, int x, int y) { super(inventory, slotIndex, x, y); } @Override - public boolean isItemValid(ItemStack itemStack) - { + public boolean isItemValid(ItemStack itemStack) { return false; } @Override - public boolean canTakeStack(EntityPlayer player) - { + public boolean canTakeStack(EntityPlayer player) { return false; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/inventory/InventoryHolding.java b/src/main/java/WayofTime/bloodmagic/item/inventory/InventoryHolding.java index c0030d76..83440993 100644 --- a/src/main/java/WayofTime/bloodmagic/item/inventory/InventoryHolding.java +++ b/src/main/java/WayofTime/bloodmagic/item/inventory/InventoryHolding.java @@ -1,47 +1,38 @@ package WayofTime.bloodmagic.item.inventory; -import java.util.UUID; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.iface.ISigil; import WayofTime.bloodmagic.item.sigil.ItemSigilHolding; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; -public class InventoryHolding extends ItemInventory -{ +import java.util.UUID; + +public class InventoryHolding extends ItemInventory { protected ItemStack[] inventory; - public InventoryHolding(ItemStack itemStack) - { + public InventoryHolding(ItemStack itemStack) { super(itemStack, ItemSigilHolding.inventorySize, "SigilOfHolding"); } - public void onGuiSaved(EntityPlayer entityPlayer) - { + public void onGuiSaved(EntityPlayer entityPlayer) { masterStack = findParentStack(entityPlayer); - if (!masterStack.isEmpty()) - { + if (!masterStack.isEmpty()) { save(); } } - public ItemStack findParentStack(EntityPlayer entityPlayer) - { - if (Utils.hasUUID(masterStack)) - { + public ItemStack findParentStack(EntityPlayer entityPlayer) { + if (Utils.hasUUID(masterStack)) { UUID parentStackUUID = new UUID(masterStack.getTagCompound().getLong(Constants.NBT.MOST_SIG), masterStack.getTagCompound().getLong(Constants.NBT.LEAST_SIG)); - for (int i = 0; i < entityPlayer.inventory.getSizeInventory(); i++) - { + for (int i = 0; i < entityPlayer.inventory.getSizeInventory(); i++) { ItemStack itemStack = entityPlayer.inventory.getStackInSlot(i); - if (!itemStack.isEmpty() && Utils.hasUUID(itemStack)) - { - if (itemStack.getTagCompound().getLong(Constants.NBT.MOST_SIG) == parentStackUUID.getMostSignificantBits() && itemStack.getTagCompound().getLong(Constants.NBT.LEAST_SIG) == parentStackUUID.getLeastSignificantBits()) - { + if (!itemStack.isEmpty() && Utils.hasUUID(itemStack)) { + if (itemStack.getTagCompound().getLong(Constants.NBT.MOST_SIG) == parentStackUUID.getMostSignificantBits() && itemStack.getTagCompound().getLong(Constants.NBT.LEAST_SIG) == parentStackUUID.getLeastSignificantBits()) { return itemStack; } } @@ -51,12 +42,10 @@ public class InventoryHolding extends ItemInventory return ItemStack.EMPTY; } - public void save() - { + public void save() { NBTTagCompound nbtTagCompound = masterStack.getTagCompound(); - if (nbtTagCompound == null) - { + if (nbtTagCompound == null) { nbtTagCompound = new NBTTagCompound(); UUID uuid = UUID.randomUUID(); @@ -69,14 +58,12 @@ public class InventoryHolding extends ItemInventory } @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) - { + public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { return itemStack.getItem() instanceof ISigil && !(itemStack.getItem() instanceof ItemSigilHolding); } @Override - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 1; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/inventory/ItemInventory.java b/src/main/java/WayofTime/bloodmagic/item/inventory/ItemInventory.java index 36e7af47..78c49062 100644 --- a/src/main/java/WayofTime/bloodmagic/item/inventory/ItemInventory.java +++ b/src/main/java/WayofTime/bloodmagic/item/inventory/ItemInventory.java @@ -11,16 +11,14 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; -public class ItemInventory implements IInventory -{ +public class ItemInventory implements IInventory { protected int[] syncedSlots = new int[0]; + protected ItemStack masterStack; private NonNullList inventory; private int size; private String name; - protected ItemStack masterStack; - public ItemInventory(ItemStack masterStack, int size, String name) - { + public ItemInventory(ItemStack masterStack, int size, String name) { this.inventory = NonNullList.withSize(size, ItemStack.EMPTY); this.size = size; this.name = name; @@ -30,53 +28,42 @@ public class ItemInventory implements IInventory this.readFromStack(masterStack); } - public void initializeInventory(ItemStack masterStack) - { + public void initializeInventory(ItemStack masterStack) { this.masterStack = masterStack; this.clear(); this.readFromStack(masterStack); } - private boolean isSyncedSlot(int slot) - { - for (int s : this.syncedSlots) - { - if (s == slot) - { + private boolean isSyncedSlot(int slot) { + for (int s : this.syncedSlots) { + if (s == slot) { return true; } } return false; } - public void readFromNBT(NBTTagCompound tagCompound) - { + public void readFromNBT(NBTTagCompound tagCompound) { NBTTagList tags = tagCompound.getTagList(Constants.NBT.ITEMS, 10); inventory = NonNullList.withSize(getSizeInventory(), ItemStack.EMPTY); - for (int i = 0; i < tags.tagCount(); i++) - { - if (!isSyncedSlot(i)) - { + for (int i = 0; i < tags.tagCount(); i++) { + if (!isSyncedSlot(i)) { NBTTagCompound data = tags.getCompoundTagAt(i); byte j = data.getByte(Constants.NBT.SLOT); - if (j >= 0 && j < inventory.size()) - { + if (j >= 0 && j < inventory.size()) { inventory.set(i, new ItemStack(data)); } } } } - public void writeToNBT(NBTTagCompound tagCompound) - { + public void writeToNBT(NBTTagCompound tagCompound) { NBTTagList tags = new NBTTagList(); - for (int i = 0; i < inventory.size(); i++) - { - if ((!inventory.get(i).isEmpty()) && !isSyncedSlot(i)) - { + for (int i = 0; i < inventory.size(); i++) { + if ((!inventory.get(i).isEmpty()) && !isSyncedSlot(i)) { NBTTagCompound data = new NBTTagCompound(); data.setByte(Constants.NBT.SLOT, (byte) i); inventory.get(i).writeToNBT(data); @@ -87,20 +74,16 @@ public class ItemInventory implements IInventory tagCompound.setTag(Constants.NBT.ITEMS, tags); } - public void readFromStack(ItemStack masterStack) - { - if (masterStack != null) - { + public void readFromStack(ItemStack masterStack) { + if (masterStack != null) { NBTHelper.checkNBT(masterStack); NBTTagCompound tag = masterStack.getTagCompound(); readFromNBT(tag.getCompoundTag(Constants.NBT.ITEM_INVENTORY)); } } - public void writeToStack(ItemStack masterStack) - { - if (masterStack != null) - { + public void writeToStack(ItemStack masterStack) { + if (masterStack != null) { NBTHelper.checkNBT(masterStack); NBTTagCompound tag = masterStack.getTagCompound(); NBTTagCompound invTag = new NBTTagCompound(); @@ -110,27 +93,22 @@ public class ItemInventory implements IInventory } @Override - public int getSizeInventory() - { + public int getSizeInventory() { return size; } @Override - public ItemStack getStackInSlot(int index) - { + public ItemStack getStackInSlot(int index) { return inventory.get(index); } @Override - public ItemStack decrStackSize(int index, int count) - { - if (!inventory.get(index).isEmpty()) - { + public ItemStack decrStackSize(int index, int count) { + if (!inventory.get(index).isEmpty()) { // if (!worldObj.isRemote) // worldObj.markBlockForUpdate(this.pos); - if (inventory.get(index).getCount() <= count) - { + if (inventory.get(index).getCount() <= count) { ItemStack itemStack = inventory.get(index); inventory.set(index, ItemStack.EMPTY); markDirty(); @@ -149,10 +127,8 @@ public class ItemInventory implements IInventory } @Override - public ItemStack removeStackFromSlot(int slot) - { - if (!inventory.get(slot).isEmpty()) - { + public ItemStack removeStackFromSlot(int slot) { + if (!inventory.get(slot).isEmpty()) { ItemStack itemStack = inventory.get(slot); setInventorySlotContents(slot, ItemStack.EMPTY); return itemStack; @@ -161,8 +137,7 @@ public class ItemInventory implements IInventory } @Override - public void setInventorySlotContents(int slot, ItemStack stack) - { + public void setInventorySlotContents(int slot, ItemStack stack) { inventory.set(slot, stack); if (stack.getCount() > getInventoryStackLimit()) stack.setCount(getInventoryStackLimit()); @@ -172,82 +147,68 @@ public class ItemInventory implements IInventory } @Override - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 64; } @Override - public boolean isUsableByPlayer(EntityPlayer player) - { + public boolean isUsableByPlayer(EntityPlayer player) { return true; } @Override - public void openInventory(EntityPlayer player) - { + public void openInventory(EntityPlayer player) { } @Override - public void closeInventory(EntityPlayer player) - { + public void closeInventory(EntityPlayer player) { } @Override - public boolean isItemValidForSlot(int index, ItemStack stack) - { + public boolean isItemValidForSlot(int index, ItemStack stack) { return true; } @Override - public int getField(int id) - { + public int getField(int id) { return 0; } @Override - public void setField(int id, int value) - { + public void setField(int id, int value) { } @Override - public int getFieldCount() - { + public int getFieldCount() { return 0; } @Override - public void clear() - { + public void clear() { this.inventory = NonNullList.withSize(getSizeInventory(), ItemStack.EMPTY); } @Override - public String getName() - { + public String getName() { return name; } @Override - public boolean hasCustomName() - { + public boolean hasCustomName() { return false; } @Override - public ITextComponent getDisplayName() - { + public ITextComponent getDisplayName() { return new TextComponentString(getName()); } @Override - public void markDirty() - { - if (masterStack != null) - { + public void markDirty() { + if (masterStack != null) { this.writeToStack(masterStack); } } @@ -257,8 +218,7 @@ public class ItemInventory implements IInventory return false; } - public boolean canInventoryBeManipulated() - { + public boolean canInventoryBeManipulated() { return masterStack != null; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/routing/IFluidFilterProvider.java b/src/main/java/WayofTime/bloodmagic/item/routing/IFluidFilterProvider.java index 7f107ba3..66342e9c 100644 --- a/src/main/java/WayofTime/bloodmagic/item/routing/IFluidFilterProvider.java +++ b/src/main/java/WayofTime/bloodmagic/item/routing/IFluidFilterProvider.java @@ -1,12 +1,11 @@ package WayofTime.bloodmagic.item.routing; +import WayofTime.bloodmagic.routing.IFluidFilter; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.capability.IFluidHandler; -import WayofTime.bloodmagic.routing.IFluidFilter; -public interface IFluidFilterProvider extends IRoutingFilterProvider -{ +public interface IFluidFilterProvider extends IRoutingFilterProvider { IFluidFilter getInputFluidFilter(ItemStack stack, TileEntity tile, IFluidHandler handler); IFluidFilter getOutputFluidFilter(ItemStack stack, TileEntity tile, IFluidHandler handler); diff --git a/src/main/java/WayofTime/bloodmagic/item/routing/IItemFilterProvider.java b/src/main/java/WayofTime/bloodmagic/item/routing/IItemFilterProvider.java index 9fc55d4b..2f0cfe61 100644 --- a/src/main/java/WayofTime/bloodmagic/item/routing/IItemFilterProvider.java +++ b/src/main/java/WayofTime/bloodmagic/item/routing/IItemFilterProvider.java @@ -1,12 +1,11 @@ package WayofTime.bloodmagic.item.routing; +import WayofTime.bloodmagic.routing.IItemFilter; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.items.IItemHandler; -import WayofTime.bloodmagic.routing.IItemFilter; -public interface IItemFilterProvider extends IRoutingFilterProvider -{ +public interface IItemFilterProvider extends IRoutingFilterProvider { IItemFilter getInputItemFilter(ItemStack stack, TileEntity tile, IItemHandler handler); IItemFilter getOutputItemFilter(ItemStack stack, TileEntity tile, IItemHandler handler); diff --git a/src/main/java/WayofTime/bloodmagic/item/routing/IRoutingFilterProvider.java b/src/main/java/WayofTime/bloodmagic/item/routing/IRoutingFilterProvider.java index 05093ff1..2ae42343 100644 --- a/src/main/java/WayofTime/bloodmagic/item/routing/IRoutingFilterProvider.java +++ b/src/main/java/WayofTime/bloodmagic/item/routing/IRoutingFilterProvider.java @@ -2,11 +2,10 @@ package WayofTime.bloodmagic.item.routing; import net.minecraft.item.ItemStack; -public interface IRoutingFilterProvider -{ +public interface IRoutingFilterProvider { /** * Translates the inputed keyStack into the proper filtered key - * + * * @param filterStack * @param keyStack * @return A new ItemStack which modifies the keyStack diff --git a/src/main/java/WayofTime/bloodmagic/item/routing/ItemFluidRouterFilter.java b/src/main/java/WayofTime/bloodmagic/item/routing/ItemFluidRouterFilter.java index ab7347cd..455c44c4 100644 --- a/src/main/java/WayofTime/bloodmagic/item/routing/ItemFluidRouterFilter.java +++ b/src/main/java/WayofTime/bloodmagic/item/routing/ItemFluidRouterFilter.java @@ -1,23 +1,5 @@ package WayofTime.bloodmagic.item.routing; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.NonNullList; -import net.minecraft.world.World; -import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; - import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.item.inventory.ItemInventory; @@ -25,13 +7,26 @@ import WayofTime.bloodmagic.routing.IFluidFilter; import WayofTime.bloodmagic.routing.RoutingFluidFilter; import WayofTime.bloodmagic.util.GhostItemHelper; import WayofTime.bloodmagic.util.helper.TextHelper; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.NonNullList; +import net.minecraft.world.World; +import net.minecraftforge.fluids.capability.IFluidHandler; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; -public class ItemFluidRouterFilter extends Item implements IFluidFilterProvider, IVariantProvider -{ - public static String[] names = { "exact" }; +import java.util.ArrayList; +import java.util.List; - public ItemFluidRouterFilter() - { +public class ItemFluidRouterFilter extends Item implements IFluidFilterProvider, IVariantProvider { + public static String[] names = {"exact"}; + + public ItemFluidRouterFilter() { super(); setUnlocalizedName(BloodMagic.MODID + ".fluidFilter."); @@ -40,15 +35,13 @@ public class ItemFluidRouterFilter extends Item implements IFluidFilterProvider, } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; @@ -58,35 +51,30 @@ public class ItemFluidRouterFilter extends Item implements IFluidFilterProvider, @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { tooltip.add(TextHelper.localize("tooltip.BloodMagic.fluidFilter." + names[stack.getItemDamage()])); super.addInformation(stack, world, tooltip, flag); } @Override - public IFluidFilter getInputFluidFilter(ItemStack filterStack, TileEntity tile, IFluidHandler handler) - { + public IFluidFilter getInputFluidFilter(ItemStack filterStack, TileEntity tile, IFluidHandler handler) { IFluidFilter testFilter; - switch (filterStack.getMetadata()) - { - case 0: - testFilter = new RoutingFluidFilter(); - break; + switch (filterStack.getMetadata()) { + case 0: + testFilter = new RoutingFluidFilter(); + break; - default: - testFilter = new RoutingFluidFilter(); + default: + testFilter = new RoutingFluidFilter(); } List filteredList = new ArrayList(); ItemInventory inv = new ItemInventory(filterStack, 9, ""); - for (int i = 0; i < inv.getSizeInventory(); i++) - { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if (stack == null) - { + if (stack == null) { continue; } @@ -100,33 +88,28 @@ public class ItemFluidRouterFilter extends Item implements IFluidFilterProvider, } @Override - public IFluidFilter getOutputFluidFilter(ItemStack filterStack, TileEntity tile, IFluidHandler handler) - { + public IFluidFilter getOutputFluidFilter(ItemStack filterStack, TileEntity tile, IFluidHandler handler) { IFluidFilter testFilter = new RoutingFluidFilter(); - switch (filterStack.getMetadata()) - { - case 0: - testFilter = new RoutingFluidFilter(); - break; + switch (filterStack.getMetadata()) { + case 0: + testFilter = new RoutingFluidFilter(); + break; - default: - testFilter = new RoutingFluidFilter(); + default: + testFilter = new RoutingFluidFilter(); } List filteredList = new ArrayList(); ItemInventory inv = new ItemInventory(filterStack, 9, ""); //TODO: Change to grab the filter from the Item later. - for (int i = 0; i < inv.getSizeInventory(); i++) - { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if (stack == null) - { + if (stack == null) { continue; } ItemStack ghostStack = GhostItemHelper.getStackFromGhost(stack); - if (ghostStack.isEmpty()) - { + if (ghostStack.isEmpty()) { ghostStack.setCount(Integer.MAX_VALUE); } @@ -138,16 +121,14 @@ public class ItemFluidRouterFilter extends Item implements IFluidFilterProvider, } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=exact")); return ret; } @Override - public ItemStack getContainedStackForItem(ItemStack filterStack, ItemStack keyStack) - { + public ItemStack getContainedStackForItem(ItemStack filterStack, ItemStack keyStack) { ItemStack copyStack = keyStack.copy(); GhostItemHelper.setItemGhostAmount(copyStack, 0); copyStack.setCount(1); diff --git a/src/main/java/WayofTime/bloodmagic/item/routing/ItemNodeRouter.java b/src/main/java/WayofTime/bloodmagic/item/routing/ItemNodeRouter.java index 9d7629bf..3cdb1aa0 100644 --- a/src/main/java/WayofTime/bloodmagic/item/routing/ItemNodeRouter.java +++ b/src/main/java/WayofTime/bloodmagic/item/routing/ItemNodeRouter.java @@ -29,10 +29,8 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; -public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvider -{ - public ItemNodeRouter() - { +public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvider { + public ItemNodeRouter() { setUnlocalizedName(BloodMagic.MODID + ".nodeRouter"); setMaxStackSize(1); setCreativeTab(BloodMagic.TAB_BM); @@ -40,36 +38,30 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; NBTTagCompound tag = stack.getTagCompound(); BlockPos coords = getBlockPos(stack); - if (coords != null && tag != null) - { + if (coords != null && tag != null) { tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.coords", coords.getX(), coords.getY(), coords.getZ())); } } @Override - public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) - { + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if (world.isRemote) - { + if (world.isRemote) { return EnumActionResult.PASS; } TileEntity tileHit = world.getTileEntity(pos); - if (!(tileHit instanceof IRoutingNode)) - { + if (!(tileHit instanceof IRoutingNode)) { // TODO: Remove contained position? BlockPos containedPos = getBlockPos(stack); - if (!containedPos.equals(BlockPos.ORIGIN)) - { + if (!containedPos.equals(BlockPos.ORIGIN)) { this.setBlockPos(stack, BlockPos.ORIGIN); player.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.routing.remove"), true); return EnumActionResult.FAIL; @@ -78,23 +70,18 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi } IRoutingNode node = (IRoutingNode) tileHit; BlockPos containedPos = getBlockPos(stack); - if (containedPos.equals(BlockPos.ORIGIN)) - { + if (containedPos.equals(BlockPos.ORIGIN)) { this.setBlockPos(stack, pos); player.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.routing.set"), true); return EnumActionResult.SUCCESS; - } else - { + } else { TileEntity pastTile = world.getTileEntity(containedPos); - if (pastTile instanceof IRoutingNode) - { + if (pastTile instanceof IRoutingNode) { IRoutingNode pastNode = (IRoutingNode) pastTile; - if (pastNode instanceof IMasterRoutingNode) - { + if (pastNode instanceof IMasterRoutingNode) { IMasterRoutingNode master = (IMasterRoutingNode) pastNode; - if (!node.isMaster(master)) - { + if (!node.isMaster(master)) { if (node.getMasterPos().equals(BlockPos.ORIGIN)) //If the node is not the master and it is receptive { node.connectMasterToRemainingNode(world, new LinkedList(), master); @@ -105,8 +92,7 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi this.setBlockPos(stack, BlockPos.ORIGIN); return EnumActionResult.SUCCESS; } - } else - { + } else { master.addConnection(pos, containedPos); node.addConnection(containedPos); player.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.routing.link.master"), true); @@ -114,12 +100,10 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi return EnumActionResult.SUCCESS; } - } else if (node instanceof IMasterRoutingNode) - { + } else if (node instanceof IMasterRoutingNode) { IMasterRoutingNode master = (IMasterRoutingNode) node; - if (!pastNode.isMaster(master)) - { + if (!pastNode.isMaster(master)) { if (pastNode.getMasterPos().equals(BlockPos.ORIGIN)) //TODO: This is where the issue is { pastNode.connectMasterToRemainingNode(world, new LinkedList(), master); @@ -130,24 +114,19 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi this.setBlockPos(stack, BlockPos.ORIGIN); return EnumActionResult.SUCCESS; } - } else - { + } else { master.addConnection(pos, containedPos); pastNode.addConnection(pos); player.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.routing.link.master"), true); this.setBlockPos(stack, BlockPos.ORIGIN); return EnumActionResult.SUCCESS; } - } else - { + } else { //Both nodes are not master nodes, so normal linking - if (pastNode.getMasterPos().equals(node.getMasterPos())) - { - if (!pastNode.getMasterPos().equals(BlockPos.ORIGIN)) - { + if (pastNode.getMasterPos().equals(node.getMasterPos())) { + if (!pastNode.getMasterPos().equals(BlockPos.ORIGIN)) { TileEntity testTile = world.getTileEntity(pastNode.getMasterPos()); - if (testTile instanceof IMasterRoutingNode) - { + if (testTile instanceof IMasterRoutingNode) { IMasterRoutingNode master = (IMasterRoutingNode) testTile; master.addConnection(pos, containedPos); } @@ -160,8 +139,7 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi } else if (pastNode.getMasterPos().equals(BlockPos.ORIGIN)) //pastNode is not connected to a master, but node is { TileEntity tile = world.getTileEntity(node.getMasterPos()); - if (tile instanceof IMasterRoutingNode) - { + if (tile instanceof IMasterRoutingNode) { IMasterRoutingNode master = (IMasterRoutingNode) tile; master.addConnection(pos, containedPos); master.addNodeToList(pastNode); @@ -175,8 +153,7 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi } else if (node.getMasterPos().equals(BlockPos.ORIGIN)) //node is not connected to a master, but pastNode is { TileEntity tile = world.getTileEntity(pastNode.getMasterPos()); - if (tile instanceof IMasterRoutingNode) - { + if (tile instanceof IMasterRoutingNode) { IMasterRoutingNode master = (IMasterRoutingNode) tile; master.addConnection(pos, containedPos); master.addNodeToList(node); @@ -187,8 +164,7 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi player.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.routing.link"), true); this.setBlockPos(stack, BlockPos.ORIGIN); return EnumActionResult.SUCCESS; - } else - { + } else { this.setBlockPos(stack, BlockPos.ORIGIN); return EnumActionResult.SUCCESS; } @@ -200,21 +176,18 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=normal")); return ret; } - public BlockPos getBlockPos(ItemStack stack) - { + public BlockPos getBlockPos(ItemStack stack) { stack = NBTHelper.checkNBT(stack); return new BlockPos(stack.getTagCompound().getInteger(Constants.NBT.X_COORD), stack.getTagCompound().getInteger(Constants.NBT.Y_COORD), stack.getTagCompound().getInteger(Constants.NBT.Z_COORD)); } - public ItemStack setBlockPos(ItemStack stack, BlockPos pos) - { + public ItemStack setBlockPos(ItemStack stack, BlockPos pos) { NBTHelper.checkNBT(stack); NBTTagCompound itemTag = stack.getTagCompound(); itemTag.setInteger(Constants.NBT.X_COORD, pos.getX()); diff --git a/src/main/java/WayofTime/bloodmagic/item/routing/ItemRouterFilter.java b/src/main/java/WayofTime/bloodmagic/item/routing/ItemRouterFilter.java index 4c3c8b6a..76cc2b48 100644 --- a/src/main/java/WayofTime/bloodmagic/item/routing/ItemRouterFilter.java +++ b/src/main/java/WayofTime/bloodmagic/item/routing/ItemRouterFilter.java @@ -1,11 +1,13 @@ package WayofTime.bloodmagic.item.routing; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.item.inventory.ItemInventory; +import WayofTime.bloodmagic.routing.*; +import WayofTime.bloodmagic.util.GhostItemHelper; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -14,28 +16,16 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.IItemHandler; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.item.inventory.ItemInventory; -import WayofTime.bloodmagic.routing.DefaultItemFilter; -import WayofTime.bloodmagic.routing.IItemFilter; -import WayofTime.bloodmagic.routing.IgnoreNBTItemFilter; -import WayofTime.bloodmagic.routing.ModIdItemFilter; -import WayofTime.bloodmagic.routing.OreDictItemFilter; -import WayofTime.bloodmagic.routing.TestItemFilter; -import WayofTime.bloodmagic.util.GhostItemHelper; -import WayofTime.bloodmagic.util.helper.TextHelper; +import java.util.ArrayList; +import java.util.List; -public class ItemRouterFilter extends Item implements IItemFilterProvider, IVariantProvider -{ - public static String[] names = { "exact", "ignoreNBT", "modItems", "oreDict" }; +public class ItemRouterFilter extends Item implements IItemFilterProvider, IVariantProvider { + public static String[] names = {"exact", "ignoreNBT", "modItems", "oreDict"}; - public ItemRouterFilter() - { + public ItemRouterFilter() { super(); setUnlocalizedName(BloodMagic.MODID + ".itemFilter."); @@ -44,15 +34,13 @@ public class ItemRouterFilter extends Item implements IItemFilterProvider, IVari } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; @@ -62,44 +50,39 @@ public class ItemRouterFilter extends Item implements IItemFilterProvider, IVari @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { tooltip.add(TextHelper.localize("tooltip.bloodmagic.itemFilter." + names[stack.getItemDamage()])); super.addInformation(stack, world, tooltip, flag); } @Override - public IItemFilter getInputItemFilter(ItemStack filterStack, TileEntity tile, IItemHandler handler) - { + public IItemFilter getInputItemFilter(ItemStack filterStack, TileEntity tile, IItemHandler handler) { IItemFilter testFilter = new TestItemFilter(); - switch (filterStack.getMetadata()) - { - case 0: - testFilter = new TestItemFilter(); - break; - case 1: - testFilter = new IgnoreNBTItemFilter(); - break; - case 2: - testFilter = new ModIdItemFilter(); - break; - case 3: - testFilter = new OreDictItemFilter(); - break; + switch (filterStack.getMetadata()) { + case 0: + testFilter = new TestItemFilter(); + break; + case 1: + testFilter = new IgnoreNBTItemFilter(); + break; + case 2: + testFilter = new ModIdItemFilter(); + break; + case 3: + testFilter = new OreDictItemFilter(); + break; - default: - testFilter = new DefaultItemFilter(); + default: + testFilter = new DefaultItemFilter(); } List filteredList = new ArrayList(); ItemInventory inv = new ItemInventory(filterStack, 9, ""); - for (int i = 0; i < inv.getSizeInventory(); i++) - { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if (stack == null) - { + if (stack == null) { continue; } @@ -113,42 +96,37 @@ public class ItemRouterFilter extends Item implements IItemFilterProvider, IVari } @Override - public IItemFilter getOutputItemFilter(ItemStack filterStack, TileEntity tile, IItemHandler handler) - { + public IItemFilter getOutputItemFilter(ItemStack filterStack, TileEntity tile, IItemHandler handler) { IItemFilter testFilter; - switch (filterStack.getMetadata()) - { - case 0: - testFilter = new TestItemFilter(); - break; - case 1: - testFilter = new IgnoreNBTItemFilter(); - break; - case 2: - testFilter = new ModIdItemFilter(); - break; - case 3: - testFilter = new OreDictItemFilter(); - break; + switch (filterStack.getMetadata()) { + case 0: + testFilter = new TestItemFilter(); + break; + case 1: + testFilter = new IgnoreNBTItemFilter(); + break; + case 2: + testFilter = new ModIdItemFilter(); + break; + case 3: + testFilter = new OreDictItemFilter(); + break; - default: - testFilter = new DefaultItemFilter(); + default: + testFilter = new DefaultItemFilter(); } List filteredList = new ArrayList(); ItemInventory inv = new ItemInventory(filterStack, 9, ""); //TODO: Change to grab the filter from the Item later. - for (int i = 0; i < inv.getSizeInventory(); i++) - { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if (stack == null) - { + if (stack == null) { continue; } ItemStack ghostStack = GhostItemHelper.getStackFromGhost(stack); - if (ghostStack.isEmpty()) - { + if (ghostStack.isEmpty()) { ghostStack.setCount(Integer.MAX_VALUE); } @@ -160,8 +138,7 @@ public class ItemRouterFilter extends Item implements IItemFilterProvider, IVari } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=exact")); ret.add(new ImmutablePair(1, "type=ignorenbt")); @@ -171,8 +148,7 @@ public class ItemRouterFilter extends Item implements IItemFilterProvider, IVari } @Override - public ItemStack getContainedStackForItem(ItemStack filterStack, ItemStack keyStack) - { + public ItemStack getContainedStackForItem(ItemStack filterStack, ItemStack keyStack) { ItemStack copyStack = keyStack.copy(); GhostItemHelper.setItemGhostAmount(copyStack, 0); copyStack.setCount(1); diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilAir.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilAir.java index 4b34e4e3..885f02b5 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilAir.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilAir.java @@ -1,6 +1,9 @@ package WayofTime.bloodmagic.item.sigil; +import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider; import WayofTime.bloodmagic.api.iface.ISigil; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.core.RegistrarBloodMagic; import net.minecraft.entity.EntityLivingBase; @@ -15,20 +18,14 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectProvider -{ - public ItemSigilAir() - { +public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectProvider { + public ItemSigilAir() { super("air", 50); } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (stack.getItem() instanceof ISigil.Holding) stack = ((Holding) stack.getItem()).getHeldItem(stack, player); @@ -36,14 +33,12 @@ public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectP return ActionResult.newResult(EnumActionResult.FAIL, stack); boolean unusable = isUnusable(stack); - if (world.isRemote && !unusable) - { + if (world.isRemote && !unusable) { Vec3d vec = player.getLookVec(); double wantedVelocity = 1.7; // TODO - Revisit after potions - if (player.isPotionActive(RegistrarBloodMagic.BOOST)) - { + if (player.isPotionActive(RegistrarBloodMagic.BOOST)) { int amplifier = player.getActivePotionEffect(RegistrarBloodMagic.BOOST).getAmplifier(); wantedVelocity += (1 + amplifier) * (0.35); } @@ -54,8 +49,7 @@ public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectP world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); } - if (!world.isRemote) - { + if (!world.isRemote) { if (!player.capabilities.isCreativeMode) this.setUnusable(stack, !NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed())); @@ -67,15 +61,13 @@ public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectP } @Override - public boolean applyOnHitEffect(EnumDemonWillType type, ItemStack swordStack, ItemStack providerStack, EntityLivingBase attacker, EntityLivingBase target) - { + public boolean applyOnHitEffect(EnumDemonWillType type, ItemStack swordStack, ItemStack providerStack, EntityLivingBase attacker, EntityLivingBase target) { target.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 200, 0)); return true; } @Override - public boolean providesEffectForWill(EnumDemonWillType type) - { + public boolean providesEffectForWill(EnumDemonWillType type) { return false; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBase.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBase.java index 7726a655..7de088ff 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBase.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBase.java @@ -1,31 +1,27 @@ package WayofTime.bloodmagic.item.sigil; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.impl.ItemSigil; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.util.helper.TextHelper; import com.google.common.base.Strings; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.util.helper.TextHelper; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; -public class ItemSigilBase extends ItemSigil implements IVariantProvider -{ +public class ItemSigilBase extends ItemSigil implements IVariantProvider { protected final String tooltipBase; private final String name; - public ItemSigilBase(String name, int lpUsed) - { + public ItemSigilBase(String name, int lpUsed) { super(lpUsed); setUnlocalizedName(BloodMagic.MODID + ".sigil." + name); @@ -35,15 +31,13 @@ public class ItemSigilBase extends ItemSigil implements IVariantProvider this.tooltipBase = "tooltip.bloodmagic.sigil." + name + "."; } - public ItemSigilBase(String name) - { + public ItemSigilBase(String name) { this(name, 0); } @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (TextHelper.canTranslate(tooltipBase + "desc")) tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect(tooltipBase + "desc")))); @@ -57,8 +51,7 @@ public class ItemSigilBase extends ItemSigil implements IVariantProvider } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(Pair.of(0, "type=normal")); return ret; diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBloodLight.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBloodLight.java index 03e54516..8dc2d99f 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBloodLight.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBloodLight.java @@ -1,7 +1,12 @@ package WayofTime.bloodmagic.item.sigil; +import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.iface.ISigil; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; +import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; +import WayofTime.bloodmagic.entity.projectile.EntityBloodLight; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -11,29 +16,20 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -import WayofTime.bloodmagic.entity.projectile.EntityBloodLight; -import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; -public class ItemSigilBloodLight extends ItemSigilBase -{ - public ItemSigilBloodLight() - { +public class ItemSigilBloodLight extends ItemSigilBase { + public ItemSigilBloodLight() { super("bloodLight", 10); } @Override - public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) - { + public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if (getCooldownRemainder(stack) > 0) reduceCooldown(stack); } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (stack.getItem() instanceof ISigil.Holding) stack = ((Holding) stack.getItem()).getHeldItem(stack, player); @@ -45,12 +41,10 @@ public class ItemSigilBloodLight extends ItemSigilBase if (getCooldownRemainder(stack) > 0) return super.onItemRightClick(world, player, hand); - if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) - { + if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) { BlockPos blockPos = mop.getBlockPos().offset(mop.sideHit); - if (world.isAirBlock(blockPos)) - { + if (world.isAirBlock(blockPos)) { world.setBlockState(blockPos, RegistrarBloodMagicBlocks.BLOOD_LIGHT.getDefaultState()); if (!world.isRemote) NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()); @@ -58,10 +52,8 @@ public class ItemSigilBloodLight extends ItemSigilBase player.swingArm(hand); return super.onItemRightClick(world, player, hand); } - } else - { - if (!world.isRemote) - { + } else { + if (!world.isRemote) { world.spawnEntity(new EntityBloodLight(world, player)); NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()); } @@ -72,23 +64,19 @@ public class ItemSigilBloodLight extends ItemSigilBase } @Override - public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) - { + public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { return oldStack.getItem() != newStack.getItem(); } - public int getCooldownRemainder(ItemStack stack) - { + public int getCooldownRemainder(ItemStack stack) { return NBTHelper.checkNBT(stack).getTagCompound().getInteger(Constants.NBT.TICKS_REMAINING); } - public void reduceCooldown(ItemStack stack) - { + public void reduceCooldown(ItemStack stack) { NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.TICKS_REMAINING, getCooldownRemainder(stack) - 1); } - public void resetCooldown(ItemStack stack) - { + public void resetCooldown(ItemStack stack) { NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.TICKS_REMAINING, 10); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBounce.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBounce.java index eb6c17db..37a6eccb 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBounce.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBounce.java @@ -7,16 +7,13 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; -public class ItemSigilBounce extends ItemSigilToggleableBase -{ - public ItemSigilBounce() - { +public class ItemSigilBounce extends ItemSigilToggleableBase { + public ItemSigilBounce() { super("bounce", 100); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) - { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { if (PlayerHelper.isFakePlayer(player)) return; diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilClaw.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilClaw.java index 2003d907..44753b5b 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilClaw.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilClaw.java @@ -7,16 +7,13 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; -public class ItemSigilClaw extends ItemSigilToggleableBase -{ - public ItemSigilClaw() - { +public class ItemSigilClaw extends ItemSigilToggleableBase { + public ItemSigilClaw() { super("claw", 100); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) - { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { if (PlayerHelper.isFakePlayer(player)) return; diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilCompression.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilCompression.java index 72c97d11..34e2d061 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilCompression.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilCompression.java @@ -7,10 +7,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public class ItemSigilCompression extends ItemSigilToggleableBase -{ - public ItemSigilCompression() - { +public class ItemSigilCompression extends ItemSigilToggleableBase { + public ItemSigilCompression() { super("compression", 200); } @@ -18,8 +16,7 @@ public class ItemSigilCompression extends ItemSigilToggleableBase // TODO for now, there is a semi-working system in place @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) - { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { if (true) return; // TODO - Rewrite compression system @@ -28,8 +25,7 @@ public class ItemSigilCompression extends ItemSigilToggleableBase ItemStack compressedStack = CompressionRegistry.compressInventory(player.inventory.mainInventory.toArray(new ItemStack[player.inventory.mainInventory.size()]), world); - if (compressedStack != null) - { + if (compressedStack != null) { EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, compressedStack); world.spawnEntity(entityItem); } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java index 31e610ae..bc77fa24 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java @@ -1,9 +1,14 @@ package WayofTime.bloodmagic.item.sigil; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.api.altar.IBloodAltar; +import WayofTime.bloodmagic.api.iface.IAltarReader; import WayofTime.bloodmagic.api.iface.ISigil; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; +import WayofTime.bloodmagic.api.util.helper.PlayerHelper; +import WayofTime.bloodmagic.tile.TileIncenseAltar; +import WayofTime.bloodmagic.tile.TileInversionPillar; +import WayofTime.bloodmagic.util.ChatUtil; +import WayofTime.bloodmagic.util.helper.NumeralHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -14,25 +19,17 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.altar.IBloodAltar; -import WayofTime.bloodmagic.api.iface.IAltarReader; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -import WayofTime.bloodmagic.api.util.helper.PlayerHelper; -import WayofTime.bloodmagic.tile.TileIncenseAltar; -import WayofTime.bloodmagic.tile.TileInversionPillar; -import WayofTime.bloodmagic.util.ChatUtil; -import WayofTime.bloodmagic.util.helper.NumeralHelper; -public class ItemSigilDivination extends ItemSigilBase implements IAltarReader -{ - public ItemSigilDivination() - { +import java.util.ArrayList; +import java.util.List; + +public class ItemSigilDivination extends ItemSigilBase implements IAltarReader { + public ItemSigilDivination() { super("divination"); } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { // if (world instanceof WorldServer) // { // System.out.println("Testing..."); @@ -54,42 +51,35 @@ public class ItemSigilDivination extends ItemSigilBase implements IAltarReader if (PlayerHelper.isFakePlayer(player)) return ActionResult.newResult(EnumActionResult.FAIL, stack); - if (!world.isRemote) - { + if (!world.isRemote) { super.onItemRightClick(world, player, hand); RayTraceResult position = rayTrace(world, player, false); - if (position == null) - { + if (position == null) { int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).getCurrentEssence(); List toSend = new ArrayList(); if (!getOwnerName(stack).equals(PlayerHelper.getUsernameFromPlayer(player))) toSend.add(new TextComponentTranslation(tooltipBase + "otherNetwork", getOwnerName(stack))); toSend.add(new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence)); ChatUtil.sendNoSpam(player, toSend.toArray(new ITextComponent[toSend.size()])); - } else - { - if (position.typeOfHit == RayTraceResult.Type.BLOCK) - { + } else { + if (position.typeOfHit == RayTraceResult.Type.BLOCK) { TileEntity tile = world.getTileEntity(position.getBlockPos()); - if (tile != null && tile instanceof IBloodAltar) - { + if (tile != null && tile instanceof IBloodAltar) { IBloodAltar altar = (IBloodAltar) tile; int tier = altar.getTier().ordinal() + 1; int currentEssence = altar.getCurrentBlood(); int capacity = altar.getCapacity(); altar.checkTier(); ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarTier", NumeralHelper.toRoman(tier)), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity)); - } else if (tile != null && tile instanceof TileIncenseAltar) - { + } else if (tile != null && tile instanceof TileIncenseAltar) { TileIncenseAltar altar = (TileIncenseAltar) tile; altar.recheckConstruction(); double tranquility = altar.tranquility; ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentTranquility", (int) ((100D * (int) (100 * tranquility)) / 100d)), new TextComponentTranslation(tooltipBase + "currentBonus", (int) (100 * altar.incenseAddition))); - } else if (tile != null && tile instanceof TileInversionPillar) - { + } else if (tile != null && tile instanceof TileInversionPillar) { TileInversionPillar pillar = (TileInversionPillar) tile; double inversion = pillar.getCurrentInversion(); ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentInversion", ((int) (10 * inversion)) / 10d)); diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilElementalAffinity.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilElementalAffinity.java index 45d0f5bf..8a08ec4f 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilElementalAffinity.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilElementalAffinity.java @@ -7,16 +7,13 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; -public class ItemSigilElementalAffinity extends ItemSigilToggleableBase -{ - public ItemSigilElementalAffinity() - { +public class ItemSigilElementalAffinity extends ItemSigilToggleableBase { + public ItemSigilElementalAffinity() { super("elementalAffinity", 200); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) - { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { if (PlayerHelper.isFakePlayer(player)) return; diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilEnderSeverance.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilEnderSeverance.java index 99c82aa4..7a7def1a 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilEnderSeverance.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilEnderSeverance.java @@ -1,7 +1,5 @@ package WayofTime.bloodmagic.item.sigil; -import java.util.List; - import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.core.RegistrarBloodMagic; import net.minecraft.entity.Entity; @@ -11,22 +9,20 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; -public class ItemSigilEnderSeverance extends ItemSigilToggleableBase -{ - public ItemSigilEnderSeverance() - { +import java.util.List; + +public class ItemSigilEnderSeverance extends ItemSigilToggleableBase { + public ItemSigilEnderSeverance() { super("enderSeverance", 200); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) - { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { if (PlayerHelper.isFakePlayer(player)) return; List entityList = world.getEntitiesWithinAABB(Entity.class, new net.minecraft.util.math.AxisAlignedBB(player.posX - 4.5, player.posY - 4.5, player.posZ - 4.5, player.posX + 4.5, player.posY + 4.5, player.posZ + 4.5)); - for (Entity entity : entityList) - { + for (Entity entity : entityList) { if (entity instanceof EntityEnderman) ((EntityEnderman) entity).addPotionEffect(new PotionEffect(RegistrarBloodMagic.PLANAR_BINDING, 40, 0)); } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFastMiner.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFastMiner.java index a9add918..ad8be9f3 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFastMiner.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFastMiner.java @@ -1,7 +1,5 @@ package WayofTime.bloodmagic.item.sigil; -import java.util.List; - import WayofTime.bloodmagic.api.BloodMagicAPI; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import net.minecraft.entity.player.EntityPlayer; @@ -12,37 +10,32 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class ItemSigilFastMiner extends ItemSigilToggleableBase -{ - public ItemSigilFastMiner() - { +import java.util.List; + +public class ItemSigilFastMiner extends ItemSigilToggleableBase { + public ItemSigilFastMiner() { super("fastMiner", 100); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) - { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { if (PlayerHelper.isFakePlayer(player)) return; player.addPotionEffect(new PotionEffect(MobEffects.HASTE, 2, 0, true, false)); } @Override - public boolean performArrayEffect(World world, BlockPos pos) - { + public boolean performArrayEffect(World world, BlockPos pos) { double radius = 10; int ticks = 600; int potionPotency = 2; AxisAlignedBB bb = new AxisAlignedBB(pos).grow(radius); List playerList = world.getEntitiesWithinAABB(EntityPlayer.class, bb); - for (EntityPlayer player : playerList) - { - if (!player.isPotionActive(MobEffects.HASTE) || (player.isPotionActive(MobEffects.HASTE) && player.getActivePotionEffect(MobEffects.HASTE).getAmplifier() < potionPotency)) - { + for (EntityPlayer player : playerList) { + if (!player.isPotionActive(MobEffects.HASTE) || (player.isPotionActive(MobEffects.HASTE) && player.getActivePotionEffect(MobEffects.HASTE).getAmplifier() < potionPotency)) { player.addPotionEffect(new PotionEffect(MobEffects.HASTE, ticks, potionPotency)); - if (!player.capabilities.isCreativeMode) - { + if (!player.capabilities.isCreativeMode) { player.hurtResistantTime = 0; player.attackEntityFrom(BloodMagicAPI.damageSource, 1.0F); } @@ -53,8 +46,7 @@ public class ItemSigilFastMiner extends ItemSigilToggleableBase } @Override - public boolean hasArrayEffect() - { + public boolean hasArrayEffect() { return true; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFilledHand.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFilledHand.java index 3f99aa2c..9ef7189e 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFilledHand.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFilledHand.java @@ -1,21 +1,18 @@ package WayofTime.bloodmagic.item.sigil; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; +import WayofTime.bloodmagic.util.handler.event.GenericHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import WayofTime.bloodmagic.util.handler.event.GenericHandler; -public class ItemSigilFilledHand extends ItemSigilToggleableBase -{ - public ItemSigilFilledHand() - { +public class ItemSigilFilledHand extends ItemSigilToggleableBase { + public ItemSigilFilledHand() { super("hand", 100); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) - { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { if (PlayerHelper.isFakePlayer(player)) return; GenericHandler.filledHandMap.put(player, 4); diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFrost.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFrost.java index 990b0040..dfaab6cd 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFrost.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFrost.java @@ -6,16 +6,13 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public class ItemSigilFrost extends ItemSigilToggleableBase -{ - public ItemSigilFrost() - { +public class ItemSigilFrost extends ItemSigilToggleableBase { + public ItemSigilFrost() { super("frost", 100); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) - { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { if (PlayerHelper.isFakePlayer(player)) return; diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilGreenGrove.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilGreenGrove.java index 279460ca..e5d05dcc 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilGreenGrove.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilGreenGrove.java @@ -14,23 +14,18 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.BonemealEvent; import net.minecraftforge.fml.common.eventhandler.Event.Result; -public class ItemSigilGreenGrove extends ItemSigilToggleableBase -{ - public ItemSigilGreenGrove() - { +public class ItemSigilGreenGrove extends ItemSigilToggleableBase { + public ItemSigilGreenGrove() { super("greenGrove", 150); } @Override - public boolean onSigilUse(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) - { + public boolean onSigilUse(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) { if (PlayerHelper.isFakePlayer(player)) return false; - if (applyBonemeal(world, blockPos, player, stack)) - { - if (!world.isRemote) - { + if (applyBonemeal(world, blockPos, player, stack)) { + if (!world.isRemote) { world.playEvent(2005, blockPos, 0); } return true; @@ -40,8 +35,7 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase } @Override - public void onSigilUpdate(ItemStack stack, World worldIn, EntityPlayer player, int itemSlot, boolean isSelected) - { + public void onSigilUpdate(ItemStack stack, World worldIn, EntityPlayer player, int itemSlot, boolean isSelected) { if (PlayerHelper.isFakePlayer(player)) return; @@ -51,21 +45,15 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase int posY = (int) player.posY; int posZ = (int) Math.round(player.posZ - 0.5f); - for (int ix = posX - range; ix <= posX + range; ix++) - { - for (int iz = posZ - range; iz <= posZ + range; iz++) - { - for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++) - { + for (int ix = posX - range; ix <= posX + range; ix++) { + for (int iz = posZ - range; iz <= posZ + range; iz++) { + for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++) { BlockPos blockPos = new BlockPos(ix, iy, iz); IBlockState state = worldIn.getBlockState(blockPos); - if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state)) - { - if (state.getBlock() instanceof IGrowable) - { - if (worldIn.rand.nextInt(50) == 0) - { + if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state)) { + if (state.getBlock() instanceof IGrowable) { + if (worldIn.rand.nextInt(50) == 0) { IBlockState preBlockState = worldIn.getBlockState(blockPos); state.getBlock().updateTick(worldIn, blockPos, state, worldIn.rand); @@ -80,8 +68,7 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase } } - private boolean applyBonemeal(World worldIn, BlockPos target, EntityPlayer player, ItemStack sigilStack) - { + private boolean applyBonemeal(World worldIn, BlockPos target, EntityPlayer player, ItemStack sigilStack) { IBlockState iblockstate = worldIn.getBlockState(target); BonemealEvent event = new BonemealEvent(player, worldIn, target, iblockstate, EnumHand.MAIN_HAND, sigilStack); @@ -90,14 +77,11 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase else if (event.getResult() == Result.ALLOW) return true; - if (iblockstate.getBlock() instanceof IGrowable) - { + if (iblockstate.getBlock() instanceof IGrowable) { IGrowable igrowable = (IGrowable) iblockstate.getBlock(); - if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote)) - { - if (!worldIn.isRemote) - { + if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote)) { + if (!worldIn.isRemote) { if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate)) igrowable.grow(worldIn, worldIn.rand, target, iblockstate); } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilHaste.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilHaste.java index b14742cd..02559204 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilHaste.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilHaste.java @@ -7,16 +7,13 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; -public class ItemSigilHaste extends ItemSigilToggleableBase -{ - public ItemSigilHaste() - { +public class ItemSigilHaste extends ItemSigilToggleableBase { + public ItemSigilHaste() { super("haste", 250); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) - { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { if (PlayerHelper.isFakePlayer(player)) return; diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilHolding.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilHolding.java index 63fdd009..da59eee5 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilHolding.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilHolding.java @@ -1,11 +1,17 @@ package WayofTime.bloodmagic.item.sigil; -import java.util.Collections; -import java.util.List; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.iface.IAltarReader; +import WayofTime.bloodmagic.api.iface.IBindable; import WayofTime.bloodmagic.api.iface.ISigil; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; +import WayofTime.bloodmagic.client.key.IKeybindable; import WayofTime.bloodmagic.client.key.KeyBindings; +import WayofTime.bloodmagic.util.Utils; +import WayofTime.bloodmagic.util.helper.TextHelper; +import com.google.common.base.Strings; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -18,44 +24,29 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.iface.IAltarReader; -import WayofTime.bloodmagic.api.iface.IBindable; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.util.Utils; -import WayofTime.bloodmagic.client.key.IKeybindable; -import WayofTime.bloodmagic.util.helper.TextHelper; - -import com.google.common.base.Strings; - import javax.annotation.Nonnull; +import java.util.Collections; +import java.util.List; -public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAltarReader, ISigil.Holding -{ +public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAltarReader, ISigil.Holding { public static final int inventorySize = 5; - public ItemSigilHolding() - { + public ItemSigilHolding() { super("holding"); } @Override - public void onKeyPressed(ItemStack stack, EntityPlayer player, KeyBindings key, boolean showInChat) - { - if (stack == player.getHeldItemMainhand() && stack.getItem() instanceof ItemSigilHolding && key.equals(KeyBindings.OPEN_HOLDING)) - { + public void onKeyPressed(ItemStack stack, EntityPlayer player, KeyBindings key, boolean showInChat) { + if (stack == player.getHeldItemMainhand() && stack.getItem() instanceof ItemSigilHolding && key.equals(KeyBindings.OPEN_HOLDING)) { Utils.setUUID(stack); player.openGui(BloodMagic.instance, Constants.Gui.SIGIL_HOLDING_GUI, player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ); } } @Override - public String getHighlightTip(ItemStack stack, String displayName) - { + public String getHighlightTip(ItemStack stack, String displayName) { List inv = getInternalInventory(stack); int currentSlot = getCurrentItemOrdinal(stack); ItemStack item = inv.get(currentSlot); @@ -68,8 +59,7 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { super.addInformation(stack, world, tooltip, flag); tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.holding.press", KeyBindings.OPEN_HOLDING.getKey().getDisplayName())); @@ -80,8 +70,7 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl int currentSlot = getCurrentItemOrdinal(stack); ItemStack item = inv.get(currentSlot); - for (int i = 0; i < inventorySize; i++) - { + for (int i = 0; i < inventorySize; i++) { ItemStack invStack = inv.get(i); if (!invStack.isEmpty()) if (!item.isEmpty() && invStack == item) @@ -92,8 +81,7 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) - { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); if (PlayerHelper.isFakePlayer(player)) return EnumActionResult.FAIL; @@ -112,8 +100,7 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (PlayerHelper.isFakePlayer(player)) return ActionResult.newResult(EnumActionResult.FAIL, stack); @@ -134,26 +121,21 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl @Nonnull @Override - public ItemStack getHeldItem(ItemStack holdingStack, EntityPlayer player) - { + public ItemStack getHeldItem(ItemStack holdingStack, EntityPlayer player) { return getInternalInventory(holdingStack).get(getCurrentItemOrdinal(holdingStack)); } - public void saveInventory(ItemStack itemStack, List inventory) - { + public void saveInventory(ItemStack itemStack, List inventory) { NBTTagCompound itemTag = itemStack.getTagCompound(); - if (itemTag == null) - { + if (itemTag == null) { itemStack.setTagCompound(new NBTTagCompound()); } NBTTagList itemList = new NBTTagList(); - for (int i = 0; i < inventorySize; i++) - { - if (!inventory.get(i).isEmpty()) - { + for (int i = 0; i < inventorySize; i++) { + if (!inventory.get(i).isEmpty()) { NBTTagCompound tag = new NBTTagCompound(); tag.setByte(Constants.NBT.SLOT, (byte) i); inventory.get(i).writeToNBT(tag); @@ -165,23 +147,18 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl } @Override - public void onUpdate(ItemStack itemStack, World world, Entity entity, int itemSlot, boolean isSelected) - { - if (itemStack.getTagCompound() != null) - { + public void onUpdate(ItemStack itemStack, World world, Entity entity, int itemSlot, boolean isSelected) { + if (itemStack.getTagCompound() != null) { this.tickInternalInventory(itemStack, world, entity, itemSlot, isSelected); } } - public void tickInternalInventory(ItemStack itemStack, World world, Entity entity, int itemSlot, boolean isSelected) - { + public void tickInternalInventory(ItemStack itemStack, World world, Entity entity, int itemSlot, boolean isSelected) { List inv = getInternalInventory(itemStack); - for (int i = 0; i < inventorySize; i++) - { + for (int i = 0; i < inventorySize; i++) { ItemStack stack = inv.get(i); - if (stack.isEmpty()) - { + if (stack.isEmpty()) { continue; } @@ -189,43 +166,40 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl } } - public static int next(int mode) - { + @Override + public List> getVariants() { + return Collections.emptyList(); + } + + public static int next(int mode) { int index = mode + 1; - if (index >= inventorySize) - { + if (index >= inventorySize) { index = 0; } return index; } - public static int prev(int mode) - { + public static int prev(int mode) { int index = mode - 1; - if (index < 0) - { + if (index < 0) { index = inventorySize; } return index; } - private static void initModeTag(ItemStack stack) - { - if (!stack.hasTagCompound()) - { + private static void initModeTag(ItemStack stack) { + if (!stack.hasTagCompound()) { stack = NBTHelper.checkNBT(stack); stack.getTagCompound().setInteger(Constants.NBT.CURRENT_SIGIL, inventorySize); } } - public static ItemStack getItemStackInSlot(ItemStack itemStack, int slot) - { - if (itemStack.getItem() instanceof ItemSigilHolding) - { + public static ItemStack getItemStackInSlot(ItemStack itemStack, int slot) { + if (itemStack.getItem() instanceof ItemSigilHolding) { List inv = getInternalInventory(itemStack); if (inv != null) return inv.get(slot == 5 ? 4 : slot); @@ -236,10 +210,8 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl return ItemStack.EMPTY; } - public static int getCurrentItemOrdinal(ItemStack stack) - { - if (stack.getItem() instanceof ItemSigilHolding) - { + public static int getCurrentItemOrdinal(ItemStack stack) { + if (stack.getItem() instanceof ItemSigilHolding) { initModeTag(stack); int currentSigil = stack.getTagCompound().getInteger(Constants.NBT.CURRENT_SIGIL); currentSigil = MathHelper.clamp(currentSigil, 0, inventorySize - 1); @@ -249,32 +221,27 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl return 0; } - public static List getInternalInventory(ItemStack stack) - { + public static List getInternalInventory(ItemStack stack) { initModeTag(stack); NBTTagCompound tagCompound = stack.getTagCompound(); - if (tagCompound == null) - { + if (tagCompound == null) { return NonNullList.withSize(inventorySize, ItemStack.EMPTY); } NBTTagList tagList = tagCompound.getTagList(Constants.NBT.ITEMS, 10); - if (tagList.hasNoTags()) - { + if (tagList.hasNoTags()) { return NonNullList.withSize(inventorySize, ItemStack.EMPTY); } List inv = NonNullList.withSize(inventorySize, ItemStack.EMPTY); - for (int i = 0; i < tagList.tagCount(); i++) - { + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound data = tagList.getCompoundTagAt(i); byte j = data.getByte(Constants.NBT.SLOT); - if (j >= 0 && j < inv.size()) - { + if (j >= 0 && j < inv.size()) { inv.set(j, new ItemStack(data)); } } @@ -282,36 +249,29 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl return inv; } - public static void cycleToNextSigil(ItemStack itemStack, int mode) - { - if (itemStack.getItem() instanceof ItemSigilHolding) - { + public static void cycleToNextSigil(ItemStack itemStack, int mode) { + if (itemStack.getItem() instanceof ItemSigilHolding) { initModeTag(itemStack); int index = mode; - if (mode == 120 || mode == -120) - { + if (mode == 120 || mode == -120) { int currentIndex = getCurrentItemOrdinal(itemStack); ItemStack currentItemStack = getItemStackInSlot(itemStack, currentIndex); if (currentItemStack.isEmpty()) return; - if (mode < 0) - { + if (mode < 0) { index = next(currentIndex); currentItemStack = getItemStackInSlot(itemStack, index); - while (currentItemStack.isEmpty()) - { + while (currentItemStack.isEmpty()) { index = next(index); currentItemStack = getItemStackInSlot(itemStack, index); } - } else - { + } else { index = prev(currentIndex); currentItemStack = getItemStackInSlot(itemStack, index); - while (currentItemStack.isEmpty()) - { + while (currentItemStack.isEmpty()) { index = prev(index); currentItemStack = getItemStackInSlot(itemStack, index); } @@ -321,10 +281,4 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl itemStack.getTagCompound().setInteger(Constants.NBT.CURRENT_SIGIL, index); } } - - @Override - public List> getVariants() - { - return Collections.emptyList(); - } } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilLava.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilLava.java index 387928f6..919b2dab 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilLava.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilLava.java @@ -21,55 +21,45 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; -public class ItemSigilLava extends ItemSigilBase -{ - public ItemSigilLava() - { +public class ItemSigilLava extends ItemSigilBase { + public ItemSigilLava() { super("lava", 1000); } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (stack.getItem() instanceof ISigil.Holding) stack = ((Holding) stack.getItem()).getHeldItem(stack, player); if (PlayerHelper.isFakePlayer(player)) return ActionResult.newResult(EnumActionResult.FAIL, stack); - if (!world.isRemote && !isUnusable(stack)) - { + if (!world.isRemote && !isUnusable(stack)) { RayTraceResult rayTrace = this.rayTrace(world, player, false); - if (rayTrace != null) - { + if (rayTrace != null) { ActionResult ret = ForgeEventFactory.onBucketUse(player, world, stack, rayTrace); if (ret != null) return ret; - if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) - { + if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) { BlockPos blockpos = rayTrace.getBlockPos(); - if (!world.isBlockModifiable(player, blockpos)) - { + if (!world.isBlockModifiable(player, blockpos)) { return super.onItemRightClick(world, player, hand); } - if (!player.canPlayerEdit(blockpos.offset(rayTrace.sideHit), rayTrace.sideHit, stack)) - { + if (!player.canPlayerEdit(blockpos.offset(rayTrace.sideHit), rayTrace.sideHit, stack)) { return super.onItemRightClick(world, player, hand); } BlockPos blockpos1 = blockpos.offset(rayTrace.sideHit); - if (!player.canPlayerEdit(blockpos1, rayTrace.sideHit, stack)) - { + if (!player.canPlayerEdit(blockpos1, rayTrace.sideHit, stack)) { return super.onItemRightClick(world, player, hand); } - if (this.canPlaceLava(world, blockpos1) && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()) && this.tryPlaceLava(world, blockpos1)) - { + if (this.canPlaceLava(world, blockpos1) && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()) && this.tryPlaceLava(world, blockpos1)) { return super.onItemRightClick(world, player, hand); } } @@ -80,27 +70,22 @@ public class ItemSigilLava extends ItemSigilBase } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); - if (world.isRemote || player.isSneaking() || isUnusable(stack)) - { + if (world.isRemote || player.isSneaking() || isUnusable(stack)) { return EnumActionResult.FAIL; } - if (!world.canMineBlockBody(player, blockPos)) - { + if (!world.canMineBlockBody(player, blockPos)) { return EnumActionResult.FAIL; } TileEntity tile = world.getTileEntity(blockPos); - if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) - { + if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) { IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side); FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000); int amount = handler.fill(fluid, false); - if (amount > 0 && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed())) - { + if (amount > 0 && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed())) { handler.fill(fluid, true); return EnumActionResult.SUCCESS; } @@ -111,23 +96,18 @@ public class ItemSigilLava extends ItemSigilBase return EnumActionResult.FAIL; } - public boolean canPlaceLava(World world, BlockPos blockPos) - { - if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial(world.getBlockState(blockPos)).isSolid()) - { + public boolean canPlaceLava(World world, BlockPos blockPos) { + if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial(world.getBlockState(blockPos)).isSolid()) { return false; - } else if ((world.getBlockState(blockPos).getBlock() == Blocks.LAVA || world.getBlockState(blockPos).getBlock() == Blocks.FLOWING_LAVA) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0) - { + } else if ((world.getBlockState(blockPos).getBlock() == Blocks.LAVA || world.getBlockState(blockPos).getBlock() == Blocks.FLOWING_LAVA) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0) { return false; - } else - { + } else { world.setBlockState(blockPos, Blocks.FLOWING_LAVA.getBlockState().getBaseState(), 3); return true; } } - public boolean tryPlaceLava(World world, BlockPos pos) - { + public boolean tryPlaceLava(World world, BlockPos pos) { Material material = world.getBlockState(pos).getBlock().getMaterial(world.getBlockState(pos)); return world.isAirBlock(pos) && !material.isSolid(); diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilMagnetism.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilMagnetism.java index 3c5aec7a..f4b7e412 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilMagnetism.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilMagnetism.java @@ -1,7 +1,5 @@ package WayofTime.bloodmagic.item.sigil; -import java.util.List; - import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityXPOrb; @@ -10,16 +8,15 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.World; -public class ItemSigilMagnetism extends ItemSigilToggleableBase -{ - public ItemSigilMagnetism() - { +import java.util.List; + +public class ItemSigilMagnetism extends ItemSigilToggleableBase { + public ItemSigilMagnetism() { super("magnetism", 50); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) - { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { if (PlayerHelper.isFakePlayer(player)) return; @@ -31,18 +28,14 @@ public class ItemSigilMagnetism extends ItemSigilToggleableBase List entities = player.getEntityWorld().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range)); List xpOrbs = player.getEntityWorld().getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range)); - for (EntityItem entity : entities) - { - if (entity != null && !world.isRemote && !entity.isDead) - { + for (EntityItem entity : entities) { + if (entity != null && !world.isRemote && !entity.isDead) { entity.onCollideWithPlayer(player); } } - for (EntityXPOrb xpOrb : xpOrbs) - { - if (xpOrb != null && !world.isRemote) - { + for (EntityXPOrb xpOrb : xpOrbs) { + if (xpOrb != null && !world.isRemote) { xpOrb.onCollideWithPlayer(player); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilPhantomBridge.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilPhantomBridge.java index e391c276..53a6cedd 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilPhantomBridge.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilPhantomBridge.java @@ -1,42 +1,35 @@ package WayofTime.bloodmagic.item.sigil; -import java.util.HashMap; -import java.util.Map; - import WayofTime.bloodmagic.api.util.helper.PlayerHelper; +import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; - import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; +import java.util.HashMap; +import java.util.Map; -public class ItemSigilPhantomBridge extends ItemSigilToggleableBase -{ +public class ItemSigilPhantomBridge extends ItemSigilToggleableBase { private Map> prevPositionMap = new HashMap>(); private double expansionFactor = 2; private int range = 3; - public ItemSigilPhantomBridge() - { + public ItemSigilPhantomBridge() { super("phantomBridge", 100); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) - { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { if (PlayerHelper.isFakePlayer(player)) return; - if (!prevPositionMap.containsKey(player)) - { + if (!prevPositionMap.containsKey(player)) { prevPositionMap.put(player, Pair.of(player.posX, player.posZ)); } - if ((!player.onGround && !player.isRiding()) && !player.isSneaking()) - { + if ((!player.onGround && !player.isRiding()) && !player.isSneaking()) { prevPositionMap.put(player, Pair.of(player.posX, player.posZ)); return; } @@ -52,8 +45,7 @@ public class ItemSigilPhantomBridge extends ItemSigilToggleableBase double playerVelZ = player.posZ - prevPosition.getRight(); double totalVel = Math.sqrt(playerVelX * playerVelX + playerVelZ * playerVelZ); - if (totalVel > 2) - { + if (totalVel > 2) { //I am SURE you are teleporting! playerVelX = 0; playerVelZ = 0; @@ -74,12 +66,9 @@ public class ItemSigilPhantomBridge extends ItemSigilToggleableBase int truncC = (int) C; //TODO: Make this for-loop better. - for (int ix = -truncC; ix <= truncC; ix++) - { - for (int iz = -truncC; iz <= truncC; iz++) - { - if (computeEllipse(ix + avgX, iz + avgZ, posX, posZ, offsetPosX, offsetPosZ) > C) - { + for (int ix = -truncC; ix <= truncC; ix++) { + for (int iz = -truncC; iz <= truncC; iz++) { + if (computeEllipse(ix + avgX, iz + avgZ, posX, posZ, offsetPosX, offsetPosZ) > C) { continue; } @@ -93,8 +82,7 @@ public class ItemSigilPhantomBridge extends ItemSigilToggleableBase prevPositionMap.put(player, Pair.of(player.posX, player.posZ)); } - public static double computeEllipse(double x, double z, double focusX1, double focusZ1, double focusX2, double focusZ2) - { + public static double computeEllipse(double x, double z, double focusX1, double focusZ1, double focusX2, double focusZ2) { return Math.sqrt((x - focusX1) * (x - focusX1) + (z - focusZ1) * (z - focusZ1)) + Math.sqrt((x - focusX2) * (x - focusX2) + (z - focusZ2) * (z - focusZ2)); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSeer.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSeer.java index 11025a9a..d05a105b 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSeer.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSeer.java @@ -1,9 +1,12 @@ package WayofTime.bloodmagic.item.sigil; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.api.altar.IBloodAltar; +import WayofTime.bloodmagic.api.iface.IAltarReader; import WayofTime.bloodmagic.api.iface.ISigil; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; +import WayofTime.bloodmagic.api.util.helper.PlayerHelper; +import WayofTime.bloodmagic.tile.TileIncenseAltar; +import WayofTime.bloodmagic.util.ChatUtil; import WayofTime.bloodmagic.util.helper.NumeralHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -16,36 +19,28 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.altar.IBloodAltar; -import WayofTime.bloodmagic.api.iface.IAltarReader; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -import WayofTime.bloodmagic.api.util.helper.PlayerHelper; -import WayofTime.bloodmagic.tile.TileIncenseAltar; -import WayofTime.bloodmagic.util.ChatUtil; -public class ItemSigilSeer extends ItemSigilBase implements IAltarReader -{ - public ItemSigilSeer() - { +import java.util.ArrayList; +import java.util.List; + +public class ItemSigilSeer extends ItemSigilBase implements IAltarReader { + public ItemSigilSeer() { super("seer"); } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (stack.getItem() instanceof ISigil.Holding) stack = ((Holding) stack.getItem()).getHeldItem(stack, player); if (PlayerHelper.isFakePlayer(player)) return ActionResult.newResult(EnumActionResult.FAIL, stack); - if (!world.isRemote) - { + if (!world.isRemote) { super.onItemRightClick(world, player, hand); RayTraceResult rayTrace = rayTrace(world, player, false); - if (rayTrace == null) - { + if (rayTrace == null) { int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).getCurrentEssence(); List toSend = new ArrayList(); @@ -53,42 +48,34 @@ public class ItemSigilSeer extends ItemSigilBase implements IAltarReader toSend.add(new TextComponentTranslation(tooltipBase + "otherNetwork", getOwnerName(stack))); toSend.add(new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence)); ChatUtil.sendNoSpam(player, toSend.toArray(new ITextComponent[toSend.size()])); - } else - { - if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) - { + } else { + if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) { TileEntity tile = world.getTileEntity(rayTrace.getBlockPos()); - if (tile != null && tile instanceof IBloodAltar) - { + if (tile != null && tile instanceof IBloodAltar) { IBloodAltar altar = (IBloodAltar) tile; int tier = altar.getTier().ordinal() + 1; int currentEssence = altar.getCurrentBlood(); int capacity = altar.getCapacity(); int charge = altar.getTotalCharge(); altar.checkTier(); - if (tile instanceof IInventory) - { - if (!((IInventory) tile).getStackInSlot(0).isEmpty()) - { + if (tile instanceof IInventory) { + if (!((IInventory) tile).getStackInSlot(0).isEmpty()) { int progress = altar.getProgress(); int totalLiquidRequired = altar.getLiquidRequired() * ((IInventory) tile).getStackInSlot(0).getCount(); int consumptionRate = (int) (altar.getConsumptionRate() * (altar.getConsumptionMultiplier() + 1)); ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarProgress", progress, totalLiquidRequired), new TextComponentTranslation(tooltipBase + "currentAltarConsumptionRate", consumptionRate), new TextComponentTranslation(tooltipBase + "currentAltarTier", NumeralHelper.toRoman(tier)), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity), new TextComponentTranslation(tooltipBase + "currentCharge", charge)); - } else - { + } else { ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarTier", NumeralHelper.toRoman(tier)), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity), new TextComponentTranslation(tooltipBase + "currentCharge", charge)); } } - } else if (tile != null && tile instanceof TileIncenseAltar) - { + } else if (tile != null && tile instanceof TileIncenseAltar) { TileIncenseAltar altar = (TileIncenseAltar) tile; altar.recheckConstruction(); double tranquility = altar.tranquility; ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentTranquility", (int) ((100D * (int) (100 * tranquility)) / 100d)), new TextComponentTranslation(tooltipBase + "currentBonus", (int) (100 * altar.incenseAddition))); - } else - { + } else { int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).getCurrentEssence(); ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence)); } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSuppression.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSuppression.java index 237d0cb9..57064bf5 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSuppression.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSuppression.java @@ -1,30 +1,22 @@ package WayofTime.bloodmagic.item.sigil; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.tile.TileSpectralBlock; import WayofTime.bloodmagic.util.Utils; -import net.minecraftforge.fluids.BlockFluidBase; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; -public class ItemSigilSuppression extends ItemSigilToggleableBase -{ - public ItemSigilSuppression() - { +public class ItemSigilSuppression extends ItemSigilToggleableBase { + public ItemSigilSuppression() { super("suppression", 400); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) - { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { if (PlayerHelper.isFakePlayer(player)) return; @@ -34,14 +26,10 @@ public class ItemSigilSuppression extends ItemSigilToggleableBase final int radius = 5; final int refresh = 100; - for (int i = -radius; i <= radius; i++) - { - for (int j = -radius; j <= radius; j++) - { - for (int k = -radius; k <= radius; k++) - { - if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f)) - { + for (int i = -radius; i <= radius; i++) { + for (int j = -radius; j <= radius; j++) { + for (int k = -radius; k <= radius; k++) { + if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f)) { continue; } @@ -49,9 +37,8 @@ public class ItemSigilSuppression extends ItemSigilToggleableBase IBlockState state = world.getBlockState(blockPos); if (Utils.isBlockLiquid(state) && world.getTileEntity(blockPos) == null) - TileSpectralBlock.createSpectralBlock(world, blockPos, refresh); - else - { + TileSpectralBlock.createSpectralBlock(world, blockPos, refresh); + else { TileEntity tile = world.getTileEntity(blockPos); if (tile instanceof TileSpectralBlock) ((TileSpectralBlock) tile).resetDuration(refresh); diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilTeleposition.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilTeleposition.java index 8230fd19..e4fd869f 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilTeleposition.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilTeleposition.java @@ -1,9 +1,13 @@ package WayofTime.bloodmagic.item.sigil; -import java.util.List; - +import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.iface.ISigil; +import WayofTime.bloodmagic.api.teleport.TeleportQueue; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; +import WayofTime.bloodmagic.ritual.portal.Teleports; +import WayofTime.bloodmagic.tile.TileTeleposer; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -16,32 +20,24 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.teleport.TeleportQueue; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.ritual.portal.Teleports; -import WayofTime.bloodmagic.tile.TileTeleposer; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class ItemSigilTeleposition extends ItemSigilBase -{ - public ItemSigilTeleposition() - { +import java.util.List; + +public class ItemSigilTeleposition extends ItemSigilBase { + public ItemSigilTeleposition() { super("teleposition"); } @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { super.addInformation(stack, world, tooltip, flag); if (!stack.hasTagCompound()) return; NBTTagCompound tag = stack.getTagCompound(); - if (tag != null && stack.getTagCompound().hasKey(Constants.NBT.DIMENSION_ID) && stack.getTagCompound().hasKey(Constants.NBT.X_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Y_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Z_COORD)) - { + if (tag != null && stack.getTagCompound().hasKey(Constants.NBT.DIMENSION_ID) && stack.getTagCompound().hasKey(Constants.NBT.X_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Y_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Z_COORD)) { tooltip.add(" "); tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.coords", getValue(tag, Constants.NBT.X_COORD), getValue(tag, Constants.NBT.Y_COORD), getValue(tag, Constants.NBT.Z_COORD))); tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.dimension", getValue(tag, Constants.NBT.DIMENSION_ID))); @@ -49,22 +45,18 @@ public class ItemSigilTeleposition extends ItemSigilBase } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (stack.getItem() instanceof ISigil.Holding) stack = ((Holding) stack.getItem()).getHeldItem(stack, player); if (PlayerHelper.isFakePlayer(player)) return ActionResult.newResult(EnumActionResult.FAIL, stack); - if (!world.isRemote && NBTHelper.checkNBT(stack) != null && stack.getTagCompound().hasKey(Constants.NBT.DIMENSION_ID) && stack.getTagCompound().hasKey(Constants.NBT.X_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Y_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Z_COORD)) - { + if (!world.isRemote && NBTHelper.checkNBT(stack) != null && stack.getTagCompound().hasKey(Constants.NBT.DIMENSION_ID) && stack.getTagCompound().hasKey(Constants.NBT.X_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Y_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Z_COORD)) { BlockPos blockPos = new BlockPos(getValue(stack.getTagCompound(), Constants.NBT.X_COORD), getValue(stack.getTagCompound(), Constants.NBT.Y_COORD), getValue(stack.getTagCompound(), Constants.NBT.Z_COORD)).up(); - if (world.provider.getDimension() == getValue(stack.getTagCompound(), Constants.NBT.DIMENSION_ID)) - { + if (world.provider.getDimension() == getValue(stack.getTagCompound(), Constants.NBT.DIMENSION_ID)) { TeleportQueue.getInstance().addITeleport(new Teleports.TeleportSameDim(blockPos, player, getOwnerUUID(stack), true)); - } else - { + } else { TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(blockPos, player, getOwnerUUID(stack), world, getValue(stack.getTagCompound(), Constants.NBT.DIMENSION_ID), true)); } } @@ -72,18 +64,15 @@ public class ItemSigilTeleposition extends ItemSigilBase } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); if (stack.getItem() instanceof ISigil.Holding) stack = ((Holding) stack.getItem()).getHeldItem(stack, player); if (PlayerHelper.isFakePlayer(player)) return EnumActionResult.FAIL; - if (!world.isRemote && player.isSneaking() && NBTHelper.checkNBT(stack) != null) - { - if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileTeleposer) - { + if (!world.isRemote && player.isSneaking() && NBTHelper.checkNBT(stack) != null) { + if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileTeleposer) { stack.getTagCompound().setInteger(Constants.NBT.DIMENSION_ID, world.provider.getDimension()); stack.getTagCompound().setInteger(Constants.NBT.X_COORD, pos.getX()); stack.getTagCompound().setInteger(Constants.NBT.Y_COORD, pos.getY()); @@ -95,8 +84,7 @@ public class ItemSigilTeleposition extends ItemSigilBase return EnumActionResult.FAIL; } - public int getValue(NBTTagCompound tag, String key) - { + public int getValue(NBTTagCompound tag, String key) { return tag.getInteger(key); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilToggleableBase.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilToggleableBase.java index 859af83f..d151c19c 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilToggleableBase.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilToggleableBase.java @@ -1,35 +1,30 @@ package WayofTime.bloodmagic.item.sigil; -import java.util.ArrayList; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.impl.ItemSigilToggleable; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.client.IMeshProvider; import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; +import WayofTime.bloodmagic.util.helper.TextHelper; import com.google.common.base.Strings; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.text.WordUtils; import javax.annotation.Nullable; -import WayofTime.bloodmagic.util.helper.TextHelper; +import java.util.ArrayList; +import java.util.List; -public class ItemSigilToggleableBase extends ItemSigilToggleable implements IMeshProvider -{ +public class ItemSigilToggleableBase extends ItemSigilToggleable implements IMeshProvider { protected final String tooltipBase; private final String name; - public ItemSigilToggleableBase(String name, int lpUsed) - { + public ItemSigilToggleableBase(String name, int lpUsed) { super(lpUsed); setUnlocalizedName(BloodMagic.MODID + ".sigil." + name); @@ -41,8 +36,7 @@ public class ItemSigilToggleableBase extends ItemSigilToggleable implements IMes @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { super.addInformation(stack, world, tooltip, flag); if (!stack.hasTagCompound()) return; @@ -54,21 +48,18 @@ public class ItemSigilToggleableBase extends ItemSigilToggleable implements IMes @Override @SideOnly(Side.CLIENT) - public ItemMeshDefinition getMeshDefinition() - { + public ItemMeshDefinition getMeshDefinition() { return new CustomMeshDefinitionActivatable("ItemSigil" + WordUtils.capitalize(name)); } @Nullable @Override - public ResourceLocation getCustomLocation() - { + public ResourceLocation getCustomLocation() { return null; } @Override - public List getVariants() - { + public List getVariants() { List ret = new ArrayList(); ret.add("active=false"); ret.add("active=true"); diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilTransposition.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilTransposition.java index f60574b5..ac8429f4 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilTransposition.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilTransposition.java @@ -1,8 +1,10 @@ package WayofTime.bloodmagic.item.sigil; -import java.util.List; - +import WayofTime.bloodmagic.api.BlockStack; +import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.iface.ISigil; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.api_impl.BloodMagicAPI; import net.minecraft.block.Block; @@ -12,36 +14,33 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntityMobSpawner; -import net.minecraft.util.*; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.api.BlockStack; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -public class ItemSigilTransposition extends ItemSigilBase -{ - public ItemSigilTransposition() - { +import java.util.List; + +public class ItemSigilTransposition extends ItemSigilBase { + public ItemSigilTransposition() { super("transposition", 1000); } @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { super.addInformation(stack, world, tooltip, flag); if (!stack.hasTagCompound()) return; NBTTagCompound tag = stack.getTagCompound(); - if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META)) - { + if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META)) { tooltip.add(" "); BlockStack blockStack = new BlockStack(Block.getBlockFromName(tag.getString(Constants.NBT.CONTAINED_BLOCK_NAME)), tag.getByte(Constants.NBT.CONTAINED_BLOCK_META)); tooltip.add(blockStack.getItemStack().getDisplayName()); @@ -49,13 +48,11 @@ public class ItemSigilTransposition extends ItemSigilBase } @Override - public String getItemStackDisplayName(ItemStack stack) - { + public String getItemStackDisplayName(ItemStack stack) { stack = NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); - if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META)) - { + if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META)) { BlockStack blockStack = new BlockStack(ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tag.getString(Constants.NBT.CONTAINED_BLOCK_NAME))), tag.getByte(Constants.NBT.CONTAINED_BLOCK_META)); if (blockStack.getItemStack() != null && blockStack.getItemStack().getItem() != null) //TODO: Figure out why it's a null item. This is a patchwork solution. { @@ -67,8 +64,7 @@ public class ItemSigilTransposition extends ItemSigilBase } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); if (stack.getItem() instanceof ISigil.Holding) stack = ((Holding) stack.getItem()).getHeldItem(stack, player); @@ -78,28 +74,23 @@ public class ItemSigilTransposition extends ItemSigilBase stack = NBTHelper.checkNBT(stack); IBlockState state = world.getBlockState(blockPos); - if (!world.isRemote) - { + if (!world.isRemote) { if (BloodMagicAPI.INSTANCE.getBlacklist().getTransposition().contains(state)) return EnumActionResult.FAIL; - if (player.isSneaking() && (!stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) || !stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META))) - { - if (state.getPlayerRelativeBlockHardness(player, world, blockPos) >= 0 && state.getBlockHardness(world, blockPos) >= 0) - { + if (player.isSneaking() && (!stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) || !stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META))) { + if (state.getPlayerRelativeBlockHardness(player, world, blockPos) >= 0 && state.getBlockHardness(world, blockPos) >= 0) { int cost = getLpUsed(); NBTTagCompound tileNBTTag = new NBTTagCompound(); String blockName = state.getBlock().getRegistryName().toString(); byte metadata = (byte) state.getBlock().getMetaFromState(state); - if (world.getTileEntity(blockPos) != null) - { + if (world.getTileEntity(blockPos) != null) { cost *= 5; world.getTileEntity(blockPos).writeToNBT(tileNBTTag); - if (world.getTileEntity(blockPos) instanceof TileEntityMobSpawner) - { + if (world.getTileEntity(blockPos) instanceof TileEntityMobSpawner) { cost *= 6; } } @@ -115,26 +106,21 @@ public class ItemSigilTransposition extends ItemSigilBase return EnumActionResult.SUCCESS; } - } else if (stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META)) - { + } else if (stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META)) { IBlockState iblockstate = world.getBlockState(blockPos); Block block = iblockstate.getBlock(); BlockStack blockToPlace = new BlockStack(Block.getBlockFromName(stack.getTagCompound().getString(Constants.NBT.CONTAINED_BLOCK_NAME)), stack.getTagCompound().getByte(Constants.NBT.CONTAINED_BLOCK_META)); - if (!block.isReplaceable(world, blockPos)) - { + if (!block.isReplaceable(world, blockPos)) { blockPos = blockPos.offset(side); } - if (!stack.isEmpty() && player.canPlayerEdit(blockPos, side, stack) && world.mayPlace(blockToPlace.getBlock(), blockPos, false, side, player)) - { - if (world.setBlockState(blockPos, blockToPlace.getState(), 3)) - { + if (!stack.isEmpty() && player.canPlayerEdit(blockPos, side, stack) && world.mayPlace(blockToPlace.getBlock(), blockPos, false, side, player)) { + if (world.setBlockState(blockPos, blockToPlace.getState(), 3)) { blockToPlace.getBlock().onBlockPlacedBy(world, blockPos, blockToPlace.getState(), player, blockToPlace.getItemStack()); // world.playSound((double) ((float) blockPos.getX() + 0.5F), (double) ((float) blockPos.getY() + 0.5F), (double) ((float) blockPos.getZ() + 0.5F), blockToPlace.getBlock().getStepSound().getPlaceSound(), (blockToPlace.getBlock().getStepSound().getVolume() + 1.0F) / 2.0F, blockToPlace.getBlock().getStepSound().getPitch() * 0.8F); - if (stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_TILE_ENTITY) && blockToPlace.getBlock().hasTileEntity(blockToPlace.getState())) - { + if (stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_TILE_ENTITY) && blockToPlace.getBlock().hasTileEntity(blockToPlace.getState())) { NBTTagCompound tag = stack.getTagCompound().getCompoundTag(Constants.NBT.CONTAINED_TILE_ENTITY); tag.setInteger("x", blockPos.getX()); tag.setInteger("y", blockPos.getY()); diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilVoid.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilVoid.java index 0e27f2be..1dca46ef 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilVoid.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilVoid.java @@ -19,59 +19,48 @@ import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; -public class ItemSigilVoid extends ItemSigilBase -{ - public ItemSigilVoid() - { +public class ItemSigilVoid extends ItemSigilBase { + public ItemSigilVoid() { super("void", 50); } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (stack.getItem() instanceof ISigil.Holding) stack = ((Holding) stack.getItem()).getHeldItem(stack, player); if (PlayerHelper.isFakePlayer(player)) return ActionResult.newResult(EnumActionResult.FAIL, stack); - if (!world.isRemote && !isUnusable(stack)) - { + if (!world.isRemote && !isUnusable(stack)) { RayTraceResult rayTrace = this.rayTrace(world, player, true); - if (rayTrace != null) - { + if (rayTrace != null) { ActionResult ret = ForgeEventFactory.onBucketUse(player, world, stack, rayTrace); if (ret != null) return ret; - if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) - { + if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) { BlockPos blockpos = rayTrace.getBlockPos(); - if (!world.isBlockModifiable(player, blockpos)) - { + if (!world.isBlockModifiable(player, blockpos)) { return super.onItemRightClick(world, player, hand); } - if (!player.canPlayerEdit(blockpos.offset(rayTrace.sideHit), rayTrace.sideHit, stack)) - { + if (!player.canPlayerEdit(blockpos.offset(rayTrace.sideHit), rayTrace.sideHit, stack)) { return super.onItemRightClick(world, player, hand); } - if (!player.canPlayerEdit(blockpos, rayTrace.sideHit, stack)) - { + if (!player.canPlayerEdit(blockpos, rayTrace.sideHit, stack)) { return super.onItemRightClick(world, player, hand); } - if (world.getBlockState(blockpos).getBlock().getMaterial(world.getBlockState(blockpos)).isLiquid() && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) - { + if (world.getBlockState(blockpos).getBlock().getMaterial(world.getBlockState(blockpos)).isLiquid() && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) { world.setBlockToAir(blockpos); return super.onItemRightClick(world, player, hand); } } - } else - { + } else { return super.onItemRightClick(world, player, hand); } @@ -83,30 +72,25 @@ public class ItemSigilVoid extends ItemSigilBase } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); if (PlayerHelper.isFakePlayer(player)) return EnumActionResult.FAIL; - if (world.isRemote || player.isSneaking() || isUnusable(stack)) - { + if (world.isRemote || player.isSneaking() || isUnusable(stack)) { return EnumActionResult.FAIL; } - if (!world.canMineBlockBody(player, blockPos)) - { + if (!world.canMineBlockBody(player, blockPos)) { return EnumActionResult.FAIL; } TileEntity tile = world.getTileEntity(blockPos); - if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) - { + if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) { IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side); FluidStack amount = handler.drain(1000, false); - if (amount != null && amount.amount > 0 && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed())) - { + if (amount != null && amount.amount > 0 && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed())) { handler.drain(1000, true); return EnumActionResult.SUCCESS; } @@ -116,13 +100,11 @@ public class ItemSigilVoid extends ItemSigilBase BlockPos newPos = blockPos.offset(side); - if (!player.canPlayerEdit(newPos, side, stack)) - { + if (!player.canPlayerEdit(newPos, side, stack)) { return EnumActionResult.FAIL; } - if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed())) - { + if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed())) { world.setBlockToAir(newPos); return EnumActionResult.SUCCESS; } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWater.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWater.java index 2de40557..8fa03754 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWater.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWater.java @@ -10,12 +10,7 @@ import net.minecraft.init.Blocks; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.EnumParticleTypes; -import net.minecraft.util.SoundCategory; +import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; @@ -24,34 +19,28 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; -public class ItemSigilWater extends ItemSigilBase -{ - public ItemSigilWater() - { +public class ItemSigilWater extends ItemSigilBase { + public ItemSigilWater() { super("water", 100); } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (stack.getItem() instanceof ISigil.Holding) stack = ((Holding) stack.getItem()).getHeldItem(stack, player); if (PlayerHelper.isFakePlayer(player)) return ActionResult.newResult(EnumActionResult.FAIL, stack); - if (!world.isRemote && !isUnusable(stack)) - { + if (!world.isRemote && !isUnusable(stack)) { RayTraceResult rayTrace = this.rayTrace(world, player, false); - if (rayTrace != null) - { + if (rayTrace != null) { ActionResult ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(player, world, stack, rayTrace); if (ret != null) return ret; - if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) - { + if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) { BlockPos blockpos = rayTrace.getBlockPos(); if (!world.isBlockModifiable(player, blockpos)) @@ -75,8 +64,7 @@ public class ItemSigilWater extends ItemSigilBase } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) - { + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); if (world.isRemote || player.isSneaking() || isUnusable(stack)) return EnumActionResult.FAIL; @@ -85,14 +73,12 @@ public class ItemSigilWater extends ItemSigilBase return EnumActionResult.FAIL; TileEntity tile = world.getTileEntity(blockPos); - if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) - { + if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) { IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side); FluidStack fluid = new FluidStack(FluidRegistry.WATER, 1000); int amount = handler.fill(fluid, false); - if (amount > 0 && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) - { + if (amount > 0 && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) { handler.fill(fluid, true); return EnumActionResult.SUCCESS; } @@ -100,8 +86,7 @@ public class ItemSigilWater extends ItemSigilBase return EnumActionResult.FAIL; } - if (world.getBlockState(blockPos).getBlock() == Blocks.CAULDRON && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) - { + if (world.getBlockState(blockPos).getBlock() == Blocks.CAULDRON && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) { world.setBlockState(blockPos, Blocks.CAULDRON.getDefaultState().withProperty(BlockCauldron.LEVEL, 3)); return EnumActionResult.SUCCESS; } @@ -109,8 +94,7 @@ public class ItemSigilWater extends ItemSigilBase return EnumActionResult.FAIL; } - public boolean canPlaceWater(World world, BlockPos blockPos) - { + public boolean canPlaceWater(World world, BlockPos blockPos) { if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial(world.getBlockState(blockPos)).isSolid()) return false; else if ((world.getBlockState(blockPos).getBlock() == Blocks.WATER || world.getBlockState(blockPos).getBlock() == Blocks.FLOWING_WATER) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0) @@ -119,19 +103,15 @@ public class ItemSigilWater extends ItemSigilBase return true; } - public boolean tryPlaceWater(World worldIn, BlockPos pos) - { + public boolean tryPlaceWater(World worldIn, BlockPos pos) { Material material = worldIn.getBlockState(pos).getBlock().getMaterial(worldIn.getBlockState(pos)); boolean notSolid = !material.isSolid(); - if (!worldIn.isAirBlock(pos) && !notSolid) - { + if (!worldIn.isAirBlock(pos) && !notSolid) { return false; - } else - { - if (worldIn.provider.doesWaterVaporize()) - { + } else { + if (worldIn.provider.doesWaterVaporize()) { int i = pos.getX(); int j = pos.getY(); int k = pos.getZ(); @@ -139,8 +119,7 @@ public class ItemSigilWater extends ItemSigilBase for (int l = 0; l < 8; ++l) worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D, 0); - } else - { + } else { if (!worldIn.isRemote && notSolid && !material.isLiquid()) worldIn.destroyBlock(pos, true); diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWhirlwind.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWhirlwind.java index fe06e950..05bb2c43 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWhirlwind.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWhirlwind.java @@ -7,16 +7,13 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; -public class ItemSigilWhirlwind extends ItemSigilToggleableBase -{ - public ItemSigilWhirlwind() - { +public class ItemSigilWhirlwind extends ItemSigilToggleableBase { + public ItemSigilWhirlwind() { super("whirlwind", 250); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) - { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { if (PlayerHelper.isFakePlayer(player)) return; diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemMonsterSoul.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemMonsterSoul.java index ea1eb7fe..3be9b4be 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemMonsterSoul.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemMonsterSoul.java @@ -9,7 +9,6 @@ import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -17,19 +16,16 @@ import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; import java.util.ArrayList; import java.util.List; -public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvider -{ - public static String[] names = { "base", "corrosive", "destructive", "vengeful", "steadfast" }; +public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvider { + public static String[] names = {"base", "corrosive", "destructive", "vengeful", "steadfast"}; - public ItemMonsterSoul() - { + public ItemMonsterSoul() { super(); setUnlocalizedName(BloodMagic.MODID + ".monsterSoul."); @@ -39,14 +35,12 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } @Override - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; @@ -56,8 +50,7 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; tooltip.add(TextHelper.localize("tooltip.bloodmagic.will", getWill(getType(stack), stack))); @@ -66,16 +59,13 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide } @Override - public EnumDemonWillType getType(ItemStack stack) - { + public EnumDemonWillType getType(ItemStack stack) { return EnumDemonWillType.values()[stack.getItemDamage() % 5]; } @Override - public double getWill(EnumDemonWillType type, ItemStack soulStack) - { - if (type != this.getType(soulStack)) - { + public double getWill(EnumDemonWillType type, ItemStack soulStack) { + if (type != this.getType(soulStack)) { return 0; } @@ -87,8 +77,7 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide } @Override - public void setWill(EnumDemonWillType type, ItemStack soulStack, double souls) - { + public void setWill(EnumDemonWillType type, ItemStack soulStack, double souls) { NBTHelper.checkNBT(soulStack); NBTTagCompound tag = soulStack.getTagCompound(); @@ -99,8 +88,7 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide } @Override - public double drainWill(EnumDemonWillType type, ItemStack soulStack, double drainAmount) - { + public double drainWill(EnumDemonWillType type, ItemStack soulStack, double drainAmount) { double souls = getWill(type, soulStack); double soulsDrained = Math.min(drainAmount, souls); @@ -110,19 +98,16 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide } @Override - public ItemStack createWill(int meta, double number) - { + public ItemStack createWill(int meta, double number) { ItemStack soulStack = new ItemStack(this, 1, meta % 5); setWill(getType(soulStack), soulStack, number); return soulStack; } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); - for (int i = 0; i < names.length; i++) - { + for (int i = 0; i < names.length; i++) { String name = names[i]; ret.add(new ImmutablePair(i, "type=" + name)); } @@ -130,20 +115,17 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide } @Override - public double getWill(ItemStack willStack) - { + public double getWill(ItemStack willStack) { return this.getWill(EnumDemonWillType.DEFAULT, willStack); } @Override - public void setWill(ItemStack willStack, double will) - { + public void setWill(ItemStack willStack, double will) { this.setWill(EnumDemonWillType.DEFAULT, willStack, will); } @Override - public double drainWill(ItemStack willStack, double drainAmount) - { + public double drainWill(ItemStack willStack, double drainAmount) { return this.drainWill(EnumDemonWillType.DEFAULT, willStack, drainAmount); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientArmourGem.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientArmourGem.java index 1a7c9e7c..9c9ca878 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientArmourGem.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientArmourGem.java @@ -1,5 +1,9 @@ package WayofTime.bloodmagic.item.soul; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; +import WayofTime.bloodmagic.item.armour.ItemSentientArmour; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -11,15 +15,9 @@ import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; -import WayofTime.bloodmagic.item.armour.ItemSentientArmour; -public class ItemSentientArmourGem extends Item -{ - public ItemSentientArmourGem() - { +public class ItemSentientArmourGem extends Item { + public ItemSentientArmourGem() { super(); setCreativeTab(BloodMagic.TAB_BM); @@ -27,29 +25,23 @@ public class ItemSentientArmourGem extends Item setMaxStackSize(1); } - public EnumDemonWillType getCurrentType(ItemStack stack) - { + public EnumDemonWillType getCurrentType(ItemStack stack) { return EnumDemonWillType.DEFAULT; } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { boolean hasSentientArmour = false; NonNullList armourInventory = player.inventory.armorInventory; - for (ItemStack armourStack : armourInventory) - { - if (armourStack != null && armourStack.getItem() instanceof ItemSentientArmour) - { + for (ItemStack armourStack : armourInventory) { + if (armourStack != null && armourStack.getItem() instanceof ItemSentientArmour) { hasSentientArmour = true; } } - if (hasSentientArmour) - { + if (hasSentientArmour) { ItemSentientArmour.revertAllArmour(player); - } else - { + } else { EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player); double will = PlayerDemonWillHandler.getTotalDemonWill(type, player); @@ -61,20 +53,16 @@ public class ItemSentientArmourGem extends Item } @SideOnly(Side.CLIENT) - public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) - { + public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) { boolean hasSentientArmour = false; NonNullList armourInventory = player.inventory.armorInventory; - for (ItemStack armourStack : armourInventory) - { - if (armourStack != null && armourStack.getItem() instanceof ItemSentientArmour) - { + for (ItemStack armourStack : armourInventory) { + if (armourStack != null && armourStack.getItem() instanceof ItemSentientArmour) { hasSentientArmour = true; } } - if (hasSentientArmour) - { + if (hasSentientArmour) { return new ModelResourceLocation("bloodmagic:ItemSentientArmourGem1", "inventory"); } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientAxe.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientAxe.java index 77bc1027..13f9d254 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientAxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientAxe.java @@ -1,9 +1,22 @@ package WayofTime.bloodmagic.item.soul; -import java.util.*; - -import javax.annotation.Nullable; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.iface.IMultiWillTool; +import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider; +import WayofTime.bloodmagic.api.iface.ISentientTool; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.soul.IDemonWill; +import WayofTime.bloodmagic.api.soul.IDemonWillWeapon; +import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.client.IMeshProvider; +import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; +import WayofTime.bloodmagic.util.helper.TextHelper; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.util.ITooltipFlag; @@ -28,55 +41,38 @@ import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.iface.IMultiWillTool; -import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider; -import WayofTime.bloodmagic.api.iface.ISentientTool; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.soul.IDemonWill; -import WayofTime.bloodmagic.api.soul.IDemonWillWeapon; -import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.client.IMeshProvider; -import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill; -import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.util.helper.TextHelper; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; +import javax.annotation.Nullable; +import java.util.*; -public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool -{ - public static int[] soulBracket = new int[] { 16, 60, 200, 400, 1000 }; - public static double[] defaultDamageAdded = new double[] { 1, 2, 3, 3.5, 4 }; - public static double[] destructiveDamageAdded = new double[] { 2, 3, 4, 5, 6 }; - public static double[] vengefulDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2 }; - public static double[] steadfastDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2 }; - public static double[] defaultDigSpeedAdded = new double[] { 1, 1.5, 2, 3, 4 }; - public static double[] soulDrainPerSwing = new double[] { 0.05, 0.1, 0.2, 0.4, 0.75 }; - public static double[] soulDrop = new double[] { 2, 4, 7, 10, 13 }; - public static double[] staticDrop = new double[] { 1, 1, 2, 3, 3 }; +public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool { + public static int[] soulBracket = new int[]{16, 60, 200, 400, 1000}; + public static double[] defaultDamageAdded = new double[]{1, 2, 3, 3.5, 4}; + public static double[] destructiveDamageAdded = new double[]{2, 3, 4, 5, 6}; + public static double[] vengefulDamageAdded = new double[]{0, 0.5, 1, 1.5, 2}; + public static double[] steadfastDamageAdded = new double[]{0, 0.5, 1, 1.5, 2}; + public static double[] defaultDigSpeedAdded = new double[]{1, 1.5, 2, 3, 4}; + public static double[] soulDrainPerSwing = new double[]{0.05, 0.1, 0.2, 0.4, 0.75}; + public static double[] soulDrop = new double[]{2, 4, 7, 10, 13}; + public static double[] staticDrop = new double[]{1, 1, 2, 3, 3}; - public static double[] healthBonus = new double[] { 0, 0, 0, 0, 0 }; //TODO: Think of implementing this later - public static double[] vengefulAttackSpeed = new double[] { -3, -2.8, -2.7, -2.6, -2.5 }; - public static double[] destructiveAttackSpeed = new double[] { -3.1, -3.1, -3.2, -3.3, -3.3 }; + public static double[] healthBonus = new double[]{0, 0, 0, 0, 0}; //TODO: Think of implementing this later + public static double[] vengefulAttackSpeed = new double[]{-3, -2.8, -2.7, -2.6, -2.5}; + public static double[] destructiveAttackSpeed = new double[]{-3.1, -3.1, -3.2, -3.3, -3.3}; - public static int[] absorptionTime = new int[] { 200, 300, 400, 500, 600 }; + public static int[] absorptionTime = new int[]{200, 300, 400, 500, 600}; public static double maxAbsorptionHearts = 10; - public static int[] poisonTime = new int[] { 25, 50, 60, 80, 100 }; - public static int[] poisonLevel = new int[] { 0, 0, 0, 1, 1 }; + public static int[] poisonTime = new int[]{25, 50, 60, 80, 100}; + public static int[] poisonLevel = new int[]{0, 0, 0, 1, 1}; - public static double[] movementSpeed = new double[] { 0.05, 0.1, 0.15, 0.2, 0.25 }; + public static double[] movementSpeed = new double[]{0.05, 0.1, 0.15, 0.2, 0.25}; public final double baseAttackDamage = 8; public final double baseAttackSpeed = -3; - public ItemSentientAxe() - { + public ItemSentientAxe() { super(Item.ToolMaterial.IRON); setMaxDamage(getMaxDamage() * 2); // super(ModItems.soulToolMaterial); @@ -86,26 +82,21 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP } @Override - public float getStrVsBlock(ItemStack stack, IBlockState state) - { + public float getStrVsBlock(ItemStack stack, IBlockState state) { float value = super.getStrVsBlock(stack, state); - if (value > 1) - { + if (value > 1) { return (float) (value + getDigSpeedOfSword(stack)); - } else - { + } else { return value; } } @Override - public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) - { + public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { return RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL == repair.getItem() || super.getIsRepairable(toRepair, repair); } - public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) - { + public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) { EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); this.setCurrentType(stack, soulsRemaining > 0 ? type : EnumDemonWillType.DEFAULT); @@ -124,106 +115,89 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP setDigSpeedOfSword(stack, level >= 0 ? getDigSpeed(type, level) : 0); } - public double getExtraDamage(EnumDemonWillType type, int willBracket) - { - if (willBracket < 0) - { + public double getExtraDamage(EnumDemonWillType type, int willBracket) { + if (willBracket < 0) { return 0; } - switch (type) - { - case CORROSIVE: - case DEFAULT: - return defaultDamageAdded[willBracket]; - case DESTRUCTIVE: - return destructiveDamageAdded[willBracket]; - case VENGEFUL: - return vengefulDamageAdded[willBracket]; - case STEADFAST: - return steadfastDamageAdded[willBracket]; + switch (type) { + case CORROSIVE: + case DEFAULT: + return defaultDamageAdded[willBracket]; + case DESTRUCTIVE: + return destructiveDamageAdded[willBracket]; + case VENGEFUL: + return vengefulDamageAdded[willBracket]; + case STEADFAST: + return steadfastDamageAdded[willBracket]; } return 0; } - public double getAttackSpeed(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case VENGEFUL: - return vengefulAttackSpeed[willBracket]; - case DESTRUCTIVE: - return destructiveAttackSpeed[willBracket]; - default: - return -2.9; + public double getAttackSpeed(EnumDemonWillType type, int willBracket) { + switch (type) { + case VENGEFUL: + return vengefulAttackSpeed[willBracket]; + case DESTRUCTIVE: + return destructiveAttackSpeed[willBracket]; + default: + return -2.9; } } - public double getHealthBonus(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case STEADFAST: - return healthBonus[willBracket]; - default: - return 0; + public double getHealthBonus(EnumDemonWillType type, int willBracket) { + switch (type) { + case STEADFAST: + return healthBonus[willBracket]; + default: + return 0; } } - public double getMovementSpeed(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case VENGEFUL: - return movementSpeed[willBracket]; - default: - return 0; + public double getMovementSpeed(EnumDemonWillType type, int willBracket) { + switch (type) { + case VENGEFUL: + return movementSpeed[willBracket]; + default: + return 0; } } - public double getDigSpeed(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case VENGEFUL: + public double getDigSpeed(EnumDemonWillType type, int willBracket) { + switch (type) { + case VENGEFUL: // return movementSpeed[willBracket]; - default: - return defaultDigSpeedAdded[willBracket]; + default: + return defaultDigSpeedAdded[willBracket]; } } - public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityPlayer attacker) - { - switch (type) - { - case CORROSIVE: - target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket])); - break; - case DEFAULT: - break; - case DESTRUCTIVE: - break; - case STEADFAST: - if (!target.isEntityAlive()) - { - float absorption = attacker.getAbsorptionAmount(); - attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127)); - attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts)); - } - break; - case VENGEFUL: - break; + public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityPlayer attacker) { + switch (type) { + case CORROSIVE: + target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket])); + break; + case DEFAULT: + break; + case DESTRUCTIVE: + break; + case STEADFAST: + if (!target.isEntityAlive()) { + float absorption = attacker.getAbsorptionAmount(); + attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127)); + attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts)); + } + break; + case VENGEFUL: + break; } } @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) - { - if (super.hitEntity(stack, target, attacker)) - { - if (attacker instanceof EntityPlayer) - { + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { + if (super.hitEntity(stack, target, attacker)) { + if (attacker instanceof EntityPlayer) { EntityPlayer attackerPlayer = (EntityPlayer) attacker; this.recalculatePowers(stack, attackerPlayer.getEntityWorld(), attackerPlayer); EnumDemonWillType type = this.getCurrentType(stack); @@ -233,11 +207,9 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP applyEffectToEntity(type, willBracket, target, attackerPlayer); ItemStack offStack = attackerPlayer.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND); - if (offStack.getItem() instanceof ISentientSwordEffectProvider) - { + if (offStack.getItem() instanceof ISentientSwordEffectProvider) { ISentientSwordEffectProvider provider = (ISentientSwordEffectProvider) offStack.getItem(); - if (provider.providesEffectForWill(type)) - { + if (provider.providesEffectForWill(type)) { provider.applyOnHitEffect(type, stack, offStack, attacker, target); } } @@ -250,22 +222,19 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP } @Override - public EnumDemonWillType getCurrentType(ItemStack stack) - { + public EnumDemonWillType getCurrentType(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); - if (!tag.hasKey(Constants.NBT.WILL_TYPE)) - { + if (!tag.hasKey(Constants.NBT.WILL_TYPE)) { return EnumDemonWillType.DEFAULT; } return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH)); } - public void setCurrentType(ItemStack stack, EnumDemonWillType type) - { + public void setCurrentType(ItemStack stack, EnumDemonWillType type) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -274,26 +243,21 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { recalculatePowers(player.getHeldItem(hand), world, player); return super.onItemRightClick(world, player, hand); } @Override - public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) - { + public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { return oldStack.getItem() != newStack.getItem(); } - private int getLevel(ItemStack stack, double soulsRemaining) - { + private int getLevel(ItemStack stack, double soulsRemaining) { int lvl = -1; - for (int i = 0; i < soulBracket.length; i++) - { - if (soulsRemaining >= soulBracket[i]) - { + for (int i = 0; i < soulBracket.length; i++) { + if (soulsRemaining >= soulBracket[i]) { lvl = i; } } @@ -303,8 +267,7 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; @@ -313,21 +276,17 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP } @Override - public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) - { + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { recalculatePowers(stack, player.getEntityWorld(), player); double drain = this.getDrainOfActivatedSword(stack); - if (drain > 0) - { + if (drain > 0) { EnumDemonWillType type = getCurrentType(stack); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); - if (drain > soulsRemaining) - { + if (drain > soulsRemaining) { return false; - } else - { + } else { PlayerDemonWillHandler.consumeDemonWill(type, player, drain); } } @@ -337,24 +296,20 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP @Override @SideOnly(Side.CLIENT) - public ItemMeshDefinition getMeshDefinition() - { + public ItemMeshDefinition getMeshDefinition() { return new CustomMeshDefinitionMultiWill("ItemSentientAxe"); } @Nullable @Override - public ResourceLocation getCustomLocation() - { + public ResourceLocation getCustomLocation() { return null; } @Override - public List getVariants() - { + public List getVariants() { List ret = new ArrayList(); - for (EnumDemonWillType type : EnumDemonWillType.values()) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { ret.add("type=" + type.getName().toLowerCase()); } @@ -362,12 +317,10 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP } @Override - public List getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) - { + public List getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) { List soulList = new ArrayList(); - if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) - { + if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) { return soulList; } @@ -377,10 +330,8 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP EnumDemonWillType type = this.getCurrentType(stack); - for (int i = 0; i <= looting; i++) - { - if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) - { + for (int i = 0; i <= looting; i++) { + if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) { ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); soulList.add(soulStack); } @@ -391,11 +342,9 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP //TODO: Change attack speed. @Override - public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) - { + public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { Multimap multimap = HashMultimap.create(); - if (slot == EntityEquipmentSlot.MAINHAND) - { + if (slot == EntityEquipmentSlot.MAINHAND) { multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0)); multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0)); multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0)); @@ -405,16 +354,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP return multimap; } - public double getDamageOfActivatedSword(ItemStack stack) - { + public double getDamageOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_DAMAGE); } - public void setDamageOfActivatedSword(ItemStack stack, double damage) - { + public void setDamageOfActivatedSword(ItemStack stack, double damage) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -422,16 +369,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP tag.setDouble(Constants.NBT.SOUL_SWORD_DAMAGE, damage); } - public double getDrainOfActivatedSword(ItemStack stack) - { + public double getDrainOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN); } - public void setDrainOfActivatedSword(ItemStack stack, double drain) - { + public void setDrainOfActivatedSword(ItemStack stack, double drain) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -439,16 +384,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP tag.setDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN, drain); } - public double getStaticDropOfActivatedSword(ItemStack stack) - { + public double getStaticDropOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP); } - public void setStaticDropOfActivatedSword(ItemStack stack, double drop) - { + public void setStaticDropOfActivatedSword(ItemStack stack, double drop) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -456,16 +399,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP tag.setDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP, drop); } - public double getDropOfActivatedSword(ItemStack stack) - { + public double getDropOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_DROP); } - public void setDropOfActivatedSword(ItemStack stack, double drop) - { + public void setDropOfActivatedSword(ItemStack stack, double drop) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -473,16 +414,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP tag.setDouble(Constants.NBT.SOUL_SWORD_DROP, drop); } - public double getHealthBonusOfSword(ItemStack stack) - { + public double getHealthBonusOfSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH); } - public void setHealthBonusOfSword(ItemStack stack, double hp) - { + public void setHealthBonusOfSword(ItemStack stack, double hp) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -490,16 +429,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP tag.setDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp); } - public double getAttackSpeedOfSword(ItemStack stack) - { + public double getAttackSpeedOfSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED); } - public void setAttackSpeedOfSword(ItemStack stack, double speed) - { + public void setAttackSpeedOfSword(ItemStack stack, double speed) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -507,16 +444,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP tag.setDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED, speed); } - public double getSpeedOfSword(ItemStack stack) - { + public double getSpeedOfSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_SPEED); } - public void setSpeedOfSword(ItemStack stack, double speed) - { + public void setSpeedOfSword(ItemStack stack, double speed) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -524,16 +459,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP tag.setDouble(Constants.NBT.SOUL_SWORD_SPEED, speed); } - public double getDigSpeedOfSword(ItemStack stack) - { + public double getDigSpeedOfSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_DIG_SPEED); } - public void setDigSpeedOfSword(ItemStack stack, double speed) - { + public void setDigSpeedOfSword(ItemStack stack, double speed) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -542,17 +475,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP } @Override - public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) - { + public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) { World world = player.getEntityWorld(); - if (!world.isRemote) - { + if (!world.isRemote) { this.recalculatePowers(droppedStack, world, player); EnumDemonWillType type = this.getCurrentType(droppedStack); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); - if (soulsRemaining < 1024) - { + if (soulsRemaining < 1024) { return false; } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java index 0a06e2e4..93591ef5 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java @@ -1,5 +1,15 @@ package WayofTime.bloodmagic.item.soul; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.iface.IMultiWillTool; +import WayofTime.bloodmagic.api.iface.ISentientTool; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; +import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -22,81 +32,59 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.iface.IMultiWillTool; -import WayofTime.bloodmagic.api.iface.ISentientTool; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; -import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import java.util.Locale; public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentientTool//, IMeshProvider { - public static int[] soulBracket = new int[] { 16, 60, 200, 400, 1000 }; - public static double[] defaultDamageAdded = new double[] { 0.25, 0.5, 0.75, 1, 1.25 }; - public static float[] velocityAdded = new float[] { 0.25f, 0.5f, 0.75f, 1, 1.25f }; - public static double[] soulDrainPerSwing = new double[] { 0.05, 0.1, 0.2, 0.4, 0.75 }; //TODO - public static double[] soulDrop = new double[] { 2, 4, 7, 10, 13 }; - public static double[] staticDrop = new double[] { 1, 1, 2, 3, 3 }; + public static int[] soulBracket = new int[]{16, 60, 200, 400, 1000}; + public static double[] defaultDamageAdded = new double[]{0.25, 0.5, 0.75, 1, 1.25}; + public static float[] velocityAdded = new float[]{0.25f, 0.5f, 0.75f, 1, 1.25f}; + public static double[] soulDrainPerSwing = new double[]{0.05, 0.1, 0.2, 0.4, 0.75}; //TODO + public static double[] soulDrop = new double[]{2, 4, 7, 10, 13}; + public static double[] staticDrop = new double[]{1, 1, 2, 3, 3}; - public ItemSentientBow() - { + public ItemSentientBow() { super(); setUnlocalizedName(BloodMagic.MODID + ".sentientBow"); setCreativeTab(BloodMagic.TAB_BM); - this.addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter() - { + this.addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter() { @SideOnly(Side.CLIENT) - public float apply(ItemStack stack, World world, EntityLivingBase entityIn) - { - if (entityIn == null) - { + public float apply(ItemStack stack, World world, EntityLivingBase entityIn) { + if (entityIn == null) { return 0.0F; - } else - { + } else { ItemStack itemstack = entityIn.getActiveItemStack(); return !itemstack.isEmpty() && itemstack.getItem() == RegistrarBloodMagicItems.SENTIENT_BOW ? (float) (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F : 0.0F; } } }); - this.addPropertyOverride(new ResourceLocation("pulling"), new IItemPropertyGetter() - { + this.addPropertyOverride(new ResourceLocation("pulling"), new IItemPropertyGetter() { @SideOnly(Side.CLIENT) - public float apply(ItemStack stack, World world, EntityLivingBase entityIn) - { + public float apply(ItemStack stack, World world, EntityLivingBase entityIn) { return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F; } }); - this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() - { + this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { @SideOnly(Side.CLIENT) - public float apply(ItemStack stack, World world, EntityLivingBase entityIn) - { + public float apply(ItemStack stack, World world, EntityLivingBase entityIn) { return ((ItemSentientBow) RegistrarBloodMagicItems.SENTIENT_BOW).getCurrentType(stack).ordinal(); } }); } @Override - public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) - { + public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { return RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL == repair.getItem() || super.getIsRepairable(toRepair, repair); } - public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) - { + public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) { EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); recalculatePowers(stack, type, soulsRemaining); } - public void recalculatePowers(ItemStack stack, EnumDemonWillType type, double will) - { + public void recalculatePowers(ItemStack stack, EnumDemonWillType type, double will) { this.setCurrentType(stack, will > 0 ? type : EnumDemonWillType.DEFAULT); int level = getLevel(stack, will); // @@ -117,13 +105,10 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien setDamageAdded(stack, level >= 0 ? getDamageModifier(type, level) : 0); } - private int getLevel(ItemStack stack, double soulsRemaining) - { + private int getLevel(ItemStack stack, double soulsRemaining) { int lvl = -1; - for (int i = 0; i < soulBracket.length; i++) - { - if (soulsRemaining >= soulBracket[i]) - { + for (int i = 0; i < soulBracket.length; i++) { + if (soulsRemaining >= soulBracket[i]) { lvl = i; } } @@ -132,49 +117,42 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien } @Override - public EnumDemonWillType getCurrentType(ItemStack stack) - { + public EnumDemonWillType getCurrentType(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); - if (!tag.hasKey(Constants.NBT.WILL_TYPE)) - { + if (!tag.hasKey(Constants.NBT.WILL_TYPE)) { return EnumDemonWillType.DEFAULT; } return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH)); } - public double getDamageModifier(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case VENGEFUL: - return 0; - case DEFAULT: - case CORROSIVE: - case DESTRUCTIVE: - case STEADFAST: - return defaultDamageAdded[willBracket]; + public double getDamageModifier(EnumDemonWillType type, int willBracket) { + switch (type) { + case VENGEFUL: + return 0; + case DEFAULT: + case CORROSIVE: + case DESTRUCTIVE: + case STEADFAST: + return defaultDamageAdded[willBracket]; } return 0; } - public float getVelocityModifier(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case VENGEFUL: - return velocityAdded[willBracket]; - default: - return 0; + public float getVelocityModifier(EnumDemonWillType type, int willBracket) { + switch (type) { + case VENGEFUL: + return velocityAdded[willBracket]; + default: + return 0; } } - public void setDamageAdded(ItemStack stack, double damage) - { + public void setDamageAdded(ItemStack stack, double damage) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -182,8 +160,7 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien tag.setDouble("damage", damage); } - public double getDamageAdded(ItemStack stack) - { + public double getDamageAdded(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -191,8 +168,7 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien return tag.getDouble("damage"); } - public void setVelocityOfArrow(ItemStack stack, float velocity) - { + public void setVelocityOfArrow(ItemStack stack, float velocity) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -200,22 +176,19 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien tag.setFloat("velocity", velocity); } - public float getVelocityOfArrow(ItemStack stack) - { + public float getVelocityOfArrow(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); - if (tag.hasKey("velocity")) - { + if (tag.hasKey("velocity")) { return tag.getFloat("velocity"); } return 3; } - public void setCurrentType(ItemStack stack, EnumDemonWillType type) - { + public void setCurrentType(ItemStack stack, EnumDemonWillType type) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -223,16 +196,14 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien tag.setString(Constants.NBT.WILL_TYPE, type.toString()); } - public double getDrainOfActivatedBow(ItemStack stack) - { + public double getDrainOfActivatedBow(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN); } - public void setDrainOfActivatedBow(ItemStack stack, double drain) - { + public void setDrainOfActivatedBow(ItemStack stack, double drain) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -240,16 +211,14 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien tag.setDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN, drain); } - public double getStaticDropOfActivatedBow(ItemStack stack) - { + public double getStaticDropOfActivatedBow(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP); } - public void setStaticDropOfActivatedBow(ItemStack stack, double drop) - { + public void setStaticDropOfActivatedBow(ItemStack stack, double drop) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -257,16 +226,14 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien tag.setDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP, drop); } - public double getDropOfActivatedBow(ItemStack stack) - { + public double getDropOfActivatedBow(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_DROP); } - public void setDropOfActivatedBow(ItemStack stack, double drop) - { + public void setDropOfActivatedBow(ItemStack stack, double drop) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -275,15 +242,13 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); this.recalculatePowers(stack, world, player); return super.onItemRightClick(world, player, hand); } - public EntityTippedArrow getArrowEntity(World world, ItemStack stack, EntityLivingBase target, EntityLivingBase user, float velocity) - { + public EntityTippedArrow getArrowEntity(World world, ItemStack stack, EntityLivingBase target, EntityLivingBase user, float velocity) { EnumDemonWillType type = this.getCurrentType(stack); double amount = user instanceof EntityPlayer ? (this.getDropOfActivatedBow(stack) * world.rand.nextDouble() + this.getStaticDropOfActivatedBow(stack)) : 0; @@ -298,14 +263,12 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); entityArrow.setThrowableHeading(d0, d1 + d3 * 0.05, d2, newArrowVelocity, 0); - if (newArrowVelocity == 0) - { + if (newArrowVelocity == 0) { world.playSound(null, user.getPosition(), SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.NEUTRAL, 0.4F, 1.0F); return null; } - if (velocity == 1.0F) - { + if (velocity == 1.0F) { entityArrow.setIsCritical(true); } @@ -315,13 +278,11 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack); - if (k > 0) - { + if (k > 0) { entityArrow.setKnockbackStrength(k); } - if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) - { + if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) { entityArrow.setFire(100); } @@ -331,10 +292,8 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien } @Override - public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entityLiving, int timeLeft) - { - if (entityLiving instanceof EntityPlayer) - { + public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entityLiving, int timeLeft) { + if (entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entityLiving; boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0; ItemStack itemstack = this.getFiredArrow(player); @@ -344,21 +303,17 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien if (i < 0) return; - if (itemstack != null || flag) - { - if (itemstack == null) - { + if (itemstack != null || flag) { + if (itemstack == null) { itemstack = new ItemStack(Items.ARROW); } float arrowVelocity = getArrowVelocity(i); - if ((double) arrowVelocity >= 0.1D) - { + if ((double) arrowVelocity >= 0.1D) { boolean flag1 = flag && itemstack.getItem() == Items.ARROW; //Forge: Fix consuming custom arrows. - if (!world.isRemote) - { + if (!world.isRemote) { this.recalculatePowers(stack, world, player); EnumDemonWillType type = this.getCurrentType(stack); @@ -372,14 +327,12 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien EntitySentientArrow entityArrow = new EntitySentientArrow(world, entityLiving, type, amount); entityArrow.setAim(player, player.rotationPitch, player.rotationYaw, 0.0F, newArrowVelocity, 1.0F); - if (newArrowVelocity == 0) - { + if (newArrowVelocity == 0) { world.playSound(null, player.getPosition(), SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.NEUTRAL, 0.4F, 1.0F); return; } - if (arrowVelocity == 1.0F) - { + if (arrowVelocity == 1.0F) { entityArrow.setIsCritical(true); } @@ -389,20 +342,17 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack); - if (k > 0) - { + if (k > 0) { entityArrow.setKnockbackStrength(k); } - if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) - { + if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) { entityArrow.setFire(100); } stack.damageItem(1, player); - if (flag1) - { + if (flag1) { entityArrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY; } @@ -411,12 +361,10 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + arrowVelocity * 0.5F); - if (!flag1) - { + if (!flag1) { itemstack.shrink(1); - if (itemstack.isEmpty()) - { + if (itemstack.isEmpty()) { player.inventory.deleteStack(itemstack); } } @@ -427,22 +375,16 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien } } - protected ItemStack getFiredArrow(EntityPlayer player) - { - if (this.isArrow(player.getHeldItem(EnumHand.OFF_HAND))) - { + protected ItemStack getFiredArrow(EntityPlayer player) { + if (this.isArrow(player.getHeldItem(EnumHand.OFF_HAND))) { return player.getHeldItem(EnumHand.OFF_HAND); - } else if (this.isArrow(player.getHeldItem(EnumHand.MAIN_HAND))) - { + } else if (this.isArrow(player.getHeldItem(EnumHand.MAIN_HAND))) { return player.getHeldItem(EnumHand.MAIN_HAND); - } else - { - for (int i = 0; i < player.inventory.getSizeInventory(); ++i) - { + } else { + for (int i = 0; i < player.inventory.getSizeInventory(); ++i) { ItemStack itemstack = player.inventory.getStackInSlot(i); - if (this.isArrow(itemstack)) - { + if (this.isArrow(itemstack)) { return itemstack; } } @@ -452,17 +394,14 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien } @Override - public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) - { + public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) { World world = player.getEntityWorld(); - if (!world.isRemote) - { + if (!world.isRemote) { this.recalculatePowers(droppedStack, world, player); EnumDemonWillType type = this.getCurrentType(droppedStack); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); - if (soulsRemaining < 1024) - { + if (soulsRemaining < 1024) { return false; } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientPickaxe.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientPickaxe.java index 2904fa35..75e2ee13 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientPickaxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientPickaxe.java @@ -1,9 +1,22 @@ package WayofTime.bloodmagic.item.soul; -import java.util.*; - -import javax.annotation.Nullable; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.iface.IMultiWillTool; +import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider; +import WayofTime.bloodmagic.api.iface.ISentientTool; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.soul.IDemonWill; +import WayofTime.bloodmagic.api.soul.IDemonWillWeapon; +import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.client.IMeshProvider; +import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; +import WayofTime.bloodmagic.util.helper.TextHelper; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.util.ITooltipFlag; @@ -28,55 +41,38 @@ import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.iface.IMultiWillTool; -import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider; -import WayofTime.bloodmagic.api.iface.ISentientTool; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.soul.IDemonWill; -import WayofTime.bloodmagic.api.soul.IDemonWillWeapon; -import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.client.IMeshProvider; -import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill; -import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.util.helper.TextHelper; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; +import javax.annotation.Nullable; +import java.util.*; -public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool -{ - public static int[] soulBracket = new int[] { 16, 60, 200, 400, 1000 }; - public static double[] defaultDamageAdded = new double[] { 1, 2, 3, 3.5, 4 }; - public static double[] destructiveDamageAdded = new double[] { 2, 3, 4, 5, 6 }; - public static double[] vengefulDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2 }; - public static double[] steadfastDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2 }; - public static double[] defaultDigSpeedAdded = new double[] { 1, 1.5, 2, 3, 4 }; - public static double[] soulDrainPerSwing = new double[] { 0.05, 0.1, 0.2, 0.4, 0.75 }; - public static double[] soulDrop = new double[] { 2, 4, 7, 10, 13 }; - public static double[] staticDrop = new double[] { 1, 1, 2, 3, 3 }; +public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool { + public static int[] soulBracket = new int[]{16, 60, 200, 400, 1000}; + public static double[] defaultDamageAdded = new double[]{1, 2, 3, 3.5, 4}; + public static double[] destructiveDamageAdded = new double[]{2, 3, 4, 5, 6}; + public static double[] vengefulDamageAdded = new double[]{0, 0.5, 1, 1.5, 2}; + public static double[] steadfastDamageAdded = new double[]{0, 0.5, 1, 1.5, 2}; + public static double[] defaultDigSpeedAdded = new double[]{1, 1.5, 2, 3, 4}; + public static double[] soulDrainPerSwing = new double[]{0.05, 0.1, 0.2, 0.4, 0.75}; + public static double[] soulDrop = new double[]{2, 4, 7, 10, 13}; + public static double[] staticDrop = new double[]{1, 1, 2, 3, 3}; - public static double[] healthBonus = new double[] { 0, 0, 0, 0, 0 }; //TODO: Think of implementing this later - public static double[] vengefulAttackSpeed = new double[] { -3, -2.8, -2.7, -2.6, -2.5 }; - public static double[] destructiveAttackSpeed = new double[] { -3.1, -3.1, -3.2, -3.3, -3.3 }; + public static double[] healthBonus = new double[]{0, 0, 0, 0, 0}; //TODO: Think of implementing this later + public static double[] vengefulAttackSpeed = new double[]{-3, -2.8, -2.7, -2.6, -2.5}; + public static double[] destructiveAttackSpeed = new double[]{-3.1, -3.1, -3.2, -3.3, -3.3}; - public static int[] absorptionTime = new int[] { 200, 300, 400, 500, 600 }; + public static int[] absorptionTime = new int[]{200, 300, 400, 500, 600}; public static double maxAbsorptionHearts = 10; - public static int[] poisonTime = new int[] { 25, 50, 60, 80, 100 }; - public static int[] poisonLevel = new int[] { 0, 0, 0, 1, 1 }; + public static int[] poisonTime = new int[]{25, 50, 60, 80, 100}; + public static int[] poisonLevel = new int[]{0, 0, 0, 1, 1}; - public static double[] movementSpeed = new double[] { 0.05, 0.1, 0.15, 0.2, 0.25 }; + public static double[] movementSpeed = new double[]{0.05, 0.1, 0.15, 0.2, 0.25}; public final double baseAttackDamage = 3; public final double baseAttackSpeed = -2.8; - public ItemSentientPickaxe() - { + public ItemSentientPickaxe() { super(Item.ToolMaterial.IRON); setMaxDamage(getMaxDamage() * 2); // super(ModItems.soulToolMaterial); @@ -86,26 +82,21 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon } @Override - public float getStrVsBlock(ItemStack stack, IBlockState state) - { + public float getStrVsBlock(ItemStack stack, IBlockState state) { float value = super.getStrVsBlock(stack, state); - if (value > 1) - { + if (value > 1) { return (float) (value + getDigSpeedOfSword(stack)); - } else - { + } else { return value; } } @Override - public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) - { + public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { return RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL == repair.getItem() ? true : super.getIsRepairable(toRepair, repair); } - public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) - { + public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) { EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); this.setCurrentType(stack, soulsRemaining > 0 ? type : EnumDemonWillType.DEFAULT); @@ -124,106 +115,89 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon setDigSpeedOfSword(stack, level >= 0 ? getDigSpeed(type, level) : 0); } - public double getExtraDamage(EnumDemonWillType type, int willBracket) - { - if (willBracket < 0) - { + public double getExtraDamage(EnumDemonWillType type, int willBracket) { + if (willBracket < 0) { return 0; } - switch (type) - { - case CORROSIVE: - case DEFAULT: - return defaultDamageAdded[willBracket]; - case DESTRUCTIVE: - return destructiveDamageAdded[willBracket]; - case VENGEFUL: - return vengefulDamageAdded[willBracket]; - case STEADFAST: - return steadfastDamageAdded[willBracket]; + switch (type) { + case CORROSIVE: + case DEFAULT: + return defaultDamageAdded[willBracket]; + case DESTRUCTIVE: + return destructiveDamageAdded[willBracket]; + case VENGEFUL: + return vengefulDamageAdded[willBracket]; + case STEADFAST: + return steadfastDamageAdded[willBracket]; } return 0; } - public double getAttackSpeed(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case VENGEFUL: - return vengefulAttackSpeed[willBracket]; - case DESTRUCTIVE: - return destructiveAttackSpeed[willBracket]; - default: - return -2.9; + public double getAttackSpeed(EnumDemonWillType type, int willBracket) { + switch (type) { + case VENGEFUL: + return vengefulAttackSpeed[willBracket]; + case DESTRUCTIVE: + return destructiveAttackSpeed[willBracket]; + default: + return -2.9; } } - public double getHealthBonus(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case STEADFAST: - return healthBonus[willBracket]; - default: - return 0; + public double getHealthBonus(EnumDemonWillType type, int willBracket) { + switch (type) { + case STEADFAST: + return healthBonus[willBracket]; + default: + return 0; } } - public double getMovementSpeed(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case VENGEFUL: - return movementSpeed[willBracket]; - default: - return 0; + public double getMovementSpeed(EnumDemonWillType type, int willBracket) { + switch (type) { + case VENGEFUL: + return movementSpeed[willBracket]; + default: + return 0; } } - public double getDigSpeed(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case VENGEFUL: + public double getDigSpeed(EnumDemonWillType type, int willBracket) { + switch (type) { + case VENGEFUL: // return movementSpeed[willBracket]; - default: - return defaultDigSpeedAdded[willBracket]; + default: + return defaultDigSpeedAdded[willBracket]; } } - public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityPlayer attacker) - { - switch (type) - { - case CORROSIVE: - target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket])); - break; - case DEFAULT: - break; - case DESTRUCTIVE: - break; - case STEADFAST: - if (!target.isEntityAlive()) - { - float absorption = attacker.getAbsorptionAmount(); - attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127)); - attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts)); - } - break; - case VENGEFUL: - break; + public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityPlayer attacker) { + switch (type) { + case CORROSIVE: + target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket])); + break; + case DEFAULT: + break; + case DESTRUCTIVE: + break; + case STEADFAST: + if (!target.isEntityAlive()) { + float absorption = attacker.getAbsorptionAmount(); + attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127)); + attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts)); + } + break; + case VENGEFUL: + break; } } @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) - { - if (super.hitEntity(stack, target, attacker)) - { - if (attacker instanceof EntityPlayer) - { + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { + if (super.hitEntity(stack, target, attacker)) { + if (attacker instanceof EntityPlayer) { EntityPlayer attackerPlayer = (EntityPlayer) attacker; this.recalculatePowers(stack, attackerPlayer.getEntityWorld(), attackerPlayer); EnumDemonWillType type = this.getCurrentType(stack); @@ -233,11 +207,9 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon applyEffectToEntity(type, willBracket, target, attackerPlayer); ItemStack offStack = attackerPlayer.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND); - if (offStack.getItem() instanceof ISentientSwordEffectProvider) - { + if (offStack.getItem() instanceof ISentientSwordEffectProvider) { ISentientSwordEffectProvider provider = (ISentientSwordEffectProvider) offStack.getItem(); - if (provider.providesEffectForWill(type)) - { + if (provider.providesEffectForWill(type)) { provider.applyOnHitEffect(type, stack, offStack, attacker, target); } } @@ -250,22 +222,19 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon } @Override - public EnumDemonWillType getCurrentType(ItemStack stack) - { + public EnumDemonWillType getCurrentType(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); - if (!tag.hasKey(Constants.NBT.WILL_TYPE)) - { + if (!tag.hasKey(Constants.NBT.WILL_TYPE)) { return EnumDemonWillType.DEFAULT; } return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH)); } - public void setCurrentType(ItemStack stack, EnumDemonWillType type) - { + public void setCurrentType(ItemStack stack, EnumDemonWillType type) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -274,25 +243,20 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { recalculatePowers(player.getHeldItem(hand), world, player); return super.onItemRightClick(world, player, hand); } @Override - public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) - { + public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { return oldStack.getItem() != newStack.getItem(); } - private int getLevel(ItemStack stack, double soulsRemaining) - { + private int getLevel(ItemStack stack, double soulsRemaining) { int lvl = -1; - for (int i = 0; i < soulBracket.length; i++) - { - if (soulsRemaining >= soulBracket[i]) - { + for (int i = 0; i < soulBracket.length; i++) { + if (soulsRemaining >= soulBracket[i]) { lvl = i; } } @@ -302,8 +266,7 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; @@ -312,21 +275,17 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon } @Override - public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) - { + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { recalculatePowers(stack, player.getEntityWorld(), player); double drain = this.getDrainOfActivatedSword(stack); - if (drain > 0) - { + if (drain > 0) { EnumDemonWillType type = getCurrentType(stack); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); - if (drain > soulsRemaining) - { + if (drain > soulsRemaining) { return false; - } else - { + } else { PlayerDemonWillHandler.consumeDemonWill(type, player, drain); } } @@ -336,24 +295,20 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon @Override @SideOnly(Side.CLIENT) - public ItemMeshDefinition getMeshDefinition() - { + public ItemMeshDefinition getMeshDefinition() { return new CustomMeshDefinitionMultiWill("ItemSentientPickaxe"); } @Nullable @Override - public ResourceLocation getCustomLocation() - { + public ResourceLocation getCustomLocation() { return null; } @Override - public List getVariants() - { + public List getVariants() { List ret = new ArrayList(); - for (EnumDemonWillType type : EnumDemonWillType.values()) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { ret.add("type=" + type.getName().toLowerCase()); } @@ -361,12 +316,10 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon } @Override - public List getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) - { + public List getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) { List soulList = new ArrayList(); - if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) - { + if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) { return soulList; } @@ -376,10 +329,8 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon EnumDemonWillType type = this.getCurrentType(stack); - for (int i = 0; i <= looting; i++) - { - if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) - { + for (int i = 0; i <= looting; i++) { + if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) { ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); soulList.add(soulStack); } @@ -390,11 +341,9 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon //TODO: Change attack speed. @Override - public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) - { + public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { Multimap multimap = HashMultimap.create(); - if (slot == EntityEquipmentSlot.MAINHAND) - { + if (slot == EntityEquipmentSlot.MAINHAND) { multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0)); multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0)); multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0)); @@ -404,16 +353,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon return multimap; } - public double getDamageOfActivatedSword(ItemStack stack) - { + public double getDamageOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_DAMAGE); } - public void setDamageOfActivatedSword(ItemStack stack, double damage) - { + public void setDamageOfActivatedSword(ItemStack stack, double damage) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -421,16 +368,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon tag.setDouble(Constants.NBT.SOUL_SWORD_DAMAGE, damage); } - public double getDrainOfActivatedSword(ItemStack stack) - { + public double getDrainOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN); } - public void setDrainOfActivatedSword(ItemStack stack, double drain) - { + public void setDrainOfActivatedSword(ItemStack stack, double drain) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -438,16 +383,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon tag.setDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN, drain); } - public double getStaticDropOfActivatedSword(ItemStack stack) - { + public double getStaticDropOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP); } - public void setStaticDropOfActivatedSword(ItemStack stack, double drop) - { + public void setStaticDropOfActivatedSword(ItemStack stack, double drop) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -455,16 +398,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon tag.setDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP, drop); } - public double getDropOfActivatedSword(ItemStack stack) - { + public double getDropOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_DROP); } - public void setDropOfActivatedSword(ItemStack stack, double drop) - { + public void setDropOfActivatedSword(ItemStack stack, double drop) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -472,16 +413,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon tag.setDouble(Constants.NBT.SOUL_SWORD_DROP, drop); } - public double getHealthBonusOfSword(ItemStack stack) - { + public double getHealthBonusOfSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH); } - public void setHealthBonusOfSword(ItemStack stack, double hp) - { + public void setHealthBonusOfSword(ItemStack stack, double hp) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -489,16 +428,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon tag.setDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp); } - public double getAttackSpeedOfSword(ItemStack stack) - { + public double getAttackSpeedOfSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED); } - public void setAttackSpeedOfSword(ItemStack stack, double speed) - { + public void setAttackSpeedOfSword(ItemStack stack, double speed) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -506,16 +443,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon tag.setDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED, speed); } - public double getSpeedOfSword(ItemStack stack) - { + public double getSpeedOfSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_SPEED); } - public void setSpeedOfSword(ItemStack stack, double speed) - { + public void setSpeedOfSword(ItemStack stack, double speed) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -523,16 +458,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon tag.setDouble(Constants.NBT.SOUL_SWORD_SPEED, speed); } - public double getDigSpeedOfSword(ItemStack stack) - { + public double getDigSpeedOfSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_DIG_SPEED); } - public void setDigSpeedOfSword(ItemStack stack, double speed) - { + public void setDigSpeedOfSword(ItemStack stack, double speed) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -541,17 +474,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon } @Override - public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) - { + public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) { World world = player.getEntityWorld(); - if (!world.isRemote) - { + if (!world.isRemote) { this.recalculatePowers(droppedStack, world, player); EnumDemonWillType type = this.getCurrentType(droppedStack); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); - if (soulsRemaining < 1024) - { + if (soulsRemaining < 1024) { return false; } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientShovel.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientShovel.java index 4c140cb8..6a99d001 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientShovel.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientShovel.java @@ -1,9 +1,22 @@ package WayofTime.bloodmagic.item.soul; -import java.util.*; - -import javax.annotation.Nullable; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.iface.IMultiWillTool; +import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider; +import WayofTime.bloodmagic.api.iface.ISentientTool; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.soul.IDemonWill; +import WayofTime.bloodmagic.api.soul.IDemonWillWeapon; +import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.client.IMeshProvider; +import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; +import WayofTime.bloodmagic.util.helper.TextHelper; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.util.ITooltipFlag; @@ -28,55 +41,38 @@ import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.iface.IMultiWillTool; -import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider; -import WayofTime.bloodmagic.api.iface.ISentientTool; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.soul.IDemonWill; -import WayofTime.bloodmagic.api.soul.IDemonWillWeapon; -import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.client.IMeshProvider; -import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill; -import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.util.helper.TextHelper; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; +import javax.annotation.Nullable; +import java.util.*; -public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool -{ - public static int[] soulBracket = new int[] { 16, 60, 200, 400, 1000 }; - public static double[] defaultDamageAdded = new double[] { 1, 2, 3, 3.5, 4 }; - public static double[] destructiveDamageAdded = new double[] { 2, 3, 4, 5, 6 }; - public static double[] vengefulDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2 }; - public static double[] steadfastDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2 }; - public static double[] defaultDigSpeedAdded = new double[] { 1, 1.5, 2, 3, 4 }; - public static double[] soulDrainPerSwing = new double[] { 0.05, 0.1, 0.2, 0.4, 0.75 }; - public static double[] soulDrop = new double[] { 2, 4, 7, 10, 13 }; - public static double[] staticDrop = new double[] { 1, 1, 2, 3, 3 }; +public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool { + public static int[] soulBracket = new int[]{16, 60, 200, 400, 1000}; + public static double[] defaultDamageAdded = new double[]{1, 2, 3, 3.5, 4}; + public static double[] destructiveDamageAdded = new double[]{2, 3, 4, 5, 6}; + public static double[] vengefulDamageAdded = new double[]{0, 0.5, 1, 1.5, 2}; + public static double[] steadfastDamageAdded = new double[]{0, 0.5, 1, 1.5, 2}; + public static double[] defaultDigSpeedAdded = new double[]{1, 1.5, 2, 3, 4}; + public static double[] soulDrainPerSwing = new double[]{0.05, 0.1, 0.2, 0.4, 0.75}; + public static double[] soulDrop = new double[]{2, 4, 7, 10, 13}; + public static double[] staticDrop = new double[]{1, 1, 2, 3, 3}; - public static double[] healthBonus = new double[] { 0, 0, 0, 0, 0 }; //TODO: Think of implementing this later - public static double[] vengefulAttackSpeed = new double[] { -3, -2.8, -2.7, -2.6, -2.5 }; - public static double[] destructiveAttackSpeed = new double[] { -3.1, -3.1, -3.2, -3.3, -3.3 }; + public static double[] healthBonus = new double[]{0, 0, 0, 0, 0}; //TODO: Think of implementing this later + public static double[] vengefulAttackSpeed = new double[]{-3, -2.8, -2.7, -2.6, -2.5}; + public static double[] destructiveAttackSpeed = new double[]{-3.1, -3.1, -3.2, -3.3, -3.3}; - public static int[] absorptionTime = new int[] { 200, 300, 400, 500, 600 }; + public static int[] absorptionTime = new int[]{200, 300, 400, 500, 600}; public static double maxAbsorptionHearts = 10; - public static int[] poisonTime = new int[] { 25, 50, 60, 80, 100 }; - public static int[] poisonLevel = new int[] { 0, 0, 0, 1, 1 }; + public static int[] poisonTime = new int[]{25, 50, 60, 80, 100}; + public static int[] poisonLevel = new int[]{0, 0, 0, 1, 1}; - public static double[] movementSpeed = new double[] { 0.05, 0.1, 0.15, 0.2, 0.25 }; + public static double[] movementSpeed = new double[]{0.05, 0.1, 0.15, 0.2, 0.25}; public final double baseAttackDamage = 3; public final double baseAttackSpeed = -2.8; - public ItemSentientShovel() - { + public ItemSentientShovel() { super(Item.ToolMaterial.IRON); setMaxDamage(getMaxDamage() * 2); // super(ModItems.soulToolMaterial); @@ -86,26 +82,21 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I } @Override - public float getStrVsBlock(ItemStack stack, IBlockState state) - { + public float getStrVsBlock(ItemStack stack, IBlockState state) { float value = super.getStrVsBlock(stack, state); - if (value > 1) - { + if (value > 1) { return (float) (value + getDigSpeedOfSword(stack)); - } else - { + } else { return value; } } @Override - public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) - { + public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { return RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL == repair.getItem() || super.getIsRepairable(toRepair, repair); } - public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) - { + public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) { EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); this.setCurrentType(stack, soulsRemaining > 0 ? type : EnumDemonWillType.DEFAULT); @@ -124,106 +115,89 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I setDigSpeedOfSword(stack, level >= 0 ? getDigSpeed(type, level) : 0); } - public double getExtraDamage(EnumDemonWillType type, int willBracket) - { - if (willBracket < 0) - { + public double getExtraDamage(EnumDemonWillType type, int willBracket) { + if (willBracket < 0) { return 0; } - switch (type) - { - case CORROSIVE: - case DEFAULT: - return defaultDamageAdded[willBracket]; - case DESTRUCTIVE: - return destructiveDamageAdded[willBracket]; - case VENGEFUL: - return vengefulDamageAdded[willBracket]; - case STEADFAST: - return steadfastDamageAdded[willBracket]; + switch (type) { + case CORROSIVE: + case DEFAULT: + return defaultDamageAdded[willBracket]; + case DESTRUCTIVE: + return destructiveDamageAdded[willBracket]; + case VENGEFUL: + return vengefulDamageAdded[willBracket]; + case STEADFAST: + return steadfastDamageAdded[willBracket]; } return 0; } - public double getAttackSpeed(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case VENGEFUL: - return vengefulAttackSpeed[willBracket]; - case DESTRUCTIVE: - return destructiveAttackSpeed[willBracket]; - default: - return -2.9; + public double getAttackSpeed(EnumDemonWillType type, int willBracket) { + switch (type) { + case VENGEFUL: + return vengefulAttackSpeed[willBracket]; + case DESTRUCTIVE: + return destructiveAttackSpeed[willBracket]; + default: + return -2.9; } } - public double getHealthBonus(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case STEADFAST: - return healthBonus[willBracket]; - default: - return 0; + public double getHealthBonus(EnumDemonWillType type, int willBracket) { + switch (type) { + case STEADFAST: + return healthBonus[willBracket]; + default: + return 0; } } - public double getMovementSpeed(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case VENGEFUL: - return movementSpeed[willBracket]; - default: - return 0; + public double getMovementSpeed(EnumDemonWillType type, int willBracket) { + switch (type) { + case VENGEFUL: + return movementSpeed[willBracket]; + default: + return 0; } } - public double getDigSpeed(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case VENGEFUL: + public double getDigSpeed(EnumDemonWillType type, int willBracket) { + switch (type) { + case VENGEFUL: // return movementSpeed[willBracket]; - default: - return defaultDigSpeedAdded[willBracket]; + default: + return defaultDigSpeedAdded[willBracket]; } } - public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityPlayer attacker) - { - switch (type) - { - case CORROSIVE: - target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket])); - break; - case DEFAULT: - break; - case DESTRUCTIVE: - break; - case STEADFAST: - if (!target.isEntityAlive()) - { - float absorption = attacker.getAbsorptionAmount(); - attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127)); - attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts)); - } - break; - case VENGEFUL: - break; + public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityPlayer attacker) { + switch (type) { + case CORROSIVE: + target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket])); + break; + case DEFAULT: + break; + case DESTRUCTIVE: + break; + case STEADFAST: + if (!target.isEntityAlive()) { + float absorption = attacker.getAbsorptionAmount(); + attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127)); + attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts)); + } + break; + case VENGEFUL: + break; } } @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) - { - if (super.hitEntity(stack, target, attacker)) - { - if (attacker instanceof EntityPlayer) - { + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { + if (super.hitEntity(stack, target, attacker)) { + if (attacker instanceof EntityPlayer) { EntityPlayer attackerPlayer = (EntityPlayer) attacker; this.recalculatePowers(stack, attackerPlayer.getEntityWorld(), attackerPlayer); EnumDemonWillType type = this.getCurrentType(stack); @@ -233,11 +207,9 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I applyEffectToEntity(type, willBracket, target, attackerPlayer); ItemStack offStack = attackerPlayer.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND); - if (offStack.getItem() instanceof ISentientSwordEffectProvider) - { + if (offStack.getItem() instanceof ISentientSwordEffectProvider) { ISentientSwordEffectProvider provider = (ISentientSwordEffectProvider) offStack.getItem(); - if (provider.providesEffectForWill(type)) - { + if (provider.providesEffectForWill(type)) { provider.applyOnHitEffect(type, stack, offStack, attacker, target); } } @@ -250,22 +222,19 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I } @Override - public EnumDemonWillType getCurrentType(ItemStack stack) - { + public EnumDemonWillType getCurrentType(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); - if (!tag.hasKey(Constants.NBT.WILL_TYPE)) - { + if (!tag.hasKey(Constants.NBT.WILL_TYPE)) { return EnumDemonWillType.DEFAULT; } return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH)); } - public void setCurrentType(ItemStack stack, EnumDemonWillType type) - { + public void setCurrentType(ItemStack stack, EnumDemonWillType type) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -274,26 +243,21 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { recalculatePowers(player.getHeldItem(hand), world, player); return super.onItemRightClick(world, player, hand); } @Override - public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) - { + public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { return oldStack.getItem() != newStack.getItem(); } - private int getLevel(ItemStack stack, double soulsRemaining) - { + private int getLevel(ItemStack stack, double soulsRemaining) { int lvl = -1; - for (int i = 0; i < soulBracket.length; i++) - { - if (soulsRemaining >= soulBracket[i]) - { + for (int i = 0; i < soulBracket.length; i++) { + if (soulsRemaining >= soulBracket[i]) { lvl = i; } } @@ -303,8 +267,7 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; @@ -313,21 +276,17 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I } @Override - public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) - { + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { recalculatePowers(stack, player.getEntityWorld(), player); double drain = this.getDrainOfActivatedSword(stack); - if (drain > 0) - { + if (drain > 0) { EnumDemonWillType type = getCurrentType(stack); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); - if (drain > soulsRemaining) - { + if (drain > soulsRemaining) { return false; - } else - { + } else { PlayerDemonWillHandler.consumeDemonWill(type, player, drain); } } @@ -337,24 +296,20 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I @Override @SideOnly(Side.CLIENT) - public ItemMeshDefinition getMeshDefinition() - { + public ItemMeshDefinition getMeshDefinition() { return new CustomMeshDefinitionMultiWill("ItemSentientShovel"); } @Nullable @Override - public ResourceLocation getCustomLocation() - { + public ResourceLocation getCustomLocation() { return null; } @Override - public List getVariants() - { + public List getVariants() { List ret = new ArrayList(); - for (EnumDemonWillType type : EnumDemonWillType.values()) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { ret.add("type=" + type.getName().toLowerCase()); } @@ -362,12 +317,10 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I } @Override - public List getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) - { + public List getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) { List soulList = new ArrayList(); - if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) - { + if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) { return soulList; } @@ -377,10 +330,8 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I EnumDemonWillType type = this.getCurrentType(stack); - for (int i = 0; i <= looting; i++) - { - if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) - { + for (int i = 0; i <= looting; i++) { + if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) { ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); soulList.add(soulStack); } @@ -391,11 +342,9 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I //TODO: Change attack speed. @Override - public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) - { + public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { Multimap multimap = HashMultimap.create(); - if (slot == EntityEquipmentSlot.MAINHAND) - { + if (slot == EntityEquipmentSlot.MAINHAND) { multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0)); multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0)); multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0)); @@ -405,16 +354,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I return multimap; } - public double getDamageOfActivatedSword(ItemStack stack) - { + public double getDamageOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_DAMAGE); } - public void setDamageOfActivatedSword(ItemStack stack, double damage) - { + public void setDamageOfActivatedSword(ItemStack stack, double damage) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -422,16 +369,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I tag.setDouble(Constants.NBT.SOUL_SWORD_DAMAGE, damage); } - public double getDrainOfActivatedSword(ItemStack stack) - { + public double getDrainOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN); } - public void setDrainOfActivatedSword(ItemStack stack, double drain) - { + public void setDrainOfActivatedSword(ItemStack stack, double drain) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -439,16 +384,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I tag.setDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN, drain); } - public double getStaticDropOfActivatedSword(ItemStack stack) - { + public double getStaticDropOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP); } - public void setStaticDropOfActivatedSword(ItemStack stack, double drop) - { + public void setStaticDropOfActivatedSword(ItemStack stack, double drop) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -456,16 +399,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I tag.setDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP, drop); } - public double getDropOfActivatedSword(ItemStack stack) - { + public double getDropOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_DROP); } - public void setDropOfActivatedSword(ItemStack stack, double drop) - { + public void setDropOfActivatedSword(ItemStack stack, double drop) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -473,16 +414,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I tag.setDouble(Constants.NBT.SOUL_SWORD_DROP, drop); } - public double getHealthBonusOfSword(ItemStack stack) - { + public double getHealthBonusOfSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH); } - public void setHealthBonusOfSword(ItemStack stack, double hp) - { + public void setHealthBonusOfSword(ItemStack stack, double hp) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -490,16 +429,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I tag.setDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp); } - public double getAttackSpeedOfSword(ItemStack stack) - { + public double getAttackSpeedOfSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED); } - public void setAttackSpeedOfSword(ItemStack stack, double speed) - { + public void setAttackSpeedOfSword(ItemStack stack, double speed) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -507,16 +444,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I tag.setDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED, speed); } - public double getSpeedOfSword(ItemStack stack) - { + public double getSpeedOfSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_SPEED); } - public void setSpeedOfSword(ItemStack stack, double speed) - { + public void setSpeedOfSword(ItemStack stack, double speed) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -524,16 +459,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I tag.setDouble(Constants.NBT.SOUL_SWORD_SPEED, speed); } - public double getDigSpeedOfSword(ItemStack stack) - { + public double getDigSpeedOfSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_DIG_SPEED); } - public void setDigSpeedOfSword(ItemStack stack, double speed) - { + public void setDigSpeedOfSword(ItemStack stack, double speed) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -542,17 +475,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I } @Override - public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) - { + public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) { World world = player.getEntityWorld(); - if (!world.isRemote) - { + if (!world.isRemote) { this.recalculatePowers(droppedStack, world, player); EnumDemonWillType type = this.getCurrentType(droppedStack); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); - if (soulsRemaining < 1024) - { + if (soulsRemaining < 1024) { return false; } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java index 80fc39ca..63f6f0bd 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java @@ -1,9 +1,22 @@ package WayofTime.bloodmagic.item.soul; -import java.util.*; - -import javax.annotation.Nullable; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.iface.IMultiWillTool; +import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider; +import WayofTime.bloodmagic.api.iface.ISentientTool; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.soul.IDemonWill; +import WayofTime.bloodmagic.api.soul.IDemonWillWeapon; +import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.client.IMeshProvider; +import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; +import WayofTime.bloodmagic.util.helper.TextHelper; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.Entity; @@ -26,51 +39,34 @@ import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.iface.IMultiWillTool; -import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider; -import WayofTime.bloodmagic.api.iface.ISentientTool; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.soul.IDemonWill; -import WayofTime.bloodmagic.api.soul.IDemonWillWeapon; -import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.client.IMeshProvider; -import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill; -import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.util.helper.TextHelper; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; +import javax.annotation.Nullable; +import java.util.*; -public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool -{ - public static int[] soulBracket = new int[] { 16, 60, 200, 400, 1000, 2000, 4000 }; - public static double[] defaultDamageAdded = new double[] { 1, 1.5, 2, 2.5, 3, 3.5, 4 }; - public static double[] destructiveDamageAdded = new double[] { 1.5, 2.25, 3, 3.75, 4.5, 5.25, 6 }; - public static double[] vengefulDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2, 2.25, 2.5 }; - public static double[] steadfastDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2, 2.25, 2.5 }; - public static double[] soulDrainPerSwing = new double[] { 0.05, 0.1, 0.2, 0.4, 0.75, 1, 1.25 }; - public static double[] soulDrop = new double[] { 2, 4, 7, 10, 13, 15, 18 }; - public static double[] staticDrop = new double[] { 1, 1, 2, 3, 3, 4, 4 }; +public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool { + public static int[] soulBracket = new int[]{16, 60, 200, 400, 1000, 2000, 4000}; + public static double[] defaultDamageAdded = new double[]{1, 1.5, 2, 2.5, 3, 3.5, 4}; + public static double[] destructiveDamageAdded = new double[]{1.5, 2.25, 3, 3.75, 4.5, 5.25, 6}; + public static double[] vengefulDamageAdded = new double[]{0, 0.5, 1, 1.5, 2, 2.25, 2.5}; + public static double[] steadfastDamageAdded = new double[]{0, 0.5, 1, 1.5, 2, 2.25, 2.5}; + public static double[] soulDrainPerSwing = new double[]{0.05, 0.1, 0.2, 0.4, 0.75, 1, 1.25}; + public static double[] soulDrop = new double[]{2, 4, 7, 10, 13, 15, 18}; + public static double[] staticDrop = new double[]{1, 1, 2, 3, 3, 4, 4}; - public static double[] healthBonus = new double[] { 0, 0, 0, 0, 0, 0, 0 }; //TODO: Think of implementing this later - public static double[] vengefulAttackSpeed = new double[] { -2.1, -2, -1.8, -1.7, -1.6, -1.6, -1.5 }; - public static double[] destructiveAttackSpeed = new double[] { -2.6, -2.7, -2.8, -2.9, -3, -3, -3 }; + public static double[] healthBonus = new double[]{0, 0, 0, 0, 0, 0, 0}; //TODO: Think of implementing this later + public static double[] vengefulAttackSpeed = new double[]{-2.1, -2, -1.8, -1.7, -1.6, -1.6, -1.5}; + public static double[] destructiveAttackSpeed = new double[]{-2.6, -2.7, -2.8, -2.9, -3, -3, -3}; - public static int[] absorptionTime = new int[] { 200, 300, 400, 500, 600, 700, 800 }; + public static int[] absorptionTime = new int[]{200, 300, 400, 500, 600, 700, 800}; public static double maxAbsorptionHearts = 10; - public static int[] poisonTime = new int[] { 25, 50, 60, 80, 100, 120, 150 }; - public static int[] poisonLevel = new int[] { 0, 0, 0, 1, 1, 1, 1 }; + public static int[] poisonTime = new int[]{25, 50, 60, 80, 100, 120, 150}; + public static int[] poisonLevel = new int[]{0, 0, 0, 1, 1, 1, 1}; - public static double[] movementSpeed = new double[] { 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4 }; + public static double[] movementSpeed = new double[]{0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4}; - public ItemSentientSword() - { + public ItemSentientSword() { super(RegistrarBloodMagicItems.SOUL_TOOL_MATERIAL); setUnlocalizedName(BloodMagic.MODID + ".sentientSword"); @@ -78,20 +74,17 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM } @Override - public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) - { + public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { return RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL == repair.getItem() || super.getIsRepairable(toRepair, repair); } - public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) - { + public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) { EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); recalculatePowers(stack, type, soulsRemaining); } - public void recalculatePowers(ItemStack stack, EnumDemonWillType type, double will) - { + public void recalculatePowers(ItemStack stack, EnumDemonWillType type, double will) { this.setCurrentType(stack, will > 0 ? type : EnumDemonWillType.DEFAULT); int level = getLevel(stack, will); @@ -107,95 +100,80 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM setSpeedOfSword(stack, level >= 0 ? getMovementSpeed(type, level) : 0); } - public double getExtraDamage(EnumDemonWillType type, int willBracket) - { - if (willBracket < 0) - { + public double getExtraDamage(EnumDemonWillType type, int willBracket) { + if (willBracket < 0) { return 0; } - switch (type) - { - case CORROSIVE: - case DEFAULT: - return defaultDamageAdded[willBracket]; - case DESTRUCTIVE: - return destructiveDamageAdded[willBracket]; - case VENGEFUL: - return vengefulDamageAdded[willBracket]; - case STEADFAST: - return steadfastDamageAdded[willBracket]; + switch (type) { + case CORROSIVE: + case DEFAULT: + return defaultDamageAdded[willBracket]; + case DESTRUCTIVE: + return destructiveDamageAdded[willBracket]; + case VENGEFUL: + return vengefulDamageAdded[willBracket]; + case STEADFAST: + return steadfastDamageAdded[willBracket]; } return 0; } - public double getAttackSpeed(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case VENGEFUL: - return vengefulAttackSpeed[willBracket]; - case DESTRUCTIVE: - return destructiveAttackSpeed[willBracket]; - default: - return -2.4; + public double getAttackSpeed(EnumDemonWillType type, int willBracket) { + switch (type) { + case VENGEFUL: + return vengefulAttackSpeed[willBracket]; + case DESTRUCTIVE: + return destructiveAttackSpeed[willBracket]; + default: + return -2.4; } } - public double getHealthBonus(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case STEADFAST: - return healthBonus[willBracket]; - default: - return 0; + public double getHealthBonus(EnumDemonWillType type, int willBracket) { + switch (type) { + case STEADFAST: + return healthBonus[willBracket]; + default: + return 0; } } - public double getMovementSpeed(EnumDemonWillType type, int willBracket) - { - switch (type) - { - case VENGEFUL: - return movementSpeed[willBracket]; - default: - return 0; + public double getMovementSpeed(EnumDemonWillType type, int willBracket) { + switch (type) { + case VENGEFUL: + return movementSpeed[willBracket]; + default: + return 0; } } - public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityLivingBase attacker) - { - switch (type) - { - case CORROSIVE: - target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket])); - break; - case DEFAULT: - break; - case DESTRUCTIVE: - break; - case STEADFAST: - if (!target.isEntityAlive()) - { - float absorption = attacker.getAbsorptionAmount(); - attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127)); - attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts)); - } - break; - case VENGEFUL: - break; + public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityLivingBase attacker) { + switch (type) { + case CORROSIVE: + target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket])); + break; + case DEFAULT: + break; + case DESTRUCTIVE: + break; + case STEADFAST: + if (!target.isEntityAlive()) { + float absorption = attacker.getAbsorptionAmount(); + attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127)); + attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts)); + } + break; + case VENGEFUL: + break; } } @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) - { - if (super.hitEntity(stack, target, attacker)) - { - if (attacker instanceof EntityPlayer) - { + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { + if (super.hitEntity(stack, target, attacker)) { + if (attacker instanceof EntityPlayer) { EntityPlayer attackerPlayer = (EntityPlayer) attacker; this.recalculatePowers(stack, attackerPlayer.getEntityWorld(), attackerPlayer); EnumDemonWillType type = this.getCurrentType(stack); @@ -205,11 +183,9 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM applyEffectToEntity(type, willBracket, target, attackerPlayer); ItemStack offStack = attackerPlayer.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND); - if (offStack.getItem() instanceof ISentientSwordEffectProvider) - { + if (offStack.getItem() instanceof ISentientSwordEffectProvider) { ISentientSwordEffectProvider provider = (ISentientSwordEffectProvider) offStack.getItem(); - if (provider.providesEffectForWill(type)) - { + if (provider.providesEffectForWill(type)) { provider.applyOnHitEffect(type, stack, offStack, attacker, target); } } @@ -222,22 +198,19 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM } @Override - public EnumDemonWillType getCurrentType(ItemStack stack) - { + public EnumDemonWillType getCurrentType(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); - if (!tag.hasKey(Constants.NBT.WILL_TYPE)) - { + if (!tag.hasKey(Constants.NBT.WILL_TYPE)) { return EnumDemonWillType.DEFAULT; } return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH)); } - public void setCurrentType(ItemStack stack, EnumDemonWillType type) - { + public void setCurrentType(ItemStack stack, EnumDemonWillType type) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -246,25 +219,20 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { recalculatePowers(player.getHeldItem(hand), world, player); return super.onItemRightClick(world, player, hand); } @Override - public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) - { + public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { return oldStack.getItem() != newStack.getItem(); } - private int getLevel(ItemStack stack, double soulsRemaining) - { + private int getLevel(ItemStack stack, double soulsRemaining) { int lvl = -1; - for (int i = 0; i < soulBracket.length; i++) - { - if (soulsRemaining >= soulBracket[i]) - { + for (int i = 0; i < soulBracket.length; i++) { + if (soulsRemaining >= soulBracket[i]) { lvl = i; } } @@ -274,8 +242,7 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; @@ -284,21 +251,17 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM } @Override - public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) - { + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { recalculatePowers(stack, player.getEntityWorld(), player); double drain = this.getDrainOfActivatedSword(stack); - if (drain > 0) - { + if (drain > 0) { EnumDemonWillType type = getCurrentType(stack); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); - if (drain > soulsRemaining) - { + if (drain > soulsRemaining) { return false; - } else - { + } else { PlayerDemonWillHandler.consumeDemonWill(type, player, drain); } } @@ -308,24 +271,20 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM @Override @SideOnly(Side.CLIENT) - public ItemMeshDefinition getMeshDefinition() - { + public ItemMeshDefinition getMeshDefinition() { return new CustomMeshDefinitionMultiWill("ItemSentientSword"); } @Nullable @Override - public ResourceLocation getCustomLocation() - { + public ResourceLocation getCustomLocation() { return null; } @Override - public List getVariants() - { + public List getVariants() { List ret = new ArrayList(); - for (EnumDemonWillType type : EnumDemonWillType.values()) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { ret.add("type=" + type.getName().toLowerCase()); } @@ -333,12 +292,10 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM } @Override - public List getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) - { + public List getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) { List soulList = new ArrayList(); - if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) - { + if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) { return soulList; } @@ -348,10 +305,8 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM EnumDemonWillType type = this.getCurrentType(stack); - for (int i = 0; i <= looting; i++) - { - if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) - { + for (int i = 0; i <= looting; i++) { + if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) { ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); soulList.add(soulStack); } @@ -362,11 +317,9 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM //TODO: Change attack speed. @Override - public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) - { + public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { Multimap multimap = HashMultimap.create(); - if (slot == EntityEquipmentSlot.MAINHAND) - { + if (slot == EntityEquipmentSlot.MAINHAND) { multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0)); multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0)); multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0)); @@ -376,16 +329,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM return multimap; } - public double getDamageOfActivatedSword(ItemStack stack) - { + public double getDamageOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_DAMAGE); } - public void setDamageOfActivatedSword(ItemStack stack, double damage) - { + public void setDamageOfActivatedSword(ItemStack stack, double damage) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -393,16 +344,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM tag.setDouble(Constants.NBT.SOUL_SWORD_DAMAGE, damage); } - public double getDrainOfActivatedSword(ItemStack stack) - { + public double getDrainOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN); } - public void setDrainOfActivatedSword(ItemStack stack, double drain) - { + public void setDrainOfActivatedSword(ItemStack stack, double drain) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -410,16 +359,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM tag.setDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN, drain); } - public double getStaticDropOfActivatedSword(ItemStack stack) - { + public double getStaticDropOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP); } - public void setStaticDropOfActivatedSword(ItemStack stack, double drop) - { + public void setStaticDropOfActivatedSword(ItemStack stack, double drop) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -427,16 +374,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM tag.setDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP, drop); } - public double getDropOfActivatedSword(ItemStack stack) - { + public double getDropOfActivatedSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_DROP); } - public void setDropOfActivatedSword(ItemStack stack, double drop) - { + public void setDropOfActivatedSword(ItemStack stack, double drop) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -444,16 +389,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM tag.setDouble(Constants.NBT.SOUL_SWORD_DROP, drop); } - public double getHealthBonusOfSword(ItemStack stack) - { + public double getHealthBonusOfSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH); } - public void setHealthBonusOfSword(ItemStack stack, double hp) - { + public void setHealthBonusOfSword(ItemStack stack, double hp) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -461,16 +404,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM tag.setDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp); } - public double getAttackSpeedOfSword(ItemStack stack) - { + public double getAttackSpeedOfSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED); } - public void setAttackSpeedOfSword(ItemStack stack, double speed) - { + public void setAttackSpeedOfSword(ItemStack stack, double speed) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -478,16 +419,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM tag.setDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED, speed); } - public double getSpeedOfSword(ItemStack stack) - { + public double getSpeedOfSword(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_SPEED); } - public void setSpeedOfSword(ItemStack stack, double speed) - { + public void setSpeedOfSword(ItemStack stack, double speed) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -496,17 +435,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM } @Override - public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) - { + public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) { World world = player.getEntityWorld(); - if (!world.isRemote) - { + if (!world.isRemote) { this.recalculatePowers(droppedStack, world, player); EnumDemonWillType type = this.getCurrentType(droppedStack); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); - if (soulsRemaining < 1024) - { + if (soulsRemaining < 1024) { return false; } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java index 8a9af1d8..b7150d83 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java @@ -1,11 +1,16 @@ package WayofTime.bloodmagic.item.soul; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import javax.annotation.Nullable; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.iface.IMultiWillTool; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.soul.IDemonWill; +import WayofTime.bloodmagic.api.soul.IDemonWillGem; +import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.client.IMeshProvider; +import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionWillGem; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; @@ -18,24 +23,16 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.iface.IMultiWillTool; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.soul.IDemonWill; -import WayofTime.bloodmagic.api.soul.IDemonWillGem; -import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.client.IMeshProvider; -import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionWillGem; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, IMultiWillTool -{ - public static String[] names = { "petty", "lesser", "common", "greater", "grand" }; +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; - public ItemSoulGem() - { +public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, IMultiWillTool { + public static String[] names = {"petty", "lesser", "common", "greater", "grand"}; + + public ItemSoulGem() { super(); setUnlocalizedName(BloodMagic.MODID + ".soulGem."); @@ -45,14 +42,12 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) - { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); EnumDemonWillType type = this.getCurrentType(stack); double drain = Math.min(this.getWill(type, stack), this.getMaxWill(type, stack) / 10); @@ -65,24 +60,20 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I @Override @SideOnly(Side.CLIENT) - public ItemMeshDefinition getMeshDefinition() - { + public ItemMeshDefinition getMeshDefinition() { return new CustomMeshDefinitionWillGem("ItemSoulGem"); } @Nullable @Override - public ResourceLocation getCustomLocation() - { + public ResourceLocation getCustomLocation() { return null; } @Override - public List getVariants() - { + public List getVariants() { List ret = new ArrayList(); - for (EnumDemonWillType type : EnumDemonWillType.values()) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { ret.add("type=petty_" + type.getName().toLowerCase()); ret.add("type=lesser_" + type.getName().toLowerCase()); ret.add("type=common_" + type.getName().toLowerCase()); @@ -94,21 +85,17 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I } @Override - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; - for (int i = 0; i < names.length; i++) - { + for (int i = 0; i < names.length; i++) { ItemStack emptyStack = new ItemStack(this, 1, i); list.add(emptyStack); } - for (EnumDemonWillType type : EnumDemonWillType.values()) - { - for (int i = 0; i < names.length; i++) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { + for (int i = 0; i < names.length; i++) { ItemStack fullStack = new ItemStack(this, 1, i); setWill(type, fullStack, getMaxWill(EnumDemonWillType.DEFAULT, fullStack)); list.add(fullStack); @@ -118,8 +105,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { if (!stack.hasTagCompound()) return; @@ -132,57 +118,47 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I } @Override - public boolean showDurabilityBar(ItemStack stack) - { + public boolean showDurabilityBar(ItemStack stack) { return true; } @Override - public double getDurabilityForDisplay(ItemStack stack) - { + public double getDurabilityForDisplay(ItemStack stack) { EnumDemonWillType type = this.getCurrentType(stack); double maxWill = getMaxWill(type, stack); - if (maxWill <= 0) - { + if (maxWill <= 0) { return 1; } return 1.0 - (getWill(type, stack) / maxWill); } @Override - public int getRGBDurabilityForDisplay(ItemStack stack) - { + public int getRGBDurabilityForDisplay(ItemStack stack) { EnumDemonWillType type = this.getCurrentType(stack); double maxWill = getMaxWill(type, stack); - if (maxWill <= 0) - { + if (maxWill <= 0) { return 1; } - return MathHelper.hsvToRGB(Math.max(0.0F, (float)(getWill(type, stack)) / (float) maxWill) / 3.0F, 1.0F, 1.0F); + return MathHelper.hsvToRGB(Math.max(0.0F, (float) (getWill(type, stack)) / (float) maxWill) / 3.0F, 1.0F, 1.0F); } @Override - public ItemStack fillDemonWillGem(ItemStack soulGemStack, ItemStack soulStack) - { - if (soulStack != null && soulStack.getItem() instanceof IDemonWill) - { + public ItemStack fillDemonWillGem(ItemStack soulGemStack, ItemStack soulStack) { + if (soulStack != null && soulStack.getItem() instanceof IDemonWill) { EnumDemonWillType thisType = this.getCurrentType(soulGemStack); - if (thisType != ((IDemonWill) soulStack.getItem()).getType(soulStack)) - { + if (thisType != ((IDemonWill) soulStack.getItem()).getType(soulStack)) { return soulStack; } IDemonWill soul = (IDemonWill) soulStack.getItem(); double soulsLeft = getWill(thisType, soulGemStack); - if (soulsLeft < getMaxWill(thisType, soulGemStack)) - { + if (soulsLeft < getMaxWill(thisType, soulGemStack)) { double newSoulsLeft = Math.min(soulsLeft + soul.getWill(thisType, soulStack), getMaxWill(thisType, soulGemStack)); soul.drainWill(thisType, soulStack, newSoulsLeft - soulsLeft); setWill(thisType, soulGemStack, newSoulsLeft); - if (soul.getWill(thisType, soulStack) <= 0) - { + if (soul.getWill(thisType, soulStack) <= 0) { return ItemStack.EMPTY; } } @@ -192,10 +168,8 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I } @Override - public double getWill(EnumDemonWillType type, ItemStack soulGemStack) - { - if (!type.equals(getCurrentType(soulGemStack))) - { + public double getWill(EnumDemonWillType type, ItemStack soulGemStack) { + if (!type.equals(getCurrentType(soulGemStack))) { return 0; } @@ -205,8 +179,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I } @Override - public void setWill(EnumDemonWillType type, ItemStack soulGemStack, double souls) - { + public void setWill(EnumDemonWillType type, ItemStack soulGemStack, double souls) { setCurrentType(type, soulGemStack); NBTTagCompound tag = soulGemStack.getTagCompound(); @@ -215,19 +188,16 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I } @Override - public double drainWill(EnumDemonWillType type, ItemStack soulGemStack, double drainAmount, boolean doDrain) - { + public double drainWill(EnumDemonWillType type, ItemStack soulGemStack, double drainAmount, boolean doDrain) { EnumDemonWillType currentType = this.getCurrentType(soulGemStack); - if (currentType != type) - { + if (currentType != type) { return 0; } double souls = getWill(type, soulGemStack); double soulsDrained = Math.min(drainAmount, souls); - if (doDrain) - { + if (doDrain) { setWill(type, soulGemStack, souls - soulsDrained); } @@ -235,55 +205,47 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I } @Override - public int getMaxWill(EnumDemonWillType type, ItemStack soulGemStack) - { + public int getMaxWill(EnumDemonWillType type, ItemStack soulGemStack) { EnumDemonWillType currentType = getCurrentType(soulGemStack); - if (!type.equals(currentType) && currentType != EnumDemonWillType.DEFAULT) - { + if (!type.equals(currentType) && currentType != EnumDemonWillType.DEFAULT) { return 0; } - switch (soulGemStack.getMetadata()) - { - case 0: - return 64; - case 1: - return 256; - case 2: - return 1024; - case 3: - return 4096; - case 4: - return 16384; + switch (soulGemStack.getMetadata()) { + case 0: + return 64; + case 1: + return 256; + case 2: + return 1024; + case 3: + return 4096; + case 4: + return 16384; } return 64; } @Override - public EnumDemonWillType getCurrentType(ItemStack soulGemStack) - { + public EnumDemonWillType getCurrentType(ItemStack soulGemStack) { NBTHelper.checkNBT(soulGemStack); NBTTagCompound tag = soulGemStack.getTagCompound(); - if (!tag.hasKey(Constants.NBT.WILL_TYPE)) - { + if (!tag.hasKey(Constants.NBT.WILL_TYPE)) { return EnumDemonWillType.DEFAULT; } return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH)); } - public void setCurrentType(EnumDemonWillType type, ItemStack soulGemStack) - { + public void setCurrentType(EnumDemonWillType type, ItemStack soulGemStack) { NBTHelper.checkNBT(soulGemStack); NBTTagCompound tag = soulGemStack.getTagCompound(); - if (type == EnumDemonWillType.DEFAULT) - { - if (tag.hasKey(Constants.NBT.WILL_TYPE)) - { + if (type == EnumDemonWillType.DEFAULT) { + if (tag.hasKey(Constants.NBT.WILL_TYPE)) { tag.removeTag(Constants.NBT.WILL_TYPE); } @@ -294,10 +256,8 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I } @Override - public double fillWill(EnumDemonWillType type, ItemStack stack, double fillAmount, boolean doFill) - { - if (!type.equals(getCurrentType(stack)) && this.getWill(getCurrentType(stack), stack) > 0) - { + public double fillWill(EnumDemonWillType type, ItemStack stack, double fillAmount, boolean doFill) { + if (!type.equals(getCurrentType(stack)) && this.getWill(getCurrentType(stack), stack) > 0) { return 0; } @@ -306,8 +266,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I double filled = Math.min(fillAmount, maxWill - current); - if (doFill) - { + if (doFill) { this.setWill(type, stack, filled + current); } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulSnare.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulSnare.java index d96f1973..e6d76d8c 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulSnare.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulSnare.java @@ -14,7 +14,6 @@ import net.minecraft.util.*; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; @@ -22,12 +21,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -public class ItemSoulSnare extends Item implements IVariantProvider -{ - public static String[] names = { "base" }; +public class ItemSoulSnare extends Item implements IVariantProvider { + public static String[] names = {"base"}; - public ItemSoulSnare() - { + public ItemSoulSnare() { super(); setUnlocalizedName(BloodMagic.MODID + ".soulSnare."); @@ -37,18 +34,15 @@ public class ItemSoulSnare extends Item implements IVariantProvider } @Override - public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) - { + public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { ItemStack stack = playerIn.getHeldItem(hand); - if (!playerIn.capabilities.isCreativeMode) - { + if (!playerIn.capabilities.isCreativeMode) { stack.shrink(1); } worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - if (!worldIn.isRemote) - { + if (!worldIn.isRemote) { EntitySoulSnare snare = new EntitySoulSnare(worldIn, playerIn); snare.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F); worldIn.spawnEntity(snare); @@ -58,15 +52,13 @@ public class ItemSoulSnare extends Item implements IVariantProvider } @Override - public String getUnlocalizedName(ItemStack stack) - { + public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs creativeTab, NonNullList list) - { + public void getSubItems(CreativeTabs creativeTab, NonNullList list) { if (!isInCreativeTab(creativeTab)) return; @@ -76,16 +68,14 @@ public class ItemSoulSnare extends Item implements IVariantProvider @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) - { + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.soulSnare.desc")))); super.addInformation(stack, world, tooltip, flag); } @Override - public List> getVariants() - { + public List> getVariants() { List> ret = new ArrayList>(); ret.add(new ImmutablePair(0, "type=soulsnare")); return ret; diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java b/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java index da0a84b1..e9e3edfb 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java @@ -1,11 +1,14 @@ package WayofTime.bloodmagic.livingArmour; -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map.Entry; - +import WayofTime.bloodmagic.api.iface.IUpgradeTrainer; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.api.livingArmour.StatTracker; +import WayofTime.bloodmagic.item.armour.ItemLivingArmour; +import WayofTime.bloodmagic.util.helper.TextHelper; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; @@ -15,19 +18,14 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.iface.IUpgradeTrainer; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.api.livingArmour.StatTracker; -import WayofTime.bloodmagic.item.armour.ItemLivingArmour; -import WayofTime.bloodmagic.util.helper.TextHelper; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map.Entry; -public class LivingArmour implements ILivingArmour -{ +public class LivingArmour implements ILivingArmour { public static String chatBase = "chat.bloodmagic.livingArmour."; public HashMap trackerMap = new HashMap(); public HashMap upgradeMap = new HashMap(); @@ -35,52 +33,42 @@ public class LivingArmour implements ILivingArmour public int maxUpgradePoints = 100; public int totalUpgradePoints = 0; - public StatTracker getTracker(String key) - { + public StatTracker getTracker(String key) { return trackerMap.get(key); } - public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) - { + public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) { double total = 0; - for (Entry entry : upgradeMap.entrySet()) - { + for (Entry entry : upgradeMap.entrySet()) { total += entry.getValue().getAdditionalDamageOnHit(damage, wearer, hitEntity, weapon); } return total; } - public double getKnockbackOnHit(EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) - { + public double getKnockbackOnHit(EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) { double total = 0; - for (Entry entry : upgradeMap.entrySet()) - { + for (Entry entry : upgradeMap.entrySet()) { total += entry.getValue().getKnockbackOnHit(wearer, hitEntity, weapon); } return total; } - public void recalculateUpgradePoints() - { + public void recalculateUpgradePoints() { totalUpgradePoints = 0; - for (LivingArmourUpgrade upgrade : upgradeMap.values()) - { + for (LivingArmourUpgrade upgrade : upgradeMap.values()) { totalUpgradePoints += upgrade.getCostOfUpgrade(); } } @Override - public Multimap getAttributeModifiers() - { + public Multimap getAttributeModifiers() { HashMultimap modifierMap = HashMultimap.create(); - for (Entry entry : upgradeMap.entrySet()) - { + for (Entry entry : upgradeMap.entrySet()) { LivingArmourUpgrade upgrade = entry.getValue(); - if (upgrade == null) - { + if (upgrade == null) { continue; } modifierMap.putAll(upgrade.getAttributeModifiers()); @@ -90,41 +78,33 @@ public class LivingArmour implements ILivingArmour } @Override - public boolean upgradeArmour(EntityPlayer user, LivingArmourUpgrade upgrade) - { + public boolean upgradeArmour(EntityPlayer user, LivingArmourUpgrade upgrade) { String key = upgrade.getUniqueIdentifier(); - if (upgradeMap.containsKey(key)) - { + if (upgradeMap.containsKey(key)) { //Check if this is a higher level than the previous upgrade int nextLevel = upgrade.getUpgradeLevel(); int currentLevel = upgradeMap.get(key).getUpgradeLevel(); - if (nextLevel > currentLevel) - { + if (nextLevel > currentLevel) { int upgradePointDifference = upgrade.getCostOfUpgrade() - upgradeMap.get(key).getCostOfUpgrade(); - if (totalUpgradePoints + upgradePointDifference <= maxUpgradePoints) - { + if (totalUpgradePoints + upgradePointDifference <= maxUpgradePoints) { upgradeMap.put(key, upgrade); totalUpgradePoints += upgradePointDifference; notifyPlayerOfUpgrade(user, upgrade); - for (StatTracker tracker : trackerMap.values()) - { + for (StatTracker tracker : trackerMap.values()) { tracker.onArmourUpgradeAdded(upgrade); } return true; } } - } else - { + } else { int upgradePoints = upgrade.getCostOfUpgrade(); - if (totalUpgradePoints + upgradePoints <= maxUpgradePoints) - { + if (totalUpgradePoints + upgradePoints <= maxUpgradePoints) { upgradeMap.put(key, upgrade); totalUpgradePoints += upgradePoints; notifyPlayerOfUpgrade(user, upgrade); - for (StatTracker tracker : trackerMap.values()) - { + for (StatTracker tracker : trackerMap.values()) { tracker.onArmourUpgradeAdded(upgrade); } @@ -136,28 +116,22 @@ public class LivingArmour implements ILivingArmour } @Override - public boolean canApplyUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade) - { + public boolean canApplyUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade) { String key = upgrade.getUniqueIdentifier(); - if (upgradeMap.containsKey(key)) - { + if (upgradeMap.containsKey(key)) { //Check if this is a higher level than the previous upgrade int nextLevel = upgrade.getUpgradeLevel(); int currentLevel = upgradeMap.get(key).getUpgradeLevel(); - if (nextLevel > currentLevel) - { + if (nextLevel > currentLevel) { int upgradePointDifference = upgrade.getCostOfUpgrade() - upgradeMap.get(key).getCostOfUpgrade(); - if (totalUpgradePoints + upgradePointDifference <= maxUpgradePoints) - { + if (totalUpgradePoints + upgradePointDifference <= maxUpgradePoints) { return true; } } - } else - { + } else { int upgradePoints = upgrade.getCostOfUpgrade(); - if (totalUpgradePoints + upgradePoints <= maxUpgradePoints) - { + if (totalUpgradePoints + upgradePoints <= maxUpgradePoints) { return true; } } @@ -166,85 +140,69 @@ public class LivingArmour implements ILivingArmour } @Override - public void notifyPlayerOfUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade) - { + public void notifyPlayerOfUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade) { user.sendStatusMessage(new TextComponentString(TextHelper.localizeEffect(chatBase + "newUpgrade")), true); } /** * Ticks the upgrades and stat trackers, passing in the world and player as * well as the LivingArmour - * + * * @param world * @param player */ @Override - public void onTick(World world, EntityPlayer player) - { - for (Entry entry : upgradeMap.entrySet()) - { + public void onTick(World world, EntityPlayer player) { + for (Entry entry : upgradeMap.entrySet()) { LivingArmourUpgrade upgrade = entry.getValue(); - if (upgrade == null) - { + if (upgrade == null) { continue; } - if (!world.isRemote || upgrade.runOnClient()) - { + if (!world.isRemote || upgrade.runOnClient()) { upgrade.onTick(world, player, this); } } - if (world.isRemote) - { + if (world.isRemote) { return; } List allowedUpgradesList = new ArrayList(); - for (ItemStack stack : player.inventory.mainInventory) - { - if (stack != null && stack.getItem() instanceof IUpgradeTrainer) - { + for (ItemStack stack : player.inventory.mainInventory) { + if (stack != null && stack.getItem() instanceof IUpgradeTrainer) { List keyList = ((IUpgradeTrainer) stack.getItem()).getTrainedUpgrades(stack); - if (!keyList.isEmpty()) - { + if (!keyList.isEmpty()) { allowedUpgradesList.addAll(keyList); } } } - for (Entry entry : trackerMap.entrySet()) - { + for (Entry entry : trackerMap.entrySet()) { StatTracker tracker = entry.getValue(); - if (tracker == null) - { + if (tracker == null) { continue; } - if (!allowedUpgradesList.isEmpty()) - { + if (!allowedUpgradesList.isEmpty()) { boolean allowed = false; - for (String key : allowedUpgradesList) - { - if (tracker.providesUpgrade(key)) - { + for (String key : allowedUpgradesList) { + if (tracker.providesUpgrade(key)) { allowed = true; break; } } - if (!allowed) - { + if (!allowed) { tracker.onDeactivatedTick(world, player, this); continue; } } - if (tracker.onTick(world, player, this)) - { + if (tracker.onTick(world, player, this)) { List upgradeList = tracker.getUpgrades(); for (LivingArmourUpgrade upgrade : upgradeList) //TODO: make a getNextUpgrade? @@ -257,62 +215,51 @@ public class LivingArmour implements ILivingArmour } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { maxUpgradePoints = Math.max(100, tag.getInteger("maxUpgradePoints")); NBTTagList upgradeTags = tag.getTagList("upgrades", 10); - if (upgradeTags != null) - { - for (int i = 0; i < upgradeTags.tagCount(); i++) - { + if (upgradeTags != null) { + for (int i = 0; i < upgradeTags.tagCount(); i++) { NBTTagCompound upgradeTag = upgradeTags.getCompoundTagAt(i); String key = upgradeTag.getString("key"); int level = upgradeTag.getInteger("level"); NBTTagCompound nbtTag = upgradeTag.getCompoundTag("upgrade"); LivingArmourUpgrade upgrade = LivingArmourHandler.generateUpgradeFromKey(key, level, nbtTag); - if (upgrade != null) - { + if (upgrade != null) { upgradeMap.put(key, upgrade); totalUpgradePoints += upgrade.getCostOfUpgrade(); } } } - for (Class clazz : LivingArmourHandler.trackers) - { - try - { + for (Class clazz : LivingArmourHandler.trackers) { + try { Constructor ctor = clazz.getConstructor(); Object obj = ctor.newInstance(); - if (!(obj instanceof StatTracker)) - { + if (!(obj instanceof StatTracker)) { // ????? } StatTracker tracker = (StatTracker) obj; String key = tracker.getUniqueIdentifier(); NBTTagCompound trackerTag = tag.getCompoundTag(key); - if (!trackerTag.hasNoTags()) - { + if (!trackerTag.hasNoTags()) { tracker.readFromNBT(trackerTag); } trackerMap.put(key, tracker); - } catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } } } @Override - public void writeToNBT(NBTTagCompound tag, boolean forceWrite) - { + public void writeToNBT(NBTTagCompound tag, boolean forceWrite) { tag.setInteger("maxUpgradePoints", maxUpgradePoints); NBTTagList tags = new NBTTagList(); - for (Entry entry : upgradeMap.entrySet()) - { + for (Entry entry : upgradeMap.entrySet()) { NBTTagCompound upgradeTag = new NBTTagCompound(); LivingArmourUpgrade upgrade = entry.getValue(); @@ -328,19 +275,16 @@ public class LivingArmour implements ILivingArmour tag.setTag("upgrades", tags); - for (Entry entry : trackerMap.entrySet()) - { + for (Entry entry : trackerMap.entrySet()) { StatTracker tracker = entry.getValue(); - if (tracker == null) - { + if (tracker == null) { continue; } String key = tracker.getUniqueIdentifier(); - if (forceWrite || tracker.isDirty()) - { + if (forceWrite || tracker.isDirty()) { NBTTagCompound trackerTag = new NBTTagCompound(); tracker.writeToNBT(trackerTag); @@ -354,27 +298,34 @@ public class LivingArmour implements ILivingArmour /** * Writes the LivingArmour to the NBTTag. This will only write the trackers * that are dirty. - * + * * @param tag */ @Override - public void writeDirtyToNBT(NBTTagCompound tag) - { + public void writeDirtyToNBT(NBTTagCompound tag) { writeToNBT(tag, false); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { writeToNBT(tag, true); } - public static boolean hasFullSet(EntityPlayer player) - { - for (EntityEquipmentSlot slot : EntityEquipmentSlot.values()) - { - if (slot.getSlotType() != EntityEquipmentSlot.Type.ARMOR) - { + @Override + public boolean removeUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade) { + String key = upgrade.getUniqueIdentifier(); + if (upgradeMap.containsKey(key)) { + upgradeMap.remove(key); + + return true; + } + + return false; + } + + public static boolean hasFullSet(EntityPlayer player) { + for (EntityEquipmentSlot slot : EntityEquipmentSlot.values()) { + if (slot.getSlotType() != EntityEquipmentSlot.Type.ARMOR) { continue; } ItemStack slotStack = player.getItemStackFromSlot(slot); @@ -384,18 +335,4 @@ public class LivingArmour implements ILivingArmour return true; } - - @Override - public boolean removeUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade) - { - String key = upgrade.getUniqueIdentifier(); - if (upgradeMap.containsKey(key)) - { - upgradeMap.remove(key); - - return true; - } - - return false; - } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeBattleHungry.java b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeBattleHungry.java index 51bac32a..2de24a51 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeBattleHungry.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeBattleHungry.java @@ -1,84 +1,71 @@ package WayofTime.bloodmagic.livingArmour.downgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeBattleHungry extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { -10, -20, -35, -50, -75 }; - public static final float[] exhaustionAdded = new float[] { 0.02f, 0.04f, 0.06f, 0.08f, 0.1f }; - public static final int[] delay = new int[] { 600, 600, 600, 500, 400 }; +public class LivingArmourUpgradeBattleHungry extends LivingArmourUpgrade { + public static final int[] costs = new int[]{-10, -20, -35, -50, -75}; + public static final float[] exhaustionAdded = new float[]{0.02f, 0.04f, 0.06f, 0.08f, 0.1f}; + public static final int[] delay = new int[]{600, 600, 600, 500, 400}; public int timer = 0; - public LivingArmourUpgradeBattleHungry(int level) - { + public LivingArmourUpgradeBattleHungry(int level) { super(level); } - public void resetTimer() - { + public void resetTimer() { this.timer = delay[this.level]; } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { - if (timer > 0) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { + if (timer > 0) { timer--; return; } - if (player.ticksExisted % 20 == 0) - { + if (player.ticksExisted % 20 == 0) { player.addExhaustion(exhaustionAdded[this.level]); //TODO: Change exhaustion added per level. } } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.battleHunger"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 5; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger("timer", timer); } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { timer = tag.getInteger("timer"); } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "battleHunger"; } @Override - public boolean isDowngrade() - { + public boolean isDowngrade() { return true; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeCrippledArm.java b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeCrippledArm.java index 489dfd4d..a187eacd 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeCrippledArm.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeCrippledArm.java @@ -1,64 +1,54 @@ package WayofTime.bloodmagic.livingArmour.downgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeCrippledArm extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { -150 }; +public class LivingArmourUpgradeCrippledArm extends LivingArmourUpgrade { + public static final int[] costs = new int[]{-150}; - public LivingArmourUpgradeCrippledArm(int level) - { + public LivingArmourUpgradeCrippledArm(int level) { super(level); } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.crippledArm"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 1; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "crippledArm"; } @Override - public boolean isDowngrade() - { + public boolean isDowngrade() { return true; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeDigSlowdown.java b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeDigSlowdown.java index 22c7f835..50655a92 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeDigSlowdown.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeDigSlowdown.java @@ -1,78 +1,65 @@ package WayofTime.bloodmagic.livingArmour.downgrade; -import java.util.HashMap; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeDigSlowdown extends LivingArmourUpgrade -{ +import java.util.HashMap; + +public class LivingArmourUpgradeDigSlowdown extends LivingArmourUpgrade { + public static final int[] costs = new int[]{-10, -17, -28, -42, -60, -80, -100, -125, -160, -200}; + public static final double[] digSpeedModifier = new double[]{0.9, 0.8, 0.7, 0.6, 0.55, 0.5, 0.4, 0.35, 0.3, 0.2}; public static HashMap changeMap = new HashMap(); - public static final int[] costs = new int[] { -10, -17, -28, -42, -60, -80, -100, -125, -160, -200 }; - - public static final double[] digSpeedModifier = new double[] { 0.9, 0.8, 0.7, 0.6, 0.55, 0.5, 0.4, 0.35, 0.3, 0.2 }; - - public LivingArmourUpgradeDigSlowdown(int level) - { + public LivingArmourUpgradeDigSlowdown(int level) { super(level); } @Override - public double getMiningSpeedModifier(EntityPlayer player) - { + public double getMiningSpeedModifier(EntityPlayer player) { return digSpeedModifier[this.level]; } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.digSlowdown"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; // Set to here until I can add more upgrades to it. } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "digSlowdown"; } @Override - public boolean isDowngrade() - { + public boolean isDowngrade() { return true; } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeDisoriented.java b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeDisoriented.java index 748e46c5..90dcf8a7 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeDisoriented.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeDisoriented.java @@ -1,75 +1,63 @@ package WayofTime.bloodmagic.livingArmour.downgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeDisoriented extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { -10, -20, -30, -40, -70, -80, -100, -140, -180, -220 }; - public static final double[] chance = new double[] { 0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.008, 0.0010, 0.0012, 0.014 }; +public class LivingArmourUpgradeDisoriented extends LivingArmourUpgrade { + public static final int[] costs = new int[]{-10, -20, -30, -40, -70, -80, -100, -140, -180, -220}; + public static final double[] chance = new double[]{0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.008, 0.0010, 0.0012, 0.014}; - public LivingArmourUpgradeDisoriented(int level) - { + public LivingArmourUpgradeDisoriented(int level) { super(level); } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { - if (world.isRemote && player.ticksExisted % 20 == 0 && world.rand.nextDouble() <= chance[this.level]) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { + if (world.isRemote && player.ticksExisted % 20 == 0 && world.rand.nextDouble() <= chance[this.level]) { player.rotationYaw = world.rand.nextFloat() * 360; player.rotationPitch = world.rand.nextFloat() * 180 - 90; } } @Override - public boolean runOnClient() - { + public boolean runOnClient() { return true; } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.disoriented"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "disoriented"; } @Override - public boolean isDowngrade() - { + public boolean isDowngrade() { return true; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeMeleeDecrease.java b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeMeleeDecrease.java index 7bf7d5b7..f5648b37 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeMeleeDecrease.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeMeleeDecrease.java @@ -3,10 +3,8 @@ package WayofTime.bloodmagic.livingArmour.downgrade; import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; - import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; - import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; @@ -16,25 +14,21 @@ import org.apache.commons.codec.binary.StringUtils; import java.util.UUID; -public class LivingArmourUpgradeMeleeDecrease extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { -10, -17, -28, -42, -60, -80, -100, -125, -160, -200 }; - public static final double[] meleeDamage = new double[] { -0.1, -0.2, -0.25, -0.3, -0.35, -0.4, -0.5, -0.6, -0.7, -0.8 }; +public class LivingArmourUpgradeMeleeDecrease extends LivingArmourUpgrade { + public static final int[] costs = new int[]{-10, -17, -28, -42, -60, -80, -100, -125, -160, -200}; + public static final double[] meleeDamage = new double[]{-0.1, -0.2, -0.25, -0.3, -0.35, -0.4, -0.5, -0.6, -0.7, -0.8}; - public LivingArmourUpgradeMeleeDecrease(int level) - { + public LivingArmourUpgradeMeleeDecrease(int level) { super(level); } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { } @Override - public Multimap getAttributeModifiers() - { + public Multimap getAttributeModifiers() { Multimap modifierMap = HashMultimap.create(); String name = getUniqueIdentifier() + "-DamageModifier1"; @@ -44,44 +38,37 @@ public class LivingArmourUpgradeMeleeDecrease extends LivingArmourUpgrade } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.meleeDecrease"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "meleeDecrease"; } @Override - public boolean isDowngrade() - { + public boolean isDowngrade() { return true; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeQuenched.java b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeQuenched.java index 57af0b42..394b308a 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeQuenched.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeQuenched.java @@ -1,64 +1,54 @@ package WayofTime.bloodmagic.livingArmour.downgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeQuenched extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { -100 }; +public class LivingArmourUpgradeQuenched extends LivingArmourUpgrade { + public static final int[] costs = new int[]{-100}; - public LivingArmourUpgradeQuenched(int level) - { + public LivingArmourUpgradeQuenched(int level) { super(level); } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.quenched"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 1; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "quenched"; } @Override - public boolean isDowngrade() - { + public boolean isDowngrade() { return true; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlippery.java b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlippery.java index aded04f5..31ddcfcc 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlippery.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlippery.java @@ -1,36 +1,31 @@ package WayofTime.bloodmagic.livingArmour.downgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeSlippery extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { -50 }; - public static final int[] slipperyDuration = new int[] { 30 * 20 }; +public class LivingArmourUpgradeSlippery extends LivingArmourUpgrade { + public static final int[] costs = new int[]{-50}; + public static final int[] slipperyDuration = new int[]{30 * 20}; - public LivingArmourUpgradeSlippery(int level) - { + public LivingArmourUpgradeSlippery(int level) { super(level); } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { - if (world.isRemote && player.onGround) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { + if (world.isRemote && player.onGround) { // if (player.moveForward == 0) { float f6 = 0.91F; BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain(player.posX, player.getEntityBoundingBox().minY - 1.0D, player.posZ); - if (player.onGround) - { + if (player.onGround) { f6 = world.getBlockState(blockpos$pooledmutableblockpos).getBlock().slipperiness * 0.91F; } @@ -40,11 +35,9 @@ public class LivingArmourUpgradeSlippery extends LivingArmourUpgrade float f7 = 0.16277136F / (f6 * f6 * f6); float f8; - if (player.onGround) - { + if (player.onGround) { f8 = player.getAIMoveSpeed() * f7; - } else - { + } else { f8 = player.jumpMovementFactor; } @@ -59,48 +52,40 @@ public class LivingArmourUpgradeSlippery extends LivingArmourUpgrade } @Override - public boolean runOnClient() - { + public boolean runOnClient() { return true; } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.slippery"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 1; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "slippery"; } @Override - public boolean isDowngrade() - { + public boolean isDowngrade() { return true; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlowHeal.java b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlowHeal.java index 97100bee..57118a87 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlowHeal.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlowHeal.java @@ -1,73 +1,62 @@ package WayofTime.bloodmagic.livingArmour.downgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeSlowHeal extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { -10, -17, -28, -42, -60, -80, -100, -125, -160, -200 }; +public class LivingArmourUpgradeSlowHeal extends LivingArmourUpgrade { + public static final int[] costs = new int[]{-10, -17, -28, -42, -60, -80, -100, -125, -160, -200}; - public static final double[] healModifier = new double[] { 0.9, 0.8, 0.7, 0.6, 0.55, 0.5, 0.4, 0.35, 0.3, 0.2 }; + public static final double[] healModifier = new double[]{0.9, 0.8, 0.7, 0.6, 0.55, 0.5, 0.4, 0.35, 0.3, 0.2}; - public LivingArmourUpgradeSlowHeal(int level) - { + public LivingArmourUpgradeSlowHeal(int level) { super(level); } - public double getHealingModifier() - { + public double getHealingModifier() { return healModifier[this.level]; } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.slowHeal"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; // Set to here until I can add more upgrades to it. } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "slowHeal"; } @Override - public boolean isDowngrade() - { + public boolean isDowngrade() { return true; } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlowness.java b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlowness.java index bd1c9898..4a8827cc 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlowness.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeSlowness.java @@ -1,33 +1,29 @@ package WayofTime.bloodmagic.livingArmour.downgrade; -import java.util.UUID; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; import org.apache.commons.codec.binary.StringUtils; -public class LivingArmourUpgradeSlowness extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { -10, -17, -23, -35, -48, -60, -80, -110, -160, -200 }; - public static final double[] speedModifier = new double[] { -0.1, -0.2, -0.3, -0.4, -0.45, -0.5, -0.55, -0.6, -0.65, -0.7 }; +import java.util.UUID; - public LivingArmourUpgradeSlowness(int level) - { +public class LivingArmourUpgradeSlowness extends LivingArmourUpgrade { + public static final int[] costs = new int[]{-10, -17, -23, -35, -48, -60, -80, -110, -160, -200}; + public static final double[] speedModifier = new double[]{-0.1, -0.2, -0.3, -0.4, -0.45, -0.5, -0.55, -0.6, -0.65, -0.7}; + + public LivingArmourUpgradeSlowness(int level) { super(level); } @Override - public Multimap getAttributeModifiers() - { + public Multimap getAttributeModifiers() { Multimap modifierMap = HashMultimap.create(); String name = getUniqueIdentifier() + "-SpeedModifier1"; @@ -37,48 +33,40 @@ public class LivingArmourUpgradeSlowness extends LivingArmourUpgrade } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.slowness"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "slowness"; } @Override - public boolean isDowngrade() - { + public boolean isDowngrade() { return true; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeStormTrooper.java b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeStormTrooper.java index 33f589b4..0b8f7788 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeStormTrooper.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/downgrade/LivingArmourUpgradeStormTrooper.java @@ -1,70 +1,59 @@ package WayofTime.bloodmagic.livingArmour.downgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeStormTrooper extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { -10, -25, -40, 65, -90 }; - public static final float[] inaccuracy = new float[] { 0.04f, 0.08f, 0.12f, 0.16f, 0.2f }; +public class LivingArmourUpgradeStormTrooper extends LivingArmourUpgrade { + public static final int[] costs = new int[]{-10, -25, -40, 65, -90}; + public static final float[] inaccuracy = new float[]{0.04f, 0.08f, 0.12f, 0.16f, 0.2f}; - public LivingArmourUpgradeStormTrooper(int level) - { + public LivingArmourUpgradeStormTrooper(int level) { super(level); } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { } - public float getArrowJiggle(EntityPlayer player) - { + public float getArrowJiggle(EntityPlayer player) { return inaccuracy[this.level]; } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.stormTrooper"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 5; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "stormTrooper"; } @Override - public boolean isDowngrade() - { + public boolean isDowngrade() { return true; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerArrowProtect.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerArrowProtect.java index a0dff362..bcb98f2a 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerArrowProtect.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerArrowProtect.java @@ -1,63 +1,49 @@ package WayofTime.bloodmagic.livingArmour.tracker; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.api.livingArmour.StatTracker; +import WayofTime.bloodmagic.livingArmour.LivingArmour; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeArrowProtect; +import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.util.Utils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.api.livingArmour.StatTracker; -import WayofTime.bloodmagic.livingArmour.LivingArmour; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeArrowProtect; - -public class StatTrackerArrowProtect extends StatTracker -{ +public class StatTrackerArrowProtect extends StatTracker { + public static HashMap changeMap = new HashMap(); + public static int[] damageRequired = new int[]{30, 200, 400, 800, 1500, 2500, 3500, 5000, 7000, 15000}; public int totalDamage = 0; - public static HashMap changeMap = new HashMap(); - public static int[] damageRequired = new int[] { 30, 200, 400, 800, 1500, 2500, 3500, 5000, 7000, 15000 }; - - public static void incrementCounter(LivingArmour armour, double damage) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.arrowProtect"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalDamage = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalDamage = tag.getInteger(BloodMagic.MODID + ".tracker.arrowProtect"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(BloodMagic.MODID + ".tracker.arrowProtect", totalDamage); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { double change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalDamage += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0d); @@ -72,23 +58,18 @@ public class StatTrackerArrowProtect extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 10; i++) - { - if (totalDamage >= damageRequired[i]) - { + for (int i = 0; i < 10; i++) { + if (totalDamage >= damageRequired[i]) { upgradeList.add(new LivingArmourUpgradeArrowProtect(i)); } } @@ -97,28 +78,27 @@ public class StatTrackerArrowProtect extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalDamage, damageRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.arrowProtect"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeArrowProtect) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeArrowProtect) { int level = upgrade.getUpgradeLevel(); - if (level < damageRequired.length) - { + if (level < damageRequired.length) { totalDamage = Math.max(totalDamage, damageRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour, double damage) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerArrowShot.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerArrowShot.java index edbac486..1a408791 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerArrowShot.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerArrowShot.java @@ -1,63 +1,49 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeArrowShot; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerArrowShot extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerArrowShot extends StatTracker { + public static HashMap changeMap = new HashMap(); + public static int[] shotsRequired = new int[]{50, 200, 700, 1500, 3000}; public int totalShots = 0; - public static HashMap changeMap = new HashMap(); - public static int[] shotsRequired = new int[] { 50, 200, 700, 1500, 3000 }; - - public static void incrementCounter(LivingArmour armour) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + 1 : 1); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.trickShot"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalShots = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalShots = tag.getInteger(BloodMagic.MODID + ".tracker.trickShot"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(BloodMagic.MODID + ".tracker.trickShot", totalShots); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { int change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalShots += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0); @@ -72,23 +58,18 @@ public class StatTrackerArrowShot extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 5; i++) - { - if (totalShots >= shotsRequired[i]) - { + for (int i = 0; i < 5; i++) { + if (totalShots >= shotsRequired[i]) { upgradeList.add(new LivingArmourUpgradeArrowShot(i)); } } @@ -97,28 +78,27 @@ public class StatTrackerArrowShot extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalShots, shotsRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.arrowShot"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeArrowShot) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeArrowShot) { int level = upgrade.getUpgradeLevel(); - if (level < shotsRequired.length) - { + if (level < shotsRequired.length) { totalShots = Math.max(totalShots, shotsRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + 1 : 1); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerCriticalStrike.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerCriticalStrike.java index 2dfb8b41..4fb581c8 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerCriticalStrike.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerCriticalStrike.java @@ -1,63 +1,49 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeCriticalStrike; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerCriticalStrike extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerCriticalStrike extends StatTracker { + public static HashMap changeMap = new HashMap(); + public static int[] damageRequired = new int[]{200, 800, 1300, 2500, 3800}; public double totalDamageDealt = 0; - public static HashMap changeMap = new HashMap(); - public static int[] damageRequired = new int[] { 200, 800, 1300, 2500, 3800 }; - - public static void incrementCounter(LivingArmour armour, double damage) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.criticalStrike"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalDamageDealt = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalDamageDealt = tag.getDouble(BloodMagic.MODID + ".tracker.criticalStrike"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setDouble(BloodMagic.MODID + ".tracker.criticalStrike", totalDamageDealt); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { double change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalDamageDealt += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0d); @@ -72,23 +58,18 @@ public class StatTrackerCriticalStrike extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 5; i++) - { - if (totalDamageDealt >= damageRequired[i]) - { + for (int i = 0; i < 5; i++) { + if (totalDamageDealt >= damageRequired[i]) { upgradeList.add(new LivingArmourUpgradeCriticalStrike(i)); } } @@ -97,28 +78,27 @@ public class StatTrackerCriticalStrike extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalDamageDealt, damageRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.criticalStrike"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeCriticalStrike) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeCriticalStrike) { int level = upgrade.getUpgradeLevel(); - if (level < damageRequired.length) - { + if (level < damageRequired.length) { totalDamageDealt = Math.max(totalDamageDealt, damageRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour, double damage) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerDigging.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerDigging.java index 5979d7c9..8d5cafe3 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerDigging.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerDigging.java @@ -1,63 +1,49 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeDigging; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerDigging extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerDigging extends StatTracker { + public static HashMap changeMap = new HashMap(); + public static int[] blocksRequired = new int[]{128, 512, 1024, 2048, 8192, 16000, 32000, 50000, 80000, 150000}; public int totalBlocksDug = 0; - public static HashMap changeMap = new HashMap(); - public static int[] blocksRequired = new int[] { 128, 512, 1024, 2048, 8192, 16000, 32000, 50000, 80000, 150000 }; - - public static void incrementCounter(LivingArmour armour) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + 1 : 1); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.digging"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalBlocksDug = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalBlocksDug = tag.getInteger(BloodMagic.MODID + ".tracker.digging"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(BloodMagic.MODID + ".tracker.digging", totalBlocksDug); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { int change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalBlocksDug += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0); @@ -72,23 +58,18 @@ public class StatTrackerDigging extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 10; i++) - { - if (totalBlocksDug >= blocksRequired[i]) - { + for (int i = 0; i < 10; i++) { + if (totalBlocksDug >= blocksRequired[i]) { upgradeList.add(new LivingArmourUpgradeDigging(i)); } } @@ -97,28 +78,27 @@ public class StatTrackerDigging extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalBlocksDug, blocksRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.digging"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeDigging) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeDigging) { int level = upgrade.getUpgradeLevel(); - if (level < blocksRequired.length) - { + if (level < blocksRequired.length) { totalBlocksDug = Math.max(totalBlocksDug, blocksRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + 1 : 1); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerExperience.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerExperience.java index 5a602e47..459d947a 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerExperience.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerExperience.java @@ -1,63 +1,49 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeExperience; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerExperience extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerExperience extends StatTracker { + public static HashMap changeMap = new HashMap(); + public static int[] experienceRequired = new int[]{100, 400, 1000, 1600, 3200, 5000, 7000, 9200, 11500, 140000}; public double totalExperienceGained = 0; - public static HashMap changeMap = new HashMap(); - public static int[] experienceRequired = new int[] { 100, 400, 1000, 1600, 3200, 5000, 7000, 9200, 11500, 140000 }; - - public static void incrementCounter(LivingArmour armour, int exp) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + exp : exp); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.experienced"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalExperienceGained = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalExperienceGained = tag.getDouble(BloodMagic.MODID + ".tracker.experienced"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setDouble(BloodMagic.MODID + ".tracker.experienced", totalExperienceGained); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { double change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalExperienceGained += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0); @@ -72,23 +58,18 @@ public class StatTrackerExperience extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 10; i++) - { - if (totalExperienceGained >= experienceRequired[i]) - { + for (int i = 0; i < 10; i++) { + if (totalExperienceGained >= experienceRequired[i]) { upgradeList.add(new LivingArmourUpgradeExperience(i)); } } @@ -97,28 +78,27 @@ public class StatTrackerExperience extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalExperienceGained, experienceRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.experienced"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeExperience) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeExperience) { int level = upgrade.getUpgradeLevel(); - if (level < experienceRequired.length) - { + if (level < experienceRequired.length) { totalExperienceGained = Math.max(totalExperienceGained, experienceRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour, int exp) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + exp : exp); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFallProtect.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFallProtect.java index 3170af53..64440c23 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFallProtect.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFallProtect.java @@ -1,63 +1,49 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeFallProtect; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerFallProtect extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerFallProtect extends StatTracker { + public static HashMap changeMap = new HashMap(); + public static int[] damageRequired = new int[]{30, 200, 400, 800, 1500}; public int totalDamage = 0; - public static HashMap changeMap = new HashMap(); - public static int[] damageRequired = new int[] { 30, 200, 400, 800, 1500 }; - - public static void incrementCounter(LivingArmour armour, double damage) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.fallProtect"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalDamage = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalDamage = tag.getInteger(BloodMagic.MODID + ".tracker.fallProtect"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(BloodMagic.MODID + ".tracker.fallProtect", totalDamage); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { double change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalDamage += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0d); @@ -72,23 +58,18 @@ public class StatTrackerFallProtect extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 5; i++) - { - if (totalDamage >= damageRequired[i]) - { + for (int i = 0; i < 5; i++) { + if (totalDamage >= damageRequired[i]) { upgradeList.add(new LivingArmourUpgradeFallProtect(i)); } } @@ -97,28 +78,27 @@ public class StatTrackerFallProtect extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalDamage, damageRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.fallProtect"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeFallProtect) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeFallProtect) { int level = upgrade.getUpgradeLevel(); - if (level < damageRequired.length) - { + if (level < damageRequired.length) { totalDamage = Math.max(totalDamage, damageRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour, double damage) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFireResist.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFireResist.java index 4b37e65a..3be711ab 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFireResist.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFireResist.java @@ -1,53 +1,45 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeFireResist; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerFireResist extends StatTracker -{ +import java.util.ArrayList; +import java.util.List; + +public class StatTrackerFireResist extends StatTracker { + public static int[] fireTicksRequired = new int[]{60 * 20, 3 * 60 * 20, 10 * 60 * 20, 20 * 60 * 20, 25 * 60 * 20}; public int totalFireTicks = 0; - public static int[] fireTicksRequired = new int[] { 60 * 20, 3 * 60 * 20, 10 * 60 * 20, 20 * 60 * 20, 25 * 60 * 20 }; - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.fire"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalFireTicks = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalFireTicks = tag.getInteger(BloodMagic.MODID + ".tracker.fire"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(BloodMagic.MODID + ".tracker.fire", totalFireTicks); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (player.isBurning()) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (player.isBurning()) { totalFireTicks++; this.markDirty(); return true; @@ -57,20 +49,16 @@ public class StatTrackerFireResist extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 5; i++) - { - if (totalFireTicks >= fireTicksRequired[i]) - { + for (int i = 0; i < 5; i++) { + if (totalFireTicks >= fireTicksRequired[i]) { upgradeList.add(new LivingArmourUpgradeFireResist(i)); } } @@ -79,25 +67,20 @@ public class StatTrackerFireResist extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalFireTicks, fireTicksRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.fireResist"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeFireResist) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeFireResist) { int level = upgrade.getUpgradeLevel(); - if (level < fireTicksRequired.length) - { + if (level < fireTicksRequired.length) { totalFireTicks = Math.max(totalFireTicks, fireTicksRequired[level]); this.markDirty(); } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFood.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFood.java index 4227f9ab..e3b35918 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFood.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerFood.java @@ -1,58 +1,51 @@ package WayofTime.bloodmagic.livingArmour.tracker; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.api.livingArmour.StatTracker; +import WayofTime.bloodmagic.livingArmour.LivingArmour; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeKnockbackResist; +import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.api.livingArmour.StatTracker; -import WayofTime.bloodmagic.livingArmour.LivingArmour; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeKnockbackResist; -import WayofTime.bloodmagic.util.Utils; - -public class StatTrackerFood extends StatTracker -{ +public class StatTrackerFood extends StatTracker { public static Map lastFoodEatenMap = new HashMap(); - public static int[] foodRequired = new int[] { 100, 200, 300, 500, 1000 }; + public static int[] foodRequired = new int[]{100, 200, 300, 500, 1000}; public int foodEaten = 0; @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.foodEaten"; } @Override - public void resetTracker() - { + public void resetTracker() { this.foodEaten = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { foodEaten = tag.getInteger(BloodMagic.MODID + ".tracker.foodEaten"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(BloodMagic.MODID + ".tracker.foodEaten", foodEaten); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (!lastFoodEatenMap.containsKey(player)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (!lastFoodEatenMap.containsKey(player)) { lastFoodEatenMap.put(player, 20); return false; } @@ -61,8 +54,7 @@ public class StatTrackerFood extends StatTracker int prevFood = lastFoodEatenMap.get(player); lastFoodEatenMap.put(player, currentFood); - if (currentFood > prevFood) - { + if (currentFood > prevFood) { foodEaten += (currentFood - prevFood); markDirty(); @@ -74,23 +66,18 @@ public class StatTrackerFood extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (lastFoodEatenMap.containsKey(player)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (lastFoodEatenMap.containsKey(player)) { lastFoodEatenMap.remove(player); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < foodRequired.length; i++) - { - if (foodEaten >= foodRequired[i]) - { + for (int i = 0; i < foodRequired.length; i++) { + if (foodEaten >= foodRequired[i]) { upgradeList.add(new LivingArmourUpgradeKnockbackResist(i)); } } @@ -99,25 +86,20 @@ public class StatTrackerFood extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(foodEaten, foodRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.knockback"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeKnockbackResist) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeKnockbackResist) { int level = upgrade.getUpgradeLevel(); - if (level < foodRequired.length) - { + if (level < foodRequired.length) { foodEaten = Math.max(foodEaten, foodRequired[level]); this.markDirty(); } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGraveDigger.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGraveDigger.java index b0a7ffd4..e7069b4e 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGraveDigger.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGraveDigger.java @@ -1,63 +1,49 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeGraveDigger; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerGraveDigger extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerGraveDigger extends StatTracker { + public static HashMap changeMap = new HashMap(); + public static int[] damageRequired = new int[]{200, 800, 1300, 2500, 3800, 5000, 7000, 9200, 11500, 140000}; public double totalDamageDealt = 0; - public static HashMap changeMap = new HashMap(); - public static int[] damageRequired = new int[] { 200, 800, 1300, 2500, 3800, 5000, 7000, 9200, 11500, 140000 }; - - public static void incrementCounter(LivingArmour armour, double damage) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.graveDigger"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalDamageDealt = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalDamageDealt = tag.getDouble(BloodMagic.MODID + ".tracker.graveDigger"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setDouble(BloodMagic.MODID + ".tracker.graveDigger", totalDamageDealt); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { double change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalDamageDealt += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0d); @@ -72,23 +58,18 @@ public class StatTrackerGraveDigger extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 10; i++) - { - if (totalDamageDealt >= damageRequired[i]) - { + for (int i = 0; i < 10; i++) { + if (totalDamageDealt >= damageRequired[i]) { upgradeList.add(new LivingArmourUpgradeGraveDigger(i)); } } @@ -97,28 +78,27 @@ public class StatTrackerGraveDigger extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalDamageDealt, damageRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.graveDigger"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeGraveDigger) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeGraveDigger) { int level = upgrade.getUpgradeLevel(); - if (level < damageRequired.length) - { + if (level < damageRequired.length) { totalDamageDealt = Math.max(totalDamageDealt, damageRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour, double damage) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGrimReaperSprint.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGrimReaperSprint.java index fb32dfe2..21670c1f 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGrimReaperSprint.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGrimReaperSprint.java @@ -1,70 +1,49 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeGrimReaperSprint; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerGrimReaperSprint extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerGrimReaperSprint extends StatTracker { + public static HashMap changeMap = new HashMap(); + public static int[] deathsRequired = new int[]{6, 10, 15, 25, 50, 70, 90, 120, 150, 200}; //TODO: Modify public int totalDeaths = 0; - public static HashMap changeMap = new HashMap(); - public static int[] deathsRequired = new int[] { 6, 10, 15, 25, 50, 70, 90, 120, 150, 200 }; //TODO: Modify - - public static void incrementCounter(LivingArmour armour) - { - StatTracker tracker = armour.getTracker(BloodMagic.MODID + ".tracker.grimReaper"); - if (tracker instanceof StatTrackerGrimReaperSprint) - { - ((StatTrackerGrimReaperSprint) tracker).totalDeaths++; - System.out.println(((StatTrackerGrimReaperSprint) tracker).totalDeaths); - tracker.markDirty(); - } -// changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + 1 : 1); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.grimReaper"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalDeaths = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalDeaths = tag.getInteger(BloodMagic.MODID + ".tracker.grimReaper"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(BloodMagic.MODID + ".tracker.grimReaper", totalDeaths); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { double change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalDeaths += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0); @@ -79,23 +58,18 @@ public class StatTrackerGrimReaperSprint extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 10; i++) - { - if (totalDeaths >= deathsRequired[i]) - { + for (int i = 0; i < 10; i++) { + if (totalDeaths >= deathsRequired[i]) { upgradeList.add(new LivingArmourUpgradeGrimReaperSprint(i)); } } @@ -104,28 +78,33 @@ public class StatTrackerGrimReaperSprint extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalDeaths, deathsRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.grimReaper"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeGrimReaperSprint) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeGrimReaperSprint) { int level = upgrade.getUpgradeLevel(); - if (level < deathsRequired.length) - { + if (level < deathsRequired.length) { totalDeaths = Math.max(totalDeaths, deathsRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour) { + StatTracker tracker = armour.getTracker(BloodMagic.MODID + ".tracker.grimReaper"); + if (tracker instanceof StatTrackerGrimReaperSprint) { + ((StatTrackerGrimReaperSprint) tracker).totalDeaths++; + System.out.println(((StatTrackerGrimReaperSprint) tracker).totalDeaths); + tracker.markDirty(); + } +// changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + 1 : 1); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerHealthboost.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerHealthboost.java index a17414aa..a5375402 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerHealthboost.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerHealthboost.java @@ -1,63 +1,49 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeHealthboost; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerHealthboost extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerHealthboost extends StatTracker { + public static HashMap changeMap = new HashMap(); + public static int[] healthedRequired = new int[]{80, 200, 340, 540, 800, 1600, 2800, 5000, 7600, 10000}; public double totalHealthGenned = 0; - public static HashMap changeMap = new HashMap(); - public static int[] healthedRequired = new int[] { 80, 200, 340, 540, 800, 1600, 2800, 5000, 7600, 10000 }; - - public static void incrementCounter(LivingArmour armour, double health) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + health : health); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.health"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalHealthGenned = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalHealthGenned = tag.getDouble(BloodMagic.MODID + ".tracker.health"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setDouble(BloodMagic.MODID + ".tracker.health", totalHealthGenned); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { double change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalHealthGenned += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0d); @@ -72,23 +58,18 @@ public class StatTrackerHealthboost extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 10; i++) - { - if (totalHealthGenned >= healthedRequired[i]) - { + for (int i = 0; i < 10; i++) { + if (totalHealthGenned >= healthedRequired[i]) { upgradeList.add(new LivingArmourUpgradeHealthboost(i)); } } @@ -97,28 +78,27 @@ public class StatTrackerHealthboost extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalHealthGenned, healthedRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.health"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeHealthboost) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeHealthboost) { int level = upgrade.getUpgradeLevel(); - if (level < healthedRequired.length) - { + if (level < healthedRequired.length) { totalHealthGenned = Math.max(totalHealthGenned, healthedRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour, double health) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + health : health); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerJump.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerJump.java index 4a789d1c..9d26e3c8 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerJump.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerJump.java @@ -1,64 +1,51 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeJump; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerJump extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerJump extends StatTracker { public static HashMap changeMap = new HashMap(); - public static int[] jumpsRequired = new int[] { 30, 200, 400, 700, 1100, 1500, 2000, 2800, 3600, 5000 }; //testing + public static int[] jumpsRequired = new int[]{30, 200, 400, 700, 1100, 1500, 2000, 2800, 3600, 5000}; //testing public int totalJumps = 0; - public static void incrementCounter(LivingArmour armour) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + 1 : 1); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.jump"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalJumps = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalJumps = tag.getInteger(BloodMagic.MODID + ".tracker.jump"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(BloodMagic.MODID + ".tracker.jump", totalJumps); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { int change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalJumps += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0); @@ -73,23 +60,18 @@ public class StatTrackerJump extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 10; i++) - { - if (totalJumps >= jumpsRequired[i]) - { + for (int i = 0; i < 10; i++) { + if (totalJumps >= jumpsRequired[i]) { upgradeList.add(new LivingArmourUpgradeJump(i)); } } @@ -98,28 +80,27 @@ public class StatTrackerJump extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalJumps, jumpsRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.jump"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeJump) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeJump) { int level = upgrade.getUpgradeLevel(); - if (level < jumpsRequired.length) - { + if (level < jumpsRequired.length) { totalJumps = Math.max(totalJumps, jumpsRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + 1 : 1); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMeleeDamage.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMeleeDamage.java index 7ecc77d2..e2ee5927 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMeleeDamage.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMeleeDamage.java @@ -1,63 +1,49 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeMeleeDamage; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerMeleeDamage extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerMeleeDamage extends StatTracker { + public static HashMap changeMap = new HashMap(); + public static int[] damageRequired = new int[]{200, 800, 1300, 2500, 3800, 5000, 7000, 9200, 11500, 140000}; public double totalDamageDealt = 0; - public static HashMap changeMap = new HashMap(); - public static int[] damageRequired = new int[] { 200, 800, 1300, 2500, 3800, 5000, 7000, 9200, 11500, 140000 }; - - public static void incrementCounter(LivingArmour armour, double damage) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.meleeDamage"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalDamageDealt = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalDamageDealt = tag.getDouble(BloodMagic.MODID + ".tracker.meleeDamage"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setDouble(BloodMagic.MODID + ".tracker.meleeDamage", totalDamageDealt); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { double change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalDamageDealt += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0d); @@ -72,23 +58,18 @@ public class StatTrackerMeleeDamage extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 10; i++) - { - if (totalDamageDealt >= damageRequired[i]) - { + for (int i = 0; i < 10; i++) { + if (totalDamageDealt >= damageRequired[i]) { upgradeList.add(new LivingArmourUpgradeMeleeDamage(i)); } } @@ -97,28 +78,27 @@ public class StatTrackerMeleeDamage extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalDamageDealt, damageRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.meleeDamage"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeMeleeDamage) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeMeleeDamage) { int level = upgrade.getUpgradeLevel(); - if (level < damageRequired.length) - { + if (level < damageRequired.length) { totalDamageDealt = Math.max(totalDamageDealt, damageRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour, double damage) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMovement.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMovement.java index fcf3b000..26ebe64b 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMovement.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerMovement.java @@ -1,73 +1,64 @@ package WayofTime.bloodmagic.livingArmour.tracker; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.api.livingArmour.StatTracker; +import WayofTime.bloodmagic.livingArmour.LivingArmour; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSpeed; +import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.api.livingArmour.StatTracker; -import WayofTime.bloodmagic.livingArmour.LivingArmour; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSpeed; -import WayofTime.bloodmagic.util.Utils; - -public class StatTrackerMovement extends StatTracker -{ +public class StatTrackerMovement extends StatTracker { public static Map lastPosX = new HashMap(); public static Map lastPosZ = new HashMap(); - public static int[] blocksRequired = new int[] { 200, 1000, 2000, 4000, 7000, 15000, 25000, 35000, 50000, 70000 }; + public static int[] blocksRequired = new int[]{200, 1000, 2000, 4000, 7000, 15000, 25000, 35000, 50000, 70000}; public double totalMovement = 0; @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.movement"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalMovement = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalMovement = tag.getDouble(BloodMagic.MODID + ".tracker.movement"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setDouble(BloodMagic.MODID + ".tracker.movement", totalMovement); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (!lastPosX.containsKey(player)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (!lastPosX.containsKey(player)) { lastPosX.put(player, player.posX); lastPosZ.put(player, player.posZ); return false; } - if (!player.onGround) - { + if (!player.onGround) { return false; } double distanceTravelled = Math.sqrt(Math.pow(lastPosX.get(player) - player.posX, 2) + Math.pow(lastPosZ.get(player) - player.posZ, 2)); - if (distanceTravelled > 0.0001 && distanceTravelled < 2) - { + if (distanceTravelled > 0.0001 && distanceTravelled < 2) { totalMovement += distanceTravelled; lastPosX.put(player, player.posX); @@ -85,20 +76,16 @@ public class StatTrackerMovement extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 10; i++) - { - if (totalMovement >= blocksRequired[i]) - { + for (int i = 0; i < 10; i++) { + if (totalMovement >= blocksRequired[i]) { upgradeList.add(new LivingArmourUpgradeSpeed(i)); } } @@ -107,25 +94,20 @@ public class StatTrackerMovement extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalMovement, blocksRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.movement"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeSpeed) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeSpeed) { int level = upgrade.getUpgradeLevel(); - if (level < blocksRequired.length) - { + if (level < blocksRequired.length) { totalMovement = Math.max(totalMovement, blocksRequired[level]); this.markDirty(); } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerNightSight.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerNightSight.java index fdd9ad6b..1cd463bd 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerNightSight.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerNightSight.java @@ -1,72 +1,57 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.MobEffects; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeNightSight; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.MobEffects; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerNightSight extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerNightSight extends StatTracker { + public static HashMap changeMap = new HashMap(); + public static int[] damageRequired = new int[]{0, 200, 800, 1300, 2500, 3800, 5000, 7000, 9200, 11500}; + public static int neededNightVision = 3 * 60 * 20; public double totalDamageDealt = 0; public int totalNightVision = 0; - public static HashMap changeMap = new HashMap(); - public static int[] damageRequired = new int[] { 0, 200, 800, 1300, 2500, 3800, 5000, 7000, 9200, 11500 }; - - public static int neededNightVision = 3 * 60 * 20; - - public static void incrementCounter(LivingArmour armour, double damage) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.nightSight"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalDamageDealt = 0; this.totalNightVision = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalDamageDealt = tag.getDouble(BloodMagic.MODID + ".tracker.nightSight"); totalNightVision = tag.getInteger(BloodMagic.MODID + ".tracker.nightSightVision"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setDouble(BloodMagic.MODID + ".tracker.nightSight", totalDamageDealt); tag.setInteger(BloodMagic.MODID + ".tracker.nightSightVision", totalNightVision); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { boolean test = false; - if (changeMap.containsKey(livingArmour)) - { + if (changeMap.containsKey(livingArmour)) { double change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalDamageDealt += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0d); @@ -75,14 +60,12 @@ public class StatTrackerNightSight extends StatTracker } } - if (world.getLight(player.getPosition()) <= 9 && player.isPotionActive(MobEffects.NIGHT_VISION)) - { + if (world.getLight(player.getPosition()) <= 9 && player.isPotionActive(MobEffects.NIGHT_VISION)) { totalNightVision++; test = true; } - if (test) - { + if (test) { this.markDirty(); } @@ -90,28 +73,22 @@ public class StatTrackerNightSight extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - if (totalNightVision < neededNightVision) - { + if (totalNightVision < neededNightVision) { return upgradeList; } - for (int i = 0; i < 10; i++) - { - if (totalDamageDealt >= damageRequired[i]) - { + for (int i = 0; i < 10; i++) { + if (totalDamageDealt >= damageRequired[i]) { upgradeList.add(new LivingArmourUpgradeNightSight(i)); } } @@ -120,29 +97,28 @@ public class StatTrackerNightSight extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalDamageDealt, damageRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.nightSight"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeNightSight) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeNightSight) { int level = upgrade.getUpgradeLevel(); - if (level < damageRequired.length) - { + if (level < damageRequired.length) { totalDamageDealt = Math.max(totalDamageDealt, damageRequired[level]); totalNightVision = neededNightVision; this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour, double damage) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPhysicalProtect.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPhysicalProtect.java index a4f06f95..11580b8f 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPhysicalProtect.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPhysicalProtect.java @@ -1,63 +1,49 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradePhysicalProtect; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerPhysicalProtect extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerPhysicalProtect extends StatTracker { + public static HashMap changeMap = new HashMap(); + public static int[] damageRequired = new int[]{30, 50, 80, 140, 200, 300, 400, 500, 650, 800}; public int totalDamage = 0; - public static HashMap changeMap = new HashMap(); - public static int[] damageRequired = new int[] { 30, 50, 80, 140, 200, 300, 400, 500, 650, 800 }; - - public static void incrementCounter(LivingArmour armour, double damage) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.physicalProtect"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalDamage = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalDamage = tag.getInteger(BloodMagic.MODID + ".tracker.physicalProtect"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(BloodMagic.MODID + ".tracker.physicalProtect", totalDamage); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { double change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalDamage += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0d); @@ -72,23 +58,18 @@ public class StatTrackerPhysicalProtect extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 10; i++) - { - if (totalDamage >= damageRequired[i]) - { + for (int i = 0; i < 10; i++) { + if (totalDamage >= damageRequired[i]) { upgradeList.add(new LivingArmourUpgradePhysicalProtect(i)); } } @@ -97,28 +78,27 @@ public class StatTrackerPhysicalProtect extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalDamage, damageRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.physicalProtect"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradePhysicalProtect) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradePhysicalProtect) { int level = upgrade.getUpgradeLevel(); - if (level < damageRequired.length) - { + if (level < damageRequired.length) { totalDamage = Math.max(totalDamage, damageRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour, double damage) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPoison.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPoison.java index 528f2eef..dd76abe2 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPoison.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPoison.java @@ -1,54 +1,46 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.MobEffects; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradePoisonResist; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.MobEffects; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerPoison extends StatTracker -{ +import java.util.ArrayList; +import java.util.List; + +public class StatTrackerPoison extends StatTracker { + public static int[] poisonTicksRequired = new int[]{60 * 20, 3 * 60 * 20, 10 * 60 * 20, 20 * 60 * 20, 25 * 60 * 20}; public int totalPoisonTicks = 0; - public static int[] poisonTicksRequired = new int[] { 60 * 20, 3 * 60 * 20, 10 * 60 * 20, 20 * 60 * 20, 25 * 60 * 20 }; - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.poison"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalPoisonTicks = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalPoisonTicks = tag.getInteger(BloodMagic.MODID + ".tracker.poison"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(BloodMagic.MODID + ".tracker.poison", totalPoisonTicks); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (player.isPotionActive(MobEffects.POISON)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (player.isPotionActive(MobEffects.POISON)) { totalPoisonTicks++; this.markDirty(); return true; @@ -58,20 +50,16 @@ public class StatTrackerPoison extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 5; i++) - { - if (totalPoisonTicks >= poisonTicksRequired[i]) - { + for (int i = 0; i < 5; i++) { + if (totalPoisonTicks >= poisonTicksRequired[i]) { upgradeList.add(new LivingArmourUpgradePoisonResist(i)); } } @@ -80,25 +68,20 @@ public class StatTrackerPoison extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalPoisonTicks, poisonTicksRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.poisonResist"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradePoisonResist) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradePoisonResist) { int level = upgrade.getUpgradeLevel(); - if (level < poisonTicksRequired.length) - { + if (level < poisonTicksRequired.length) { totalPoisonTicks = Math.max(totalPoisonTicks, poisonTicksRequired[level]); this.markDirty(); } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerRepairing.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerRepairing.java index c8457c24..d3929d36 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerRepairing.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerRepairing.java @@ -1,63 +1,49 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeRepairing; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerRepairing extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerRepairing extends StatTracker { + public static HashMap changeMap = new HashMap(); + public static int[] damageRequired = new int[]{500}; public double totalDamage = 0; - public static HashMap changeMap = new HashMap(); - public static int[] damageRequired = new int[] { 500 }; - - public static void incrementCounter(LivingArmour armour, int receivedDamage) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + receivedDamage : receivedDamage); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.repair"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalDamage = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalDamage = tag.getDouble(BloodMagic.MODID + ".tracker.repair"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setDouble(BloodMagic.MODID + ".tracker.repair", totalDamage); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { double change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalDamage += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0); @@ -72,23 +58,18 @@ public class StatTrackerRepairing extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 1; i++) - { - if (totalDamage >= damageRequired[i]) - { + for (int i = 0; i < 1; i++) { + if (totalDamage >= damageRequired[i]) { upgradeList.add(new LivingArmourUpgradeRepairing(i)); } } @@ -97,28 +78,27 @@ public class StatTrackerRepairing extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalDamage, damageRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.repair"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeRepairing) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeRepairing) { int level = upgrade.getUpgradeLevel(); - if (level < damageRequired.length) - { + if (level < damageRequired.length) { totalDamage = Math.max(totalDamage, damageRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour, int receivedDamage) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + receivedDamage : receivedDamage); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSelfSacrifice.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSelfSacrifice.java index 26448f93..fe7b7258 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSelfSacrifice.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSelfSacrifice.java @@ -1,64 +1,51 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerSelfSacrifice extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerSelfSacrifice extends StatTracker { public static HashMap changeMap = new HashMap(); - public static int[] sacrificesRequired = new int[] { 30, 200, 400, 700, 1100, 1500, 2000, 2800, 3600, 5000 }; //testing + public static int[] sacrificesRequired = new int[]{30, 200, 400, 700, 1100, 1500, 2000, 2800, 3600, 5000}; //testing public int totalSacrifices = 0; - public static void incrementCounter(LivingArmour armour, int hearts) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + hearts : hearts); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.selfSacrifice"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalSacrifices = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalSacrifices = tag.getInteger(BloodMagic.MODID + ".tracker.selfSacrifice"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(BloodMagic.MODID + ".tracker.selfSacrifice", totalSacrifices); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { int change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalSacrifices += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0); @@ -73,23 +60,18 @@ public class StatTrackerSelfSacrifice extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 10; i++) - { - if (totalSacrifices >= sacrificesRequired[i]) - { + for (int i = 0; i < 10; i++) { + if (totalSacrifices >= sacrificesRequired[i]) { upgradeList.add(new LivingArmourUpgradeSelfSacrifice(i)); } } @@ -98,28 +80,27 @@ public class StatTrackerSelfSacrifice extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalSacrifices, sacrificesRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.selfSacrifice"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeSelfSacrifice) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeSelfSacrifice) { int level = upgrade.getUpgradeLevel(); - if (level < sacrificesRequired.length) - { + if (level < sacrificesRequired.length) { totalSacrifices = Math.max(totalSacrifices, sacrificesRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour, int hearts) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + hearts : hearts); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSolarPowered.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSolarPowered.java index 7ff2a4d7..8e2ecb20 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSolarPowered.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSolarPowered.java @@ -1,63 +1,49 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSolarPowered; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerSolarPowered extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerSolarPowered extends StatTracker { + public static HashMap changeMap = new HashMap(); + public static int[] healthedRequired = new int[]{70, 150, 300, 500, 700, 1400, 2400, 4000, 7000, 9000}; public double totalHealthGenned = 0; - public static HashMap changeMap = new HashMap(); - public static int[] healthedRequired = new int[] { 70, 150, 300, 500, 700, 1400, 2400, 4000, 7000, 9000 }; - - public static void incrementCounter(LivingArmour armour, double health) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + health : health); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.solarPowered"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalHealthGenned = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalHealthGenned = tag.getDouble(BloodMagic.MODID + ".tracker.solarPowered"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setDouble(BloodMagic.MODID + ".tracker.solarPowered", totalHealthGenned); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { double change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalHealthGenned += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0d); @@ -72,23 +58,18 @@ public class StatTrackerSolarPowered extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 10; i++) - { - if (totalHealthGenned >= healthedRequired[i]) - { + for (int i = 0; i < 10; i++) { + if (totalHealthGenned >= healthedRequired[i]) { upgradeList.add(new LivingArmourUpgradeSolarPowered(i)); } } @@ -97,28 +78,27 @@ public class StatTrackerSolarPowered extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalHealthGenned, healthedRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.solarPowered"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeSolarPowered) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeSolarPowered) { int level = upgrade.getUpgradeLevel(); - if (level < healthedRequired.length) - { + if (level < healthedRequired.length) { totalHealthGenned = Math.max(totalHealthGenned, healthedRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour, double health) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + health : health); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSprintAttack.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSprintAttack.java index a587a494..ae0451e9 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSprintAttack.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSprintAttack.java @@ -1,63 +1,49 @@ package WayofTime.bloodmagic.livingArmour.tracker; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSprintAttack; import WayofTime.bloodmagic.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; -public class StatTrackerSprintAttack extends StatTracker -{ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class StatTrackerSprintAttack extends StatTracker { + public static HashMap changeMap = new HashMap(); + public static int[] damageRequired = new int[]{200, 800, 1300, 2500, 3800}; public double totalDamageDealt = 0; - public static HashMap changeMap = new HashMap(); - public static int[] damageRequired = new int[] { 200, 800, 1300, 2500, 3800 }; - - public static void incrementCounter(LivingArmour armour, double damage) - { - changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); - } - @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.sprintAttack"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalDamageDealt = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalDamageDealt = tag.getDouble(BloodMagic.MODID + ".tracker.sprintAttack"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setDouble(BloodMagic.MODID + ".tracker.sprintAttack", totalDamageDealt); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { double change = Math.abs(changeMap.get(livingArmour)); - if (change > 0) - { + if (change > 0) { totalDamageDealt += Math.abs(changeMap.get(livingArmour)); changeMap.put(livingArmour, 0d); @@ -72,23 +58,18 @@ public class StatTrackerSprintAttack extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour)) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour)) { changeMap.remove(livingArmour); } } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - for (int i = 0; i < 5; i++) - { - if (totalDamageDealt >= damageRequired[i]) - { + for (int i = 0; i < 5; i++) { + if (totalDamageDealt >= damageRequired[i]) { upgradeList.add(new LivingArmourUpgradeSprintAttack(i)); } } @@ -97,28 +78,27 @@ public class StatTrackerSprintAttack extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { return Utils.calculateStandardProgress(totalDamageDealt, damageRequired, currentLevel); } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.sprintAttack"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeSprintAttack) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeSprintAttack) { int level = upgrade.getUpgradeLevel(); - if (level < damageRequired.length) - { + if (level < damageRequired.length) { totalDamageDealt = Math.max(totalDamageDealt, damageRequired[level]); this.markDirty(); } } } + + public static void incrementCounter(LivingArmour armour, double damage) { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerStepAssist.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerStepAssist.java index d102438f..438f5d59 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerStepAssist.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerStepAssist.java @@ -1,21 +1,20 @@ package WayofTime.bloodmagic.livingArmour.tracker; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.api.livingArmour.StatTracker; +import WayofTime.bloodmagic.livingArmour.LivingArmour; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeStepAssist; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.api.livingArmour.StatTracker; -import WayofTime.bloodmagic.livingArmour.LivingArmour; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeStepAssist; - -public class StatTrackerStepAssist extends StatTracker -{ +public class StatTrackerStepAssist extends StatTracker { public static Map lastPosX = new HashMap(); public static Map lastPosZ = new HashMap(); @@ -24,49 +23,41 @@ public class StatTrackerStepAssist extends StatTracker public double totalMovement = 0; @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".tracker.stepAssist"; } @Override - public void resetTracker() - { + public void resetTracker() { this.totalMovement = 0; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { totalMovement = tag.getDouble(BloodMagic.MODID + ".tracker.stepAssist"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setDouble(BloodMagic.MODID + ".tracker.stepAssist", totalMovement); } @Override - public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) - { - if (!lastPosX.containsKey(player)) - { + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { + if (!lastPosX.containsKey(player)) { lastPosX.put(player, player.posX); lastPosZ.put(player, player.posZ); return false; } - if (!player.onGround || player.stepHeight < 1) - { + if (!player.onGround || player.stepHeight < 1) { return false; } double distanceTravelled = Math.sqrt(Math.pow(lastPosX.get(player) - player.posX, 2) + Math.pow(lastPosZ.get(player) - player.posZ, 2)); - if (distanceTravelled > 0.0001 && distanceTravelled < 2) - { + if (distanceTravelled > 0.0001 && distanceTravelled < 2) { double previousMovement = totalMovement; totalMovement += distanceTravelled; @@ -85,18 +76,15 @@ public class StatTrackerStepAssist extends StatTracker } @Override - public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) - { + public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour) { } @Override - public List getUpgrades() - { + public List getUpgrades() { List upgradeList = new ArrayList(); - if (totalMovement >= blocksRequired) - { + if (totalMovement >= blocksRequired) { upgradeList.add(new LivingArmourUpgradeStepAssist(0)); } @@ -104,8 +92,7 @@ public class StatTrackerStepAssist extends StatTracker } @Override - public double getProgress(LivingArmour livingArmour, int currentLevel) - { + public double getProgress(LivingArmour livingArmour, int currentLevel) { if (currentLevel == 1) return 1.0D; @@ -113,16 +100,13 @@ public class StatTrackerStepAssist extends StatTracker } @Override - public boolean providesUpgrade(String key) - { + public boolean providesUpgrade(String key) { return key.equals(BloodMagic.MODID + ".upgrade.stepAssist"); } @Override - public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) - { - if (upgrade instanceof LivingArmourUpgradeStepAssist) - { + public void onArmourUpgradeAdded(LivingArmourUpgrade upgrade) { + if (upgrade instanceof LivingArmourUpgradeStepAssist) { totalMovement = Math.max(totalMovement, blocksRequired); this.markDirty(); } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeArrowProtect.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeArrowProtect.java index b5567bea..48d96ee4 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeArrowProtect.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeArrowProtect.java @@ -1,26 +1,22 @@ package WayofTime.bloodmagic.livingArmour.upgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeArrowProtect extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 4, 9, 16, 30, 60, 90, 125, 165, 210, 250 }; - public static final double[] protectionLevel = new double[] { 0.1, 0.3, 0.4, 0.5, 0.6, 0.7, 0.75, 0.77, 0.80, 0.83 }; +public class LivingArmourUpgradeArrowProtect extends LivingArmourUpgrade { + public static final int[] costs = new int[]{4, 9, 16, 30, 60, 90, 125, 165, 210, 250}; + public static final double[] protectionLevel = new double[]{0.1, 0.3, 0.4, 0.5, 0.6, 0.7, 0.75, 0.77, 0.80, 0.83}; - public LivingArmourUpgradeArrowProtect(int level) - { + public LivingArmourUpgradeArrowProtect(int level) { super(level); } @Override - public double getArmourProtection(EntityLivingBase wearer, DamageSource source) - { - if (source.isProjectile()) - { + public double getArmourProtection(EntityLivingBase wearer, DamageSource source) { + if (source.isProjectile()) { return protectionLevel[this.level]; } @@ -28,38 +24,32 @@ public class LivingArmourUpgradeArrowProtect extends LivingArmourUpgrade } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.arrowProtect"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; // Set to here until I can add more upgrades to it. } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "arrowProtect"; } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeArrowShot.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeArrowShot.java index bb447592..95f9c7b4 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeArrowShot.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeArrowShot.java @@ -7,60 +7,50 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -public class LivingArmourUpgradeArrowShot extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 20, 50, 90, 160, 290 }; - public static final int[] extraArrow = new int[] { 1, 2, 3, 4, 5 }; +public class LivingArmourUpgradeArrowShot extends LivingArmourUpgrade { + public static final int[] costs = new int[]{20, 50, 90, 160, 290}; + public static final int[] extraArrow = new int[]{1, 2, 3, 4, 5}; - public LivingArmourUpgradeArrowShot(int level) - { + public LivingArmourUpgradeArrowShot(int level) { super(level); } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.arrowShot"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 5; // Set to here until I can add more upgrades to it. } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "arrowShot"; } - public int getExtraArrows() - { + public int getExtraArrows() { return extraArrow[this.level]; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeCriticalStrike.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeCriticalStrike.java index 039b85a1..75ffd6b0 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeCriticalStrike.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeCriticalStrike.java @@ -1,74 +1,63 @@ package WayofTime.bloodmagic.livingArmour.upgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeCriticalStrike extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 5, 12, 22, 35, 49 }; - public static final double[] damageBoost = new double[] { 0.1, 0.2, 0.3, 0.4, 0.5 }; +public class LivingArmourUpgradeCriticalStrike extends LivingArmourUpgrade { + public static final int[] costs = new int[]{5, 12, 22, 35, 49}; + public static final double[] damageBoost = new double[]{0.1, 0.2, 0.3, 0.4, 0.5}; - public LivingArmourUpgradeCriticalStrike(int level) - { + public LivingArmourUpgradeCriticalStrike(int level) { super(level); } @Override - public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) - { + public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) { boolean flag = wearer.fallDistance > 0.0F && !wearer.onGround && !wearer.isOnLadder() && !wearer.isInWater() && !wearer.isPotionActive(MobEffects.BLINDNESS) && !wearer.isRiding() && !wearer.isSprinting(); - if (flag) - { + if (flag) { return getDamageModifier() * damage; } return 0; } - public double getDamageModifier() - { + public double getDamageModifier() { return damageBoost[this.level]; } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.criticalStrike"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 5; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "criticalStrike"; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeDigging.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeDigging.java index 059f6bd0..1ba86bcb 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeDigging.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeDigging.java @@ -1,90 +1,75 @@ package WayofTime.bloodmagic.livingArmour.upgrade; -import java.util.HashMap; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.livingArmour.LivingArmour; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.livingArmour.LivingArmour; -public class LivingArmourUpgradeDigging extends LivingArmourUpgrade -{ +import java.util.HashMap; + +public class LivingArmourUpgradeDigging extends LivingArmourUpgrade { + public static final int[] costs = new int[]{5, 10, 18, 32, 60, 90, 140, 180, 240, 300}; + public static final int[] digSpeedTime = new int[]{0, 50, 60, 100, 100, 100, 100, 150, 150, 150}; + public static final int[] digSpeedLevel = new int[]{0, 0, 0, 1, 1, 1, 1, 1, 2, 2}; + public static final double[] digSpeedModifier = new double[]{1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.8, 2, 2.2, 2.5}; public static HashMap changeMap = new HashMap(); - public static final int[] costs = new int[] { 5, 10, 18, 32, 60, 90, 140, 180, 240, 300 }; - public static final int[] digSpeedTime = new int[] { 0, 50, 60, 100, 100, 100, 100, 150, 150, 150 }; - public static final int[] digSpeedLevel = new int[] { 0, 0, 0, 1, 1, 1, 1, 1, 2, 2 }; - - public static final double[] digSpeedModifier = new double[] { 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.8, 2, 2.2, 2.5 }; - - public static void hasDug(LivingArmour armour) - { - changeMap.put(armour, true); - } - - public LivingArmourUpgradeDigging(int level) - { + public LivingArmourUpgradeDigging(int level) { super(level); } @Override - public double getMiningSpeedModifier(EntityPlayer player) - { + public double getMiningSpeedModifier(EntityPlayer player) { return digSpeedModifier[this.level]; } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { - if (changeMap.containsKey(livingArmour) && changeMap.get(livingArmour)) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { + if (changeMap.containsKey(livingArmour) && changeMap.get(livingArmour)) { changeMap.put(livingArmour, false); - if (digSpeedTime[this.level] > 0) - { + if (digSpeedTime[this.level] > 0) { player.addPotionEffect(new PotionEffect(MobEffects.SPEED, digSpeedTime[this.level], digSpeedLevel[this.level], false, false)); } } } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.digging"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "digging"; } + + public static void hasDug(LivingArmour armour) { + changeMap.put(armour, true); + } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeElytra.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeElytra.java index 2cd24cb8..7908f9d8 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeElytra.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeElytra.java @@ -7,54 +7,45 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -public class LivingArmourUpgradeElytra extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 20 }; +public class LivingArmourUpgradeElytra extends LivingArmourUpgrade { + public static final int[] costs = new int[]{20}; - public LivingArmourUpgradeElytra(int level) - { + public LivingArmourUpgradeElytra(int level) { super(level); } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.elytra"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 1; // Set to here until I can add more upgrades to it. } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "elytra"; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeExperience.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeExperience.java index 0bf1fd38..83a98ede 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeExperience.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeExperience.java @@ -4,54 +4,45 @@ import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.nbt.NBTTagCompound; -public class LivingArmourUpgradeExperience extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 7, 13, 22, 40, 65, 90, 130, 180, 250, 350 }; - public static final double[] experienceModifier = new double[] { 0.15, 0.3, 0.45, 0.6, 0.75, 0.9, 1.05, 1.2, 1.35, 1.5 }; +public class LivingArmourUpgradeExperience extends LivingArmourUpgrade { + public static final int[] costs = new int[]{7, 13, 22, 40, 65, 90, 130, 180, 250, 350}; + public static final double[] experienceModifier = new double[]{0.15, 0.3, 0.45, 0.6, 0.75, 0.9, 1.05, 1.2, 1.35, 1.5}; - public LivingArmourUpgradeExperience(int level) - { + public LivingArmourUpgradeExperience(int level) { super(level); } - public double getExperienceModifier() - { + public double getExperienceModifier() { return experienceModifier[this.level]; } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.experienced"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; // Set to here until I can add more upgrades to it. } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "experienced"; } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFallProtect.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFallProtect.java index d5da14a8..d00394dd 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFallProtect.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFallProtect.java @@ -6,21 +6,17 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; -public class LivingArmourUpgradeFallProtect extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 2, 5, 9, 15, 25 }; - public static final double[] protectionLevel = new double[] { 0.2, 0.4, 0.6, 0.8, 1 }; +public class LivingArmourUpgradeFallProtect extends LivingArmourUpgrade { + public static final int[] costs = new int[]{2, 5, 9, 15, 25}; + public static final double[] protectionLevel = new double[]{0.2, 0.4, 0.6, 0.8, 1}; - public LivingArmourUpgradeFallProtect(int level) - { + public LivingArmourUpgradeFallProtect(int level) { super(level); } @Override - public double getArmourProtection(EntityLivingBase wearer, DamageSource source) - { - if (source.equals(DamageSource.FALL)) - { + public double getArmourProtection(EntityLivingBase wearer, DamageSource source) { + if (source.equals(DamageSource.FALL)) { return protectionLevel[this.level]; } @@ -28,38 +24,32 @@ public class LivingArmourUpgradeFallProtect extends LivingArmourUpgrade } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.fallProtect"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 5; // Set to here until I can add more upgrades to it. } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "fallProtect"; } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFireResist.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFireResist.java index 05f94c2e..e76812e1 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFireResist.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFireResist.java @@ -1,80 +1,69 @@ package WayofTime.bloodmagic.livingArmour.upgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class LivingArmourUpgradeFireResist extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 2, 6, 14, 25, 40 }; - public static final int[] fireCooldownTime = new int[] { 5 * 60 * 20, 5 * 60 * 20, 4 * 60 * 20, 3 * 60 * 20, 2 * 60 * 20 }; - public static final int[] fireResistDuration = new int[] { 30 * 20, 30 * 20, 40 * 20, 50 * 20, 60 * 20 }; +public class LivingArmourUpgradeFireResist extends LivingArmourUpgrade { + public static final int[] costs = new int[]{2, 6, 14, 25, 40}; + public static final int[] fireCooldownTime = new int[]{5 * 60 * 20, 5 * 60 * 20, 4 * 60 * 20, 3 * 60 * 20, 2 * 60 * 20}; + public static final int[] fireResistDuration = new int[]{30 * 20, 30 * 20, 40 * 20, 50 * 20, 60 * 20}; public int fireCooldown = 0; - public LivingArmourUpgradeFireResist(int level) - { + public LivingArmourUpgradeFireResist(int level) { super(level); } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { - if (player.isBurning() && fireCooldown <= 0) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { + if (player.isBurning() && fireCooldown <= 0) { player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, fireResistDuration[this.level])); fireCooldown = fireCooldownTime[this.level]; player.sendStatusMessage(new TextComponentString(TextHelper.localizeEffect(chatBase + "fireRemove")), true); - } else if (fireCooldown > 0) - { + } else if (fireCooldown > 0) { fireCooldown--; } } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.fireResist"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 5; // Set to here until I can add more upgrades to it. } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(Constants.NBT.UPGRADE_FIRE_TIMER, fireCooldown); } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { fireCooldown = tag.getInteger(Constants.NBT.UPGRADE_FIRE_TIMER); } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "fireResist"; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeGraveDigger.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeGraveDigger.java index 34fcbc24..e7c285e9 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeGraveDigger.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeGraveDigger.java @@ -1,72 +1,61 @@ package WayofTime.bloodmagic.livingArmour.upgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemSpade; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeGraveDigger extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 5, 12, 20, 35, 49, 78, 110, 160, 215, 320 }; - public static final double[] damageBoost = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; +public class LivingArmourUpgradeGraveDigger extends LivingArmourUpgrade { + public static final int[] costs = new int[]{5, 12, 20, 35, 49, 78, 110, 160, 215, 320}; + public static final double[] damageBoost = new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; - public LivingArmourUpgradeGraveDigger(int level) - { + public LivingArmourUpgradeGraveDigger(int level) { super(level); } @Override - public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) - { - if (!weapon.isEmpty() && weapon.getItem() instanceof ItemSpade) - { + public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) { + if (!weapon.isEmpty() && weapon.getItem() instanceof ItemSpade) { return getDamageModifier(); } return 0; } - public double getDamageModifier() - { + public double getDamageModifier() { return damageBoost[this.level]; } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.graveDigger"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "graveDigger"; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeGrimReaperSprint.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeGrimReaperSprint.java index 1dde6181..e6dc11ad 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeGrimReaperSprint.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeGrimReaperSprint.java @@ -1,91 +1,78 @@ package WayofTime.bloodmagic.livingArmour.upgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class LivingArmourUpgradeGrimReaperSprint extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 20, 50, 130, 270, 450, 580, 700, 800, 900, 1000 }; - public static final int[] rebirthDelay = new int[] { 20 * 60 * 60, 20 * 60 * 50, 20 * 60 * 45, 20 * 60 * 40, 20 * 60 * 30, 20 * 60 * 25, 20 * 60 * 15, 20 * 60 * 10, 20 * 60 * 5, 20 * 60 }; - public static final int[] strengthDuration = new int[] { 0, 0, 100, 100, 200, 200, 200, 300, 300, 400 }; - public static final int[] strengthValue = new int[] { 0, 0, 0, 0, 0, 1, 1, 2, 2, 3 }; - public static final int[] resistanceDuration = new int[] { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 }; - public static final int[] resistanceValue = new int[] { 0, 0, 0, 0, 0, 1, 1, 2, 2, 3 }; - public static final float[] healthOnRevive = new float[] { 0.2f, 0.2f, 0.3f, 0.3f, 0.4f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f }; +public class LivingArmourUpgradeGrimReaperSprint extends LivingArmourUpgrade { + public static final int[] costs = new int[]{20, 50, 130, 270, 450, 580, 700, 800, 900, 1000}; + public static final int[] rebirthDelay = new int[]{20 * 60 * 60, 20 * 60 * 50, 20 * 60 * 45, 20 * 60 * 40, 20 * 60 * 30, 20 * 60 * 25, 20 * 60 * 15, 20 * 60 * 10, 20 * 60 * 5, 20 * 60}; + public static final int[] strengthDuration = new int[]{0, 0, 100, 100, 200, 200, 200, 300, 300, 400}; + public static final int[] strengthValue = new int[]{0, 0, 0, 0, 0, 1, 1, 2, 2, 3}; + public static final int[] resistanceDuration = new int[]{100, 100, 100, 100, 100, 100, 100, 100, 100, 100}; + public static final int[] resistanceValue = new int[]{0, 0, 0, 0, 0, 1, 1, 2, 2, 3}; + public static final float[] healthOnRevive = new float[]{0.2f, 0.2f, 0.3f, 0.3f, 0.4f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f}; public int deathTimer = 0; - public LivingArmourUpgradeGrimReaperSprint(int level) - { + public LivingArmourUpgradeGrimReaperSprint(int level) { super(level); } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { - if (deathTimer > 0) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { + if (deathTimer > 0) { deathTimer--; } } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.grimReaper"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { deathTimer = tag.getInteger(BloodMagic.MODID + ".tracker.grimReaper"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(BloodMagic.MODID + ".tracker.grimReaper", deathTimer); } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "grimReaper"; } - public void applyEffectOnRebirth(EntityPlayer player) - { + public void applyEffectOnRebirth(EntityPlayer player) { player.setHealth(player.getMaxHealth() * healthOnRevive[this.level]); int strDur = strengthDuration[this.level]; - if (strDur > 0) - { + if (strDur > 0) { player.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, strDur, strengthValue[this.level])); } int resDur = resistanceDuration[this.level]; - if (resDur > 0) - { + if (resDur > 0) { player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, resDur, resistanceValue[this.level])); } @@ -93,8 +80,7 @@ public class LivingArmourUpgradeGrimReaperSprint extends LivingArmourUpgrade player.sendStatusMessage(new TextComponentString(TextHelper.localizeEffect(chatBase + "grimReaper")), true); } - public boolean canSavePlayer(EntityPlayer player) - { + public boolean canSavePlayer(EntityPlayer player) { return deathTimer <= 0; } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeHealthboost.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeHealthboost.java index ee231a07..19181cda 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeHealthboost.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeHealthboost.java @@ -14,25 +14,21 @@ import org.apache.commons.codec.binary.StringUtils; import java.util.UUID; -public class LivingArmourUpgradeHealthboost extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 5, 12, 20, 35, 49, 78, 110, 160, 215, 320 }; - public static final int[] healthModifier = new int[] { 4, 8, 12, 16, 20, 26, 32, 38, 44, 50 }; +public class LivingArmourUpgradeHealthboost extends LivingArmourUpgrade { + public static final int[] costs = new int[]{5, 12, 20, 35, 49, 78, 110, 160, 215, 320}; + public static final int[] healthModifier = new int[]{4, 8, 12, 16, 20, 26, 32, 38, 44, 50}; - public LivingArmourUpgradeHealthboost(int level) - { + public LivingArmourUpgradeHealthboost(int level) { super(level); } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { } @Override - public Multimap getAttributeModifiers() - { + public Multimap getAttributeModifiers() { Multimap modifierMap = HashMultimap.create(); String name = getUniqueIdentifier() + "-HealthModifier1"; @@ -42,38 +38,32 @@ public class LivingArmourUpgradeHealthboost extends LivingArmourUpgrade } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.health"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "health"; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeJump.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeJump.java index 876a94f3..dd831b75 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeJump.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeJump.java @@ -1,75 +1,63 @@ package WayofTime.bloodmagic.livingArmour.upgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeJump extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 3, 6, 11, 23, 37, 50, 70, 100, 140, 200 }; - public static final double[] jumpModifier = new double[] { 0.10, 0.2, 0.3, 0.4, 0.5, 0.7, 0.9, 1.1, 1.3, 1.5 }; - public static final double[] fallModifier = new double[] { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.75, 0.8, 0.85 }; +public class LivingArmourUpgradeJump extends LivingArmourUpgrade { + public static final int[] costs = new int[]{3, 6, 11, 23, 37, 50, 70, 100, 140, 200}; + public static final double[] jumpModifier = new double[]{0.10, 0.2, 0.3, 0.4, 0.5, 0.7, 0.9, 1.1, 1.3, 1.5}; + public static final double[] fallModifier = new double[]{0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.75, 0.8, 0.85}; - public LivingArmourUpgradeJump(int level) - { + public LivingArmourUpgradeJump(int level) { super(level); } - public double getJumpModifier() - { + public double getJumpModifier() { return jumpModifier[this.level]; } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.jump"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; // Set to here until I can add more upgrades to it. } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { - if (!world.isRemote) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { + if (!world.isRemote) { double motionY = player.motionY; - if (motionY < 0) - { + if (motionY < 0) { player.fallDistance = (float) Math.max(0, player.fallDistance + motionY * fallModifier[this.level]); } } } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "jump"; } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeKnockbackResist.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeKnockbackResist.java index 461b7e04..84363286 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeKnockbackResist.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeKnockbackResist.java @@ -11,27 +11,23 @@ import org.apache.commons.codec.binary.StringUtils; import java.util.UUID; -public class LivingArmourUpgradeKnockbackResist extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 3, 7, 13, 26, 42 }; - public static final double[] kbModifier = new double[] { 0.2, 0.4, 0.6, 0.8, 1.0 }; - public static final int[] healthModifier = new int[] { 0, 0, 0, 4, 10 }; +public class LivingArmourUpgradeKnockbackResist extends LivingArmourUpgrade { + public static final int[] costs = new int[]{3, 7, 13, 26, 42}; + public static final double[] kbModifier = new double[]{0.2, 0.4, 0.6, 0.8, 1.0}; + public static final int[] healthModifier = new int[]{0, 0, 0, 4, 10}; - public LivingArmourUpgradeKnockbackResist(int level) - { + public LivingArmourUpgradeKnockbackResist(int level) { super(level); } @Override - public Multimap getAttributeModifiers() - { + public Multimap getAttributeModifiers() { Multimap modifierMap = HashMultimap.create(); String name = getUniqueIdentifier() + "-KnockbackModifier1"; modifierMap.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(UUID.nameUUIDFromBytes(StringUtils.getBytesUtf8(name)), "KnockbackModifier1", kbModifier[this.level], 0)); - if (healthModifier[this.level] > 0) - { + if (healthModifier[this.level] > 0) { name = getUniqueIdentifier() + "-HealthModifier1"; modifierMap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(UUID.nameUUIDFromBytes(StringUtils.getBytesUtf8(name)), "HealthModifier1", healthModifier[this.level], 0)); } @@ -40,38 +36,32 @@ public class LivingArmourUpgradeKnockbackResist extends LivingArmourUpgrade } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.knockback"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 5; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "knockback"; } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeMeleeDamage.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeMeleeDamage.java index 44ed0210..5b59193e 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeMeleeDamage.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeMeleeDamage.java @@ -14,25 +14,21 @@ import org.apache.commons.codec.binary.StringUtils; import java.util.UUID; -public class LivingArmourUpgradeMeleeDamage extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 5, 12, 20, 35, 49, 78, 110, 160, 215, 320 }; - public static final double[] meleeDamage = new double[] { 0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6, 7 }; +public class LivingArmourUpgradeMeleeDamage extends LivingArmourUpgrade { + public static final int[] costs = new int[]{5, 12, 20, 35, 49, 78, 110, 160, 215, 320}; + public static final double[] meleeDamage = new double[]{0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6, 7}; - public LivingArmourUpgradeMeleeDamage(int level) - { + public LivingArmourUpgradeMeleeDamage(int level) { super(level); } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { } @Override - public Multimap getAttributeModifiers() - { + public Multimap getAttributeModifiers() { Multimap modifierMap = HashMultimap.create(); String name = getUniqueIdentifier() + "-DamageModifier1"; @@ -42,38 +38,32 @@ public class LivingArmourUpgradeMeleeDamage extends LivingArmourUpgrade } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.meleeDamage"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "meleeDamage"; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeNightSight.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeNightSight.java index 662c78fb..6a39ff37 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeNightSight.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeNightSight.java @@ -1,6 +1,9 @@ package WayofTime.bloodmagic.livingArmour.upgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; @@ -8,84 +11,67 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeNightSight extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 5, 8, 15, 20, 34, 45, 70, 100, 150, 200 }; - public static final double[] meleeDamage = new double[] { 0, 0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6 }; +public class LivingArmourUpgradeNightSight extends LivingArmourUpgrade { + public static final int[] costs = new int[]{5, 8, 15, 20, 34, 45, 70, 100, 150, 200}; + public static final double[] meleeDamage = new double[]{0, 0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6}; public boolean isActive = false; - public LivingArmourUpgradeNightSight(int level) - { + public LivingArmourUpgradeNightSight(int level) { super(level); } @Override - public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) - { + public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) { return isActive ? meleeDamage[this.level] : 0; } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { - if (world.getLight(player.getPosition()) <= 9) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { + if (world.getLight(player.getPosition()) <= 9) { isActive = true; - if (player.isPotionActive(MobEffects.NIGHT_VISION)) - { + if (player.isPotionActive(MobEffects.NIGHT_VISION)) { int dur = player.getActivePotionEffect(MobEffects.NIGHT_VISION).getDuration(); - if (dur > 100 && dur < 20 * 60 * 20) - { + if (dur > 100 && dur < 20 * 60 * 20) { //Don't override the potion effect if the other potion effect is sufficiently long. return; } } player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, Constants.Misc.NIGHT_VISION_CONSTANT_BEGIN, 0, false, false)); - } else - { + } else { isActive = false; } } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.nightSight"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; // Set to here until I can add more upgrades to it. } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "nightSight"; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePhysicalProtect.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePhysicalProtect.java index 44fc26a9..0cb14b98 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePhysicalProtect.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePhysicalProtect.java @@ -6,21 +6,17 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; -public class LivingArmourUpgradePhysicalProtect extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 5, 10, 18, 35, 65, 100, 140, 190, 250, 300 }; - public static final double[] protectionLevel = new double[] { 0.1, 0.3, 0.4, 0.5, 0.6, 0.7, 0.75, 0.77, 0.80, 0.83 }; +public class LivingArmourUpgradePhysicalProtect extends LivingArmourUpgrade { + public static final int[] costs = new int[]{5, 10, 18, 35, 65, 100, 140, 190, 250, 300}; + public static final double[] protectionLevel = new double[]{0.1, 0.3, 0.4, 0.5, 0.6, 0.7, 0.75, 0.77, 0.80, 0.83}; - public LivingArmourUpgradePhysicalProtect(int level) - { + public LivingArmourUpgradePhysicalProtect(int level) { super(level); } @Override - public double getArmourProtection(EntityLivingBase wearer, DamageSource source) - { - if (source.getTrueSource() != null && !source.isMagicDamage() && !source.isProjectile()) - { + public double getArmourProtection(EntityLivingBase wearer, DamageSource source) { + if (source.getTrueSource() != null && !source.isMagicDamage() && !source.isProjectile()) { return protectionLevel[this.level]; } @@ -28,38 +24,32 @@ public class LivingArmourUpgradePhysicalProtect extends LivingArmourUpgrade } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.physicalProtect"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; // Set to here until I can add more upgrades to it. } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "physicalProtect"; } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePoisonResist.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePoisonResist.java index fb4f7af1..d5ed775f 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePoisonResist.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePoisonResist.java @@ -1,82 +1,70 @@ package WayofTime.bloodmagic.livingArmour.upgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class LivingArmourUpgradePoisonResist extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 2, 6, 14, 25, 40 }; - public static final int[] poisonCooldownTime = new int[] { 1200, 800, 600, 300, 100 }; - public static final int[] poisonMaxCure = new int[] { 0, 1, 2, 2, 3 }; +public class LivingArmourUpgradePoisonResist extends LivingArmourUpgrade { + public static final int[] costs = new int[]{2, 6, 14, 25, 40}; + public static final int[] poisonCooldownTime = new int[]{1200, 800, 600, 300, 100}; + public static final int[] poisonMaxCure = new int[]{0, 1, 2, 2, 3}; public int poisonCooldown = 0; - public LivingArmourUpgradePoisonResist(int level) - { + public LivingArmourUpgradePoisonResist(int level) { super(level); } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { - if (player.isPotionActive(MobEffects.POISON) && poisonCooldown <= 0) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { + if (player.isPotionActive(MobEffects.POISON) && poisonCooldown <= 0) { PotionEffect eff = player.getActivePotionEffect(MobEffects.POISON); - if (eff.getAmplifier() <= poisonMaxCure[this.level]) - { + if (eff.getAmplifier() <= poisonMaxCure[this.level]) { player.removePotionEffect(MobEffects.POISON); poisonCooldown = poisonCooldownTime[this.level]; player.sendStatusMessage(new TextComponentString(TextHelper.localize(chatBase + "poisonRemove")), true); } - } else if (poisonCooldown > 0) - { + } else if (poisonCooldown > 0) { poisonCooldown--; } } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.poisonResist"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 5; // Set to here until I can add more upgrades to it. } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(Constants.NBT.UPGRADE_POISON_TIMER, poisonCooldown); } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { poisonCooldown = tag.getInteger(Constants.NBT.UPGRADE_POISON_TIMER); } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "poisonResist"; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeRepairing.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeRepairing.java index ac5469fc..8f8ec4d2 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeRepairing.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeRepairing.java @@ -1,87 +1,73 @@ package WayofTime.bloodmagic.livingArmour.upgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeRepairing extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 15 }; - public static final int[] repairDelay = new int[] { 200 }; +public class LivingArmourUpgradeRepairing extends LivingArmourUpgrade { + public static final int[] costs = new int[]{15}; + public static final int[] repairDelay = new int[]{200}; int maxRepair = 1; int delay = 0; - public LivingArmourUpgradeRepairing(int level) - { + public LivingArmourUpgradeRepairing(int level) { super(level); } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { - if (delay <= 0) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { + if (delay <= 0) { delay = repairDelay[this.level]; EntityEquipmentSlot randomSlot = EntityEquipmentSlot.values()[2 + world.rand.nextInt(4)]; ItemStack repairStack = player.getItemStackFromSlot(randomSlot); - if (!repairStack.isEmpty()) - { - if (repairStack.isItemStackDamageable() && repairStack.isItemDamaged()) - { + if (!repairStack.isEmpty()) { + if (repairStack.isItemStackDamageable() && repairStack.isItemDamaged()) { int toRepair = Math.min(maxRepair, repairStack.getItemDamage()); - if (toRepair > 0) - { + if (toRepair > 0) { repairStack.setItemDamage(repairStack.getItemDamage() - toRepair); } } } - } else - { + } else { delay--; } } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.repair"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 1; // Set to here until I can add more upgrades to it. } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger("repairingDelay", delay); } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { delay = tag.getInteger("repairingDelay"); } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "repair"; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSelfSacrifice.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSelfSacrifice.java index 7bb7c94e..acc05450 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSelfSacrifice.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSelfSacrifice.java @@ -4,55 +4,46 @@ import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.nbt.NBTTagCompound; -public class LivingArmourUpgradeSelfSacrifice extends LivingArmourUpgrade -{ +public class LivingArmourUpgradeSelfSacrifice extends LivingArmourUpgrade { //TODO: Add extra effects for higher levels - public static final int[] costs = new int[] { 7, 13, 22, 40, 65, 90, 130, 180, 250, 350 }; - public static final double[] sacrificeModifier = new double[] { 0.15, 0.3, 0.45, 0.6, 0.75, 0.9, 1.05, 1.2, 1.35, 1.5 }; + public static final int[] costs = new int[]{7, 13, 22, 40, 65, 90, 130, 180, 250, 350}; + public static final double[] sacrificeModifier = new double[]{0.15, 0.3, 0.45, 0.6, 0.75, 0.9, 1.05, 1.2, 1.35, 1.5}; - public LivingArmourUpgradeSelfSacrifice(int level) - { + public LivingArmourUpgradeSelfSacrifice(int level) { super(level); } - public double getSacrificeModifier() - { + public double getSacrificeModifier() { return sacrificeModifier[this.level]; } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.selfSacrifice"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; // Set to here until I can add more upgrades to it. } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "selfSacrifice"; } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSolarPowered.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSolarPowered.java index 73787d8c..34291867 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSolarPowered.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSolarPowered.java @@ -1,6 +1,8 @@ package WayofTime.bloodmagic.livingArmour.upgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; @@ -8,29 +10,23 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeSolarPowered extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 5, 12, 20, 35, 49, 78, 110, 160, 215, 320 }; - public static final int[] regenCooldown = new int[] { 200, 180, 160, 120, 100, 80, 40, 20, 10, 10 }; - public static final int[] fireResistCooldown = new int[] { 1, 1, 60 * 60, 50 * 60, 40 * 60, 35 * 60, 30 * 60, 25 * 60, 20 * 60, 10 * 60 }; - public static final int[] fireResistTime = new int[] { 0, 0, 15 * 60, 20 * 60, 30 * 60, 35 * 60, 40 * 60, 50 * 60, 60 * 60, 100 * 60 }; - public static final double[] protectionLevel = new double[] { 0.02, 0.04, 0.06, 0.08, 0.10, 0.13, 0.16, 0.19, 0.22, 0.25 }; +public class LivingArmourUpgradeSolarPowered extends LivingArmourUpgrade { + public static final int[] costs = new int[]{5, 12, 20, 35, 49, 78, 110, 160, 215, 320}; + public static final int[] regenCooldown = new int[]{200, 180, 160, 120, 100, 80, 40, 20, 10, 10}; + public static final int[] fireResistCooldown = new int[]{1, 1, 60 * 60, 50 * 60, 40 * 60, 35 * 60, 30 * 60, 25 * 60, 20 * 60, 10 * 60}; + public static final int[] fireResistTime = new int[]{0, 0, 15 * 60, 20 * 60, 30 * 60, 35 * 60, 40 * 60, 50 * 60, 60 * 60, 100 * 60}; + public static final double[] protectionLevel = new double[]{0.02, 0.04, 0.06, 0.08, 0.10, 0.13, 0.16, 0.19, 0.22, 0.25}; public int counter = 0; - public LivingArmourUpgradeSolarPowered(int level) - { + public LivingArmourUpgradeSolarPowered(int level) { super(level); } @Override - public double getArmourProtection(EntityLivingBase wearer, DamageSource source) - { - if (wearer.getEntityWorld().canSeeSky(wearer.getPosition()) || wearer.getEntityWorld().provider.isDaytime()) - { + public double getArmourProtection(EntityLivingBase wearer, DamageSource source) { + if (wearer.getEntityWorld().canSeeSky(wearer.getPosition()) || wearer.getEntityWorld().provider.isDaytime()) { return protectionLevel[this.level]; } @@ -38,56 +34,46 @@ public class LivingArmourUpgradeSolarPowered extends LivingArmourUpgrade } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { counter++; - if (world.canSeeSky(player.getPosition()) || world.provider.isDaytime()) - { - if (counter % regenCooldown[this.level] == 0 && player.getHealth() < player.getMaxHealth()) - { + if (world.canSeeSky(player.getPosition()) || world.provider.isDaytime()) { + if (counter % regenCooldown[this.level] == 0 && player.getHealth() < player.getMaxHealth()) { player.heal(1); } - if (fireResistTime[this.level] != 0 && counter % fireResistCooldown[this.level] == 0) - { + if (fireResistTime[this.level] != 0 && counter % fireResistCooldown[this.level] == 0) { player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, fireResistTime[this.level], 0, false, false)); } } } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.solarPowered"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; // Set to here until I can add more upgrades to it. } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { tag.setInteger(BloodMagic.MODID + ".tracker.solarPowered", counter); } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { counter = tag.getInteger(BloodMagic.MODID + ".tracker.solarPowered"); } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "solarPowered"; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSpeed.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSpeed.java index 3a2a61f5..2677eaba 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSpeed.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSpeed.java @@ -1,8 +1,10 @@ package WayofTime.bloodmagic.livingArmour.upgrade; -import java.util.UUID; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; @@ -10,58 +12,46 @@ import net.minecraft.init.MobEffects; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; import org.apache.commons.codec.binary.StringUtils; -public class LivingArmourUpgradeSpeed extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 3, 7, 13, 26, 42, 60, 90, 130, 180, 250 }; - public static final double[] speedModifier = new double[] { 0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 0.9, 1.1, 1.3, 1.5 }; - public static final int[] sprintSpeedTime = new int[] { 0, 0, 0, 0, 0, 20, 60, 60, 100, 200 }; - public static final int[] sprintSpeedLevel = new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 1, 2 }; - public static final int[] healthModifier = new int[] { 0, 0, 0, 0, 0, 0, 0, 4, 10, 20 }; - public static final int[] sprintRegenTime = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 25 }; +import java.util.UUID; - public LivingArmourUpgradeSpeed(int level) - { +public class LivingArmourUpgradeSpeed extends LivingArmourUpgrade { + public static final int[] costs = new int[]{3, 7, 13, 26, 42, 60, 90, 130, 180, 250}; + public static final double[] speedModifier = new double[]{0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 0.9, 1.1, 1.3, 1.5}; + public static final int[] sprintSpeedTime = new int[]{0, 0, 0, 0, 0, 20, 60, 60, 100, 200}; + public static final int[] sprintSpeedLevel = new int[]{0, 0, 0, 0, 0, 0, 0, 1, 1, 2}; + public static final int[] healthModifier = new int[]{0, 0, 0, 0, 0, 0, 0, 4, 10, 20}; + public static final int[] sprintRegenTime = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 25}; + + public LivingArmourUpgradeSpeed(int level) { super(level); } - public double getSpeedModifier() - { + public double getSpeedModifier() { return speedModifier[this.level]; } @Override - public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) - { - if (player.isSprinting()) - { - if (sprintSpeedTime[this.level] > 0) - { + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { + if (player.isSprinting()) { + if (sprintSpeedTime[this.level] > 0) { player.addPotionEffect(new PotionEffect(MobEffects.SPEED, sprintSpeedTime[this.level], sprintSpeedLevel[this.level], false, false)); } - if (sprintRegenTime[this.level] > 0 && !player.isPotionActive(MobEffects.REGENERATION)) - { + if (sprintRegenTime[this.level] > 0 && !player.isPotionActive(MobEffects.REGENERATION)) { player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, sprintRegenTime[this.level], 0, false, false)); } } } @Override - public Multimap getAttributeModifiers() - { + public Multimap getAttributeModifiers() { Multimap modifierMap = HashMultimap.create(); // modifierMap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(895132, 1), "Speed modifier" + 1, speedModifier[this.level], 1)); - if (healthModifier[this.level] > 0) - { + if (healthModifier[this.level] > 0) { String name = getUniqueIdentifier() + "-HealthModifier1"; modifierMap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(UUID.nameUUIDFromBytes(StringUtils.getBytesUtf8(name)), "HealthModifier1", healthModifier[this.level], 0)); } @@ -70,38 +60,32 @@ public class LivingArmourUpgradeSpeed extends LivingArmourUpgrade } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.movement"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 10; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "speed"; } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSprintAttack.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSprintAttack.java index eae1a291..22d175b6 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSprintAttack.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSprintAttack.java @@ -1,28 +1,24 @@ package WayofTime.bloodmagic.livingArmour.upgrade; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -public class LivingArmourUpgradeSprintAttack extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 3, 7, 15, 25, 40 }; - public static final double[] damageBoost = new double[] { 0.5, 0.75, 1, 1.25, 1.5 }; - public static final double[] knockbackModifier = new double[] { 1, 2, 3, 4, 5 }; +public class LivingArmourUpgradeSprintAttack extends LivingArmourUpgrade { + public static final int[] costs = new int[]{3, 7, 15, 25, 40}; + public static final double[] damageBoost = new double[]{0.5, 0.75, 1, 1.25, 1.5}; + public static final double[] knockbackModifier = new double[]{1, 2, 3, 4, 5}; - public LivingArmourUpgradeSprintAttack(int level) - { + public LivingArmourUpgradeSprintAttack(int level) { super(level); } @Override - public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) - { - if (wearer.isSprinting()) - { + public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) { + if (wearer.isSprinting()) { return getDamageModifier(); } @@ -30,59 +26,49 @@ public class LivingArmourUpgradeSprintAttack extends LivingArmourUpgrade } @Override - public double getKnockbackOnHit(EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) - { - if (wearer.isSprinting()) - { + public double getKnockbackOnHit(EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) { + if (wearer.isSprinting()) { return getKnockbackModifier(); } return 0; } - public double getDamageModifier() - { + public double getDamageModifier() { return damageBoost[this.level]; } - public double getKnockbackModifier() - { + public double getKnockbackModifier() { return knockbackModifier[this.level]; } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.sprintAttack"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 5; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "sprintAttack"; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeStepAssist.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeStepAssist.java index 3b43023c..48c8d7c6 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeStepAssist.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeStepAssist.java @@ -5,10 +5,9 @@ import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.nbt.NBTTagCompound; -public class LivingArmourUpgradeStepAssist extends LivingArmourUpgrade -{ - public static final int[] costs = new int[] { 20 }; - public static final float[] assist = new float[] { Constants.Misc.ALTERED_STEP_HEIGHT }; +public class LivingArmourUpgradeStepAssist extends LivingArmourUpgrade { + public static final int[] costs = new int[]{20}; + public static final float[] assist = new float[]{Constants.Misc.ALTERED_STEP_HEIGHT}; // public static final double[] speedModifier = new double[] { 0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 0.9, 1.1, 1.3, 1.5 }; // public static final int[] sprintSpeedTime = new int[] { 0, 0, 0, 0, 0, 20, 60, 60, 100, 200 }; @@ -16,49 +15,41 @@ public class LivingArmourUpgradeStepAssist extends LivingArmourUpgrade // public static final int[] healthModifier = new int[] { 0, 0, 0, 0, 0, 0, 0, 4, 10, 20 }; // public static final int[] sprintRegenTime = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 25 }; - public LivingArmourUpgradeStepAssist(int level) - { + public LivingArmourUpgradeStepAssist(int level) { super(level); } @Override - public String getUniqueIdentifier() - { + public String getUniqueIdentifier() { return BloodMagic.MODID + ".upgrade.stepAssist"; } @Override - public int getMaxTier() - { + public int getMaxTier() { return 1; } @Override - public int getCostOfUpgrade() - { + public int getCostOfUpgrade() { return costs[this.level]; } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { // EMPTY } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { // EMPTY } @Override - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return tooltipBase + "stepAssist"; } - public float getStepAssist() - { + public float getStepAssist() { return assist[this.level]; } } diff --git a/src/main/java/WayofTime/bloodmagic/meteor/Meteor.java b/src/main/java/WayofTime/bloodmagic/meteor/Meteor.java index 9e929db6..f547c205 100644 --- a/src/main/java/WayofTime/bloodmagic/meteor/Meteor.java +++ b/src/main/java/WayofTime/bloodmagic/meteor/Meteor.java @@ -1,16 +1,15 @@ package WayofTime.bloodmagic.meteor; -import java.util.List; -import java.util.Random; - +import WayofTime.bloodmagic.util.Utils; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.util.Utils; -public class Meteor -{ +import java.util.List; +import java.util.Random; + +public class Meteor { private static final Random RAND = new Random(); private final ItemStack catalystStack; @@ -20,8 +19,7 @@ public class Meteor private final int maxWeight; public int version; - public Meteor(ItemStack catalystStack, List components, float explosionStrength, int radius) - { + public Meteor(ItemStack catalystStack, List components, float explosionStrength, int radius) { this.catalystStack = catalystStack; this.components = components; this.explosionStrength = explosionStrength; @@ -33,31 +31,24 @@ public class Meteor this.maxWeight = weight; } - public void generateMeteor(World world, BlockPos pos, IBlockState fillerBlock, double radiusModifier, double explosionModifier, double fillerChance) - { + public void generateMeteor(World world, BlockPos pos, IBlockState fillerBlock, double radiusModifier, double explosionModifier, double fillerChance) { world.newExplosion(null, pos.getX(), pos.getY(), pos.getZ(), (float) (explosionStrength * explosionModifier), true, true); int radius = (int) Math.ceil(getRadius() * radiusModifier); double floatingRadius = getRadius() * radiusModifier; - for (int i = -radius; i <= radius; i++) - { - for (int j = -radius; j <= radius; j++) - { - for (int k = -radius; k <= radius; k++) - { - if (i * i + j * j + k * k > (floatingRadius + 0.5) * (floatingRadius + 0.5)) - { + for (int i = -radius; i <= radius; i++) { + for (int j = -radius; j <= radius; j++) { + for (int k = -radius; k <= radius; k++) { + if (i * i + j * j + k * k > (floatingRadius + 0.5) * (floatingRadius + 0.5)) { continue; } BlockPos newPos = pos.add(i, j, k); IBlockState state = world.getBlockState(newPos); - if (world.isAirBlock(newPos) || Utils.isBlockLiquid(state)) - { + if (world.isAirBlock(newPos) || Utils.isBlockLiquid(state)) { IBlockState placedState = getRandomOreFromComponents(fillerBlock, fillerChance); - if (placedState != null) - { + if (placedState != null) { world.setBlockState(newPos, placedState); } } @@ -67,21 +58,16 @@ public class Meteor } //fillerChance is the chance that the filler block will NOT be placed - public IBlockState getRandomOreFromComponents(IBlockState fillerBlock, double fillerChance) - { + public IBlockState getRandomOreFromComponents(IBlockState fillerBlock, double fillerChance) { int goal = RAND.nextInt(getMaxWeight()); - for (MeteorComponent component : getComponents()) - { + for (MeteorComponent component : getComponents()) { goal -= component.getWeight(); - if (goal < 0) - { + if (goal < 0) { IBlockState state = component.getStateFromOre(); - if (state != null) - { + if (state != null) { return state; - } else - { + } else { return RAND.nextDouble() > fillerChance ? fillerBlock : null; } } diff --git a/src/main/java/WayofTime/bloodmagic/meteor/MeteorComponent.java b/src/main/java/WayofTime/bloodmagic/meteor/MeteorComponent.java index 3c4d7e5f..df810fe5 100644 --- a/src/main/java/WayofTime/bloodmagic/meteor/MeteorComponent.java +++ b/src/main/java/WayofTime/bloodmagic/meteor/MeteorComponent.java @@ -1,7 +1,6 @@ package WayofTime.bloodmagic.meteor; -import java.util.List; - +import WayofTime.bloodmagic.util.Utils; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -10,10 +9,10 @@ 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; -public class MeteorComponent -{ +import java.util.List; + +public class MeteorComponent { public int weight; public String oreName; @@ -22,33 +21,26 @@ public class MeteorComponent this.oreName = oreName; } - public IBlockState getStateFromOre() - { - if (oreName.contains(":")) - { + public IBlockState getStateFromOre() { + if (oreName.contains(":")) { String[] stringList = oreName.split(":"); String domain = stringList[0]; String block = stringList[1]; int meta = 0; - if (stringList.length > 2 && Utils.isInteger(stringList[2])) - { + if (stringList.length > 2 && Utils.isInteger(stringList[2])) { meta = Integer.parseInt(stringList[2]); } Block ore = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(domain, block)); - if (ore != Blocks.AIR) - { + if (ore != Blocks.AIR) { return ore.getStateFromMeta(meta); } } List list = OreDictionary.getOres(oreName); - if (list != null && !list.isEmpty()) - { - for (ItemStack stack : list) - { - if (stack != null && stack.getItem() instanceof ItemBlock) - { + if (list != null && !list.isEmpty()) { + for (ItemStack stack : list) { + if (stack != null && stack.getItem() instanceof ItemBlock) { Block block = ((ItemBlock) stack.getItem()).getBlock(); IBlockState state = block.getStateFromMeta(stack.getItemDamage()); diff --git a/src/main/java/WayofTime/bloodmagic/meteor/MeteorConfigHandler.java b/src/main/java/WayofTime/bloodmagic/meteor/MeteorConfigHandler.java index b755ff3c..1c482c0d 100644 --- a/src/main/java/WayofTime/bloodmagic/meteor/MeteorConfigHandler.java +++ b/src/main/java/WayofTime/bloodmagic/meteor/MeteorConfigHandler.java @@ -17,20 +17,17 @@ import java.util.List; import java.util.Map; import java.util.Set; -public class MeteorConfigHandler -{ +public class MeteorConfigHandler { private static final Map DEFAULT_METEORS = Maps.newHashMap(); private static File meteorDir; - public static void init(File meteorDirectory) - { + public static void init(File meteorDirectory) { meteorDir = meteorDirectory; handleMeteors(true); } - public static void handleMeteors(boolean checkNewVersion) - { + public static void handleMeteors(boolean checkNewVersion) { if (meteorDir == null) { BloodMagic.instance.logger.error("Attempted to handle meteor config but the folder has not been initialized. Was this run too early?"); return; @@ -40,13 +37,10 @@ public class MeteorConfigHandler MeteorRegistry.meteorMap.clear(); List> defaultMeteors = getDefaultMeteors(); - try - { + try { // Create defaults if the folder doesn't exist - if (!meteorDir.exists() && meteorDir.mkdir()) - { - for (Pair meteor : defaultMeteors) - { + if (!meteorDir.exists() && meteorDir.mkdir()) { + for (Pair meteor : defaultMeteors) { String json = Serializers.GSON.toJson(meteor.getRight()); FileWriter writer = new FileWriter(new File(meteorDir, meteor.getLeft() + ".json")); writer.write(json); @@ -62,24 +56,20 @@ public class MeteorConfigHandler List> meteors = Lists.newArrayList(); // Filter names so we can compare to defaults - for (File meteorFile : meteorFiles) - { + for (File meteorFile : meteorFiles) { FileReader reader = new FileReader(meteorFile); Meteor meteor = Serializers.GSON.fromJson(reader, Meteor.class); meteors.add(Pair.of(FilenameUtils.removeExtension(meteorFile.getName()), meteor)); reader.close(); } - if (checkNewVersion && ConfigHandler.config.getBoolean("resyncOnVersionChange", "Meteors", true, "Should the default meteors be regenerated if the mod has updated them")) - { + if (checkNewVersion && ConfigHandler.config.getBoolean("resyncOnVersionChange", "Meteors", true, "Should the default meteors be regenerated if the mod has updated them")) { Set discoveredDefaults = Sets.newHashSet(); // Check existing defaults for new version - for (Pair meteor : meteors) - { + for (Pair meteor : meteors) { Meteor defaultMeteor = DEFAULT_METEORS.get(meteor.getLeft()); - if (defaultMeteor != null) - { + if (defaultMeteor != null) { discoveredDefaults.add(meteor.getLeft()); if (defaultMeteor.version > meteor.getRight().version) { writeMeteor(meteor.getLeft(), defaultMeteor); @@ -100,16 +90,14 @@ public class MeteorConfigHandler // Finally, register all of our meteors for (Pair meteor : meteors) MeteorRegistry.registerMeteor(meteor.getRight().getCatalystStack(), meteor.getRight()); - } catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } ConfigHandler.config.save(); } - private static List> getDefaultMeteors() - { + private static List> getDefaultMeteors() { List> holders = Lists.newArrayList(); // Iron diff --git a/src/main/java/WayofTime/bloodmagic/meteor/MeteorRegistry.java b/src/main/java/WayofTime/bloodmagic/meteor/MeteorRegistry.java index 9e7fd9aa..4550aca7 100644 --- a/src/main/java/WayofTime/bloodmagic/meteor/MeteorRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/meteor/MeteorRegistry.java @@ -1,51 +1,43 @@ package WayofTime.bloodmagic.meteor; +import WayofTime.bloodmagic.api.ItemStackWrapper; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + import java.util.HashMap; import java.util.List; import java.util.Map; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import WayofTime.bloodmagic.api.ItemStackWrapper; - -public class MeteorRegistry -{ +public class MeteorRegistry { public static Map meteorMap = new HashMap(); - public static void registerMeteor(ItemStack stack, Meteor holder) - { + public static void registerMeteor(ItemStack stack, Meteor holder) { ItemStackWrapper wrapper = ItemStackWrapper.getHolder(stack); - if (wrapper != null) - { + if (wrapper != null) { meteorMap.put(wrapper, holder); } } - public static void registerMeteor(ItemStack stack, List componentList, float explosionStrength, int radius) - { + public static void registerMeteor(ItemStack stack, List componentList, float explosionStrength, int radius) { Meteor holder = new Meteor(stack, componentList, explosionStrength, radius); registerMeteor(stack, holder); } - public static boolean hasMeteorForItem(ItemStack stack) - { + public static boolean hasMeteorForItem(ItemStack stack) { ItemStackWrapper wrapper = ItemStackWrapper.getHolder(stack); return wrapper != null && meteorMap.containsKey(wrapper); } - public static Meteor getMeteorForItem(ItemStack stack) - { + public static Meteor getMeteorForItem(ItemStack stack) { ItemStackWrapper wrapper = ItemStackWrapper.getHolder(stack); return wrapper != null ? meteorMap.get(wrapper) : null; } - public static void generateMeteorForItem(ItemStack stack, World world, BlockPos pos, IBlockState fillerBlock, double radiusModifier, double explosionModifier, double fillerChance) - { + public static void generateMeteorForItem(ItemStack stack, World world, BlockPos pos, IBlockState fillerBlock, double radiusModifier, double explosionModifier, double fillerChance) { Meteor holder = getMeteorForItem(stack); - if (holder != null) - { + if (holder != null) { holder.generateMeteor(world, pos, fillerBlock, radiusModifier, explosionModifier, fillerChance); } } diff --git a/src/main/java/WayofTime/bloodmagic/network/BloodMagicPacketHandler.java b/src/main/java/WayofTime/bloodmagic/network/BloodMagicPacketHandler.java index e0847590..98856381 100644 --- a/src/main/java/WayofTime/bloodmagic/network/BloodMagicPacketHandler.java +++ b/src/main/java/WayofTime/bloodmagic/network/BloodMagicPacketHandler.java @@ -1,20 +1,18 @@ package WayofTime.bloodmagic.network; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.util.ChatUtil; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.relauncher.Side; -import WayofTime.bloodmagic.util.ChatUtil; -public class BloodMagicPacketHandler -{ +public class BloodMagicPacketHandler { public static final SimpleNetworkWrapper INSTANCE = new SimpleNetworkWrapper(BloodMagic.MODID); - public static void init() - { + public static void init() { INSTANCE.registerMessage(ChatUtil.PacketNoSpamChat.Handler.class, ChatUtil.PacketNoSpamChat.class, 0, Side.CLIENT); INSTANCE.registerMessage(ItemRouterButtonPacketProcessor.class, ItemRouterButtonPacketProcessor.class, 1, Side.SERVER); INSTANCE.registerMessage(PlayerVelocityPacketProcessor.class, PlayerVelocityPacketProcessor.class, 2, Side.CLIENT); @@ -25,18 +23,15 @@ public class BloodMagicPacketHandler INSTANCE.registerMessage(ItemRouterAmountPacketProcessor.class, ItemRouterAmountPacketProcessor.class, 7, Side.SERVER); } - public static void sendToAllAround(IMessage message, TileEntity te, int range) - { + public static void sendToAllAround(IMessage message, TileEntity te, int range) { INSTANCE.sendToAllAround(message, new NetworkRegistry.TargetPoint(te.getWorld().provider.getDimension(), te.getPos().getX(), te.getPos().getY(), te.getPos().getZ(), range)); } - public static void sendToAllAround(IMessage message, TileEntity te) - { + public static void sendToAllAround(IMessage message, TileEntity te) { sendToAllAround(message, te, 64); } - public static void sendTo(IMessage message, EntityPlayerMP player) - { + public static void sendTo(IMessage message, EntityPlayerMP player) { INSTANCE.sendTo(message, player); } } diff --git a/src/main/java/WayofTime/bloodmagic/network/DemonAuraPacketProcessor.java b/src/main/java/WayofTime/bloodmagic/network/DemonAuraPacketProcessor.java index 69659502..eb8b9724 100644 --- a/src/main/java/WayofTime/bloodmagic/network/DemonAuraPacketProcessor.java +++ b/src/main/java/WayofTime/bloodmagic/network/DemonAuraPacketProcessor.java @@ -1,5 +1,8 @@ package WayofTime.bloodmagic.network; +import WayofTime.bloodmagic.api.soul.DemonWillHolder; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.proxy.ClientProxy; import io.netty.buffer.ByteBuf; import net.minecraft.network.PacketBuffer; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; @@ -7,63 +10,48 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.api.soul.DemonWillHolder; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.proxy.ClientProxy; -public class DemonAuraPacketProcessor implements IMessage, IMessageHandler -{ +public class DemonAuraPacketProcessor implements IMessage, IMessageHandler { public DemonWillHolder currentWill = new DemonWillHolder(); - public DemonAuraPacketProcessor() - { + public DemonAuraPacketProcessor() { } - public DemonAuraPacketProcessor(DemonWillHolder holder) - { + public DemonAuraPacketProcessor(DemonWillHolder holder) { this.currentWill = holder; } @Override - public void fromBytes(ByteBuf buffer) - { + public void fromBytes(ByteBuf buffer) { PacketBuffer buff = new PacketBuffer(buffer); - for (EnumDemonWillType type : EnumDemonWillType.values()) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { currentWill.willMap.put(type, buff.readDouble()); } } @Override - public void toBytes(ByteBuf buffer) - { + public void toBytes(ByteBuf buffer) { PacketBuffer buff = new PacketBuffer(buffer); - for (EnumDemonWillType type : EnumDemonWillType.values()) - { - if (currentWill.willMap.containsKey(type)) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { + if (currentWill.willMap.containsKey(type)) { buff.writeDouble(currentWill.willMap.get(type)); - } else - { + } else { buff.writeDouble(0); } } } @Override - public IMessage onMessage(DemonAuraPacketProcessor message, MessageContext ctx) - { - if (ctx.side == Side.CLIENT) - { + public IMessage onMessage(DemonAuraPacketProcessor message, MessageContext ctx) { + if (ctx.side == Side.CLIENT) { message.onMessageFromServer(); } return null; } @SideOnly(Side.CLIENT) - public void onMessageFromServer() - { + public void onMessageFromServer() { ClientProxy.currentAura = currentWill; } } diff --git a/src/main/java/WayofTime/bloodmagic/network/ItemRouterAmountPacketProcessor.java b/src/main/java/WayofTime/bloodmagic/network/ItemRouterAmountPacketProcessor.java index d6cc57b8..de84fd3d 100644 --- a/src/main/java/WayofTime/bloodmagic/network/ItemRouterAmountPacketProcessor.java +++ b/src/main/java/WayofTime/bloodmagic/network/ItemRouterAmountPacketProcessor.java @@ -12,20 +12,17 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.relauncher.Side; -public class ItemRouterAmountPacketProcessor implements IMessage, IMessageHandler -{ +public class ItemRouterAmountPacketProcessor implements IMessage, IMessageHandler { private int ghostItemSlot; private int amount; private int dimension; private BlockPos pos; - public ItemRouterAmountPacketProcessor() - { + public ItemRouterAmountPacketProcessor() { } - public ItemRouterAmountPacketProcessor(int ghostItemSlot, int amount, BlockPos pos, World world) - { + public ItemRouterAmountPacketProcessor(int ghostItemSlot, int amount, BlockPos pos, World world) { this.ghostItemSlot = ghostItemSlot; this.amount = amount; this.pos = pos; @@ -33,8 +30,7 @@ public class ItemRouterAmountPacketProcessor implements IMessage, IMessageHandle } @Override - public void fromBytes(ByteBuf buffer) - { + public void fromBytes(ByteBuf buffer) { PacketBuffer buff = new PacketBuffer(buffer); dimension = buff.readInt(); pos = buff.readBlockPos(); @@ -43,8 +39,7 @@ public class ItemRouterAmountPacketProcessor implements IMessage, IMessageHandle } @Override - public void toBytes(ByteBuf buffer) - { + public void toBytes(ByteBuf buffer) { PacketBuffer buff = new PacketBuffer(buffer); buff.writeInt(dimension); buff.writeBlockPos(pos); @@ -53,26 +48,21 @@ public class ItemRouterAmountPacketProcessor implements IMessage, IMessageHandle } @Override - public IMessage onMessage(ItemRouterAmountPacketProcessor message, MessageContext ctx) - { - if (ctx.side == Side.SERVER) - { + public IMessage onMessage(ItemRouterAmountPacketProcessor message, MessageContext ctx) { + if (ctx.side == Side.SERVER) { message.onMessageFromClient(); } return null; } - public void onMessageFromClient() - { + public void onMessageFromClient() { World world = DimensionManager.getWorld(dimension); - if (world != null) - { + if (world != null) { if (!world.isBlockLoaded(pos)) return; TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileFilteredRoutingNode) - { + if (tile instanceof TileFilteredRoutingNode) { ((TileFilteredRoutingNode) tile).setGhostItemAmount(ghostItemSlot, amount); } } diff --git a/src/main/java/WayofTime/bloodmagic/network/ItemRouterButtonPacketProcessor.java b/src/main/java/WayofTime/bloodmagic/network/ItemRouterButtonPacketProcessor.java index 905af75a..e8aafad7 100644 --- a/src/main/java/WayofTime/bloodmagic/network/ItemRouterButtonPacketProcessor.java +++ b/src/main/java/WayofTime/bloodmagic/network/ItemRouterButtonPacketProcessor.java @@ -12,27 +12,23 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.relauncher.Side; -public class ItemRouterButtonPacketProcessor implements IMessage, IMessageHandler -{ +public class ItemRouterButtonPacketProcessor implements IMessage, IMessageHandler { private int buttonPress; private int dimension; private BlockPos pos; - public ItemRouterButtonPacketProcessor() - { + public ItemRouterButtonPacketProcessor() { } - public ItemRouterButtonPacketProcessor(int buttonPress, BlockPos pos, World world) - { + public ItemRouterButtonPacketProcessor(int buttonPress, BlockPos pos, World world) { this.buttonPress = buttonPress; this.pos = pos; this.dimension = world.provider.getDimension(); } @Override - public void fromBytes(ByteBuf buffer) - { + public void fromBytes(ByteBuf buffer) { PacketBuffer buff = new PacketBuffer(buffer); dimension = buff.readInt(); pos = buff.readBlockPos(); @@ -40,8 +36,7 @@ public class ItemRouterButtonPacketProcessor implements IMessage, IMessageHandle } @Override - public void toBytes(ByteBuf buffer) - { + public void toBytes(ByteBuf buffer) { PacketBuffer buff = new PacketBuffer(buffer); buff.writeInt(dimension); buff.writeBlockPos(pos); @@ -49,37 +44,28 @@ public class ItemRouterButtonPacketProcessor implements IMessage, IMessageHandle } @Override - public IMessage onMessage(ItemRouterButtonPacketProcessor message, MessageContext ctx) - { - if (ctx.side == Side.SERVER) - { + public IMessage onMessage(ItemRouterButtonPacketProcessor message, MessageContext ctx) { + if (ctx.side == Side.SERVER) { message.onMessageFromClient(); } return null; } - public void onMessageFromClient() - { + public void onMessageFromClient() { World world = DimensionManager.getWorld(dimension); - if (world != null) - { + if (world != null) { if (!world.isBlockLoaded(pos)) return; TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileFilteredRoutingNode) - { - if (buttonPress >= 6) - { - if (buttonPress == 6) - { + if (tile instanceof TileFilteredRoutingNode) { + if (buttonPress >= 6) { + if (buttonPress == 6) { ((TileFilteredRoutingNode) tile).incrementCurrentPriotiryToMaximum(9); - } else if (buttonPress == 7) - { + } else if (buttonPress == 7) { ((TileFilteredRoutingNode) tile).decrementCurrentPriority(); } - } else - { + } else { ((TileFilteredRoutingNode) tile).swapFilters(buttonPress); } } diff --git a/src/main/java/WayofTime/bloodmagic/network/KeyProcessor.java b/src/main/java/WayofTime/bloodmagic/network/KeyProcessor.java index a41c5c70..d3620782 100644 --- a/src/main/java/WayofTime/bloodmagic/network/KeyProcessor.java +++ b/src/main/java/WayofTime/bloodmagic/network/KeyProcessor.java @@ -9,47 +9,38 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -public class KeyProcessor implements IMessage, IMessageHandler -{ +public class KeyProcessor implements IMessage, IMessageHandler { public int keyId; public boolean showInChat; - public KeyProcessor() - { + public KeyProcessor() { } - public KeyProcessor(KeyBindings key, boolean showInChat) - { + public KeyProcessor(KeyBindings key, boolean showInChat) { this.keyId = key.ordinal(); this.showInChat = showInChat; } @Override - public void fromBytes(ByteBuf buf) - { + public void fromBytes(ByteBuf buf) { this.keyId = buf.readInt(); this.showInChat = buf.readBoolean(); } @Override - public void toBytes(ByteBuf buf) - { + public void toBytes(ByteBuf buf) { buf.writeInt(this.keyId); buf.writeBoolean(this.showInChat); } @Override - public IMessage onMessage(KeyProcessor msg, MessageContext ctx) - { + public IMessage onMessage(KeyProcessor msg, MessageContext ctx) { EntityPlayer entityPlayer = ctx.getServerHandler().player; - if (entityPlayer != null) - { + if (entityPlayer != null) { ItemStack heldStack = entityPlayer.getHeldItemMainhand(); - if (heldStack.getItem() instanceof IKeybindable) - { - if (msg.keyId < 0 || msg.keyId >= KeyBindings.values().length) - { + if (heldStack.getItem() instanceof IKeybindable) { + if (msg.keyId < 0 || msg.keyId >= KeyBindings.values().length) { return null; } KeyBindings key = KeyBindings.values()[msg.keyId]; diff --git a/src/main/java/WayofTime/bloodmagic/network/PlayerFallDistancePacketProcessor.java b/src/main/java/WayofTime/bloodmagic/network/PlayerFallDistancePacketProcessor.java index 9011f034..89dd5980 100644 --- a/src/main/java/WayofTime/bloodmagic/network/PlayerFallDistancePacketProcessor.java +++ b/src/main/java/WayofTime/bloodmagic/network/PlayerFallDistancePacketProcessor.java @@ -7,48 +7,39 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -public class PlayerFallDistancePacketProcessor implements IMessage, IMessageHandler -{ +public class PlayerFallDistancePacketProcessor implements IMessage, IMessageHandler { private float fallDistance; - public PlayerFallDistancePacketProcessor() - { + public PlayerFallDistancePacketProcessor() { } - public PlayerFallDistancePacketProcessor(float fallDistance) - { + public PlayerFallDistancePacketProcessor(float fallDistance) { this.fallDistance = fallDistance; } @Override - public void fromBytes(ByteBuf buffer) - { + public void fromBytes(ByteBuf buffer) { PacketBuffer buff = new PacketBuffer(buffer); fallDistance = buff.readFloat(); } @Override - public void toBytes(ByteBuf buffer) - { + public void toBytes(ByteBuf buffer) { PacketBuffer buff = new PacketBuffer(buffer); buff.writeFloat(fallDistance); } @Override - public IMessage onMessage(PlayerFallDistancePacketProcessor message, MessageContext ctx) - { - if (ctx.side == Side.SERVER) - { + public IMessage onMessage(PlayerFallDistancePacketProcessor message, MessageContext ctx) { + if (ctx.side == Side.SERVER) { message.onMessageFromClient(ctx.getServerHandler().player); } return null; } - public void onMessageFromClient(EntityPlayer player) - { + public void onMessageFromClient(EntityPlayer player) { player.fallDistance = fallDistance; } } diff --git a/src/main/java/WayofTime/bloodmagic/network/PlayerVelocityPacketProcessor.java b/src/main/java/WayofTime/bloodmagic/network/PlayerVelocityPacketProcessor.java index e9a6f608..39f1ad82 100644 --- a/src/main/java/WayofTime/bloodmagic/network/PlayerVelocityPacketProcessor.java +++ b/src/main/java/WayofTime/bloodmagic/network/PlayerVelocityPacketProcessor.java @@ -10,27 +10,23 @@ import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class PlayerVelocityPacketProcessor implements IMessage, IMessageHandler -{ +public class PlayerVelocityPacketProcessor implements IMessage, IMessageHandler { private double motionX; private double motionY; private double motionZ; - public PlayerVelocityPacketProcessor() - { + public PlayerVelocityPacketProcessor() { } - public PlayerVelocityPacketProcessor(double motionX, double motionY, double motionZ) - { + public PlayerVelocityPacketProcessor(double motionX, double motionY, double motionZ) { this.motionX = motionX; this.motionY = motionY; this.motionZ = motionZ; } @Override - public void fromBytes(ByteBuf buffer) - { + public void fromBytes(ByteBuf buffer) { PacketBuffer buff = new PacketBuffer(buffer); motionX = buff.readDouble(); motionY = buff.readDouble(); @@ -38,8 +34,7 @@ public class PlayerVelocityPacketProcessor implements IMessage, IMessageHandler< } @Override - public void toBytes(ByteBuf buffer) - { + public void toBytes(ByteBuf buffer) { PacketBuffer buff = new PacketBuffer(buffer); buff.writeDouble(motionX); buff.writeDouble(motionY); @@ -47,18 +42,15 @@ public class PlayerVelocityPacketProcessor implements IMessage, IMessageHandler< } @Override - public IMessage onMessage(PlayerVelocityPacketProcessor message, MessageContext ctx) - { - if (ctx.side == Side.CLIENT) - { + public IMessage onMessage(PlayerVelocityPacketProcessor message, MessageContext ctx) { + if (ctx.side == Side.CLIENT) { message.onMessageFromServer(); } return null; } @SideOnly(Side.CLIENT) - public void onMessageFromServer() - { + public void onMessageFromServer() { EntityPlayer player = Minecraft.getMinecraft().player; player.motionX = motionX; player.motionY = motionY; diff --git a/src/main/java/WayofTime/bloodmagic/network/SigilHoldingPacketProcessor.java b/src/main/java/WayofTime/bloodmagic/network/SigilHoldingPacketProcessor.java index 909573a0..9cd7631f 100644 --- a/src/main/java/WayofTime/bloodmagic/network/SigilHoldingPacketProcessor.java +++ b/src/main/java/WayofTime/bloodmagic/network/SigilHoldingPacketProcessor.java @@ -7,47 +7,39 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -public class SigilHoldingPacketProcessor implements IMessage, IMessageHandler -{ +public class SigilHoldingPacketProcessor implements IMessage, IMessageHandler { private int slot; private int mode; - public SigilHoldingPacketProcessor() - { + public SigilHoldingPacketProcessor() { } - public SigilHoldingPacketProcessor(int slot, int mode) - { + public SigilHoldingPacketProcessor(int slot, int mode) { this.slot = slot; this.mode = mode; } @Override - public void toBytes(ByteBuf buffer) - { + public void toBytes(ByteBuf buffer) { buffer.writeInt(slot); buffer.writeInt(mode); } @Override - public void fromBytes(ByteBuf buffer) - { + public void fromBytes(ByteBuf buffer) { slot = buffer.readInt(); mode = buffer.readInt(); } @Override - public IMessage onMessage(SigilHoldingPacketProcessor message, MessageContext ctx) - { + public IMessage onMessage(SigilHoldingPacketProcessor message, MessageContext ctx) { ItemStack itemStack = ItemStack.EMPTY; - if (message.slot > -1 && message.slot < 9) - { + if (message.slot > -1 && message.slot < 9) { itemStack = ctx.getServerHandler().player.inventory.getStackInSlot(message.slot); } - if (!itemStack.isEmpty()) - { + if (!itemStack.isEmpty()) { ItemSigilHolding.cycleToNextSigil(itemStack, message.mode); } diff --git a/src/main/java/WayofTime/bloodmagic/potion/BMPotionUtils.java b/src/main/java/WayofTime/bloodmagic/potion/BMPotionUtils.java index 7751ab33..cb0ea468 100644 --- a/src/main/java/WayofTime/bloodmagic/potion/BMPotionUtils.java +++ b/src/main/java/WayofTime/bloodmagic/potion/BMPotionUtils.java @@ -1,11 +1,9 @@ package WayofTime.bloodmagic.potion; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Random; - +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; import WayofTime.bloodmagic.api_impl.BloodMagicAPI; +import WayofTime.bloodmagic.recipe.alchemyTable.AlchemyTablePotionAugmentRecipe; import net.minecraft.block.Block; import net.minecraft.block.IGrowable; import net.minecraft.block.state.IBlockState; @@ -17,24 +15,22 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.recipe.alchemyTable.AlchemyTablePotionAugmentRecipe; -public class BMPotionUtils -{ +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Random; + +public class BMPotionUtils { public static Random rand = new Random(); - public static double damageMobAndGrowSurroundingPlants(EntityLivingBase entity, int horizontalRadius, int verticalRadius, double damageRatio, int maxPlantsGrown) - { + public static double damageMobAndGrowSurroundingPlants(EntityLivingBase entity, int horizontalRadius, int verticalRadius, double damageRatio, int maxPlantsGrown) { World world = entity.getEntityWorld(); - if (world.isRemote) - { + if (world.isRemote) { return 0; } - if (entity.isDead) - { + if (entity.isDead) { return 0; } @@ -42,22 +38,18 @@ public class BMPotionUtils List growList = new ArrayList(); - for (int i = 0; i < maxPlantsGrown; i++) - { + for (int i = 0; i < maxPlantsGrown; i++) { BlockPos blockPos = entity.getPosition().add(rand.nextInt(horizontalRadius * 2 + 1) - horizontalRadius, rand.nextInt(verticalRadius * 2 + 1) - verticalRadius, rand.nextInt(horizontalRadius * 2 + 1) - horizontalRadius); IBlockState state = world.getBlockState(blockPos); - if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state)) - { - if (state.getBlock() instanceof IGrowable) - { + if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state)) { + if (state.getBlock() instanceof IGrowable) { growList.add(blockPos); } } } - for (BlockPos blockPos : growList) - { + for (BlockPos blockPos : growList) { Block block = world.getBlockState(blockPos).getBlock(); // if (world.rand.nextInt(50) == 0) { @@ -66,34 +58,29 @@ public class BMPotionUtils block.updateTick(world, blockPos, world.getBlockState(blockPos), world.rand); IBlockState newState = world.getBlockState(blockPos); - if (!newState.equals(preBlockState)) - { + if (!newState.equals(preBlockState)) { world.playEvent(2001, blockPos, Block.getIdFromBlock(newState.getBlock()) + (newState.getBlock().getMetaFromState(newState) << 12)); incurredDamage += damageRatio; } } } - if (incurredDamage > 0) - { + if (incurredDamage > 0) { entity.attackEntityFrom(WayofTime.bloodmagic.api.BloodMagicAPI.damageSource, (float) incurredDamage); } return incurredDamage; } - public static double getLengthAugment(ItemStack flaskStack, Potion potion) - { + public static double getLengthAugment(ItemStack flaskStack, Potion potion) { NBTHelper.checkNBT(flaskStack); NBTTagCompound tag = flaskStack.getTagCompound(); return tag.getDouble(Constants.NBT.POTION_AUGMENT_LENGHT + potion.getName()); } - public static void setLengthAugment(ItemStack flaskStack, Potion potion, double value) - { - if (value < 0) - { + public static void setLengthAugment(ItemStack flaskStack, Potion potion, double value) { + if (value < 0) { value = 0; } @@ -103,30 +90,25 @@ public class BMPotionUtils tag.setDouble(Constants.NBT.POTION_AUGMENT_LENGHT + potion.getName(), value); } - public static int getAugmentedLength(int originalLength, double lengthAugment, double powerAugment) - { + public static int getAugmentedLength(int originalLength, double lengthAugment, double powerAugment) { return Math.max((int) (originalLength * (Math.pow(8f / 3f, lengthAugment) * Math.pow(0.5, powerAugment))), 1); } /** * Copied from PotionUtils - * + * * @param stack * @param effects * @return */ - public static ItemStack setEffects(ItemStack stack, Collection effects) - { - if (effects.isEmpty()) - { + public static ItemStack setEffects(ItemStack stack, Collection effects) { + if (effects.isEmpty()) { return stack; - } else - { + } else { NBTTagCompound nbttagcompound = stack.hasTagCompound() ? stack.getTagCompound() : new NBTTagCompound(); NBTTagList nbttaglist = new NBTTagList(); - for (PotionEffect potioneffect : effects) - { + for (PotionEffect potioneffect : effects) { nbttaglist.appendTag(potioneffect.writeCustomPotionEffectToNBT(new NBTTagCompound())); } @@ -136,23 +118,19 @@ public class BMPotionUtils } } - public static AlchemyTablePotionAugmentRecipe getLengthAugmentRecipe(int lpDrained, int ticksRequired, int tierRequired, List inputItems, PotionEffect baseEffect, double lengthAugment) - { + public static AlchemyTablePotionAugmentRecipe getLengthAugmentRecipe(int lpDrained, int ticksRequired, int tierRequired, List inputItems, PotionEffect baseEffect, double lengthAugment) { return new AlchemyTablePotionAugmentRecipe(lpDrained, ticksRequired, tierRequired, inputItems, baseEffect, lengthAugment, 0); } - public static AlchemyTablePotionAugmentRecipe getPowerAugmentRecipe(int lpDrained, int ticksRequired, int tierRequired, List inputItems, PotionEffect baseEffect, int powerAugment) - { + public static AlchemyTablePotionAugmentRecipe getPowerAugmentRecipe(int lpDrained, int ticksRequired, int tierRequired, List inputItems, PotionEffect baseEffect, int powerAugment) { return new AlchemyTablePotionAugmentRecipe(lpDrained, ticksRequired, tierRequired, inputItems, baseEffect, 0, powerAugment); } - public static AlchemyTablePotionAugmentRecipe getLengthAugmentRecipe(int lpDrained, int ticksRequired, int tierRequired, ItemStack inputItem, PotionEffect baseEffect, double lengthAugment) - { + public static AlchemyTablePotionAugmentRecipe getLengthAugmentRecipe(int lpDrained, int ticksRequired, int tierRequired, ItemStack inputItem, PotionEffect baseEffect, double lengthAugment) { return new AlchemyTablePotionAugmentRecipe(lpDrained, ticksRequired, tierRequired, inputItem, baseEffect, lengthAugment, 0); } - public static AlchemyTablePotionAugmentRecipe getPowerAugmentRecipe(int lpDrained, int ticksRequired, int tierRequired, ItemStack inputItem, PotionEffect baseEffect, int powerAugment) - { + public static AlchemyTablePotionAugmentRecipe getPowerAugmentRecipe(int lpDrained, int ticksRequired, int tierRequired, ItemStack inputItem, PotionEffect baseEffect, int powerAugment) { return new AlchemyTablePotionAugmentRecipe(lpDrained, ticksRequired, tierRequired, inputItem, baseEffect, 0, powerAugment); } } diff --git a/src/main/java/WayofTime/bloodmagic/potion/PotionBloodMagic.java b/src/main/java/WayofTime/bloodmagic/potion/PotionBloodMagic.java index 892ea5de..d9d552b5 100644 --- a/src/main/java/WayofTime/bloodmagic/potion/PotionBloodMagic.java +++ b/src/main/java/WayofTime/bloodmagic/potion/PotionBloodMagic.java @@ -9,55 +9,46 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class PotionBloodMagic extends Potion -{ +public class PotionBloodMagic extends Potion { public static ResourceLocation texture = new ResourceLocation(BloodMagic.MODID, "textures/misc/potions.png"); - public PotionBloodMagic(String name, boolean badEffect, int potionColor, int iconIndexX, int iconIndexY) - { + public PotionBloodMagic(String name, boolean badEffect, int potionColor, int iconIndexX, int iconIndexY) { super(badEffect, potionColor); this.setPotionName(name); this.setIconIndex(iconIndexX, iconIndexY); } @Override - public boolean shouldRenderInvText(PotionEffect effect) - { + public boolean shouldRenderInvText(PotionEffect effect) { return true; } - public PotionEffect apply(EntityLivingBase entity, int duration) - { + public PotionEffect apply(EntityLivingBase entity, int duration) { return apply(entity, duration, 0); } - public PotionEffect apply(EntityLivingBase entity, int duration, int level) - { + public PotionEffect apply(EntityLivingBase entity, int duration, int level) { PotionEffect effect = new PotionEffect(this, duration, level, false, false); entity.addPotionEffect(effect); return effect; } - public int getLevel(EntityLivingBase entity) - { + public int getLevel(EntityLivingBase entity) { PotionEffect effect = entity.getActivePotionEffect(this); - if (effect != null) - { + if (effect != null) { return effect.getAmplifier(); } return 0; } @Override - public boolean shouldRender(PotionEffect effect) - { + public boolean shouldRender(PotionEffect effect) { return true; } @Override @SideOnly(Side.CLIENT) - public int getStatusIconIndex() - { + public int getStatusIconIndex() { Minecraft.getMinecraft().renderEngine.bindTexture(texture); return super.getStatusIconIndex(); diff --git a/src/main/java/WayofTime/bloodmagic/potion/PotionEventHandlers.java b/src/main/java/WayofTime/bloodmagic/potion/PotionEventHandlers.java index fa7c6237..27911f00 100644 --- a/src/main/java/WayofTime/bloodmagic/potion/PotionEventHandlers.java +++ b/src/main/java/WayofTime/bloodmagic/potion/PotionEventHandlers.java @@ -19,14 +19,11 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import java.util.List; @Mod.EventBusSubscriber -public class PotionEventHandlers -{ +public class PotionEventHandlers { @SubscribeEvent - public static void onLivingJumpEvent(LivingEvent.LivingJumpEvent event) - { - if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.BOOST)) - { + public static void onLivingJumpEvent(LivingEvent.LivingJumpEvent event) { + if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.BOOST)) { int i = event.getEntityLiving().getActivePotionEffect(RegistrarBloodMagic.BOOST).getAmplifier(); event.getEntityLiving().motionY += (0.1f) * (2 + i); } @@ -37,8 +34,7 @@ public class PotionEventHandlers } @SubscribeEvent - public static void onEntityUpdate(LivingEvent.LivingUpdateEvent event) - { + public static void onEntityUpdate(LivingEvent.LivingUpdateEvent event) { // if (event.getEntityLiving().isPotionActive(ModPotions.boost)) // { // int i = event.getEntityLiving().getActivePotionEffect(ModPotions.boost).getAmplifier(); @@ -55,14 +51,12 @@ public class PotionEventHandlers // } // } - if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.WHIRLWIND)) - { + if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.WHIRLWIND)) { 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().getEntityWorld().getEntitiesWithinAABB(Entity.class, axisAlignedBB); - for (Entity projectile : entityList) - { + for (Entity projectile : entityList) { if (projectile == null) continue; if (!(projectile instanceof IProjectile)) @@ -89,8 +83,7 @@ public class PotionEventHandlers if (angle < 3 * (Math.PI / 4)) continue; // angle is < 135 degrees - if (throwingEntity != null) - { + if (throwingEntity != null) { delX = -projectile.posX + throwingEntity.posX; delY = -projectile.posY + (throwingEntity.posY + throwingEntity.getEyeHeight()); delZ = -projectile.posZ + throwingEntity.posZ; @@ -110,31 +103,26 @@ public class PotionEventHandlers } @SubscribeEvent - public static void onPlayerRespawn(PlayerEvent.Clone event) - { + public static void onPlayerRespawn(PlayerEvent.Clone event) { if (event.isWasDeath()) event.getEntityPlayer().addPotionEffect(new PotionEffect(RegistrarBloodMagic.SOUL_FRAY, 400)); } @SubscribeEvent - public static void onSacrificeKnifeUsed(SacrificeKnifeUsedEvent event) - { + public static void onSacrificeKnifeUsed(SacrificeKnifeUsedEvent event) { if (event.player.isPotionActive(RegistrarBloodMagic.SOUL_FRAY)) event.lpAdded = (int) (event.lpAdded * 0.1D); } @SubscribeEvent(priority = EventPriority.HIGHEST) - public static void onPlayerDamageEvent(LivingAttackEvent event) - { + public static void onPlayerDamageEvent(LivingAttackEvent event) { if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.WHIRLWIND) && event.isCancelable() && event.getSource().isProjectile()) event.setCanceled(true); } @SubscribeEvent - public static void onEndermanTeleportEvent(EnderTeleportEvent event) - { - if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.PLANAR_BINDING) && event.isCancelable()) - { + public static void onEndermanTeleportEvent(EnderTeleportEvent event) { + if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.PLANAR_BINDING) && event.isCancelable()) { event.setCanceled(true); } } diff --git a/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java b/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java index 9b474376..3d9d0233 100644 --- a/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java +++ b/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java @@ -1,11 +1,26 @@ package WayofTime.bloodmagic.proxy; -import java.awt.Color; -import java.util.Map; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.soul.DemonWillHolder; +import WayofTime.bloodmagic.client.IMeshProvider; +import WayofTime.bloodmagic.client.IVariantProvider; +import WayofTime.bloodmagic.client.helper.ShaderHelper; +import WayofTime.bloodmagic.client.hud.HUDElementDemonWillAura; +import WayofTime.bloodmagic.client.hud.HUDElementHolding; import WayofTime.bloodmagic.client.key.KeyBindings; +import WayofTime.bloodmagic.client.render.LayerBloodElytra; import WayofTime.bloodmagic.client.render.block.*; +import WayofTime.bloodmagic.client.render.entity.*; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.entity.mob.*; +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 WayofTime.bloodmagic.tile.*; +import WayofTime.bloodmagic.tile.routing.TileRoutingNode; +import com.google.common.collect.ImmutableMap; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; @@ -24,59 +39,23 @@ import net.minecraftforge.common.model.animation.IAnimationStateMachine; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; - import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.soul.DemonWillHolder; -import WayofTime.bloodmagic.client.IMeshProvider; -import WayofTime.bloodmagic.client.IVariantProvider; -import WayofTime.bloodmagic.client.helper.ShaderHelper; -import WayofTime.bloodmagic.client.hud.HUDElementDemonWillAura; -import WayofTime.bloodmagic.client.hud.HUDElementHolding; -import WayofTime.bloodmagic.client.render.LayerBloodElytra; -import WayofTime.bloodmagic.client.render.entity.BloodLightRenderFactory; -import WayofTime.bloodmagic.client.render.entity.CorruptedChickenRenderFactory; -import WayofTime.bloodmagic.client.render.entity.CorruptedSheepRenderFactory; -import WayofTime.bloodmagic.client.render.entity.CorruptedSpiderRenderFactory; -import WayofTime.bloodmagic.client.render.entity.CorruptedZombieRenderFactory; -import WayofTime.bloodmagic.client.render.entity.MeteorRenderFactory; -import WayofTime.bloodmagic.client.render.entity.MimicRenderFactory; -import WayofTime.bloodmagic.client.render.entity.SentientArrowRenderFactory; -import WayofTime.bloodmagic.client.render.entity.SentientSpecterRenderFactory; -import WayofTime.bloodmagic.client.render.entity.SoulSnareRenderFactory; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedSpider; -import WayofTime.bloodmagic.entity.mob.EntityCorruptedZombie; -import WayofTime.bloodmagic.entity.mob.EntityMimic; -import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; -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 WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.tile.routing.TileRoutingNode; +import java.awt.Color; +import java.util.Map; -import com.google.common.collect.ImmutableMap; - -public class ClientProxy extends CommonProxy -{ +public class ClientProxy extends CommonProxy { public static DemonWillHolder currentAura = new DemonWillHolder(); @Override - public void preInit() - { + public void preInit() { super.preInit(); OBJLoader.INSTANCE.addDomain(BloodMagic.MODID); - ClientRegistry.bindTileEntitySpecialRenderer(TileInversionPillar.class, new AnimationTESR() - { + ClientRegistry.bindTileEntitySpecialRenderer(TileInversionPillar.class, new AnimationTESR() { @Override - public void handleEvents(TileInversionPillar chest, float time, Iterable pastEvents) - { + public void handleEvents(TileInversionPillar chest, float time, Iterable pastEvents) { chest.handleEvents(time, pastEvents); } }); @@ -94,8 +73,7 @@ public class ClientProxy extends CommonProxy } @Override - public void registerRenderers() - { + public void registerRenderers() { RenderingRegistry.registerEntityRenderingHandler(EntitySoulSnare.class, new SoulSnareRenderFactory()); RenderingRegistry.registerEntityRenderingHandler(EntitySentientArrow.class, new SentientArrowRenderFactory()); RenderingRegistry.registerEntityRenderingHandler(EntityBloodLight.class, new BloodLightRenderFactory()); @@ -111,17 +89,14 @@ public class ClientProxy extends CommonProxy } @Override - public void init() - { + public void init() { super.init(); Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> { - try - { + try { if (stack.hasTagCompound() && stack.getTagCompound().hasKey(Constants.NBT.COLOR)) if (tintIndex == 1) return Color.decode(stack.getTagCompound().getString(Constants.NBT.COLOR)).getRGB(); - } catch (NumberFormatException e) - { + } catch (NumberFormatException e) { return -1; } return -1; @@ -140,17 +115,14 @@ public class ClientProxy extends CommonProxy } @Override - public void postInit() - { + public void postInit() { new HUDElementHolding(); new HUDElementDemonWillAura(); } @Override - public void tryHandleBlockModel(Block block, String name) - { - if (block instanceof IVariantProvider) - { + public void tryHandleBlockModel(Block block, String name) { + if (block instanceof IVariantProvider) { IVariantProvider variantProvider = (IVariantProvider) block; for (Pair variant : variantProvider.getVariants()) ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), variant.getLeft(), new ModelResourceLocation(new ResourceLocation(BloodMagic.MODID, name), variant.getRight())); @@ -158,10 +130,8 @@ public class ClientProxy extends CommonProxy } @Override - public void tryHandleItemModel(Item item, String name) - { - if (item instanceof IMeshProvider) - { + public void tryHandleItemModel(Item item, String name) { + if (item instanceof IMeshProvider) { IMeshProvider meshProvider = (IMeshProvider) item; ModelLoader.setCustomMeshDefinition(item, meshProvider.getMeshDefinition()); ResourceLocation resourceLocation = meshProvider.getCustomLocation(); @@ -169,33 +139,28 @@ public class ClientProxy extends CommonProxy resourceLocation = new ResourceLocation(BloodMagic.MODID, "item/" + name); for (String variant : meshProvider.getVariants()) ModelLoader.registerItemVariants(item, new ModelResourceLocation(resourceLocation, variant)); - } else if (item instanceof IVariantProvider) - { + } else if (item instanceof IVariantProvider) { IVariantProvider variantProvider = (IVariantProvider) item; for (Pair variant : variantProvider.getVariants()) ModelLoader.setCustomModelResourceLocation(item, variant.getLeft(), new ModelResourceLocation(new ResourceLocation(BloodMagic.MODID, "item/" + name), variant.getRight())); } } - private void addElytraLayer() - { + private void addElytraLayer() { RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); - try - { + try { Map skinMap = ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, renderManager, "skinMap", "field_178636_l"); skinMap.get("default").addLayer(new LayerBloodElytra(skinMap.get("default"))); skinMap.get("slim").addLayer(new LayerBloodElytra(skinMap.get("slim"))); BloodMagic.instance.logger.info("Elytra layer added"); - } catch (Exception e) - { + } catch (Exception e) { BloodMagic.instance.logger.error("Failed to set custom Elytra Layer for Elytra Living Armour Upgrade."); BloodMagic.instance.logger.error(e.getLocalizedMessage()); } } @Override - public IAnimationStateMachine load(ResourceLocation location, ImmutableMap parameters) - { + public IAnimationStateMachine load(ResourceLocation location, ImmutableMap parameters) { return ModelLoaderRegistry.loadASM(location, parameters); } } diff --git a/src/main/java/WayofTime/bloodmagic/proxy/CommonProxy.java b/src/main/java/WayofTime/bloodmagic/proxy/CommonProxy.java index 4449daeb..636310a4 100644 --- a/src/main/java/WayofTime/bloodmagic/proxy/CommonProxy.java +++ b/src/main/java/WayofTime/bloodmagic/proxy/CommonProxy.java @@ -1,5 +1,10 @@ package WayofTime.bloodmagic.proxy; +import WayofTime.bloodmagic.api.ritual.CapabilityRuneType; +import WayofTime.bloodmagic.api.ritual.IRitualStone; +import WayofTime.bloodmagic.api.teleport.TeleportQueue; +import WayofTime.bloodmagic.fuel.FuelHandler; +import com.google.common.collect.ImmutableMap; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; @@ -9,55 +14,40 @@ import net.minecraftforge.common.animation.ITimeValue; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.model.animation.IAnimationStateMachine; import net.minecraftforge.fml.common.registry.GameRegistry; -import WayofTime.bloodmagic.api.ritual.CapabilityRuneType; -import WayofTime.bloodmagic.api.ritual.IRitualStone; -import WayofTime.bloodmagic.api.teleport.TeleportQueue; -import WayofTime.bloodmagic.fuel.FuelHandler; -import com.google.common.collect.ImmutableMap; - -public class CommonProxy -{ - public void preInit() - { +public class CommonProxy { + public void preInit() { MinecraftForge.EVENT_BUS.register(TeleportQueue.getInstance()); GameRegistry.registerFuelHandler(new FuelHandler()); registerRenderers(); } - public void init() - { + public void init() { CapabilityManager.INSTANCE.register(IRitualStone.Tile.class, new CapabilityRuneType.RuneTypeStorage(), new CapabilityRuneType.Factory()); } - public void postInit() - { + public void postInit() { } - public void registerRenderers() - { + public void registerRenderers() { } - public Object beamCont(World worldObj, double xi, double yi, double zi, double tx, double ty, double tz, int type, int color, boolean reverse, float endmod, Object input, int impact) - { + public Object beamCont(World worldObj, double xi, double yi, double zi, double tx, double ty, double tz, int type, int color, boolean reverse, float endmod, Object input, int impact) { // TODO Auto-generated method stub return null; } - public void tryHandleBlockModel(Block block, String name) - { + public void tryHandleBlockModel(Block block, String name) { // NO-OP } - public void tryHandleItemModel(Item item, String name) - { + public void tryHandleItemModel(Item item, String name) { // NO-OP } - public IAnimationStateMachine load(ResourceLocation location, ImmutableMap parameters) - { + public IAnimationStateMachine load(ResourceLocation location, ImmutableMap parameters) { return null; } } diff --git a/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTableDyeableRecipe.java b/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTableDyeableRecipe.java index bc8e601b..971e44cb 100644 --- a/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTableDyeableRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTableDyeableRecipe.java @@ -1,8 +1,7 @@ package WayofTime.bloodmagic.recipe.alchemyTable; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe; import net.minecraft.init.Items; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.ItemBanner; @@ -11,15 +10,14 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe; -public class AlchemyTableDyeableRecipe extends AlchemyTableRecipe -{ +import java.util.ArrayList; +import java.util.List; + +public class AlchemyTableDyeableRecipe extends AlchemyTableRecipe { private ItemStack inputItem; - public AlchemyTableDyeableRecipe(int lpDrained, int ticksRequired, int tierRequired, ItemStack inputItem) - { + public AlchemyTableDyeableRecipe(int lpDrained, int ticksRequired, int tierRequired, ItemStack inputItem) { super(inputItem, lpDrained, ticksRequired, tierRequired); ArrayList validDyes = new ArrayList(); @@ -36,58 +34,46 @@ public class AlchemyTableDyeableRecipe extends AlchemyTableRecipe } @Override - public ItemStack getRecipeOutput(List inputList) - { + public ItemStack getRecipeOutput(List inputList) { int nameTagOrDyeLocation = -1; int inputItemLocation = -1; - for (int x = 0; x < inputList.size(); x++) - { + for (int x = 0; x < inputList.size(); x++) { ItemStack slot = inputList.get(x); - if (slot != null) - { + if (slot != null) { boolean match = OreDictionary.itemMatches(inputItem, slot, false); - if (match) - { + if (match) { inputItemLocation = x; - } else - { - if (slot.getItem() == Items.NAME_TAG || slot.getItem() == Items.DYE) - { + } else { + if (slot.getItem() == Items.NAME_TAG || slot.getItem() == Items.DYE) { nameTagOrDyeLocation = x; } } } } - if (nameTagOrDyeLocation != -1 && inputItemLocation != -1) - { + if (nameTagOrDyeLocation != -1 && inputItemLocation != -1) { ItemStack tagOrDyeStack = inputList.get(nameTagOrDyeLocation); ItemStack inputStack = inputList.get(inputItemLocation); - if (inputStack.isEmpty() || tagOrDyeStack.isEmpty()) - { + if (inputStack.isEmpty() || tagOrDyeStack.isEmpty()) { return output.copy(); } ItemStack outputStack = inputStack.copy(); - if (tagOrDyeStack.getItem() == Items.NAME_TAG) - { - if (!outputStack.hasTagCompound()) - { + if (tagOrDyeStack.getItem() == Items.NAME_TAG) { + if (!outputStack.hasTagCompound()) { outputStack.setTagCompound(new NBTTagCompound()); } outputStack.getTagCompound().setString(Constants.NBT.COLOR, tagOrDyeStack.getDisplayName()); return outputStack; - } else - { + } else { EnumDyeColor dyeColor = ItemBanner.getBaseColor(tagOrDyeStack); - if (!outputStack.hasTagCompound()) - { + if (!outputStack.hasTagCompound()) { outputStack.setTagCompound(new NBTTagCompound()); } @@ -101,32 +87,23 @@ public class AlchemyTableDyeableRecipe extends AlchemyTableRecipe } @Override - public boolean matches(List checkedList, World world, BlockPos pos) - { + public boolean matches(List checkedList, World world, BlockPos pos) { boolean hasNameTagOrDye = false; boolean hasInputItem = false; - for (ItemStack slot : checkedList) - { - if (!slot.isEmpty()) - { + for (ItemStack slot : checkedList) { + if (!slot.isEmpty()) { boolean match = OreDictionary.itemMatches(inputItem, slot, false); - if (match && hasInputItem) - { + if (match && hasInputItem) { return false; - } else if (match) - { + } else if (match) { hasInputItem = true; - } 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 4b9811cb..ebd06887 100644 --- a/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTablePotionAugmentRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTablePotionAugmentRecipe.java @@ -1,27 +1,26 @@ package WayofTime.bloodmagic.recipe.alchemyTable; -import java.util.*; - +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.potion.BMPotionUtils; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionUtils; -import WayofTime.bloodmagic.potion.BMPotionUtils; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -public class AlchemyTablePotionAugmentRecipe extends AlchemyTablePotionRecipe -{ +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class AlchemyTablePotionAugmentRecipe extends AlchemyTablePotionRecipe { protected double lengthAugment = 0; protected int powerAugment = 0; protected Potion wantedPotion; - public AlchemyTablePotionAugmentRecipe(int lpDrained, int ticksRequired, int tierRequired, List inputItems, PotionEffect baseEffect, double lengthAugment, int powerAugment) - { + public AlchemyTablePotionAugmentRecipe(int lpDrained, int ticksRequired, int tierRequired, List inputItems, PotionEffect baseEffect, double lengthAugment, int powerAugment) { super(lpDrained, ticksRequired, tierRequired, inputItems, baseEffect); ArrayList recipe = new ArrayList(); - for (ItemStack stack : inputItems) - { + for (ItemStack stack : inputItems) { recipe.add(stack); } recipe.add(getAugmentedPotionFlask(baseEffect)); @@ -33,19 +32,15 @@ public class AlchemyTablePotionAugmentRecipe extends AlchemyTablePotionRecipe this.powerAugment = powerAugment; } - public AlchemyTablePotionAugmentRecipe(int lpDrained, int ticksRequired, int tierRequired, ItemStack inputItem, PotionEffect baseEffect, double lengthAugment, int powerAugment) - { + public AlchemyTablePotionAugmentRecipe(int lpDrained, int ticksRequired, int tierRequired, ItemStack inputItem, PotionEffect baseEffect, double lengthAugment, int powerAugment) { this(lpDrained, ticksRequired, tierRequired, Collections.singletonList(inputItem), baseEffect, lengthAugment, powerAugment); } @Override - public boolean isPotionFlaskValidInput(ItemStack stack) - { + public boolean isPotionFlaskValidInput(ItemStack stack) { List effectList = PotionUtils.getEffectsFromStack(stack); - for (PotionEffect eff : effectList) - { - if (eff.getPotion() == wantedPotion) - { + for (PotionEffect eff : effectList) { + if (eff.getPotion() == wantedPotion) { double currentAugment = BMPotionUtils.getLengthAugment(stack, wantedPotion); return currentAugment < lengthAugment || eff.getAmplifier() < powerAugment; @@ -56,10 +51,8 @@ public class AlchemyTablePotionAugmentRecipe extends AlchemyTablePotionRecipe } @Override - public ItemStack getModifiedFlaskForInput(ItemStack inputStack) - { - if (inputStack == null) - { + public ItemStack getModifiedFlaskForInput(ItemStack inputStack) { + if (inputStack == null) { ItemStack outputStack = new ItemStack(RegistrarBloodMagicItems.POTION_FLASK); List effectList = new ArrayList(); @@ -93,8 +86,7 @@ public class AlchemyTablePotionAugmentRecipe extends AlchemyTablePotionRecipe return outputStack; } - public static ItemStack getAugmentedPotionFlask(PotionEffect baseEffect) - { + public static ItemStack getAugmentedPotionFlask(PotionEffect baseEffect) { ItemStack outputStack = new ItemStack(RegistrarBloodMagicItems.POTION_FLASK); List effectList = new ArrayList(); diff --git a/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTablePotionRecipe.java b/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTablePotionRecipe.java index 032bff2f..bd97772c 100644 --- a/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTablePotionRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/recipe/alchemyTable/AlchemyTablePotionRecipe.java @@ -1,32 +1,30 @@ package WayofTime.bloodmagic.recipe.alchemyTable; -import java.util.*; - +import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionUtils; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; -import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -public class AlchemyTablePotionRecipe extends AlchemyTableRecipe -{ +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +public class AlchemyTablePotionRecipe extends AlchemyTableRecipe { public static final ItemStack basePotionFlaskStack = new ItemStack(RegistrarBloodMagicItems.POTION_FLASK, 1, OreDictionary.WILDCARD_VALUE); - protected PotionEffect baseEffect; - public static final int temporaryMaximumEffectsOnThePotionFlaskYesThisIsALongFieldItIsJustSoIRemember = 3; - + protected PotionEffect baseEffect; protected double baseAddedImpurity = 5; - public AlchemyTablePotionRecipe(int lpDrained, int ticksRequired, int tierRequired, List inputItems, PotionEffect baseEffect) - { + public AlchemyTablePotionRecipe(int lpDrained, int ticksRequired, int tierRequired, List inputItems, PotionEffect baseEffect) { super(basePotionFlaskStack, lpDrained, ticksRequired, tierRequired); ArrayList recipe = new ArrayList(); - for (ItemStack stack : inputItems) - { + for (ItemStack stack : inputItems) { recipe.add(stack); } recipe.add(basePotionFlaskStack); @@ -35,32 +33,26 @@ public class AlchemyTablePotionRecipe extends AlchemyTableRecipe this.baseEffect = baseEffect; } - public AlchemyTablePotionRecipe(int lpDrained, int ticksRequired, int tierRequired, ItemStack inputItem, PotionEffect baseEffect) - { + public AlchemyTablePotionRecipe(int lpDrained, int ticksRequired, int tierRequired, ItemStack inputItem, PotionEffect baseEffect) { this(lpDrained, ticksRequired, tierRequired, Collections.singletonList(inputItem), baseEffect); } @Override - public ItemStack getRecipeOutput(List inputList) - { + public ItemStack getRecipeOutput(List inputList) { int flaskLocation = -1; - for (int x = 0; x < inputList.size(); x++) - { + for (int x = 0; x < inputList.size(); x++) { ItemStack slot = inputList.get(x); - if (slot != null) - { + if (slot != null) { boolean match = slot.getItem() == RegistrarBloodMagicItems.POTION_FLASK; - if (match) - { + if (match) { flaskLocation = x; } } } - if (flaskLocation != -1) - { + if (flaskLocation != -1) { return getModifiedFlaskForInput(inputList.get(flaskLocation)); } @@ -68,8 +60,7 @@ public class AlchemyTablePotionRecipe extends AlchemyTableRecipe } @Override - public boolean matches(List checkedList, World world, BlockPos pos) - { + public boolean matches(List checkedList, World world, BlockPos pos) { ArrayList required = new ArrayList(input); for (ItemStack slot : checkedList) { @@ -112,18 +103,14 @@ public class AlchemyTablePotionRecipe extends AlchemyTableRecipe return required.isEmpty(); } - public boolean isPotionFlaskValidInput(ItemStack stack) - { + public boolean isPotionFlaskValidInput(ItemStack stack) { List effectList = PotionUtils.getEffectsFromStack(stack); - if (effectList.size() >= temporaryMaximumEffectsOnThePotionFlaskYesThisIsALongFieldItIsJustSoIRemember) - { + if (effectList.size() >= temporaryMaximumEffectsOnThePotionFlaskYesThisIsALongFieldItIsJustSoIRemember) { return false; } - for (PotionEffect eff : effectList) - { - if (eff.getPotion() == baseEffect.getPotion()) - { + for (PotionEffect eff : effectList) { + if (eff.getPotion() == baseEffect.getPotion()) { return false; } } @@ -131,10 +118,8 @@ public class AlchemyTablePotionRecipe extends AlchemyTableRecipe return true; } - public ItemStack getModifiedFlaskForInput(ItemStack inputStack) - { - if (inputStack.isEmpty()) - { + public ItemStack getModifiedFlaskForInput(ItemStack inputStack) { + if (inputStack.isEmpty()) { ItemStack outputStack = new ItemStack(RegistrarBloodMagicItems.POTION_FLASK); List effectList = new ArrayList(); diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModArmourTrackers.java b/src/main/java/WayofTime/bloodmagic/registry/ModArmourTrackers.java index ca58b1b7..4e0e9d18 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModArmourTrackers.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModArmourTrackers.java @@ -1,64 +1,12 @@ package WayofTime.bloodmagic.registry; import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeBattleHungry; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeCrippledArm; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeDigSlowdown; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeDisoriented; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeMeleeDecrease; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeQuenched; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeSlippery; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeSlowHeal; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeSlowness; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeStormTrooper; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerArrowShot; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerCriticalStrike; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerDigging; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerExperience; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerFallProtect; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerFireResist; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerFood; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGraveDigger; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerHealthboost; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerJump; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerMeleeDamage; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerMovement; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerNightSight; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerPhysicalProtect; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerPoison; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerRepairing; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSelfSacrifice; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSolarPowered; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSprintAttack; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerStepAssist; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeArrowShot; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeCriticalStrike; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeDigging; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeElytra; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeExperience; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeFallProtect; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeFireResist; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeGraveDigger; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeGrimReaperSprint; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeHealthboost; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeJump; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeKnockbackResist; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeMeleeDamage; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeNightSight; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradePhysicalProtect; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradePoisonResist; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeRepairing; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSolarPowered; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSpeed; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSprintAttack; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeStepAssist; +import WayofTime.bloodmagic.livingArmour.downgrade.*; +import WayofTime.bloodmagic.livingArmour.tracker.*; +import WayofTime.bloodmagic.livingArmour.upgrade.*; -public class ModArmourTrackers -{ - public static void init() - { +public class ModArmourTrackers { + public static void init() { LivingArmourHandler.registerStatTracker(StatTrackerMovement.class); LivingArmourHandler.registerStatTracker(StatTrackerDigging.class); LivingArmourHandler.registerStatTracker(StatTrackerPoison.class); diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModCorruptionBlocks.java b/src/main/java/WayofTime/bloodmagic/registry/ModCorruptionBlocks.java index c425cfd9..fff4f109 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModCorruptionBlocks.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModCorruptionBlocks.java @@ -1,16 +1,13 @@ package WayofTime.bloodmagic.registry; -import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; -import net.minecraft.init.Blocks; import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; import WayofTime.bloodmagic.inversion.CorruptionHandler; +import net.minecraft.init.Blocks; -public class ModCorruptionBlocks -{ - public static void init() - { - for (EnumDemonWillType type : EnumDemonWillType.values()) - { +public class ModCorruptionBlocks { + public static void init() { + for (EnumDemonWillType type : EnumDemonWillType.values()) { CorruptionHandler.registerBlockCorruption(type, Blocks.STONE, 0, RegistrarBloodMagicBlocks.DEMON_EXTRAS.getStateFromMeta(type.ordinal())); CorruptionHandler.registerBlockCorruption(type, Blocks.GRASS, 0, RegistrarBloodMagicBlocks.DEMON_EXTRAS.getStateFromMeta(type.ordinal())); CorruptionHandler.registerBlockCorruption(type, Blocks.DIRT, 0, RegistrarBloodMagicBlocks.DEMON_EXTRAS.getStateFromMeta(type.ordinal())); diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java b/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java index be432487..f88962e2 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java @@ -1,20 +1,37 @@ package WayofTime.bloodmagic.registry; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.*; -import java.util.Map.Entry; - +import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.ConfigHandler; +import WayofTime.bloodmagic.alchemyArray.*; +import WayofTime.bloodmagic.api.altar.EnumAltarTier; +import WayofTime.bloodmagic.api.compress.CompressionRegistry; +import WayofTime.bloodmagic.api.iface.ISigil; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.orb.BloodOrb; import WayofTime.bloodmagic.api.orb.IBloodOrb; +import WayofTime.bloodmagic.api.recipe.AlchemyTableCustomRecipe; +import WayofTime.bloodmagic.api.registry.*; +import WayofTime.bloodmagic.api.ritual.EnumRuneType; import WayofTime.bloodmagic.block.enums.EnumBloodRune; +import WayofTime.bloodmagic.client.render.alchemyArray.*; +import WayofTime.bloodmagic.compress.AdvancedCompressionHandler; +import WayofTime.bloodmagic.compress.BaseCompressionHandler; +import WayofTime.bloodmagic.compress.StorageBlockCraftingManager; import WayofTime.bloodmagic.core.RegistrarBloodMagic; import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.item.ItemComponent; +import WayofTime.bloodmagic.item.ItemDemonCrystal; +import WayofTime.bloodmagic.item.alchemy.ItemCuttingFluid; +import WayofTime.bloodmagic.item.alchemy.ItemLivingArmourPointsUpgrade; import WayofTime.bloodmagic.item.soul.ItemSoulGem; +import WayofTime.bloodmagic.livingArmour.downgrade.*; +import WayofTime.bloodmagic.potion.BMPotionUtils; +import WayofTime.bloodmagic.recipe.alchemyTable.AlchemyTableDyeableRecipe; +import WayofTime.bloodmagic.recipe.alchemyTable.AlchemyTablePotionRecipe; import WayofTime.bloodmagic.tile.TileBloodTank; +import WayofTime.bloodmagic.util.Utils; +import com.google.common.base.Stopwatch; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -32,63 +49,23 @@ import net.minecraft.util.text.TextComponentTranslation; import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.oredict.OreDictionary; - import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectAttractor; -import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectBinding; -import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectBounce; -import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectMovement; -import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectSigil; -import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectSkeletonTurret; -import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectUpdraft; -import WayofTime.bloodmagic.api.altar.EnumAltarTier; -import WayofTime.bloodmagic.api.compress.CompressionRegistry; -import WayofTime.bloodmagic.api.iface.ISigil; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.api.recipe.AlchemyTableCustomRecipe; -import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry; -import WayofTime.bloodmagic.api.registry.AlchemyTableRecipeRegistry; -import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry; -import WayofTime.bloodmagic.api.registry.LivingArmourDowngradeRecipeRegistry; -import WayofTime.bloodmagic.api.registry.OrbRegistry; -import WayofTime.bloodmagic.api.registry.TartaricForgeRecipeRegistry; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.client.render.alchemyArray.AttractorAlchemyCircleRenderer; -import WayofTime.bloodmagic.client.render.alchemyArray.BindingAlchemyCircleRenderer; -import WayofTime.bloodmagic.client.render.alchemyArray.DualAlchemyCircleRenderer; -import WayofTime.bloodmagic.client.render.alchemyArray.SingleAlchemyCircleRenderer; -import WayofTime.bloodmagic.client.render.alchemyArray.StaticAlchemyCircleRenderer; -import WayofTime.bloodmagic.compress.AdvancedCompressionHandler; -import WayofTime.bloodmagic.compress.BaseCompressionHandler; -import WayofTime.bloodmagic.compress.StorageBlockCraftingManager; -import WayofTime.bloodmagic.item.ItemComponent; -import WayofTime.bloodmagic.item.ItemDemonCrystal; -import WayofTime.bloodmagic.item.alchemy.ItemCuttingFluid; -import WayofTime.bloodmagic.item.alchemy.ItemLivingArmourPointsUpgrade; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeBattleHungry; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeCrippledArm; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeDigSlowdown; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeDisoriented; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeMeleeDecrease; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeQuenched; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeSlowHeal; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeSlowness; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeStormTrooper; -import WayofTime.bloodmagic.potion.BMPotionUtils; -import WayofTime.bloodmagic.recipe.alchemyTable.AlchemyTableDyeableRecipe; -import WayofTime.bloodmagic.recipe.alchemyTable.AlchemyTablePotionRecipe; -import WayofTime.bloodmagic.util.Utils; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.*; +import java.util.Map.Entry; -import com.google.common.base.Stopwatch; - -public class ModRecipes -{ +public class ModRecipes { + private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); + private static final Set USED_OD_NAMES = new TreeSet<>(); public static ArrayList addedOreRecipeList = new ArrayList(); + static ItemStack mundaneLengtheningStack = ItemComponent.getStack(ItemComponent.CATALYST_LENGTH_1); + static ItemStack mundanePowerStack = ItemComponent.getStack(ItemComponent.CATALYST_POWER_1); + private static File RECIPE_DIR = null; - public static void init() - { + public static void init() { initOreDict(); addFurnaceRecipes(); // addCraftingRecipes(); @@ -101,21 +78,18 @@ public class ModRecipes addLivingArmourDowngradeRecipes(); } - public static void initOreDict() - { + public static void initOreDict() { OreDictionary.registerOre("dustIron", ItemComponent.getStack(ItemComponent.SAND_IRON)); OreDictionary.registerOre("dustGold", ItemComponent.getStack(ItemComponent.SAND_GOLD)); OreDictionary.registerOre("dustCoal", ItemComponent.getStack(ItemComponent.SAND_COAL)); } - public static void addFurnaceRecipes() - { + public static void addFurnaceRecipes() { FurnaceRecipes.instance().addSmeltingRecipe(ItemComponent.getStack(ItemComponent.SAND_IRON), new ItemStack(Items.IRON_INGOT), (float) 0.15); FurnaceRecipes.instance().addSmeltingRecipe(ItemComponent.getStack(ItemComponent.SAND_GOLD), new ItemStack(Items.GOLD_INGOT), (float) 0.15); } - public static void addCraftingRecipes() - { + public static void addCraftingRecipes() { addShapedRecipe(new ItemStack(RegistrarBloodMagicBlocks.SOUL_FORGE), "i i", "sgs", "sos", 'i', "ingotIron", 's', "stone", 'g', "ingotGold", 'o', "blockIron"); addShapedRecipe(new ItemStack(RegistrarBloodMagicItems.SACRIFICIAL_DAGGER), "aaa", " ba", "c a", 'a', "blockGlass", 'b', "ingotGold", 'c', "ingotIron"); addShapedRecipe(new ItemStack(RegistrarBloodMagicBlocks.ALTAR), "a a", "aba", "cdc", 'a', "stone", 'b', Blocks.FURNACE, 'c', "ingotGold", 'd', new ItemStack(RegistrarBloodMagicItems.MONSTER_SOUL)); @@ -179,10 +153,8 @@ public class ModRecipes for (int i = 1; i < EnumBloodRune.values().length; i++) addShapelessRecipe(new ItemStack(RegistrarBloodMagicBlocks.BLOOD_RUNE), new ItemStack(RegistrarBloodMagicBlocks.BLOOD_RUNE, 1, i)); - for (int i = 0; i < ItemSoulGem.names.length; i++) - { - for (int j = 0; j < ItemDemonCrystal.NAMES.size(); j++) - { + for (int i = 0; i < ItemSoulGem.names.length; i++) { + for (int j = 0; j < ItemDemonCrystal.NAMES.size(); j++) { ItemStack baseGemStack = new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, i); ItemStack newGemStack = new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, i); @@ -198,8 +170,7 @@ public class ModRecipes // GameRegistry.addRecipe(new ShapedBloodOrbRecipe(new ItemStack(RegistrarBloodMagicBlocks.MIMIC, 4, 2), "bsb", "srs", "bob", 'b', new ItemStack(RegistrarBloodMagicBlocks.DECORATIVE_BRICK), 'r', new ItemStack(RegistrarBloodMagicBlocks.BLOOD_RUNE), 's', "blockGlass", 'o', OrbRegistry.getOrbStack(RegistrarBloodMagicItems.ORB_MAGICIAN))); // GameRegistry.addRecipe(new ShapedBloodOrbRecipe(new ItemStack(RegistrarBloodMagicBlocks.MIMIC, 2, 3), "bnb", "trt", "bob", 'b', new ItemStack(RegistrarBloodMagicBlocks.DECORATIVE_BRICK), 'r', new ItemStack(RegistrarBloodMagicBlocks.BLOOD_RUNE), 'n', "glowstone", 't', "torch", 'o', OrbRegistry.getOrbStack(RegistrarBloodMagicItems.ORB_MAGICIAN))); - for (int i = 0; i < 5; i++) - { + for (int i = 0; i < 5; i++) { ItemStack crystalStack = new ItemStack(RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL, 1, i); ItemStack baseStoneStack = new ItemStack(RegistrarBloodMagicBlocks.DEMON_EXTRAS, 1, i); ItemStack baseStoneStackCrafted = new ItemStack(RegistrarBloodMagicBlocks.DEMON_EXTRAS, 16, i); @@ -235,8 +206,7 @@ public class ModRecipes generateConstants(); } - public static void addAltarRecipes() - { + public static void addAltarRecipes() { // ONE AltarRecipeRegistry.registerFillRecipe(OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_WEAK), EnumAltarTier.ONE, RegistrarBloodMagic.ORB_WEAK.getCapacity(), 2, 1); AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Items.DIAMOND), OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_WEAK), EnumAltarTier.ONE, 2000, 2, 1)); @@ -279,8 +249,7 @@ public class ModRecipes AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Blocks.GLOWSTONE), EnumRuneType.DAWN.getScribeStack(), EnumAltarTier.SIX, 200000, 100, 200)); } - public static void addAlchemyArrayRecipes() - { + public static void addAlchemyArrayRecipes() { AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.DIAMOND_SWORD), new AlchemyArrayEffectBinding("boundSword", Utils.setUnbreakable(new ItemStack(RegistrarBloodMagicItems.BOUND_SWORD))), new BindingAlchemyCircleRenderer()); AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.DIAMOND_AXE), new AlchemyArrayEffectBinding("boundAxe", Utils.setUnbreakable(new ItemStack(RegistrarBloodMagicItems.BOUND_AXE)))); AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.DIAMOND_PICKAXE), new AlchemyArrayEffectBinding("boundPickaxe", Utils.setUnbreakable(new ItemStack(RegistrarBloodMagicItems.BOUND_PICKAXE)))); @@ -325,8 +294,7 @@ public class ModRecipes } - public static void addCompressionHandlers() - { + public static void addCompressionHandlers() { Stopwatch stopwatch = Stopwatch.createStarted(); StorageBlockCraftingManager.getInstance().addStorageBlockRecipes(); CompressionRegistry.registerHandler(new BaseCompressionHandler(new ItemStack(Items.GLOWSTONE_DUST, 4, 0), new ItemStack(Blocks.GLOWSTONE), 64)); @@ -339,8 +307,7 @@ public class ModRecipes BloodMagic.instance.logger.info("Added compression recipes in {}", stopwatch); } - public static void addSoulForgeRecipes() - { + public static void addSoulForgeRecipes() { TartaricForgeRecipeRegistry.registerRecipe(new ItemStack(RegistrarBloodMagicItems.SOUL_GEM), 1, 1, "dustRedstone", "ingotGold", "blockGlass", "dyeBlue"); TartaricForgeRecipeRegistry.registerRecipe(new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 1), 60, 20, new ItemStack(RegistrarBloodMagicItems.SOUL_GEM), "gemDiamond", "blockRedstone", "blockLapis"); TartaricForgeRecipeRegistry.registerRecipe(new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 2), 240, 50, new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 1), "gemDiamond", "blockGold", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 2)); @@ -396,8 +363,7 @@ public class ModRecipes TartaricForgeRecipeRegistry.registerRecipe(new ItemStack(RegistrarBloodMagicItems.DEMON_WILL_GAUGE), 400, 50, "ingotGold", "dustRedstone", "blockGlass", RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL); } - public static void addAlchemyTableRecipes() - { + public static void addAlchemyTableRecipes() { AlchemyTableRecipeRegistry.registerRecipe(new ItemStack(Items.STRING, 4), 0, 100, 0, Blocks.WOOL, Items.FLINT); AlchemyTableRecipeRegistry.registerRecipe(new ItemStack(Items.FLINT, 2), 0, 20, 0, Blocks.GRAVEL, Items.FLINT); AlchemyTableRecipeRegistry.registerRecipe(new ItemStack(Items.LEATHER, 4), 100, 200, 1, Items.ROTTEN_FLESH, Items.ROTTEN_FLESH, Items.ROTTEN_FLESH, Items.ROTTEN_FLESH, Items.FLINT, Items.WATER_BUCKET); @@ -448,19 +414,15 @@ public class ModRecipes AlchemyTableRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.CATALYST_POWER_1), 1000, 100, 2, "gunpowder", "cropNetherWart", "dustRedstone"); } - public static void addOreDoublingAlchemyRecipes() - { + public static void addOreDoublingAlchemyRecipes() { String[] oreList = OreDictionary.getOreNames().clone(); - for (String ore : oreList) - { - if (ore.startsWith("ore") && !addedOreRecipeList.contains(ore)) - { + for (String ore : oreList) { + if (ore.startsWith("ore") && !addedOreRecipeList.contains(ore)) { String dustName = ore.replaceFirst("ore", "dust"); List discoveredOres = OreDictionary.getOres(ore); List dustList = OreDictionary.getOres(dustName); - if (dustList != null && !dustList.isEmpty() && discoveredOres != null && !discoveredOres.isEmpty()) - { + if (dustList != null && !dustList.isEmpty() && discoveredOres != null && !discoveredOres.isEmpty()) { ItemStack dustStack = dustList.get(0).copy(); dustStack.setCount(2); AlchemyTableRecipeRegistry.registerRecipe(new AlchemyTableCustomRecipe(dustStack, 400, 200, 1, ore, ItemCuttingFluid.getStack(ItemCuttingFluid.BASIC))); @@ -470,8 +432,7 @@ public class ModRecipes } } - public static void addPotionRecipes() - { + public static void addPotionRecipes() { addPotionRecipe(1000, 1, new ItemStack(Items.GHAST_TEAR), new PotionEffect(MobEffects.REGENERATION, 450)); addPotionRecipe(1000, 1, new ItemStack(Items.GOLDEN_CARROT), new PotionEffect(MobEffects.NIGHT_VISION, 2 * 60 * 20)); addPotionRecipe(1000, 1, new ItemStack(Items.MAGMA_CREAM), new PotionEffect(MobEffects.FIRE_RESISTANCE, 2 * 60 * 20)); @@ -497,11 +458,7 @@ public class ModRecipes // AlchemyTableRecipeRegistry.registerRecipe(new AlchemyTablePotionRecipe(5000, 100, 4, new ItemStack("string"), new PotionEffect(ModPotions.bounce, 15 * 60 * 20))); } - static ItemStack mundaneLengtheningStack = ItemComponent.getStack(ItemComponent.CATALYST_LENGTH_1); - static ItemStack mundanePowerStack = ItemComponent.getStack(ItemComponent.CATALYST_POWER_1); - - public static void addPotionRecipe(int lpDrained, int tier, ItemStack inputStack, PotionEffect baseEffect) - { + public static void addPotionRecipe(int lpDrained, int tier, ItemStack inputStack, PotionEffect baseEffect) { AlchemyTableRecipeRegistry.registerRecipe(new AlchemyTablePotionRecipe(lpDrained, 100, tier, inputStack, baseEffect)); List lengtheningList = new ArrayList(); @@ -515,8 +472,7 @@ public class ModRecipes AlchemyTableRecipeRegistry.registerRecipe(BMPotionUtils.getPowerAugmentRecipe(lpDrained, 100, tier, powerList, baseEffect, 1)); } - public static void addLivingArmourDowngradeRecipes() - { + public static void addLivingArmourDowngradeRecipes() { String messageBase = "ritual.bloodmagic.downgradeRitual.dialogue."; ItemStack bowStack = new ItemStack(Items.BOW); @@ -530,18 +486,16 @@ public class ModRecipes ItemStack stringStack = new ItemStack(Items.STRING); Map> dialogueMap = new HashMap>(); - dialogueMap.put(bowStack, Pair.of("bow", new int[] { 1, 100, 300, 500 })); - dialogueMap.put(bottleStack, Pair.of("quenched", new int[] { 1, 100, 300, 500 })); - dialogueMap.put(swordStack, Pair.of("dulledBlade", new int[] { 1, 100, 300, 500, 700 })); - dialogueMap.put(goldenAppleStack, Pair.of("slowHeal", new int[] { 1, 100, 300, 500, 700 })); + dialogueMap.put(bowStack, Pair.of("bow", new int[]{1, 100, 300, 500})); + dialogueMap.put(bottleStack, Pair.of("quenched", new int[]{1, 100, 300, 500})); + dialogueMap.put(swordStack, Pair.of("dulledBlade", new int[]{1, 100, 300, 500, 700})); + dialogueMap.put(goldenAppleStack, Pair.of("slowHeal", new int[]{1, 100, 300, 500, 700})); - for (Entry> entry : dialogueMap.entrySet()) - { + for (Entry> entry : dialogueMap.entrySet()) { ItemStack keyStack = entry.getKey(); String str = entry.getValue().getKey(); Map> textMap = new HashMap>(); - for (int tick : entry.getValue().getValue()) - { + for (int tick : entry.getValue().getValue()) { List textList = new ArrayList(); textList.add(new TextComponentTranslation("\u00A74%s", new TextComponentTranslation(messageBase + str + "." + tick))); textMap.put(tick, textList); @@ -559,8 +513,7 @@ public class ModRecipes LivingArmourDowngradeRecipeRegistry.registerRecipe(new LivingArmourUpgradeQuenched(0), bottleStack, Items.DRAGON_BREATH); LivingArmourDowngradeRecipeRegistry.registerRecipe(new LivingArmourUpgradeCrippledArm(0), shieldStack, "gemDiamond"); - for (int i = 0; i < 10; i++) - { + for (int i = 0; i < 10; i++) { addRecipeForTieredDowngrade(new LivingArmourUpgradeMeleeDecrease(i), swordStack, i); addRecipeForTieredDowngrade(new LivingArmourUpgradeSlowHeal(i), goldenAppleStack, i); addRecipeForTieredDowngrade(new LivingArmourUpgradeBattleHungry(i), fleshStack, i); @@ -570,46 +523,40 @@ public class ModRecipes } } - public static void addRecipeForTieredDowngrade(LivingArmourUpgrade upgrade, ItemStack stack, int tier) - { - switch (tier) - { - case 0: - LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, "ingotIron", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 0)); - break; - case 1: - LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, "dustRedstone", "dustRedstone", "ingotIron", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 0)); - break; - case 2: - LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, "ingotGold", "gemLapis", "gemLapis", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 1)); - break; - case 3: - LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, Blocks.VINE, "dyeRed", Items.GOLDEN_CARROT, new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 1)); - break; - case 4: - LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, Items.GOLDEN_APPLE, "treeSapling", "treeSapling", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 2)); - break; - case 5: - LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, Blocks.IRON_BLOCK, Blocks.REDSTONE_BLOCK, new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 2)); - break; - case 6: - LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, Blocks.IRON_BLOCK, Blocks.GLOWSTONE, "ingotGold", "ingotGold", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 3)); - break; - case 7: - LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, Blocks.GOLD_BLOCK, Blocks.LAPIS_BLOCK, "gemDiamond", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 3)); - break; - case 8: - LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, Items.DRAGON_BREATH, "gemDiamond", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 4)); - break; - case 9: - LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, Items.NETHER_STAR, "gemDiamond", "gemDiamond", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 4)); + public static void addRecipeForTieredDowngrade(LivingArmourUpgrade upgrade, ItemStack stack, int tier) { + switch (tier) { + case 0: + LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, "ingotIron", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 0)); + break; + case 1: + LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, "dustRedstone", "dustRedstone", "ingotIron", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 0)); + break; + case 2: + LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, "ingotGold", "gemLapis", "gemLapis", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 1)); + break; + case 3: + LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, Blocks.VINE, "dyeRed", Items.GOLDEN_CARROT, new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 1)); + break; + case 4: + LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, Items.GOLDEN_APPLE, "treeSapling", "treeSapling", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 2)); + break; + case 5: + LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, Blocks.IRON_BLOCK, Blocks.REDSTONE_BLOCK, new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 2)); + break; + case 6: + LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, Blocks.IRON_BLOCK, Blocks.GLOWSTONE, "ingotGold", "ingotGold", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 3)); + break; + case 7: + LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, Blocks.GOLD_BLOCK, Blocks.LAPIS_BLOCK, "gemDiamond", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 3)); + break; + case 8: + LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, Items.DRAGON_BREATH, "gemDiamond", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 4)); + break; + case 9: + LivingArmourDowngradeRecipeRegistry.registerRecipe(upgrade, stack, Items.NETHER_STAR, "gemDiamond", "gemDiamond", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 4)); } } - private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); - private static File RECIPE_DIR = null; - private static final Set USED_OD_NAMES = new TreeSet<>(); - private static void setupDir() { if (RECIPE_DIR == null) { RECIPE_DIR = ConfigHandler.config.getConfigFile().toPath().resolve("../recipes/").toFile(); @@ -675,8 +622,7 @@ public class ModRecipes } } - private static void addShapelessRecipe(ItemStack result, Object... components) - { + private static void addShapelessRecipe(ItemStack result, Object... components) { setupDir(); // addShapelessRecipe(result, components); @@ -768,7 +714,7 @@ public class ModRecipes GSON.toJson(json, w); } catch (IOException e) { e.printStackTrace(); - + } } } diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java b/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java index b03ccce2..ad026e23 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java @@ -1,6 +1,5 @@ package WayofTime.bloodmagic.registry; -import net.minecraft.init.Blocks; import WayofTime.bloodmagic.ConfigHandler; import WayofTime.bloodmagic.api.BlockStack; import WayofTime.bloodmagic.api.registry.HarvestRegistry; @@ -9,35 +8,7 @@ import WayofTime.bloodmagic.api.registry.RitualRegistry; import WayofTime.bloodmagic.api.ritual.Ritual; import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual; import WayofTime.bloodmagic.item.alchemy.ItemCuttingFluid; -import WayofTime.bloodmagic.ritual.RitualAltarBuilder; -import WayofTime.bloodmagic.ritual.RitualAnimalGrowth; -import WayofTime.bloodmagic.ritual.RitualArmourEvolve; -import WayofTime.bloodmagic.ritual.RitualContainment; -import WayofTime.bloodmagic.ritual.RitualCrushing; -import WayofTime.bloodmagic.ritual.RitualCrystalHarvest; -import WayofTime.bloodmagic.ritual.RitualExpulsion; -import WayofTime.bloodmagic.ritual.RitualFeatheredKnife; -import WayofTime.bloodmagic.ritual.RitualFelling; -import WayofTime.bloodmagic.ritual.RitualForsakenSoul; -import WayofTime.bloodmagic.ritual.RitualFullStomach; -import WayofTime.bloodmagic.ritual.RitualGreenGrove; -import WayofTime.bloodmagic.ritual.RitualHarvest; -import WayofTime.bloodmagic.ritual.RitualInterdiction; -import WayofTime.bloodmagic.ritual.RitualJumping; -import WayofTime.bloodmagic.ritual.RitualLava; -import WayofTime.bloodmagic.ritual.RitualLivingArmourDowngrade; -import WayofTime.bloodmagic.ritual.RitualMagnetic; -import WayofTime.bloodmagic.ritual.RitualMeteor; -import WayofTime.bloodmagic.ritual.RitualPlacer; -import WayofTime.bloodmagic.ritual.RitualPortal; -import WayofTime.bloodmagic.ritual.RitualPump; -import WayofTime.bloodmagic.ritual.RitualRegeneration; -import WayofTime.bloodmagic.ritual.RitualSpeed; -import WayofTime.bloodmagic.ritual.RitualSuppression; -import WayofTime.bloodmagic.ritual.RitualUpgradeRemove; -import WayofTime.bloodmagic.ritual.RitualWater; -import WayofTime.bloodmagic.ritual.RitualWellOfSuffering; -import WayofTime.bloodmagic.ritual.RitualZephyr; +import WayofTime.bloodmagic.ritual.*; import WayofTime.bloodmagic.ritual.harvest.HarvestHandlerPlantable; import WayofTime.bloodmagic.ritual.harvest.HarvestHandlerStem; import WayofTime.bloodmagic.ritual.harvest.HarvestHandlerTall; @@ -45,9 +16,9 @@ import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitualNight; import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitualRain; import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitualResistance; import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitualZombie; +import net.minecraft.init.Blocks; -public class ModRituals -{ +public class ModRituals { public static Ritual waterRitual; public static Ritual lavaRitual; public static Ritual greenGroveRitual; @@ -71,7 +42,7 @@ public class ModRituals public static Ritual forsakenSoulRitual; public static Ritual crystalHarvestRitual; -// public static Ritual cobblestoneRitual; + // public static Ritual cobblestoneRitual; public static Ritual placerRitual; public static Ritual fellingRitual; public static Ritual pumpRitual; @@ -87,8 +58,7 @@ public class ModRituals public static ImperfectRitual imperfectResistance; public static ImperfectRitual imperfectZombie; - public static void initRituals() - { + public static void initRituals() { waterRitual = new RitualWater(); RitualRegistry.registerRitual(waterRitual, ConfigHandler.ritualWater); lavaRitual = new RitualLava(); @@ -157,8 +127,7 @@ public class ModRituals RitualCrushing.registerCuttingFluid(ItemCuttingFluid.getStack(ItemCuttingFluid.EXPLOSIVE), 25, 0.05); } - public static void initImperfectRituals() - { + public static void initImperfectRituals() { imperfectNight = new ImperfectRitualNight(); ImperfectRitualRegistry.registerRitual(imperfectNight, ConfigHandler.imperfectRitualNight); imperfectRain = new ImperfectRitualRain(); @@ -169,8 +138,7 @@ public class ModRituals ImperfectRitualRegistry.registerRitual(imperfectZombie, ConfigHandler.imperfectRitualZombie); } - public static void initHarvestHandlers() - { + public static void initHarvestHandlers() { HarvestRegistry.registerRangeAmplifier(new BlockStack(Blocks.DIAMOND_BLOCK), 15); HarvestRegistry.registerRangeAmplifier(new BlockStack(Blocks.GOLD_BLOCK), 10); HarvestRegistry.registerRangeAmplifier(new BlockStack(Blocks.IRON_BLOCK), 6); diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModTranquilityHandlers.java b/src/main/java/WayofTime/bloodmagic/registry/ModTranquilityHandlers.java index 0c7c8c4b..69834f08 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModTranquilityHandlers.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModTranquilityHandlers.java @@ -1,12 +1,10 @@ package WayofTime.bloodmagic.registry; import WayofTime.bloodmagic.api.incense.IncenseTranquilityRegistry; -import WayofTime.bloodmagic.incense.*; +import WayofTime.bloodmagic.incense.TranquilityHandlers; -public class ModTranquilityHandlers -{ - public static void init() - { +public class ModTranquilityHandlers { + public static void init() { IncenseTranquilityRegistry.registerTranquilityHandler(new TranquilityHandlers.Plant()); IncenseTranquilityRegistry.registerTranquilityHandler(new TranquilityHandlers.Crop()); IncenseTranquilityRegistry.registerTranquilityHandler(new TranquilityHandlers.Water()); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualAltarBuilder.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualAltarBuilder.java index c765a6ca..69ccc38a 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualAltarBuilder.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualAltarBuilder.java @@ -28,115 +28,95 @@ import net.minecraftforge.items.IItemHandler; import java.util.ArrayList; import java.util.Iterator; -public class RitualAltarBuilder extends Ritual -{ +public class RitualAltarBuilder extends Ritual { private Iterator altarComponentsIterator = new ArrayList(EnumAltarTier.SIX.getAltarComponents()).iterator(); private boolean cycleDone = false; private AltarComponent currentComponent; private BlockPos currentPos; - public RitualAltarBuilder() - { + public RitualAltarBuilder() { super("ritualAltarBuilder", 0, 450, "ritual." + BloodMagic.MODID + ".altarBuilderRitual"); } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); TileEntity tileEntity = world.getTileEntity(masterRitualStone.getBlockPos().up()); BlockPos altarPos = masterRitualStone.getBlockPos().up(2); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } - if (cycleDone) - { + if (cycleDone) { altarComponentsIterator = new ArrayList(EnumAltarTier.SIX.getAltarComponents()).iterator(); } - if (world.getBlockState(altarPos).getBlock().isReplaceable(world, altarPos) && hasItem(tileEntity, Item.getItemFromBlock(RegistrarBloodMagicBlocks.ALTAR), 0, true)) - { + if (world.getBlockState(altarPos).getBlock().isReplaceable(world, altarPos) && hasItem(tileEntity, Item.getItemFromBlock(RegistrarBloodMagicBlocks.ALTAR), 0, true)) { world.setBlockState(altarPos, RegistrarBloodMagicBlocks.ALTAR.getDefaultState()); lightning(world, altarPos); masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); } - if (altarComponentsIterator.hasNext()) - { + if (altarComponentsIterator.hasNext()) { currentComponent = altarComponentsIterator.next(); currentPos = altarPos.add(currentComponent.getOffset()); - if (world.getBlockState(currentPos).getBlock().isReplaceable(world, currentPos)) - { - switch (currentComponent.getComponent()) - { - case NOTAIR: - { - BlockStack blockStack = getMundaneBlock(tileEntity); - if (blockStack != null) - { - world.setBlockState(currentPos, blockStack.getState(), 3); - lightning(world, currentPos); - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + if (world.getBlockState(currentPos).getBlock().isReplaceable(world, currentPos)) { + switch (currentComponent.getComponent()) { + case NOTAIR: { + BlockStack blockStack = getMundaneBlock(tileEntity); + if (blockStack != null) { + world.setBlockState(currentPos, blockStack.getState(), 3); + lightning(world, currentPos); + masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + } + break; } - break; - } - case BLOODRUNE: - { - BlockStack blockStack = getBloodRune(tileEntity); - if (blockStack != null) - { - world.setBlockState(currentPos, blockStack.getState(), 3); - lightning(world, currentPos); - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + case BLOODRUNE: { + BlockStack blockStack = getBloodRune(tileEntity); + if (blockStack != null) { + world.setBlockState(currentPos, blockStack.getState(), 3); + lightning(world, currentPos); + masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + } + break; } - break; - } - default: - { - BlockStack blockStack = new BlockStack(Utils.getBlockForComponent(currentComponent.getComponent()), 0); - if (hasItem(tileEntity, Item.getItemFromBlock(blockStack.getBlock()), blockStack.getMeta(), true)) - { - world.setBlockState(currentPos, blockStack.getState(), 3); - lightning(world, currentPos); - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + default: { + BlockStack blockStack = new BlockStack(Utils.getBlockForComponent(currentComponent.getComponent()), 0); + if (hasItem(tileEntity, Item.getItemFromBlock(blockStack.getBlock()), blockStack.getMeta(), true)) { + world.setBlockState(currentPos, blockStack.getState(), 3); + lightning(world, currentPos); + masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + } + break; } - break; - } } } - } else - { + } else { cycleDone = true; } } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 75; } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 12; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); - for (int i = -12; i <= -8; i++) - { + for (int i = -12; i <= -8; i++) { addRune(components, i, -6, 13, EnumRuneType.AIR); addRune(components, i, -6, -13, EnumRuneType.FIRE); @@ -150,8 +130,7 @@ public class RitualAltarBuilder extends Ritual addRune(components, -13, 5, i, EnumRuneType.WATER); } - for (int i = 8; i <= 12; i++) - { + for (int i = 8; i <= 12; i++) { addRune(components, i, -6, 13, EnumRuneType.AIR); addRune(components, i, -6, -13, EnumRuneType.FIRE); @@ -165,13 +144,11 @@ public class RitualAltarBuilder extends Ritual addRune(components, -13, 5, i, EnumRuneType.WATER); } - for (int i = -6; i <= -4; i++) - { + for (int i = -6; i <= -4; i++) { addCornerRunes(components, 13, i, EnumRuneType.DUSK); } - for (int i = 3; i <= 5; i++) - { + for (int i = 3; i <= 5; i++) { addCornerRunes(components, 13, i, EnumRuneType.DUSK); } @@ -179,13 +156,11 @@ public class RitualAltarBuilder extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualAltarBuilder(); } - public void lightning(World world, BlockPos blockPos) - { + public void lightning(World world, BlockPos blockPos) { world.addWeatherEffect(new EntityLightningBolt(world, blockPos.getX(), blockPos.getY(), blockPos.getZ(), true)); } @@ -194,35 +169,25 @@ public class RitualAltarBuilder extends Ritual * These methods are utilities for this ritual. They support both the old * forge inventory system, and the new one. */ - public boolean hasItem(TileEntity tileEntity, Item item, int damage, boolean consumeItem) - { - if (tileEntity != null) - { - if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) - { + public boolean hasItem(TileEntity tileEntity, Item item, int damage, boolean consumeItem) { + if (tileEntity != null) { + if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) { IItemHandler itemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN); - if (itemHandler.getSlots() <= 0) - { + if (itemHandler.getSlots() <= 0) { return false; } - for (int i = 0; i < itemHandler.getSlots(); i++) - { - if (!itemHandler.getStackInSlot(i).isEmpty() && itemHandler.getStackInSlot(i).getItem() == item && itemHandler.getStackInSlot(i).getItemDamage() == damage && !itemHandler.extractItem(i, 1, !consumeItem).isEmpty()) - { + for (int i = 0; i < itemHandler.getSlots(); i++) { + if (!itemHandler.getStackInSlot(i).isEmpty() && itemHandler.getStackInSlot(i).getItem() == item && itemHandler.getStackInSlot(i).getItemDamage() == damage && !itemHandler.extractItem(i, 1, !consumeItem).isEmpty()) { return true; } } - } else if (tileEntity instanceof IInventory) - { + } else if (tileEntity instanceof IInventory) { IInventory inv = (IInventory) tileEntity; - for (int i = 0; i < inv.getSizeInventory(); i++) - { - if (!inv.getStackInSlot(0).isEmpty() && inv.getStackInSlot(i).getItem() == item && inv.getStackInSlot(i).getItemDamage() == damage) - { - if (consumeItem) - { + for (int i = 0; i < inv.getSizeInventory(); i++) { + if (!inv.getStackInSlot(0).isEmpty() && inv.getStackInSlot(i).getItem() == item && inv.getStackInSlot(i).getItemDamage() == damage) { + if (consumeItem) { inv.decrStackSize(i, 1); } return true; @@ -233,35 +198,26 @@ public class RitualAltarBuilder extends Ritual return false; } - public BlockStack getBloodRune(TileEntity tileEntity) - { - if (tileEntity != null) - { - if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) - { + public BlockStack getBloodRune(TileEntity tileEntity) { + if (tileEntity != null) { + if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) { IItemHandler itemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN); - if (itemHandler.getSlots() <= 0) - { + if (itemHandler.getSlots() <= 0) { return null; } - for (int i = 0; i < itemHandler.getSlots(); i++) - { - 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) - { + for (int i = 0; i < itemHandler.getSlots(); i++) { + 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), itemHandler.getStackInSlot(i).getItemDamage()); itemHandler.extractItem(i, 1, false); return blockStack; } } - } else if (tileEntity instanceof IInventory) - { + } else if (tileEntity instanceof IInventory) { IInventory inv = (IInventory) tileEntity; - for (int i = 0; i < inv.getSizeInventory(); i++) - { - if (!inv.getStackInSlot(i).isEmpty() && inv.getStackInSlot(i).getItem() instanceof ItemBlock && Block.getBlockFromItem(inv.getStackInSlot(i).getItem()) instanceof BlockBloodRune) - { + for (int i = 0; i < inv.getSizeInventory(); i++) { + 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); return blockStack; @@ -272,42 +228,31 @@ public class RitualAltarBuilder extends Ritual return null; } - public BlockStack getMundaneBlock(TileEntity tileEntity) - { - if (tileEntity != null) - { - if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) - { + public BlockStack getMundaneBlock(TileEntity tileEntity) { + if (tileEntity != null) { + if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) { IItemHandler itemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN); - if (itemHandler.getSlots() <= 0) - { + if (itemHandler.getSlots() <= 0) { return null; } - for (int i = 0; i < itemHandler.getSlots(); i++) - { - if (!itemHandler.getStackInSlot(i).isEmpty() && itemHandler.getStackInSlot(i).getItem() instanceof ItemBlock && !(Block.getBlockFromItem(itemHandler.getStackInSlot(i).getItem()) instanceof BlockBloodRune) && !itemHandler.extractItem(i, 1, true).isEmpty()) - { + for (int i = 0; i < itemHandler.getSlots(); i++) { + if (!itemHandler.getStackInSlot(i).isEmpty() && itemHandler.getStackInSlot(i).getItem() instanceof ItemBlock && !(Block.getBlockFromItem(itemHandler.getStackInSlot(i).getItem()) instanceof BlockBloodRune) && !itemHandler.extractItem(i, 1, true).isEmpty()) { Block block = Block.getBlockFromItem(itemHandler.getStackInSlot(i).getItem()); - if (block != Blocks.AIR && block != Blocks.GLOWSTONE && block != RegistrarBloodMagicBlocks.DECORATIVE_BRICK) - { + if (block != Blocks.AIR && block != Blocks.GLOWSTONE && block != RegistrarBloodMagicBlocks.DECORATIVE_BRICK) { BlockStack blockStack = new BlockStack(block, itemHandler.getStackInSlot(i).getItemDamage()); itemHandler.extractItem(i, 1, false); return blockStack; } } } - } else if (tileEntity instanceof IInventory) - { + } else if (tileEntity instanceof IInventory) { IInventory inv = (IInventory) tileEntity; - for (int i = 0; i < inv.getSizeInventory(); i++) - { - if (!inv.getStackInSlot(i).isEmpty() && inv.getStackInSlot(i).getItem() instanceof ItemBlock && !(Block.getBlockFromItem(inv.getStackInSlot(i).getItem()) instanceof BlockBloodRune)) - { + for (int i = 0; i < inv.getSizeInventory(); i++) { + 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 != Blocks.GLOWSTONE && block != RegistrarBloodMagicBlocks.DECORATIVE_BRICK) - { + if (block != Blocks.GLOWSTONE && block != RegistrarBloodMagicBlocks.DECORATIVE_BRICK) { BlockStack blockStack = new BlockStack(block, inv.getStackInSlot(i).getItemDamage()); inv.decrStackSize(i, 1); return blockStack; diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualAnimalGrowth.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualAnimalGrowth.java index 2cecd2b5..d5671333 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualAnimalGrowth.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualAnimalGrowth.java @@ -1,10 +1,11 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.ritual.*; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import WayofTime.bloodmagic.core.RegistrarBloodMagic; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -16,17 +17,11 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; import net.minecraftforge.items.IItemHandler; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -import WayofTime.bloodmagic.util.Utils; -public class RitualAnimalGrowth extends Ritual -{ +import java.util.ArrayList; +import java.util.List; + +public class RitualAnimalGrowth extends Ritual { public static final double rawWillDrain = 0.05; public static final double vengefulWillDrain = 0.02; public static final double steadfastWillDrain = 0.1; @@ -34,12 +29,10 @@ public class RitualAnimalGrowth extends Ritual public static final String GROWTH_RANGE = "growing"; public static final String CHEST_RANGE = "chest"; - - public int refreshTime = 20; public static int defaultRefreshTime = 20; + public int refreshTime = 20; - public RitualAnimalGrowth() - { + public RitualAnimalGrowth() { super("ritualAnimalGrowth", 0, 10000, "ritual." + BloodMagic.MODID + ".animalGrowthRitual"); addBlockRange(GROWTH_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-2, 1, -2), 5, 2, 5)); addBlockRange(CHEST_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1)); @@ -49,13 +42,11 @@ public class RitualAnimalGrowth extends Ritual } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -67,8 +58,7 @@ public class RitualAnimalGrowth extends Ritual AreaDescriptor chestRange = getBlockRange(CHEST_RANGE); TileEntity chest = world.getTileEntity(chestRange.getContainedPositions(pos).get(0)); IItemHandler itemHandler = null; - if (chest != null) - { + if (chest != null) { itemHandler = Utils.getInventory(chest, null); } @@ -98,58 +88,42 @@ public class RitualAnimalGrowth extends Ritual boolean performedEffect = false; - for (EntityAnimal animal : animalList) - { - if (animal.getGrowingAge() < 0) - { + for (EntityAnimal animal : animalList) { + if (animal.getGrowingAge() < 0) { animal.addGrowth(5); totalGrowths++; performedEffect = true; - } else if (animal.getGrowingAge() > 0) - { - if (decreaseBreedTimer) - { - if (vengefulWill >= vengefulWillDrain) - { + } else if (animal.getGrowingAge() > 0) { + if (decreaseBreedTimer) { + if (vengefulWill >= vengefulWillDrain) { animal.setGrowingAge(Math.max(0, animal.getGrowingAge() - getBreedingDecreaseForWill(vengefulWill))); vengefulDrain += vengefulWillDrain; vengefulWill -= vengefulWillDrain; performedEffect = true; - } else - { + } else { decreaseBreedTimer = false; } } - } else - { - if (kamikaze) - { - if (destructiveWill >= destructiveWillDrain) - { - if (!animal.isPotionActive(RegistrarBloodMagic.SACRIFICIAL_LAMB)) - { + } else { + if (kamikaze) { + if (destructiveWill >= destructiveWillDrain) { + if (!animal.isPotionActive(RegistrarBloodMagic.SACRIFICIAL_LAMB)) { animal.addPotionEffect(new PotionEffect(RegistrarBloodMagic.SACRIFICIAL_LAMB, 1200)); destructiveDrain += destructiveWillDrain; destructiveWill -= destructiveWillDrain; performedEffect = true; } - } else - { + } else { kamikaze = false; } } - if (breedAnimals) - { - if (steadfastWill >= steadfastWillDrain) - { - if (!animal.isInLove()) - { - for (int slot = 0; slot < itemHandler.getSlots(); slot++) - { + if (breedAnimals) { + if (steadfastWill >= steadfastWillDrain) { + if (!animal.isInLove()) { + for (int slot = 0; slot < itemHandler.getSlots(); slot++) { ItemStack foodStack = itemHandler.getStackInSlot(slot); - if (foodStack != null && animal.isBreedingItem(foodStack) && itemHandler.extractItem(slot, 1, true) != null) - { + if (foodStack != null && animal.isBreedingItem(foodStack) && itemHandler.extractItem(slot, 1, true) != null) { animal.setInLove(null); itemHandler.extractItem(slot, 1, false); steadfastDrain += steadfastWillDrain; @@ -159,36 +133,30 @@ public class RitualAnimalGrowth extends Ritual } } } - } else - { + } else { breedAnimals = false; } } } - if (totalGrowths >= maxGrowths) - { + if (totalGrowths >= maxGrowths) { break; } } - if (performedEffect && consumeRawWill) - { + if (performedEffect && consumeRawWill) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawWillDrain, true); } - if (vengefulDrain > 0) - { + if (vengefulDrain > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.VENGEFUL, vengefulDrain, true); } - if (steadfastDrain > 0) - { + if (steadfastDrain > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.STEADFAST, steadfastDrain, true); } - if (destructiveDrain > 0) - { + if (destructiveDrain > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DESTRUCTIVE, destructiveDrain, true); } @@ -196,14 +164,12 @@ public class RitualAnimalGrowth extends Ritual } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 2; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addParallelRunes(components, 2, 0, EnumRuneType.DUSK); @@ -221,15 +187,13 @@ public class RitualAnimalGrowth extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualAnimalGrowth(); } @Override - public ITextComponent[] provideInformationOfRitualToPlayer(EntityPlayer player) - { - return new ITextComponent[] { + 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"), @@ -239,15 +203,12 @@ public class RitualAnimalGrowth extends Ritual }; } - public int getBreedingDecreaseForWill(double vengefulWill) - { + public int getBreedingDecreaseForWill(double vengefulWill) { return (int) (10 + vengefulWill / 5); } - public int getRefreshTimeForRawWill(double rawWill) - { - if (rawWill >= rawWillDrain) - { + public int getRefreshTimeForRawWill(double rawWill) { + if (rawWill >= rawWillDrain) { return (int) Math.max(defaultRefreshTime - rawWill / 10, 1); } @@ -255,8 +216,7 @@ public class RitualAnimalGrowth extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return refreshTime; } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualArmourEvolve.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualArmourEvolve.java index 0872e9bc..8db309d0 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualArmourEvolve.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualArmourEvolve.java @@ -14,23 +14,19 @@ import net.minecraft.world.World; import java.util.ArrayList; import java.util.List; -public class RitualArmourEvolve extends Ritual -{ +public class RitualArmourEvolve extends Ritual { public static final String CHECK_RANGE = "fillRange"; - public RitualArmourEvolve() - { + public RitualArmourEvolve() { super("ritualArmourEvolve", 0, 50000, "ritual." + BloodMagic.MODID + ".armourEvolveRitual"); addBlockRange(CHECK_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1, 2, 1)); } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); - if (world.isRemote) - { + if (world.isRemote) { return; } @@ -40,16 +36,12 @@ public class RitualArmourEvolve extends Ritual List playerList = world.getEntitiesWithinAABB(EntityPlayer.class, checkRange.getAABB(pos)); - for (EntityPlayer player : playerList) - { - if (LivingArmour.hasFullSet(player)) - { + for (EntityPlayer player : playerList) { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2]; LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { - if (armour.maxUpgradePoints < 300) - { + if (armour != null) { + if (armour.maxUpgradePoints < 300) { armour.maxUpgradePoints = 300; ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true); @@ -63,20 +55,17 @@ public class RitualArmourEvolve extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 1; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 0; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addCornerRunes(components, 1, 0, EnumRuneType.DUSK); @@ -87,8 +76,7 @@ public class RitualArmourEvolve extends Ritual this.addCornerRunes(components, 1, 3, EnumRuneType.DUSK); this.addParallelRunes(components, 1, 4, EnumRuneType.EARTH); - for (int i = 0; i < 4; i++) - { + for (int i = 0; i < 4; i++) { this.addCornerRunes(components, 3, i, EnumRuneType.EARTH); } @@ -96,8 +84,7 @@ public class RitualArmourEvolve extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualArmourEvolve(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualCobblestone.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualCobblestone.java index 0977427b..2a8be8aa 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualCobblestone.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualCobblestone.java @@ -12,27 +12,23 @@ import net.minecraft.world.World; import java.util.ArrayList; -public class RitualCobblestone extends Ritual -{ +public class RitualCobblestone extends Ritual { public static final String COBBLESTONE_RANGE = "cobblestoneRange"; - public RitualCobblestone() - { + public RitualCobblestone() { super("ritualCobblestone", 0, 500, "ritual." + BloodMagic.MODID + ".cobblestoneRitual"); addBlockRange(COBBLESTONE_RANGE, new AreaDescriptor.Cross(new BlockPos(0, 1, 0), 1)); } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); TileEntity tileEntity = world.getTileEntity(masterRitualStone.getBlockPos().up()); Block block = Blocks.COBBLESTONE; - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -42,44 +38,38 @@ public class RitualCobblestone extends Ritual AreaDescriptor cobblestoneRange = getBlockRange(COBBLESTONE_RANGE); - if (tileEntity != null && tileEntity instanceof TileAlchemyArray) - { + if (tileEntity != null && tileEntity instanceof TileAlchemyArray) { TileAlchemyArray alchemyArray = (TileAlchemyArray) tileEntity; - if (!alchemyArray.getStackInSlot(0).isEmpty() && alchemyArray.getStackInSlot(0).getItem() instanceof ItemComponent) - { - switch (alchemyArray.getStackInSlot(0).getItemDamage()) - { - case 0: - block = Blocks.OBSIDIAN; - alchemyArray.decrStackSize(0, 1); - world.setBlockToAir(alchemyArray.getPos()); - break; - case 1: - block = Blocks.NETHERRACK; - alchemyArray.decrStackSize(0, 1); - world.setBlockToAir(alchemyArray.getPos()); - break; + if (!alchemyArray.getStackInSlot(0).isEmpty() && alchemyArray.getStackInSlot(0).getItem() instanceof ItemComponent) { + switch (alchemyArray.getStackInSlot(0).getItemDamage()) { + case 0: + block = Blocks.OBSIDIAN; + alchemyArray.decrStackSize(0, 1); + world.setBlockToAir(alchemyArray.getPos()); + break; + case 1: + block = Blocks.NETHERRACK; + alchemyArray.decrStackSize(0, 1); + world.setBlockToAir(alchemyArray.getPos()); + break; /* * case 4: block = Blocks.end_stone; * alchemyArray.decrStackSize(0, 1); * world.setBlockToAir(alchemyArray.getPos()); break; */ - default: - break; + default: + break; } } } - for (BlockPos blockPos : cobblestoneRange.getContainedPositions(masterRitualStone.getBlockPos())) - { - if (world.isAirBlock(blockPos)) - { + for (BlockPos blockPos : cobblestoneRange.getContainedPositions(masterRitualStone.getBlockPos())) { + if (world.isAirBlock(blockPos)) { world.setBlockState(blockPos, block.getDefaultState()); totalEffects++; } - if (totalEffects >= maxEffects) - { + if (totalEffects >= maxEffects) { break; } } @@ -88,14 +78,12 @@ public class RitualCobblestone extends Ritual } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 25; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addCornerRunes(components, 1, 1, EnumRuneType.FIRE); @@ -105,8 +93,7 @@ public class RitualCobblestone extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualCobblestone(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualContainment.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualContainment.java index 250439a2..b5a4953e 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualContainment.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualContainment.java @@ -10,33 +10,28 @@ import net.minecraft.world.World; import java.util.ArrayList; -public class RitualContainment extends Ritual -{ +public class RitualContainment extends Ritual { public static final String CONTAINMENT_RANGE = "containmentRange"; - public RitualContainment() - { + public RitualContainment() { super("ritualContainment", 0, 2000, "ritual." + BloodMagic.MODID + ".containmentRitual"); addBlockRange(CONTAINMENT_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-3, 0, -3), 7)); setMaximumVolumeAndDistanceOfRange(CONTAINMENT_RANGE, 0, 10, 10); } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } AreaDescriptor containmentRange = getBlockRange(CONTAINMENT_RANGE); - for (EntityLivingBase entity : world.getEntitiesWithinAABB(EntityLivingBase.class, containmentRange.getAABB(masterRitualStone.getBlockPos()))) - { + for (EntityLivingBase entity : world.getEntitiesWithinAABB(EntityLivingBase.class, containmentRange.getAABB(masterRitualStone.getBlockPos()))) { if (entity instanceof EntityPlayer && (((EntityPlayer) entity).capabilities.isCreativeMode || PlayerHelper.getUUIDFromPlayer((EntityPlayer) entity).toString().equals(masterRitualStone.getOwner()))) continue; @@ -52,20 +47,17 @@ public class RitualContainment extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 1; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 1; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addParallelRunes(components, 1, 0, EnumRuneType.EARTH); @@ -77,8 +69,7 @@ public class RitualContainment extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualContainment(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualCrushing.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualCrushing.java index 515bf11a..ea01a579 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualCrushing.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualCrushing.java @@ -1,12 +1,14 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.compress.CompressionRegistry; +import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe; +import WayofTime.bloodmagic.api.registry.AlchemyTableRecipeRegistry; +import WayofTime.bloodmagic.api.ritual.*; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; @@ -17,24 +19,15 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; - import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.api.compress.CompressionRegistry; -import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe; -import WayofTime.bloodmagic.api.registry.AlchemyTableRecipeRegistry; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; -import WayofTime.bloodmagic.util.Utils; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; -public class RitualCrushing extends Ritual -{ +public class RitualCrushing extends Ritual { public static final String CRUSHING_RANGE = "crushingRange"; public static final String CHEST_RANGE = "chest"; @@ -45,12 +38,10 @@ public class RitualCrushing extends Ritual public static Map cuttingFluidLPMap = new HashMap(); public static Map cuttingFluidWillMap = new HashMap(); - - public int refreshTime = 40; public static int defaultRefreshTime = 40; + public int refreshTime = 40; - public RitualCrushing() - { + public RitualCrushing() { super("ritualCrushing", 0, 5000, "ritual." + BloodMagic.MODID + ".crushingRitual"); addBlockRange(CRUSHING_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-1, -3, -1), 3)); addBlockRange(CHEST_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1)); @@ -59,20 +50,12 @@ public class RitualCrushing extends Ritual setMaximumVolumeAndDistanceOfRange(CHEST_RANGE, 1, 3, 3); } - public static void registerCuttingFluid(ItemStack stack, int lpDrain, double willDrain) - { - cuttingFluidLPMap.put(stack, lpDrain); - cuttingFluidWillMap.put(stack, willDrain); - } - @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -81,8 +64,7 @@ public class RitualCrushing extends Ritual AreaDescriptor chestRange = getBlockRange(CHEST_RANGE); TileEntity tile = world.getTileEntity(chestRange.getContainedPositions(pos).get(0)); - if (tile != null && Utils.getNumberOfFreeSlots(tile, EnumFacing.DOWN) < 1) - { + if (tile != null && Utils.getNumberOfFreeSlots(tile, EnumFacing.DOWN) < 1) { return; } @@ -108,39 +90,32 @@ public class RitualCrushing extends Ritual double rawDrain = 0; - for (BlockPos newPos : crushingRange.getContainedPositions(pos)) - { - if (world.isAirBlock(newPos)) - { + for (BlockPos newPos : crushingRange.getContainedPositions(pos)) { + if (world.isAirBlock(newPos)) { continue; } IBlockState state = world.getBlockState(newPos); Block block = state.getBlock(); - if (block.equals(RegistrarBloodMagicBlocks.RITUAL_CONTROLLER) || block.equals(RegistrarBloodMagicBlocks.RITUAL_STONE) || block.getBlockHardness(state, world, newPos) == -1.0F || Utils.isBlockLiquid(state)) - { + if (block.equals(RegistrarBloodMagicBlocks.RITUAL_CONTROLLER) || block.equals(RegistrarBloodMagicBlocks.RITUAL_STONE) || block.getBlockHardness(state, world, newPos) == -1.0F || Utils.isBlockLiquid(state)) { continue; } boolean isBlockClaimed = false; - if (useCuttingFluid) - { + if (useCuttingFluid) { ItemStack checkStack = block.getItem(world, newPos, state); - if (checkStack.isEmpty()) - { + if (checkStack.isEmpty()) { continue; } ItemStack copyStack = checkStack.copy(); - for (Entry entry : cuttingFluidLPMap.entrySet()) - { + for (Entry entry : cuttingFluidLPMap.entrySet()) { ItemStack cuttingStack = entry.getKey(); int lpDrain = entry.getValue(); double willDrain = cuttingFluidWillMap.containsKey(cuttingStack) ? cuttingFluidWillMap.get(cuttingStack) : 0; - if (corrosiveWill < willDrain || currentEssence < lpDrain + getRefreshCost()) - { + if (corrosiveWill < willDrain || currentEssence < lpDrain + getRefreshCost()) { continue; } @@ -150,26 +125,21 @@ public class RitualCrushing extends Ritual input.add(copyStack); AlchemyTableRecipe recipe = AlchemyTableRecipeRegistry.getMatchingRecipe(input, world, pos); - if (recipe == null) - { + if (recipe == null) { continue; } ItemStack result = recipe.getRecipeOutput(input); - if (result.isEmpty()) - { + if (result.isEmpty()) { continue; } - if (tile != null) - { + if (tile != null) { result = Utils.insertStackIntoTile(result, tile, EnumFacing.DOWN); - if (!result.isEmpty()) - { + if (!result.isEmpty()) { Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, result); } - } else - { + } else { Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, result); } @@ -183,22 +153,18 @@ public class RitualCrushing extends Ritual } } - if (!isBlockClaimed && isSilkTouch && block.canSilkHarvest(world, newPos, state, null)) - { + if (!isBlockClaimed && isSilkTouch && block.canSilkHarvest(world, newPos, state, null)) { ItemStack checkStack = block.getItem(world, newPos, state); - if (checkStack.isEmpty()) - { + if (checkStack.isEmpty()) { continue; } ItemStack copyStack = checkStack.copy(); - if (steadfastWill >= steadfastWillDrain) - { + if (steadfastWill >= steadfastWillDrain) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.STEADFAST, steadfastWillDrain, true); steadfastWill -= steadfastWillDrain; - } else - { + } else { continue; } @@ -207,39 +173,31 @@ public class RitualCrushing extends Ritual else Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack); - if (!copyStack.isEmpty()) - { + if (!copyStack.isEmpty()) { Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack); } - } else if (!isBlockClaimed) - { - if (fortune > 0 && destructiveWill < destructiveWillDrain) - { + } else if (!isBlockClaimed) { + if (fortune > 0 && destructiveWill < destructiveWillDrain) { fortune = 0; } List stackList = block.getDrops(world, newPos, state, fortune); - for (ItemStack item : stackList) - { + for (ItemStack item : stackList) { ItemStack copyStack = item.copy(); - if (tile != null) - { + if (tile != null) { copyStack = Utils.insertStackIntoTile(copyStack, tile, EnumFacing.DOWN); - } else - { + } else { Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack); continue; } - if (!copyStack.isEmpty()) - { + if (!copyStack.isEmpty()) { Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack); } } - if (fortune > 0) - { + if (fortune > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DESTRUCTIVE, destructiveWillDrain, true); destructiveWill -= destructiveWillDrain; } @@ -249,8 +207,7 @@ public class RitualCrushing extends Ritual masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); hasOperated = true; - if (consumeRawWill) - { + if (consumeRawWill) { rawDrain += rawWillDrain; rawWill -= rawWillDrain; } @@ -258,14 +215,11 @@ public class RitualCrushing extends Ritual break; } - if (hasOperated && tile != null && vengefulWill >= vengefulWillDrain) - { + if (hasOperated && tile != null && vengefulWill >= vengefulWillDrain) { Pair pair = CompressionRegistry.compressInventory(tile, world); - if (pair.getRight()) - { + if (pair.getRight()) { ItemStack returned = pair.getLeft(); - if (returned != null) - { + if (returned != null) { Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, returned); } @@ -273,16 +227,13 @@ public class RitualCrushing extends Ritual } } - if (rawDrain > 0) - { + if (rawDrain > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawDrain, true); } } - public int getRefreshTimeForRawWill(double rawWill) - { - if (rawWill >= rawWillDrain) - { + public int getRefreshTimeForRawWill(double rawWill) { + if (rawWill >= rawWillDrain) { return Math.max(1, (int) (40 - rawWill / 5)); } @@ -290,20 +241,17 @@ public class RitualCrushing extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return refreshTime; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 7; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addParallelRunes(components, 1, 0, EnumRuneType.EARTH); @@ -315,9 +263,8 @@ public class RitualCrushing extends Ritual } @Override - public ITextComponent[] provideInformationOfRitualToPlayer(EntityPlayer player) - { - return new ITextComponent[] { + 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"), @@ -328,8 +275,12 @@ public class RitualCrushing extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualCrushing(); } + + public static void registerCuttingFluid(ItemStack stack, int lpDrain, double willDrain) { + cuttingFluidLPMap.put(stack, lpDrain); + cuttingFluidWillMap.put(stack, willDrain); + } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualCrystalHarvest.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualCrystalHarvest.java index 797f5eed..00e1b34f 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualCrystalHarvest.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualCrystalHarvest.java @@ -1,25 +1,19 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.ritual.*; +import WayofTime.bloodmagic.tile.TileDemonCrystal; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.tile.TileDemonCrystal; -public class RitualCrystalHarvest extends Ritual -{ +import java.util.ArrayList; + +public class RitualCrystalHarvest extends Ritual { public static final String CRYSTAL_RANGE = "crystal"; - public RitualCrystalHarvest() - { + public RitualCrystalHarvest() { super("ritualCrystalHarvest", 0, 40000, "ritual." + BloodMagic.MODID + ".crystalHarvestRitual"); addBlockRange(CRYSTAL_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-3, 2, -3), 7, 5, 7)); @@ -27,14 +21,12 @@ public class RitualCrystalHarvest extends Ritual } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); BlockPos pos = masterRitualStone.getBlockPos(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -45,20 +37,16 @@ public class RitualCrystalHarvest extends Ritual AreaDescriptor crystalRange = getBlockRange(CRYSTAL_RANGE); crystalRange.resetIterator(); - while (crystalRange.hasNext()) - { + while (crystalRange.hasNext()) { BlockPos nextPos = crystalRange.next().add(pos); TileEntity tile = world.getTileEntity(nextPos); - if (tile instanceof TileDemonCrystal) - { + if (tile instanceof TileDemonCrystal) { TileDemonCrystal demonCrystal = (TileDemonCrystal) tile; - if (demonCrystal.dropSingleCrystal()) - { + if (demonCrystal.dropSingleCrystal()) { IBlockState state = world.getBlockState(nextPos); world.notifyBlockUpdate(nextPos, state, state, 3); totalEffects++; - if (totalEffects >= maxEffects) - { + if (totalEffects >= maxEffects) { break; } } @@ -69,20 +57,17 @@ public class RitualCrystalHarvest extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 25; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 50; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addCornerRunes(components, 1, 0, EnumRuneType.AIR); @@ -99,8 +84,7 @@ public class RitualCrystalHarvest extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualCrystalHarvest(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualExpulsion.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualExpulsion.java index e0e30068..9cc17048 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualExpulsion.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualExpulsion.java @@ -1,10 +1,11 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.iface.IBindable; +import WayofTime.bloodmagic.api.ritual.*; +import WayofTime.bloodmagic.api.util.helper.PlayerHelper; +import WayofTime.bloodmagic.util.Utils; +import com.google.common.base.Strings; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -18,36 +19,26 @@ import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.EnderTeleportEvent; import net.minecraftforge.items.IItemHandler; -import WayofTime.bloodmagic.api.iface.IBindable; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.api.util.helper.PlayerHelper; -import WayofTime.bloodmagic.util.Utils; -import com.google.common.base.Strings; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; -public class RitualExpulsion extends Ritual -{ +public class RitualExpulsion extends Ritual { public static final String EXPULSION_RANGE = "expulsionRange"; - public RitualExpulsion() - { + public RitualExpulsion() { super("ritualExpulsion", 0, 10000, "ritual." + BloodMagic.MODID + ".expulsionRitual"); addBlockRange(EXPULSION_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-12, 0, -12), 25)); setMaximumVolumeAndDistanceOfRange(EXPULSION_RANGE, 0, 12, 12); } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -61,16 +52,12 @@ public class RitualExpulsion extends Ritual BlockPos masterPos = masterRitualStone.getBlockPos(); TileEntity tile = world.getTileEntity(masterPos.up()); - if (tile != null) - { + if (tile != null) { IItemHandler handler = Utils.getInventory(tile, null); - if (handler != null) - { - for (int i = 0; i < handler.getSlots(); i++) - { + if (handler != null) { + for (int i = 0; i < handler.getSlots(); i++) { ItemStack itemStack = handler.getStackInSlot(i); - if (itemStack != null && itemStack.getItem() instanceof IBindable) - { + if (itemStack != null && itemStack.getItem() instanceof IBindable) { IBindable bindable = (IBindable) itemStack.getItem(); if (!Strings.isNullOrEmpty(bindable.getOwnerName(itemStack)) && !allowedNames.contains(bindable.getOwnerName(itemStack))) allowedNames.add(bindable.getOwnerUUID(itemStack)); @@ -81,8 +68,7 @@ public class RitualExpulsion extends Ritual final int teleportDistance = 100; - for (EntityPlayer player : world.getEntitiesWithinAABB(EntityPlayer.class, expulsionRange.getAABB(masterRitualStone.getBlockPos()))) - { + for (EntityPlayer player : world.getEntitiesWithinAABB(EntityPlayer.class, expulsionRange.getAABB(masterRitualStone.getBlockPos()))) { if (player.capabilities.isCreativeMode || PlayerHelper.getUUIDFromPlayer(player).toString().equals(masterRitualStone.getOwner()) || allowedNames.contains(PlayerHelper.getUUIDFromPlayer(player).toString())) continue; @@ -93,10 +79,8 @@ public class RitualExpulsion extends Ritual allowedNames.clear(); } - public boolean teleportRandomly(EntityLivingBase entityLiving, double distance) - { - if (entityLiving instanceof EntityPlayer) - { + public boolean teleportRandomly(EntityLivingBase entityLiving, double distance) { + if (entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entityLiving; if (player.capabilities.isCreativeMode) return false; @@ -111,8 +95,7 @@ public class RitualExpulsion extends Ritual double randZ = z + (rand.nextDouble() - 0.5D) * distance; int i = 0; - while (!teleportTo(entityLiving, randX, randY, randZ, x, y, z) && i < 100) - { + while (!teleportTo(entityLiving, randX, randY, randZ, x, y, z) && i < 100) { randX = x + (rand.nextDouble() - 0.5D) * distance; randY = y + (rand.nextInt((int) distance) - (distance) / 2); randZ = z + (rand.nextDouble() - 0.5D) * distance; @@ -122,12 +105,10 @@ public class RitualExpulsion extends Ritual return i >= 100; } - public boolean teleportTo(EntityLivingBase entityLiving, double par1, double par3, double par5, double lastX, double lastY, double lastZ) - { + public boolean teleportTo(EntityLivingBase entityLiving, double par1, double par3, double par5, double lastX, double lastY, double lastZ) { EnderTeleportEvent event = new EnderTeleportEvent(entityLiving, par1, par3, par5, 0); - if (MinecraftForge.EVENT_BUS.post(event)) - { + if (MinecraftForge.EVENT_BUS.post(event)) { return false; } @@ -138,43 +119,34 @@ public class RitualExpulsion extends Ritual int k = MathHelper.floor(entityLiving.posZ); int l; - if (!entityLiving.getEntityWorld().isAirBlock(new BlockPos(i, j, k))) - { + if (!entityLiving.getEntityWorld().isAirBlock(new BlockPos(i, j, k))) { boolean flag1 = false; - while (!flag1 && j > 0) - { + while (!flag1 && j > 0) { IBlockState state = entityLiving.getEntityWorld().getBlockState(new BlockPos(i, j - 1, k)); - if (state.getMaterial().blocksMovement()) - { + if (state.getMaterial().blocksMovement()) { flag1 = true; - } else - { + } else { --entityLiving.posY; --j; } } - if (flag1) - { + if (flag1) { moveEntityViaTeleport(entityLiving, entityLiving.posX, entityLiving.posY, entityLiving.posZ); - if (!entityLiving.isCollided && !entityLiving.getEntityWorld().containsAnyLiquid(entityLiving.getEntityBoundingBox())) - { + if (!entityLiving.isCollided && !entityLiving.getEntityWorld().containsAnyLiquid(entityLiving.getEntityBoundingBox())) { flag = true; } } } - if (!flag) - { + if (!flag) { moveEntityViaTeleport(entityLiving, lastX, lastY, lastZ); return false; - } else - { - for (l = 0; l < 128; ++l) - { + } else { + for (l = 0; l < 128; ++l) { double lengthVal = (double) l / ((double) 128 - 1.0D); float randF1 = (entityLiving.getEntityWorld().rand.nextFloat() - 0.5F) * 0.2F; float randF2 = (entityLiving.getEntityWorld().rand.nextFloat() - 0.5F) * 0.2F; @@ -189,49 +161,39 @@ public class RitualExpulsion extends Ritual } } - public void moveEntityViaTeleport(EntityLivingBase entityLiving, double x, double y, double z) - { - if (entityLiving != null && entityLiving instanceof EntityPlayer) - { - if (entityLiving instanceof EntityPlayerMP) - { + public void moveEntityViaTeleport(EntityLivingBase entityLiving, double x, double y, double z) { + if (entityLiving != null && entityLiving instanceof EntityPlayer) { + if (entityLiving instanceof EntityPlayerMP) { EntityPlayerMP entityplayermp = (EntityPlayerMP) entityLiving; - if (entityplayermp.getEntityWorld() == entityLiving.getEntityWorld()) - { + if (entityplayermp.getEntityWorld() == entityLiving.getEntityWorld()) { EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, x, y, z, 5.0F); - if (!MinecraftForge.EVENT_BUS.post(event)) - { - if (entityLiving.isRiding()) - { + if (!MinecraftForge.EVENT_BUS.post(event)) { + if (entityLiving.isRiding()) { entityplayermp.mountEntityAndWakeUp(); } entityLiving.setPositionAndUpdate(event.getTargetX(), event.getTargetY(), event.getTargetZ()); } } } - } else if (entityLiving != null) - { + } else if (entityLiving != null) { entityLiving.setPosition(x, y, z); } } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 1; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 2; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addCornerRunes(components, 2, 0, EnumRuneType.EARTH); @@ -275,8 +237,7 @@ public class RitualExpulsion extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualExpulsion(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualFeatheredKnife.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualFeatheredKnife.java index 82b330e3..60dce160 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualFeatheredKnife.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualFeatheredKnife.java @@ -1,10 +1,17 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.ConfigHandler; +import WayofTime.bloodmagic.api.altar.IBloodAltar; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.api.ritual.*; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.util.helper.PlayerSacrificeHelper; import WayofTime.bloodmagic.core.RegistrarBloodMagic; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; +import WayofTime.bloodmagic.item.armour.ItemLivingArmour; +import WayofTime.bloodmagic.livingArmour.LivingArmour; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; @@ -15,23 +22,11 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; -import WayofTime.bloodmagic.ConfigHandler; -import WayofTime.bloodmagic.api.altar.IBloodAltar; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.util.helper.PlayerSacrificeHelper; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -import WayofTime.bloodmagic.item.armour.ItemLivingArmour; -import WayofTime.bloodmagic.livingArmour.LivingArmour; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice; -public class RitualFeatheredKnife extends Ritual -{ +import java.util.ArrayList; +import java.util.List; + +public class RitualFeatheredKnife extends Ritual { public static final String ALTAR_RANGE = "altar"; public static final String DAMAGE_RANGE = "damage"; @@ -40,14 +35,11 @@ public class RitualFeatheredKnife extends Ritual public static double corrosiveWillThreshold = 10; public static double steadfastWillThreshold = 10; public static double vengefulWillThreshold = 10; - - public int refreshTime = 20; public static int defaultRefreshTime = 20; - + public int refreshTime = 20; public BlockPos altarOffsetPos = new BlockPos(0, 0, 0); //TODO: Save! - public RitualFeatheredKnife() - { + public RitualFeatheredKnife() { super("ritualFeatheredKnife", 0, 25000, "ritual." + BloodMagic.MODID + ".featheredKnifeRitual"); addBlockRange(ALTAR_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-5, -10, -5), 11, 21, 11)); addBlockRange(DAMAGE_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-15, -20, -15), 31, 41, 31)); @@ -57,13 +49,11 @@ public class RitualFeatheredKnife extends Ritual } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -91,13 +81,10 @@ public class RitualFeatheredKnife extends Ritual AreaDescriptor altarRange = getBlockRange(ALTAR_RANGE); - if (!altarRange.isWithinArea(altarOffsetPos) || !(tile instanceof IBloodAltar)) - { - for (BlockPos newPos : altarRange.getContainedPositions(pos)) - { + if (!altarRange.isWithinArea(altarOffsetPos) || !(tile instanceof IBloodAltar)) { + for (BlockPos newPos : altarRange.getContainedPositions(pos)) { TileEntity nextTile = world.getTileEntity(newPos); - if (nextTile instanceof IBloodAltar) - { + if (nextTile instanceof IBloodAltar) { tile = nextTile; altarOffsetPos = newPos.subtract(pos); @@ -109,8 +96,7 @@ public class RitualFeatheredKnife extends Ritual boolean useIncense = corrosiveWill >= corrosiveWillThreshold; - if (tile instanceof IBloodAltar) - { + if (tile instanceof IBloodAltar) { IBloodAltar tileAltar = (IBloodAltar) tile; AreaDescriptor damageRange = getBlockRange(DAMAGE_RANGE); @@ -120,12 +106,10 @@ public class RitualFeatheredKnife extends Ritual List entities = world.getEntitiesWithinAABB(EntityPlayer.class, range); - for (EntityPlayer player : entities) - { + for (EntityPlayer player : entities) { float healthThreshold = steadfastWill >= steadfastWillThreshold ? 0.7f : 0.3f; - if (vengefulWill >= vengefulWillThreshold && !player.getUniqueID().toString().equals(masterRitualStone.getOwner())) - { + if (vengefulWill >= vengefulWillThreshold && !player.getUniqueID().toString().equals(masterRitualStone.getOwner())) { healthThreshold = 0.1f; } @@ -135,10 +119,8 @@ public class RitualFeatheredKnife extends Ritual float sacrificedHealth = 1; double lpModifier = 1; - if ((health / player.getMaxHealth() > healthThreshold) && (!useIncense || !player.isPotionActive(RegistrarBloodMagic.SOUL_FRAY))) - { - if (useIncense) - { + if ((health / player.getMaxHealth() > healthThreshold) && (!useIncense || !player.isPotionActive(RegistrarBloodMagic.SOUL_FRAY))) { + if (useIncense) { double incenseAmount = PlayerSacrificeHelper.getPlayerIncense(player); sacrificedHealth = health - maxHealth * healthThreshold; @@ -148,23 +130,19 @@ public class RitualFeatheredKnife extends Ritual player.addPotionEffect(new PotionEffect(RegistrarBloodMagic.SOUL_FRAY, PlayerSacrificeHelper.soulFrayDuration)); } - if (destructiveWill >= destructiveWillDrain * sacrificedHealth) - { + if (destructiveWill >= destructiveWillDrain * sacrificedHealth) { lpModifier *= getLPModifierForWill(destructiveWill); destructiveWill -= destructiveWillDrain * sacrificedHealth; destructiveDrain += destructiveWillDrain * sacrificedHealth; } - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { + if (armour != null) { LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.selfSacrifice", chestStack); - if (upgrade instanceof LivingArmourUpgradeSelfSacrifice) - { + if (upgrade instanceof LivingArmourUpgradeSelfSacrifice) { double modifier = ((LivingArmourUpgradeSelfSacrifice) upgrade).getSacrificeModifier(); lpModifier *= (1 + modifier); @@ -178,42 +156,36 @@ public class RitualFeatheredKnife extends Ritual totalEffects++; - if (totalEffects >= maxEffects) - { + if (totalEffects >= maxEffects) { break; } } } - if (destructiveDrain > 0) - { + if (destructiveDrain > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.STEADFAST, destructiveDrain, true); } } masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); - if (totalEffects > 0 && consumeRawWill) - { + if (totalEffects > 0 && consumeRawWill) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawWillDrain, true); } } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return refreshTime; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 20; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addParallelRunes(components, 1, 0, EnumRuneType.DUSK); @@ -228,26 +200,21 @@ public class RitualFeatheredKnife extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualFeatheredKnife(); } @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") }; + 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")}; } - public double getLPModifierForWill(double destructiveWill) - { + public double getLPModifierForWill(double destructiveWill) { return 1 + destructiveWill * 0.2 / 100; } - public int getRefreshTimeForRawWill(double rawWill) - { - if (rawWill >= rawWillDrain) - { + public int getRefreshTimeForRawWill(double rawWill) { + if (rawWill >= rawWillDrain) { return 10; } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualFelling.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualFelling.java index fd8a1e74..52c22bf5 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualFelling.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualFelling.java @@ -7,8 +7,8 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemHandlerHelper; @@ -17,8 +17,7 @@ import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Iterator; -public class RitualFelling extends Ritual -{ +public class RitualFelling extends Ritual { public static final String FELLING_RANGE = "fellingRange"; public static final String CHEST_RANGE = "chest"; @@ -28,8 +27,7 @@ public class RitualFelling extends Ritual private boolean cached = false; private BlockPos currentPos; - public RitualFelling() - { + public RitualFelling() { super("ritualFelling", 0, 20000, "ritual." + BloodMagic.MODID + ".fellingRitual"); addBlockRange(FELLING_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-10, -3, -10), new BlockPos(11, 27, 11))); addBlockRange(CHEST_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1)); @@ -41,8 +39,7 @@ public class RitualFelling extends Ritual } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); @@ -50,19 +47,15 @@ public class RitualFelling extends Ritual AreaDescriptor chestRange = getBlockRange(CHEST_RANGE); TileEntity tileInventory = world.getTileEntity(chestRange.getContainedPositions(masterPos).get(0)); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } - if (!cached || treePartsCache.isEmpty()) - { - for (BlockPos blockPos : getBlockRange(FELLING_RANGE).getContainedPositions(masterRitualStone.getBlockPos())) - { + if (!cached || treePartsCache.isEmpty()) { + for (BlockPos blockPos : getBlockRange(FELLING_RANGE).getContainedPositions(masterRitualStone.getBlockPos())) { if (!treePartsCache.contains(blockPos)) - if (!world.isAirBlock(blockPos) && (world.getBlockState(blockPos).getBlock().isWood(world, blockPos) || world.getBlockState(blockPos).getBlock().isLeaves(world.getBlockState(blockPos), world, blockPos))) - { + if (!world.isAirBlock(blockPos) && (world.getBlockState(blockPos).getBlock().isWood(world, blockPos) || world.getBlockState(blockPos).getBlock().isLeaves(world.getBlockState(blockPos), world, blockPos))) { treePartsCache.add(blockPos); } } @@ -71,8 +64,7 @@ public class RitualFelling extends Ritual blockPosIterator = treePartsCache.iterator(); } - if (blockPosIterator.hasNext() && tileInventory != null) - { + if (blockPosIterator.hasNext() && tileInventory != null) { masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); currentPos = blockPosIterator.next(); IItemHandler inventory = Utils.getInventory(tileInventory, EnumFacing.DOWN); @@ -83,20 +75,17 @@ public class RitualFelling extends Ritual } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 10; } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 1; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); addCornerRunes(components, 1, 0, EnumRuneType.EARTH); @@ -106,18 +95,15 @@ public class RitualFelling extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualFelling(); } - private void placeInInventory(IBlockState choppedState, World world, BlockPos choppedPos, @Nullable IItemHandler inventory) - { + private void placeInInventory(IBlockState choppedState, World world, BlockPos choppedPos, @Nullable IItemHandler inventory) { if (inventory == null) return; - for (ItemStack stack : choppedState.getBlock().getDrops(world, choppedPos, world.getBlockState(choppedPos), 0)) - { + for (ItemStack stack : choppedState.getBlock().getDrops(world, choppedPos, world.getBlockState(choppedPos), 0)) { ItemStack remainder = ItemHandlerHelper.insertItem(inventory, stack, false); if (!remainder.isEmpty()) world.spawnEntity(new EntityItem(world, choppedPos.getX() + 0.4, choppedPos.getY() + 2, choppedPos.getZ() + 0.4, remainder)); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualForsakenSoul.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualForsakenSoul.java index ae60ee22..6f704b07 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualForsakenSoul.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualForsakenSoul.java @@ -1,10 +1,9 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.ritual.*; import WayofTime.bloodmagic.api_impl.BloodMagicAPI; +import WayofTime.bloodmagic.tile.TileDemonCrystal; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.player.EntityPlayer; @@ -14,18 +13,13 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.ConfigHandler; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.tile.TileDemonCrystal; import net.minecraftforge.fml.common.registry.EntityEntry; import net.minecraftforge.fml.common.registry.EntityRegistry; -public class RitualForsakenSoul extends Ritual -{ +import java.util.ArrayList; +import java.util.List; + +public class RitualForsakenSoul extends Ritual { public static final String CRYSTAL_RANGE = "crystal"; public static final String DAMAGE_RANGE = "damage"; public static final int MAX_UNIQUENESS = 10; @@ -37,8 +31,7 @@ public class RitualForsakenSoul extends Ritual public List keyList = new ArrayList(); - public RitualForsakenSoul() - { + public RitualForsakenSoul() { super("ritualForsakenSoul", 0, 40000, "ritual." + BloodMagic.MODID + ".forsakenSoulRitual"); addBlockRange(CRYSTAL_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-3, 2, -3), 7, 5, 7)); addBlockRange(DAMAGE_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-10, -10, -10), 21)); @@ -48,48 +41,41 @@ public class RitualForsakenSoul extends Ritual } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); willBuffer = tag.getDouble("willBuffer"); crystalBuffer = tag.getDouble("crystalBuffer"); keyList.clear(); - for (int i = 0; i < MAX_UNIQUENESS; i++) - { + for (int i = 0; i < MAX_UNIQUENESS; i++) { String key = "uniq" + i; - if (tag.hasKey(key)) - { + if (tag.hasKey(key)) { keyList.add(tag.getInteger(key)); } } } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); tag.setDouble("willBuffer", willBuffer); tag.setDouble("crystalBuffer", crystalBuffer); - for (int i = 0; i < Math.min(MAX_UNIQUENESS, keyList.size()); i++) - { + for (int i = 0; i < Math.min(MAX_UNIQUENESS, keyList.size()); i++) { String key = "uniq" + i; tag.setInteger(key, keyList.get(i)); } } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); BlockPos pos = masterRitualStone.getBlockPos(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -102,12 +88,10 @@ public class RitualForsakenSoul extends Ritual AreaDescriptor crystalRange = getBlockRange(CRYSTAL_RANGE); crystalRange.resetIterator(); - while (crystalRange.hasNext()) - { + while (crystalRange.hasNext()) { BlockPos nextPos = crystalRange.next().add(pos); TileEntity tile = world.getTileEntity(nextPos); - if (tile instanceof TileDemonCrystal) - { + if (tile instanceof TileDemonCrystal) { crystalList.add((TileDemonCrystal) tile); } } @@ -117,23 +101,18 @@ public class RitualForsakenSoul extends Ritual List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, range); - for (EntityLivingBase entity : entities) - { + for (EntityLivingBase entity : entities) { EntityEntry entityEntry = EntityRegistry.getEntry(entity.getClass()); if (BloodMagicAPI.INSTANCE.getBlacklist().getSacrifice().contains(entityEntry.getRegistryName())) continue; - if (entity.isEntityAlive() && !(entity instanceof EntityPlayer)) - { - if (entity.attackEntityFrom(DamageSource.OUT_OF_WORLD, 1)) - { - if (!entity.isEntityAlive()) - { + if (entity.isEntityAlive() && !(entity instanceof EntityPlayer)) { + if (entity.attackEntityFrom(DamageSource.OUT_OF_WORLD, 1)) { + if (!entity.isEntityAlive()) { int uniqueness = calculateUniqueness(entity); double modifier = 1; - if (entity instanceof EntityAnimal && !entity.isCollided) - { + if (entity instanceof EntityAnimal && !entity.isCollided) { modifier = 4; } @@ -141,8 +120,7 @@ public class RitualForsakenSoul extends Ritual crystalBuffer += modifier * entity.getMaxHealth() / HEALTH_THRESHOLD; totalEffects++; - if (totalEffects >= maxEffects) - { + if (totalEffects >= maxEffects) { break; } } @@ -150,14 +128,12 @@ public class RitualForsakenSoul extends Ritual } } - if (crystalList.size() > 0 && crystalBuffer > 0) - { + if (crystalList.size() > 0 && crystalBuffer > 0) { double growth = Math.min(crystalBuffer, 1); double willSyphonAmount = growth * willBuffer / crystalBuffer; TileDemonCrystal chosenCrystal = crystalList.get(world.rand.nextInt(crystalList.size())); double percentageGrowth = chosenCrystal.growCrystalWithWillAmount(growth * willBuffer / crystalBuffer, growth); - if (percentageGrowth > 0) - { + if (percentageGrowth > 0) { crystalBuffer -= percentageGrowth; willBuffer -= percentageGrowth * willSyphonAmount; } @@ -167,24 +143,19 @@ public class RitualForsakenSoul extends Ritual } /** - * * @param mob * @return The amount of uniqueness to the last 10 mobs killed */ - public int calculateUniqueness(EntityLivingBase mob) - { + public int calculateUniqueness(EntityLivingBase mob) { int key = mob.getClass().hashCode(); keyList.add(key); - if (keyList.size() > MAX_UNIQUENESS) - { + if (keyList.size() > MAX_UNIQUENESS) { keyList.remove(0); } List uniquenessList = new ArrayList(); - for (int value : keyList) - { - if (!uniquenessList.contains(value)) - { + for (int value : keyList) { + if (!uniquenessList.contains(value)) { uniquenessList.add(value); } } @@ -192,26 +163,22 @@ public class RitualForsakenSoul extends Ritual return Math.min(uniquenessList.size(), MAX_UNIQUENESS); } - public double getWillForUniqueness(int uniqueness) - { + public double getWillForUniqueness(int uniqueness) { return Math.max(50 - 15 * Math.sqrt(uniqueness), 0); } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 25; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 2; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addCornerRunes(components, 1, 0, EnumRuneType.AIR); @@ -228,8 +195,7 @@ public class RitualForsakenSoul extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualForsakenSoul(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualFullStomach.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualFullStomach.java index 00d72cb5..37e6c56b 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualFullStomach.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualFullStomach.java @@ -8,20 +8,18 @@ import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.FoodStats; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import java.util.ArrayList; import java.util.List; -public class RitualFullStomach extends Ritual -{ +public class RitualFullStomach extends Ritual { public static final String FILL_RANGE = "fillRange"; public static final String CHEST_RANGE = "chest"; - public RitualFullStomach() - { + public RitualFullStomach() { super("ritualFullStomach", 0, 100000, "ritual." + BloodMagic.MODID + ".fullStomachRitual"); addBlockRange(FILL_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-25, -25, -25), 51)); addBlockRange(CHEST_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1)); @@ -31,8 +29,7 @@ public class RitualFullStomach extends Ritual } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); @@ -43,8 +40,7 @@ public class RitualFullStomach extends Ritual AreaDescriptor chestRange = getBlockRange(CHEST_RANGE); TileEntity tile = world.getTileEntity(chestRange.getContainedPositions(pos).get(0)); - if (!(tile instanceof IInventory)) - { + if (!(tile instanceof IInventory)) { return; } @@ -56,23 +52,19 @@ public class RitualFullStomach extends Ritual List playerList = world.getEntitiesWithinAABB(EntityPlayer.class, fillingRange.getAABB(pos)); - for (EntityPlayer player : playerList) - { + for (EntityPlayer player : playerList) { FoodStats foodStats = player.getFoodStats(); float satLevel = foodStats.getSaturationLevel(); - for (int i = lastSlot; i < inventory.getSizeInventory(); i++) - { + for (int i = lastSlot; i < inventory.getSizeInventory(); i++) { ItemStack stack = inventory.getStackInSlot(i); - if (!stack.isEmpty() && stack.getItem() instanceof ItemFood) - { + if (!stack.isEmpty() && stack.getItem() instanceof ItemFood) { ItemFood foodItem = (ItemFood) stack.getItem(); int healAmount = foodItem.getHealAmount(stack); float saturationAmount = foodItem.getSaturationModifier(stack) * healAmount * 2.0f; - if (saturationAmount + satLevel <= 20) - { + if (saturationAmount + satLevel <= 20) { NBTTagCompound nbt = new NBTTagCompound(); foodStats.writeNBT(nbt); nbt.setFloat("foodSaturationLevel", saturationAmount + satLevel); @@ -86,8 +78,7 @@ public class RitualFullStomach extends Ritual } } - if (totalEffects >= maxEffects) - { + if (totalEffects >= maxEffects) { masterRitualStone.getOwnerNetwork().causeNausea(); break; } @@ -97,20 +88,17 @@ public class RitualFullStomach extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 20; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 100; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addParallelRunes(components, 3, 0, EnumRuneType.FIRE); @@ -123,8 +111,7 @@ public class RitualFullStomach extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualFullStomach(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualGreenGrove.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualGreenGrove.java index 996c7656..9f2af4fa 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualGreenGrove.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualGreenGrove.java @@ -1,12 +1,13 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.ritual.*; +import WayofTime.bloodmagic.api.soul.DemonWillHolder; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import WayofTime.bloodmagic.api_impl.BloodMagicAPI; import WayofTime.bloodmagic.core.RegistrarBloodMagic; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.block.Block; import net.minecraft.block.BlockFarmland; import net.minecraft.block.IGrowable; @@ -20,19 +21,12 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; -import net.minecraftforge.common.IPlantable; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.api.soul.DemonWillHolder; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -import WayofTime.bloodmagic.util.Utils; -public class RitualGreenGrove extends Ritual -{ +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public class RitualGreenGrove extends Ritual { public static final String GROW_RANGE = "growing"; public static final String LEECH_RANGE = "leech"; public static final String HYDRATE_RANGE = "hydrate"; @@ -41,16 +35,12 @@ public class RitualGreenGrove extends Ritual public static double rawWillDrain = 0.05; public static double vengefulWillDrain = 0.05; public static double steadfastWillDrain = 0.05; - - public int refreshTime = 20; public static int defaultRefreshTime = 20; - public static double defaultGrowthChance = 0.3; - public static IBlockState farmlandState = Blocks.FARMLAND.getDefaultState().withProperty(BlockFarmland.MOISTURE, 7); + public int refreshTime = 20; - public RitualGreenGrove() - { + public RitualGreenGrove() { super("ritualGreenGrove", 0, 5000, "ritual." + BloodMagic.MODID + ".greenGroveRitual"); addBlockRange(GROW_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-1, 2, -1), 3, 1, 3)); addBlockRange(LEECH_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 0, 0), 1)); @@ -61,14 +51,12 @@ public class RitualGreenGrove extends Ritual } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); BlockPos pos = masterRitualStone.getBlockPos(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -96,34 +84,26 @@ public class RitualGreenGrove extends Ritual AreaDescriptor growingRange = getBlockRange(GROW_RANGE); int maxGrowthVolume = getMaxVolumeForRange(GROW_RANGE, willConfig, holder); - if (!growingRange.isWithinRange(getMaxVerticalRadiusForRange(GROW_RANGE, willConfig, holder), getMaxHorizontalRadiusForRange(GROW_RANGE, willConfig, holder)) || (maxGrowthVolume != 0 && growingRange.getVolume() > maxGrowthVolume)) - { + if (!growingRange.isWithinRange(getMaxVerticalRadiusForRange(GROW_RANGE, willConfig, holder), getMaxHorizontalRadiusForRange(GROW_RANGE, willConfig, holder)) || (maxGrowthVolume != 0 && growingRange.getVolume() > maxGrowthVolume)) { return; } - for (BlockPos newPos : growingRange.getContainedPositions(pos)) - { + for (BlockPos newPos : growingRange.getContainedPositions(pos)) { IBlockState state = world.getBlockState(newPos); - if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state)) - { - if (state.getBlock() instanceof IGrowable) - { - if (world.rand.nextDouble() < growthChance) - { + if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state)) { + if (state.getBlock() instanceof IGrowable) { + if (world.rand.nextDouble() < growthChance) { state.getBlock().updateTick(world, newPos, state, new Random()); IBlockState newState = world.getBlockState(newPos); - if (!newState.equals(state)) - { + if (!newState.equals(state)) { totalGrowths++; - if (consumeRawWill) - { + if (consumeRawWill) { rawWill -= rawWillDrain; rawDrain += rawWillDrain; } - if (consumeVengefulWill) - { + if (consumeVengefulWill) { vengefulWill -= vengefulWillDrain; vengefulDrain += vengefulWillDrain; } @@ -132,35 +112,29 @@ public class RitualGreenGrove extends Ritual } } - if (totalGrowths >= maxGrowths || (consumeRawWill && rawWill < rawWillDrain) || (consumeVengefulWill && vengefulWill < vengefulWillDrain)) - { + if (totalGrowths >= maxGrowths || (consumeRawWill && rawWill < rawWillDrain) || (consumeVengefulWill && vengefulWill < vengefulWillDrain)) { break; } } - if (rawDrain > 0) - { + if (rawDrain > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawDrain, true); } - if (vengefulDrain > 0) - { + if (vengefulDrain > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.VENGEFUL, vengefulDrain, true); } AreaDescriptor hydrateRange = getBlockRange(HYDRATE_RANGE); double steadfastDrain = 0; - if (steadfastWill > steadfastWillDrain) - { + if (steadfastWill > steadfastWillDrain) { AxisAlignedBB aabb = hydrateRange.getAABB(pos); steadfastDrain += steadfastWillDrain * Utils.plantSeedsInArea(world, aabb, 2, 1); steadfastWill -= steadfastDrain; - for (BlockPos newPos : hydrateRange.getContainedPositions(pos)) - { - if (steadfastWill < steadfastWillDrain) - { + for (BlockPos newPos : hydrateRange.getContainedPositions(pos)) { + if (steadfastWill < steadfastWillDrain) { break; } @@ -168,53 +142,43 @@ public class RitualGreenGrove extends Ritual Block block = state.getBlock(); boolean hydratedBlock = false; - if (block == Blocks.DIRT || block == Blocks.GRASS) - { + if (block == Blocks.DIRT || block == Blocks.GRASS) { world.setBlockState(newPos, farmlandState); hydratedBlock = true; - } else if (block == Blocks.FARMLAND) - { + } else if (block == Blocks.FARMLAND) { int meta = block.getMetaFromState(state); - if (meta < 7) - { + if (meta < 7) { world.setBlockState(newPos, farmlandState); hydratedBlock = true; } } - if (hydratedBlock) - { + if (hydratedBlock) { steadfastWill -= steadfastWillDrain; steadfastDrain += steadfastWillDrain; } } } - if (steadfastDrain > 0) - { + if (steadfastDrain > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.STEADFAST, steadfastDrain, true); } double corrosiveDrain = 0; - if (corrosiveWill > corrosiveWillDrain) - { + if (corrosiveWill > corrosiveWillDrain) { AreaDescriptor leechRange = getBlockRange(LEECH_RANGE); AxisAlignedBB mobArea = leechRange.getAABB(pos); List entityList = world.getEntitiesWithinAABB(EntityLivingBase.class, mobArea); - for (EntityLivingBase entityLiving : entityList) - { - if (corrosiveWill < corrosiveWillDrain) - { + for (EntityLivingBase entityLiving : entityList) { + if (corrosiveWill < corrosiveWillDrain) { break; } - if (entityLiving instanceof EntityPlayer) - { + if (entityLiving instanceof EntityPlayer) { continue; } - if (entityLiving.isPotionActive(RegistrarBloodMagic.PLANT_LEECH) || !entityLiving.isPotionApplicable(new PotionEffect(RegistrarBloodMagic.PLANT_LEECH))) - { + if (entityLiving.isPotionActive(RegistrarBloodMagic.PLANT_LEECH) || !entityLiving.isPotionApplicable(new PotionEffect(RegistrarBloodMagic.PLANT_LEECH))) { continue; } @@ -224,8 +188,7 @@ public class RitualGreenGrove extends Ritual corrosiveDrain += corrosiveWillDrain; } - if (corrosiveDrain > 0) - { + if (corrosiveDrain > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveDrain, true); } } @@ -233,20 +196,16 @@ public class RitualGreenGrove extends Ritual masterRitualStone.getOwnerNetwork().syphon(totalGrowths * getRefreshCost()); } - public double getPlantGrowthChanceForWill(double will) - { - if (will > 0) - { + public double getPlantGrowthChanceForWill(double will) { + if (will > 0) { return 0.3 + will / 200; } return defaultGrowthChance; } - public int getRefreshTimeForRawWill(double rawWill) - { - if (rawWill > 0) - { + public int getRefreshTimeForRawWill(double rawWill) { + if (rawWill > 0) { return 10; } @@ -254,19 +213,15 @@ public class RitualGreenGrove extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return refreshTime; } @Override - public int getMaxVolumeForRange(String range, List activeTypes, DemonWillHolder holder) - { - if (GROW_RANGE.equals(range) && activeTypes.contains(EnumDemonWillType.DESTRUCTIVE)) - { + public int getMaxVolumeForRange(String range, List activeTypes, DemonWillHolder holder) { + if (GROW_RANGE.equals(range) && activeTypes.contains(EnumDemonWillType.DESTRUCTIVE)) { double destructiveWill = holder.getWill(EnumDemonWillType.DESTRUCTIVE); - if (destructiveWill > 0) - { + if (destructiveWill > 0) { return 81 + (int) Math.pow(destructiveWill / 4, 1.5); } } @@ -275,13 +230,10 @@ public class RitualGreenGrove extends Ritual } @Override - public int getMaxVerticalRadiusForRange(String range, List activeTypes, DemonWillHolder holder) - { - if (GROW_RANGE.equals(range) && activeTypes.contains(EnumDemonWillType.DESTRUCTIVE)) - { + public int getMaxVerticalRadiusForRange(String range, List activeTypes, DemonWillHolder holder) { + if (GROW_RANGE.equals(range) && activeTypes.contains(EnumDemonWillType.DESTRUCTIVE)) { double destructiveWill = holder.getWill(EnumDemonWillType.DESTRUCTIVE); - if (destructiveWill > 0) - { + if (destructiveWill > 0) { return (int) (4 + destructiveWill / 10d); } } @@ -290,13 +242,10 @@ public class RitualGreenGrove extends Ritual } @Override - public int getMaxHorizontalRadiusForRange(String range, List activeTypes, DemonWillHolder holder) - { - if (GROW_RANGE.equals(range) && activeTypes.contains(EnumDemonWillType.DESTRUCTIVE)) - { + public int getMaxHorizontalRadiusForRange(String range, List activeTypes, DemonWillHolder holder) { + if (GROW_RANGE.equals(range) && activeTypes.contains(EnumDemonWillType.DESTRUCTIVE)) { double destructiveWill = holder.getWill(EnumDemonWillType.DESTRUCTIVE); - if (destructiveWill > 0) - { + if (destructiveWill > 0) { return (int) (4 + destructiveWill / 10d); } } @@ -305,14 +254,12 @@ public class RitualGreenGrove extends Ritual } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 20; //TODO: Need to find a way to balance this } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addCornerRunes(components, 1, 0, EnumRuneType.EARTH); @@ -322,14 +269,12 @@ public class RitualGreenGrove 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") }; + 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")}; } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualGreenGrove(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualHarvest.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualHarvest.java index abc6dea5..e48c6b36 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualHarvest.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualHarvest.java @@ -12,34 +12,30 @@ import java.util.ArrayList; /** * This ritual uses registered {@link IHarvestHandler}'s to harvest blocks. - * + *

* To register a new Handler for this ritual use * {@link HarvestRegistry#registerHandler(IHarvestHandler)} - * + *

* This ritual includes a way to change the range based on what block is above * the MasterRitualStone. You can use * {@link HarvestRegistry#registerRangeAmplifier(BlockStack, int)} to register a * new amplifier. */ -public class RitualHarvest extends Ritual -{ +public class RitualHarvest extends Ritual { public static final String HARVEST_RANGE = "harvestRange"; - public RitualHarvest() - { + public RitualHarvest() { super("ritualHarvest", 0, 20000, "ritual." + BloodMagic.MODID + ".harvestRitual"); addBlockRange(HARVEST_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-4, 1, -4), 9, 5, 9)); setMaximumVolumeAndDistanceOfRange(HARVEST_RANGE, 0, 15, 15); } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); BlockPos pos = masterRitualStone.getBlockPos(); - if (masterRitualStone.getOwnerNetwork().getCurrentEssence() < getRefreshCost()) - { + if (masterRitualStone.getOwnerNetwork().getCurrentEssence() < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -49,11 +45,9 @@ public class RitualHarvest extends Ritual AreaDescriptor harvestArea = getBlockRange(HARVEST_RANGE); harvestArea.resetIterator(); - while (harvestArea.hasNext()) - { + while (harvestArea.hasNext()) { BlockPos nextPos = harvestArea.next().add(pos); - if (harvestBlock(world, nextPos)) - { + if (harvestBlock(world, nextPos)) { harvested++; } } @@ -62,20 +56,17 @@ public class RitualHarvest extends Ritual } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 20; } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 5; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); components.add(new RitualComponent(new BlockPos(1, 0, 1), EnumRuneType.DUSK)); @@ -107,13 +98,11 @@ public class RitualHarvest extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualHarvest(); } - public static boolean harvestBlock(World world, BlockPos pos) - { + public static boolean harvestBlock(World world, BlockPos pos) { BlockStack harvestStack = BlockStack.getStackFromPos(world, pos); for (IHarvestHandler handler : HarvestRegistry.getHandlerList()) diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualInterdiction.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualInterdiction.java index 57255109..69e6c61d 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualInterdiction.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualInterdiction.java @@ -10,33 +10,28 @@ import net.minecraft.world.World; import java.util.ArrayList; -public class RitualInterdiction extends Ritual -{ +public class RitualInterdiction extends Ritual { public static final String INTERDICTION_RANGE = "interdictionRange"; - public RitualInterdiction() - { + public RitualInterdiction() { super("ritualInterdiction", 0, 1000, "ritual." + BloodMagic.MODID + ".interdictionRitual"); addBlockRange(INTERDICTION_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-2, 0, -2), 5)); setMaximumVolumeAndDistanceOfRange(INTERDICTION_RANGE, 0, 10, 10); } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } AreaDescriptor interdictionRange = getBlockRange(INTERDICTION_RANGE); - for (EntityLivingBase entity : world.getEntitiesWithinAABB(EntityLivingBase.class, interdictionRange.getAABB(masterRitualStone.getBlockPos()))) - { + for (EntityLivingBase entity : world.getEntitiesWithinAABB(EntityLivingBase.class, interdictionRange.getAABB(masterRitualStone.getBlockPos()))) { if (entity instanceof EntityPlayer && (((EntityPlayer) entity).capabilities.isCreativeMode || PlayerHelper.getUUIDFromPlayer((EntityPlayer) entity).toString().equals(masterRitualStone.getOwner()))) continue; @@ -49,28 +44,24 @@ public class RitualInterdiction extends Ritual entity.motionZ = 0.1 * zDif; entity.fallDistance = 0; - if (entity instanceof EntityPlayer) - { + if (entity instanceof EntityPlayer) { entity.velocityChanged = true; } } } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 1; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 1; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addCornerRunes(components, 1, 0, EnumRuneType.AIR); @@ -80,8 +71,7 @@ public class RitualInterdiction extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualInterdiction(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualJumping.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualJumping.java index 5cc64b52..45ab5d5c 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualJumping.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualJumping.java @@ -11,25 +11,21 @@ import net.minecraft.world.World; import java.util.ArrayList; import java.util.List; -public class RitualJumping extends Ritual -{ +public class RitualJumping extends Ritual { public static final String JUMP_RANGE = "jumpRange"; - public RitualJumping() - { + public RitualJumping() { super("ritualJump", 0, 5000, "ritual." + BloodMagic.MODID + ".jumpRitual"); addBlockRange(JUMP_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-1, 1, -1), 3, 1, 3)); setMaximumVolumeAndDistanceOfRange(JUMP_RANGE, 0, 5, 5); } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -39,26 +35,22 @@ public class RitualJumping extends Ritual AreaDescriptor jumpRange = getBlockRange(JUMP_RANGE); List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, jumpRange.getAABB(masterRitualStone.getBlockPos())); - for (EntityLivingBase entity : entities) - { - if (totalEffects >= maxEffects) - { + for (EntityLivingBase entity : entities) { + if (totalEffects >= maxEffects) { break; } double motionY = 1.5; entity.fallDistance = 0; - if (entity.isSneaking()) - { + if (entity.isSneaking()) { continue; } entity.motionY = motionY; totalEffects++; - if (entity instanceof EntityPlayer) - { + if (entity instanceof EntityPlayer) { Utils.setPlayerSpeedFromServer((EntityPlayer) entity, entity.motionX, entity.motionY, entity.motionZ); } } @@ -67,20 +59,17 @@ public class RitualJumping extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 1; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 5; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); for (int i = -1; i <= 1; i++) @@ -90,8 +79,7 @@ public class RitualJumping extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualJumping(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualLava.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualLava.java index 3a8e82e0..1b6d15c1 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualLava.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualLava.java @@ -1,10 +1,13 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.BloodMagicAPI; +import WayofTime.bloodmagic.api.ritual.*; +import WayofTime.bloodmagic.api.soul.DemonWillHolder; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import WayofTime.bloodmagic.core.RegistrarBloodMagic; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -21,19 +24,11 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; -import WayofTime.bloodmagic.api.BloodMagicAPI; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.api.soul.DemonWillHolder; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -import WayofTime.bloodmagic.util.Utils; -public class RitualLava extends Ritual -{ +import java.util.ArrayList; +import java.util.List; + +public class RitualLava extends Ritual { public static final String LAVA_RANGE = "lavaRange"; public static final String FIRE_FUSE_RANGE = "fireFuse"; public static final String FIRE_RESIST_RANGE = "fireResist"; @@ -43,12 +38,10 @@ public class RitualLava extends Ritual public static final double vengefulWillDrain = 1; public static final double steadfastWillDrain = 0.5; public static final double corrosiveWillDrain = 0.2; - - public int timer = 0; public static final int corrosiveRefreshTime = 20; + public int timer = 0; - public RitualLava() - { + public RitualLava() { super("ritualLava", 0, 10000, "ritual." + BloodMagic.MODID + ".lavaRitual"); addBlockRange(LAVA_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1)); addBlockRange(FIRE_FUSE_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-2, -2, -2), 5)); @@ -64,15 +57,13 @@ public class RitualLava extends Ritual } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { timer++; World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); int lpDrain = 0; - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -87,26 +78,21 @@ public class RitualLava extends Ritual AreaDescriptor lavaRange = getBlockRange(LAVA_RANGE); int maxLavaVolume = getMaxVolumeForRange(LAVA_RANGE, willConfig, holder); - if (!lavaRange.isWithinRange(getMaxVerticalRadiusForRange(LAVA_RANGE, willConfig, holder), getMaxHorizontalRadiusForRange(LAVA_RANGE, willConfig, holder)) || (maxLavaVolume != 0 && lavaRange.getVolume() > maxLavaVolume)) - { + if (!lavaRange.isWithinRange(getMaxVerticalRadiusForRange(LAVA_RANGE, willConfig, holder), getMaxHorizontalRadiusForRange(LAVA_RANGE, willConfig, holder)) || (maxLavaVolume != 0 && lavaRange.getVolume() > maxLavaVolume)) { return; } - for (BlockPos newPos : lavaRange.getContainedPositions(pos)) - { + for (BlockPos newPos : lavaRange.getContainedPositions(pos)) { IBlockState state = world.getBlockState(newPos); - if (world.isAirBlock(newPos) || Utils.isFlowingLiquid(world, newPos, state)) - { + if (world.isAirBlock(newPos) || Utils.isFlowingLiquid(world, newPos, state)) { int lpCost = getLPCostForRawWill(rawWill); - if (currentEssence < lpCost) - { + if (currentEssence < lpCost) { break; } world.setBlockState(newPos, Blocks.FLOWING_LAVA.getDefaultState()); currentEssence -= lpCost; lpDrain += lpCost; - if (rawWill > 0) - { + if (rawWill > 0) { double drain = getWillCostForRawWill(rawWill); rawWill -= drain; rawDrained += drain; @@ -114,19 +100,15 @@ public class RitualLava extends Ritual } } - if (rawWill > 0) - { + if (rawWill > 0) { AreaDescriptor chestRange = getBlockRange(LAVA_TANK_RANGE); TileEntity tile = world.getTileEntity(chestRange.getContainedPositions(pos).get(0)); double drain = getWillCostForRawWill(rawWill); int lpCost = getLPCostForRawWill(rawWill); - if (rawWill >= drain && currentEssence >= lpCost) - { - if (tile != null) - { - if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) - { + if (rawWill >= drain && currentEssence >= lpCost) { + if (tile != null) { + if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) { IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null); double filled = handler.fill(new FluidStack(FluidRegistry.LAVA, 1000), true); @@ -146,28 +128,23 @@ public class RitualLava extends Ritual double steadfastWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.STEADFAST, willConfig); double corrosiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.CORROSIVE, willConfig); - if (vengefulWill >= vengefulWillDrain) - { + if (vengefulWill >= vengefulWillDrain) { double vengefulDrained = 0; AreaDescriptor fuseRange = getBlockRange(FIRE_FUSE_RANGE); AxisAlignedBB fuseArea = fuseRange.getAABB(pos); List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, fuseArea); - for (EntityLivingBase entity : entities) - { - if (vengefulWill < vengefulWillDrain) - { + for (EntityLivingBase entity : entities) { + if (vengefulWill < vengefulWillDrain) { break; } - if (entity instanceof EntityPlayer) - { + if (entity instanceof EntityPlayer) { continue; } - if (!entity.isPotionActive(RegistrarBloodMagic.FIRE_FUSE)) - { + if (!entity.isPotionActive(RegistrarBloodMagic.FIRE_FUSE)) { entity.addPotionEffect(new PotionEffect(RegistrarBloodMagic.FIRE_FUSE, 100, 0)); vengefulDrained += vengefulWillDrain; @@ -175,14 +152,12 @@ public class RitualLava extends Ritual } } - if (vengefulDrained > 0) - { + if (vengefulDrained > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.VENGEFUL, vengefulDrained, true); } } - if (steadfastWill >= steadfastWillDrain) - { + if (steadfastWill >= steadfastWillDrain) { double steadfastDrained = 0; AreaDescriptor resistRange = getBlockRange(FIRE_RESIST_RANGE); @@ -191,14 +166,11 @@ public class RitualLava extends Ritual AxisAlignedBB resistArea = resistRange.getAABB(pos); List entities = world.getEntitiesWithinAABB(EntityPlayer.class, resistArea); - for (EntityPlayer entity : entities) - { - if (steadfastWill < steadfastWillDrain) - { + for (EntityPlayer entity : entities) { + if (steadfastWill < steadfastWillDrain) { break; } - if (!entity.isPotionActive(MobEffects.FIRE_RESISTANCE) || (entity.getActivePotionEffect(MobEffects.FIRE_RESISTANCE).getDuration() < 2)) - { + if (!entity.isPotionActive(MobEffects.FIRE_RESISTANCE) || (entity.getActivePotionEffect(MobEffects.FIRE_RESISTANCE).getDuration() < 2)) { entity.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 100, 0)); steadfastDrained += steadfastWillDrain; @@ -206,14 +178,12 @@ public class RitualLava extends Ritual } } - if (steadfastDrained > 0) - { + if (steadfastDrained > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.STEADFAST, steadfastDrained, true); } } - if (timer % corrosiveRefreshTime == 0 && corrosiveWill >= corrosiveWillDrain) - { + if (timer % corrosiveRefreshTime == 0 && corrosiveWill >= corrosiveWillDrain) { double corrosiveDrained = 0; AreaDescriptor resistRange = getBlockRange(FIRE_DAMAGE_RANGE); @@ -222,31 +192,25 @@ public class RitualLava extends Ritual AxisAlignedBB damageArea = resistRange.getAABB(pos); List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, damageArea); - for (EntityLivingBase entity : entities) - { - if (corrosiveWill < corrosiveWillDrain) - { + for (EntityLivingBase entity : entities) { + if (corrosiveWill < corrosiveWillDrain) { break; } - if (!entity.isDead && entity.hurtTime <= 0 && Utils.isImmuneToFireDamage(entity)) - { - if (entity.attackEntityFrom(BloodMagicAPI.damageSource, damage)) - { + if (!entity.isDead && entity.hurtTime <= 0 && Utils.isImmuneToFireDamage(entity)) { + if (entity.attackEntityFrom(BloodMagicAPI.damageSource, damage)) { corrosiveDrained += corrosiveWillDrain; corrosiveWill -= corrosiveWillDrain; } } } - if (corrosiveDrained > 0) - { + if (corrosiveDrained > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveDrained, true); } } - if (rawDrained > 0) - { + if (rawDrained > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawDrained, true); } @@ -254,26 +218,22 @@ public class RitualLava extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 1; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 500; } @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") }; + 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")}; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addParallelRunes(components, 1, 0, EnumRuneType.FIRE); @@ -282,19 +242,15 @@ public class RitualLava extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualLava(); } @Override - public int getMaxVolumeForRange(String range, List activeTypes, DemonWillHolder holder) - { - if (LAVA_RANGE.equals(range) && activeTypes.contains(EnumDemonWillType.DESTRUCTIVE)) - { + public int getMaxVolumeForRange(String range, List activeTypes, DemonWillHolder holder) { + if (LAVA_RANGE.equals(range) && activeTypes.contains(EnumDemonWillType.DESTRUCTIVE)) { double destructiveWill = holder.getWill(EnumDemonWillType.DESTRUCTIVE); - if (destructiveWill > 0) - { + if (destructiveWill > 0) { return 9 + (int) Math.pow(destructiveWill / 10, 1.5); } } @@ -303,13 +259,10 @@ public class RitualLava extends Ritual } @Override - public int getMaxVerticalRadiusForRange(String range, List activeTypes, DemonWillHolder holder) - { - if (LAVA_RANGE.equals(range) && activeTypes.contains(EnumDemonWillType.DESTRUCTIVE)) - { + public int getMaxVerticalRadiusForRange(String range, List activeTypes, DemonWillHolder holder) { + if (LAVA_RANGE.equals(range) && activeTypes.contains(EnumDemonWillType.DESTRUCTIVE)) { double destructiveWill = holder.getWill(EnumDemonWillType.DESTRUCTIVE); - if (destructiveWill > 0) - { + if (destructiveWill > 0) { return (int) (3 + destructiveWill / 10d); } } @@ -318,13 +271,10 @@ public class RitualLava extends Ritual } @Override - public int getMaxHorizontalRadiusForRange(String range, List activeTypes, DemonWillHolder holder) - { - if (LAVA_RANGE.equals(range) && activeTypes.contains(EnumDemonWillType.DESTRUCTIVE)) - { + public int getMaxHorizontalRadiusForRange(String range, List activeTypes, DemonWillHolder holder) { + if (LAVA_RANGE.equals(range) && activeTypes.contains(EnumDemonWillType.DESTRUCTIVE)) { double destructiveWill = holder.getWill(EnumDemonWillType.DESTRUCTIVE); - if (destructiveWill > 0) - { + if (destructiveWill > 0) { return (int) (3 + destructiveWill / 10d); } } @@ -332,23 +282,19 @@ public class RitualLava extends Ritual return horizontalRangeMap.get(range); } - public int getFireResistForWill(double steadfastWill) - { + public int getFireResistForWill(double steadfastWill) { return (int) (200 + steadfastWill * 3); } - public float getCorrosiveDamageForWill(double corrosiveWill) - { + public float getCorrosiveDamageForWill(double corrosiveWill) { return (float) (1 + corrosiveWill * 0.05); } - public int getLPCostForRawWill(double raw) - { + public int getLPCostForRawWill(double raw) { return Math.max((int) (500 - raw), 0); } - public double getWillCostForRawWill(double raw) - { + public double getWillCostForRawWill(double raw) { return Math.min(1, raw / 500); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualLivingArmourDowngrade.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualLivingArmourDowngrade.java index c6e26ab9..70d01e55 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualLivingArmourDowngrade.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualLivingArmourDowngrade.java @@ -1,9 +1,14 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.api.recipe.LivingArmourDowngradeRecipe; +import WayofTime.bloodmagic.api.registry.LivingArmourDowngradeRecipeRegistry; +import WayofTime.bloodmagic.api.ritual.*; +import WayofTime.bloodmagic.item.armour.ItemLivingArmour; +import WayofTime.bloodmagic.livingArmour.LivingArmour; +import WayofTime.bloodmagic.util.ChatUtil; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.player.EntityPlayer; @@ -17,38 +22,25 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; import net.minecraftforge.items.IItemHandler; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.api.recipe.LivingArmourDowngradeRecipe; -import WayofTime.bloodmagic.api.registry.LivingArmourDowngradeRecipeRegistry; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.item.armour.ItemLivingArmour; -import WayofTime.bloodmagic.livingArmour.LivingArmour; -import WayofTime.bloodmagic.util.ChatUtil; -import WayofTime.bloodmagic.util.Utils; -public class RitualLivingArmourDowngrade extends Ritual -{ +import java.util.ArrayList; +import java.util.List; + +public class RitualLivingArmourDowngrade extends Ritual { public static final String DOWNGRADE_RANGE = "containmentRange"; private int internalTimer = 0; - public RitualLivingArmourDowngrade() - { + public RitualLivingArmourDowngrade() { super("ritualDowngrade", 0, 10000, "ritual." + BloodMagic.MODID + ".downgradeRitual"); addBlockRange(DOWNGRADE_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-3, 0, -3), 7)); } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -58,65 +50,50 @@ public class RitualLivingArmourDowngrade extends Ritual AreaDescriptor downgradeRange = getBlockRange(DOWNGRADE_RANGE); boolean isActivatorPresent = false; - for (EntityPlayer player : world.getEntitiesWithinAABB(EntityPlayer.class, downgradeRange.getAABB(masterRitualStone.getBlockPos()))) - { - if (player.getUniqueID().toString().equals(masterRitualStone.getOwner())) - { + for (EntityPlayer player : world.getEntitiesWithinAABB(EntityPlayer.class, downgradeRange.getAABB(masterRitualStone.getBlockPos()))) { + if (player.getUniqueID().toString().equals(masterRitualStone.getOwner())) { ItemStack keyStack = getStackFromItemFrame(world, masterPos, masterRitualStone.getDirection()); - if (keyStack.isEmpty()) - { + if (keyStack.isEmpty()) { return; } List textList = LivingArmourDowngradeRecipeRegistry.getDialogForProcessTick(keyStack, internalTimer); - if (textList != null) - { + if (textList != null) { ChatUtil.sendChat(player, textList.toArray(new ITextComponent[textList.size()])); } internalTimer++; - if (player.isSneaking()) - { + if (player.isSneaking()) { double distance2 = masterPos.offset(EnumFacing.UP).distanceSqToCenter(player.posX, player.posY, player.posZ); - if (distance2 > 1) - { + if (distance2 > 1) { return; } BlockPos chestPos = masterPos.offset(masterRitualStone.getDirection(), 2).offset(EnumFacing.UP); TileEntity tile = world.getTileEntity(chestPos); - if (tile == null) - { + if (tile == null) { return; } IItemHandler inv = Utils.getInventory(tile, null); - if (inv != null) - { + if (inv != null) { List recipeList = new ArrayList(); - for (int i = 0; i < inv.getSlots(); i++) - { + for (int i = 0; i < inv.getSlots(); i++) { ItemStack invStack = inv.getStackInSlot(i); - if (!invStack.isEmpty()) - { + if (!invStack.isEmpty()) { recipeList.add(invStack); } } LivingArmourDowngradeRecipe recipe = LivingArmourDowngradeRecipeRegistry.getMatchingRecipe(keyStack, recipeList, world, masterPos); - if (recipe != null) - { + if (recipe != null) { LivingArmourUpgrade upgrade = recipe.getRecipeOutput(); - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { - if (armour.canApplyUpgrade(player, upgrade)) - { - if (armour.upgradeArmour(player, upgrade)) - { + if (armour != null) { + if (armour.canApplyUpgrade(player, upgrade)) { + if (armour.upgradeArmour(player, upgrade)) { ItemLivingArmour.setLivingArmour(chestStack, armour); recipe.consumeInventory(inv); @@ -126,8 +103,7 @@ public class RitualLivingArmourDowngrade extends Ritual masterRitualStone.setActive(false); } - } else - { + } else { //TODO: You are not able to receive my blessing... //TODO: Need to add a timer that will stop it from working. } @@ -141,39 +117,33 @@ public class RitualLivingArmourDowngrade extends Ritual } } - if (!isActivatorPresent) - { + if (!isActivatorPresent) { internalTimer = 0; } } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); this.internalTimer = tag.getInteger("internalTimer"); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); tag.setInteger("internalTimer", internalTimer); } - public ItemStack getStackFromItemFrame(World world, BlockPos masterPos, EnumFacing direction) - { + public ItemStack getStackFromItemFrame(World world, BlockPos masterPos, EnumFacing direction) { BlockPos offsetPos = new BlockPos(0, 3, 0); offsetPos = offsetPos.offset(direction, 2); AxisAlignedBB bb = new AxisAlignedBB(masterPos.add(offsetPos)); List frames = world.getEntitiesWithinAABB(EntityItemFrame.class, bb); - for (EntityItemFrame frame : frames) - { - if (!frame.getDisplayedItem().isEmpty()) - { + for (EntityItemFrame frame : frames) { + if (!frame.getDisplayedItem().isEmpty()) { return frame.getDisplayedItem(); } } @@ -182,20 +152,17 @@ public class RitualLivingArmourDowngrade extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 1; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 0; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addRune(components, 0, 0, -1, EnumRuneType.AIR); @@ -208,8 +175,7 @@ public class RitualLivingArmourDowngrade extends Ritual for (int i = 1; i <= 3; i++) this.addRune(components, 0, 0, i, EnumRuneType.AIR); - for (int sgn = -1; sgn <= 1; sgn += 2) - { + for (int sgn = -1; sgn <= 1; sgn += 2) { this.addRune(components, sgn, 0, 4, EnumRuneType.AIR); this.addRune(components, sgn * 2, 0, 2, EnumRuneType.AIR); this.addRune(components, sgn * 3, 0, 2, EnumRuneType.AIR); @@ -239,8 +205,7 @@ public class RitualLivingArmourDowngrade extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualLivingArmourDowngrade(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualMagnetic.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualMagnetic.java index ab176dc3..948ce689 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualMagnetic.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualMagnetic.java @@ -1,10 +1,9 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.BlockStack; +import WayofTime.bloodmagic.api.ritual.*; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.block.Block; import net.minecraft.block.BlockOre; import net.minecraft.block.BlockRedstoneOre; @@ -16,81 +15,29 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; -import WayofTime.bloodmagic.api.BlockStack; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.util.Utils; -public class RitualMagnetic extends Ritual -{ - private static final Map oreBlockCache = new HashMap(); +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +public class RitualMagnetic extends Ritual { public static final String PLACEMENT_RANGE = "placementRange"; + private static final Map oreBlockCache = new HashMap(); // public static final String SEARCH_RANGE = "searchRange"; - public BlockPos lastPos; // An offset - public RitualMagnetic() - { + public RitualMagnetic() { super("ritualMagnetic", 0, 5000, "ritual." + BloodMagic.MODID + ".magneticRitual"); addBlockRange(PLACEMENT_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-1, 1, -1), 3)); setMaximumVolumeAndDistanceOfRange(PLACEMENT_RANGE, 50, 4, 4); } - public static boolean isBlockOre(Block block, int meta) - { - if (block == null) - return false; - - if (block instanceof BlockOre || block instanceof BlockRedstoneOre) - return true; - - if (Item.getItemFromBlock(block) == Items.AIR) - return false; - - BlockStack type = new BlockStack(block, meta); - Boolean result = oreBlockCache.get(type); - if (result == null) - { - result = computeIsItemOre(type); - oreBlockCache.put(type, result); - } - return result; - } - - private static boolean computeIsItemOre(BlockStack type) - { - ItemStack stack = new ItemStack(type.getBlock(), type.getMeta()); - return isBlockOre(stack); - } - - public static boolean isBlockOre(ItemStack stack) - { - if (stack.isEmpty()) - { - return false; - } - - for (int id : OreDictionary.getOreIDs(stack)) - { - String oreName = OreDictionary.getOreName(id); - if (oreName.contains("ore")) - return true; - } - return false; - } - @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -102,10 +49,8 @@ public class RitualMagnetic extends Ritual BlockPos replacement = pos; boolean replace = false; - for (BlockPos offset : placementRange.getContainedPositions(pos)) - { - if (world.isAirBlock(offset)) - { + for (BlockPos offset : placementRange.getContainedPositions(pos)) { + if (world.isAirBlock(offset)) { replacement = offset; replace = true; break; @@ -117,40 +62,33 @@ public class RitualMagnetic extends Ritual int radius = getRadius(downBlock); - if (replace) - { + if (replace) { int j = -1; int i = -radius; int k = -radius; - if (lastPos != null) - { + if (lastPos != null) { j = lastPos.getY(); i = Math.min(radius, Math.max(-radius, lastPos.getX())); k = Math.min(radius, Math.max(-radius, lastPos.getZ())); } - while (j + pos.getY() >= 0) - { - while (i <= radius) - { - while (k <= radius) - { + while (j + pos.getY() >= 0) { + while (i <= radius) { + while (k <= radius) { BlockPos newPos = pos.add(i, j, k); IBlockState state = world.getBlockState(newPos); Block block = state.getBlock(); ItemStack checkStack = block.getItem(world, newPos, state); // int meta = block.getMetaFromState(state); - if (isBlockOre(checkStack)) - { + if (isBlockOre(checkStack)) { Utils.swapLocations(world, newPos, world, replacement); masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); k++; this.lastPos = new BlockPos(i, j, k); return; - } else - { + } else { k++; } } @@ -170,20 +108,16 @@ public class RitualMagnetic extends Ritual } - public int getRadius(Block block) - { - if (block == Blocks.IRON_BLOCK) - { + public int getRadius(Block block) { + if (block == Blocks.IRON_BLOCK) { return 7; } - if (block == Blocks.GOLD_BLOCK) - { + if (block == Blocks.GOLD_BLOCK) { return 15; } - if (block == Blocks.DIAMOND_BLOCK) - { + if (block == Blocks.DIAMOND_BLOCK) { return 31; } @@ -191,20 +125,17 @@ public class RitualMagnetic extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 40; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 50; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addCornerRunes(components, 1, 0, EnumRuneType.EARTH); @@ -216,8 +147,44 @@ public class RitualMagnetic extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualMagnetic(); } + + public static boolean isBlockOre(Block block, int meta) { + if (block == null) + return false; + + if (block instanceof BlockOre || block instanceof BlockRedstoneOre) + return true; + + if (Item.getItemFromBlock(block) == Items.AIR) + return false; + + BlockStack type = new BlockStack(block, meta); + Boolean result = oreBlockCache.get(type); + if (result == null) { + result = computeIsItemOre(type); + oreBlockCache.put(type, result); + } + return result; + } + + private static boolean computeIsItemOre(BlockStack type) { + ItemStack stack = new ItemStack(type.getBlock(), type.getMeta()); + return isBlockOre(stack); + } + + public static boolean isBlockOre(ItemStack stack) { + if (stack.isEmpty()) { + return false; + } + + for (int id : OreDictionary.getOreIDs(stack)) { + String oreName = OreDictionary.getOreName(id); + if (oreName.contains("ore")) + return true; + } + return false; + } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualMeteor.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualMeteor.java index 72090b53..90a9412f 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualMeteor.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualMeteor.java @@ -1,38 +1,31 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; +import WayofTime.bloodmagic.api.ritual.*; import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; import WayofTime.bloodmagic.entity.projectile.EntityMeteor; import WayofTime.bloodmagic.meteor.MeteorRegistry; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; -public class RitualMeteor extends Ritual -{ +import java.util.ArrayList; +import java.util.List; + +public class RitualMeteor extends Ritual { public static final String ITEM_RANGE = "itemRange"; public static final double destructiveWillDrain = 50; - public RitualMeteor() - { + public RitualMeteor() { super("ritualMeteor", 0, 1000000, "ritual." + BloodMagic.MODID + ".meteorRitual"); addBlockRange(ITEM_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1)); setMaximumVolumeAndDistanceOfRange(ITEM_RANGE, 0, 10, 10); } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); @@ -55,22 +48,18 @@ public class RitualMeteor extends Ritual boolean successful = false; - for (EntityItem entityItem : itemList) - { + for (EntityItem entityItem : itemList) { ItemStack stack = entityItem.getItem(); - if (MeteorRegistry.hasMeteorForItem(stack)) - { + if (MeteorRegistry.hasMeteorForItem(stack)) { EntityMeteor meteor = new EntityMeteor(world, pos.getX(), 260, pos.getZ(), 0, -0.1, 0, radiusModifier, explosionModifier, fillerChance); meteor.setMeteorStack(stack.copy()); world.spawnEntity(meteor); entityItem.setDead(); - if (destructiveWill >= destructiveWillDrain && currentEssence >= 1000000000) - { + if (destructiveWill >= destructiveWillDrain && currentEssence >= 1000000000) { masterRitualStone.getOwnerNetwork().syphon(1000000); - } else - { + } else { masterRitualStone.setActive(false); } successful = true; @@ -78,40 +67,33 @@ public class RitualMeteor extends Ritual } } - if (successful) - { - if (rawWill > 0) - { + if (successful) { + if (rawWill > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawWill, true); } - if (corrosiveWill > 0) - { + if (corrosiveWill > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveWill, true); } - if (steadfastWill > 0) - { + if (steadfastWill > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.STEADFAST, steadfastWill, true); } } } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 1; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 0; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addParallelRunes(components, 2, 0, EnumRuneType.FIRE); @@ -120,8 +102,7 @@ public class RitualMeteor extends Ritual this.addOffsetRunes(components, 5, 3, 0, EnumRuneType.DUSK); this.addCornerRunes(components, 4, 0, EnumRuneType.DUSK); - for (int i = 4; i <= 6; i++) - { + for (int i = 4; i <= 6; i++) { this.addParallelRunes(components, 4, 0, EnumRuneType.EARTH); } @@ -145,23 +126,19 @@ public class RitualMeteor extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualMeteor(); } - public double getRadiusModifier(double rawWill) - { + public double getRadiusModifier(double rawWill) { return Math.pow(1 + rawWill / 100, 1 / 3); } - public double getFillerChance(double corrosiveWill) - { + public double getFillerChance(double corrosiveWill) { return corrosiveWill / 200; } - public double getExplosionModifier(double steadfastWill) - { + public double getExplosionModifier(double steadfastWill) { return Math.max(Math.pow(0.4, steadfastWill / 100), 1); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualPlacer.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualPlacer.java index 28abcbb3..938a3fab 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualPlacer.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualPlacer.java @@ -7,21 +7,19 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import java.util.ArrayList; -public class RitualPlacer extends Ritual -{ +public class RitualPlacer extends Ritual { public static final String PLACER_RANGE = "placerRange"; public static final String CHEST_RANGE = "chest"; - public RitualPlacer() - { + public RitualPlacer() { super("ritualPlacer", 0, 5000, "ritual." + BloodMagic.MODID + ".placerRitual"); addBlockRange(PLACER_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-2, 0, -2), 5, 1, 5)); addBlockRange(CHEST_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1)); @@ -31,8 +29,7 @@ public class RitualPlacer extends Ritual } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); BlockPos masterPos = masterRitualStone.getBlockPos(); AreaDescriptor chestRange = getBlockRange(CHEST_RANGE); @@ -40,33 +37,27 @@ public class RitualPlacer extends Ritual int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } AreaDescriptor areaDescriptor = getBlockRange(PLACER_RANGE); - if (tileEntity != null) - { - if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) - { + if (tileEntity != null) { + if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) { IItemHandler itemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN); - if (itemHandler.getSlots() <= 0) - { + if (itemHandler.getSlots() <= 0) { return; } posLoop: - for (BlockPos blockPos : areaDescriptor.getContainedPositions(masterRitualStone.getBlockPos())) - { + for (BlockPos blockPos : areaDescriptor.getContainedPositions(masterRitualStone.getBlockPos())) { if (!world.getBlockState(blockPos).getBlock().isReplaceable(world, blockPos)) continue; - for (int invSlot = 0; invSlot < itemHandler.getSlots(); invSlot++) - { + for (int invSlot = 0; invSlot < itemHandler.getSlots(); invSlot++) { ItemStack stack = itemHandler.extractItem(invSlot, 1, true); if (stack.isEmpty() || !(stack.getItem() instanceof ItemBlock)) continue; @@ -84,14 +75,12 @@ public class RitualPlacer extends Ritual } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 50; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); addRune(components, 3, 0, 3, EnumRuneType.EARTH); @@ -112,8 +101,7 @@ public class RitualPlacer extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualPlacer(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualPortal.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualPortal.java index 171c068e..4732b101 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualPortal.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualPortal.java @@ -12,30 +12,26 @@ import WayofTime.bloodmagic.tile.TileDimensionalPortal; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.ForgeRegistries; import java.util.ArrayList; -public class RitualPortal extends Ritual -{ - - private NBTTagCompound portalRitualTag; +public class RitualPortal extends Ritual { public static final String PORTAL_NBT_TAG = "PortalRitualTag"; public static final String PORTAL_ID_TAG = "PortalRitualID"; + private NBTTagCompound portalRitualTag; - public RitualPortal() - { + public RitualPortal() { super("ritualPortal", 0, 50000, "ritual." + BloodMagic.MODID + ".portalRitual"); portalRitualTag = new NBTTagCompound(); } @Override - public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player, String owner) - { + public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player, String owner) { World world = masterRitualStone.getWorldObj(); int x = masterRitualStone.getBlockPos().getX(); int y = masterRitualStone.getBlockPos().getY(); @@ -45,72 +41,54 @@ public class RitualPortal extends Ritual String name = owner; IBlockState blockState; - if (!world.isRemote) - { + if (!world.isRemote) { portalRitualTag.removeTag(PORTAL_ID_TAG); - if (direction == EnumFacing.NORTH || direction == EnumFacing.SOUTH) - { - for (int i = x - 3; i <= x + 3; i++) - { - for (int k = z - 2; k <= z + 2; k++) - { - if (!world.isAirBlock(new BlockPos(i, y, k)) && !(getBlockState(world, i, y, k).getBlock() == RegistrarBloodMagicBlocks.RITUAL_STONE)) - { + if (direction == EnumFacing.NORTH || direction == EnumFacing.SOUTH) { + for (int i = x - 3; i <= x + 3; i++) { + for (int k = z - 2; k <= z + 2; k++) { + if (!world.isAirBlock(new BlockPos(i, y, k)) && !(getBlockState(world, i, y, k).getBlock() == RegistrarBloodMagicBlocks.RITUAL_STONE)) { blockState = getBlockState(world, i, y, k); name = addStringToEnd(name, ForgeRegistries.BLOCKS.getKey(blockState.getBlock()) + String.valueOf(blockState.getBlock().getMetaFromState(blockState))); } } } - for (int j = y + 1; j <= y + 5; j++) - { - if (!world.isAirBlock(new BlockPos(x - 3, j, z)) && !(getBlockState(world, x - 3, j, z).getBlock() == RegistrarBloodMagicBlocks.RITUAL_STONE)) - { + for (int j = y + 1; j <= y + 5; j++) { + if (!world.isAirBlock(new BlockPos(x - 3, j, z)) && !(getBlockState(world, x - 3, j, z).getBlock() == RegistrarBloodMagicBlocks.RITUAL_STONE)) { blockState = getBlockState(world, x - 3, j, z); name = addStringToEnd(name, ForgeRegistries.BLOCKS.getKey(blockState.getBlock()) + String.valueOf(blockState.getBlock().getMetaFromState(blockState))); } } - for (int j = y + 1; j <= y + 5; j++) - { - if (!world.isAirBlock(new BlockPos(x + 3, j, z)) && !(getBlockState(world, x + 3, j, z) == RegistrarBloodMagicBlocks.RITUAL_STONE)) - { + for (int j = y + 1; j <= y + 5; j++) { + if (!world.isAirBlock(new BlockPos(x + 3, j, z)) && !(getBlockState(world, x + 3, j, z) == RegistrarBloodMagicBlocks.RITUAL_STONE)) { blockState = getBlockState(world, x + 3, j, z); name = addStringToEnd(name, ForgeRegistries.BLOCKS.getKey(blockState.getBlock()) + String.valueOf(blockState.getBlock().getMetaFromState(blockState))); } } - } else if (direction == EnumFacing.EAST || direction == EnumFacing.WEST) - { - for (int k = z - 3; k <= z + 3; k++) - { - for (int i = x - 2; i <= x + 2; i++) - { - if (!world.isAirBlock(new BlockPos(i, y, k)) && !(getBlockState(world, i, y, k).getBlock() == RegistrarBloodMagicBlocks.RITUAL_STONE)) - { + } else if (direction == EnumFacing.EAST || direction == EnumFacing.WEST) { + for (int k = z - 3; k <= z + 3; k++) { + for (int i = x - 2; i <= x + 2; i++) { + if (!world.isAirBlock(new BlockPos(i, y, k)) && !(getBlockState(world, i, y, k).getBlock() == RegistrarBloodMagicBlocks.RITUAL_STONE)) { blockState = getBlockState(world, i, y, k); name = addStringToEnd(name, ForgeRegistries.BLOCKS.getKey(blockState.getBlock()) + String.valueOf(blockState.getBlock().getMetaFromState(blockState))); } } } - for (int j = y + 1; j <= y + 5; j++) - { - if (!world.isAirBlock(new BlockPos(x, j, z - 3)) && !(getBlockState(world, x, j, z - 3).getBlock() == RegistrarBloodMagicBlocks.RITUAL_STONE)) - { + for (int j = y + 1; j <= y + 5; j++) { + if (!world.isAirBlock(new BlockPos(x, j, z - 3)) && !(getBlockState(world, x, j, z - 3).getBlock() == RegistrarBloodMagicBlocks.RITUAL_STONE)) { blockState = getBlockState(world, x, j, z - 3); name = addStringToEnd(name, ForgeRegistries.BLOCKS.getKey(blockState.getBlock()) + String.valueOf(blockState.getBlock().getMetaFromState(blockState))); } } - for (int j = y + 1; j <= y + 5; j++) - { - if (!world.isAirBlock(new BlockPos(x, j, z + 3)) && !(getBlockState(world, x, j, z + 3).getBlock() == RegistrarBloodMagicBlocks.RITUAL_STONE)) - { + for (int j = y + 1; j <= y + 5; j++) { + if (!world.isAirBlock(new BlockPos(x, j, z + 3)) && !(getBlockState(world, x, j, z + 3).getBlock() == RegistrarBloodMagicBlocks.RITUAL_STONE)) { blockState = getBlockState(world, x, j, z + 3); name = addStringToEnd(name, ForgeRegistries.BLOCKS.getKey(blockState.getBlock()) + String.valueOf(blockState.getBlock().getMetaFromState(blockState))); } } } - 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; } @@ -119,11 +97,9 @@ public class RitualPortal extends Ritual } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); - if (world.isRemote) - { + if (world.isRemote) { return; } @@ -132,21 +108,16 @@ public class RitualPortal extends Ritual int z = masterRitualStone.getBlockPos().getZ(); EnumFacing direction = masterRitualStone.getDirection(); - if (direction == EnumFacing.NORTH || direction == EnumFacing.SOUTH) - { - for (int i = x - 1; i <= x + 1; i++) - { - for (int j = y + 1; j <= y + 3; j++) - { + if (direction == EnumFacing.NORTH || direction == EnumFacing.SOUTH) { + for (int i = x - 1; i <= x + 1; i++) { + for (int j = y + 1; j <= y + 3; j++) { BlockPos tempPos = new BlockPos(i, j, z); - if (world.isAirBlock(tempPos)) - { + if (world.isAirBlock(tempPos)) { IBlockState blockState = RegistrarBloodMagicBlocks.DIMENSIONAL_PORTAL.getStateFromMeta(0); world.setBlockState(tempPos, blockState, 3); - if (world.getTileEntity(tempPos) != null && world.getTileEntity(tempPos) instanceof TileDimensionalPortal) - { + if (world.getTileEntity(tempPos) != null && world.getTileEntity(tempPos) instanceof TileDimensionalPortal) { TileDimensionalPortal tile = (TileDimensionalPortal) world.getTileEntity(tempPos); tile.setMasterStonePos(masterRitualStone.getBlockPos()); tile.portalID = portalRitualTag.getString(PORTAL_ID_TAG); @@ -154,20 +125,15 @@ public class RitualPortal extends Ritual } } } - } else if (direction == EnumFacing.EAST || direction == EnumFacing.WEST) - { - for (int k = z - 1; k <= z + 1; k++) - { - for (int j = y + 1; j <= y + 3; j++) - { + } else if (direction == EnumFacing.EAST || direction == EnumFacing.WEST) { + for (int k = z - 1; k <= z + 1; k++) { + for (int j = y + 1; j <= y + 3; j++) { BlockPos tempPos = new BlockPos(x, j, k); - if (world.isAirBlock(tempPos)) - { + if (world.isAirBlock(tempPos)) { IBlockState blockState = RegistrarBloodMagicBlocks.DIMENSIONAL_PORTAL.getStateFromMeta(1); world.setBlockState(tempPos, blockState, 3); - if (world.getTileEntity(tempPos) != null && world.getTileEntity(tempPos) instanceof TileDimensionalPortal) - { + if (world.getTileEntity(tempPos) != null && world.getTileEntity(tempPos) instanceof TileDimensionalPortal) { TileDimensionalPortal tile = (TileDimensionalPortal) world.getTileEntity(tempPos); tile.setMasterStonePos(masterRitualStone.getBlockPos()); tile.portalID = portalRitualTag.getString(PORTAL_ID_TAG); @@ -180,8 +146,7 @@ public class RitualPortal extends Ritual } @Override - public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType) - { + public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType) { World world = masterRitualStone.getWorldObj(); int x = masterRitualStone.getBlockPos().getX(); int y = masterRitualStone.getBlockPos().getY(); @@ -190,26 +155,18 @@ public class RitualPortal extends Ritual LocationsHandler.getLocationsHandler().removeLocation(portalRitualTag.getString(PORTAL_ID_TAG), new PortalLocation(x, y + 1, z, world.provider.getDimension())); - if (direction == EnumFacing.NORTH || direction == EnumFacing.SOUTH) - { - for (int i = x - 2; i <= x + 2; i++) - { - for (int j = y + 1; j <= y + 3; j++) - { - if (getBlockState(world, i, j, z).getBlock() == RegistrarBloodMagicBlocks.DIMENSIONAL_PORTAL) - { + if (direction == EnumFacing.NORTH || direction == EnumFacing.SOUTH) { + for (int i = x - 2; i <= x + 2; i++) { + for (int j = y + 1; j <= y + 3; j++) { + if (getBlockState(world, i, j, z).getBlock() == RegistrarBloodMagicBlocks.DIMENSIONAL_PORTAL) { world.setBlockToAir(new BlockPos(i, j, z)); } } } - } else if (direction == EnumFacing.EAST || direction == EnumFacing.WEST) - { - for (int k = z - 2; k <= z + 2; k++) - { - for (int j = y + 1; j <= y + 3; j++) - { - if (getBlockState(world, x, j, k).getBlock() == RegistrarBloodMagicBlocks.DIMENSIONAL_PORTAL) - { + } else if (direction == EnumFacing.EAST || direction == EnumFacing.WEST) { + for (int k = z - 2; k <= z + 2; k++) { + for (int j = y + 1; j <= y + 3; j++) { + if (getBlockState(world, x, j, k).getBlock() == RegistrarBloodMagicBlocks.DIMENSIONAL_PORTAL) { world.setBlockToAir(new BlockPos(x, j, k)); } } @@ -220,14 +177,12 @@ public class RitualPortal extends Ritual } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 0; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); addRune(components, 1, 0, 0, EnumRuneType.AIR); @@ -252,34 +207,29 @@ public class RitualPortal extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualPortal(); } @Override - public void readFromNBT(NBTTagCompound tag) - { + public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); portalRitualTag = tag.getCompoundTag(PORTAL_NBT_TAG); } @Override - public void writeToNBT(NBTTagCompound tag) - { + public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); tag.setTag(PORTAL_NBT_TAG, portalRitualTag); } - public IBlockState getBlockState(World world, int x, int y, int z) - { + public IBlockState getBlockState(World world, int x, int y, int z) { return world.getBlockState(new BlockPos(x, y, z)); } - public String addStringToEnd(String input, String toAdd) - { + public String addStringToEnd(String input, String toAdd) { return input + toAdd; } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualPump.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualPump.java index ca63f12a..0158e15c 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualPump.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualPump.java @@ -7,8 +7,8 @@ import net.minecraft.block.BlockLiquid; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidBlock; @@ -22,15 +22,13 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -public class RitualPump extends Ritual -{ +public class RitualPump extends Ritual { public static final String PUMP_RANGE = "pumpRange"; private List> liquidsCache; private Iterator> blockPosIterator; - public RitualPump() - { + public RitualPump() { super("ritualPump", 0, 500, "ritual." + BloodMagic.MODID + ".pumpRitual"); addBlockRange(PUMP_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-16, -16, -16), new BlockPos(17, 17, 17))); @@ -39,14 +37,12 @@ public class RitualPump extends Ritual } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); TileEntity tileEntity = world.getTileEntity(masterRitualStone.getBlockPos().up()); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -90,14 +86,12 @@ public class RitualPump extends Ritual } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 25; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); addRune(components, 1, 0, 1, EnumRuneType.WATER); @@ -111,8 +105,7 @@ public class RitualPump extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualPump(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualRegeneration.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualRegeneration.java index 5e7fd81d..64537627 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualRegeneration.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualRegeneration.java @@ -1,10 +1,11 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.BloodMagicAPI; +import WayofTime.bloodmagic.api.ritual.*; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; @@ -12,18 +13,12 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.BloodMagicAPI; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -import WayofTime.bloodmagic.util.Utils; -public class RitualRegeneration extends Ritual -{ +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class RitualRegeneration extends Ritual { public static final String HEAL_RANGE = "heal"; public static final String VAMPIRE_RANGE = "vampire"; @@ -31,8 +26,7 @@ public class RitualRegeneration extends Ritual public static final double corrosiveWillDrain = 0.04; - public RitualRegeneration() - { + public RitualRegeneration() { super("ritualRegeneration", 0, 25000, "ritual." + BloodMagic.MODID + ".regenerationRitual"); addBlockRange(HEAL_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-15, -15, -15), 31)); addBlockRange(VAMPIRE_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-15, -15, -15), 31)); @@ -42,13 +36,11 @@ public class RitualRegeneration extends Ritual } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -88,18 +80,13 @@ public class RitualRegeneration extends Ritual List players = world.getEntitiesWithinAABB(EntityPlayer.class, healRange); List damagedEntities = world.getEntitiesWithinAABB(EntityLivingBase.class, damageRange); - if (syphonHealth) - { - for (EntityPlayer player : players) - { - if (player.getHealth() <= player.getMaxHealth() - 1) - { + if (syphonHealth) { + for (EntityPlayer player : players) { + if (player.getHealth() <= player.getMaxHealth() - 1) { float syphonedHealthAmount = getSyphonAmountForWill(corrosiveWill); Collections.shuffle(damagedEntities); - for (EntityLivingBase damagedEntity : damagedEntities) - { - if (damagedEntity instanceof EntityPlayer) - { + for (EntityLivingBase damagedEntity : damagedEntities) { + if (damagedEntity instanceof EntityPlayer) { continue; } @@ -108,8 +95,7 @@ public class RitualRegeneration extends Ritual damagedEntity.attackEntityFrom(BloodMagicAPI.damageSource, Math.min(player.getMaxHealth() - player.getHealth(), syphonedHealthAmount)); float healthDifference = currentHealth - damagedEntity.getHealth(); - if (healthDifference > 0) - { + if (healthDifference > 0) { corrosiveDrain += corrosiveWillDrain; corrosiveWill -= corrosiveWillDrain; player.heal(healthDifference); @@ -121,19 +107,14 @@ public class RitualRegeneration extends Ritual } } - for (EntityLivingBase entity : entities) - { + for (EntityLivingBase entity : entities) { float health = entity.getHealth(); - if (health <= entity.getMaxHealth() - 1) - { - if (entity.isPotionApplicable(new PotionEffect(MobEffects.REGENERATION))) - { - if (entity instanceof EntityPlayer) - { + if (health <= entity.getMaxHealth() - 1) { + if (entity.isPotionApplicable(new PotionEffect(MobEffects.REGENERATION))) { + if (entity instanceof EntityPlayer) { totalCost += getRefreshCost(); currentEssence -= getRefreshCost(); - } else - { + } else { totalCost += getRefreshCost() / 10; currentEssence -= getRefreshCost() / 10; } @@ -142,23 +123,19 @@ public class RitualRegeneration extends Ritual totalEffects++; - if (totalEffects >= maxEffects) - { + if (totalEffects >= maxEffects) { break; } } } - if (applyAbsorption && entity instanceof EntityPlayer) - { - if (applyAbsorption) - { + if (applyAbsorption && entity instanceof EntityPlayer) { + if (applyAbsorption) { float added = Utils.addAbsorptionToMaximum(entity, absorptionRate, maxAbsorption, 1000); } } } - if (corrosiveDrain > 0) - { + if (corrosiveDrain > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveDrain, true); } @@ -166,20 +143,17 @@ public class RitualRegeneration extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 50; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return SACRIFICE_AMOUNT; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); components.add(new RitualComponent(new BlockPos(4, 0, 0), EnumRuneType.AIR)); @@ -204,13 +178,11 @@ public class RitualRegeneration extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualRegeneration(); } - public float getSyphonAmountForWill(double corrosiveWill) - { + public float getSyphonAmountForWill(double corrosiveWill) { return 1; } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualSpeed.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualSpeed.java index a2de3a23..4cc59843 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualSpeed.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualSpeed.java @@ -1,9 +1,10 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.ritual.*; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.EnumFacing; @@ -11,38 +12,29 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -import WayofTime.bloodmagic.util.Utils; -public class RitualSpeed extends Ritual -{ +import java.util.ArrayList; +import java.util.List; + +public class RitualSpeed extends Ritual { public static final String SPEED_RANGE = "sanicRange"; public static final double vengefulWillDrain = 0.05; public static final double destructiveWillDrain = 0.05; public static final double rawWillDrain = 0.1; - public RitualSpeed() - { + public RitualSpeed() { super("ritualSpeed", 0, 1000, "ritual." + BloodMagic.MODID + ".speedRitual"); addBlockRange(SPEED_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-2, 1, -2), new BlockPos(2, 5, 2))); setMaximumVolumeAndDistanceOfRange(SPEED_RANGE, 0, 2, 5); } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -63,37 +55,31 @@ public class RitualSpeed extends Ritual double destructiveDrain = 0; double rawDrain = 0; - if (rawWill < rawWillDrain) - { + if (rawWill < rawWillDrain) { rawWill = 0; //Simplifies later calculations } - for (EntityLivingBase entity : world.getEntitiesWithinAABB(EntityLivingBase.class, speedRange.getAABB(masterRitualStone.getBlockPos()))) - { + for (EntityLivingBase entity : world.getEntitiesWithinAABB(EntityLivingBase.class, speedRange.getAABB(masterRitualStone.getBlockPos()))) { if (entity.isSneaking()) continue; boolean transportChildren = destructiveWill < destructiveWillDrain; boolean transportAdults = vengefulWill < vengefulWillDrain; - if ((entity.isChild() && !transportChildren) || (!entity.isChild() && !transportAdults)) - { + if ((entity.isChild() && !transportChildren) || (!entity.isChild() && !transportAdults)) { continue; } - if (entity instanceof EntityPlayer && (transportChildren ^ transportAdults)) - { + if (entity instanceof EntityPlayer && (transportChildren ^ transportAdults)) { continue; } - if (!transportChildren) - { + if (!transportChildren) { destructiveWill -= destructiveWillDrain; destructiveDrain += destructiveWillDrain; } - if (!transportAdults) - { + if (!transportAdults) { vengefulWill -= vengefulWillDrain; vengefulDrain += vengefulWillDrain; } @@ -102,8 +88,7 @@ public class RitualSpeed extends Ritual double speed = getHorizontalSpeedForWill(rawWill); EnumFacing direction = masterRitualStone.getDirection(); - if (rawWill >= rawWillDrain) - { + if (rawWill >= rawWillDrain) { rawWill -= rawWillDrain; rawDrain += rawWillDrain; } @@ -111,79 +96,70 @@ public class RitualSpeed extends Ritual entity.motionY = motionY; entity.fallDistance = 0; - switch (direction) - { - case NORTH: - entity.motionX = 0; - entity.motionY = motionY; - entity.motionZ = -speed; - break; + switch (direction) { + case NORTH: + entity.motionX = 0; + entity.motionY = motionY; + entity.motionZ = -speed; + break; - case SOUTH: - entity.motionX = 0; - entity.motionY = motionY; - entity.motionZ = speed; - break; + case SOUTH: + entity.motionX = 0; + entity.motionY = motionY; + entity.motionZ = speed; + break; - case WEST: - entity.motionX = -speed; - entity.motionY = motionY; - entity.motionZ = 0; - break; + case WEST: + entity.motionX = -speed; + entity.motionY = motionY; + entity.motionZ = 0; + break; - case EAST: - entity.motionX = speed; - entity.motionY = motionY; - entity.motionZ = 0; - break; - default: - break; + case EAST: + entity.motionX = speed; + entity.motionY = motionY; + entity.motionZ = 0; + break; + default: + break; } - if (entity instanceof EntityPlayer) - { + if (entity instanceof EntityPlayer) { Utils.setPlayerSpeedFromServer((EntityPlayer) entity, entity.motionX, entity.motionY, entity.motionZ); } } - if (rawDrain > 0) - { + if (rawDrain > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawDrain, true); } - if (vengefulDrain > 0) - { + if (vengefulDrain > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.VENGEFUL, vengefulDrain, true); } - if (destructiveDrain > 0) - { + if (destructiveDrain > 0) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DESTRUCTIVE, destructiveDrain, true); } } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 1; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 5; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addRune(components, 0, 0, -2, EnumRuneType.DUSK); this.addRune(components, 1, 0, -1, EnumRuneType.AIR); this.addRune(components, -1, 0, -1, EnumRuneType.AIR); - for (int i = 0; i < 3; i++) - { + for (int i = 0; i < 3; i++) { this.addRune(components, 2, 0, i, EnumRuneType.AIR); this.addRune(components, -2, 0, i, EnumRuneType.AIR); } @@ -192,24 +168,20 @@ public class RitualSpeed extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualSpeed(); } @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") }; + 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")}; } - public double getVerticalSpeedForWill(double rawWill) - { + public double getVerticalSpeedForWill(double rawWill) { return 1.2 + rawWill / 200; } - public double getHorizontalSpeedForWill(double rawWill) - { + public double getHorizontalSpeedForWill(double rawWill) { return 3 + rawWill / 40; } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualSuppression.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualSuppression.java index 9c593771..967ca362 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualSuppression.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualSuppression.java @@ -1,38 +1,30 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.ritual.*; +import WayofTime.bloodmagic.tile.TileSpectralBlock; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.tile.TileSpectralBlock; -import WayofTime.bloodmagic.util.Utils; -public class RitualSuppression extends Ritual -{ +import java.util.ArrayList; + +public class RitualSuppression extends Ritual { public static final String SUPPRESSION_RANGE = "suppressionRange"; - public RitualSuppression() - { + public RitualSuppression() { super("ritualSuppression", 0, 10000, "ritual." + BloodMagic.MODID + ".suppressionRitual"); addBlockRange(SUPPRESSION_RANGE, new AreaDescriptor.HemiSphere(new BlockPos(0, 0, 0), 10)); } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -40,14 +32,12 @@ public class RitualSuppression extends Ritual final int refresh = 100; AreaDescriptor suppressionRange = getBlockRange(SUPPRESSION_RANGE); - for (BlockPos blockPos : suppressionRange.getContainedPositions(masterRitualStone.getBlockPos())) - { + for (BlockPos blockPos : suppressionRange.getContainedPositions(masterRitualStone.getBlockPos())) { IBlockState state = world.getBlockState(blockPos); if (Utils.isBlockLiquid(state) && world.getTileEntity(blockPos) == null) TileSpectralBlock.createSpectralBlock(world, blockPos, refresh); - else - { + else { TileEntity tile = world.getTileEntity(blockPos); if (tile instanceof TileSpectralBlock) ((TileSpectralBlock) tile).resetDuration(refresh); @@ -56,20 +46,17 @@ public class RitualSuppression extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 1; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 2; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addCornerRunes(components, 2, 0, EnumRuneType.WATER); @@ -86,8 +73,7 @@ public class RitualSuppression extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualSuppression(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualUpgradeRemove.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualUpgradeRemove.java index c7dce0df..f1c12561 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualUpgradeRemove.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualUpgradeRemove.java @@ -1,48 +1,39 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map.Entry; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.api.livingArmour.StatTracker; +import WayofTime.bloodmagic.api.ritual.*; +import WayofTime.bloodmagic.api.util.helper.ItemHelper.LivingUpgrades; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.item.armour.ItemLivingArmour; +import WayofTime.bloodmagic.livingArmour.LivingArmour; +import com.google.common.collect.Iterables; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.api.livingArmour.StatTracker; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.api.util.helper.ItemHelper.LivingUpgrades; -import WayofTime.bloodmagic.item.armour.ItemLivingArmour; -import WayofTime.bloodmagic.livingArmour.LivingArmour; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import com.google.common.collect.Iterables; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map.Entry; -public class RitualUpgradeRemove extends Ritual -{ +public class RitualUpgradeRemove extends Ritual { public static final String CHECK_RANGE = "fillRange"; - public RitualUpgradeRemove() - { + public RitualUpgradeRemove() { super("ritualUpgradeRemove", 0, 25000, "ritual." + BloodMagic.MODID + ".upgradeRemoveRitual"); addBlockRange(CHECK_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1, 2, 1)); } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); - if (world.isRemote) - { + if (world.isRemote) { return; } @@ -52,21 +43,17 @@ public class RitualUpgradeRemove extends Ritual List playerList = world.getEntitiesWithinAABB(EntityPlayer.class, checkRange.getAABB(pos)); - for (EntityPlayer player : playerList) - { - if (LivingArmour.hasFullSet(player)) - { + for (EntityPlayer player : playerList) { + if (LivingArmour.hasFullSet(player)) { boolean removedUpgrade = false; ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2]; LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { + if (armour != null) { @SuppressWarnings("unchecked") HashMap upgradeMap = (HashMap) armour.upgradeMap.clone(); - for (Entry entry : upgradeMap.entrySet()) - { + for (Entry entry : upgradeMap.entrySet()) { LivingArmourUpgrade upgrade = entry.getValue(); String upgradeKey = entry.getKey(); @@ -76,17 +63,13 @@ public class RitualUpgradeRemove extends Ritual boolean successful = armour.removeUpgrade(player, upgrade); - if (successful) - { + if (successful) { removedUpgrade = true; world.spawnEntity(new EntityItem(world, player.posX, player.posY, player.posZ, upgradeStack)); - for (Entry trackerEntry : armour.trackerMap.entrySet()) - { + for (Entry trackerEntry : armour.trackerMap.entrySet()) { StatTracker tracker = trackerEntry.getValue(); - if (tracker != null) - { - if (tracker.providesUpgrade(upgradeKey)) - { + if (tracker != null) { + if (tracker.providesUpgrade(upgradeKey)) { tracker.resetTracker(); //Resets the tracker if the upgrade corresponding to it was removed. } } @@ -94,8 +77,7 @@ public class RitualUpgradeRemove extends Ritual } } - if (removedUpgrade) - { + if (removedUpgrade) { ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true); ItemLivingArmour.setLivingArmour(chestStack, armour); armour.recalculateUpgradePoints(); @@ -111,20 +93,17 @@ public class RitualUpgradeRemove extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 1; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 0; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addCornerRunes(components, 1, 0, EnumRuneType.DUSK); @@ -135,8 +114,7 @@ public class RitualUpgradeRemove extends Ritual this.addCornerRunes(components, 1, 3, EnumRuneType.WATER); this.addParallelRunes(components, 1, 4, EnumRuneType.AIR); - for (int i = 0; i < 4; i++) - { + for (int i = 0; i < 4; i++) { this.addCornerRunes(components, 3, i, EnumRuneType.EARTH); } @@ -144,8 +122,7 @@ public class RitualUpgradeRemove extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualUpgradeRemove(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualWater.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualWater.java index 9d4dcbc6..c8291570 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualWater.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualWater.java @@ -8,25 +8,21 @@ import net.minecraft.world.World; import java.util.ArrayList; -public class RitualWater extends Ritual -{ +public class RitualWater extends Ritual { public static final String WATER_RANGE = "waterRange"; - public RitualWater() - { + public RitualWater() { super("ritualWater", 0, 500, "ritual." + BloodMagic.MODID + ".waterRitual"); addBlockRange(WATER_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1)); setMaximumVolumeAndDistanceOfRange(WATER_RANGE, 9, 3, 3); } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -36,16 +32,13 @@ public class RitualWater extends Ritual AreaDescriptor waterRange = getBlockRange(WATER_RANGE); - for (BlockPos newPos : waterRange.getContainedPositions(masterRitualStone.getBlockPos())) - { - if (world.isAirBlock(newPos)) - { + for (BlockPos newPos : waterRange.getContainedPositions(masterRitualStone.getBlockPos())) { + if (world.isAirBlock(newPos)) { world.setBlockState(newPos, Blocks.FLOWING_WATER.getDefaultState()); totalEffects++; } - if (totalEffects >= maxEffects) - { + if (totalEffects >= maxEffects) { break; } } @@ -54,20 +47,17 @@ public class RitualWater extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 1; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 25; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addCornerRunes(components, 1, 0, EnumRuneType.WATER); @@ -76,8 +66,7 @@ public class RitualWater extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualWater(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualWellOfSuffering.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualWellOfSuffering.java index 69651ce0..e16184bd 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualWellOfSuffering.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualWellOfSuffering.java @@ -1,16 +1,15 @@ package WayofTime.bloodmagic.ritual; import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.ConfigHandler; import WayofTime.bloodmagic.api.ritual.*; import WayofTime.bloodmagic.api_impl.BloodMagicAPI; import WayofTime.bloodmagic.tile.TileAltar; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.DamageSource; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.DamageSource; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.EntityEntry; import net.minecraftforge.fml.common.registry.EntityRegistry; @@ -18,8 +17,7 @@ import net.minecraftforge.fml.common.registry.EntityRegistry; import java.util.ArrayList; import java.util.List; -public class RitualWellOfSuffering extends Ritual -{ +public class RitualWellOfSuffering extends Ritual { public static final String ALTAR_RANGE = "altar"; public static final String DAMAGE_RANGE = "damage"; @@ -27,8 +25,7 @@ public class RitualWellOfSuffering extends Ritual public BlockPos altarOffsetPos = new BlockPos(0, 0, 0); //TODO: Save! - public RitualWellOfSuffering() - { + public RitualWellOfSuffering() { super("ritualWellOfSuffering", 0, 40000, "ritual." + BloodMagic.MODID + ".wellOfSufferingRitual"); addBlockRange(ALTAR_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-5, -10, -5), 11, 21, 11)); addBlockRange(DAMAGE_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-10, -10, -10), 21)); @@ -38,13 +35,11 @@ public class RitualWellOfSuffering extends Ritual } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); - if (currentEssence < getRefreshCost()) - { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -60,13 +55,10 @@ public class RitualWellOfSuffering extends Ritual AreaDescriptor altarRange = getBlockRange(ALTAR_RANGE); - if (!altarRange.isWithinArea(altarOffsetPos) || !(tile instanceof TileAltar)) - { - for (BlockPos newPos : altarRange.getContainedPositions(pos)) - { + if (!altarRange.isWithinArea(altarOffsetPos) || !(tile instanceof TileAltar)) { + for (BlockPos newPos : altarRange.getContainedPositions(pos)) { TileEntity nextTile = world.getTileEntity(newPos); - if (nextTile instanceof TileAltar) - { + if (nextTile instanceof TileAltar) { tile = nextTile; altarOffsetPos = newPos.subtract(pos); @@ -76,8 +68,7 @@ public class RitualWellOfSuffering extends Ritual } } - if (tile instanceof TileAltar) - { + if (tile instanceof TileAltar) { TileAltar tileAltar = (TileAltar) tile; AreaDescriptor damageRange = getBlockRange(DAMAGE_RANGE); @@ -85,8 +76,7 @@ public class RitualWellOfSuffering extends Ritual List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, range); - for (EntityLivingBase entity : entities) - { + for (EntityLivingBase entity : entities) { EntityEntry entityEntry = EntityRegistry.getEntry(entity.getClass()); if (BloodMagicAPI.INSTANCE.getBlacklist().getSacrifice().contains(entityEntry.getRegistryName())) @@ -97,10 +87,8 @@ public class RitualWellOfSuffering extends Ritual if (lifeEssenceRatio <= 0) continue; - if (entity.isEntityAlive() && !(entity instanceof EntityPlayer)) - { - if (entity.attackEntityFrom(DamageSource.OUT_OF_WORLD, 1)) - { + if (entity.isEntityAlive() && !(entity instanceof EntityPlayer)) { + if (entity.attackEntityFrom(DamageSource.OUT_OF_WORLD, 1)) { if (entity.isChild()) lifeEssenceRatio *= 0.5F; @@ -108,8 +96,7 @@ public class RitualWellOfSuffering extends Ritual totalEffects++; - if (totalEffects >= maxEffects) - { + if (totalEffects >= maxEffects) { break; } } @@ -121,20 +108,17 @@ public class RitualWellOfSuffering extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 25; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 2; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addCornerRunes(components, 1, 0, EnumRuneType.FIRE); @@ -149,8 +133,7 @@ public class RitualWellOfSuffering extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualWellOfSuffering(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualZephyr.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualZephyr.java index 30a252f1..7db7ffea 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualZephyr.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualZephyr.java @@ -1,29 +1,23 @@ package WayofTime.bloodmagic.ritual; -import java.util.ArrayList; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.ritual.*; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.ritual.EnumRuneType; -import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.util.Utils; -public class RitualZephyr extends Ritual -{ +import java.util.ArrayList; +import java.util.List; + +public class RitualZephyr extends Ritual { public static final String ZEPHYR_RANGE = "zephyrRange"; public static final String CHEST_RANGE = "chest"; - public RitualZephyr() - { + public RitualZephyr() { super("ritualZephyr", 0, 1000, "ritual." + BloodMagic.MODID + ".zephyrRitual"); addBlockRange(ZEPHYR_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-5, -5, -5), 11)); addBlockRange(CHEST_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1)); @@ -33,17 +27,14 @@ public class RitualZephyr extends Ritual } @Override - public void performRitual(IMasterRitualStone masterRitualStone) - { + public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); 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()) - { + if (!masterRitualStone.getWorldObj().isRemote && tileInventory != null) { + if (currentEssence < getRefreshCost()) { masterRitualStone.getOwnerNetwork().causeNausea(); return; } @@ -53,10 +44,8 @@ public class RitualZephyr extends Ritual List itemList = world.getEntitiesWithinAABB(EntityItem.class, zephyrRange.getAABB(masterRitualStone.getBlockPos())); int count = 0; - for (EntityItem entityItem : itemList) - { - if (entityItem.isDead) - { + for (EntityItem entityItem : itemList) { + if (entityItem.isDead) { continue; } @@ -64,8 +53,7 @@ public class RitualZephyr extends Ritual int originalAmount = copyStack.getCount(); ItemStack newStack = Utils.insertStackIntoTile(copyStack, tileInventory, EnumFacing.DOWN); - if (!newStack.isEmpty() && newStack.getCount() < originalAmount) - { + if (!newStack.isEmpty() && newStack.getCount() < originalAmount) { count++; if (newStack.isEmpty()) entityItem.setDead(); @@ -73,8 +61,7 @@ public class RitualZephyr extends Ritual entityItem.getItem().setCount(newStack.getCount()); } - if (newStack.isEmpty()) - { + if (newStack.isEmpty()) { entityItem.setDead(); } } @@ -84,20 +71,17 @@ public class RitualZephyr extends Ritual } @Override - public int getRefreshTime() - { + public int getRefreshTime() { return 1; } @Override - public int getRefreshCost() - { + public int getRefreshCost() { return 1; } @Override - public ArrayList getComponents() - { + public ArrayList getComponents() { ArrayList components = new ArrayList(); this.addParallelRunes(components, 2, 0, EnumRuneType.AIR); @@ -108,8 +92,7 @@ public class RitualZephyr extends Ritual } @Override - public Ritual getNewCopy() - { + public Ritual getNewCopy() { return new RitualZephyr(); } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerPlantable.java b/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerPlantable.java index acef5d0a..55512361 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerPlantable.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerPlantable.java @@ -1,9 +1,5 @@ package WayofTime.bloodmagic.ritual.harvest; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; - import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.BlockStack; import WayofTime.bloodmagic.api.iface.IHarvestHandler; @@ -21,6 +17,9 @@ import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.fml.relauncher.ReflectionHelper; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.List; /** @@ -29,10 +28,8 @@ import java.util.List; * Register a new crop for this handler with * {@link HarvestRegistry#registerStandardCrop(Block, int)} */ -public class HarvestHandlerPlantable implements IHarvestHandler -{ - public HarvestHandlerPlantable() - { +public class HarvestHandlerPlantable implements IHarvestHandler { + public HarvestHandlerPlantable() { HarvestRegistry.registerStandardCrop(Blocks.CARROTS, 7); HarvestRegistry.registerStandardCrop(Blocks.WHEAT, 7); HarvestRegistry.registerStandardCrop(Blocks.POTATOES, 7); @@ -57,8 +54,7 @@ public class HarvestHandlerPlantable implements IHarvestHandler } @Override - public boolean harvestAndPlant(World world, BlockPos pos, BlockStack blockStack) - { + public boolean harvestAndPlant(World world, BlockPos pos, BlockStack blockStack) { if (!HarvestRegistry.getStandardCrops().containsKey(blockStack.getBlock())) return false; @@ -70,30 +66,25 @@ public class HarvestHandlerPlantable implements IHarvestHandler List drops = blockStack.getBlock().getDrops(world, pos, blockStack.getState(), 0); boolean foundSeed = false; - for (ItemStack stack : drops) - { + for (ItemStack stack : drops) { if (stack.isEmpty()) continue; - if (stack.getItem() instanceof IPlantable) - { + if (stack.getItem() instanceof IPlantable) { stack.shrink(1); foundSeed = true; break; } } - if (foundSeed) - { + if (foundSeed) { world.setBlockState(pos, blockStack.getBlock().getDefaultState()); world.playEvent(2001, pos, Block.getStateId(blockStack.getState())); - for (ItemStack stack : drops) - { + for (ItemStack stack : drops) { if (stack.isEmpty()) continue; - if (!world.isRemote) - { + if (!world.isRemote) { EntityItem toDrop = new EntityItem(world, pos.getX(), pos.getY() + 0.5, pos.getZ(), stack); world.spawnEntity(toDrop); } @@ -105,8 +96,7 @@ public class HarvestHandlerPlantable implements IHarvestHandler return false; } - private static void addThirdPartyCrop(String modid, String regName, int matureMeta) - { + private static void addThirdPartyCrop(String modid, String regName, int matureMeta) { if (!Loader.isModLoaded(modid)) return; @@ -115,8 +105,7 @@ public class HarvestHandlerPlantable implements IHarvestHandler HarvestRegistry.registerStandardCrop(block, matureMeta); } - private static void addPamCrops() - { + private static void addPamCrops() { if (!Loader.isModLoaded("harvestcraft")) return; @@ -126,7 +115,7 @@ public class HarvestHandlerPlantable implements IHarvestHandler Class registry = ReflectionHelper.getClass(loader, className); Field names = ReflectionHelper.findField(registry, "cropNames"); Method getCrop = registry.getMethod("getCrop", String.class); - for (String name : (String[])names.get(null)) { + for (String name : (String[]) names.get(null)) { BlockCrops crop = (BlockCrops) getCrop.invoke(null, name); HarvestRegistry.registerStandardCrop(crop, crop.getMaxAge()); } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerStem.java b/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerStem.java index 86ebcffe..5454ca0b 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerStem.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerStem.java @@ -23,32 +23,26 @@ import java.util.List; * Register a new crop for this handler with * {@link HarvestRegistry#registerStemCrop(BlockStack, BlockStack)} */ -public class HarvestHandlerStem implements IHarvestHandler -{ - public HarvestHandlerStem() - { +public class HarvestHandlerStem implements IHarvestHandler { + public HarvestHandlerStem() { HarvestRegistry.registerStemCrop(new BlockStack(Blocks.PUMPKIN, OreDictionary.WILDCARD_VALUE), new BlockStack(Blocks.PUMPKIN_STEM, 7)); HarvestRegistry.registerStemCrop(new BlockStack(Blocks.MELON_BLOCK), new BlockStack(Blocks.MELON_STEM, 7)); } @Override - public boolean harvestAndPlant(World world, BlockPos pos, BlockStack blockStack) - { + public boolean harvestAndPlant(World world, BlockPos pos, BlockStack blockStack) { boolean retFlag = false; List drops = new ArrayList(); BlockPos cropPos = pos; - if (HarvestRegistry.getStemCrops().containsKey(blockStack)) - { + if (HarvestRegistry.getStemCrops().containsKey(blockStack)) { EnumFacing cropDir = blockStack.getBlock().getActualState(blockStack.getState(), world, pos).getValue(BlockStem.FACING); - if (cropDir != EnumFacing.UP) - { + if (cropDir != EnumFacing.UP) { cropPos = pos.offset(cropDir); BlockStack probableCrop = BlockStack.getStackFromPos(world, cropPos); BlockStack regCrop = HarvestRegistry.getStemCrops().get(blockStack); - if ((regCrop.getMeta() == OreDictionary.WILDCARD_VALUE && regCrop.getBlock() == probableCrop.getBlock()) || regCrop.equals(probableCrop)) - { + if ((regCrop.getMeta() == OreDictionary.WILDCARD_VALUE && regCrop.getBlock() == probableCrop.getBlock()) || regCrop.equals(probableCrop)) { drops = probableCrop.getBlock().getDrops(world, cropPos, probableCrop.getState(), 0); world.destroyBlock(cropPos, false); retFlag = true; @@ -56,10 +50,8 @@ public class HarvestHandlerStem implements IHarvestHandler } } - if (!world.isRemote) - { - for (ItemStack drop : drops) - { + if (!world.isRemote) { + for (ItemStack drop : drops) { EntityItem item = new EntityItem(world, cropPos.getX(), cropPos.getY() + 0.5, cropPos.getZ(), drop); 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 4325a79b..19f045b3 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerTall.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/harvest/HarvestHandlerTall.java @@ -17,35 +17,28 @@ import java.util.List; * Register a new crop for this handler with * {@link HarvestRegistry#registerTallCrop(BlockStack)} */ -public class HarvestHandlerTall implements IHarvestHandler -{ - public HarvestHandlerTall() - { +public class HarvestHandlerTall implements IHarvestHandler { + public HarvestHandlerTall() { HarvestRegistry.registerTallCrop(new BlockStack(Blocks.REEDS)); HarvestRegistry.registerTallCrop(new BlockStack(Blocks.CACTUS)); } @Override - public boolean harvestAndPlant(World world, BlockPos pos, BlockStack blockStack) - { + public boolean harvestAndPlant(World world, BlockPos pos, BlockStack blockStack) { boolean retFlag = false; List drops = new ArrayList(); - if (HarvestRegistry.getTallCrops().contains(blockStack)) - { + if (HarvestRegistry.getTallCrops().contains(blockStack)) { BlockStack up = BlockStack.getStackFromPos(world, pos.up()); - if (up.equals(blockStack)) - { + if (up.equals(blockStack)) { drops = up.getBlock().getDrops(world, pos.up(), up.getState(), 0); world.destroyBlock(pos.up(), false); retFlag = true; } } - if (!world.isRemote) - { - for (ItemStack drop : drops) - { + if (!world.isRemote) { + for (ItemStack drop : drops) { EntityItem item = new EntityItem(world, pos.getX(), pos.getY() + 0.5, pos.getZ(), drop); world.spawnEntity(item); } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualDay.java b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualDay.java index 810c5d33..ef7523fa 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualDay.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualDay.java @@ -7,16 +7,13 @@ import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -public class ImperfectRitualDay extends ImperfectRitual -{ - public ImperfectRitualDay() - { +public class ImperfectRitualDay extends ImperfectRitual { + public ImperfectRitualDay() { super("day", new BlockStack(Blocks.GOLD_BLOCK), 5000, true, "ritual." + BloodMagic.MODID + ".imperfect.day"); } @Override - public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) - { + public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) { if (!imperfectRitualStone.getRitualWorld().isRemote) imperfectRitualStone.getRitualWorld().setWorldTime((imperfectRitualStone.getRitualWorld().getWorldTime() / 24000) * 24000); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualNight.java b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualNight.java index 6c06d69f..d8d9093c 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualNight.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualNight.java @@ -7,16 +7,13 @@ import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -public class ImperfectRitualNight extends ImperfectRitual -{ - public ImperfectRitualNight() - { +public class ImperfectRitualNight extends ImperfectRitual { + public ImperfectRitualNight() { super("night", new BlockStack(Blocks.LAPIS_BLOCK), 100, true, "ritual." + BloodMagic.MODID + ".imperfect.night"); } @Override - public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) - { + public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) { if (!imperfectRitualStone.getRitualWorld().isRemote) imperfectRitualStone.getRitualWorld().setWorldTime((imperfectRitualStone.getRitualWorld().getWorldTime() / 24000) * 24000 + 13800); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualRain.java b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualRain.java index 92a858bc..243bd5e3 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualRain.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualRain.java @@ -7,23 +7,18 @@ import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -public class ImperfectRitualRain extends ImperfectRitual -{ - public ImperfectRitualRain() - { +public class ImperfectRitualRain extends ImperfectRitual { + public ImperfectRitualRain() { super("rain", new BlockStack(Blocks.WATER), 5000, true, "ritual." + BloodMagic.MODID + ".imperfect.rain"); } @Override - public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) - { - if (!imperfectRitualStone.getRitualWorld().isRemote) - { + public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) { + if (!imperfectRitualStone.getRitualWorld().isRemote) { imperfectRitualStone.getRitualWorld().getWorldInfo().setRaining(true); } - if (imperfectRitualStone.getRitualWorld().isRemote) - { + if (imperfectRitualStone.getRitualWorld().isRemote) { imperfectRitualStone.getRitualWorld().setRainStrength(1.0F); imperfectRitualStone.getRitualWorld().setThunderStrength(1.0F); } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualResistance.java b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualResistance.java index 521cf385..871769f2 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualResistance.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualResistance.java @@ -9,16 +9,13 @@ import net.minecraft.init.Blocks; import net.minecraft.init.MobEffects; import net.minecraft.potion.PotionEffect; -public class ImperfectRitualResistance extends ImperfectRitual -{ - public ImperfectRitualResistance() - { +public class ImperfectRitualResistance extends ImperfectRitual { + public ImperfectRitualResistance() { super("resistance", new BlockStack(Blocks.BEDROCK), 5000, "ritual." + BloodMagic.MODID + ".imperfect.resistance"); } @Override - public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) - { + public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) { player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 1200, 1)); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java index c18a5f17..39bec8d2 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java @@ -10,16 +10,13 @@ import net.minecraft.init.Blocks; import net.minecraft.init.MobEffects; import net.minecraft.potion.PotionEffect; -public class ImperfectRitualZombie extends ImperfectRitual -{ - public ImperfectRitualZombie() - { +public class ImperfectRitualZombie extends ImperfectRitual { + public ImperfectRitualZombie() { super("zombie", new BlockStack(Blocks.COAL_BLOCK), 5000, "ritual." + BloodMagic.MODID + ".imperfect.zombie"); } @Override - public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) - { + public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) { EntityZombie zombie = new EntityZombie(imperfectRitualStone.getRitualWorld()); zombie.setPosition(imperfectRitualStone.getRitualPos().getX() + 0.5, imperfectRitualStone.getRitualPos().getY() + 2.1, imperfectRitualStone.getRitualPos().getZ() + 0.5); zombie.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 2000)); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/portal/LocationsHandler.java b/src/main/java/WayofTime/bloodmagic/ritual/portal/LocationsHandler.java index 7001a118..1a1c0555 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/portal/LocationsHandler.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/portal/LocationsHandler.java @@ -9,48 +9,75 @@ import java.io.*; import java.util.ArrayList; import java.util.HashMap; -public class LocationsHandler implements Serializable -{ +public class LocationsHandler implements Serializable { public static final long serialVersionUID = 10102001; private static final String fileName = String.valueOf(DimensionManager.getCurrentSaveRootDirectory()) + "/" + BloodMagic.MODID + "/PortalLocations.dat"; private static HashMap> portals; private static LocationsHandler locationsHandler; - private LocationsHandler() - { + private LocationsHandler() { portals = new HashMap>(); } - public static LocationsHandler getLocationsHandler() - { - if (locationsHandler == null || loadFile() == null) - { + public boolean addLocation(String name, PortalLocation location) { + ArrayList portalLocations = portals.get(name); + if (portalLocations == null) { + portals.put(name, new ArrayList()); + updateFile(fileName, portals); + } + if (!portals.get(name).isEmpty() && portals.get(name).size() >= 2) { + BloodMagicAPI.logger.info("Location " + name + " already exists."); + updateFile(fileName, portals); + return false; + } else { + portals.get(name).add(location); + BloodMagicAPI.logger.info("Adding " + name); + updateFile(fileName, portals); + return true; + } + } + + public boolean removeLocation(String name, PortalLocation location) { + if (portals.get(name) != null && !portals.get(name).isEmpty()) { + if (portals.get(name).contains(location)) { + portals.get(name).remove(location); + BloodMagicAPI.logger.info("Removing " + name); + updateFile(fileName, portals); + return true; + } else { + BloodMagicAPI.logger.info("No location matching " + name); + updateFile(fileName, portals); + return false; + } + } + return false; + } + + public ArrayList getLinkedLocations(String name) { + return portals.get(name); + } + + public static LocationsHandler getLocationsHandler() { + if (locationsHandler == null || loadFile() == null) { locationsHandler = new LocationsHandler(); return locationsHandler; - } else - { + } else { portals = loadFile(); return locationsHandler; } } - private static HashMap> loadFile() - { + private static HashMap> loadFile() { HashMap> map; File file = new File(fileName); - try - { - if (!file.exists()) - { - if (file.getParentFile().mkdir()) - { - if (file.createNewFile()) - { + try { + if (!file.exists()) { + if (file.getParentFile().mkdir()) { + if (file.createNewFile()) { BloodMagicAPI.logger.info("Creating " + fileName + " in " + String.valueOf(DimensionManager.getCurrentSaveRootDirectory())); } - } else if (file.createNewFile()) - { + } else if (file.createNewFile()) { BloodMagicAPI.logger.info("Creating " + fileName + " in " + String.valueOf(DimensionManager.getCurrentSaveRootDirectory())); } } @@ -60,74 +87,22 @@ public class LocationsHandler implements Serializable in.close(); fileIn.close(); return map; - } catch (IOException e) - { + } catch (IOException e) { return null; - } catch (ClassNotFoundException e) - { + } catch (ClassNotFoundException e) { BloodMagicAPI.logger.error(String.valueOf(file) + " was not found in " + String.valueOf(DimensionManager.getCurrentSaveRootDirectory())); return null; } } - private static void updateFile(String file, HashMap> object) - { - try - { + private static void updateFile(String file, HashMap> object) { + try { FileOutputStream fos = new FileOutputStream(file); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(object); oos.close(); - } catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); } } - - public boolean addLocation(String name, PortalLocation location) - { - ArrayList portalLocations = portals.get(name); - if (portalLocations == null) - { - portals.put(name, new ArrayList()); - updateFile(fileName, portals); - } - if (!portals.get(name).isEmpty() && portals.get(name).size() >= 2) - { - BloodMagicAPI.logger.info("Location " + name + " already exists."); - updateFile(fileName, portals); - return false; - } else - { - portals.get(name).add(location); - BloodMagicAPI.logger.info("Adding " + name); - updateFile(fileName, portals); - return true; - } - } - - public boolean removeLocation(String name, PortalLocation location) - { - if (portals.get(name) != null && !portals.get(name).isEmpty()) - { - if (portals.get(name).contains(location)) - { - portals.get(name).remove(location); - BloodMagicAPI.logger.info("Removing " + name); - updateFile(fileName, portals); - return true; - } else - { - BloodMagicAPI.logger.info("No location matching " + name); - updateFile(fileName, portals); - return false; - } - } - return false; - } - - public ArrayList getLinkedLocations(String name) - { - return portals.get(name); - } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/ritual/portal/Teleports.java b/src/main/java/WayofTime/bloodmagic/ritual/portal/Teleports.java index 8d7ecfe3..b005e751 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/portal/Teleports.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/portal/Teleports.java @@ -20,33 +20,25 @@ import net.minecraft.world.WorldServer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.FMLCommonHandler; -public class Teleports -{ +public class Teleports { - public static class TeleportSameDim extends Teleport - { + public static class TeleportSameDim extends Teleport { private final boolean teleposer; - public TeleportSameDim(int x, int y, int z, Entity entity, String networkToDrain, boolean teleposer) - { + public TeleportSameDim(int x, int y, int z, Entity entity, String networkToDrain, boolean teleposer) { this(new BlockPos(x, y, z), entity, networkToDrain, teleposer); } - public TeleportSameDim(BlockPos blockPos, Entity entity, String networkToDrain, boolean teleposer) - { + public TeleportSameDim(BlockPos blockPos, Entity entity, String networkToDrain, boolean teleposer) { super(blockPos, entity, networkToDrain); this.teleposer = teleposer; } @Override - public void teleport() - { - if (entity != null) - { - if (entity.timeUntilPortal <= 0) - { - if (entity instanceof EntityPlayer) - { + public void teleport() { + if (entity != null) { + if (entity.timeUntilPortal <= 0) { + if (entity instanceof EntityPlayer) { SoulNetwork network = NetworkHelper.getSoulNetwork(networkToDrain); if (network.getCurrentEssence() < getTeleportCost()) return; @@ -67,8 +59,7 @@ public class Teleports 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.getEntityWorld(), entity.getPosition(), entity.getEntityWorld(), new BlockPos(x, y, z))); - } else - { + } else { SoulNetwork network = NetworkHelper.getSoulNetwork(networkToDrain); if (network.getCurrentEssence() < (getTeleportCost() / 10)) return; @@ -94,25 +85,21 @@ public class Teleports } @Override - public int getTeleportCost() - { + public int getTeleportCost() { return 1000; } } - public static class TeleportToDim extends Teleport - { + public static class TeleportToDim extends Teleport { private World oldWorld; private int newWorldID; private boolean teleposer; - public TeleportToDim(int x, int y, int z, Entity entity, String networkToDrain, World oldWorld, int newWorld, boolean teleposer) - { + public TeleportToDim(int x, int y, int z, Entity entity, String networkToDrain, World oldWorld, int newWorld, boolean teleposer) { this(new BlockPos(x, y, z), entity, networkToDrain, oldWorld, newWorld, teleposer); } - public TeleportToDim(BlockPos blockPos, Entity entity, String networkToDrain, World oldWorld, int newWorldID, boolean teleposer) - { + public TeleportToDim(BlockPos blockPos, Entity entity, String networkToDrain, World oldWorld, int newWorldID, boolean teleposer) { super(blockPos, entity, networkToDrain); this.oldWorld = oldWorld; this.newWorldID = newWorldID; @@ -120,22 +107,17 @@ public class Teleports } @Override - public void teleport() - { - if (entity != null) - { - if (entity.timeUntilPortal <= 0) - { + public void teleport() { + if (entity != null) { + if (entity.timeUntilPortal <= 0) { MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); WorldServer oldWorldServer = server.getWorld(entity.dimension); WorldServer newWorldServer = server.getWorld(newWorldID); - if (entity instanceof EntityPlayer) - { + if (entity instanceof EntityPlayer) { EntityPlayerMP player = (EntityPlayerMP) entity; - if (!player.getEntityWorld().isRemote) - { + if (!player.getEntityWorld().isRemote) { SoulNetwork network = NetworkHelper.getSoulNetwork(networkToDrain); if (network.getCurrentEssence() < getTeleportCost()) return; @@ -155,8 +137,7 @@ public class Teleports MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent.Post(entity, entity.getEntityWorld(), entity.getPosition(), newWorldServer, new BlockPos(x, y, z))); } - } else if (!entity.getEntityWorld().isRemote) - { + } else if (!entity.getEntityWorld().isRemote) { SoulNetwork network = NetworkHelper.getSoulNetwork(networkToDrain); if (network.getCurrentEssence() < (getTeleportCost() / 10)) return; @@ -174,8 +155,7 @@ public class Teleports oldWorld.playSound(entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.AMBIENT, 1.0F, 1.0F, false); Entity teleportedEntity = EntityList.createEntityFromNBT(tag, newWorldServer); - if (teleportedEntity != null) - { + if (teleportedEntity != null) { teleportedEntity.setLocationAndAngles(x + 0.5, y + 0.5, z + 0.5, entity.rotationYaw, entity.rotationPitch); teleportedEntity.forceSpawn = true; newWorldServer.spawnEntity(teleportedEntity); @@ -195,8 +175,7 @@ public class Teleports } @Override - public int getTeleportCost() - { + public int getTeleportCost() { return 10000; } diff --git a/src/main/java/WayofTime/bloodmagic/routing/DefaultItemFilter.java b/src/main/java/WayofTime/bloodmagic/routing/DefaultItemFilter.java index b436f7e6..c33f19c9 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/DefaultItemFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/DefaultItemFilter.java @@ -1,43 +1,37 @@ package WayofTime.bloodmagic.routing; -import java.util.List; - +import WayofTime.bloodmagic.util.Utils; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.items.IItemHandler; -import WayofTime.bloodmagic.util.Utils; + +import java.util.List; /** * This particular implementation of IItemFilter allows any item to be drained * from or inputed to the connected inventory. Every stack is accepted here! * We're basically Olive Gardens. - * + * * @author WayofTime - * */ -public class DefaultItemFilter implements IItemFilter -{ +public class DefaultItemFilter implements IItemFilter { protected TileEntity accessedTile; protected IItemHandler itemHandler; /** * Initializes the filter so that it knows what it wants to fulfill. - * - * @param filteredList - * - The list of ItemStacks that the filter is set to. - * @param itemHandler - * - The inventory that is being accessed. This inventory is either - * being pulled from or pushed to. - * @param isFilterOutput - * - Tells the filter what actions to expect. If true, it should be - * initialized as an output filter. If false, it should be - * initialized as an input filter. + * + * @param filteredList - The list of ItemStacks that the filter is set to. + * @param itemHandler - The inventory that is being accessed. This inventory is either + * being pulled from or pushed to. + * @param isFilterOutput - Tells the filter what actions to expect. If true, it should be + * initialized as an output filter. If false, it should be + * initialized as an input filter. */ @Override - public void initializeFilter(List filteredList, TileEntity tile, IItemHandler itemHandler, boolean isFilterOutput) - { + public void initializeFilter(List filteredList, TileEntity tile, IItemHandler itemHandler, boolean isFilterOutput) { this.accessedTile = tile; this.itemHandler = itemHandler; } @@ -46,20 +40,16 @@ public class DefaultItemFilter implements IItemFilter * This method is only called when the output inventory this filter is * managing receives an ItemStack. Should only really be called by the Input * filter via it's transfer method. - * - * @param inputStack - * - The stack to transfer - * + * + * @param inputStack - The stack to transfer * @return - The remainder of the stack after it has been absorbed into the - * inventory. + * inventory. */ @Override - public ItemStack transferStackThroughOutputFilter(ItemStack inputStack) - { + public ItemStack transferStackThroughOutputFilter(ItemStack inputStack) { int allowedAmount = inputStack.getCount(); //This is done to make the migration to a maximum amount transfered a lot easier - if (allowedAmount <= 0) - { + if (allowedAmount <= 0) { return inputStack; } @@ -83,10 +73,8 @@ public class DefaultItemFilter implements IItemFilter * the input inventory to the output inventory. */ @Override - public int transferThroughInputFilter(IItemFilter outputFilter, int maxTransfer) - { - for (int slot = 0; slot < itemHandler.getSlots(); slot++) - { + public int transferThroughInputFilter(IItemFilter outputFilter, int maxTransfer) { + for (int slot = 0; slot < itemHandler.getSlots(); slot++) { ItemStack inputStack = itemHandler.getStackInSlot(slot); if (inputStack.isEmpty() || itemHandler.extractItem(slot, inputStack.getCount(), true).isEmpty())//(accessedInventory instanceof ISidedInventory && !((ISidedInventory) accessedInventory).canExtractItem(slot, inputStack, accessedSide))) { @@ -100,8 +88,7 @@ public class DefaultItemFilter implements IItemFilter ItemStack remainderStack = outputFilter.transferStackThroughOutputFilter(testStack); int changeAmount = allowedAmount - (remainderStack.isEmpty() ? 0 : remainderStack.getCount()); - if (!remainderStack.isEmpty() && remainderStack.getCount() == allowedAmount) - { + if (!remainderStack.isEmpty() && remainderStack.getCount() == allowedAmount) { //Nothing has changed. Moving on! continue; } @@ -119,14 +106,12 @@ public class DefaultItemFilter implements IItemFilter } @Override - public boolean doesStackMatchFilter(ItemStack testStack) - { + public boolean doesStackMatchFilter(ItemStack testStack) { return true; } @Override - public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack) - { + public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack) { return true; } } diff --git a/src/main/java/WayofTime/bloodmagic/routing/IFluidFilter.java b/src/main/java/WayofTime/bloodmagic/routing/IFluidFilter.java index 8d5f138b..d4851334 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/IFluidFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/IFluidFilter.java @@ -1,26 +1,23 @@ package WayofTime.bloodmagic.routing; -import java.util.List; - import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; -public interface IFluidFilter extends IRoutingFilter -{ +import java.util.List; + +public interface IFluidFilter extends IRoutingFilter { void initializeFilter(List filteredList, TileEntity tile, IFluidHandler fluidHandler, boolean isFilterOutput); /** * This method is only called when the output tank this filter is managing * receives an ItemStack. Should only really be called by the Input filter * via it's transfer method. - * - * @param fluidStack - * - The stack to filter - * + * + * @param fluidStack - The stack to filter * @return - The remainder of the stack after it has been absorbed into the - * tank. + * tank. */ FluidStack transferStackThroughOutputFilter(FluidStack fluidStack); diff --git a/src/main/java/WayofTime/bloodmagic/routing/IFluidRoutingNode.java b/src/main/java/WayofTime/bloodmagic/routing/IFluidRoutingNode.java index 4b109eac..97bfdb01 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/IFluidRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/routing/IFluidRoutingNode.java @@ -2,8 +2,7 @@ package WayofTime.bloodmagic.routing; import net.minecraft.util.EnumFacing; -public interface IFluidRoutingNode extends IRoutingNode -{ +public interface IFluidRoutingNode extends IRoutingNode { boolean isTankConnectedToSide(EnumFacing side); int getPriority(EnumFacing side); diff --git a/src/main/java/WayofTime/bloodmagic/routing/IInputFluidRoutingNode.java b/src/main/java/WayofTime/bloodmagic/routing/IInputFluidRoutingNode.java index bd01f34f..8f8e7a6d 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/IInputFluidRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/routing/IInputFluidRoutingNode.java @@ -2,8 +2,7 @@ package WayofTime.bloodmagic.routing; import net.minecraft.util.EnumFacing; -public interface IInputFluidRoutingNode extends IFluidRoutingNode -{ +public interface IInputFluidRoutingNode extends IFluidRoutingNode { boolean isFluidInput(EnumFacing side); IFluidFilter getInputFluidFilterForSide(EnumFacing side); diff --git a/src/main/java/WayofTime/bloodmagic/routing/IInputItemRoutingNode.java b/src/main/java/WayofTime/bloodmagic/routing/IInputItemRoutingNode.java index b61db904..6e833a54 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/IInputItemRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/routing/IInputItemRoutingNode.java @@ -2,8 +2,7 @@ package WayofTime.bloodmagic.routing; import net.minecraft.util.EnumFacing; -public interface IInputItemRoutingNode extends IItemRoutingNode -{ +public interface IInputItemRoutingNode extends IItemRoutingNode { boolean isInput(EnumFacing side); IItemFilter getInputFilterForSide(EnumFacing side); diff --git a/src/main/java/WayofTime/bloodmagic/routing/IItemFilter.java b/src/main/java/WayofTime/bloodmagic/routing/IItemFilter.java index da01785c..443b0d69 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/IItemFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/IItemFilter.java @@ -1,25 +1,22 @@ package WayofTime.bloodmagic.routing; -import java.util.List; - import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.items.IItemHandler; -public interface IItemFilter extends IRoutingFilter -{ +import java.util.List; + +public interface IItemFilter extends IRoutingFilter { void initializeFilter(List filteredList, TileEntity tile, IItemHandler itemHandler, boolean isFilterOutput); /** * This method is only called when the output inventory this filter is * managing receives an ItemStack. Should only really be called by the Input * filter via it's transfer method. - * - * @param inputStack - * - The stack to filter - * + * + * @param inputStack - The stack to filter * @return - The remainder of the stack after it has been absorbed into the - * inventory. + * inventory. */ ItemStack transferStackThroughOutputFilter(ItemStack inputStack); diff --git a/src/main/java/WayofTime/bloodmagic/routing/IItemRoutingNode.java b/src/main/java/WayofTime/bloodmagic/routing/IItemRoutingNode.java index ed56109b..d52126a0 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/IItemRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/routing/IItemRoutingNode.java @@ -2,8 +2,7 @@ package WayofTime.bloodmagic.routing; import net.minecraft.util.EnumFacing; -public interface IItemRoutingNode extends IRoutingNode -{ +public interface IItemRoutingNode extends IRoutingNode { boolean isInventoryConnectedToSide(EnumFacing side); int getPriority(EnumFacing side); diff --git a/src/main/java/WayofTime/bloodmagic/routing/IMasterRoutingNode.java b/src/main/java/WayofTime/bloodmagic/routing/IMasterRoutingNode.java index d3f825b1..dba8ba08 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/IMasterRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/routing/IMasterRoutingNode.java @@ -4,8 +4,7 @@ import net.minecraft.util.math.BlockPos; import java.util.List; -public interface IMasterRoutingNode extends IRoutingNode -{ +public interface IMasterRoutingNode extends IRoutingNode { boolean isConnected(List path, BlockPos nodePos); void addNodeToList(IRoutingNode node); diff --git a/src/main/java/WayofTime/bloodmagic/routing/IOutputFluidRoutingNode.java b/src/main/java/WayofTime/bloodmagic/routing/IOutputFluidRoutingNode.java index 85f49736..08c3ce67 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/IOutputFluidRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/routing/IOutputFluidRoutingNode.java @@ -2,8 +2,7 @@ package WayofTime.bloodmagic.routing; import net.minecraft.util.EnumFacing; -public interface IOutputFluidRoutingNode extends IFluidRoutingNode -{ +public interface IOutputFluidRoutingNode extends IFluidRoutingNode { boolean isFluidOutput(EnumFacing side); IFluidFilter getOutputFluidFilterForSide(EnumFacing side); diff --git a/src/main/java/WayofTime/bloodmagic/routing/IOutputItemRoutingNode.java b/src/main/java/WayofTime/bloodmagic/routing/IOutputItemRoutingNode.java index 091cebd2..819e2813 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/IOutputItemRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/routing/IOutputItemRoutingNode.java @@ -2,8 +2,7 @@ package WayofTime.bloodmagic.routing; import net.minecraft.util.EnumFacing; -public interface IOutputItemRoutingNode extends IItemRoutingNode -{ +public interface IOutputItemRoutingNode extends IItemRoutingNode { boolean isOutput(EnumFacing side); IItemFilter getOutputFilterForSide(EnumFacing side); diff --git a/src/main/java/WayofTime/bloodmagic/routing/IRoutingFilter.java b/src/main/java/WayofTime/bloodmagic/routing/IRoutingFilter.java index 4de55c21..d7413770 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/IRoutingFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/IRoutingFilter.java @@ -1,6 +1,5 @@ package WayofTime.bloodmagic.routing; -public interface IRoutingFilter -{ +public interface IRoutingFilter { } diff --git a/src/main/java/WayofTime/bloodmagic/routing/IRoutingNode.java b/src/main/java/WayofTime/bloodmagic/routing/IRoutingNode.java index 4fe9e038..3498c570 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/IRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/routing/IRoutingNode.java @@ -5,8 +5,7 @@ import net.minecraft.world.World; import java.util.List; -public interface IRoutingNode -{ +public interface IRoutingNode { void connectMasterToRemainingNode(World world, List alreadyChecked, IMasterRoutingNode master); BlockPos getBlockPos(); diff --git a/src/main/java/WayofTime/bloodmagic/routing/IgnoreNBTItemFilter.java b/src/main/java/WayofTime/bloodmagic/routing/IgnoreNBTItemFilter.java index 334959b6..b7ef367d 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/IgnoreNBTItemFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/IgnoreNBTItemFilter.java @@ -2,15 +2,11 @@ package WayofTime.bloodmagic.routing; import net.minecraft.item.ItemStack; -public class IgnoreNBTItemFilter extends TestItemFilter -{ +public class IgnoreNBTItemFilter extends TestItemFilter { @Override - public boolean doesStackMatchFilter(ItemStack testStack) - { - for (ItemStack filterStack : requestList) - { - if (doStacksMatch(filterStack, testStack)) - { + public boolean doesStackMatchFilter(ItemStack testStack) { + for (ItemStack filterStack : requestList) { + if (doStacksMatch(filterStack, testStack)) { return true; } } @@ -19,8 +15,7 @@ public class IgnoreNBTItemFilter extends TestItemFilter } @Override - public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack) - { + public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack) { 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 56eb3644..c414770a 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/ModIdItemFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/ModIdItemFilter.java @@ -5,13 +5,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.registry.ForgeRegistries; -public class ModIdItemFilter extends TestItemFilter -{ +public class ModIdItemFilter extends TestItemFilter { @Override - public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack) - { - if (ItemStack.areItemsEqualIgnoreDurability(filterStack, testStack)) - { + public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack) { + if (ItemStack.areItemsEqualIgnoreDurability(filterStack, testStack)) { String keyId = getModID(filterStack.getItem()); String checkedId = getModID(testStack.getItem()); return keyId.equals(checkedId); @@ -20,8 +17,7 @@ public class ModIdItemFilter extends TestItemFilter return false; } - public String getModID(Item item) - { + public String getModID(Item item) { ResourceLocation resource = ForgeRegistries.ITEMS.getKey(item); return resource.getResourceDomain(); } diff --git a/src/main/java/WayofTime/bloodmagic/routing/NodeHelper.java b/src/main/java/WayofTime/bloodmagic/routing/NodeHelper.java index 82bbc283..bd9ff18a 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/NodeHelper.java +++ b/src/main/java/WayofTime/bloodmagic/routing/NodeHelper.java @@ -4,17 +4,13 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class NodeHelper -{ - public static boolean isNodeConnectionEnabled(World world, IRoutingNode node, BlockPos testPos) - { - if (!node.isConnectionEnabled(testPos)) - { +public class NodeHelper { + public static boolean isNodeConnectionEnabled(World world, IRoutingNode node, BlockPos testPos) { + if (!node.isConnectionEnabled(testPos)) { return false; } TileEntity tile = world.getTileEntity(testPos); - if (!(tile instanceof IRoutingNode)) - { + if (!(tile instanceof IRoutingNode)) { return false; } diff --git a/src/main/java/WayofTime/bloodmagic/routing/OreDictItemFilter.java b/src/main/java/WayofTime/bloodmagic/routing/OreDictItemFilter.java index 2cde4909..812c4cc3 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/OreDictItemFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/OreDictItemFilter.java @@ -3,15 +3,11 @@ package WayofTime.bloodmagic.routing; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -public class OreDictItemFilter extends TestItemFilter -{ +public class OreDictItemFilter extends TestItemFilter { @Override - public boolean doesStackMatchFilter(ItemStack testStack) - { - for (ItemStack filterStack : requestList) - { - if (doStacksMatch(filterStack, testStack)) - { + public boolean doesStackMatchFilter(ItemStack testStack) { + for (ItemStack filterStack : requestList) { + if (doStacksMatch(filterStack, testStack)) { return true; } } @@ -20,22 +16,17 @@ public class OreDictItemFilter extends TestItemFilter } @Override - public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack) - { + public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack) { int[] filterIds = OreDictionary.getOreIDs(filterStack); int[] testIds = OreDictionary.getOreIDs(testStack); - if (filterIds.length <= 0 || testIds.length <= 0) - { + if (filterIds.length <= 0 || testIds.length <= 0) { return false; } - for (int filterId : filterIds) - { - for (int testId : testIds) - { - if (filterId == testId) - { + for (int filterId : filterIds) { + for (int testId : testIds) { + if (filterId == testId) { return true; } } diff --git a/src/main/java/WayofTime/bloodmagic/routing/RoutingFluidFilter.java b/src/main/java/WayofTime/bloodmagic/routing/RoutingFluidFilter.java index b5132798..81c51625 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/RoutingFluidFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/RoutingFluidFilter.java @@ -1,9 +1,5 @@ package WayofTime.bloodmagic.routing; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; @@ -14,55 +10,46 @@ import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidTankProperties; import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; -public class RoutingFluidFilter implements IFluidFilter -{ +public class RoutingFluidFilter implements IFluidFilter { protected List requestList; protected TileEntity accessedTile; protected IFluidHandler fluidHandler; @Override - public void initializeFilter(List filteredList, TileEntity tile, IFluidHandler fluidHandler, boolean isFilterOutput) - { + public void initializeFilter(List filteredList, TileEntity tile, IFluidHandler fluidHandler, boolean isFilterOutput) { this.accessedTile = tile; this.fluidHandler = fluidHandler; - if (isFilterOutput) - { + if (isFilterOutput) { //The requestList contains a list of how much can be extracted. requestList = new ArrayList(); - for (ItemStack filterStack : filteredList) - { + for (ItemStack filterStack : filteredList) { FluidStack fluidFilterStack = getFluidStackFromItemStack(filterStack); - if (fluidFilterStack != null) - { + if (fluidFilterStack != null) { requestList.add(fluidFilterStack); } } IFluidTankProperties[] properties = fluidHandler.getTankProperties(); - for (IFluidTankProperties property : properties) - { + for (IFluidTankProperties property : properties) { FluidStack containedStack = property.getContents(); - if (containedStack != null) - { - for (FluidStack fluidFilterStack : requestList) - { - if (doStacksMatch(fluidFilterStack, containedStack)) - { + if (containedStack != null) { + for (FluidStack fluidFilterStack : requestList) { + if (doStacksMatch(fluidFilterStack, containedStack)) { fluidFilterStack.amount = Math.max(fluidFilterStack.amount - containedStack.amount, 0); } } } } - } else - { + } else { requestList = new ArrayList(); - for (ItemStack filterStack : filteredList) - { + for (ItemStack filterStack : filteredList) { FluidStack fluidFilterStack = getFluidStackFromItemStack(filterStack); - if (fluidFilterStack != null) - { + if (fluidFilterStack != null) { fluidFilterStack.amount *= -1; requestList.add(fluidFilterStack); } @@ -70,15 +57,11 @@ public class RoutingFluidFilter implements IFluidFilter IFluidTankProperties[] properties = fluidHandler.getTankProperties(); - for (IFluidTankProperties property : properties) - { + for (IFluidTankProperties property : properties) { FluidStack containedStack = property.getContents(); - if (containedStack != null) - { - for (FluidStack fluidFilterStack : requestList) - { - if (doStacksMatch(fluidFilterStack, containedStack)) - { + if (containedStack != null) { + for (FluidStack fluidFilterStack : requestList) { + if (doStacksMatch(fluidFilterStack, containedStack)) { fluidFilterStack.amount += containedStack.amount; } } @@ -87,35 +70,20 @@ public class RoutingFluidFilter implements IFluidFilter } } - @Nullable - public static FluidStack getFluidStackFromItemStack(ItemStack inputStack) - { - FluidStack fluidStack = FluidUtil.getFluidContained(inputStack); - if (fluidStack == null) - return null; - - fluidStack.amount = inputStack.getCount(); - return fluidStack; - } - /** * Gives the remainder~ */ @Override - public FluidStack transferStackThroughOutputFilter(FluidStack fluidStack) - { + public FluidStack transferStackThroughOutputFilter(FluidStack fluidStack) { int allowedAmount = 0; - for (FluidStack filterStack : requestList) - { - if (doStacksMatch(filterStack, fluidStack)) - { + for (FluidStack filterStack : requestList) { + if (doStacksMatch(filterStack, fluidStack)) { allowedAmount = Math.min(filterStack.amount, fluidStack.amount); break; } } - if (allowedAmount <= 0) - { + if (allowedAmount <= 0) { return fluidStack; } @@ -124,14 +92,11 @@ public class RoutingFluidFilter implements IFluidFilter copyStack.amount = fluidStack.amount - filledAmount; Iterator itr = requestList.iterator(); - while (itr.hasNext()) - { + while (itr.hasNext()) { FluidStack filterStack = itr.next(); - if (doStacksMatch(filterStack, copyStack)) - { + if (doStacksMatch(filterStack, copyStack)) { filterStack.amount -= filledAmount; - if (filterStack.amount <= 0) - { + if (filterStack.amount <= 0) { itr.remove(); } } @@ -145,13 +110,10 @@ public class RoutingFluidFilter implements IFluidFilter } @Override - public int transferThroughInputFilter(IFluidFilter outputFilter, int maxTransfer) - { - for (FluidStack filterFluidStack : requestList) - { + public int transferThroughInputFilter(IFluidFilter outputFilter, int maxTransfer) { + for (FluidStack filterFluidStack : requestList) { int allowedAmount = Math.min(filterFluidStack.amount, maxTransfer); - if (allowedAmount <= 0) - { + if (allowedAmount <= 0) { continue; } @@ -163,8 +125,7 @@ public class RoutingFluidFilter implements IFluidFilter FluidStack remainderStack = outputFilter.transferStackThroughOutputFilter(drainStack); int drained = remainderStack == null ? copyStack.amount : (copyStack.amount - remainderStack.amount); - if (drained > 0) - { + if (drained > 0) { drainStack.amount = drained; fluidHandler.drain(drainStack, true); @@ -172,14 +133,11 @@ public class RoutingFluidFilter implements IFluidFilter } Iterator itr = requestList.iterator(); - while (itr.hasNext()) - { + while (itr.hasNext()) { FluidStack filterStack = itr.next(); - if (doStacksMatch(filterStack, copyStack)) - { + if (doStacksMatch(filterStack, copyStack)) { filterStack.amount -= drained; - if (filterStack.amount <= 0) - { + if (filterStack.amount <= 0) { itr.remove(); } } @@ -197,12 +155,9 @@ public class RoutingFluidFilter implements IFluidFilter } @Override - public boolean doesStackMatchFilter(FluidStack testStack) - { - for (FluidStack filterStack : requestList) - { - if (doStacksMatch(filterStack, testStack)) - { + public boolean doesStackMatchFilter(FluidStack testStack) { + for (FluidStack filterStack : requestList) { + if (doStacksMatch(filterStack, testStack)) { return true; } } @@ -211,8 +166,17 @@ public class RoutingFluidFilter implements IFluidFilter } @Override - public boolean doStacksMatch(FluidStack filterStack, FluidStack testStack) - { + public boolean doStacksMatch(FluidStack filterStack, FluidStack testStack) { return testStack != null && filterStack.getFluid() == testStack.getFluid(); } + + @Nullable + public static FluidStack getFluidStackFromItemStack(ItemStack inputStack) { + FluidStack fluidStack = FluidUtil.getFluidContained(inputStack); + if (fluidStack == null) + return null; + + fluidStack.amount = inputStack.getCount(); + return fluidStack; + } } diff --git a/src/main/java/WayofTime/bloodmagic/routing/TestItemFilter.java b/src/main/java/WayofTime/bloodmagic/routing/TestItemFilter.java index 4ebd6109..ecf423d7 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/TestItemFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/TestItemFilter.java @@ -1,26 +1,23 @@ package WayofTime.bloodmagic.routing; -import java.util.Iterator; -import java.util.List; - +import WayofTime.bloodmagic.util.Utils; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.items.IItemHandler; -import WayofTime.bloodmagic.util.GhostItemHelper; -import WayofTime.bloodmagic.util.Utils; + +import java.util.Iterator; +import java.util.List; /** * This particular implementation of IItemFilter checks to make sure that a) as * an output filter it will fill until the requested amount and b) as an input * filter it will only syphon until the requested amount. - * + * * @author WayofTime - * */ -public class TestItemFilter implements IItemFilter -{ +public class TestItemFilter implements IItemFilter { /* * This list acts as the way the filter keeps track of its contents. For the * case of an output filter, it holds a list of ItemStacks that needs to be @@ -33,73 +30,56 @@ public class TestItemFilter implements IItemFilter /** * Initializes the filter so that it knows what it wants to fulfill. - * - * @param filteredList - * - The list of ItemStacks that the filter is set to. - * @param tile - * - The inventory that is being accessed. This inventory is either - * being pulled from or pushed to. - * @param itemHandler - * - The item handler - * @param isFilterOutput - * - Tells the filter what actions to expect. If true, it should be - * initialized as an output filter. If false, it should be - * initialized as an input filter. + * + * @param filteredList - The list of ItemStacks that the filter is set to. + * @param tile - The inventory that is being accessed. This inventory is either + * being pulled from or pushed to. + * @param itemHandler - The item handler + * @param isFilterOutput - Tells the filter what actions to expect. If true, it should be + * initialized as an output filter. If false, it should be + * initialized as an input filter. */ @Override - public void initializeFilter(List filteredList, TileEntity tile, IItemHandler itemHandler, boolean isFilterOutput) - { + public void initializeFilter(List filteredList, TileEntity tile, IItemHandler itemHandler, boolean isFilterOutput) { this.accessedTile = tile; this.itemHandler = itemHandler; - if (isFilterOutput) - { + if (isFilterOutput) { requestList = filteredList; - for (int slot = 0; slot < itemHandler.getSlots(); slot++) - { + for (int slot = 0; slot < itemHandler.getSlots(); slot++) { ItemStack checkedStack = itemHandler.getStackInSlot(slot); - if (checkedStack.isEmpty()) - { + if (checkedStack.isEmpty()) { continue; } int stackSize = checkedStack.getCount(); - for (ItemStack filterStack : requestList) - { - if (filterStack.getCount() == 0) - { + for (ItemStack filterStack : requestList) { + if (filterStack.getCount() == 0) { continue; } - if (doStacksMatch(filterStack, checkedStack)) - { + if (doStacksMatch(filterStack, checkedStack)) { filterStack.setCount(Math.max(filterStack.getCount() - stackSize, 0)); } } } - } else - { + } else { requestList = filteredList; - for (ItemStack filterStack : requestList) - { + for (ItemStack filterStack : requestList) { filterStack.setCount(filterStack.getCount() * -1); //Invert the stack size so that } - for (int slot = 0; slot < itemHandler.getSlots(); slot++) - { + for (int slot = 0; slot < itemHandler.getSlots(); slot++) { ItemStack checkedStack = itemHandler.getStackInSlot(slot); - if (checkedStack.isEmpty()) - { + if (checkedStack.isEmpty()) { continue; } int stackSize = checkedStack.getCount(); - for (ItemStack filterStack : filteredList) - { - if (doStacksMatch(filterStack, checkedStack)) - { + for (ItemStack filterStack : filteredList) { + if (doStacksMatch(filterStack, checkedStack)) { filterStack.grow(stackSize); } } @@ -107,11 +87,9 @@ public class TestItemFilter implements IItemFilter } Iterator iterator = requestList.iterator(); - while (iterator.hasNext()) - { + while (iterator.hasNext()) { ItemStack filterStack = iterator.next(); - if (filterStack.isEmpty()) - { + if (filterStack.isEmpty()) { iterator.remove(); } } @@ -121,27 +99,22 @@ public class TestItemFilter implements IItemFilter * This method is only called when the output inventory this filter is * managing receives an ItemStack. Should only really be called by the Input * filter via it's transfer method. - * - * @param inputStack - * - The stack to transfer + * + * @param inputStack - The stack to transfer * @return - The remainder of the stack after it has been absorbed into the - * inventory. + * inventory. */ @Override - public ItemStack transferStackThroughOutputFilter(ItemStack inputStack) - { + public ItemStack transferStackThroughOutputFilter(ItemStack inputStack) { int allowedAmount = 0; - for (ItemStack filterStack : requestList) - { - if (doStacksMatch(filterStack, inputStack)) - { + for (ItemStack filterStack : requestList) { + if (doStacksMatch(filterStack, inputStack)) { allowedAmount = Math.min(filterStack.getCount(), inputStack.getCount()); break; } } - if (allowedAmount <= 0) - { + if (allowedAmount <= 0) { return inputStack; } @@ -154,14 +127,11 @@ public class TestItemFilter implements IItemFilter testStack.shrink(changeAmount); Iterator itr = requestList.iterator(); - while (itr.hasNext()) - { + while (itr.hasNext()) { ItemStack filterStack = itr.next(); - if (doStacksMatch(filterStack, inputStack)) - { + if (doStacksMatch(filterStack, inputStack)) { filterStack.shrink(changeAmount); - if (filterStack.isEmpty()) - { + if (filterStack.isEmpty()) { itr.remove(); } } @@ -179,10 +149,8 @@ public class TestItemFilter implements IItemFilter * the input inventory to the output inventory. */ @Override - public int transferThroughInputFilter(IItemFilter outputFilter, int maxTransfer) - { - for (int slot = 0; slot < itemHandler.getSlots(); slot++) - { + public int transferThroughInputFilter(IItemFilter outputFilter, int maxTransfer) { + for (int slot = 0; slot < itemHandler.getSlots(); slot++) { ItemStack inputStack = itemHandler.getStackInSlot(slot); if (inputStack.isEmpty() || itemHandler.extractItem(slot, inputStack.getCount(), true).isEmpty())//(accessedInventory instanceof ISidedInventory && !((ISidedInventory) accessedInventory).canExtractItem(slot, inputStack, accessedSide))) { @@ -190,17 +158,14 @@ public class TestItemFilter implements IItemFilter } int allowedAmount = 0; - for (ItemStack filterStack : requestList) - { - if (doStacksMatch(filterStack, inputStack)) - { + for (ItemStack filterStack : requestList) { + if (doStacksMatch(filterStack, inputStack)) { allowedAmount = Math.min(maxTransfer, Math.min(filterStack.getCount(), itemHandler.extractItem(slot, inputStack.getCount(), true).getCount())); break; } } - if (allowedAmount <= 0) - { + if (allowedAmount <= 0) { continue; } @@ -209,8 +174,7 @@ public class TestItemFilter implements IItemFilter ItemStack remainderStack = outputFilter.transferStackThroughOutputFilter(testStack); int changeAmount = allowedAmount - (remainderStack.isEmpty() ? 0 : remainderStack.getCount()); - if (!remainderStack.isEmpty() && remainderStack.getCount() == allowedAmount) - { + if (!remainderStack.isEmpty() && remainderStack.getCount() == allowedAmount) { //Nothing has changed. Moving on! continue; } @@ -218,14 +182,11 @@ public class TestItemFilter implements IItemFilter itemHandler.extractItem(slot, changeAmount, false); Iterator itr = requestList.iterator(); - while (itr.hasNext()) - { + while (itr.hasNext()) { ItemStack filterStack = itr.next(); - if (doStacksMatch(filterStack, inputStack)) - { + if (doStacksMatch(filterStack, inputStack)) { filterStack.shrink(changeAmount); - if (filterStack.isEmpty()) - { + if (filterStack.isEmpty()) { itr.remove(); } } @@ -242,12 +203,9 @@ public class TestItemFilter implements IItemFilter } @Override - public boolean doesStackMatchFilter(ItemStack testStack) - { - for (ItemStack filterStack : requestList) - { - if (doStacksMatch(filterStack, testStack)) - { + public boolean doesStackMatchFilter(ItemStack testStack) { + for (ItemStack filterStack : requestList) { + if (doStacksMatch(filterStack, testStack)) { return true; } } @@ -256,8 +214,7 @@ public class TestItemFilter implements IItemFilter } @Override - public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack) - { + public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack) { return Utils.canCombine(filterStack, testStack); } } diff --git a/src/main/java/WayofTime/bloodmagic/structures/BuildTestStructure.java b/src/main/java/WayofTime/bloodmagic/structures/BuildTestStructure.java index 2b18479e..58b52194 100644 --- a/src/main/java/WayofTime/bloodmagic/structures/BuildTestStructure.java +++ b/src/main/java/WayofTime/bloodmagic/structures/BuildTestStructure.java @@ -1,7 +1,5 @@ package WayofTime.bloodmagic.structures; -import java.util.Random; - import WayofTime.bloodmagic.BloodMagic; import net.minecraft.server.MinecraftServer; import net.minecraft.util.Mirror; @@ -13,10 +11,10 @@ import net.minecraft.world.gen.structure.template.PlacementSettings; import net.minecraft.world.gen.structure.template.Template; import net.minecraft.world.gen.structure.template.TemplateManager; -public class BuildTestStructure -{ - public boolean placeStructureAtPosition(Random rand, Rotation baseRotation, WorldServer world, BlockPos pos, int iteration) - { +import java.util.Random; + +public class BuildTestStructure { + public boolean placeStructureAtPosition(Random rand, Rotation baseRotation, WorldServer world, BlockPos pos, int iteration) { if (pos == null) return false; @@ -26,8 +24,7 @@ public class BuildTestStructure ResourceLocation resource = new ResourceLocation(BloodMagic.MODID, "Corridor1"); Template template = templatemanager.getTemplate(minecraftserver, resource); - if (template == null) - { + if (template == null) { System.out.println("Invalid template for location: " + resource); return false; } diff --git a/src/main/java/WayofTime/bloodmagic/structures/Dungeon.java b/src/main/java/WayofTime/bloodmagic/structures/Dungeon.java index 4a00f85c..11209c0c 100644 --- a/src/main/java/WayofTime/bloodmagic/structures/Dungeon.java +++ b/src/main/java/WayofTime/bloodmagic/structures/Dungeon.java @@ -1,30 +1,19 @@ package WayofTime.bloodmagic.structures; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Random; - -import net.minecraft.block.Block; +import WayofTime.bloodmagic.api.ritual.AreaDescriptor; import net.minecraft.util.EnumFacing; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; import net.minecraft.world.WorldServer; import net.minecraft.world.gen.structure.template.PlacementSettings; - import org.apache.commons.lang3.tuple.Pair; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; +import java.util.*; +import java.util.Map.Entry; -public class Dungeon -{ - public static boolean placeStructureAtPosition(Random rand, WorldServer world, BlockPos pos) - { +public class Dungeon { + public static boolean placeStructureAtPosition(Random rand, WorldServer world, BlockPos pos) { long startTime = System.nanoTime(); Map> availableDoorMap = new HashMap>(); //Map of doors. The EnumFacing indicates what way this door faces. @@ -47,27 +36,21 @@ public class Dungeon DungeonRoom room = getRandomRoom(rand); roomMap.put(pos, Pair.of(room, settings.copy())); descriptorList.addAll(room.getAreaDescriptors(settings, pos)); - for (EnumFacing facing : EnumFacing.VALUES) - { - if (availableDoorMap.containsKey(facing)) - { + for (EnumFacing facing : EnumFacing.VALUES) { + if (availableDoorMap.containsKey(facing)) { List doorList = availableDoorMap.get(facing); doorList.addAll(room.getDoorOffsetsForFacing(settings, facing, pos)); - } else - { + } else { List doorList = room.getDoorOffsetsForFacing(settings, facing, pos); availableDoorMap.put(facing, doorList); } } //Initial AreaDescriptors and door positions are initialized. Time for fun! - for (int i = 0; i < 100; i++) - { + for (int i = 0; i < 100; i++) { List facingList = new ArrayList(); - for (Entry> entry : availableDoorMap.entrySet()) - { - if (entry.getValue() != null && !entry.getValue().isEmpty()) - { + for (Entry> entry : availableDoorMap.entrySet()) { + if (entry.getValue() != null && !entry.getValue().isEmpty()) { facingList.add(entry.getKey()); } } @@ -78,8 +61,8 @@ public class Dungeon Pair removedDoor2 = null; BlockPos roomLocation = null; - roomPlacement: for (EnumFacing doorFacing : facingList) - { + roomPlacement: + for (EnumFacing doorFacing : facingList) { EnumFacing oppositeDoorFacing = doorFacing.getOpposite(); List availableDoorList = availableDoorMap.get(doorFacing); //May need to copy here Collections.shuffle(availableDoorList); @@ -88,23 +71,19 @@ public class Dungeon DungeonRoom testingRoom = getRandomRoom(rand); List otherDoorList = testingRoom.getDoorOffsetsForFacing(settings, oppositeDoorFacing, BlockPos.ORIGIN); - if (otherDoorList != null && !otherDoorList.isEmpty()) - { + if (otherDoorList != null && !otherDoorList.isEmpty()) { //See if one of these doors works. Collections.shuffle(otherDoorList); BlockPos testDoor = otherDoorList.get(0); - testDoor: for (BlockPos availableDoor : availableDoorList) - { + testDoor: + for (BlockPos availableDoor : availableDoorList) { //TODO: Test if it fits, then add the doors to the list. roomLocation = availableDoor.subtract(testDoor).add(doorFacing.getDirectionVec()); List descriptors = testingRoom.getAreaDescriptors(settings, roomLocation); - for (AreaDescriptor testDesc : descriptors) - { - for (AreaDescriptor currentDesc : descriptorList) - { - if (testDesc.intersects(currentDesc)) - { + for (AreaDescriptor testDesc : descriptors) { + for (AreaDescriptor currentDesc : descriptorList) { + if (testDesc.intersects(currentDesc)) { break testDoor; } } @@ -124,33 +103,26 @@ public class Dungeon // Collections.shuffle(otherDoorList); } - if (removedDoor1 != null) - { - for (EnumFacing facing : EnumFacing.VALUES) - { - if (availableDoorMap.containsKey(facing)) - { + if (removedDoor1 != null) { + for (EnumFacing facing : EnumFacing.VALUES) { + if (availableDoorMap.containsKey(facing)) { List doorList = availableDoorMap.get(facing); doorList.addAll(room.getDoorOffsetsForFacing(settings, facing, roomLocation)); - } else - { + } else { List doorList = room.getDoorOffsetsForFacing(settings, facing, roomLocation); availableDoorMap.put(facing, doorList); } } EnumFacing face = removedDoor1.getKey(); - if (availableDoorMap.containsKey(face)) - { + if (availableDoorMap.containsKey(face)) { availableDoorMap.get(face).remove(removedDoor1.getRight()); } } - if (removedDoor2 != null) - { + if (removedDoor2 != null) { EnumFacing face = removedDoor2.getKey(); - if (availableDoorMap.containsKey(face)) - { + if (availableDoorMap.containsKey(face)) { availableDoorMap.get(face).remove(removedDoor2.getRight()); } } @@ -162,8 +134,7 @@ public class Dungeon System.out.println("Duration: " + duration + "(ns), " + duration / 1000000 + "(ms)"); //Building what I've got - for (Entry> entry : roomMap.entrySet()) - { + for (Entry> entry : roomMap.entrySet()) { BlockPos placementPos = entry.getKey(); DungeonRoom placedRoom = entry.getValue().getKey(); PlacementSettings placementSettings = entry.getValue().getValue(); @@ -174,8 +145,7 @@ public class Dungeon return false; } - public static DungeonRoom getRandomRoom(Random rand) - { + public static DungeonRoom getRandomRoom(Random rand) { return DungeonRoomRegistry.getRandomDungeonRoom(rand); } } diff --git a/src/main/java/WayofTime/bloodmagic/structures/DungeonRoom.java b/src/main/java/WayofTime/bloodmagic/structures/DungeonRoom.java index ed72b577..d9ab71a6 100644 --- a/src/main/java/WayofTime/bloodmagic/structures/DungeonRoom.java +++ b/src/main/java/WayofTime/bloodmagic/structures/DungeonRoom.java @@ -1,57 +1,46 @@ package WayofTime.bloodmagic.structures; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Random; - +import WayofTime.bloodmagic.api.ritual.AreaDescriptor; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; import net.minecraft.world.gen.structure.template.PlacementSettings; import net.minecraft.world.gen.structure.template.Template; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -public class DungeonRoom -{ +import java.util.*; +import java.util.Map.Entry; + +public class DungeonRoom { public int dungeonWeight = 1; public Map structureMap = new HashMap(); public Map> doorMap = new HashMap>(); //Map of doors. The EnumFacing indicates what way this door faces. public List descriptorList = new ArrayList(); - public DungeonRoom(Map structureMap, Map> doorMap, List descriptorList) - { + public DungeonRoom(Map structureMap, Map> doorMap, List descriptorList) { this.structureMap = structureMap; this.doorMap = doorMap; this.descriptorList = descriptorList; } - public List getAreaDescriptors(PlacementSettings settings, BlockPos offset) - { + public List getAreaDescriptors(PlacementSettings settings, BlockPos offset) { List newList = new ArrayList(); - for (AreaDescriptor desc : descriptorList) - { + for (AreaDescriptor desc : descriptorList) { newList.add(desc.rotateDescriptor(settings).offset(offset)); } return newList; } - public List getDoorOffsetsForFacing(PlacementSettings settings, EnumFacing facing, BlockPos offset) - { + public List getDoorOffsetsForFacing(PlacementSettings settings, EnumFacing facing, BlockPos offset) { List offsetList = new ArrayList(); EnumFacing originalFacing = DungeonUtil.reverseRotate(settings.getMirror(), settings.getRotation(), facing); - if (doorMap.containsKey(originalFacing)) - { + if (doorMap.containsKey(originalFacing)) { List doorList = doorMap.get(originalFacing); - for (BlockPos doorPos : doorList) - { + for (BlockPos doorPos : doorList) { offsetList.add(Template.transformedBlockPos(settings, doorPos).add(offset)); } } @@ -59,10 +48,8 @@ public class DungeonRoom return offsetList; } - public boolean placeStructureAtPosition(Random rand, PlacementSettings settings, WorldServer world, BlockPos pos) - { - for (Entry entry : structureMap.entrySet()) - { + public boolean placeStructureAtPosition(Random rand, PlacementSettings settings, WorldServer world, BlockPos pos) { + for (Entry entry : structureMap.entrySet()) { ResourceLocation location = new ResourceLocation(entry.getKey()); DungeonStructure structure = new DungeonStructure(location); BlockPos offsetPos = Template.transformedBlockPos(settings, entry.getValue()); diff --git a/src/main/java/WayofTime/bloodmagic/structures/DungeonRoomLoader.java b/src/main/java/WayofTime/bloodmagic/structures/DungeonRoomLoader.java index 05ee3546..a8b3038f 100644 --- a/src/main/java/WayofTime/bloodmagic/structures/DungeonRoomLoader.java +++ b/src/main/java/WayofTime/bloodmagic/structures/DungeonRoomLoader.java @@ -1,95 +1,75 @@ package WayofTime.bloodmagic.structures; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.Writer; -import java.net.URL; -import java.util.List; -import java.util.Random; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.gson.Serializers; import com.google.common.base.Charsets; import com.google.common.io.Resources; import com.google.common.reflect.TypeToken; import net.minecraft.util.ResourceLocation; - import org.apache.commons.io.IOUtils; -import WayofTime.bloodmagic.gson.Serializers; +import java.io.*; +import java.net.URL; +import java.util.List; +import java.util.Random; -public class DungeonRoomLoader -{ - public static void saveDungeons() - { - for (DungeonRoom room : DungeonRoomRegistry.dungeonWeightMap.keySet()) - { +public class DungeonRoomLoader { + public static void saveDungeons() { + for (DungeonRoom room : DungeonRoomRegistry.dungeonWeightMap.keySet()) { saveSingleDungeon(room); } } - public static void saveSingleDungeon(DungeonRoom room) - { + public static void saveSingleDungeon(DungeonRoom room) { String json = Serializers.GSON.toJson(room); Writer writer; - try - { + try { File file = new File("config/BloodMagic/schematics"); file.mkdirs(); writer = new FileWriter("config/BloodMagic/schematics/" + new Random().nextInt() + ".json"); writer.write(json); writer.close(); - } catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); } } - public static void loadDungeons() - { - try - { + public static void loadDungeons() { + try { URL schematicURL = DungeonRoomLoader.class.getResource(resLocToResourcePath(new ResourceLocation("bloodmagic:schematics"))); - List schematics = Serializers.GSON.fromJson(Resources.toString(schematicURL, Charsets.UTF_8), new TypeToken>(){}.getType()); - for (String schematicKey : schematics) - { + List schematics = Serializers.GSON.fromJson(Resources.toString(schematicURL, Charsets.UTF_8), new TypeToken>() { + }.getType()); + for (String schematicKey : schematics) { ResourceLocation schematic = new ResourceLocation(schematicKey); URL dungeonURL = DungeonRoomLoader.class.getResource(resLocToResourcePath(schematic)); DungeonRoom dungeonRoom = Serializers.GSON.fromJson(Resources.toString(dungeonURL, Charsets.UTF_8), DungeonRoom.class); DungeonRoomRegistry.registerDungeonRoom(dungeonRoom, Math.max(1, dungeonRoom.dungeonWeight)); } - } catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } } - public static void test() - { + public static void test() { ResourceLocation id = new ResourceLocation(BloodMagic.MODID, "testGson"); String s = id.getResourceDomain(); String s1 = id.getResourcePath(); InputStream inputstream = null; - try - { + try { inputstream = DungeonRoomLoader.class.getResourceAsStream("/assets/" + s + "/schematics/" + s1 + ".nbt"); // this.readTemplateFromStream(s1, inputstream); return; - } catch (Throwable var10) - { + } catch (Throwable var10) { - } finally - { + } finally { IOUtils.closeQuietly(inputstream); } } - public static String resLocToResourcePath(ResourceLocation resourceLocation) - { + public static String resLocToResourcePath(ResourceLocation resourceLocation) { return "/assets/" + resourceLocation.getResourceDomain() + "/schematics/" + resourceLocation.getResourcePath() + ".json"; } } diff --git a/src/main/java/WayofTime/bloodmagic/structures/DungeonRoomRegistry.java b/src/main/java/WayofTime/bloodmagic/structures/DungeonRoomRegistry.java index bfd47d8b..3bd4ab75 100644 --- a/src/main/java/WayofTime/bloodmagic/structures/DungeonRoomRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/structures/DungeonRoomRegistry.java @@ -5,25 +5,20 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Random; -public class DungeonRoomRegistry -{ +public class DungeonRoomRegistry { public static Map dungeonWeightMap = new HashMap(); private static int totalWeight = 0; - public static void registerDungeonRoom(DungeonRoom room, int weight) - { + public static void registerDungeonRoom(DungeonRoom room, int weight) { dungeonWeightMap.put(room, weight); totalWeight += weight; } - public static DungeonRoom getRandomDungeonRoom(Random rand) - { + public static DungeonRoom getRandomDungeonRoom(Random rand) { int wantedWeight = rand.nextInt(totalWeight); - for (Entry entry : dungeonWeightMap.entrySet()) - { + for (Entry entry : dungeonWeightMap.entrySet()) { wantedWeight -= entry.getValue(); - if (wantedWeight < 0) - { + if (wantedWeight < 0) { return entry.getKey(); } } diff --git a/src/main/java/WayofTime/bloodmagic/structures/DungeonStructure.java b/src/main/java/WayofTime/bloodmagic/structures/DungeonStructure.java index 2c3aeeb8..8e06624f 100644 --- a/src/main/java/WayofTime/bloodmagic/structures/DungeonStructure.java +++ b/src/main/java/WayofTime/bloodmagic/structures/DungeonStructure.java @@ -1,7 +1,5 @@ package WayofTime.bloodmagic.structures; -import java.util.Random; - import net.minecraft.server.MinecraftServer; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; @@ -10,17 +8,16 @@ import net.minecraft.world.gen.structure.template.PlacementSettings; import net.minecraft.world.gen.structure.template.Template; import net.minecraft.world.gen.structure.template.TemplateManager; -public class DungeonStructure -{ +import java.util.Random; + +public class DungeonStructure { public ResourceLocation resource; - public DungeonStructure(ResourceLocation resource) - { + public DungeonStructure(ResourceLocation resource) { this.resource = resource; } - public boolean placeStructureAtPosition(Random rand, PlacementSettings settings, WorldServer world, BlockPos pos) - { + public boolean placeStructureAtPosition(Random rand, PlacementSettings settings, WorldServer world, BlockPos pos) { if (pos == null) return false; @@ -29,8 +26,7 @@ public class DungeonStructure Template template = templatemanager.getTemplate(minecraftserver, resource); - if (template == null) - { + if (template == null) { System.out.println("Invalid template for location: " + resource); return false; } @@ -44,8 +40,7 @@ public class DungeonStructure return true; } - public DungeonStructure copy() - { + public DungeonStructure copy() { return new DungeonStructure(resource); } } diff --git a/src/main/java/WayofTime/bloodmagic/structures/DungeonTester.java b/src/main/java/WayofTime/bloodmagic/structures/DungeonTester.java index 2cfcd8f3..70bc4aaf 100644 --- a/src/main/java/WayofTime/bloodmagic/structures/DungeonTester.java +++ b/src/main/java/WayofTime/bloodmagic/structures/DungeonTester.java @@ -1,19 +1,16 @@ package WayofTime.bloodmagic.structures; -import java.util.Random; - import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; -public class DungeonTester -{ - public static void testDungeonGeneration(WorldServer world, BlockPos pos) - { +import java.util.Random; + +public class DungeonTester { + public static void testDungeonGeneration(WorldServer world, BlockPos pos) { } - public static void testDungeonElementWithOutput(WorldServer world, BlockPos pos) - { + public static void testDungeonElementWithOutput(WorldServer world, BlockPos pos) { Dungeon.placeStructureAtPosition(new Random(), world, pos); // ResourceLocation resource = new ResourceLocation(Constants.Mod.MODID, "Corridor1"); // diff --git a/src/main/java/WayofTime/bloodmagic/structures/DungeonUtil.java b/src/main/java/WayofTime/bloodmagic/structures/DungeonUtil.java index a6acf178..9534787e 100644 --- a/src/main/java/WayofTime/bloodmagic/structures/DungeonUtil.java +++ b/src/main/java/WayofTime/bloodmagic/structures/DungeonUtil.java @@ -1,52 +1,43 @@ package WayofTime.bloodmagic.structures; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - import net.minecraft.util.EnumFacing; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.gen.structure.template.PlacementSettings; -public class DungeonUtil -{ - public static EnumFacing rotate(Mirror mirror, Rotation rotation, EnumFacing original) - { +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class DungeonUtil { + public static EnumFacing rotate(Mirror mirror, Rotation rotation, EnumFacing original) { return rotation.rotate(mirror.mirror(original)); } - public static EnumFacing reverseRotate(Mirror mirror, Rotation rotation, EnumFacing original) - { + public static EnumFacing reverseRotate(Mirror mirror, Rotation rotation, EnumFacing original) { return mirror.mirror(getOppositeRotation(rotation).rotate(original)); } - public static EnumFacing getFacingForSettings(PlacementSettings settings, EnumFacing original) - { + public static EnumFacing getFacingForSettings(PlacementSettings settings, EnumFacing original) { return rotate(settings.getMirror(), settings.getRotation(), original); } - public static Rotation getOppositeRotation(Rotation rotation) - { - switch (rotation) - { - case CLOCKWISE_90: - return Rotation.COUNTERCLOCKWISE_90; - case COUNTERCLOCKWISE_90: - return Rotation.CLOCKWISE_90; - default: - return rotation; + public static Rotation getOppositeRotation(Rotation rotation) { + switch (rotation) { + case CLOCKWISE_90: + return Rotation.COUNTERCLOCKWISE_90; + case COUNTERCLOCKWISE_90: + return Rotation.CLOCKWISE_90; + default: + return rotation; } } - public static void addRoom(Map> doorMap, EnumFacing facing, BlockPos offsetPos) - { - if (doorMap.containsKey(facing)) - { + public static void addRoom(Map> doorMap, EnumFacing facing, BlockPos offsetPos) { + if (doorMap.containsKey(facing)) { doorMap.get(facing).add(offsetPos); - } else - { + } else { List doorList = new ArrayList(); doorList.add(offsetPos); doorMap.put(facing, doorList); diff --git a/src/main/java/WayofTime/bloodmagic/structures/ModDungeons.java b/src/main/java/WayofTime/bloodmagic/structures/ModDungeons.java index d7d493b2..469e3abe 100644 --- a/src/main/java/WayofTime/bloodmagic/structures/ModDungeons.java +++ b/src/main/java/WayofTime/bloodmagic/structures/ModDungeons.java @@ -1,9 +1,7 @@ package WayofTime.bloodmagic.structures; -public class ModDungeons -{ - public static void init() - { +public class ModDungeons { + public static void init() { // ResourceLocation resource = new ResourceLocation(Constants.Mod.MODID, "HallChest1"); // // Map structureMap = new HashMap(); diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java b/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java index 70f11cc8..6905948d 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java @@ -1,40 +1,36 @@ package WayofTime.bloodmagic.tile; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; +import WayofTime.bloodmagic.api.iface.IAlchemyArray; +import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; -import WayofTime.bloodmagic.api.iface.IAlchemyArray; -import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry; -public class TileAlchemyArray extends TileInventory implements ITickable, IAlchemyArray -{ +public class TileAlchemyArray extends TileInventory implements ITickable, IAlchemyArray { public boolean isActive = false; public int activeCounter = 0; - public EnumFacing rotation = EnumFacing.HORIZONTALS[0];; + public EnumFacing rotation = EnumFacing.HORIZONTALS[0]; + ; private String key = "empty"; private AlchemyArrayEffect arrayEffect; - public TileAlchemyArray() - { + public TileAlchemyArray() { super(2, "alchemyArray"); } - public void onEntityCollidedWithBlock(IBlockState state, Entity entity) - { - if (arrayEffect != null) - { + public void onEntityCollidedWithBlock(IBlockState state, Entity entity) { + if (arrayEffect != null) { arrayEffect.onEntityCollidedWithBlock(this, getWorld(), pos, state, entity); } } @Override - public void deserialize(NBTTagCompound tagCompound) - { + public void deserialize(NBTTagCompound tagCompound) { super.deserialize(tagCompound); this.isActive = tagCompound.getBoolean("isActive"); this.activeCounter = tagCompound.getInteger("activeCounter"); @@ -43,15 +39,13 @@ public class TileAlchemyArray extends TileInventory implements ITickable, IAlche NBTTagCompound arrayTag = tagCompound.getCompoundTag("arrayTag"); arrayEffect = AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(key); - if (arrayEffect != null) - { + if (arrayEffect != null) { arrayEffect.readFromNBT(arrayTag); } } @Override - public NBTTagCompound serialize(NBTTagCompound tagCompound) - { + public NBTTagCompound serialize(NBTTagCompound tagCompound) { super.serialize(tagCompound); tagCompound.setBoolean("isActive", isActive); tagCompound.setInteger("activeCounter", activeCounter); @@ -59,8 +53,7 @@ public class TileAlchemyArray extends TileInventory implements ITickable, IAlche tagCompound.setInteger(Constants.NBT.DIRECTION, rotation.getHorizontalIndex()); NBTTagCompound arrayTag = new NBTTagCompound(); - if (arrayEffect != null) - { + if (arrayEffect != null) { arrayEffect.writeToNBT(arrayTag); } tagCompound.setTag("arrayTag", arrayTag); @@ -69,19 +62,15 @@ public class TileAlchemyArray extends TileInventory implements ITickable, IAlche } @Override - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 1; } @Override - public void update() - { - if (isActive && attemptCraft()) - { + public void update() { + if (isActive && attemptCraft()) { activeCounter++; - } else - { + } else { isActive = false; activeCounter = 0; arrayEffect = null; @@ -93,49 +82,38 @@ public class TileAlchemyArray extends TileInventory implements ITickable, IAlche * This occurs when the block is destroyed. */ @Override - public void dropItems() - { + public void dropItems() { super.dropItems(); - if (arrayEffect != null) - { + if (arrayEffect != null) { } } - public boolean attemptCraft() - { + public boolean attemptCraft() { AlchemyArrayEffect effect = AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(this.getStackInSlot(0), this.getStackInSlot(1)); - if (effect != null) - { - if (arrayEffect == null) - { + if (effect != null) { + if (arrayEffect == null) { arrayEffect = effect; key = effect.getKey(); - } else - { + } else { String effectKey = effect.getKey(); - if (effectKey.equals(key)) - { + if (effectKey.equals(key)) { //Good! Moving on. - } else - { + } else { //Something has changed, therefore we have to move our stuffs. //TODO: Add an AlchemyArrayEffect.onBreak(); ? arrayEffect = effect; key = effect.getKey(); } } - } else - { + } else { return false; } - if (arrayEffect != null) - { + if (arrayEffect != null) { isActive = true; - if (arrayEffect.update(this, this.activeCounter)) - { + if (arrayEffect.update(this, this.activeCounter)) { this.decrStackSize(0, 1); this.decrStackSize(1, 1); this.getWorld().setBlockToAir(getPos()); diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyTable.java b/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyTable.java index c0d9086e..0290cf78 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyTable.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyTable.java @@ -1,9 +1,13 @@ package WayofTime.bloodmagic.tile; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.orb.BloodOrb; +import WayofTime.bloodmagic.api.orb.IBloodOrb; +import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe; +import WayofTime.bloodmagic.api.registry.AlchemyTableRecipeRegistry; +import WayofTime.bloodmagic.api.saving.SoulNetwork; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; +import com.google.common.base.Strings; import net.minecraft.block.state.IBlockState; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -16,17 +20,11 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.wrapper.SidedInvWrapper; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.saving.SoulNetwork; -import WayofTime.bloodmagic.api.orb.IBloodOrb; -import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe; -import WayofTime.bloodmagic.api.registry.AlchemyTableRecipeRegistry; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -import com.google.common.base.Strings; +import java.util.ArrayList; +import java.util.List; -public class TileAlchemyTable extends TileInventory implements ISidedInventory, ITickable -{ +public class TileAlchemyTable extends TileInventory implements ISidedInventory, ITickable { public static final int orbSlot = 6; public static final int toolSlot = 7; public static final int outputSlot = 8; @@ -37,26 +35,22 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, public int ticksRequired = 1; public BlockPos connectedPos = BlockPos.ORIGIN; - public boolean[] blockedSlots = new boolean[] { false, false, false, false, false, false }; + public boolean[] blockedSlots = new boolean[]{false, false, false, false, false, false}; - public TileAlchemyTable() - { + public TileAlchemyTable() { super(9, "alchemyTable"); } - public void setInitialTableParameters(EnumFacing direction, boolean isSlave, BlockPos connectedPos) - { + public void setInitialTableParameters(EnumFacing direction, boolean isSlave, BlockPos connectedPos) { this.isSlave = isSlave; this.connectedPos = connectedPos; - if (!isSlave) - { + if (!isSlave) { this.direction = direction; } } - public boolean isInvisible() - { + public boolean isInvisible() { return isSlave(); } @@ -64,15 +58,13 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, return !(slot < 6 && slot >= 0) || !blockedSlots[slot]; } - public void toggleInputSlotAccessible(int slot) - { + public void toggleInputSlotAccessible(int slot) { if (slot < 6 && slot >= 0) blockedSlots[slot] = !blockedSlots[slot]; } @Override - public void deserialize(NBTTagCompound tag) - { + public void deserialize(NBTTagCompound tag) { super.deserialize(tag); isSlave = tag.getBoolean("isSlave"); @@ -88,8 +80,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, } @Override - public NBTTagCompound serialize(NBTTagCompound tag) - { + public NBTTagCompound serialize(NBTTagCompound tag) { super.serialize(tag); tag.setBoolean("isSlave", isSlave); @@ -111,19 +102,14 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, @SuppressWarnings("unchecked") @Override - public T getCapability(Capability capability, EnumFacing facing) - { - if (facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) - { - if (this.isSlave()) - { + public T getCapability(Capability capability, EnumFacing facing) { + if (facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + if (this.isSlave()) { TileEntity tile = getWorld().getTileEntity(connectedPos); - if (tile instanceof TileAlchemyTable) - { + if (tile instanceof TileAlchemyTable) { return (T) new SidedInvWrapper((TileAlchemyTable) tile, facing); } - } else - { + } else { return (T) new SidedInvWrapper(this, facing); } } @@ -132,73 +118,58 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, } @Override - public int[] getSlotsForFace(EnumFacing side) - { - switch (side) - { - case DOWN: - return new int[] { outputSlot }; - case UP: - return new int[] { orbSlot, toolSlot }; - default: - return new int[] { 0, 1, 2, 3, 4, 5 }; + public int[] getSlotsForFace(EnumFacing side) { + switch (side) { + case DOWN: + return new int[]{outputSlot}; + case UP: + return new int[]{orbSlot, toolSlot}; + default: + return new int[]{0, 1, 2, 3, 4, 5}; } } @Override - public boolean canInsertItem(int index, ItemStack stack, EnumFacing direction) - { - switch (direction) - { - case DOWN: - return index != outputSlot && index != orbSlot && index != toolSlot; - case UP: - if (index == orbSlot && !stack.isEmpty() && stack.getItem() instanceof IBloodOrb) - { - return true; - } else if (index == toolSlot) - { - return false; //TODO: - } else - { - return true; - } - default: - return getAccessibleInputSlots(direction).contains(index); + public boolean canInsertItem(int index, ItemStack stack, EnumFacing direction) { + switch (direction) { + case DOWN: + return index != outputSlot && index != orbSlot && index != toolSlot; + case UP: + if (index == orbSlot && !stack.isEmpty() && stack.getItem() instanceof IBloodOrb) { + return true; + } else if (index == toolSlot) { + return false; //TODO: + } else { + return true; + } + default: + return getAccessibleInputSlots(direction).contains(index); } } @Override - public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) - { - switch (direction) - { - case DOWN: - return index == outputSlot; - case UP: - if (index == orbSlot && !stack.isEmpty() && stack.getItem() instanceof IBloodOrb) - { - return true; - } else if (index == toolSlot) - { - return true; //TODO: - } else - { - return true; - } - default: - return getAccessibleInputSlots(direction).contains(index); + public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { + switch (direction) { + case DOWN: + return index == outputSlot; + case UP: + if (index == orbSlot && !stack.isEmpty() && stack.getItem() instanceof IBloodOrb) { + return true; + } else if (index == toolSlot) { + return true; //TODO: + } else { + return true; + } + default: + return getAccessibleInputSlots(direction).contains(index); } } - public List getAccessibleInputSlots(EnumFacing direction) - { + public List getAccessibleInputSlots(EnumFacing direction) { List list = new ArrayList(); - for (int i = 0; i < 6; i++) - { - if (isInputSlotAccessible(i)) - { + for (int i = 0; i < 6; i++) { + if (isInputSlotAccessible(i)) { list.add(i); } } @@ -207,19 +178,15 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, } @Override - public void update() - { - if (isSlave()) - { + public void update() { + if (isSlave()) { return; } List inputList = new ArrayList(); - for (int i = 0; i < 6; i++) - { - if (!getStackInSlot(i).isEmpty()) - { + for (int i = 0; i < 6; i++) { + if (!getStackInSlot(i).isEmpty()) { inputList.add(getStackInSlot(i)); } } @@ -227,34 +194,26 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, int tier = getTierOfOrb(); AlchemyTableRecipe recipe = AlchemyTableRecipeRegistry.getMatchingRecipe(inputList, getWorld(), getPos()); - if (recipe != null && (burnTime > 0 || (!getWorld().isRemote && tier >= recipe.getTierRequired() && this.getContainedLp() >= recipe.getLpDrained()))) - { - if (burnTime == 1) - { + if (recipe != null && (burnTime > 0 || (!getWorld().isRemote && tier >= recipe.getTierRequired() && this.getContainedLp() >= recipe.getLpDrained()))) { + if (burnTime == 1) { IBlockState state = getWorld().getBlockState(pos); getWorld().notifyBlockUpdate(getPos(), state, state, 3); } - if (canCraft(inputList, recipe)) - { + if (canCraft(inputList, recipe)) { ticksRequired = recipe.getTicksRequired(); burnTime++; - if (burnTime == ticksRequired) - { - if (!getWorld().isRemote) - { + if (burnTime == ticksRequired) { + if (!getWorld().isRemote) { int requiredLp = recipe.getLpDrained(); - if (requiredLp > 0) - { - if (!getWorld().isRemote) - { + if (requiredLp > 0) { + if (!getWorld().isRemote) { consumeLp(requiredLp); } } - if (!getWorld().isRemote) - { + if (!getWorld().isRemote) { craftItem(inputList, recipe); } } @@ -263,29 +222,23 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, IBlockState state = getWorld().getBlockState(pos); getWorld().notifyBlockUpdate(getPos(), state, state, 3); - } else if (burnTime > ticksRequired + 10) - { + } else if (burnTime > ticksRequired + 10) { burnTime = 0; } - } else - { + } else { burnTime = 0; } - } else - { + } else { burnTime = 0; } } - public double getProgressForGui() - { + public double getProgressForGui() { return ((double) burnTime) / ticksRequired; } - private boolean canCraft(List inputList, AlchemyTableRecipe recipe) - { - if (recipe == null) - { + private boolean canCraft(List inputList, AlchemyTableRecipe recipe) { + if (recipe == null) { return false; } @@ -301,13 +254,10 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, return result <= getInventoryStackLimit() && result <= currentOutputStack.getMaxStackSize(); } - public int getTierOfOrb() - { + public int getTierOfOrb() { ItemStack orbStack = getStackInSlot(orbSlot); - if (!orbStack.isEmpty()) - { - if (orbStack.getItem() instanceof IBloodOrb) - { + if (!orbStack.isEmpty()) { + if (orbStack.getItem() instanceof IBloodOrb) { BloodOrb orb = ((IBloodOrb) orbStack.getItem()).getOrb(orbStack); return orb == null ? 0 : orb.getTier(); } @@ -316,24 +266,19 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, return 0; } - public int getContainedLp() - { + public int getContainedLp() { ItemStack orbStack = getStackInSlot(orbSlot); - if (!orbStack.isEmpty()) - { - if (orbStack.getItem() instanceof IBloodOrb) - { + if (!orbStack.isEmpty()) { + if (orbStack.getItem() instanceof IBloodOrb) { NBTTagCompound itemTag = orbStack.getTagCompound(); - if (itemTag == null) - { + if (itemTag == null) { return 0; } String ownerUUID = itemTag.getString(Constants.NBT.OWNER_UUID); - if (Strings.isNullOrEmpty(ownerUUID)) - { + if (Strings.isNullOrEmpty(ownerUUID)) { return 0; } @@ -346,18 +291,14 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, return 0; } - public void craftItem(List inputList, AlchemyTableRecipe recipe) - { - if (this.canCraft(inputList, recipe)) - { + public void craftItem(List inputList, AlchemyTableRecipe recipe) { + if (this.canCraft(inputList, recipe)) { ItemStack outputStack = recipe.getRecipeOutput(inputList); ItemStack currentOutputStack = getStackInSlot(outputSlot); - if (currentOutputStack.isEmpty()) - { + if (currentOutputStack.isEmpty()) { setInventorySlotContents(outputSlot, outputStack); - } else if (ItemHandlerHelper.canItemStacksStack(outputStack, currentOutputStack)) - { + } else if (ItemHandlerHelper.canItemStacksStack(outputStack, currentOutputStack)) { currentOutputStack.grow(outputStack.getCount()); } @@ -365,16 +306,12 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, } } - public int consumeLp(int requested) - { + public int consumeLp(int requested) { ItemStack orbStack = getStackInSlot(orbSlot); - if (!orbStack.isEmpty()) - { - if (orbStack.getItem() instanceof IBloodOrb) - { - if (NetworkHelper.syphonFromContainer(orbStack, requested)) - { + if (!orbStack.isEmpty()) { + if (orbStack.getItem() instanceof IBloodOrb) { + if (NetworkHelper.syphonFromContainer(orbStack, requested)) { return requested; } } @@ -383,34 +320,19 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, return 0; } - public void consumeInventory(AlchemyTableRecipe recipe) - { + public void consumeInventory(AlchemyTableRecipe recipe) { ItemStack[] input = new ItemStack[6]; - for (int i = 0; i < 6; i++) - { + for (int i = 0; i < 6; i++) { input[i] = getStackInSlot(i); } ItemStack[] result = recipe.getRemainingItems(input); - for (int i = 0; i < 6; i++) - { + for (int i = 0; i < 6; i++) { setInventorySlotContents(i, result[i]); } } - public static int getOrbSlot() { - return orbSlot; - } - - public static int getToolSlot() { - return toolSlot; - } - - public static int getOutputSlot() { - return outputSlot; - } - public EnumFacing getDirection() { return direction; } @@ -434,4 +356,16 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, public boolean[] getBlockedSlots() { return blockedSlots; } + + public static int getOrbSlot() { + return orbSlot; + } + + public static int getToolSlot() { + return toolSlot; + } + + public static int getOutputSlot() { + return outputSlot; + } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileAltar.java b/src/main/java/WayofTime/bloodmagic/tile/TileAltar.java index d1892d27..945c7918 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileAltar.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileAltar.java @@ -1,31 +1,28 @@ package WayofTime.bloodmagic.tile; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - +import WayofTime.bloodmagic.altar.BloodAltar; +import WayofTime.bloodmagic.api.altar.EnumAltarTier; +import WayofTime.bloodmagic.api.altar.IBloodAltar; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; -import WayofTime.bloodmagic.altar.BloodAltar; -import WayofTime.bloodmagic.api.altar.EnumAltarTier; -import WayofTime.bloodmagic.api.altar.IBloodAltar; -public class TileAltar extends TileInventory implements IBloodAltar, ITickable -{ +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class TileAltar extends TileInventory implements IBloodAltar, ITickable { private BloodAltar bloodAltar; - public TileAltar() - { + public TileAltar() { super(1, "altar"); this.bloodAltar = new BloodAltar(this); } @Override - public void deserialize(NBTTagCompound tagCompound) - { + public void deserialize(NBTTagCompound tagCompound) { super.deserialize(tagCompound); NBTTagCompound altarTag = tagCompound.getCompoundTag("bloodAltar"); @@ -34,8 +31,7 @@ public class TileAltar extends TileInventory implements IBloodAltar, ITickable } @Override - public NBTTagCompound serialize(NBTTagCompound tagCompound) - { + public NBTTagCompound serialize(NBTTagCompound tagCompound) { super.serialize(tagCompound); NBTTagCompound altarTag = new NBTTagCompound(); @@ -46,164 +42,136 @@ public class TileAltar extends TileInventory implements IBloodAltar, ITickable } @Override - public void update() - { + public void update() { bloodAltar.update(); } @Override - public void sacrificialDaggerCall(int amount, boolean isSacrifice) - { + public void sacrificialDaggerCall(int amount, boolean isSacrifice) { bloodAltar.sacrificialDaggerCall(amount, isSacrifice); } @Override - public boolean isItemValidForSlot(int slot, ItemStack itemstack) - { + public boolean isItemValidForSlot(int slot, ItemStack itemstack) { return slot == 0; } @Override - public int getCapacity() - { + public int getCapacity() { return bloodAltar.getCapacity(); } @Override - public int getCurrentBlood() - { + public int getCurrentBlood() { return bloodAltar.getCurrentBlood(); } @Override - public EnumAltarTier getTier() - { + public EnumAltarTier getTier() { return bloodAltar.getTier(); } @Override - public int getProgress() - { + public int getProgress() { return bloodAltar.getProgress(); } @Override - public float getSacrificeMultiplier() - { + public float getSacrificeMultiplier() { return bloodAltar.getSacrificeMultiplier(); } @Override - public float getSelfSacrificeMultiplier() - { + public float getSelfSacrificeMultiplier() { return bloodAltar.getSelfSacrificeMultiplier(); } @Override - public float getOrbMultiplier() - { + public float getOrbMultiplier() { return bloodAltar.getOrbMultiplier(); } @Override - public float getDislocationMultiplier() - { + public float getDislocationMultiplier() { return bloodAltar.getDislocationMultiplier(); } @Override - public float getConsumptionMultiplier() - { + public float getConsumptionMultiplier() { return bloodAltar.getConsumptionMultiplier(); } @Override - public float getConsumptionRate() - { + public float getConsumptionRate() { return bloodAltar.getConsumptionRate(); } @Override - public int getLiquidRequired() - { + public int getLiquidRequired() { return bloodAltar.getLiquidRequired(); } @Override - public int getBufferCapacity() - { + public int getBufferCapacity() { return bloodAltar.getBufferCapacity(); } @Override - public void startCycle() - { + public void startCycle() { bloodAltar.startCycle(); } @Override - public void checkTier() - { + public void checkTier() { bloodAltar.checkTier(); } @Override - public void requestPauseAfterCrafting(int cooldown) - { + public void requestPauseAfterCrafting(int cooldown) { bloodAltar.requestPauseAfterCrafting(cooldown); } @Override - public boolean isActive() - { + public boolean isActive() { return bloodAltar.isActive(); } @Override - public int fillMainTank(int amount) - { + public int fillMainTank(int amount) { return bloodAltar.fillMainTank(amount); } @Override - public void setActive() - { + public void setActive() { bloodAltar.setActive(); } @Override - public int getChargingRate() - { + public int getChargingRate() { return bloodAltar.getChargingRate(); } @Override - public int getTotalCharge() - { + public int getTotalCharge() { return bloodAltar.getTotalCharge(); } @Override - public int getChargingFrequency() - { + public int getChargingFrequency() { return bloodAltar.getChargingFrequency(); } - public EnumAltarTier getCurrentTierDisplayed() - { + public EnumAltarTier getCurrentTierDisplayed() { return bloodAltar.getCurrentTierDisplayed(); } - public boolean setCurrentTierDisplayed(EnumAltarTier altarTier) - { + public boolean setCurrentTierDisplayed(EnumAltarTier altarTier) { return bloodAltar.setCurrentTierDisplayed(altarTier); } @Override - public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) - { - if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) - { + public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { + if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return true; } @@ -212,10 +180,8 @@ public class TileAltar extends TileInventory implements IBloodAltar, ITickable @SuppressWarnings("unchecked") @Override - public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) - { - if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) - { + public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { + if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return (T) bloodAltar; } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileBloodTank.java b/src/main/java/WayofTime/bloodmagic/tile/TileBloodTank.java index 0df38b4a..2bf3e98e 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileBloodTank.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileBloodTank.java @@ -9,28 +9,23 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; -public class TileBloodTank extends TileBase -{ +public class TileBloodTank extends TileBase { + public static final int[] CAPACITIES = {16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65336, 131072, 262144, 524288}; public int capacity; protected FluidTank tank; - public static final int[] CAPACITIES = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65336, 131072, 262144, 524288 }; - - public TileBloodTank(int meta) - { + public TileBloodTank(int meta) { capacity = CAPACITIES[meta] * Fluid.BUCKET_VOLUME; tank = new FluidTank(capacity); } - public TileBloodTank() - { + public TileBloodTank() { capacity = CAPACITIES[0] * Fluid.BUCKET_VOLUME; tank = new FluidTank(capacity); } @Override - public void deserialize(NBTTagCompound tagCompound) - { + public void deserialize(NBTTagCompound tagCompound) { super.deserialize(tagCompound); tank.readFromNBT(tagCompound.getCompoundTag(Constants.NBT.TANK)); capacity = tagCompound.getInteger(Constants.NBT.ALTAR_CAPACITY); @@ -38,8 +33,7 @@ public class TileBloodTank extends TileBase } @Override - public NBTTagCompound serialize(NBTTagCompound tagCompound) - { + public NBTTagCompound serialize(NBTTagCompound tagCompound) { super.serialize(tagCompound); if (tank.getFluidAmount() != 0) tagCompound.setTag(Constants.NBT.TANK, tank.writeToNBT(new NBTTagCompound())); @@ -47,45 +41,38 @@ public class TileBloodTank extends TileBase return tagCompound; } - public int getCapacity() - { + public int getCapacity() { return capacity; } - public FluidTank getTank() - { + public FluidTank getTank() { return tank; } - public Fluid getClientRenderFluid() - { + public Fluid getClientRenderFluid() { if (tank != null && tank.getFluid() != null) return tank.getFluid().getFluid(); return null; } - public float getRenderHeight() - { + public float getRenderHeight() { if (tank != null && tank.getFluidAmount() > 0) return (float) tank.getFluidAmount() / (float) getCapacity(); return 0F; } - public int getComparatorOutput() - { + public int getComparatorOutput() { return tank.getFluidAmount() > 0 ? (int) (1 + ((double) tank.getFluidAmount() / (double) tank.getCapacity()) * 14) : 0; } @Override - public boolean hasCapability(Capability capability, EnumFacing facing) - { + public boolean hasCapability(Capability capability, EnumFacing facing) { return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing); } @SuppressWarnings("unchecked") @Override - public T getCapability(Capability capability, EnumFacing facing) - { + public T getCapability(Capability capability, EnumFacing facing) { if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) return (T) tank; return super.getCapability(capability, facing); diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrucible.java b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrucible.java index 0308178f..ac4a0e7b 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrucible.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrucible.java @@ -14,72 +14,55 @@ import net.minecraft.util.ITickable; import java.util.HashMap; import java.util.Map.Entry; -public class TileDemonCrucible extends TileInventory implements ITickable, IDemonWillConduit, ISidedInventory -{ - public HashMap willMap = new HashMap(); //TODO: Change to DemonWillHolder +public class TileDemonCrucible extends TileInventory implements ITickable, IDemonWillConduit, ISidedInventory { public final int maxWill = 100; public final double gemDrainRate = 10; - + public HashMap willMap = new HashMap(); //TODO: Change to DemonWillHolder public int internalCounter = 0; - public TileDemonCrucible() - { + public TileDemonCrucible() { super(1, "demonCrucible"); } @Override - public void update() - { - if (getWorld().isRemote) - { + public void update() { + if (getWorld().isRemote) { return; } internalCounter++; - if (getWorld().isBlockPowered(getPos())) - { + if (getWorld().isBlockPowered(getPos())) { //TODO: Fill the contained gem if it is there. ItemStack stack = this.getStackInSlot(0); - if (stack.getItem() instanceof IDemonWillGem) - { + if (stack.getItem() instanceof IDemonWillGem) { IDemonWillGem gemItem = (IDemonWillGem) stack.getItem(); - for (EnumDemonWillType type : EnumDemonWillType.values()) - { - if (willMap.containsKey(type)) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { + if (willMap.containsKey(type)) { double current = willMap.get(type); double fillAmount = Math.min(gemDrainRate, current); - if (fillAmount > 0) - { + if (fillAmount > 0) { fillAmount = gemItem.fillWill(type, stack, fillAmount, true); - if (willMap.get(type) - fillAmount <= 0) - { + if (willMap.get(type) - fillAmount <= 0) { willMap.remove(type); - } else - { + } else { willMap.put(type, willMap.get(type) - fillAmount); } } } } } - } else - { + } else { ItemStack stack = this.getStackInSlot(0); - if (!stack.isEmpty()) - { - if (stack.getItem() instanceof IDemonWillGem) - { + if (!stack.isEmpty()) { + if (stack.getItem() instanceof IDemonWillGem) { IDemonWillGem gemItem = (IDemonWillGem) stack.getItem(); - for (EnumDemonWillType type : EnumDemonWillType.values()) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { double currentAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); double drainAmount = Math.min(maxWill - currentAmount, gemDrainRate); double filled = WorldDemonWillHandler.fillWillToMaximum(getWorld(), pos, type, drainAmount, maxWill, false); filled = gemItem.drainWill(type, stack, filled, false); - if (filled > 0) - { + if (filled > 0) { filled = gemItem.drainWill(type, stack, filled, true); WorldDemonWillHandler.fillWillToMaximum(getWorld(), pos, type, filled, maxWill, true); } @@ -91,14 +74,11 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo double currentAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); double needed = maxWill - currentAmount; double discreteAmount = willItem.getDiscretization(stack); - if (needed >= discreteAmount) - { + if (needed >= discreteAmount) { double filled = willItem.drainWill(stack, discreteAmount); - if (filled > 0) - { + if (filled > 0) { WorldDemonWillHandler.fillWillToMaximum(getWorld(), pos, type, filled, maxWill, true); - if (stack.getCount() <= 0) - { + if (stack.getCount() <= 0) { this.setInventorySlotContents(0, ItemStack.EMPTY); } } @@ -109,29 +89,24 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo } @Override - public void deserialize(NBTTagCompound tag) - { + public void deserialize(NBTTagCompound tag) { super.deserialize(tag); willMap.clear(); - for (EnumDemonWillType type : EnumDemonWillType.values()) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { double amount = tag.getDouble("EnumWill" + type.getName()); - if (amount > 0) - { + if (amount > 0) { willMap.put(type, amount); } } } @Override - public NBTTagCompound serialize(NBTTagCompound tag) - { + public NBTTagCompound serialize(NBTTagCompound tag) { super.serialize(tag); - for (Entry entry : willMap.entrySet()) - { + for (Entry entry : willMap.entrySet()) { tag.setDouble("EnumWill" + entry.getKey().getName(), entry.getValue()); } return tag; @@ -140,36 +115,29 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo // IDemonWillConduit @Override - public int getWeight() - { + public int getWeight() { return 10; } @Override - public double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill) - { - if (amount <= 0) - { + public double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill) { + if (amount <= 0) { return 0; } - if (!canFill(type)) - { + if (!canFill(type)) { return 0; } - if (!doFill) - { - if (!willMap.containsKey(type)) - { + if (!doFill) { + if (!willMap.containsKey(type)) { return Math.min(maxWill, amount); } return Math.min(maxWill - willMap.get(type), amount); } - if (!willMap.containsKey(type)) - { + if (!willMap.containsKey(type)) { double max = Math.min(maxWill, amount); willMap.put(type, max); @@ -180,12 +148,10 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo double current = willMap.get(type); double filled = maxWill - current; - if (amount < filled) - { + if (amount < filled) { willMap.put(type, current + amount); filled = amount; - } else - { + } else { willMap.put(type, (double) maxWill); } @@ -193,28 +159,22 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo } @Override - public double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain) - { - if (!willMap.containsKey(type)) - { + public double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain) { + if (!willMap.containsKey(type)) { return 0; } double drained = amount; double current = willMap.get(type); - if (current < drained) - { + if (current < drained) { drained = current; } - if (doDrain) - { + if (doDrain) { current -= drained; - if (current <= 0) - { + if (current <= 0) { willMap.remove(type); - } else - { + } else { willMap.put(type, current); } } @@ -223,38 +183,32 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo } @Override - public boolean canFill(EnumDemonWillType type) - { + public boolean canFill(EnumDemonWillType type) { return true; } @Override - public boolean canDrain(EnumDemonWillType type) - { + public boolean canDrain(EnumDemonWillType type) { return true; } @Override - public double getCurrentWill(EnumDemonWillType type) - { + public double getCurrentWill(EnumDemonWillType type) { return willMap.containsKey(type) ? willMap.get(type) : 0; } @Override - public int[] getSlotsForFace(EnumFacing side) - { - return new int[] { 0 }; + public int[] getSlotsForFace(EnumFacing side) { + return new int[]{0}; } @Override - public boolean canInsertItem(int index, ItemStack stack, EnumFacing direction) - { + public boolean canInsertItem(int index, ItemStack stack, EnumFacing direction) { return !stack.isEmpty() && (stack.getItem() instanceof IDemonWillGem || stack.getItem() instanceof IDiscreteDemonWill); } @Override - public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) - { + public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { return true; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java index d442fa49..2cfda269 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java @@ -1,5 +1,9 @@ package WayofTime.bloodmagic.tile; +import WayofTime.bloodmagic.api.soul.DemonWillHolder; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.block.BlockDemonCrystal; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; import WayofTime.bloodmagic.tile.base.TileTicking; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; @@ -7,64 +11,48 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.MathHelper; -import WayofTime.bloodmagic.api.soul.DemonWillHolder; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.block.BlockDemonCrystal; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -public class TileDemonCrystal extends TileTicking -{ - public DemonWillHolder holder = new DemonWillHolder(); - public final int maxWill = 100; - public final double drainRate = 1; +public class TileDemonCrystal extends TileTicking { public static final double sameWillConversionRate = 50; public static final double defaultWillConversionRate = 100; public static final double timeDelayForWrongWill = 0.6; - + public final int maxWill = 100; + public final double drainRate = 1; + public DemonWillHolder holder = new DemonWillHolder(); public double progressToNextCrystal = 0; public int internalCounter = 0; public int crystalCount = 1; public EnumFacing placement = EnumFacing.UP; //Side that this crystal is placed on. - public TileDemonCrystal() - { + public TileDemonCrystal() { this.crystalCount = 1; } @Override - public void onUpdate() - { - if (getWorld().isRemote) - { + public void onUpdate() { + if (getWorld().isRemote) { return; } internalCounter++; - if (internalCounter % 20 == 0 && crystalCount < 7) - { + if (internalCounter % 20 == 0 && crystalCount < 7) { EnumDemonWillType type = EnumDemonWillType.values()[this.getBlockMetadata()]; double value = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); - if (type != EnumDemonWillType.DEFAULT) - { - if (value >= 100) - { + if (type != EnumDemonWillType.DEFAULT) { + if (value >= 100) { double nextProgress = getCrystalGrowthPerSecond(value); progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), type, nextProgress * sameWillConversionRate, true) / sameWillConversionRate; - } else - { + } else { value = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, EnumDemonWillType.DEFAULT); - if (value > 0.5) - { + if (value > 0.5) { double nextProgress = getCrystalGrowthPerSecond(value) * timeDelayForWrongWill; progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), EnumDemonWillType.DEFAULT, nextProgress * defaultWillConversionRate, true) / defaultWillConversionRate; } } - } else - { - if (value > 0.5) - { + } else { + if (value > 0.5) { double nextProgress = getCrystalGrowthPerSecond(value); progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), type, nextProgress * sameWillConversionRate, true) / sameWillConversionRate; } @@ -83,18 +71,15 @@ public class TileDemonCrystal extends TileTicking /** * Encourages the crystal to grow by a large percentage by telling it to * drain will from the aura. - * - * @param willDrain - * The amount of drain that is needed for the crystal to grow - * successfully for the desired amount. Can be more than the base - * amount. + * + * @param willDrain The amount of drain that is needed for the crystal to grow + * successfully for the desired amount. Can be more than the base + * amount. * @param progressPercentage * @return percentage actually grown. */ - public double growCrystalWithWillAmount(double willDrain, double progressPercentage) - { - if (crystalCount >= 7) - { + public double growCrystalWithWillAmount(double willDrain, double progressPercentage) { + if (crystalCount >= 7) { return 0; } @@ -104,8 +89,7 @@ public class TileDemonCrystal extends TileTicking double value = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); double percentDrain = willDrain <= 0 ? 1 : Math.min(1, value / willDrain); - if (percentDrain <= 0) - { + if (percentDrain <= 0) { return 0; } @@ -118,10 +102,8 @@ public class TileDemonCrystal extends TileTicking return percentDrain * progressPercentage; } - public void checkAndGrowCrystal() - { - if (progressToNextCrystal >= 1) - { + public void checkAndGrowCrystal() { + if (progressToNextCrystal >= 1) { progressToNextCrystal--; crystalCount++; IBlockState thisState = getWorld().getBlockState(pos); @@ -130,20 +112,16 @@ public class TileDemonCrystal extends TileTicking } } - public double getMaxWillForCrystal() - { + public double getMaxWillForCrystal() { return 50; } - public boolean dropSingleCrystal() - { - if (!getWorld().isRemote && crystalCount > 1) - { + public boolean dropSingleCrystal() { + if (!getWorld().isRemote && crystalCount > 1) { IBlockState state = getWorld().getBlockState(pos); EnumDemonWillType type = state.getValue(BlockDemonCrystal.TYPE); ItemStack stack = BlockDemonCrystal.getItemStackDropped(type, 1); - if (stack != null) - { + if (stack != null) { crystalCount--; getWorld().spawnEntity(new EntityItem(getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack)); return true; @@ -153,19 +131,16 @@ public class TileDemonCrystal extends TileTicking return false; } - public double getCrystalGrowthPerSecond(double will) - { + public double getCrystalGrowthPerSecond(double will) { return 1.0 / 800 * Math.sqrt(will / 200); } - public int getCrystalCountForRender() - { + public int getCrystalCountForRender() { return MathHelper.clamp(crystalCount - 1, 0, 6); } @Override - public void deserialize(NBTTagCompound tag) - { + public void deserialize(NBTTagCompound tag) { holder.readFromNBT(tag, "Will"); crystalCount = tag.getInteger("crystalCount"); placement = EnumFacing.getFront(tag.getInteger("placement")); @@ -173,8 +148,7 @@ public class TileDemonCrystal extends TileTicking } @Override - public NBTTagCompound serialize(NBTTagCompound tag) - { + public NBTTagCompound serialize(NBTTagCompound tag) { holder.writeToNBT(tag, "Will"); tag.setInteger("crystalCount", crystalCount); tag.setInteger("placement", placement.getIndex()); diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystallizer.java b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystallizer.java index c153f800..78d2424e 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystallizer.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystallizer.java @@ -3,35 +3,30 @@ package WayofTime.bloodmagic.tile; import WayofTime.bloodmagic.api.soul.DemonWillHolder; import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import WayofTime.bloodmagic.api.soul.IDemonWillConduit; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; import WayofTime.bloodmagic.tile.base.TileTicking; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; -public class TileDemonCrystallizer extends TileTicking implements IDemonWillConduit -{ - //The whole purpose of this block is to grow a crystal initially. The acceleration and crystal growing is up to the crystal itself afterwards. - public DemonWillHolder holder = new DemonWillHolder(); +public class TileDemonCrystallizer extends TileTicking implements IDemonWillConduit { public static final int maxWill = 100; public static final double drainRate = 1; - public static final double willToFormCrystal = 99; public static final double totalFormationTime = 1000; + //The whole purpose of this block is to grow a crystal initially. The acceleration and crystal growing is up to the crystal itself afterwards. + public DemonWillHolder holder = new DemonWillHolder(); public double internalCounter = 0; - public TileDemonCrystallizer() - { + public TileDemonCrystallizer() { } @Override - public void onUpdate() - { - if (getWorld().isRemote) - { + public void onUpdate() { + if (getWorld().isRemote) { return; } @@ -40,15 +35,11 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond { EnumDemonWillType highestType = WorldDemonWillHandler.getHighestDemonWillType(getWorld(), pos); double amount = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, highestType); - if (amount >= willToFormCrystal) - { + if (amount >= willToFormCrystal) { internalCounter += getCrystalFormationRate(amount); - if (internalCounter >= totalFormationTime) - { - if (WorldDemonWillHandler.drainWill(getWorld(), getPos(), highestType, willToFormCrystal, false) >= willToFormCrystal) - { - if (highestType == EnumDemonWillType.DEFAULT && formRandomSpecialCrystal(offsetPos) || formCrystal(highestType, offsetPos)) - { + if (internalCounter >= totalFormationTime) { + if (WorldDemonWillHandler.drainWill(getWorld(), getPos(), highestType, willToFormCrystal, false) >= willToFormCrystal) { + if (highestType == EnumDemonWillType.DEFAULT && formRandomSpecialCrystal(offsetPos) || formCrystal(highestType, offsetPos)) { WorldDemonWillHandler.drainWill(getWorld(), getPos(), highestType, willToFormCrystal, true); internalCounter = 0; } @@ -58,12 +49,10 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond } } - public boolean formCrystal(EnumDemonWillType type, BlockPos position) - { + public boolean formCrystal(EnumDemonWillType type, BlockPos position) { getWorld().setBlockState(position, RegistrarBloodMagicBlocks.DEMON_CRYSTAL.getStateFromMeta(type.ordinal())); TileEntity tile = getWorld().getTileEntity(position); - if (tile instanceof TileDemonCrystal) - { + if (tile instanceof TileDemonCrystal) { ((TileDemonCrystal) tile).setPlacement(EnumFacing.UP); return true; } @@ -71,31 +60,26 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond return false; } - public boolean formRandomSpecialCrystal(BlockPos position) - { - if (getWorld().rand.nextDouble() > 0.1) - { + public boolean formRandomSpecialCrystal(BlockPos position) { + if (getWorld().rand.nextDouble() > 0.1) { return formCrystal(EnumDemonWillType.DEFAULT, position); } EnumDemonWillType crystalType = EnumDemonWillType.values()[getWorld().rand.nextInt(EnumDemonWillType.values().length - 1) + 1]; return formCrystal(crystalType, position); } - public double getCrystalFormationRate(double currentWill) - { + public double getCrystalFormationRate(double currentWill) { return 1; } @Override - public void deserialize(NBTTagCompound tag) - { + public void deserialize(NBTTagCompound tag) { holder.readFromNBT(tag, "Will"); internalCounter = tag.getDouble("internalCounter"); } @Override - public NBTTagCompound serialize(NBTTagCompound tag) - { + public NBTTagCompound serialize(NBTTagCompound tag) { holder.writeToNBT(tag, "Will"); tag.setDouble("internalCounter", internalCounter); return tag; @@ -104,26 +88,21 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond // IDemonWillConduit @Override - public int getWeight() - { + public int getWeight() { return 10; } @Override - public double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill) - { - if (amount <= 0) - { + public double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill) { + if (amount <= 0) { return 0; } - if (!canFill(type)) - { + if (!canFill(type)) { return 0; } - if (!doFill) - { + if (!doFill) { return Math.min(maxWill - holder.getWill(type), amount); } @@ -131,17 +110,14 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond } @Override - public double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain) - { + public double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain) { double drained = amount; double current = holder.getWill(type); - if (current < drained) - { + if (current < drained) { drained = current; } - if (doDrain) - { + if (doDrain) { return holder.drainWill(type, amount); } @@ -149,20 +125,17 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond } @Override - public boolean canFill(EnumDemonWillType type) - { + public boolean canFill(EnumDemonWillType type) { return true; } @Override - public boolean canDrain(EnumDemonWillType type) - { + public boolean canDrain(EnumDemonWillType type) { return true; } @Override - public double getCurrentWill(EnumDemonWillType type) - { + public double getCurrentWill(EnumDemonWillType type) { return holder.getWill(type); } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileDemonPylon.java b/src/main/java/WayofTime/bloodmagic/tile/TileDemonPylon.java index 475f73c8..e1e73718 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileDemonPylon.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileDemonPylon.java @@ -9,35 +9,28 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; -public class TileDemonPylon extends TileTicking implements IDemonWillConduit -{ - public DemonWillHolder holder = new DemonWillHolder(); +public class TileDemonPylon extends TileTicking implements IDemonWillConduit { public final int maxWill = 100; public final double drainRate = 1; + public DemonWillHolder holder = new DemonWillHolder(); - public TileDemonPylon() - { + public TileDemonPylon() { } @Override - public void onUpdate() - { - if (getWorld().isRemote) - { + public void onUpdate() { + if (getWorld().isRemote) { return; } - for (EnumDemonWillType type : EnumDemonWillType.values()) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { double currentAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); - for (EnumFacing side : EnumFacing.HORIZONTALS) - { + for (EnumFacing side : EnumFacing.HORIZONTALS) { BlockPos offsetPos = pos.offset(side, 16); double sideAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), offsetPos, type); - if (sideAmount > currentAmount) - { + if (sideAmount > currentAmount) { double drainAmount = Math.min((sideAmount - currentAmount) / 2, drainRate); double drain = WorldDemonWillHandler.drainWill(getWorld(), offsetPos, type, drainAmount, true); WorldDemonWillHandler.fillWill(getWorld(), pos, type, drain, true); @@ -47,14 +40,12 @@ public class TileDemonPylon extends TileTicking implements IDemonWillConduit } @Override - public void deserialize(NBTTagCompound tag) - { + public void deserialize(NBTTagCompound tag) { holder.readFromNBT(tag, "Will"); } @Override - public NBTTagCompound serialize(NBTTagCompound tag) - { + public NBTTagCompound serialize(NBTTagCompound tag) { holder.writeToNBT(tag, "Will"); return tag; } @@ -62,26 +53,21 @@ public class TileDemonPylon extends TileTicking implements IDemonWillConduit // IDemonWillConduit @Override - public int getWeight() - { + public int getWeight() { return 10; } @Override - public double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill) - { - if (amount <= 0) - { + public double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill) { + if (amount <= 0) { return 0; } - if (!canFill(type)) - { + if (!canFill(type)) { return 0; } - if (!doFill) - { + if (!doFill) { return Math.min(maxWill - holder.getWill(type), amount); } @@ -89,17 +75,14 @@ public class TileDemonPylon extends TileTicking implements IDemonWillConduit } @Override - public double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain) - { + public double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain) { double drained = amount; double current = holder.getWill(type); - if (current < drained) - { + if (current < drained) { drained = current; } - if (doDrain) - { + if (doDrain) { return holder.drainWill(type, amount); } @@ -107,20 +90,17 @@ public class TileDemonPylon extends TileTicking implements IDemonWillConduit } @Override - public boolean canFill(EnumDemonWillType type) - { + public boolean canFill(EnumDemonWillType type) { return true; } @Override - public boolean canDrain(EnumDemonWillType type) - { + public boolean canDrain(EnumDemonWillType type) { return true; } @Override - public double getCurrentWill(EnumDemonWillType type) - { + public double getCurrentWill(EnumDemonWillType type) { return holder.getWill(type); } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileDimensionalPortal.java b/src/main/java/WayofTime/bloodmagic/tile/TileDimensionalPortal.java index 83db6385..8fe0d65c 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileDimensionalPortal.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileDimensionalPortal.java @@ -6,15 +6,13 @@ import com.google.common.base.Strings; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; -public class TileDimensionalPortal extends TileBase -{ +public class TileDimensionalPortal extends TileBase { public String portalID = ""; public int masterStoneX; public int masterStoneY; public int masterStoneZ; - public void deserialize(NBTTagCompound tagCompound) - { + public void deserialize(NBTTagCompound tagCompound) { portalID = tagCompound.getString(RitualPortal.PORTAL_ID_TAG); masterStoneX = tagCompound.getInteger("masterStoneX"); @@ -22,8 +20,7 @@ public class TileDimensionalPortal extends TileBase masterStoneZ = tagCompound.getInteger("masterStoneZ"); } - public NBTTagCompound serialize(NBTTagCompound tagCompound) - { + public NBTTagCompound serialize(NBTTagCompound tagCompound) { tagCompound.setString(RitualPortal.PORTAL_ID_TAG, Strings.isNullOrEmpty(portalID) ? "" : portalID); tagCompound.setInteger("masterStoneX", masterStoneX); @@ -32,13 +29,11 @@ public class TileDimensionalPortal extends TileBase return tagCompound; } - public BlockPos getMasterStonePos() - { + public BlockPos getMasterStonePos() { return new BlockPos(masterStoneX, masterStoneY, masterStoneZ); } - public void setMasterStonePos(BlockPos blockPos) - { + public void setMasterStonePos(BlockPos blockPos) { this.masterStoneX = blockPos.getX(); this.masterStoneY = blockPos.getY(); this.masterStoneZ = blockPos.getZ(); diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileImperfectRitualStone.java b/src/main/java/WayofTime/bloodmagic/tile/TileImperfectRitualStone.java index 4d6784cd..ec1fc4b8 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileImperfectRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileImperfectRitualStone.java @@ -11,20 +11,15 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class TileImperfectRitualStone extends TileBase implements IImperfectRitualStone -{ +public class TileImperfectRitualStone extends TileBase implements IImperfectRitualStone { // IImperfectRitualStone @Override - public boolean performRitual(World world, BlockPos pos, ImperfectRitual imperfectRitual, EntityPlayer player) - { - if (imperfectRitual != null && ImperfectRitualRegistry.ritualEnabled(imperfectRitual)) - { - if (!PlayerHelper.isFakePlayer(player) && !world.isRemote) - { + public boolean performRitual(World world, BlockPos pos, ImperfectRitual imperfectRitual, EntityPlayer player) { + if (imperfectRitual != null && ImperfectRitualRegistry.ritualEnabled(imperfectRitual)) { + if (!PlayerHelper.isFakePlayer(player) && !world.isRemote) { NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, imperfectRitual.getActivationCost()); - if (imperfectRitual.onActivate(this, player)) - { + if (imperfectRitual.onActivate(this, player)) { if (imperfectRitual.isLightshow()) getWorld().addWeatherEffect(new EntityLightningBolt(getWorld(), getPos().getX(), getPos().getY() + 2, getPos().getZ(), true)); return true; @@ -38,14 +33,12 @@ public class TileImperfectRitualStone extends TileBase implements IImperfectRitu } @Override - public World getRitualWorld() - { + public World getRitualWorld() { return getWorld(); } @Override - public BlockPos getRitualPos() - { + public BlockPos getRitualPos() { return getPos(); } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java b/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java index 6ebf9778..8f90b289 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java @@ -23,50 +23,41 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -public class TileIncenseAltar extends TileInventory implements ITickable -{ - public AreaDescriptor incenseArea = new AreaDescriptor.Rectangle(new BlockPos(-5, -5, -5), 11); +public class TileIncenseAltar extends TileInventory implements ITickable { public static int maxCheckRange = 5; + public AreaDescriptor incenseArea = new AreaDescriptor.Rectangle(new BlockPos(-5, -5, -5), 11); public Map tranquilityMap = new HashMap(); public double incenseAddition = 0; //Self-sacrifice is multiplied by 1 plus this value. public double tranquility = 0; public int roadDistance = 0; //Number of road blocks laid down - public TileIncenseAltar() - { + public TileIncenseAltar() { super(1, "incenseAltar"); } @Override - public void update() - { + public void update() { AxisAlignedBB aabb = incenseArea.getAABB(getPos()); List playerList = getWorld().getEntitiesWithinAABB(EntityPlayer.class, aabb); - if (playerList.isEmpty()) - { + if (playerList.isEmpty()) { return; } - if (getWorld().getTotalWorldTime() % 100 == 0) - { + if (getWorld().getTotalWorldTime() % 100 == 0) { recheckConstruction(); } boolean hasPerformed = false; - for (EntityPlayer player : playerList) - { - if (PlayerSacrificeHelper.incrementIncense(player, 0, incenseAddition, incenseAddition / 100)) - { + for (EntityPlayer player : playerList) { + if (PlayerSacrificeHelper.incrementIncense(player, 0, incenseAddition, incenseAddition / 100)) { hasPerformed = true; } } - if (hasPerformed) - { - if (getWorld().rand.nextInt(4) == 0 && getWorld() instanceof WorldServer) - { + if (hasPerformed) { + if (getWorld().rand.nextInt(4) == 0 && getWorld() instanceof WorldServer) { 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]); } @@ -74,94 +65,77 @@ public class TileIncenseAltar extends TileInventory implements ITickable } @Override - public void deserialize(NBTTagCompound tag) - { + public void deserialize(NBTTagCompound tag) { super.deserialize(tag); tranquility = tag.getDouble("tranquility"); incenseAddition = tag.getDouble("incenseAddition"); } @Override - public NBTTagCompound serialize(NBTTagCompound tag) - { + public NBTTagCompound serialize(NBTTagCompound tag) { super.serialize(tag); tag.setDouble("tranquility", tranquility); tag.setDouble("incenseAddition", incenseAddition); return tag; } - public void recheckConstruction() - { + public void recheckConstruction() { //TODO: Check the physical construction of the incense altar to determine the maximum length. int maxLength = 11; //Max length of the path. The path starts two blocks away from the center block. int yOffset = 0; Map tranquilityMap = new HashMap(); - for (int currentDistance = 2; currentDistance < currentDistance + maxLength; currentDistance++) - { + for (int currentDistance = 2; currentDistance < currentDistance + maxLength; currentDistance++) { boolean canFormRoad = false; - for (int i = -maxCheckRange + yOffset; i <= maxCheckRange + yOffset; i++) - { + for (int i = -maxCheckRange + yOffset; i <= maxCheckRange + yOffset; i++) { BlockPos verticalPos = pos.add(0, i, 0); canFormRoad = true; - level: for (EnumFacing horizontalFacing : EnumFacing.HORIZONTALS) - { + level: + for (EnumFacing horizontalFacing : EnumFacing.HORIZONTALS) { BlockPos facingOffsetPos = verticalPos.offset(horizontalFacing, currentDistance); - for (int j = -1; j <= 1; j++) - { + for (int j = -1; j <= 1; j++) { BlockPos offsetPos = facingOffsetPos.offset(horizontalFacing.rotateY(), j); IBlockState state = getWorld().getBlockState(offsetPos); Block block = state.getBlock(); - if (!(block instanceof IIncensePath && ((IIncensePath) block).getLevelOfPath(getWorld(), offsetPos, state) >= currentDistance - 2)) - { + if (!(block instanceof IIncensePath && ((IIncensePath) block).getLevelOfPath(getWorld(), offsetPos, state) >= currentDistance - 2)) { canFormRoad = false; break level; } } } - if (canFormRoad) - { + if (canFormRoad) { yOffset = i; break; } } - if (canFormRoad) - { - for (int i = -currentDistance; i <= currentDistance; i++) - { - for (int j = -currentDistance; j <= currentDistance; j++) - { - if (Math.abs(i) != currentDistance && Math.abs(j) != currentDistance) - { + if (canFormRoad) { + for (int i = -currentDistance; i <= currentDistance; i++) { + for (int j = -currentDistance; j <= currentDistance; j++) { + if (Math.abs(i) != currentDistance && Math.abs(j) != currentDistance) { continue; //TODO: Can make this just set j to currentDistance to speed it up. } - for (int y = 0 + yOffset; y <= 2 + yOffset; y++) - { + for (int y = 0 + yOffset; y <= 2 + yOffset; y++) { BlockPos offsetPos = pos.add(i, y, j); IBlockState state = getWorld().getBlockState(offsetPos); Block block = state.getBlock(); TranquilityStack stack = IncenseTranquilityRegistry.getTranquilityOfBlock(getWorld(), offsetPos, block, state); - if (stack != null) - { - if (!tranquilityMap.containsKey(stack.type)) - { + if (stack != null) { + if (!tranquilityMap.containsKey(stack.type)) { tranquilityMap.put(stack.type, stack.value); - } else - { + } else { tranquilityMap.put(stack.type, tranquilityMap.get(stack.type) + stack.value); } } } } } - } else - { + } else { roadDistance = currentDistance - 2; break; } @@ -170,19 +144,16 @@ public class TileIncenseAltar extends TileInventory implements ITickable this.tranquilityMap = tranquilityMap; double totalTranquility = 0; - for (Entry entry : tranquilityMap.entrySet()) - { + for (Entry entry : tranquilityMap.entrySet()) { totalTranquility += entry.getValue(); } - if (totalTranquility < 0) - { + if (totalTranquility < 0) { return; } double appliedTranquility = 0; - for (Entry entry : tranquilityMap.entrySet()) - { + for (Entry entry : tranquilityMap.entrySet()) { appliedTranquility += Math.sqrt(entry.getValue()); } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileInventory.java b/src/main/java/WayofTime/bloodmagic/tile/TileInventory.java index acf47041..11e2edf3 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileInventory.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileInventory.java @@ -1,6 +1,7 @@ package WayofTime.bloodmagic.tile; import WayofTime.bloodmagic.tile.base.TileBase; +import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; @@ -17,29 +18,31 @@ import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.wrapper.InvWrapper; import net.minecraftforge.items.wrapper.SidedInvWrapper; -import WayofTime.bloodmagic.util.helper.TextHelper; -public class TileInventory extends TileBase implements IInventory -{ +public class TileInventory extends TileBase implements IInventory { protected int[] syncedSlots = new int[0]; protected NonNullList inventory; + IItemHandler handlerDown; + IItemHandler handlerUp; + IItemHandler handlerNorth; + IItemHandler handlerSouth; + IItemHandler handlerWest; + IItemHandler handlerEast; private int size; + + // IInventory private String name; - public TileInventory(int size, String name) - { + public TileInventory(int size, String name) { this.inventory = NonNullList.withSize(size, ItemStack.EMPTY); this.size = size; this.name = name; initializeItemHandlers(); } - protected boolean isSyncedSlot(int slot) - { - for (int s : this.syncedSlots) - { - if (s == slot) - { + protected boolean isSyncedSlot(int slot) { + for (int s : this.syncedSlots) { + if (s == slot) { return true; } } @@ -47,21 +50,17 @@ public class TileInventory extends TileBase implements IInventory } @Override - public void deserialize(NBTTagCompound tagCompound) - { + public void deserialize(NBTTagCompound tagCompound) { super.deserialize(tagCompound); NBTTagList tags = tagCompound.getTagList("Items", 10); inventory = NonNullList.withSize(size, ItemStack.EMPTY); - for (int i = 0; i < tags.tagCount(); i++) - { - if (!isSyncedSlot(i)) - { + for (int i = 0; i < tags.tagCount(); i++) { + if (!isSyncedSlot(i)) { NBTTagCompound data = tags.getCompoundTagAt(i); byte j = data.getByte("Slot"); - if (j >= 0 && j < inventory.size()) - { + if (j >= 0 && j < inventory.size()) { inventory.set(j, new ItemStack(data)); // No matter how much an i looks like a j, it is not one. They are drastically different characters and cause drastically different things to happen. Apparently I didn't know this at one point. - TehNut } } @@ -69,15 +68,12 @@ public class TileInventory extends TileBase implements IInventory } @Override - public NBTTagCompound serialize(NBTTagCompound tagCompound) - { + public NBTTagCompound serialize(NBTTagCompound tagCompound) { super.serialize(tagCompound); NBTTagList tags = new NBTTagList(); - for (int i = 0; i < inventory.size(); i++) - { - if ((!inventory.get(i).isEmpty()) && !isSyncedSlot(i)) - { + for (int i = 0; i < inventory.size(); i++) { + if ((!inventory.get(i).isEmpty()) && !isSyncedSlot(i)) { NBTTagCompound data = new NBTTagCompound(); data.setByte("Slot", (byte) i); inventory.get(i).writeToNBT(data); @@ -89,35 +85,27 @@ public class TileInventory extends TileBase implements IInventory return tagCompound; } - public void dropItems() - { + public void dropItems() { InventoryHelper.dropInventoryItems(getWorld(), getPos(), this); } - // IInventory - @Override - public int getSizeInventory() - { + public int getSizeInventory() { return size; } @Override - public ItemStack getStackInSlot(int index) - { + public ItemStack getStackInSlot(int index) { return inventory.get(index); } @Override - public ItemStack decrStackSize(int index, int count) - { - if (!getStackInSlot(index).isEmpty()) - { + public ItemStack decrStackSize(int index, int count) { + if (!getStackInSlot(index).isEmpty()) { if (!getWorld().isRemote) getWorld().notifyBlockUpdate(getPos(), getWorld().getBlockState(getPos()), getWorld().getBlockState(getPos()), 3); - if (getStackInSlot(index).getCount() <= count) - { + if (getStackInSlot(index).getCount() <= count) { ItemStack itemStack = inventory.get(index); inventory.set(index, ItemStack.EMPTY); markDirty(); @@ -133,10 +121,8 @@ public class TileInventory extends TileBase implements IInventory } @Override - public ItemStack removeStackFromSlot(int slot) - { - if (!inventory.get(slot).isEmpty()) - { + public ItemStack removeStackFromSlot(int slot) { + if (!inventory.get(slot).isEmpty()) { ItemStack itemStack = inventory.get(slot); setInventorySlotContents(slot, ItemStack.EMPTY); return itemStack; @@ -145,8 +131,7 @@ public class TileInventory extends TileBase implements IInventory } @Override - public void setInventorySlotContents(int slot, ItemStack stack) - { + public void setInventorySlotContents(int slot, ItemStack stack) { inventory.set(slot, stack); if (!stack.isEmpty() && stack.getCount() > getInventoryStackLimit()) stack.setCount(getInventoryStackLimit()); @@ -156,50 +141,44 @@ public class TileInventory extends TileBase implements IInventory } @Override - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 64; } @Override - public void openInventory(EntityPlayer player) - { + public void openInventory(EntityPlayer player) { } @Override - public void closeInventory(EntityPlayer player) - { + public void closeInventory(EntityPlayer player) { } @Override - public boolean isItemValidForSlot(int index, ItemStack stack) - { + public boolean isItemValidForSlot(int index, ItemStack stack) { return true; } + // IWorldNameable + @Override - public int getField(int id) - { + public int getField(int id) { return 0; } @Override - public void setField(int id, int value) - { + public void setField(int id, int value) { } @Override - public int getFieldCount() - { + public int getFieldCount() { return 0; } @Override - public void clear() - { + public void clear() { this.inventory = NonNullList.withSize(size, ItemStack.EMPTY); } @@ -217,38 +196,30 @@ public class TileInventory extends TileBase implements IInventory return true; } - // IWorldNameable - @Override - public String getName() - { + public String getName() { return TextHelper.localize("tile.bloodmagic." + name + ".name"); } @Override - public boolean hasCustomName() - { + public boolean hasCustomName() { return true; } @Override - public ITextComponent getDisplayName() - { + public ITextComponent getDisplayName() { return new TextComponentString(getName()); } - protected void initializeItemHandlers() - { - if (this instanceof ISidedInventory) - { + protected void initializeItemHandlers() { + if (this instanceof ISidedInventory) { handlerDown = new SidedInvWrapper((ISidedInventory) this, EnumFacing.DOWN); handlerUp = new SidedInvWrapper((ISidedInventory) this, EnumFacing.UP); handlerNorth = new SidedInvWrapper((ISidedInventory) this, EnumFacing.NORTH); handlerSouth = new SidedInvWrapper((ISidedInventory) this, EnumFacing.SOUTH); handlerWest = new SidedInvWrapper((ISidedInventory) this, EnumFacing.WEST); handlerEast = new SidedInvWrapper((ISidedInventory) this, EnumFacing.EAST); - } else - { + } else { handlerDown = new InvWrapper(this); handlerUp = handlerDown; handlerNorth = handlerDown; @@ -258,36 +229,25 @@ public class TileInventory extends TileBase implements IInventory } } - IItemHandler handlerDown; - IItemHandler handlerUp; - IItemHandler handlerNorth; - IItemHandler handlerSouth; - IItemHandler handlerWest; - IItemHandler handlerEast; - @SuppressWarnings("unchecked") @Override - public T getCapability(Capability capability, EnumFacing facing) - { - if (facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) - { - switch (facing) - { - case DOWN: - return (T) handlerDown; - case EAST: - return (T) handlerEast; - case NORTH: - return (T) handlerNorth; - case SOUTH: - return (T) handlerSouth; - case UP: - return (T) handlerUp; - case WEST: - return (T) handlerWest; + public T getCapability(Capability capability, EnumFacing facing) { + if (facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + switch (facing) { + case DOWN: + return (T) handlerDown; + case EAST: + return (T) handlerEast; + case NORTH: + return (T) handlerNorth; + case SOUTH: + return (T) handlerSouth; + case UP: + return (T) handlerUp; + case WEST: + return (T) handlerWest; } - } else if (facing == null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) - { + } else if (facing == null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return (T) handlerDown; } @@ -295,8 +255,7 @@ public class TileInventory extends TileBase implements IInventory } @Override - public boolean hasCapability(Capability capability, EnumFacing facing) - { + public boolean hasCapability(Capability capability, EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileInversionPillar.java b/src/main/java/WayofTime/bloodmagic/tile/TileInversionPillar.java index fb578023..7ba2a285 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileInversionPillar.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileInversionPillar.java @@ -1,9 +1,13 @@ package WayofTime.bloodmagic.tile; -import java.util.Collections; -import java.util.List; -import java.util.Locale; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; +import WayofTime.bloodmagic.inversion.InversionPillarHandler; +import WayofTime.bloodmagic.tile.base.TileTicking; +import com.google.common.collect.ImmutableMap; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -19,18 +23,13 @@ import net.minecraftforge.common.animation.TimeValues.VariableValue; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.model.animation.CapabilityAnimation; import net.minecraftforge.common.model.animation.IAnimationStateMachine; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -import WayofTime.bloodmagic.inversion.InversionPillarHandler; -import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; -import WayofTime.bloodmagic.tile.base.TileTicking; -import com.google.common.collect.ImmutableMap; +import java.util.Collections; +import java.util.List; +import java.util.Locale; -public class TileInversionPillar extends TileTicking -{ +public class TileInversionPillar extends TileTicking { + public static final double maxWillForChunk = 1000; public static double willPerOperation = 0.5; public static double inversionPerOperation = 4; public static double addedInversionPerFailedCheck = 1; @@ -41,9 +40,7 @@ public class TileInversionPillar extends TileTicking public static double willPushRate = 1; public static double inversionCostPerWillSpread = 4; public static double minimumWillForChunkWhenSpreading = 100; - private final IAnimationStateMachine asm; - private float animationOffsetValue = 0; private final VariableValue animationOffset = new VariableValue(0); private final VariableValue cycleLength = new VariableValue(4); @@ -58,45 +55,37 @@ public class TileInversionPillar extends TileTicking public int counter = 0; public boolean isRegistered = false; + private float animationOffsetValue = 0; - public static final double maxWillForChunk = 1000; - - public TileInversionPillar() - { + public TileInversionPillar() { this(EnumDemonWillType.DEFAULT); } - public TileInversionPillar(EnumDemonWillType type) - { + public TileInversionPillar(EnumDemonWillType type) { this.type = type; asm = BloodMagic.proxy.load(new ResourceLocation(BloodMagic.MODID.toLowerCase(), "asms/block/inversion_pillar.json"), ImmutableMap.of("offset", animationOffset, "cycle_length", cycleLength)); animationOffsetValue = -1; } @Override - public void onUpdate() - { - if (animationOffsetValue < 0) - { + public void onUpdate() { + if (animationOffsetValue < 0) { animationOffsetValue = getWorld().getTotalWorldTime() * getWorld().rand.nextFloat(); animationOffset.setValue(animationOffsetValue); } - if (getWorld().isRemote) - { + if (getWorld().isRemote) { return; } - if (!isRegistered) - { + if (!isRegistered) { isRegistered = InversionPillarHandler.addPillarToMap(getWorld(), getType(), getPos()); } counter++; double currentWill = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); - if (counter % 1 == 0) - { + if (counter % 1 == 0) { List pillarList = getNearbyPillarsExcludingThis(); // if (type == EnumDemonWillType.VENGEFUL) // { @@ -105,33 +94,27 @@ public class TileInversionPillar extends TileTicking generateWillForNearbyPillars(currentWill, pillarList); generateInversionForNearbyPillars(currentWill, pillarList); int pollute = polluteNearbyBlocks(currentWill); - if (pollute == 1) - { + if (pollute == 1) { currentInversion += addedInversionPerFailedCheck; consecutiveFailedChecks++; - } else if (pollute == 3) - { + } else if (pollute == 3) { currentInversion += addedInversionPerFailedCheck; consecutiveFailedAirChecks++; - } else if (pollute == 0) - { + } else if (pollute == 0) { //We successfully found a block to replace! consecutiveFailedChecks = 0; consecutiveFailedAirChecks = 0; } - if (consecutiveFailedAirChecks > 100) - { + if (consecutiveFailedAirChecks > 100) { createObstructionsInAir(); } - if (currentInversion >= inversionToSpreadWill) - { + if (currentInversion >= inversionToSpreadWill) { spreadWillToSurroundingChunks(); } - if (consecutiveFailedChecks > 5 * currentInfectionRadius && currentInversion >= inversionToIncreaseRadius) - { + if (consecutiveFailedChecks > 5 * currentInfectionRadius && currentInversion >= inversionToIncreaseRadius) { currentInfectionRadius++; consecutiveFailedChecks = 0; currentInversion -= inversionToIncreaseRadius; @@ -144,13 +127,11 @@ public class TileInversionPillar extends TileTicking System.out.println("Increasing radius due to being in the air!"); } - if (currentInfectionRadius >= 8 && currentInversion >= inversionToAddPillar) - { + if (currentInfectionRadius >= 8 && currentInversion >= inversionToAddPillar) { //TODO: Improve algorithm List allConnectedPos = InversionPillarHandler.getAllConnectedPillars(getWorld(), type, pos); BlockPos candidatePos = findCandidatePositionForPillar(getWorld(), type, pos, allConnectedPos, 5, 10); - if (!candidatePos.equals(BlockPos.ORIGIN)) - { + if (!candidatePos.equals(BlockPos.ORIGIN)) { currentInversion = 0; IBlockState pillarState = RegistrarBloodMagicBlocks.INVERSION_PILLAR.getStateFromMeta(type.ordinal()); IBlockState bottomState = RegistrarBloodMagicBlocks.INVERSION_PILLAR_END.getStateFromMeta(type.ordinal() * 2); @@ -168,10 +149,8 @@ public class TileInversionPillar extends TileTicking // return 0; // } - public void createObstructionsInAir() - { - if (currentInversion > 1000) - { + public void createObstructionsInAir() { + if (currentInversion > 1000) { 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.x, vec.y, vec.z); @@ -181,72 +160,18 @@ public class TileInversionPillar extends TileTicking } } - public static BlockPos findCandidatePositionForPillar(World world, EnumDemonWillType type, BlockPos pos, List posList, double tooCloseDistance, double wantedAverageDistance) - { - int maxIterations = 100; - int heightCheckRange = 3; - - for (int i = 0; i < maxIterations; i++) - { - Collections.shuffle(posList); - BlockPos pillarPos = posList.get(0); - - Vec3d vec = new Vec3d(world.rand.nextDouble() * 2 - 1, world.rand.nextDouble() * 2 - 1, world.rand.nextDouble() * 2 - 1).normalize().scale(wantedAverageDistance); - - BlockPos centralPos = pillarPos.add(vec.x, vec.y, vec.z); - BlockPos testPos = null; - candidateTest: for (int h = 0; h <= heightCheckRange; h++) - { - for (int sig = -1; sig <= 1; sig += (h > 0 ? 2 : 3)) - { - BlockPos candidatePos = centralPos.add(0, sig * h, 0); - if (world.isAirBlock(candidatePos) && world.isAirBlock(candidatePos.up()) && world.isAirBlock(candidatePos.down()) && !world.isAirBlock(candidatePos.down(2))) - { - testPos = candidatePos; - break candidateTest; - } - } - } - - if (testPos != null) - { - boolean isValid = true; - for (BlockPos pillarTestPos : posList) - { - if (pillarTestPos.distanceSq(testPos) <= tooCloseDistance * tooCloseDistance) - { - isValid = false; - break; - } - } - - if (isValid) - { - return testPos; - } - } - } - - return BlockPos.ORIGIN; - } - - public void spreadWillToSurroundingChunks() - { + public void spreadWillToSurroundingChunks() { double currentAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); - if (currentAmount <= minimumWillForChunkWhenSpreading) - { + if (currentAmount <= minimumWillForChunkWhenSpreading) { return; } - for (EnumFacing side : EnumFacing.HORIZONTALS) - { + for (EnumFacing side : EnumFacing.HORIZONTALS) { BlockPos offsetPos = pos.offset(side, 16); double sideAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), offsetPos, type); - if (currentAmount > sideAmount) - { + if (currentAmount > sideAmount) { double drainAmount = Math.min((currentAmount - sideAmount) / 2, willPushRate); - if (drainAmount < willPushRate / 2) - { + if (drainAmount < willPushRate / 2) { continue; } @@ -258,26 +183,21 @@ public class TileInversionPillar extends TileTicking } } - public void removePillarFromMap() - { - if (!getWorld().isRemote) - { + public void removePillarFromMap() { + if (!getWorld().isRemote) { InversionPillarHandler.removePillarFromMap(getWorld(), type, pos); } } - public List getNearbyPillarsExcludingThis() - { + public List getNearbyPillarsExcludingThis() { return InversionPillarHandler.getNearbyPillars(getWorld(), type, pos); } @Override - public void deserialize(NBTTagCompound tag) - { + public void deserialize(NBTTagCompound tag) { super.deserialize(tag); - if (!tag.hasKey(Constants.NBT.WILL_TYPE)) - { + if (!tag.hasKey(Constants.NBT.WILL_TYPE)) { type = EnumDemonWillType.DEFAULT; } @@ -291,8 +211,7 @@ public class TileInversionPillar extends TileTicking } @Override - public NBTTagCompound serialize(NBTTagCompound tag) - { + public NBTTagCompound serialize(NBTTagCompound tag) { super.serialize(tag); tag.setString(Constants.NBT.WILL_TYPE, type.toString()); @@ -304,31 +223,26 @@ public class TileInversionPillar extends TileTicking return tag; } - public void generateWillForNearbyPillars(double currentWillInChunk, List offsetPositions) - { + public void generateWillForNearbyPillars(double currentWillInChunk, List offsetPositions) { double totalGeneratedWill = 0; double willFactor = currentWillInChunk / 1000; - for (BlockPos offsetPos : offsetPositions) - { + for (BlockPos offsetPos : offsetPositions) { double distanceSquared = offsetPos.distanceSq(pos); totalGeneratedWill += willFactor * 343 / (343 + Math.pow(distanceSquared, 3 / 2)); } - if (totalGeneratedWill > 0) - { + if (totalGeneratedWill > 0) { WorldDemonWillHandler.fillWillToMaximum(getWorld(), pos, type, totalGeneratedWill, maxWillForChunk, true); } } - public void generateInversionForNearbyPillars(double currentWillInChunk, List offsetPositions) - { + public void generateInversionForNearbyPillars(double currentWillInChunk, List offsetPositions) { double willFactor = currentWillInChunk / 400; double totalGeneratedInversion = willFactor; - for (BlockPos offsetPos : offsetPositions) - { + for (BlockPos offsetPos : offsetPositions) { double distanceSquared = offsetPos.distanceSq(pos); totalGeneratedInversion += 3125 / (3125 + Math.pow(distanceSquared, 5 / 2)); @@ -338,30 +252,25 @@ public class TileInversionPillar extends TileTicking } /** - * * @param currentWillInChunk * @return 0 if the block is successfully placed, 1 if the block is not - * placed due to the selected place being invalid, 2 if the block is - * not placed due to there not being enough Will or Inversion, 3 if - * the block is not placed due to the selected block being air. + * placed due to the selected place being invalid, 2 if the block is + * not placed due to there not being enough Will or Inversion, 3 if + * the block is not placed due to the selected block being air. */ - public int polluteNearbyBlocks(double currentWillInChunk) - { + public int polluteNearbyBlocks(double currentWillInChunk) { // System.out.println("Hai! :D Current Inversion: " + currentInversion + ", Current Will: " + currentWillInChunk); - if (currentWillInChunk < operationThreshold || currentInversion < inversionPerOperation) - { + if (currentWillInChunk < operationThreshold || currentInversion < inversionPerOperation) { return 2; //Not enough Will or Inversion available } - for (int i = 0; i < currentInfectionRadius; i++) - { + for (int i = 0; i < currentInfectionRadius; i++) { 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) - { + if (r2 > maxInfectionRadius2) { double factor = Math.sqrt(maxInfectionRadius2 / r2); xOff *= factor; yOff *= factor; @@ -369,20 +278,16 @@ public class TileInversionPillar extends TileTicking } BlockPos offsetPos = pos.add(xOff + 0.5, yOff + 0.5, zOff + 0.5); - if (offsetPos.equals(pos)) - { + if (offsetPos.equals(pos)) { return 1; //Invalid block (itself!) } IBlockState state = getWorld().getBlockState(offsetPos); - if (!state.getBlock().isAir(state, getWorld(), 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 (getWorld().setBlockState(offsetPos, RegistrarBloodMagicBlocks.DEMON_EXTRAS.getStateFromMeta(0))) - { + if (block == Blocks.DIRT || block == Blocks.STONE || block == Blocks.GRASS) { + if (getWorld().setBlockState(offsetPos, RegistrarBloodMagicBlocks.DEMON_EXTRAS.getStateFromMeta(0))) { WorldDemonWillHandler.drainWill(getWorld(), pos, type, willPerOperation, true); currentInversion -= inversionPerOperation; @@ -397,40 +302,150 @@ public class TileInversionPillar extends TileTicking return 3; //The block was air } - public void handleEvents(float time, Iterable pastEvents) - { - for (Event event : pastEvents) - { + public void handleEvents(float time, Iterable pastEvents) { + for (Event event : pastEvents) { System.out.println("Event: " + event.event() + " " + event.offset() + " " + getPos() + " " + time); } } @Override - public boolean hasFastRenderer() - { + public boolean hasFastRenderer() { return true; } @Override - public boolean hasCapability(Capability capability, EnumFacing side) - { - if (capability == CapabilityAnimation.ANIMATION_CAPABILITY) - { + public boolean hasCapability(Capability capability, EnumFacing side) { + if (capability == CapabilityAnimation.ANIMATION_CAPABILITY) { return true; } return super.hasCapability(capability, side); } @Override - public T getCapability(Capability capability, EnumFacing side) - { - if (capability == CapabilityAnimation.ANIMATION_CAPABILITY) - { + public T getCapability(Capability capability, EnumFacing side) { + if (capability == CapabilityAnimation.ANIMATION_CAPABILITY) { return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm); } return super.getCapability(capability, side); } + public IAnimationStateMachine getAsm() { + return asm; + } + + public float getAnimationOffsetValue() { + return animationOffsetValue; + } + + public void setAnimationOffsetValue(float animationOffsetValue) { + this.animationOffsetValue = animationOffsetValue; + } + + public VariableValue getAnimationOffset() { + return animationOffset; + } + + public VariableValue getCycleLength() { + return cycleLength; + } + + public EnumDemonWillType getType() { + return type; + } + + public void setType(EnumDemonWillType type) { + this.type = type; + } + + public double getCurrentInversion() { + return currentInversion; + } + + public void setCurrentInversion(double currentInversion) { + this.currentInversion = currentInversion; + } + + public int getConsecutiveFailedChecks() { + return consecutiveFailedChecks; + } + + public void setConsecutiveFailedChecks(int consecutiveFailedChecks) { + this.consecutiveFailedChecks = consecutiveFailedChecks; + } + + public int getConsecutiveFailedAirChecks() { + return consecutiveFailedAirChecks; + } + + public void setConsecutiveFailedAirChecks(int consecutiveFailedAirChecks) { + this.consecutiveFailedAirChecks = consecutiveFailedAirChecks; + } + + public int getCurrentInfectionRadius() { + return currentInfectionRadius; + } + + public void setCurrentInfectionRadius(int currentInfectionRadius) { + this.currentInfectionRadius = currentInfectionRadius; + } + + public int getCounter() { + return counter; + } + + public void setCounter(int counter) { + this.counter = counter; + } + + public boolean isRegistered() { + return isRegistered; + } + + public void setRegistered(boolean registered) { + isRegistered = registered; + } + + public static BlockPos findCandidatePositionForPillar(World world, EnumDemonWillType type, BlockPos pos, List posList, double tooCloseDistance, double wantedAverageDistance) { + int maxIterations = 100; + int heightCheckRange = 3; + + for (int i = 0; i < maxIterations; i++) { + Collections.shuffle(posList); + BlockPos pillarPos = posList.get(0); + + Vec3d vec = new Vec3d(world.rand.nextDouble() * 2 - 1, world.rand.nextDouble() * 2 - 1, world.rand.nextDouble() * 2 - 1).normalize().scale(wantedAverageDistance); + + BlockPos centralPos = pillarPos.add(vec.x, vec.y, vec.z); + BlockPos testPos = null; + candidateTest: + for (int h = 0; h <= heightCheckRange; h++) { + for (int sig = -1; sig <= 1; sig += (h > 0 ? 2 : 3)) { + BlockPos candidatePos = centralPos.add(0, sig * h, 0); + if (world.isAirBlock(candidatePos) && world.isAirBlock(candidatePos.up()) && world.isAirBlock(candidatePos.down()) && !world.isAirBlock(candidatePos.down(2))) { + testPos = candidatePos; + break candidateTest; + } + } + } + + if (testPos != null) { + boolean isValid = true; + for (BlockPos pillarTestPos : posList) { + if (pillarTestPos.distanceSq(testPos) <= tooCloseDistance * tooCloseDistance) { + isValid = false; + break; + } + } + + if (isValid) { + return testPos; + } + } + } + + return BlockPos.ORIGIN; + } + public static double getWillPerOperation() { return willPerOperation; } @@ -511,82 +526,6 @@ public class TileInversionPillar extends TileTicking TileInversionPillar.minimumWillForChunkWhenSpreading = minimumWillForChunkWhenSpreading; } - public IAnimationStateMachine getAsm() { - return asm; - } - - public float getAnimationOffsetValue() { - return animationOffsetValue; - } - - public void setAnimationOffsetValue(float animationOffsetValue) { - this.animationOffsetValue = animationOffsetValue; - } - - public VariableValue getAnimationOffset() { - return animationOffset; - } - - public VariableValue getCycleLength() { - return cycleLength; - } - - public EnumDemonWillType getType() { - return type; - } - - public void setType(EnumDemonWillType type) { - this.type = type; - } - - public double getCurrentInversion() { - return currentInversion; - } - - public void setCurrentInversion(double currentInversion) { - this.currentInversion = currentInversion; - } - - public int getConsecutiveFailedChecks() { - return consecutiveFailedChecks; - } - - public void setConsecutiveFailedChecks(int consecutiveFailedChecks) { - this.consecutiveFailedChecks = consecutiveFailedChecks; - } - - public int getConsecutiveFailedAirChecks() { - return consecutiveFailedAirChecks; - } - - public void setConsecutiveFailedAirChecks(int consecutiveFailedAirChecks) { - this.consecutiveFailedAirChecks = consecutiveFailedAirChecks; - } - - public int getCurrentInfectionRadius() { - return currentInfectionRadius; - } - - public void setCurrentInfectionRadius(int currentInfectionRadius) { - this.currentInfectionRadius = currentInfectionRadius; - } - - public int getCounter() { - return counter; - } - - public void setCounter(int counter) { - this.counter = counter; - } - - public boolean isRegistered() { - return isRegistered; - } - - public void setRegistered(boolean registered) { - isRegistered = registered; - } - public static double getMaxWillForChunk() { return maxWillForChunk; } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java b/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java index 2faf553d..c812f552 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java @@ -1,18 +1,5 @@ package WayofTime.bloodmagic.tile; -import java.util.ArrayList; -import java.util.List; - -import WayofTime.bloodmagic.tile.base.TileTicking; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Event; import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.event.RitualEvent; import WayofTime.bloodmagic.api.registry.RitualRegistry; @@ -24,16 +11,26 @@ import WayofTime.bloodmagic.api.util.helper.NBTHelper; import WayofTime.bloodmagic.api.util.helper.NetworkHelper; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.api.util.helper.RitualHelper; -import WayofTime.bloodmagic.item.ItemActivationCrystal; import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.item.ItemActivationCrystal; +import WayofTime.bloodmagic.tile.base.TileTicking; import WayofTime.bloodmagic.util.ChatUtil; - import com.google.common.base.Strings; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.Event; import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; -public class TileMasterRitualStone extends TileTicking implements IMasterRitualStone -{ +public class TileMasterRitualStone extends TileTicking implements IMasterRitualStone { private String owner; private SoulNetwork cachedNetwork; private boolean active; @@ -46,21 +43,18 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS private List currentActiveWillConfig = new ArrayList(); @Override - public void onUpdate() - { + public void onUpdate() { if (getWorld().isRemote) return; - if (isPowered() && isActive()) - { + if (isPowered() && isActive()) { active = false; redstoned = true; stopRitual(Ritual.BreakType.REDSTONE); return; } - if (!isActive() && !isPowered() && isRedstoned() && getCurrentRitual() != null) - { + if (!isActive() && !isPowered() && isRedstoned() && getCurrentRitual() != null) { active = true; ItemStack crystalStack = NBTHelper.checkNBT(new ItemStack(RegistrarBloodMagicItems.ACTIVATION_CRYSTAL, 1, getCurrentRitual().getCrystalLevel())); crystalStack.getTagCompound().setString(Constants.NBT.OWNER_UUID, getOwner()); @@ -68,8 +62,7 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS redstoned = false; } - if (getCurrentRitual() != null && isActive()) - { + if (getCurrentRitual() != null && isActive()) { if (activeTime % getCurrentRitual().getRefreshTime() == 0) performRitual(getWorld(), getPos()); @@ -78,17 +71,14 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS } @Override - public void deserialize(NBTTagCompound tag) - { + public void deserialize(NBTTagCompound tag) { owner = tag.getString(Constants.NBT.OWNER_UUID); if (!Strings.isNullOrEmpty(owner)) cachedNetwork = NetworkHelper.getSoulNetwork(owner); currentRitual = RitualRegistry.getRitualForId(tag.getString(Constants.NBT.CURRENT_RITUAL)); - if (currentRitual != null) - { + if (currentRitual != null) { NBTTagCompound ritualTag = tag.getCompoundTag(Constants.NBT.CURRENT_RITUAL_TAG); - if (!ritualTag.hasNoTags()) - { + if (!ritualTag.hasNoTags()) { currentRitual.readFromNBT(ritualTag); } } @@ -97,23 +87,19 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS direction = EnumFacing.VALUES[tag.getInteger(Constants.NBT.DIRECTION)]; redstoned = tag.getBoolean(Constants.NBT.IS_REDSTONED); - for (EnumDemonWillType type : EnumDemonWillType.values()) - { - if (tag.getBoolean("EnumWill" + type)) - { + for (EnumDemonWillType type : EnumDemonWillType.values()) { + if (tag.getBoolean("EnumWill" + type)) { currentActiveWillConfig.add(type); } } } @Override - public NBTTagCompound serialize(NBTTagCompound tag) - { + public NBTTagCompound serialize(NBTTagCompound tag) { String ritualId = RitualRegistry.getIdForRitual(getCurrentRitual()); tag.setString(Constants.NBT.OWNER_UUID, Strings.isNullOrEmpty(getOwner()) ? "" : getOwner()); tag.setString(Constants.NBT.CURRENT_RITUAL, Strings.isNullOrEmpty(ritualId) ? "" : ritualId); - if (currentRitual != null) - { + if (currentRitual != null) { NBTTagCompound ritualTag = new NBTTagCompound(); currentRitual.writeToNBT(ritualTag); tag.setTag(Constants.NBT.CURRENT_RITUAL_TAG, ritualTag); @@ -123,8 +109,7 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex()); tag.setBoolean(Constants.NBT.IS_REDSTONED, redstoned); - for (EnumDemonWillType type : currentActiveWillConfig) - { + for (EnumDemonWillType type : currentActiveWillConfig) { tag.setBoolean("EnumWill" + type, true); } @@ -132,27 +117,21 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS } @Override - public boolean activateRitual(ItemStack activationCrystal, @Nullable EntityPlayer activator, Ritual ritual) - { + public boolean activateRitual(ItemStack activationCrystal, @Nullable EntityPlayer activator, Ritual ritual) { if (PlayerHelper.isFakePlayer(activator)) return false; activationCrystal = NBTHelper.checkNBT(activationCrystal); String crystalOwner = activationCrystal.getTagCompound().getString(Constants.NBT.OWNER_UUID); - if (!Strings.isNullOrEmpty(crystalOwner) && ritual != null) - { - if (activationCrystal.getItem() instanceof ItemActivationCrystal) - { + if (!Strings.isNullOrEmpty(crystalOwner) && ritual != null) { + if (activationCrystal.getItem() instanceof ItemActivationCrystal) { int crystalLevel = ((ItemActivationCrystal) activationCrystal.getItem()).getCrystalLevel(activationCrystal); - if (RitualHelper.canCrystalActivate(ritual, crystalLevel)) - { - if (!getWorld().isRemote) - { + if (RitualHelper.canCrystalActivate(ritual, crystalLevel)) { + if (!getWorld().isRemote) { SoulNetwork network = NetworkHelper.getSoulNetwork(crystalOwner); - if (!isRedstoned() && network.getCurrentEssence() < ritual.getActivationCost() && (activator != null && !activator.capabilities.isCreativeMode)) - { + if (!isRedstoned() && network.getCurrentEssence() < ritual.getActivationCost() && (activator != null && !activator.capabilities.isCreativeMode)) { activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.weak"), true); return false; } @@ -162,15 +141,13 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS RitualEvent.RitualActivatedEvent event = new RitualEvent.RitualActivatedEvent(this, crystalOwner, ritual, activator, activationCrystal, crystalLevel); - if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) - { + if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) { if (activator != null) activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.prevent"), true); return false; } - if (ritual.activateRitual(this, activator, crystalOwner)) - { + if (ritual.activateRitual(this, activator, crystalOwner)) { if (!isRedstoned() && (activator != null && !activator.capabilities.isCreativeMode)) network.syphon(ritual.getActivationCost()); @@ -191,8 +168,7 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS return true; } } - } else - { + } else { if (activator != null) activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.notValid"), true); } @@ -201,38 +177,31 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS } @Override - public void performRitual(World world, BlockPos pos) - { - if (!world.isRemote && getCurrentRitual() != null && RitualRegistry.ritualEnabled(getCurrentRitual())) - { - if (RitualHelper.checkValidRitual(getWorld(), getPos(), RitualRegistry.getIdForRitual(currentRitual), getDirection())) - { + public void performRitual(World world, BlockPos pos) { + if (!world.isRemote && getCurrentRitual() != null && RitualRegistry.ritualEnabled(getCurrentRitual())) { + if (RitualHelper.checkValidRitual(getWorld(), getPos(), RitualRegistry.getIdForRitual(currentRitual), getDirection())) { RitualEvent.RitualRunEvent event = new RitualEvent.RitualRunEvent(this, getOwner(), getCurrentRitual()); if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) return; getCurrentRitual().performRitual(this); - } else - { + } else { stopRitual(Ritual.BreakType.BREAK_STONE); } } } @Override - public void stopRitual(Ritual.BreakType breakType) - { - if (!getWorld().isRemote && getCurrentRitual() != null) - { + public void stopRitual(Ritual.BreakType breakType) { + if (!getWorld().isRemote && getCurrentRitual() != null) { RitualEvent.RitualStopEvent event = new RitualEvent.RitualStopEvent(this, getOwner(), getCurrentRitual(), breakType); if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) return; getCurrentRitual().stopRitual(this, breakType); - if (breakType != Ritual.BreakType.REDSTONE) - { + if (breakType != Ritual.BreakType.REDSTONE) { this.currentRitual = null; this.active = false; this.activeTime = 0; @@ -242,82 +211,71 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS } @Override - public int getCooldown() - { + public int getCooldown() { return cooldown; } @Override - public void setCooldown(int cooldown) - { + public void setCooldown(int cooldown) { this.cooldown = cooldown; } @Override - public void setActive(boolean active) - { - this.active = active; - } - - @Override - public EnumFacing getDirection() - { + public EnumFacing getDirection() { return direction; } + public void setDirection(EnumFacing direction) { + this.direction = direction; + } + @Override - public boolean areTanksEmpty() - { + public boolean areTanksEmpty() { return false; } @Override - public int getRunningTime() - { + public int getRunningTime() { return activeTime; } @Override - public String getOwner() - { + public String getOwner() { return owner; } + public void setOwner(String owner) { + this.owner = owner; + } + @Override - public SoulNetwork getOwnerNetwork() - { + public SoulNetwork getOwnerNetwork() { return cachedNetwork; } @Override - public World getWorld() - { + public World getWorld() { return super.getWorld(); } @Override - public BlockPos getPos() - { + public BlockPos getPos() { return super.getPos(); } @Override - public World getWorldObj() - { + public World getWorldObj() { return getWorld(); } @Override - public BlockPos getBlockPos() - { + public BlockPos getBlockPos() { return getPos(); } @Override - public String getNextBlockRange(String range) - { - if (this.currentRitual != null) - { + public String getNextBlockRange(String range) { + if (this.currentRitual != null) { return this.currentRitual.getNextBlockRange(range); } @@ -325,48 +283,38 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS } @Override - public void provideInformationOfRitualToPlayer(EntityPlayer player) - { - if (this.currentRitual != null) - { + public void provideInformationOfRitualToPlayer(EntityPlayer player) { + if (this.currentRitual != null) { ChatUtil.sendNoSpam(player, this.currentRitual.provideInformationOfRitualToPlayer(player)); } } @Override - public void provideInformationOfRangeToPlayer(EntityPlayer player, String range) - { - if (this.currentRitual != null && this.currentRitual.getListOfRanges().contains(range)) - { + public void provideInformationOfRangeToPlayer(EntityPlayer player, String range) { + if (this.currentRitual != null && this.currentRitual.getListOfRanges().contains(range)) { ChatUtil.sendNoSpam(player, this.currentRitual.provideInformationOfRangeToPlayer(player, range)); } } @Override - public void setActiveWillConfig(EntityPlayer player, List typeList) - { + public void setActiveWillConfig(EntityPlayer player, List typeList) { this.currentActiveWillConfig = typeList; } @Override - public boolean setBlockRangeByBounds(EntityPlayer player, String range, BlockPos offset1, BlockPos offset2) - { - if (this.currentRitual != null) - { + public boolean setBlockRangeByBounds(EntityPlayer player, String range, BlockPos offset1, BlockPos offset2) { + if (this.currentRitual != null) { boolean allowed = this.currentRitual.setBlockRangeByBounds(range, this, offset1, offset2); - if (player != null && !allowed) - { + if (player != null && !allowed) { ChatUtil.sendNoSpam(player, this.currentRitual.getErrorForBlockRangeOnFail(player, range, this, offset1, offset2)); - } else - { + } else { ChatUtil.sendNoSpam(player, new TextComponentTranslation("ritual.bloodmagic.blockRange.success")); } return allowed; } - if (player != null) - { + if (player != null) { ChatUtil.sendNoSpam(player, new TextComponentTranslation("ritual.bloodmagic.blockRange.inactive")); } @@ -374,49 +322,38 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS } @Override - public List getActiveWillConfig() - { + public List getActiveWillConfig() { return new ArrayList(currentActiveWillConfig); } @Override - public void provideInformationOfWillConfigToPlayer(EntityPlayer player, List typeList) - { + public void provideInformationOfWillConfigToPlayer(EntityPlayer player, List typeList) { //There is probably an easier way to make expanded chat messages - if (typeList.size() >= 1) - { + if (typeList.size() >= 1) { Object[] translations = new TextComponentTranslation[typeList.size()]; String constructedString = "%s"; - for (int i = 1; i < typeList.size(); i++) - { + for (int i = 1; i < typeList.size(); i++) { constructedString = constructedString + ", %s"; } - for (int i = 0; i < typeList.size(); i++) - { + for (int i = 0; i < typeList.size(); i++) { translations[i] = new TextComponentTranslation("tooltip.bloodmagic.currentBaseType." + typeList.get(i).name.toLowerCase()); } ChatUtil.sendNoSpam(player, new TextComponentTranslation("ritual.bloodmagic.willConfig.set", new TextComponentTranslation(constructedString, translations))); - } else - { + } else { ChatUtil.sendNoSpam(player, new TextComponentTranslation("ritual.bloodmagic.willConfig.void")); } } - public boolean isPowered() - { + public boolean isPowered() { if (inverted) return !getWorld().isBlockPowered(getPos()); return getWorld().isBlockPowered(getPos()); } - public void setOwner(String owner) { - this.owner = owner; - } - public SoulNetwork getCachedNetwork() { return cachedNetwork; } @@ -429,6 +366,11 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS return active; } + @Override + public void setActive(boolean active) { + this.active = active; + } + public boolean isRedstoned() { return redstoned; } @@ -453,10 +395,6 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS this.currentRitual = currentRitual; } - public void setDirection(EnumFacing direction) { - this.direction = direction; - } - public boolean isInverted() { return inverted; } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileMimic.java b/src/main/java/WayofTime/bloodmagic/tile/TileMimic.java index 71669907..46ed0004 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileMimic.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileMimic.java @@ -1,8 +1,11 @@ package WayofTime.bloodmagic.tile; -import java.lang.reflect.Field; -import java.util.List; - +import WayofTime.bloodmagic.block.BlockMimic; +import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.entity.mob.EntityMimic; +import WayofTime.bloodmagic.util.ChatUtil; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; @@ -25,17 +28,12 @@ import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.ReflectionHelper; -import WayofTime.bloodmagic.block.BlockMimic; -import WayofTime.bloodmagic.entity.mob.EntityMimic; -import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.util.ChatUtil; -import WayofTime.bloodmagic.util.Utils; import javax.annotation.Nullable; +import java.lang.reflect.Field; +import java.util.List; -public class TileMimic extends TileInventory implements ITickable -{ +public class TileMimic extends TileInventory implements ITickable { private static Field _blockMetadata = ReflectionHelper.findField(TileEntity.class, "blockMetadata", "field_145847_g"); public boolean dropItemsOnBreak = true; @@ -49,32 +47,25 @@ public class TileMimic extends TileInventory implements ITickable private int internalCounter = 0; - public TileMimic() - { + public TileMimic() { super(2, "mimic"); } @Override - public void update() - { - if (getWorld().isRemote) - { + public void update() { + if (getWorld().isRemote) { return; } internalCounter++; - if (internalCounter % potionSpawnInterval == 0 && this.getBlockMetadata() == BlockMimic.sentientMimicMeta) - { + if (internalCounter % potionSpawnInterval == 0 && this.getBlockMetadata() == BlockMimic.sentientMimicMeta) { ItemStack potionStack = this.getStackInSlot(1); - if (!potionStack.isEmpty()) - { + if (!potionStack.isEmpty()) { AxisAlignedBB bb = new AxisAlignedBB(this.getPos()).expand(playerCheckRadius, playerCheckRadius, playerCheckRadius); List playerList = getWorld().getEntitiesWithinAABB(EntityPlayer.class, bb); - for (EntityPlayer player : playerList) - { - if (!player.capabilities.isCreativeMode) - { + for (EntityPlayer player : playerList) { + if (!player.capabilities.isCreativeMode) { 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; @@ -91,15 +82,12 @@ public class TileMimic extends TileInventory implements ITickable } } - if (this.getBlockMetadata() == BlockMimic.sentientMimicMeta && getWorld().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 = getWorld().getEntitiesWithinAABB(EntityPlayer.class, bb); - for (EntityPlayer player : playerList) - { - if (!player.capabilities.isCreativeMode && Utils.canEntitySeeBlock(getWorld(), player, getPos())) - { + for (EntityPlayer player : playerList) { + if (!player.capabilities.isCreativeMode && Utils.canEntitySeeBlock(getWorld(), player, getPos())) { spawnMimicEntity(player); break; } @@ -108,25 +96,19 @@ 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.isEmpty() && player.capabilities.isCreativeMode) - { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side) { + if (!heldItem.isEmpty() && player.capabilities.isCreativeMode) { List list = PotionUtils.getEffectsFromStack(heldItem); - if (!list.isEmpty()) - { - if (!world.isRemote) - { + if (!list.isEmpty()) { + if (!world.isRemote) { setInventorySlotContents(1, heldItem.copy()); world.notifyBlockUpdate(pos, state, state, 3); ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionSet")); } return true; - } else if (heldItem.getItem() == RegistrarBloodMagicItems.POTION_FLASK) - { + } else if (heldItem.getItem() == RegistrarBloodMagicItems.POTION_FLASK) { //The potion flask is empty, therefore we have to reset the stored potion. - if (!world.isRemote) - { + if (!world.isRemote) { setInventorySlotContents(1, ItemStack.EMPTY); world.notifyBlockUpdate(pos, state, state, 3); ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionRemove")); @@ -135,8 +117,7 @@ public class TileMimic extends TileInventory implements ITickable } } - if (performSpecialAbility(player, side)) - { + if (performSpecialAbility(player, side)) { return true; } @@ -155,8 +136,7 @@ public class TileMimic extends TileInventory implements ITickable Utils.insertItemToTile(this, player, 0); this.refreshTileEntity(); - if (player.capabilities.isCreativeMode) - { + if (player.capabilities.isCreativeMode) { dropItemsOnBreak = getStackInSlot(0).isEmpty(); } @@ -164,93 +144,76 @@ public class TileMimic extends TileInventory implements ITickable return true; } - public boolean performSpecialAbility(EntityPlayer player, EnumFacing sideHit) - { - switch (this.getBlockMetadata()) - { - case BlockMimic.sentientMimicMeta: - if (player.capabilities.isCreativeMode) - { - if (player.isSneaking()) - { - playerCheckRadius = Math.max(playerCheckRadius - 1, 0); - ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.detectRadius.down", playerCheckRadius)); - } else - { - playerCheckRadius++; - ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.detectRadius.up", playerCheckRadius)); - } - - return false; - } - - return spawnMimicEntity(player); - default: - if (!player.capabilities.isCreativeMode) - { - return false; - } - - if (player.getActiveItemStack().isEmpty() && !getStackInSlot(1).isEmpty()) - { - switch (sideHit) - { - case EAST: //When the block is clicked on the EAST or WEST side, potionSpawnRadius is edited. - case WEST: - if (player.isSneaking()) - { - potionSpawnRadius = Math.max(potionSpawnRadius - 1, 0); - ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionSpawnRadius.down", potionSpawnRadius)); - } else - { - potionSpawnRadius++; - ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionSpawnRadius.up", potionSpawnRadius)); - } - break; - case NORTH: //When the block is clicked on the NORTH or SOUTH side, detectRadius is edited. - case SOUTH: - if (player.isSneaking()) - { + public boolean performSpecialAbility(EntityPlayer player, EnumFacing sideHit) { + switch (this.getBlockMetadata()) { + case BlockMimic.sentientMimicMeta: + if (player.capabilities.isCreativeMode) { + if (player.isSneaking()) { playerCheckRadius = Math.max(playerCheckRadius - 1, 0); ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.detectRadius.down", playerCheckRadius)); - } else - { + } else { playerCheckRadius++; ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.detectRadius.up", playerCheckRadius)); } - break; - case UP: //When the block is clicked on the UP or DOWN side, potionSpawnInterval is edited. - case DOWN: - if (player.isSneaking()) - { - potionSpawnInterval = Math.max(potionSpawnInterval - 1, 1); - ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionInterval.down", potionSpawnInterval)); - } else - { - potionSpawnInterval++; - ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionInterval.up", potionSpawnInterval)); - } - break; - default: - break; + return false; } - return true; - } + return spawnMimicEntity(player); + default: + if (!player.capabilities.isCreativeMode) { + return false; + } + + if (player.getActiveItemStack().isEmpty() && !getStackInSlot(1).isEmpty()) { + switch (sideHit) { + case EAST: //When the block is clicked on the EAST or WEST side, potionSpawnRadius is edited. + case WEST: + if (player.isSneaking()) { + potionSpawnRadius = Math.max(potionSpawnRadius - 1, 0); + ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionSpawnRadius.down", potionSpawnRadius)); + } else { + potionSpawnRadius++; + ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionSpawnRadius.up", potionSpawnRadius)); + } + break; + case NORTH: //When the block is clicked on the NORTH or SOUTH side, detectRadius is edited. + case SOUTH: + if (player.isSneaking()) { + playerCheckRadius = Math.max(playerCheckRadius - 1, 0); + ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.detectRadius.down", playerCheckRadius)); + } else { + playerCheckRadius++; + ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.detectRadius.up", playerCheckRadius)); + } + break; + case UP: //When the block is clicked on the UP or DOWN side, potionSpawnInterval is edited. + case DOWN: + if (player.isSneaking()) { + potionSpawnInterval = Math.max(potionSpawnInterval - 1, 1); + ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionInterval.down", potionSpawnInterval)); + } else { + potionSpawnInterval++; + ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.bloodmagic.mimic.potionInterval.up", potionSpawnInterval)); + } + break; + default: + break; + + } + + return true; + } } return false; } - public boolean spawnMimicEntity(EntityPlayer target) - { - if (this.getWorld().getDifficulty() == EnumDifficulty.PEACEFUL) - { + public boolean spawnMimicEntity(EntityPlayer target) { + if (this.getWorld().getDifficulty() == EnumDifficulty.PEACEFUL) { return false; } - if (this.getStackInSlot(0).isEmpty() || getWorld().isRemote) - { + if (this.getStackInSlot(0).isEmpty() || getWorld().isRemote) { return false; } @@ -263,8 +226,7 @@ public class TileMimic extends TileInventory implements ITickable this.setInventorySlotContents(0, ItemStack.EMPTY); getWorld().spawnEntity(mimicEntity); - if (target != null) - { + if (target != null) { mimicEntity.setAttackTarget(target); } @@ -273,18 +235,15 @@ public class TileMimic extends TileInventory implements ITickable return true; } - public void refreshTileEntity() - { - if (mimicedTile != null) - { + public void refreshTileEntity() { + if (mimicedTile != null) { dropMimicedTileInventory(); } mimicedTile = getTileFromStackWithTag(getWorld(), pos, getStackInSlot(0), tileTag, metaOfReplacedBlock); } @Override - public void deserialize(NBTTagCompound tag) - { + public void deserialize(NBTTagCompound tag) { super.deserialize(tag); dropItemsOnBreak = tag.getBoolean("dropItemsOnBreak"); @@ -297,8 +256,7 @@ public class TileMimic extends TileInventory implements ITickable } @Override - public NBTTagCompound serialize(NBTTagCompound tag) - { + public NBTTagCompound serialize(NBTTagCompound tag) { super.serialize(tag); tag.setBoolean("dropItemsOnBreak", dropItemsOnBreak); @@ -311,25 +269,40 @@ public class TileMimic extends TileInventory implements ITickable return tag; } - public static void replaceMimicWithBlockActual(TileMimic mimic) - { + @Override + public void dropItems() { + if (dropItemsOnBreak) { + InventoryHelper.dropInventoryItems(getWorld(), getPos(), this); + } + + dropMimicedTileInventory(); + } + + public void dropMimicedTileInventory() { + if (!getWorld().isRemote && mimicedTile instanceof IInventory) { + InventoryHelper.dropInventoryItems(getWorld(), getPos(), (IInventory) mimicedTile); + } + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack itemstack) { + return slot == 0 && dropItemsOnBreak; + } + + public static void replaceMimicWithBlockActual(TileMimic mimic) { World world = mimic.getWorld(); BlockPos pos = mimic.getPos(); replaceMimicWithBlockActual(world, pos, mimic.getStackInSlot(0), mimic.tileTag, mimic.metaOfReplacedBlock); } - public static boolean replaceMimicWithBlockActual(World world, BlockPos pos, ItemStack stack, NBTTagCompound tileTag, int replacedMeta) - { - if (!stack.isEmpty() && stack.getItem() instanceof ItemBlock) - { + public static boolean replaceMimicWithBlockActual(World world, BlockPos pos, ItemStack stack, NBTTagCompound tileTag, int replacedMeta) { + if (!stack.isEmpty() && stack.getItem() instanceof ItemBlock) { Block block = ((ItemBlock) stack.getItem()).getBlock(); IBlockState state = block.getStateFromMeta(replacedMeta); - if (world.setBlockState(pos, state, 3)) - { + if (world.setBlockState(pos, state, 3)) { TileEntity tile = world.getTileEntity(pos); - if (tile != null) - { + if (tile != null) { tileTag.setInteger("x", pos.getX()); tileTag.setInteger("y", pos.getY()); tileTag.setInteger("z", pos.getZ()); @@ -344,21 +317,17 @@ public class TileMimic extends TileInventory implements ITickable } @Nullable - public static TileEntity getTileFromStackWithTag(World world, BlockPos pos, ItemStack stack, @Nullable NBTTagCompound tag, int replacementMeta) - { - if (!stack.isEmpty() && stack.getItem() instanceof ItemBlock) - { + public static TileEntity getTileFromStackWithTag(World world, BlockPos pos, ItemStack stack, @Nullable NBTTagCompound tag, int replacementMeta) { + if (!stack.isEmpty() && stack.getItem() instanceof ItemBlock) { Block block = ((ItemBlock) stack.getItem()).getBlock(); IBlockState state = block.getStateFromMeta(stack.getItemDamage()); - if (block.hasTileEntity(state)) - { + if (block.hasTileEntity(state)) { TileEntity tile = block.createTileEntity(world, state); if (tile == null) return null; - if (tag != null) - { + if (tag != null) { NBTTagCompound copyTag = tag.copy(); copyTag.setInteger("x", pos.getX()); copyTag.setInteger("y", pos.getY()); @@ -368,14 +337,11 @@ public class TileMimic extends TileInventory implements ITickable tile.setWorld(world); - try - { + try { _blockMetadata.setInt(tile, replacementMeta); - } catch (IllegalArgumentException e) - { + } catch (IllegalArgumentException e) { e.printStackTrace(); - } catch (IllegalAccessException e) - { + } catch (IllegalAccessException e) { e.printStackTrace(); } @@ -385,29 +351,4 @@ public class TileMimic extends TileInventory implements ITickable return null; } - - @Override - public void dropItems() - { - if (dropItemsOnBreak) - { - InventoryHelper.dropInventoryItems(getWorld(), getPos(), this); - } - - dropMimicedTileInventory(); - } - - public void dropMimicedTileInventory() - { - if (!getWorld().isRemote && mimicedTile instanceof IInventory) - { - InventoryHelper.dropInventoryItems(getWorld(), getPos(), (IInventory) mimicedTile); - } - } - - @Override - public boolean isItemValidForSlot(int slot, ItemStack itemstack) - { - return slot == 0 && dropItemsOnBreak; - } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/tile/TilePhantomBlock.java b/src/main/java/WayofTime/bloodmagic/tile/TilePhantomBlock.java index 0b8435e0..e9cbe72a 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TilePhantomBlock.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TilePhantomBlock.java @@ -4,38 +4,32 @@ import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.tile.base.TileTicking; import net.minecraft.nbt.NBTTagCompound; -public class TilePhantomBlock extends TileTicking -{ +public class TilePhantomBlock extends TileTicking { private int ticksRemaining = 10; public TilePhantomBlock() { } - public TilePhantomBlock(int ticksRemaining) - { + public TilePhantomBlock(int ticksRemaining) { this.ticksRemaining = ticksRemaining; } @Override - public void deserialize(NBTTagCompound tagCompound) - { + public void deserialize(NBTTagCompound tagCompound) { this.ticksRemaining = tagCompound.getInteger(Constants.NBT.TICKS_REMAINING); } @Override - public NBTTagCompound serialize(NBTTagCompound tagCompound) - { + public NBTTagCompound serialize(NBTTagCompound tagCompound) { tagCompound.setInteger(Constants.NBT.TICKS_REMAINING, ticksRemaining); return tagCompound; } @Override - public void onUpdate() - { + public void onUpdate() { ticksRemaining--; - if (ticksRemaining <= 0) - { + if (ticksRemaining <= 0) { 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 f393ee0b..4e0f8872 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TilePurificationAltar.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TilePurificationAltar.java @@ -1,7 +1,8 @@ package WayofTime.bloodmagic.tile; -import java.util.List; - +import WayofTime.bloodmagic.api.iface.IPurificationAsh; +import WayofTime.bloodmagic.api.ritual.AreaDescriptor; +import WayofTime.bloodmagic.api.util.helper.PurificationHelper; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -10,63 +11,51 @@ import net.minecraft.util.ITickable; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; -import WayofTime.bloodmagic.api.iface.IPurificationAsh; -import WayofTime.bloodmagic.api.ritual.AreaDescriptor; -import WayofTime.bloodmagic.api.util.helper.PurificationHelper; -public class TilePurificationAltar extends TileInventory implements ITickable -{ +import java.util.List; + +public class TilePurificationAltar extends TileInventory implements ITickable { public AreaDescriptor purityArea = new AreaDescriptor.Rectangle(new BlockPos(-5, -5, -5), 11); public double totalPurity = 0; public double maxPurity = 0; public double purityRate = 0; - public TilePurificationAltar() - { + public TilePurificationAltar() { super(1, "purificationAltar"); } @Override - public void update() - { - if (totalPurity <= 0) - { + public void update() { + if (totalPurity <= 0) { ItemStack stack = this.getStackInSlot(0); - if (!stack.isEmpty() && stack.getItem() instanceof IPurificationAsh) - { + if (!stack.isEmpty() && stack.getItem() instanceof IPurificationAsh) { totalPurity = ((IPurificationAsh) stack.getItem()).getTotalPurity(stack); maxPurity = ((IPurificationAsh) stack.getItem()).getMaxPurity(stack); purityRate = ((IPurificationAsh) stack.getItem()).getPurityRate(stack); } - } else - { + } else { return; } AxisAlignedBB aabb = purityArea.getAABB(getPos()); List animalList = getWorld().getEntitiesWithinAABB(EntityAnimal.class, aabb); - if (animalList.isEmpty()) - { + if (animalList.isEmpty()) { return; } boolean hasPerformed = false; - for (EntityAnimal animal : animalList) - { + for (EntityAnimal animal : animalList) { double added = PurificationHelper.addPurity(animal, Math.min(purityRate, totalPurity), maxPurity); - if (added > 0) - { + if (added > 0) { totalPurity -= purityRate; hasPerformed = true; } } - if (hasPerformed) - { - if (getWorld().rand.nextInt(4) == 0 && getWorld() instanceof WorldServer) - { + if (hasPerformed) { + if (getWorld().rand.nextInt(4) == 0 && getWorld() instanceof WorldServer) { 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]); } @@ -74,8 +63,7 @@ public class TilePurificationAltar extends TileInventory implements ITickable } @Override - public void deserialize(NBTTagCompound tag) - { + public void deserialize(NBTTagCompound tag) { super.deserialize(tag); totalPurity = tag.getDouble("totalPurity"); maxPurity = tag.getDouble("maxPurity"); @@ -83,8 +71,7 @@ public class TilePurificationAltar extends TileInventory implements ITickable } @Override - public NBTTagCompound serialize(NBTTagCompound tag) - { + public NBTTagCompound serialize(NBTTagCompound tag) { super.serialize(tag); tag.setDouble("totalPurity", totalPurity); diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java b/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java index 1aa3cc29..7bdf5b3e 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java @@ -15,8 +15,7 @@ import net.minecraft.util.ITickable; import java.util.ArrayList; import java.util.List; -public class TileSoulForge extends TileInventory implements ITickable, IDemonWillConduit -{ +public class TileSoulForge extends TileInventory implements ITickable, IDemonWillConduit { public static final int ticksRequired = 100; public static final double worldWillTransferRate = 1; @@ -27,22 +26,19 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil public int burnTime = 0; - public TileSoulForge() - { + public TileSoulForge() { super(6, "soulForge"); } @Override - public void deserialize(NBTTagCompound tag) - { + public void deserialize(NBTTagCompound tag) { super.deserialize(tag); burnTime = tag.getInteger(Constants.NBT.SOUL_FORGE_BURN); } @Override - public NBTTagCompound serialize(NBTTagCompound tag) - { + public NBTTagCompound serialize(NBTTagCompound tag) { super.serialize(tag); tag.setInteger(Constants.NBT.SOUL_FORGE_BURN, burnTime); @@ -50,22 +46,17 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil } @Override - public void update() - { - if (!getWorld().isRemote) - { - for (EnumDemonWillType type : EnumDemonWillType.values()) - { + public void update() { + if (!getWorld().isRemote) { + for (EnumDemonWillType type : EnumDemonWillType.values()) { double willInWorld = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type); double filled = Math.min(willInWorld, worldWillTransferRate); - if (filled > 0) - { + if (filled > 0) { filled = this.fillDemonWill(type, filled, false); filled = WorldDemonWillHandler.drainWill(getWorld(), pos, type, filled, false); - if (filled > 0) - { + if (filled > 0) { this.fillDemonWill(type, filled, true); WorldDemonWillHandler.drainWill(getWorld(), pos, type, filled, true); } @@ -73,8 +64,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil } } - if (!hasSoulGemOrSoul()) - { + if (!hasSoulGemOrSoul()) { burnTime = 0; return; } @@ -83,30 +73,22 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil List inputList = new ArrayList(); - for (int i = 0; i < 4; i++) - { - if (!getStackInSlot(i).isEmpty()) - { + for (int i = 0; i < 4; i++) { + if (!getStackInSlot(i).isEmpty()) { inputList.add(getStackInSlot(i)); } } TartaricForgeRecipe recipe = TartaricForgeRecipeRegistry.getMatchingRecipe(inputList, getWorld(), getPos()); - if (recipe != null && (soulsInGem >= recipe.getMinimumSouls() || burnTime > 0)) - { - if (canCraft(recipe)) - { + if (recipe != null && (soulsInGem >= recipe.getMinimumSouls() || burnTime > 0)) { + if (canCraft(recipe)) { burnTime++; - if (burnTime == ticksRequired) - { - if (!getWorld().isRemote) - { + if (burnTime == ticksRequired) { + if (!getWorld().isRemote) { double requiredSouls = recipe.getSoulsDrained(); - if (requiredSouls > 0) - { - if (!getWorld().isRemote && soulsInGem >= recipe.getMinimumSouls()) - { + if (requiredSouls > 0) { + if (!getWorld().isRemote && soulsInGem >= recipe.getMinimumSouls()) { consumeSouls(EnumDemonWillType.DEFAULT, requiredSouls); } } @@ -116,29 +98,23 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil } burnTime = 0; - } else if (burnTime > ticksRequired + 10) - { + } else if (burnTime > ticksRequired + 10) { burnTime = 0; } - } else - { + } else { burnTime = 0; } - } else - { + } else { burnTime = 0; } } - public double getProgressForGui() - { + public double getProgressForGui() { return ((double) burnTime) / ticksRequired; } - private boolean canCraft(TartaricForgeRecipe recipe) - { - if (recipe == null) - { + private boolean canCraft(TartaricForgeRecipe recipe) { + if (recipe == null) { return false; } @@ -155,18 +131,14 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil } - public void craftItem(TartaricForgeRecipe recipe) - { - if (this.canCraft(recipe)) - { + public void craftItem(TartaricForgeRecipe recipe) { + if (this.canCraft(recipe)) { ItemStack outputStack = recipe.getRecipeOutput(); ItemStack currentOutputStack = getStackInSlot(outputSlot); - if (currentOutputStack.isEmpty()) - { + if (currentOutputStack.isEmpty()) { setInventorySlotContents(outputSlot, outputStack); - } else if (currentOutputStack.getItem() == currentOutputStack.getItem()) - { + } else if (currentOutputStack.getItem() == currentOutputStack.getItem()) { currentOutputStack.grow(outputStack.getCount()); } @@ -174,14 +146,11 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil } } - public boolean hasSoulGemOrSoul() - { + public boolean hasSoulGemOrSoul() { ItemStack soulStack = getStackInSlot(soulSlot); - if (!soulStack.isEmpty()) - { - if (soulStack.getItem() instanceof IDemonWill || soulStack.getItem() instanceof IDemonWillGem) - { + if (!soulStack.isEmpty()) { + if (soulStack.getItem() instanceof IDemonWill || soulStack.getItem() instanceof IDemonWillGem) { return true; } } @@ -189,20 +158,16 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil return false; } - public double getWill(EnumDemonWillType type) - { + public double getWill(EnumDemonWillType type) { ItemStack soulStack = getStackInSlot(soulSlot); - if (soulStack != null) - { - if (soulStack.getItem() instanceof IDemonWill && ((IDemonWill) soulStack.getItem()).getType(soulStack) == type) - { + if (soulStack != null) { + if (soulStack.getItem() instanceof IDemonWill && ((IDemonWill) soulStack.getItem()).getType(soulStack) == type) { IDemonWill soul = (IDemonWill) soulStack.getItem(); return soul.getWill(type, soulStack); } - if (soulStack.getItem() instanceof IDemonWillGem) - { + if (soulStack.getItem() instanceof IDemonWillGem) { IDemonWillGem soul = (IDemonWillGem) soulStack.getItem(); return soul.getWill(type, soulStack); } @@ -211,25 +176,20 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil return 0; } - public double consumeSouls(EnumDemonWillType type, double requested) - { + public double consumeSouls(EnumDemonWillType type, double requested) { ItemStack soulStack = getStackInSlot(soulSlot); - if (soulStack != null) - { - if (soulStack.getItem() instanceof IDemonWill && ((IDemonWill) soulStack.getItem()).getType(soulStack) == type) - { + if (soulStack != null) { + if (soulStack.getItem() instanceof IDemonWill && ((IDemonWill) soulStack.getItem()).getType(soulStack) == type) { IDemonWill soul = (IDemonWill) soulStack.getItem(); double souls = soul.drainWill(type, soulStack, requested); - if (soul.getWill(type, soulStack) <= 0) - { + if (soul.getWill(type, soulStack) <= 0) { setInventorySlotContents(soulSlot, ItemStack.EMPTY); } return souls; } - if (soulStack.getItem() instanceof IDemonWillGem) - { + if (soulStack.getItem() instanceof IDemonWillGem) { IDemonWillGem soul = (IDemonWillGem) soulStack.getItem(); return soul.drainWill(type, soulStack, requested, true); } @@ -238,22 +198,17 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil return 0; } - public void consumeInventory() - { - for (int i = 0; i < 4; i++) - { + public void consumeInventory() { + for (int i = 0; i < 4; i++) { ItemStack inputStack = getStackInSlot(i); - if (!inputStack.isEmpty()) - { - if (inputStack.getItem().hasContainerItem(inputStack)) - { + if (!inputStack.isEmpty()) { + if (inputStack.getItem().hasContainerItem(inputStack)) { setInventorySlotContents(i, inputStack.getItem().getContainerItem(inputStack)); continue; } inputStack.shrink(1); - if (inputStack.isEmpty()) - { + if (inputStack.isEmpty()) { setInventorySlotContents(i, ItemStack.EMPTY); } } @@ -261,27 +216,22 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil } @Override - public int getWeight() - { + public int getWeight() { return 50; } @Override - public double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill) - { - if (amount <= 0) - { + public double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill) { + if (amount <= 0) { return 0; } - if (!canFill(type)) - { + if (!canFill(type)) { return 0; } ItemStack stack = this.getStackInSlot(soulSlot); - if (stack.isEmpty() || !(stack.getItem() instanceof IDemonWillGem)) - { + if (stack.isEmpty() || !(stack.getItem() instanceof IDemonWillGem)) { return 0; } @@ -290,11 +240,9 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil } @Override - public double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain) - { + public double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain) { ItemStack stack = this.getStackInSlot(soulSlot); - if (stack.isEmpty() || !(stack.getItem() instanceof IDemonWillGem)) - { + if (stack.isEmpty() || !(stack.getItem() instanceof IDemonWillGem)) { return 0; } @@ -302,13 +250,11 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil double drained = amount; double current = willGem.getWill(type, stack); - if (current < drained) - { + if (current < drained) { drained = current; } - if (doDrain) - { + if (doDrain) { drained = willGem.drainWill(type, stack, drained, true); } @@ -316,20 +262,17 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil } @Override - public boolean canFill(EnumDemonWillType type) - { + public boolean canFill(EnumDemonWillType type) { return true; } @Override - public boolean canDrain(EnumDemonWillType type) - { + public boolean canDrain(EnumDemonWillType type) { return true; } @Override - public double getCurrentWill(EnumDemonWillType type) - { + public double getCurrentWill(EnumDemonWillType type) { return 0; } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileSpectralBlock.java b/src/main/java/WayofTime/bloodmagic/tile/TileSpectralBlock.java index d55faece..44696136 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileSpectralBlock.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileSpectralBlock.java @@ -12,27 +12,23 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.ForgeRegistries; -public class TileSpectralBlock extends TileTicking -{ +public class TileSpectralBlock extends TileTicking { private int ticksRemaining; private String containedBlockName; private int containedBlockMeta; - public TileSpectralBlock() - { + public TileSpectralBlock() { } @Override - public void deserialize(NBTTagCompound tagCompound) - { + public void deserialize(NBTTagCompound tagCompound) { ticksRemaining = tagCompound.getInteger(Constants.NBT.TICKS_REMAINING); containedBlockName = tagCompound.getString(Constants.NBT.CONTAINED_BLOCK_NAME); containedBlockMeta = tagCompound.getInteger(Constants.NBT.CONTAINED_BLOCK_META); } @Override - public NBTTagCompound serialize(NBTTagCompound tagCompound) - { + public NBTTagCompound serialize(NBTTagCompound tagCompound) { tagCompound.setInteger(Constants.NBT.TICKS_REMAINING, ticksRemaining); tagCompound.setString(Constants.NBT.CONTAINED_BLOCK_NAME, Strings.isNullOrEmpty(containedBlockName) ? "" : containedBlockName); tagCompound.setInteger(Constants.NBT.CONTAINED_BLOCK_META, containedBlockMeta); @@ -40,40 +36,33 @@ public class TileSpectralBlock extends TileTicking } @Override - public void onUpdate() - { - if (getWorld().isRemote) - { + public void onUpdate() { + if (getWorld().isRemote) { return; } ticksRemaining--; - if (ticksRemaining <= 0) - { + if (ticksRemaining <= 0) { returnContainedBlock(); } } - private void setContainedBlockInfo(IBlockState blockState) - { + private void setContainedBlockInfo(IBlockState blockState) { containedBlockName = blockState.getBlock().getRegistryName().toString(); containedBlockMeta = blockState.getBlock().getMetaFromState(blockState); } - private void setDuration(int duration) - { + private void setDuration(int duration) { ticksRemaining = duration; } - public void resetDuration(int reset) - { + public void resetDuration(int reset) { if (ticksRemaining < reset) ticksRemaining = reset; } - public void returnContainedBlock() - { + public void returnContainedBlock() { Block block = null; if (!Strings.isNullOrEmpty(containedBlockName)) @@ -83,8 +72,7 @@ public class TileSpectralBlock extends TileTicking getWorld().notifyBlockUpdate(getPos(), getWorld().getBlockState(getPos()), getWorld().getBlockState(getPos()), 3); } - public static void createSpectralBlock(World world, BlockPos blockPos, int duration) - { + public static void createSpectralBlock(World world, BlockPos blockPos, int duration) { if (world.isAirBlock(blockPos)) return; IBlockState cachedState = world.getBlockState(blockPos); diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileTeleposer.java b/src/main/java/WayofTime/bloodmagic/tile/TileTeleposer.java index 625eeb8e..97c51571 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileTeleposer.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileTeleposer.java @@ -22,42 +22,35 @@ import net.minecraftforge.common.MinecraftForge; import java.util.List; -public class TileTeleposer extends TileInventory implements ITickable -{ +public class TileTeleposer extends TileInventory implements ITickable { //TODO FUTURE: Make AreaDescriptor for Teleposer perhaps? public static final String TELEPOSER_RANGE = "teleposerRange"; private int previousInput; - public TileTeleposer() - { + public TileTeleposer() { super(1, "teleposer"); } @Override - public void deserialize(NBTTagCompound tagCompound) - { + public void deserialize(NBTTagCompound tagCompound) { super.deserialize(tagCompound); previousInput = tagCompound.getInteger(Constants.NBT.PREVIOUS_INPUT); } @Override - public NBTTagCompound serialize(NBTTagCompound tagCompound) - { + public NBTTagCompound serialize(NBTTagCompound tagCompound) { super.serialize(tagCompound); tagCompound.setInteger(Constants.NBT.PREVIOUS_INPUT, previousInput); return tagCompound; } @Override - public void update() - { - if (!getWorld().isRemote) - { + public void update() { + if (!getWorld().isRemote) { int currentInput = getWorld().getStrongPower(pos); - if (previousInput == 0 && currentInput != 0) - { + if (previousInput == 0 && currentInput != 0) { initiateTeleport(); } @@ -65,33 +58,25 @@ public class TileTeleposer extends TileInventory implements ITickable } } - public void initiateTeleport() - { - if (!getWorld().isRemote && canInitiateTeleport(this) && getBlockType() instanceof BlockTeleposer) - { + public void initiateTeleport() { + if (!getWorld().isRemote && canInitiateTeleport(this) && getBlockType() instanceof BlockTeleposer) { ItemStack focusStack = NBTHelper.checkNBT(getStackInSlot(0)); ItemTelepositionFocus focus = (ItemTelepositionFocus) focusStack.getItem(); 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)) - { + if (focusWorld != null && focusWorld.getTileEntity(focusPos) instanceof TileTeleposer && !focusWorld.getTileEntity(focusPos).equals(this)) { 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))) - { + if (NetworkHelper.getSoulNetwork(focus.getOwnerUUID(focusStack)).syphonAndDamage(PlayerHelper.getPlayerFromUUID(focus.getOwnerUUID(focusStack)), lpToBeDrained * (focusLevel * 2 - 1) * (focusLevel * 2 - 1) * (focusLevel * 2 - 1))) { int blocksTransported = 0; - for (int i = -(focusLevel - 1); i <= (focusLevel - 1); i++) - { - for (int j = 0; j <= (focusLevel * 2 - 2); j++) - { - for (int k = -(focusLevel - 1); k <= (focusLevel - 1); k++) - { + for (int i = -(focusLevel - 1); i <= (focusLevel - 1); i++) { + for (int j = 0; j <= (focusLevel * 2 - 2); j++) { + for (int k = -(focusLevel - 1); k <= (focusLevel - 1); 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)) - { + if (Utils.swapLocations(event.initalWorld, event.initialBlockPos, event.finalWorld, event.finalBlockPos) && !MinecraftForge.EVENT_BUS.post(event)) { blocksTransported++; } } @@ -107,37 +92,27 @@ public class TileTeleposer extends TileInventory implements ITickable 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(getWorld())) - { - if (!originalWorldEntities.isEmpty()) - { - for (Entity entity : originalWorldEntities) - { + if (focusWorld.equals(getWorld())) { + if (!originalWorldEntities.isEmpty()) { + for (Entity entity : originalWorldEntities) { TeleportQueue.getInstance().addITeleport(new Teleports.TeleportSameDim(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), true)); } } - if (!focusWorldEntities.isEmpty()) - { - for (Entity entity : focusWorldEntities) - { + if (!focusWorldEntities.isEmpty()) { + for (Entity entity : focusWorldEntities) { TeleportQueue.getInstance().addITeleport(new Teleports.TeleportSameDim(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), true)); } } - } else - { - if (!originalWorldEntities.isEmpty()) - { - for (Entity entity : originalWorldEntities) - { + } else { + if (!originalWorldEntities.isEmpty()) { + 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), getWorld(), focusWorld.provider.getDimension(), true)); } } - if (!focusWorldEntities.isEmpty()) - { - for (Entity entity : focusWorldEntities) - { + if (!focusWorldEntities.isEmpty()) { + 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, getWorld().provider.getDimension(), true)); } } @@ -147,8 +122,7 @@ public class TileTeleposer extends TileInventory implements ITickable } } - private boolean canInitiateTeleport(TileTeleposer teleposer) - { + private boolean canInitiateTeleport(TileTeleposer teleposer) { 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/base/TileBase.java b/src/main/java/WayofTime/bloodmagic/tile/base/TileBase.java index 138d4719..56498ae8 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/base/TileBase.java +++ b/src/main/java/WayofTime/bloodmagic/tile/base/TileBase.java @@ -12,22 +12,19 @@ import net.minecraftforge.fml.relauncher.SideOnly; /** * Base tile class. - * + *

* Handles data syncing and core data writing/reading. */ -public class TileBase extends TileEntity -{ +public class TileBase extends TileEntity { @Override - public final void readFromNBT(NBTTagCompound compound) - { + public final void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); deserializeBase(compound); deserialize(compound); } @Override - public final NBTTagCompound writeToNBT(NBTTagCompound compound) - { + public final NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); serializeBase(compound); return serialize(compound); @@ -35,38 +32,34 @@ public class TileBase extends TileEntity /** * Called by {@link #readFromNBT(NBTTagCompound)} - * + *

* Internal data (such as coordinates) are handled for you. Just read the data you need. * * @param tagCompound - The tag compound to read from */ - public void deserialize(NBTTagCompound tagCompound) - { + public void deserialize(NBTTagCompound tagCompound) { } /** * Package private method for reading base data from the tag compound. * - * @see TileTicking - * * @param tagCompound - The tag compound to read from + * @see TileTicking */ - void deserializeBase(NBTTagCompound tagCompound) - { + void deserializeBase(NBTTagCompound tagCompound) { } /** * Called by {@link #writeToNBT(NBTTagCompound)} - * + *

* Internal data (such as coordinates) are handled for you. Just read the data you need. * * @param tagCompound - The tag compound to write to. * @return the modified tag compound */ - public NBTTagCompound serialize(NBTTagCompound tagCompound) - { + public NBTTagCompound serialize(NBTTagCompound tagCompound) { return tagCompound; } @@ -74,13 +67,11 @@ public class TileBase extends TileEntity /** * Package private method for writing base data to the tag compound. * - * @see TileTicking - * * @param tagCompound - The tag compound to write to. * @return the modified tag compound + * @see TileTicking */ - NBTTagCompound serializeBase(NBTTagCompound tagCompound) - { + NBTTagCompound serializeBase(NBTTagCompound tagCompound) { return tagCompound; } @@ -91,34 +82,29 @@ public class TileBase extends TileEntity // Data syncing @Override - public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) - { + public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) { return oldState.getBlock() != newState.getBlock(); } @Override - public final SPacketUpdateTileEntity getUpdatePacket() - { + public final SPacketUpdateTileEntity getUpdatePacket() { return new SPacketUpdateTileEntity(getPos(), -999, writeToNBT(new NBTTagCompound())); } @Override @SideOnly(Side.CLIENT) - public final void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) - { + public final void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); readFromNBT(pkt.getNbtCompound()); } @Override - public final NBTTagCompound getUpdateTag() - { + public final NBTTagCompound getUpdateTag() { return writeToNBT(new NBTTagCompound()); } @Override - public final void handleUpdateTag(NBTTagCompound tag) - { + public final void handleUpdateTag(NBTTagCompound tag) { readFromNBT(tag); } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/base/TileTicking.java b/src/main/java/WayofTime/bloodmagic/tile/base/TileTicking.java index 83ccaab6..f0a532ad 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/base/TileTicking.java +++ b/src/main/java/WayofTime/bloodmagic/tile/base/TileTicking.java @@ -7,14 +7,12 @@ import net.minecraft.util.ITickable; * Base class for tiles that tick. Allows disabling the ticking programmatically. */ // TODO - Move implementations that depend on existed ticks to new methods from here. -public abstract class TileTicking extends TileBase implements ITickable -{ +public abstract class TileTicking extends TileBase implements ITickable { private int ticksExisted; private boolean shouldTick = true; @Override - public final void update() - { + public final void update() { if (shouldTick()) { ticksExisted++; onUpdate(); @@ -22,15 +20,13 @@ public abstract class TileTicking extends TileBase implements ITickable } @Override - void deserializeBase(NBTTagCompound tagCompound) - { + void deserializeBase(NBTTagCompound tagCompound) { this.ticksExisted = tagCompound.getInteger("ticksExisted"); this.shouldTick = tagCompound.getBoolean("shouldTick"); } @Override - NBTTagCompound serializeBase(NBTTagCompound tagCompound) - { + NBTTagCompound serializeBase(NBTTagCompound tagCompound) { tagCompound.setInteger("ticksExisted", getTicksExisted()); tagCompound.setBoolean("shouldTick", shouldTick()); return tagCompound; @@ -41,23 +37,19 @@ public abstract class TileTicking extends TileBase implements ITickable */ public abstract void onUpdate(); - public int getTicksExisted() - { + public int getTicksExisted() { return ticksExisted; } - public void resetLifetime() - { + public void resetLifetime() { ticksExisted = 0; } - public boolean shouldTick() - { + public boolean shouldTick() { return shouldTick; } - public void setShouldTick(boolean shouldTick) - { + public void setShouldTick(boolean shouldTick) { this.shouldTick = shouldTick; } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerAlchemyTable.java b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerAlchemyTable.java index 4cf8c221..9ba7f05a 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerAlchemyTable.java +++ b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerAlchemyTable.java @@ -1,5 +1,7 @@ package WayofTime.bloodmagic.tile.container; +import WayofTime.bloodmagic.api.orb.IBloodOrb; +import WayofTime.bloodmagic.tile.TileAlchemyTable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ClickType; @@ -7,15 +9,11 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import WayofTime.bloodmagic.api.orb.IBloodOrb; -import WayofTime.bloodmagic.tile.TileAlchemyTable; -public class ContainerAlchemyTable extends Container -{ +public class ContainerAlchemyTable extends Container { private final IInventory tileTable; - public ContainerAlchemyTable(InventoryPlayer inventoryPlayer, IInventory tileTable) - { + public ContainerAlchemyTable(InventoryPlayer inventoryPlayer, IInventory tileTable) { this.tileTable = tileTable; this.addSlotToContainer(new Slot(tileTable, 0, 62, 15)); this.addSlotToContainer(new Slot(tileTable, 1, 80, 51)); @@ -27,30 +25,24 @@ public class ContainerAlchemyTable extends Container this.addSlotToContainer(new SlotOrb(tileTable, TileAlchemyTable.orbSlot, 152, 69)); this.addSlotToContainer(new SlotOutput(tileTable, TileAlchemyTable.outputSlot, 44, 51)); - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 9; j++) - { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 123 + i * 18)); } } - for (int i = 0; i < 9; i++) - { + for (int i = 0; i < 9; i++) { addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 181)); } } @Override - public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) - { + public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { InventoryPlayer inventoryPlayer = player.inventory; - if (slotId < 6 && slotId >= 0) - { + if (slotId < 6 && slotId >= 0) { Slot slot = this.getSlot(slotId); - if (!slot.getHasStack() && inventoryPlayer.getItemStack().isEmpty()) - { + if (!slot.getHasStack() && inventoryPlayer.getItemStack().isEmpty()) { ((TileAlchemyTable) tileTable).toggleInputSlotAccessible(slotId); } } @@ -59,51 +51,40 @@ public class ContainerAlchemyTable extends Container } @Override - public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) - { + public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); - if (slot != null && slot.getHasStack()) - { + if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); - if (index == 8) - { - if (!this.mergeItemStack(itemstack1, 9, 9 + 36, true)) - { + if (index == 8) { + if (!this.mergeItemStack(itemstack1, 9, 9 + 36, true)) { return ItemStack.EMPTY; } slot.onSlotChange(itemstack1, itemstack); - } else if (index > 8) - { - if (itemstack1.getItem() instanceof IBloodOrb) - { + } else if (index > 8) { + if (itemstack1.getItem() instanceof IBloodOrb) { if (!this.mergeItemStack(itemstack1, 7, 8, false)) //TODO: Add alchemy tools to list { return ItemStack.EMPTY; } - } else if (!this.mergeItemStack(itemstack1, 0, 6, false)) - { + } else if (!this.mergeItemStack(itemstack1, 0, 6, false)) { return ItemStack.EMPTY; } - } else if (!this.mergeItemStack(itemstack1, 9, 9 + 36, false)) - { + } else if (!this.mergeItemStack(itemstack1, 9, 9 + 36, false)) { return ItemStack.EMPTY; } - if (itemstack1.getCount() == 0) - { + if (itemstack1.getCount() == 0) { slot.putStack(ItemStack.EMPTY); - } else - { + } else { slot.onSlotChanged(); } - if (itemstack1.getCount() == itemstack.getCount()) - { + if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } @@ -114,35 +95,28 @@ public class ContainerAlchemyTable extends Container } @Override - public boolean canInteractWith(EntityPlayer playerIn) - { + public boolean canInteractWith(EntityPlayer playerIn) { return this.tileTable.isUsableByPlayer(playerIn); } - private class SlotOrb extends Slot - { - public SlotOrb(IInventory inventory, int slotIndex, int x, int y) - { + private class SlotOrb extends Slot { + public SlotOrb(IInventory inventory, int slotIndex, int x, int y) { super(inventory, slotIndex, x, y); } @Override - public boolean isItemValid(ItemStack itemStack) - { + public boolean isItemValid(ItemStack itemStack) { return itemStack.getItem() instanceof IBloodOrb; } } - private class SlotOutput extends Slot - { - public SlotOutput(IInventory inventory, int slotIndex, int x, int y) - { + private class SlotOutput extends Slot { + public SlotOutput(IInventory inventory, int slotIndex, int x, int y) { super(inventory, slotIndex, x, y); } @Override - public boolean isItemValid(ItemStack stack) - { + public boolean isItemValid(ItemStack stack) { return false; } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerItemRoutingNode.java b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerItemRoutingNode.java index e2ec3eee..fa230b5a 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerItemRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerItemRoutingNode.java @@ -1,7 +1,8 @@ package WayofTime.bloodmagic.tile.container; -import javax.annotation.Nullable; - +import WayofTime.bloodmagic.item.inventory.ItemInventory; +import WayofTime.bloodmagic.item.routing.IRoutingFilterProvider; +import WayofTime.bloodmagic.tile.routing.TileFilteredRoutingNode; import WayofTime.bloodmagic.util.GhostItemHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -10,54 +11,43 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import WayofTime.bloodmagic.item.inventory.ItemInventory; -import WayofTime.bloodmagic.item.routing.IRoutingFilterProvider; -import WayofTime.bloodmagic.tile.routing.TileFilteredRoutingNode; -public class ContainerItemRoutingNode extends Container -{ +import javax.annotation.Nullable; + +public class ContainerItemRoutingNode extends Container { private final IInventory tileItemRoutingNode; -// private final ItemInventory itemInventory; + private final TileFilteredRoutingNode inventory; + public int lastGhostSlotClicked = -1; + // private final ItemInventory itemInventory; private int slotsOccupied; - private final TileFilteredRoutingNode inventory; - - public int lastGhostSlotClicked = -1; - - public ContainerItemRoutingNode(InventoryPlayer inventoryPlayer, IInventory tileItemRoutingNode) - { + public ContainerItemRoutingNode(InventoryPlayer inventoryPlayer, IInventory tileItemRoutingNode) { this.tileItemRoutingNode = tileItemRoutingNode; inventory = (TileFilteredRoutingNode) tileItemRoutingNode; this.addSlotToContainer(new SlotItemFilter(this, tileItemRoutingNode, 0, 8, 33)); ItemInventory itemInventory = inventory.itemInventory; - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { addSlotToContainer(new SlotGhostItem(itemInventory, j + i * 3, 26 + j * 18, 15 + i * 18)); } } slotsOccupied = 10; - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 9; j++) - { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 87 + i * 18)); } } - for (int i = 0; i < 9; i++) - { + for (int i = 0; i < 9; i++) { addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 145)); } } - public void resetItemInventory(ItemStack masterStack) - { + public void resetItemInventory(ItemStack masterStack) { inventory.itemInventory.initializeInventory(masterStack); } @@ -65,34 +55,28 @@ public class ContainerItemRoutingNode extends Container * Overridden in order to handle ghost item slots. */ @Override - public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) - { + public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { InventoryPlayer inventoryPlayer = player.inventory; // if (!player.worldObj.isRemote) { - if (slotId >= 0) - { + if (slotId >= 0) { Slot slot = this.inventorySlots.get(slotId); if (slot instanceof SlotGhostItem) //TODO: make the slot clicking work! { lastGhostSlotClicked = slot.getSlotIndex(); - if ((dragType == 0 || dragType == 1)) - { + if ((dragType == 0 || dragType == 1)) { ItemStack slotStack = slot.getStack(); ItemStack heldStack = inventoryPlayer.getItemStack(); if (dragType == 0) //Left mouse click-eth { { - if (heldStack.isEmpty() && !slotStack.isEmpty()) - { + if (heldStack.isEmpty() && !slotStack.isEmpty()) { //I clicked on the slot with an empty hand. Selecting! - } else if (!heldStack.isEmpty() && slotStack.isEmpty()) - { - if (!((SlotGhostItem) slot).canBeAccessed()) - { + } else if (!heldStack.isEmpty() && slotStack.isEmpty()) { + if (!((SlotGhostItem) slot).canBeAccessed()) { return super.slotClick(slotId, dragType, clickTypeIn, player); } @@ -102,8 +86,7 @@ public class ContainerItemRoutingNode extends Container slot.putStack(copyStack); ItemStack filterStack = this.inventorySlots.get(0).getStack(); - if (filterStack.getItem() instanceof IRoutingFilterProvider) - { + if (filterStack.getItem() instanceof IRoutingFilterProvider) { ItemStack filterCopy = ((IRoutingFilterProvider) filterStack.getItem()).getContainedStackForItem(filterStack, heldStack); slot.putStack(filterCopy); } @@ -123,55 +106,44 @@ public class ContainerItemRoutingNode extends Container } @Override - public void detectAndSendChanges() - { + public void detectAndSendChanges() { super.detectAndSendChanges(); } @Override - public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) - { + public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); - if (slot != null && slot.getHasStack()) - { + if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); - if (index == 0) - { - if (!this.mergeItemStack(itemstack1, slotsOccupied, slotsOccupied + 36, true)) - { + if (index == 0) { + if (!this.mergeItemStack(itemstack1, slotsOccupied, slotsOccupied + 36, true)) { return null; } slot.onSlotChange(itemstack1, itemstack); - } else if (index > 0) - { + } else if (index > 0) { // return null; if (itemstack1.getItem() instanceof IRoutingFilterProvider) // Change to check item is a filter { - if (!this.mergeItemStack(itemstack1, 0, 1, false)) - { + if (!this.mergeItemStack(itemstack1, 0, 1, false)) { return ItemStack.EMPTY; } } - } else if (!this.mergeItemStack(itemstack1, slotsOccupied, 36 + slotsOccupied, false)) - { + } else if (!this.mergeItemStack(itemstack1, slotsOccupied, 36 + slotsOccupied, false)) { return ItemStack.EMPTY; } - if (itemstack1.isEmpty()) - { + if (itemstack1.isEmpty()) { slot.putStack(ItemStack.EMPTY); - } else - { + } else { slot.onSlotChanged(); } - if (itemstack1.getCount() == itemstack.getCount()) - { + if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } @@ -182,85 +154,71 @@ public class ContainerItemRoutingNode extends Container } @Override - public boolean canInteractWith(EntityPlayer playerIn) - { + public boolean canInteractWith(EntityPlayer playerIn) { return this.tileItemRoutingNode.isUsableByPlayer(playerIn); } - private class SlotItemFilter extends Slot - { + private class SlotItemFilter extends Slot { public ContainerItemRoutingNode container; public TileFilteredRoutingNode inventory; - public SlotItemFilter(ContainerItemRoutingNode container, IInventory inventory, int slotIndex, int x, int y) - { + public SlotItemFilter(ContainerItemRoutingNode container, IInventory inventory, int slotIndex, int x, int y) { super(inventory, slotIndex, x, y); this.container = container; this.inventory = (TileFilteredRoutingNode) inventory; } @Override - public boolean isItemValid(ItemStack itemStack) - { + public boolean isItemValid(ItemStack itemStack) { return itemStack.getItem() instanceof IRoutingFilterProvider; //TODO: Create a new Item that holds the filter. } @Override - public void onSlotChanged() - { + public void onSlotChanged() { super.onSlotChanged(); container.resetItemInventory(getStack()); - for (int i = 1; i <= 9; i++) - { + for (int i = 1; i <= 9; i++) { Slot slot = container.getSlot(i); slot.onSlotChanged(); } } @Override - public ItemStack getStack() - { + public ItemStack getStack() { return this.inventory.getStackInSlot(getActiveSlot()); } @Override - public void putStack(@Nullable ItemStack stack) - { + public void putStack(@Nullable ItemStack stack) { this.inventory.setInventorySlotContents(getActiveSlot(), stack); this.onSlotChanged(); } @Override - public ItemStack decrStackSize(int amount) - { + public ItemStack decrStackSize(int amount) { return this.inventory.decrStackSize(getActiveSlot(), amount); } - public int getActiveSlot() - { + public int getActiveSlot() { return inventory.currentActiveSlot; } } - private class SlotGhostItem extends Slot - { + private class SlotGhostItem extends Slot { private ItemInventory itemInv; - public SlotGhostItem(ItemInventory inventory, int slotIndex, int x, int y) - { + public SlotGhostItem(ItemInventory inventory, int slotIndex, int x, int y) { super(inventory, slotIndex, x, y); itemInv = inventory; } @Override - public boolean isItemValid(ItemStack stack) - { + public boolean isItemValid(ItemStack stack) { return false; } @Override - public boolean canTakeStack(EntityPlayer playerIn) - { + public boolean canTakeStack(EntityPlayer playerIn) { return false; } @@ -270,8 +228,7 @@ public class ContainerItemRoutingNode extends Container // return itemInv.canInventoryBeManipulated() && super.isHere(inv, slotIn); // } - public boolean canBeAccessed() - { + public boolean canBeAccessed() { return itemInv.canInventoryBeManipulated(); } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerMasterRoutingNode.java b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerMasterRoutingNode.java index 64cd4de9..a9959c27 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerMasterRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerMasterRoutingNode.java @@ -5,19 +5,16 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; -public class ContainerMasterRoutingNode extends Container -{ +public class ContainerMasterRoutingNode extends Container { private final IInventory tileMasterRoutingNode; - public ContainerMasterRoutingNode(InventoryPlayer inventoryPlayer, IInventory tileMasterRoutingNode) - { + public ContainerMasterRoutingNode(InventoryPlayer inventoryPlayer, IInventory tileMasterRoutingNode) { this.tileMasterRoutingNode = tileMasterRoutingNode; } @Override - public boolean canInteractWith(EntityPlayer playerIn) - { + public boolean canInteractWith(EntityPlayer 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 ecf995d3..ced03f85 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerSoulForge.java +++ b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerSoulForge.java @@ -10,12 +10,10 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerSoulForge extends Container -{ +public class ContainerSoulForge extends Container { private final IInventory tileForge; - public ContainerSoulForge(InventoryPlayer inventoryPlayer, IInventory tileForge) - { + public ContainerSoulForge(InventoryPlayer inventoryPlayer, IInventory tileForge) { this.tileForge = tileForge; this.addSlotToContainer(new Slot(tileForge, 0, 8, 15)); this.addSlotToContainer(new Slot(tileForge, 1, 80, 15)); @@ -24,66 +22,51 @@ public class ContainerSoulForge extends Container this.addSlotToContainer(new SlotSoul(tileForge, TileSoulForge.soulSlot, 152, 51)); this.addSlotToContainer(new SlotOutput(tileForge, TileSoulForge.outputSlot, 44, 51)); - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 9; j++) - { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 123 + i * 18)); } } - for (int i = 0; i < 9; i++) - { + for (int i = 0; i < 9; i++) { addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 181)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) - { + public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); - if (slot != null && slot.getHasStack()) - { + if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); - if (index == 5) - { - if (!this.mergeItemStack(itemstack1, 6, 6 + 36, true)) - { + if (index == 5) { + if (!this.mergeItemStack(itemstack1, 6, 6 + 36, true)) { return ItemStack.EMPTY; } slot.onSlotChange(itemstack1, itemstack); - } else if (index > 5) - { - if (itemstack1.getItem() instanceof IDemonWill || itemstack1.getItem() instanceof IDemonWillGem) - { - if (!this.mergeItemStack(itemstack1, 4, 5, false)) - { + } else if (index > 5) { + if (itemstack1.getItem() instanceof IDemonWill || itemstack1.getItem() instanceof IDemonWillGem) { + if (!this.mergeItemStack(itemstack1, 4, 5, false)) { return ItemStack.EMPTY; } - } else if (!this.mergeItemStack(itemstack1, 0, 4, false)) - { + } else if (!this.mergeItemStack(itemstack1, 0, 4, false)) { return ItemStack.EMPTY; } - } else if (!this.mergeItemStack(itemstack1, 6, 42, false)) - { + } else if (!this.mergeItemStack(itemstack1, 6, 42, false)) { return ItemStack.EMPTY; } - if (itemstack1.getCount() == 0) - { + if (itemstack1.getCount() == 0) { slot.putStack(ItemStack.EMPTY); - } else - { + } else { slot.onSlotChanged(); } - if (itemstack1.getCount() == itemstack.getCount()) - { + if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } @@ -94,35 +77,28 @@ public class ContainerSoulForge extends Container } @Override - public boolean canInteractWith(EntityPlayer playerIn) - { + public boolean canInteractWith(EntityPlayer playerIn) { return this.tileForge.isUsableByPlayer(playerIn); } - private class SlotSoul extends Slot - { - public SlotSoul(IInventory inventory, int slotIndex, int x, int y) - { + private class SlotSoul extends Slot { + public SlotSoul(IInventory inventory, int slotIndex, int x, int y) { super(inventory, slotIndex, x, y); } @Override - public boolean isItemValid(ItemStack itemStack) - { + public boolean isItemValid(ItemStack itemStack) { return itemStack.getItem() instanceof IDemonWillGem || itemStack.getItem() instanceof IDemonWill; } } - private class SlotOutput extends Slot - { - public SlotOutput(IInventory inventory, int slotIndex, int x, int y) - { + private class SlotOutput extends Slot { + public SlotOutput(IInventory inventory, int slotIndex, int x, int y) { super(inventory, slotIndex, x, y); } @Override - public boolean isItemValid(ItemStack stack) - { + public boolean isItemValid(ItemStack stack) { return false; } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerTeleposer.java b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerTeleposer.java index 163361a0..82588b45 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/container/ContainerTeleposer.java +++ b/src/main/java/WayofTime/bloodmagic/tile/container/ContainerTeleposer.java @@ -8,65 +8,51 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerTeleposer extends Container -{ +public class ContainerTeleposer extends Container { private final IInventory tileTeleposer; - public ContainerTeleposer(InventoryPlayer inventoryPlayer, IInventory tileTeleposer) - { + public ContainerTeleposer(InventoryPlayer inventoryPlayer, IInventory tileTeleposer) { this.tileTeleposer = tileTeleposer; this.addSlotToContainer(new SlotTeleposer(tileTeleposer, 0, 80, 33)); - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 9; j++) - { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 57 + i * 18)); } } - for (int i = 0; i < 9; i++) - { + for (int i = 0; i < 9; i++) { addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 115)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) - { + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { ItemStack stack = ItemStack.EMPTY; Slot slotObject = inventorySlots.get(slot); int slots = inventorySlots.size(); - if (slotObject != null && slotObject.getHasStack()) - { + if (slotObject != null && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); stack = stackInSlot.copy(); - if (stack.getItem() instanceof ItemTelepositionFocus) - { - if (slot <= slots) - { - if (!this.mergeItemStack(stackInSlot, 0, slots, false)) - { + if (stack.getItem() instanceof ItemTelepositionFocus) { + if (slot <= slots) { + if (!this.mergeItemStack(stackInSlot, 0, slots, false)) { return ItemStack.EMPTY; } - } else if (!this.mergeItemStack(stackInSlot, slots, 36 + slots, false)) - { + } else if (!this.mergeItemStack(stackInSlot, slots, 36 + slots, false)) { return ItemStack.EMPTY; } } - if (stackInSlot.getCount() == 0) - { + if (stackInSlot.getCount() == 0) { slotObject.putStack(ItemStack.EMPTY); - } else - { + } else { slotObject.onSlotChanged(); } - if (stackInSlot.getCount() == stack.getCount()) - { + if (stackInSlot.getCount() == stack.getCount()) { return ItemStack.EMPTY; } @@ -77,21 +63,17 @@ public class ContainerTeleposer extends Container } @Override - public boolean canInteractWith(EntityPlayer playerIn) - { + public boolean canInteractWith(EntityPlayer playerIn) { return this.tileTeleposer.isUsableByPlayer(playerIn); } - private class SlotTeleposer extends Slot - { - public SlotTeleposer(IInventory inventory, int slotIndex, int x, int y) - { + private class SlotTeleposer extends Slot { + public SlotTeleposer(IInventory inventory, int slotIndex, int x, int y) { super(inventory, slotIndex, x, y); } @Override - public boolean isItemValid(ItemStack itemStack) - { + public boolean isItemValid(ItemStack itemStack) { return itemStack.getItem() instanceof ItemTelepositionFocus; } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/routing/TileFilteredRoutingNode.java b/src/main/java/WayofTime/bloodmagic/tile/routing/TileFilteredRoutingNode.java index d63884c2..83a22f14 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/routing/TileFilteredRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/routing/TileFilteredRoutingNode.java @@ -1,40 +1,35 @@ package WayofTime.bloodmagic.tile.routing; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.item.inventory.ItemInventory; +import WayofTime.bloodmagic.util.GhostItemHelper; import net.minecraft.block.state.IBlockState; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.EnumFacing; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.item.inventory.ItemInventory; -import WayofTime.bloodmagic.util.GhostItemHelper; import net.minecraft.util.NonNullList; -public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedInventory -{ +public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedInventory { public int currentActiveSlot = 0; public int[] priorities = new int[6]; public ItemInventory itemInventory = new ItemInventory(ItemStack.EMPTY, 9, ""); - public TileFilteredRoutingNode(int size, String name) - { + public TileFilteredRoutingNode(int size, String name) { super(size, name); } - public ItemStack getFilterStack(EnumFacing side) - { + public ItemStack getFilterStack(EnumFacing side) { int index = side.getIndex(); return getStackInSlot(index); } - public void setGhostItemAmount(int ghostItemSlot, int amount) - { + public void setGhostItemAmount(int ghostItemSlot, int amount) { ItemStack stack = itemInventory.getStackInSlot(ghostItemSlot); - if (!stack.isEmpty()) - { + if (!stack.isEmpty()) { GhostItemHelper.setItemGhostAmount(stack, amount); } @@ -42,38 +37,30 @@ public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedIn } @Override - public boolean isInventoryConnectedToSide(EnumFacing side) - { + public boolean isInventoryConnectedToSide(EnumFacing side) { return true; } @Override - public void deserialize(NBTTagCompound tag) - { + public void deserialize(NBTTagCompound tag) { super.deserialize(tag); currentActiveSlot = tag.getInteger("currentSlot"); priorities = tag.getIntArray(Constants.NBT.ROUTING_PRIORITY); - if (priorities.length != 6) - { + if (priorities.length != 6) { priorities = new int[6]; } - if (!tag.getBoolean("updated")) - { + if (!tag.getBoolean("updated")) { NBTTagList tags = tag.getTagList("Items", 10); inventory = NonNullList.withSize(getSizeInventory(), ItemStack.EMPTY); - for (int i = 0; i < tags.tagCount(); i++) - { - if (!isSyncedSlot(i)) - { + for (int i = 0; i < tags.tagCount(); i++) { + if (!isSyncedSlot(i)) { NBTTagCompound data = tags.getCompoundTagAt(i); byte j = data.getByte("Slot"); - if (j == 0) - { + if (j == 0) { inventory.set(i, new ItemStack(data)); - } else if (j >= 1 && j < inventory.size() + 1) - { + } else if (j >= 1 && j < inventory.size() + 1) { inventory.set(j - 1, new ItemStack(data)); } } @@ -84,8 +71,7 @@ public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedIn } @Override - public NBTTagCompound serialize(NBTTagCompound tag) - { + public NBTTagCompound serialize(NBTTagCompound tag) { super.serialize(tag); tag.setInteger("currentSlot", currentActiveSlot); tag.setIntArray(Constants.NBT.ROUTING_PRIORITY, priorities); @@ -93,46 +79,39 @@ public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedIn return tag; } - public void swapFilters(int requestedSlot) - { + public void swapFilters(int requestedSlot) { currentActiveSlot = requestedSlot; itemInventory.initializeInventory(getStackInSlot(currentActiveSlot)); this.markDirty(); } @Override - public int[] getSlotsForFace(EnumFacing side) - { + public int[] getSlotsForFace(EnumFacing side) { return new int[0]; } @Override - public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) - { + public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) { return false; } @Override - public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) - { + public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { return false; } @Override - public int getPriority(EnumFacing side) - { + public int getPriority(EnumFacing side) { return priorities[side.getIndex()]; } - public void incrementCurrentPriotiryToMaximum(int max) - { + public void incrementCurrentPriotiryToMaximum(int max) { priorities[currentActiveSlot] = Math.min(priorities[currentActiveSlot] + 1, max); IBlockState state = getWorld().getBlockState(pos); getWorld().notifyBlockUpdate(pos, state, state, 3); } - public void decrementCurrentPriority() - { + public void decrementCurrentPriority() { priorities[currentActiveSlot] = Math.max(priorities[currentActiveSlot] - 1, 0); 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 1717445f..d758f2b5 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/routing/TileInputRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/routing/TileInputRoutingNode.java @@ -1,51 +1,39 @@ package WayofTime.bloodmagic.tile.routing; +import WayofTime.bloodmagic.item.routing.IFluidFilterProvider; +import WayofTime.bloodmagic.item.routing.IItemFilterProvider; +import WayofTime.bloodmagic.routing.*; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.items.IItemHandler; -import WayofTime.bloodmagic.item.routing.IFluidFilterProvider; -import WayofTime.bloodmagic.item.routing.IItemFilterProvider; -import WayofTime.bloodmagic.routing.DefaultItemFilter; -import WayofTime.bloodmagic.routing.IFluidFilter; -import WayofTime.bloodmagic.routing.IInputFluidRoutingNode; -import WayofTime.bloodmagic.routing.IInputItemRoutingNode; -import WayofTime.bloodmagic.routing.IItemFilter; -import WayofTime.bloodmagic.util.Utils; -public class TileInputRoutingNode extends TileFilteredRoutingNode implements IInputItemRoutingNode, IInputFluidRoutingNode -{ - public TileInputRoutingNode() - { +public class TileInputRoutingNode extends TileFilteredRoutingNode implements IInputItemRoutingNode, IInputFluidRoutingNode { + public TileInputRoutingNode() { super(6, "inputNode"); } @Override - public boolean isInput(EnumFacing side) - { + public boolean isInput(EnumFacing side) { return true; } @Override - public IItemFilter getInputFilterForSide(EnumFacing side) - { + public IItemFilter getInputFilterForSide(EnumFacing side) { TileEntity tile = getWorld().getTileEntity(pos.offset(side)); - if (tile != null) - { + if (tile != null) { IItemHandler handler = Utils.getInventory(tile, side.getOpposite()); - if (handler != null) - { + if (handler != null) { ItemStack filterStack = this.getFilterStack(side); - if (filterStack.isEmpty()) - { + if (filterStack.isEmpty()) { IItemFilter filter = new DefaultItemFilter(); filter.initializeFilter(null, tile, handler, false); return filter; - } else if (!(filterStack.getItem() instanceof IItemFilterProvider)) - { + } else if (!(filterStack.getItem() instanceof IItemFilterProvider)) { return null; } @@ -58,21 +46,17 @@ public class TileInputRoutingNode extends TileFilteredRoutingNode implements IIn } @Override - public boolean isFluidInput(EnumFacing side) - { + public boolean isFluidInput(EnumFacing side) { return true; } @Override - public IFluidFilter getInputFluidFilterForSide(EnumFacing side) - { + public IFluidFilter getInputFluidFilterForSide(EnumFacing side) { TileEntity tile = getWorld().getTileEntity(pos.offset(side)); - if (tile != null && tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) - { + if (tile != null && tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) { IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side); ItemStack filterStack = this.getFilterStack(side); - if (filterStack == null || !(filterStack.getItem() instanceof IFluidFilterProvider)) - { + if (filterStack == null || !(filterStack.getItem() instanceof IFluidFilterProvider)) { return null; } @@ -83,8 +67,7 @@ public class TileInputRoutingNode extends TileFilteredRoutingNode implements IIn } @Override - public boolean isTankConnectedToSide(EnumFacing side) - { + public boolean isTankConnectedToSide(EnumFacing side) { return true; } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/routing/TileItemRoutingNode.java b/src/main/java/WayofTime/bloodmagic/tile/routing/TileItemRoutingNode.java index 01ef2372..6c598390 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/routing/TileItemRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/routing/TileItemRoutingNode.java @@ -1,9 +1,7 @@ package WayofTime.bloodmagic.tile.routing; -public class TileItemRoutingNode extends TileRoutingNode -{ - public TileItemRoutingNode() - { +public class TileItemRoutingNode extends TileRoutingNode { + public TileItemRoutingNode() { super(0, "itemNode"); } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/routing/TileMasterRoutingNode.java b/src/main/java/WayofTime/bloodmagic/tile/routing/TileMasterRoutingNode.java index 2344057c..cbe898e4 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/routing/TileMasterRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/routing/TileMasterRoutingNode.java @@ -1,12 +1,10 @@ package WayofTime.bloodmagic.tile.routing; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.TreeMap; - +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; +import WayofTime.bloodmagic.routing.*; +import WayofTime.bloodmagic.tile.TileInventory; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; @@ -14,42 +12,26 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -import WayofTime.bloodmagic.routing.IFluidFilter; -import WayofTime.bloodmagic.routing.IInputFluidRoutingNode; -import WayofTime.bloodmagic.routing.IInputItemRoutingNode; -import WayofTime.bloodmagic.routing.IItemFilter; -import WayofTime.bloodmagic.routing.IMasterRoutingNode; -import WayofTime.bloodmagic.routing.IOutputFluidRoutingNode; -import WayofTime.bloodmagic.routing.IOutputItemRoutingNode; -import WayofTime.bloodmagic.routing.IRoutingNode; -import WayofTime.bloodmagic.routing.NodeHelper; -import WayofTime.bloodmagic.tile.TileInventory; -public class TileMasterRoutingNode extends TileInventory implements IMasterRoutingNode, ITickable -{ +import java.util.*; +import java.util.Map.Entry; + +public class TileMasterRoutingNode extends TileInventory implements IMasterRoutingNode, ITickable { + public static final int tickRate = 20; private int currentInput; - - public TileMasterRoutingNode() - { - super(0, "masterRoutingNode"); - } - // A list of connections private TreeMap> connectionMap = new TreeMap>(); private List generalNodeList = new LinkedList(); private List outputNodeList = new LinkedList(); private List inputNodeList = new LinkedList(); - public static final int tickRate = 20; + public TileMasterRoutingNode() { + super(0, "masterRoutingNode"); + } @Override - public void update() - { - if (!getWorld().isRemote) - { + public void update() { + if (!getWorld().isRemote) { // currentInput = getWorld().isBlockIndirectlyGettingPowered(pos); currentInput = getWorld().getStrongPower(pos); @@ -64,31 +46,23 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti Map> outputMap = new TreeMap>(); Map> outputFluidMap = new TreeMap>(); - for (BlockPos outputPos : outputNodeList) - { + for (BlockPos outputPos : outputNodeList) { TileEntity outputTile = getWorld().getTileEntity(outputPos); - if (this.isConnected(new LinkedList(), outputPos)) - { - if (outputTile instanceof IOutputItemRoutingNode) - { + if (this.isConnected(new LinkedList(), outputPos)) { + if (outputTile instanceof IOutputItemRoutingNode) { IOutputItemRoutingNode outputNode = (IOutputItemRoutingNode) outputTile; - for (EnumFacing facing : EnumFacing.VALUES) - { - if (!outputNode.isInventoryConnectedToSide(facing) || !outputNode.isOutput(facing)) - { + for (EnumFacing facing : EnumFacing.VALUES) { + if (!outputNode.isInventoryConnectedToSide(facing) || !outputNode.isOutput(facing)) { continue; } IItemFilter filter = outputNode.getOutputFilterForSide(facing); - if (filter != null) - { + if (filter != null) { int priority = outputNode.getPriority(facing); - if (outputMap.containsKey(priority)) - { + if (outputMap.containsKey(priority)) { outputMap.get(priority).add(filter); - } else - { + } else { List filterList = new LinkedList(); filterList.add(filter); outputMap.put(priority, filterList); @@ -97,26 +71,20 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } } - if (outputTile instanceof IOutputFluidRoutingNode) - { + if (outputTile instanceof IOutputFluidRoutingNode) { IOutputFluidRoutingNode outputNode = (IOutputFluidRoutingNode) outputTile; - for (EnumFacing facing : EnumFacing.VALUES) - { - if (!outputNode.isTankConnectedToSide(facing) || !outputNode.isFluidOutput(facing)) - { + for (EnumFacing facing : EnumFacing.VALUES) { + if (!outputNode.isTankConnectedToSide(facing) || !outputNode.isFluidOutput(facing)) { continue; } IFluidFilter filter = outputNode.getOutputFluidFilterForSide(facing); - if (filter != null) - { + if (filter != null) { int priority = outputNode.getPriority(facing); - if (outputMap.containsKey(priority)) - { + if (outputMap.containsKey(priority)) { outputFluidMap.get(priority).add(filter); - } else - { + } else { List filterList = new LinkedList(); filterList.add(filter); outputFluidMap.put(priority, filterList); @@ -130,31 +98,23 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti Map> inputMap = new TreeMap>(); Map> inputFluidMap = new TreeMap>(); - for (BlockPos inputPos : inputNodeList) - { + for (BlockPos inputPos : inputNodeList) { TileEntity inputTile = getWorld().getTileEntity(inputPos); - if (this.isConnected(new LinkedList(), inputPos)) - { - if (inputTile instanceof IInputItemRoutingNode) - { + if (this.isConnected(new LinkedList(), inputPos)) { + if (inputTile instanceof IInputItemRoutingNode) { IInputItemRoutingNode inputNode = (IInputItemRoutingNode) inputTile; - for (EnumFacing facing : EnumFacing.VALUES) - { - if (!inputNode.isInventoryConnectedToSide(facing) || !inputNode.isInput(facing)) - { + for (EnumFacing facing : EnumFacing.VALUES) { + if (!inputNode.isInventoryConnectedToSide(facing) || !inputNode.isInput(facing)) { continue; } IItemFilter filter = inputNode.getInputFilterForSide(facing); - if (filter != null) - { + if (filter != null) { int priority = inputNode.getPriority(facing); - if (inputMap.containsKey(priority)) - { + if (inputMap.containsKey(priority)) { inputMap.get(priority).add(filter); - } else - { + } else { List filterList = new LinkedList(); filterList.add(filter); inputMap.put(priority, filterList); @@ -163,26 +123,20 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } } - if (inputTile instanceof IInputFluidRoutingNode) - { + if (inputTile instanceof IInputFluidRoutingNode) { IInputFluidRoutingNode inputNode = (IInputFluidRoutingNode) inputTile; - for (EnumFacing facing : EnumFacing.VALUES) - { - if (!inputNode.isTankConnectedToSide(facing) || !inputNode.isFluidInput(facing)) - { + for (EnumFacing facing : EnumFacing.VALUES) { + if (!inputNode.isTankConnectedToSide(facing) || !inputNode.isFluidInput(facing)) { continue; } IFluidFilter filter = inputNode.getInputFluidFilterForSide(facing); - if (filter != null) - { + if (filter != null) { int priority = inputNode.getPriority(facing); - if (inputMap.containsKey(priority)) - { + if (inputMap.containsKey(priority)) { inputFluidMap.get(priority).add(filter); - } else - { + } else { List filterList = new LinkedList(); filterList.add(filter); inputFluidMap.put(priority, filterList); @@ -196,19 +150,14 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti int maxTransfer = this.getMaxTransferForDemonWill(WorldDemonWillHandler.getCurrentWill(getWorld(), pos, EnumDemonWillType.DEFAULT)); int maxFluidTransfer = 1000; - for (Entry> outputEntry : outputMap.entrySet()) - { + for (Entry> outputEntry : outputMap.entrySet()) { List outputList = outputEntry.getValue(); - for (IItemFilter outputFilter : outputList) - { - for (Entry> inputEntry : inputMap.entrySet()) - { + for (IItemFilter outputFilter : outputList) { + for (Entry> inputEntry : inputMap.entrySet()) { List inputList = inputEntry.getValue(); - for (IItemFilter inputFilter : inputList) - { + for (IItemFilter inputFilter : inputList) { maxTransfer -= inputFilter.transferThroughInputFilter(outputFilter, maxTransfer); - if (maxTransfer <= 0) - { + if (maxTransfer <= 0) { return; } } @@ -216,19 +165,14 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } } - for (Entry> outputEntry : outputFluidMap.entrySet()) - { + for (Entry> outputEntry : outputFluidMap.entrySet()) { List outputList = outputEntry.getValue(); - for (IFluidFilter outputFilter : outputList) - { - for (Entry> inputEntry : inputFluidMap.entrySet()) - { + for (IFluidFilter outputFilter : outputList) { + for (Entry> inputEntry : inputFluidMap.entrySet()) { List inputList = inputEntry.getValue(); - for (IFluidFilter inputFilter : inputList) - { + for (IFluidFilter inputFilter : inputList) { maxFluidTransfer -= inputFilter.transferThroughInputFilter(outputFilter, maxFluidTransfer); - if (maxFluidTransfer <= 0) - { + if (maxFluidTransfer <= 0) { return; } } @@ -237,18 +181,15 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } } - public int getMaxTransferForDemonWill(double will) - { + public int getMaxTransferForDemonWill(double will) { return 8; } @Override - public NBTTagCompound serialize(NBTTagCompound tag) - { + public NBTTagCompound serialize(NBTTagCompound tag) { super.serialize(tag); NBTTagList tags = new NBTTagList(); - for (BlockPos pos : generalNodeList) - { + for (BlockPos pos : generalNodeList) { NBTTagCompound posTag = new NBTTagCompound(); posTag.setInteger(Constants.NBT.X_COORD, pos.getX()); posTag.setInteger(Constants.NBT.Y_COORD, pos.getY()); @@ -258,8 +199,7 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti tag.setTag(Constants.NBT.ROUTING_MASTER_GENERAL, tags); tags = new NBTTagList(); - for (BlockPos pos : inputNodeList) - { + for (BlockPos pos : inputNodeList) { NBTTagCompound posTag = new NBTTagCompound(); posTag.setInteger(Constants.NBT.X_COORD, pos.getX()); posTag.setInteger(Constants.NBT.Y_COORD, pos.getY()); @@ -269,8 +209,7 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti tag.setTag(Constants.NBT.ROUTING_MASTER_INPUT, tags); tags = new NBTTagList(); - for (BlockPos pos : outputNodeList) - { + for (BlockPos pos : outputNodeList) { NBTTagCompound posTag = new NBTTagCompound(); posTag.setInteger(Constants.NBT.X_COORD, pos.getX()); posTag.setInteger(Constants.NBT.Y_COORD, pos.getY()); @@ -282,29 +221,25 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } @Override - public void deserialize(NBTTagCompound tag) - { + public void deserialize(NBTTagCompound tag) { super.deserialize(tag); NBTTagList tags = tag.getTagList(Constants.NBT.ROUTING_MASTER_GENERAL, 10); - for (int i = 0; i < tags.tagCount(); i++) - { + for (int i = 0; i < tags.tagCount(); i++) { NBTTagCompound blockTag = tags.getCompoundTagAt(i); BlockPos newPos = new BlockPos(blockTag.getInteger(Constants.NBT.X_COORD), blockTag.getInteger(Constants.NBT.Y_COORD), blockTag.getInteger(Constants.NBT.Z_COORD)); generalNodeList.add(newPos); } tags = tag.getTagList(Constants.NBT.ROUTING_MASTER_INPUT, 10); - for (int i = 0; i < tags.tagCount(); i++) - { + for (int i = 0; i < tags.tagCount(); i++) { NBTTagCompound blockTag = tags.getCompoundTagAt(i); BlockPos newPos = new BlockPos(blockTag.getInteger(Constants.NBT.X_COORD), blockTag.getInteger(Constants.NBT.Y_COORD), blockTag.getInteger(Constants.NBT.Z_COORD)); inputNodeList.add(newPos); } tags = tag.getTagList(Constants.NBT.ROUTING_MASTER_OUTPUT, 10); - for (int i = 0; i < tags.tagCount(); i++) - { + for (int i = 0; i < tags.tagCount(); i++) { NBTTagCompound blockTag = tags.getCompoundTagAt(i); BlockPos newPos = new BlockPos(blockTag.getInteger(Constants.NBT.X_COORD), blockTag.getInteger(Constants.NBT.Y_COORD), blockTag.getInteger(Constants.NBT.Z_COORD)); outputNodeList.add(newPos); @@ -312,16 +247,14 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } @Override - public boolean isConnected(List path, BlockPos nodePos) - { + public boolean isConnected(List path, BlockPos nodePos) { //TODO: Figure out how to make it so the path is obtained // if (!connectionMap.containsKey(nodePos)) // { // return false; // } TileEntity tile = getWorld().getTileEntity(nodePos); - if (!(tile instanceof IRoutingNode)) - { + if (!(tile instanceof IRoutingNode)) { // connectionMap.remove(nodePos); return false; } @@ -330,22 +263,17 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti List connectionList = node.getConnected(); // List testPath = path.subList(0, path.size()); path.add(nodePos); - for (BlockPos testPos : connectionList) - { - if (path.contains(testPos)) - { + for (BlockPos testPos : connectionList) { + if (path.contains(testPos)) { continue; } - if (testPos.equals(this.getPos()) && node.isConnectionEnabled(testPos)) - { + if (testPos.equals(this.getPos()) && node.isConnectionEnabled(testPos)) { // path.clear(); // path.addAll(testPath); return true; - } else if (NodeHelper.isNodeConnectionEnabled(getWorld(), node, testPos)) - { - if (isConnected(path, testPos)) - { + } else if (NodeHelper.isNodeConnectionEnabled(getWorld(), node, testPos)) { + if (isConnected(path, testPos)) { // path.clear(); // path.addAll(testPath); return true; @@ -357,56 +285,44 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } @Override - public boolean isConnectionEnabled(BlockPos testPos) - { + public boolean isConnectionEnabled(BlockPos testPos) { return currentInput <= 0; } @Override - public void addNodeToList(IRoutingNode node) - { + public void addNodeToList(IRoutingNode node) { BlockPos newPos = node.getBlockPos(); - if (!generalNodeList.contains(newPos)) - { + if (!generalNodeList.contains(newPos)) { generalNodeList.add(newPos); } - if (node instanceof IInputItemRoutingNode && !inputNodeList.contains(newPos)) - { + if (node instanceof IInputItemRoutingNode && !inputNodeList.contains(newPos)) { inputNodeList.add(newPos); } - if (node instanceof IOutputItemRoutingNode && !outputNodeList.contains(newPos)) - { + if (node instanceof IOutputItemRoutingNode && !outputNodeList.contains(newPos)) { outputNodeList.add(newPos); } } @Override - public void addConnections(BlockPos pos, List connectionList) - { - for (BlockPos testPos : connectionList) - { + public void addConnections(BlockPos pos, List connectionList) { + for (BlockPos testPos : connectionList) { addConnection(pos, testPos); } } @Override - public void addConnection(BlockPos pos1, BlockPos pos2) - { - if (connectionMap.containsKey(pos1) && !connectionMap.get(pos1).contains(pos2)) - { + public void addConnection(BlockPos pos1, BlockPos pos2) { + if (connectionMap.containsKey(pos1) && !connectionMap.get(pos1).contains(pos2)) { connectionMap.get(pos1).add(pos2); - } else - { + } else { List list = new LinkedList(); list.add(pos2); connectionMap.put(pos1, list); } - if (connectionMap.containsKey(pos2) && !connectionMap.get(pos2).contains(pos1)) - { + if (connectionMap.containsKey(pos2) && !connectionMap.get(pos2).contains(pos1)) { connectionMap.get(pos2).add(pos1); - } else - { + } else { List list = new LinkedList(); list.add(pos1); connectionMap.put(pos2, list); @@ -414,84 +330,69 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } @Override - public void removeConnection(BlockPos pos1, BlockPos pos2) - { - if (connectionMap.containsKey(pos1)) - { + public void removeConnection(BlockPos pos1, BlockPos pos2) { + if (connectionMap.containsKey(pos1)) { List posList = connectionMap.get(pos1); posList.remove(pos2); - if (posList.isEmpty()) - { + if (posList.isEmpty()) { connectionMap.remove(pos1); } } - if (connectionMap.containsKey(pos2)) - { + if (connectionMap.containsKey(pos2)) { List posList = connectionMap.get(pos2); posList.remove(pos1); - if (posList.isEmpty()) - { + if (posList.isEmpty()) { connectionMap.remove(pos2); } } } @Override - public void connectMasterToRemainingNode(World world, List alreadyChecked, IMasterRoutingNode master) - { + public void connectMasterToRemainingNode(World world, List alreadyChecked, IMasterRoutingNode master) { return; } @Override - public BlockPos getBlockPos() - { + public BlockPos getBlockPos() { return this.getPos(); } @Override - public List getConnected() - { + public List getConnected() { return new LinkedList(); } @Override - public BlockPos getMasterPos() - { + public BlockPos getMasterPos() { return this.getPos(); } @Override - public boolean isMaster(IMasterRoutingNode master) - { + public boolean isMaster(IMasterRoutingNode master) { return false; } @Override - public void addConnection(BlockPos pos1) - { + public void addConnection(BlockPos pos1) { // Empty } @Override - public void removeConnection(BlockPos pos1) - { + public void removeConnection(BlockPos pos1) { generalNodeList.remove(pos1); inputNodeList.remove(pos1); outputNodeList.remove(pos1); } @Override - public void removeAllConnections() - { + public void removeAllConnections() { List list = generalNodeList.subList(0, generalNodeList.size()); Iterator itr = list.iterator(); - while (itr.hasNext()) - { + while (itr.hasNext()) { BlockPos testPos = itr.next(); TileEntity tile = getWorld().getTileEntity(testPos); - if (tile instanceof IRoutingNode) - { + if (tile instanceof IRoutingNode) { ((IRoutingNode) tile).removeConnection(pos); getWorld().notifyBlockUpdate(getPos(), getWorld().getBlockState(testPos), getWorld().getBlockState(testPos), 3); } diff --git a/src/main/java/WayofTime/bloodmagic/tile/routing/TileOutputRoutingNode.java b/src/main/java/WayofTime/bloodmagic/tile/routing/TileOutputRoutingNode.java index 3a98ed33..9c57f30c 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/routing/TileOutputRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/routing/TileOutputRoutingNode.java @@ -1,51 +1,39 @@ package WayofTime.bloodmagic.tile.routing; +import WayofTime.bloodmagic.item.routing.IFluidFilterProvider; +import WayofTime.bloodmagic.item.routing.IItemFilterProvider; +import WayofTime.bloodmagic.routing.*; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.items.IItemHandler; -import WayofTime.bloodmagic.item.routing.IFluidFilterProvider; -import WayofTime.bloodmagic.item.routing.IItemFilterProvider; -import WayofTime.bloodmagic.routing.DefaultItemFilter; -import WayofTime.bloodmagic.routing.IFluidFilter; -import WayofTime.bloodmagic.routing.IItemFilter; -import WayofTime.bloodmagic.routing.IOutputFluidRoutingNode; -import WayofTime.bloodmagic.routing.IOutputItemRoutingNode; -import WayofTime.bloodmagic.util.Utils; -public class TileOutputRoutingNode extends TileFilteredRoutingNode implements IOutputItemRoutingNode, IOutputFluidRoutingNode -{ - public TileOutputRoutingNode() - { +public class TileOutputRoutingNode extends TileFilteredRoutingNode implements IOutputItemRoutingNode, IOutputFluidRoutingNode { + public TileOutputRoutingNode() { super(6, "outputNode"); } @Override - public boolean isOutput(EnumFacing side) - { + public boolean isOutput(EnumFacing side) { return true; } @Override - public IItemFilter getOutputFilterForSide(EnumFacing side) - { + public IItemFilter getOutputFilterForSide(EnumFacing side) { TileEntity tile = getWorld().getTileEntity(pos.offset(side)); - if (tile != null) - { + if (tile != null) { IItemHandler handler = Utils.getInventory(tile, side.getOpposite()); - if (handler != null) - { + if (handler != null) { ItemStack filterStack = this.getFilterStack(side); - if (filterStack.isEmpty()) - { + if (filterStack.isEmpty()) { IItemFilter filter = new DefaultItemFilter(); filter.initializeFilter(null, tile, handler, true); return filter; - } else if (!(filterStack.getItem() instanceof IItemFilterProvider)) - { + } else if (!(filterStack.getItem() instanceof IItemFilterProvider)) { return null; } @@ -58,21 +46,17 @@ public class TileOutputRoutingNode extends TileFilteredRoutingNode implements IO } @Override - public boolean isFluidOutput(EnumFacing side) - { + public boolean isFluidOutput(EnumFacing side) { return true; } @Override - public IFluidFilter getOutputFluidFilterForSide(EnumFacing side) - { + public IFluidFilter getOutputFluidFilterForSide(EnumFacing side) { TileEntity tile = getWorld().getTileEntity(pos.offset(side)); - if (tile != null && tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) - { + if (tile != null && tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) { IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side); ItemStack filterStack = this.getFilterStack(side); - if (filterStack == null || !(filterStack.getItem() instanceof IFluidFilterProvider)) - { + if (filterStack == null || !(filterStack.getItem() instanceof IFluidFilterProvider)) { return null; } @@ -83,8 +67,7 @@ public class TileOutputRoutingNode extends TileFilteredRoutingNode implements IO } @Override - public boolean isTankConnectedToSide(EnumFacing side) - { + public boolean isTankConnectedToSide(EnumFacing side) { return true; } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/routing/TileRoutingNode.java b/src/main/java/WayofTime/bloodmagic/tile/routing/TileRoutingNode.java index ac00e276..a8b7aa2c 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/routing/TileRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/routing/TileRoutingNode.java @@ -1,8 +1,10 @@ package WayofTime.bloodmagic.tile.routing; -import java.util.LinkedList; -import java.util.List; - +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.routing.IItemRoutingNode; +import WayofTime.bloodmagic.routing.IMasterRoutingNode; +import WayofTime.bloodmagic.routing.IRoutingNode; +import WayofTime.bloodmagic.tile.TileInventory; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; @@ -12,37 +14,29 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.routing.IItemRoutingNode; -import WayofTime.bloodmagic.routing.IMasterRoutingNode; -import WayofTime.bloodmagic.routing.IRoutingNode; -import WayofTime.bloodmagic.tile.TileInventory; -public class TileRoutingNode extends TileInventory implements IRoutingNode, IItemRoutingNode, ITickable -{ +import java.util.LinkedList; +import java.util.List; + +public class TileRoutingNode extends TileInventory implements IRoutingNode, IItemRoutingNode, ITickable { private int currentInput; + private BlockPos masterPos = BlockPos.ORIGIN; + private List connectionList = new LinkedList(); - public TileRoutingNode(int size, String name) - { + public TileRoutingNode(int size, String name) { super(size, name); } @Override - public void update() - { - if (!getWorld().isRemote) - { + public void update() { + if (!getWorld().isRemote) { currentInput = getWorld().isBlockIndirectlyGettingPowered(pos); // currentInput = getWorld().getStrongPower(pos); } } - private BlockPos masterPos = BlockPos.ORIGIN; - private List connectionList = new LinkedList(); - @Override - public NBTTagCompound serialize(NBTTagCompound tag) - { + public NBTTagCompound serialize(NBTTagCompound tag) { super.serialize(tag); NBTTagCompound masterTag = new NBTTagCompound(); masterTag.setInteger(Constants.NBT.X_COORD, masterPos.getX()); @@ -51,8 +45,7 @@ public class TileRoutingNode extends TileInventory implements IRoutingNode, IIte tag.setTag(Constants.NBT.ROUTING_MASTER, masterTag); NBTTagList tags = new NBTTagList(); - for (BlockPos pos : connectionList) - { + for (BlockPos pos : connectionList) { NBTTagCompound posTag = new NBTTagCompound(); posTag.setInteger(Constants.NBT.X_COORD, pos.getX()); posTag.setInteger(Constants.NBT.Y_COORD, pos.getY()); @@ -64,16 +57,14 @@ public class TileRoutingNode extends TileInventory implements IRoutingNode, IIte } @Override - public void deserialize(NBTTagCompound tag) - { + public void deserialize(NBTTagCompound tag) { super.deserialize(tag); connectionList.clear(); NBTTagCompound masterTag = tag.getCompoundTag(Constants.NBT.ROUTING_MASTER); masterPos = new BlockPos(masterTag.getInteger(Constants.NBT.X_COORD), masterTag.getInteger(Constants.NBT.Y_COORD), masterTag.getInteger(Constants.NBT.Z_COORD)); NBTTagList tags = tag.getTagList(Constants.NBT.ROUTING_CONNECTION, 10); - for (int i = 0; i < tags.tagCount(); i++) - { + for (int i = 0; i < tags.tagCount(); i++) { NBTTagCompound blockTag = tags.getCompoundTagAt(i); BlockPos newPos = new BlockPos(blockTag.getInteger(Constants.NBT.X_COORD), blockTag.getInteger(Constants.NBT.Y_COORD), blockTag.getInteger(Constants.NBT.Z_COORD)); connectionList.add(newPos); @@ -81,18 +72,14 @@ public class TileRoutingNode extends TileInventory implements IRoutingNode, IIte } @Override - public void removeAllConnections() - { + public void removeAllConnections() { TileEntity testTile = getWorld().getTileEntity(getMasterPos()); - if (testTile instanceof IMasterRoutingNode) - { + if (testTile instanceof IMasterRoutingNode) { ((IMasterRoutingNode) testTile).removeConnection(pos); // Remove this node from the master } - for (BlockPos testPos : connectionList) - { + for (BlockPos testPos : connectionList) { TileEntity tile = getWorld().getTileEntity(testPos); - if (tile instanceof IRoutingNode) - { + if (tile instanceof IRoutingNode) { ((IRoutingNode) tile).removeConnection(pos); getWorld().notifyBlockUpdate(getPos(), getWorld().getBlockState(testPos), getWorld().getBlockState(testPos), 3); } @@ -102,20 +89,16 @@ public class TileRoutingNode extends TileInventory implements IRoutingNode, IIte } @Override - public void connectMasterToRemainingNode(World world, List alreadyChecked, IMasterRoutingNode master) - { + public void connectMasterToRemainingNode(World world, List alreadyChecked, IMasterRoutingNode master) { this.masterPos = master.getBlockPos(); List connectedList = this.getConnected(); - for (BlockPos testPos : connectedList) - { - if (alreadyChecked.contains(testPos)) - { + for (BlockPos testPos : connectedList) { + if (alreadyChecked.contains(testPos)) { continue; } alreadyChecked.add(testPos); TileEntity tile = world.getTileEntity(testPos); - if (!(tile instanceof IRoutingNode)) - { + if (!(tile instanceof IRoutingNode)) { continue; } IRoutingNode node = (IRoutingNode) tile; @@ -130,77 +113,64 @@ public class TileRoutingNode extends TileInventory implements IRoutingNode, IIte } @Override - public BlockPos getBlockPos() - { + public BlockPos getBlockPos() { return this.getPos(); } @Override - public List getConnected() - { + public List getConnected() { return connectionList; } @Override - public BlockPos getMasterPos() - { + public BlockPos getMasterPos() { return masterPos; } @Override - public boolean isMaster(IMasterRoutingNode master) - { + public boolean isMaster(IMasterRoutingNode master) { BlockPos checkPos = master.getBlockPos(); return checkPos.equals(getMasterPos()); } @Override - public boolean isConnectionEnabled(BlockPos testPos) - { + public boolean isConnectionEnabled(BlockPos testPos) { return currentInput <= 0; } @Override - public void addConnection(BlockPos pos1) - { - if (!connectionList.contains(pos1)) - { + public void addConnection(BlockPos pos1) { + if (!connectionList.contains(pos1)) { getWorld().notifyBlockUpdate(getPos(), getWorld().getBlockState(getPos()), getWorld().getBlockState(getPos()), 3); connectionList.add(pos1); } } @Override - public void removeConnection(BlockPos pos1) - { - if (connectionList.contains(pos1)) - { + public void removeConnection(BlockPos pos1) { + if (connectionList.contains(pos1)) { connectionList.remove(pos1); getWorld().notifyBlockUpdate(getPos(), getWorld().getBlockState(getPos()), getWorld().getBlockState(getPos()), 3); } - if (pos1.equals(masterPos)) - { + if (pos1.equals(masterPos)) { this.masterPos = BlockPos.ORIGIN; } } @Override - public boolean isInventoryConnectedToSide(EnumFacing side) - { + public boolean isInventoryConnectedToSide(EnumFacing side) { return false; } @Override - public int getPriority(EnumFacing side) - { + public int getPriority(EnumFacing side) { return 0; } @Override @SideOnly(Side.CLIENT) - public double getMaxRenderDistanceSquared() - { + public double getMaxRenderDistanceSquared() { return 10000; } } diff --git a/src/main/java/WayofTime/bloodmagic/util/ChatUtil.java b/src/main/java/WayofTime/bloodmagic/util/ChatUtil.java index ba5ff465..5ff4bd36 100644 --- a/src/main/java/WayofTime/bloodmagic/util/ChatUtil.java +++ b/src/main/java/WayofTime/bloodmagic/util/ChatUtil.java @@ -15,20 +15,16 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -public class ChatUtil -{ +public class ChatUtil { private static final int DELETION_ID = 2525277; private static int lastAdded; - private static void sendNoSpamMessages(ITextComponent[] messages) - { + private static void sendNoSpamMessages(ITextComponent[] messages) { GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); - for (int i = DELETION_ID + messages.length - 1; i <= lastAdded; i++) - { + for (int i = DELETION_ID + messages.length - 1; i <= lastAdded; i++) { chat.deleteChatLine(i); } - for (int i = 0; i < messages.length; i++) - { + for (int i = 0; i < messages.length; i++) { chat.printChatMessageWithOptionalDeletion(messages[i], DELETION_ID + i); } lastAdded = DELETION_ID + messages.length - 1; @@ -37,25 +33,20 @@ public class ChatUtil /** * Returns a standard {@link TextComponentString} for the given * {@link String} . - * - * @param s - * The string to wrap. - * + * + * @param s The string to wrap. * @return An {@link ITextComponent} containing the string. */ - public static ITextComponent wrap(String s) - { + public static ITextComponent wrap(String s) { return new TextComponentString(s); } /** * @see #wrap(String) */ - public static ITextComponent[] wrap(String... s) - { + public static ITextComponent[] wrap(String... s) { ITextComponent[] ret = new ITextComponent[s.length]; - for (int i = 0; i < ret.length; i++) - { + for (int i = 0; i < ret.length; i++) { ret[i] = wrap(s[i]); } return ret; @@ -64,97 +55,80 @@ public class ChatUtil /** * Returns a translatable chat component for the given string and format * args. - * - * @param s - * The string to format - * @param args - * The args to apply to the format + * + * @param s The string to format + * @param args The args to apply to the format */ - public static ITextComponent wrapFormatted(String s, Object... args) - { + public static ITextComponent wrapFormatted(String s, Object... args) { return new TextComponentTranslation(s, args); } /** * Simply sends the passed lines to the player in a chat message. - * - * @param player - * The player to send the chat to - * @param lines - * The lines to send + * + * @param player The player to send the chat to + * @param lines The lines to send */ - public static void sendChat(EntityPlayer player, String... lines) - { + public static void sendChat(EntityPlayer player, String... lines) { sendChat(player, wrap(lines)); } /** * Localizes the lines before sending them. - * + * * @see #sendChat(EntityPlayer, String...) */ - public static void sendChatUnloc(EntityPlayer player, String... unlocLines) - { + public static void sendChatUnloc(EntityPlayer player, String... unlocLines) { sendChat(player, TextHelper.localizeAll(unlocLines)); } /** * Sends all passed chat components to the player. - * - * @param player - * The player to send the chat lines to. - * @param lines - * The {@link ITextComponent chat components} to send.yes + * + * @param player The player to send the chat lines to. + * @param lines The {@link ITextComponent chat components} to send.yes */ - public static void sendChat(EntityPlayer player, ITextComponent... lines) - { - for (ITextComponent c : lines) - { + public static void sendChat(EntityPlayer player, ITextComponent... lines) { + for (ITextComponent c : lines) { player.sendMessage(c); } } /** * Localizes the strings before sending them. - * + * * @see #sendNoSpamClient(String...) */ - public static void sendNoSpamClientUnloc(String... unlocLines) - { + public static void sendNoSpamClientUnloc(String... unlocLines) { sendNoSpamClient(TextHelper.localizeAll(unlocLines)); } /** * Same as {@link #sendNoSpamClient(ITextComponent...)}, but wraps the * Strings automatically. - * - * @param lines - * The chat lines to send - * + * + * @param lines The chat lines to send * @see #wrap(String) */ - public static void sendNoSpamClient(String... lines) - { + public static void sendNoSpamClient(String... lines) { sendNoSpamClient(wrap(lines)); } /** * Skips the packet sending, unsafe to call on servers. - * + * * @see #sendNoSpam(EntityPlayerMP, ITextComponent...) */ - public static void sendNoSpamClient(ITextComponent... lines) - { + public static void sendNoSpamClient(ITextComponent... lines) { sendNoSpamMessages(lines); } /** * Localizes the strings before sending them. - * + * * @see #sendNoSpam(EntityPlayer, String...) */ - public static void sendNoSpamUnloc(EntityPlayer player, String... unlocLines) - { + public static void sendNoSpamUnloc(EntityPlayer player, String... unlocLines) { sendNoSpam(player, TextHelper.localizeAll(unlocLines)); } @@ -162,32 +136,28 @@ public class ChatUtil * @see #wrap(String) * @see #sendNoSpam(EntityPlayer, ITextComponent...) */ - public static void sendNoSpam(EntityPlayer player, String... lines) - { + public static void sendNoSpam(EntityPlayer player, String... lines) { sendNoSpam(player, wrap(lines)); } /** * First checks if the player is instanceof {@link EntityPlayerMP} before * casting. - * + * * @see #sendNoSpam(EntityPlayerMP, ITextComponent...) */ - public static void sendNoSpam(EntityPlayer player, ITextComponent... lines) - { - if (player instanceof EntityPlayerMP) - { + public static void sendNoSpam(EntityPlayer player, ITextComponent... lines) { + if (player instanceof EntityPlayerMP) { sendNoSpam((EntityPlayerMP) player, lines); } } /** * Localizes the strings before sending them. - * + * * @see #sendNoSpam(EntityPlayerMP, String...) */ - public static void sendNoSpamUnloc(EntityPlayerMP player, String... unlocLines) - { + public static void sendNoSpamUnloc(EntityPlayerMP player, String... unlocLines) { sendNoSpam(player, TextHelper.localizeAll(unlocLines)); } @@ -195,73 +165,60 @@ public class ChatUtil * @see #wrap(String) * @see #sendNoSpam(EntityPlayerMP, ITextComponent...) */ - public static void sendNoSpam(EntityPlayerMP player, String... lines) - { + public static void sendNoSpam(EntityPlayerMP player, String... lines) { sendNoSpam(player, wrap(lines)); } /** * Sends a chat message to the client, deleting past messages also sent via * this method. - * + *

* Credit to RWTema for the idea - * - * @param player - * The player to send the chat message to - * @param lines - * The chat lines to send. + * + * @param player The player to send the chat message to + * @param lines The chat lines to send. */ - public static void sendNoSpam(EntityPlayerMP player, ITextComponent... lines) - { + public static void sendNoSpam(EntityPlayerMP player, ITextComponent... lines) { if (lines.length > 0) BloodMagicPacketHandler.INSTANCE.sendTo(new PacketNoSpamChat(lines), player); } /** * @author tterrag1098 - * + *

* Ripped from EnderCore (and slightly altered) */ - public static class PacketNoSpamChat implements IMessage - { + public static class PacketNoSpamChat implements IMessage { private ITextComponent[] chatLines; - public PacketNoSpamChat() - { + public PacketNoSpamChat() { chatLines = new ITextComponent[0]; } - private PacketNoSpamChat(ITextComponent... lines) - { + private PacketNoSpamChat(ITextComponent... lines) { // this is guaranteed to be >1 length by accessing methods this.chatLines = lines; } @Override - public void toBytes(ByteBuf buf) - { + public void toBytes(ByteBuf buf) { buf.writeInt(chatLines.length); - for (ITextComponent c : chatLines) - { + for (ITextComponent c : chatLines) { ByteBufUtils.writeUTF8String(buf, ITextComponent.Serializer.componentToJson(c)); } } @Override - public void fromBytes(ByteBuf buf) - { + public void fromBytes(ByteBuf buf) { chatLines = new ITextComponent[buf.readInt()]; - for (int i = 0; i < chatLines.length; i++) - { + for (int i = 0; i < chatLines.length; i++) { chatLines[i] = ITextComponent.Serializer.jsonToComponent(ByteBufUtils.readUTF8String(buf)); } } - public static class Handler implements IMessageHandler - { + public static class Handler implements IMessageHandler { @Override - public IMessage onMessage(final PacketNoSpamChat message, MessageContext ctx) - { + public IMessage onMessage(final PacketNoSpamChat message, MessageContext ctx) { Minecraft.getMinecraft().addScheduledTask(new Runnable() { @Override public void run() { diff --git a/src/main/java/WayofTime/bloodmagic/util/GhostItemHelper.java b/src/main/java/WayofTime/bloodmagic/util/GhostItemHelper.java index f70598e6..36b29da4 100644 --- a/src/main/java/WayofTime/bloodmagic/util/GhostItemHelper.java +++ b/src/main/java/WayofTime/bloodmagic/util/GhostItemHelper.java @@ -5,28 +5,23 @@ import WayofTime.bloodmagic.api.util.helper.NBTHelper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class GhostItemHelper -{ - public static void setItemGhostAmount(ItemStack stack, int amount) - { +public class GhostItemHelper { + public static void setItemGhostAmount(ItemStack stack, int amount) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); tag.setInteger(Constants.NBT.GHOST_STACK_SIZE, amount); } - public static int getItemGhostAmount(ItemStack stack) - { + public static int getItemGhostAmount(ItemStack stack) { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getInteger(Constants.NBT.GHOST_STACK_SIZE); } - public static boolean hasGhostAmount(ItemStack stack) - { - if (!stack.hasTagCompound()) - { + public static boolean hasGhostAmount(ItemStack stack) { + if (!stack.hasTagCompound()) { return false; } @@ -34,29 +29,25 @@ public class GhostItemHelper return tag.hasKey(Constants.NBT.GHOST_STACK_SIZE); } - public static void incrementGhostAmout(ItemStack stack, int value) - { + public static void incrementGhostAmout(ItemStack stack, int value) { int amount = getItemGhostAmount(stack); amount += value; setItemGhostAmount(stack, amount); } - public static void decrementGhostAmount(ItemStack stack, int value) - { + public static void decrementGhostAmount(ItemStack stack, int value) { int amount = getItemGhostAmount(stack); amount -= value; setItemGhostAmount(stack, amount); } - public static ItemStack getStackFromGhost(ItemStack ghostStack) - { + public static ItemStack getStackFromGhost(ItemStack ghostStack) { ItemStack newStack = ghostStack.copy(); NBTHelper.checkNBT(newStack); NBTTagCompound tag = newStack.getTagCompound(); int amount = getItemGhostAmount(ghostStack); tag.removeTag(Constants.NBT.GHOST_STACK_SIZE); - if (tag.hasNoTags()) - { + if (tag.hasNoTags()) { newStack.setTagCompound(null); } newStack.setCount(amount); diff --git a/src/main/java/WayofTime/bloodmagic/util/Utils.java b/src/main/java/WayofTime/bloodmagic/util/Utils.java index 9c4dbd68..b30a0ab0 100644 --- a/src/main/java/WayofTime/bloodmagic/util/Utils.java +++ b/src/main/java/WayofTime/bloodmagic/util/Utils.java @@ -1,13 +1,16 @@ package WayofTime.bloodmagic.util; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.Set; -import java.util.UUID; - -import javax.annotation.Nullable; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.BlockStack; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.altar.EnumAltarComponent; +import WayofTime.bloodmagic.api.iface.IDemonWillViewer; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; +import WayofTime.bloodmagic.network.BloodMagicPacketHandler; +import WayofTime.bloodmagic.network.PlayerVelocityPacketProcessor; +import WayofTime.bloodmagic.tile.TileInventory; +import com.google.common.collect.Iterables; import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; import net.minecraft.block.BlockPortal; @@ -50,33 +53,20 @@ import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.wrapper.InvWrapper; import net.minecraftforge.items.wrapper.PlayerMainInvWrapper; import net.minecraftforge.items.wrapper.SidedInvWrapper; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.BlockStack; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.altar.EnumAltarComponent; -import WayofTime.bloodmagic.api.iface.IDemonWillViewer; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.network.BloodMagicPacketHandler; -import WayofTime.bloodmagic.network.PlayerVelocityPacketProcessor; -import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; -import WayofTime.bloodmagic.tile.TileInventory; -import com.google.common.collect.Iterables; +import javax.annotation.Nullable; +import java.util.*; -public class Utils -{ - public static float addAbsorptionToMaximum(EntityLivingBase entity, float added, int maximum, int duration) - { +public class Utils { + public static float addAbsorptionToMaximum(EntityLivingBase entity, float added, int maximum, int duration) { float currentAmount = entity.getAbsorptionAmount(); added = Math.min(maximum - currentAmount, added); - if (added <= 0) - { + if (added <= 0) { return 0; } - if (duration > 0) - { + if (duration > 0) { int potionLevel = (int) ((currentAmount + added) / 4); entity.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, duration, potionLevel, true, false)); } @@ -86,27 +76,22 @@ public class Utils return added; } - public static boolean isImmuneToFireDamage(EntityLivingBase entity) - { + public static boolean isImmuneToFireDamage(EntityLivingBase entity) { return entity.isImmuneToFire() || entity.isPotionActive(MobEffects.FIRE_RESISTANCE); } - public static boolean isPlayerBesideSolidBlockFace(EntityPlayer player) - { + public static boolean isPlayerBesideSolidBlockFace(EntityPlayer player) { World world = player.getEntityWorld(); double minimumDistanceFromAxis = 0.7; BlockPos centralPos = player.getPosition(); - for (EnumFacing facing : EnumFacing.HORIZONTALS) - { + for (EnumFacing facing : EnumFacing.HORIZONTALS) { BlockPos offsetPos = centralPos.offset(facing); double distance = Math.min(offsetPos.getX() + 0.5 - player.posX, offsetPos.getZ() + 0.5 - player.posZ); - if (distance > minimumDistanceFromAxis) - { + if (distance > minimumDistanceFromAxis) { continue; } IBlockState state = world.getBlockState(offsetPos); - if (state.isSideSolid(world, offsetPos, facing.getOpposite())) - { + if (state.isSideSolid(world, offsetPos, facing.getOpposite())) { return true; } } @@ -114,20 +99,16 @@ public class Utils return false; } - public static boolean canPlayerSeeDemonWill(EntityPlayer player) - { + public static boolean canPlayerSeeDemonWill(EntityPlayer player) { IItemHandler inventory = new PlayerMainInvWrapper(player.inventory); - for (int i = 0; i < inventory.getSlots(); i++) - { + for (int i = 0; i < inventory.getSlots(); i++) { ItemStack stack = inventory.getStackInSlot(i); - if (stack.isEmpty()) - { + if (stack.isEmpty()) { continue; } - if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.getEntityWorld(), stack, player)) - { + if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.getEntityWorld(), stack, player)) { return true; } } @@ -135,71 +116,56 @@ public class Utils return false; } - public static boolean canEntitySeeBlock(World world, Entity entity, BlockPos pos) - { + public static boolean canEntitySeeBlock(World world, Entity entity, BlockPos pos) { 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.x, (float) relativePosition.y, (float) relativePosition.z); 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); return result == null || pos.equals(result.getBlockPos()); } - public static int plantSeedsInArea(World world, AxisAlignedBB aabb, int horizontalRadius, int verticalRadius) - { + public static int plantSeedsInArea(World world, AxisAlignedBB aabb, int horizontalRadius, int verticalRadius) { int placedBlocks = 0; List itemEntities = world.getEntitiesWithinAABB(EntityItem.class, aabb); - for (EntityItem itemEntity : itemEntities) - { + for (EntityItem itemEntity : itemEntities) { placedBlocks += plantEntityItem(itemEntity, horizontalRadius, verticalRadius); } return placedBlocks; } - public static int plantItemStack(World world, BlockPos centralPos, ItemStack stack, int horizontalRadius, int verticalRadius) - { - if (stack.isEmpty()) - { + public static int plantItemStack(World world, BlockPos centralPos, ItemStack stack, int horizontalRadius, int verticalRadius) { + if (stack.isEmpty()) { return 0; } Item item = stack.getItem(); - if (!(item instanceof IPlantable)) - { + if (!(item instanceof IPlantable)) { return 0; } int planted = 0; - for (int hR = 0; hR <= horizontalRadius; hR++) - { - for (int vR = 0; vR <= verticalRadius; vR++) - { - for (int i = -hR; i <= hR; i++) - { - for (int k = -hR; k <= hR; k++) - { - for (int j = -vR; j <= vR; j += 2 * vR + (vR > 0 ? 0 : 1)) - { - if (!(Math.abs(i) == hR || Math.abs(k) == hR)) - { + for (int hR = 0; hR <= horizontalRadius; hR++) { + for (int vR = 0; vR <= verticalRadius; vR++) { + for (int i = -hR; i <= hR; i++) { + for (int k = -hR; k <= hR; k++) { + for (int j = -vR; j <= vR; j += 2 * vR + (vR > 0 ? 0 : 1)) { + if (!(Math.abs(i) == hR || Math.abs(k) == hR)) { continue; } BlockPos newPos = centralPos.add(i, j, k); - if (world.isAirBlock(newPos)) - { + if (world.isAirBlock(newPos)) { BlockPos offsetPos = newPos.offset(EnumFacing.DOWN); IBlockState state = world.getBlockState(offsetPos); - if (state.getBlock().canSustainPlant(state, world, offsetPos, EnumFacing.UP, (IPlantable) item)) - { + if (state.getBlock().canSustainPlant(state, world, offsetPos, EnumFacing.UP, (IPlantable) item)) { 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.shrink(1); planted++; - if (stack.isEmpty() || stack.getCount() <= 0) - { + if (stack.isEmpty() || stack.getCount() <= 0) { return planted; } } @@ -213,10 +179,8 @@ public class Utils return planted; } - public static int plantEntityItem(EntityItem itemEntity, int horizontalRadius, int verticalRadius) - { - if (itemEntity == null || itemEntity.isDead) - { + public static int plantEntityItem(EntityItem itemEntity, int horizontalRadius, int verticalRadius) { + if (itemEntity == null || itemEntity.isDead) { return 0; } @@ -226,28 +190,23 @@ public class Utils int planted = plantItemStack(world, pos, stack, horizontalRadius, verticalRadius); - if (stack.isEmpty()) - { + if (stack.isEmpty()) { itemEntity.setDead(); } return planted; } - public static int getDemonWillResolution(EntityPlayer player) - { + public static int getDemonWillResolution(EntityPlayer player) { IItemHandler inventory = new PlayerMainInvWrapper(player.inventory); - for (int i = 0; i < inventory.getSlots(); i++) - { + for (int i = 0; i < inventory.getSlots(); i++) { ItemStack stack = inventory.getStackInSlot(i); - if (stack.isEmpty()) - { + if (stack.isEmpty()) { continue; } - if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.getEntityWorld(), stack, player)) - { + if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.getEntityWorld(), stack, player)) { return ((IDemonWillViewer) stack.getItem()).getDemonWillAuraResolution(player.getEntityWorld(), stack, player); } } @@ -255,8 +214,7 @@ public class Utils return 1; } - public static NBTTagCompound getPersistentDataTag(EntityPlayer player) - { + public static NBTTagCompound getPersistentDataTag(EntityPlayer player) { NBTTagCompound forgeData = player.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); NBTTagCompound beaconData = forgeData.getCompoundTag("BloodMagic"); @@ -269,51 +227,40 @@ public class Utils return beaconData; } - public static void setPlayerSpeedFromServer(EntityPlayer player, double motionX, double motionY, double motionZ) - { - if (!player.getEntityWorld().isRemote && player instanceof EntityPlayerMP) - { + public static void setPlayerSpeedFromServer(EntityPlayer player, double motionX, double motionY, double motionZ) { + if (!player.getEntityWorld().isRemote && player instanceof EntityPlayerMP) { BloodMagicPacketHandler.sendTo(new PlayerVelocityPacketProcessor(motionX, motionY, motionZ), (EntityPlayerMP) player); } } - public static boolean isInteger(String integer) - { - try - { + public static boolean isInteger(String integer) { + try { Integer.parseInt(integer); - } catch (NumberFormatException e) - { + } catch (NumberFormatException e) { return false; - } catch (NullPointerException e) - { + } catch (NullPointerException e) { return false; } // only got here if we didn't return false return true; } - public static String toFancyCasing(String input) - { + public static String toFancyCasing(String input) { return String.valueOf(input.charAt(0)).toUpperCase(Locale.ENGLISH) + input.substring(1); } - public static String prettifyBlockPosString(BlockPos pos) - { + public static String prettifyBlockPosString(BlockPos pos) { return "[" + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + "]"; } /** - * @param tile - * - The {@link TileInventory} to input the item to - * @param player - * - The player to take the item from. + * @param tile - The {@link TileInventory} to input the item to + * @param player - The player to take the item from. * @return {@code true} if the ItemStack is inserted, {@code false} - * otherwise + * otherwise * @see #insertItemToTile(TileInventory, EntityPlayer, int) */ - public static boolean insertItemToTile(TileInventory tile, EntityPlayer player) - { + public static boolean insertItemToTile(TileInventory tile, EntityPlayer player) { return insertItemToTile(tile, player, 0); } @@ -322,29 +269,22 @@ public class Utils * inventory at slot 0 *

* EG: Block Altar - * - * @param tile - * - The {@link TileInventory} to input the item to - * @param player - * - The player to take the item from. - * @param slot - * - The slot to attempt to insert to + * + * @param tile - The {@link TileInventory} to input the item to + * @param player - The player to take the item from. + * @param slot - The slot to attempt to insert to * @return {@code true} if the ItemStack is inserted, {@code false} - * otherwise + * otherwise */ - public static boolean insertItemToTile(TileInventory tile, EntityPlayer player, int slot) - { - if (tile.getStackInSlot(slot).isEmpty() && !player.getHeldItemMainhand().isEmpty()) - { + public static boolean insertItemToTile(TileInventory tile, EntityPlayer player, int slot) { + if (tile.getStackInSlot(slot).isEmpty() && !player.getHeldItemMainhand().isEmpty()) { ItemStack input = player.getHeldItemMainhand().copy(); input.setCount(1); player.getHeldItemMainhand().shrink(1); tile.setInventorySlotContents(slot, input); return true; - } else if (!tile.getStackInSlot(slot).isEmpty() && player.getHeldItemMainhand().isEmpty()) - { - if (!tile.getWorld().isRemote) - { + } 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().spawnEntity(invItem); } @@ -355,8 +295,7 @@ public class Utils return false; } - public static double calculateStandardProgress(Number currentValue, int[] requiredValues, int currentLevel) - { + public static double calculateStandardProgress(Number currentValue, int[] requiredValues, int currentLevel) { int nextLevel = currentLevel + 1; if (nextLevel >= requiredValues.length) return 1.0D; @@ -366,8 +305,7 @@ public class Utils } @Nullable - public static IItemHandler getInventory(TileEntity tile, @Nullable EnumFacing facing) - { + public static IItemHandler getInventory(TileEntity tile, @Nullable EnumFacing facing) { if (facing == null) facing = EnumFacing.DOWN; @@ -383,8 +321,7 @@ public class Utils return itemHandler; } - public static ItemStack setUnbreakable(ItemStack stack) - { + public static ItemStack setUnbreakable(ItemStack stack) { NBTHelper.checkNBT(stack); stack.getTagCompound().setBoolean("Unbreakable", true); return stack; @@ -392,36 +329,31 @@ public class Utils /** * Gets a default block for each type of {@link EnumAltarComponent} - * - * @param component - * - The Component to provide a block for. + * + * @param component - The Component to provide a block for. * @return The default Block for the EnumAltarComponent */ - public static Block getBlockForComponent(EnumAltarComponent component) - { - switch (component) - { - case GLOWSTONE: - return Blocks.GLOWSTONE; - case BLOODSTONE: - return RegistrarBloodMagicBlocks.DECORATIVE_BRICK; - case BEACON: - return Blocks.BEACON; - case BLOODRUNE: - return RegistrarBloodMagicBlocks.BLOOD_RUNE; - case CRYSTAL: - return RegistrarBloodMagicBlocks.BLOOD_RUNE; - case NOTAIR: - return Blocks.STONEBRICK; - default: - return Blocks.AIR; + public static Block getBlockForComponent(EnumAltarComponent component) { + switch (component) { + case GLOWSTONE: + return Blocks.GLOWSTONE; + case BLOODSTONE: + return RegistrarBloodMagicBlocks.DECORATIVE_BRICK; + case BEACON: + return Blocks.BEACON; + case BLOODRUNE: + return RegistrarBloodMagicBlocks.BLOOD_RUNE; + case CRYSTAL: + return RegistrarBloodMagicBlocks.BLOOD_RUNE; + case NOTAIR: + return Blocks.STONEBRICK; + default: + return Blocks.AIR; } } - public static float getModifiedDamage(EntityLivingBase attackedEntity, DamageSource source, float amount) - { - if (!attackedEntity.isEntityInvulnerable(source)) - { + public static float getModifiedDamage(EntityLivingBase attackedEntity, DamageSource source, float amount) { + if (!attackedEntity.isEntityInvulnerable(source)) { if (amount <= 0) return 0; @@ -436,42 +368,33 @@ public class Utils return 0; } - public static float applyArmor(EntityLivingBase entity, ItemStack[] inventory, DamageSource source, double damage) - { + public static float applyArmor(EntityLivingBase entity, ItemStack[] inventory, DamageSource source, double damage) { damage *= 25; ArrayList dmgVals = new ArrayList(); - for (int x = 0; x < inventory.length; x++) - { + for (int x = 0; x < inventory.length; x++) { ItemStack stack = inventory[x]; - if (stack.isEmpty()) - { + if (stack.isEmpty()) { continue; } ArmorProperties prop = null; - if (stack.getItem() instanceof ISpecialArmor) - { + if (stack.getItem() instanceof ISpecialArmor) { ISpecialArmor armor = (ISpecialArmor) stack.getItem(); prop = armor.getProperties(entity, stack, source, damage / 25D, x).copy(); - } else if (stack.getItem() instanceof ItemArmor && !source.isUnblockable()) - { + } else if (stack.getItem() instanceof ItemArmor && !source.isUnblockable()) { ItemArmor armor = (ItemArmor) stack.getItem(); prop = new ArmorProperties(0, armor.damageReduceAmount / 25D, Integer.MAX_VALUE); } - if (prop != null) - { + if (prop != null) { prop.Slot = x; dmgVals.add(prop); } } - if (dmgVals.size() > 0) - { + if (dmgVals.size() > 0) { ArmorProperties[] props = dmgVals.toArray(new ArmorProperties[dmgVals.size()]); int level = props[0].Priority; double ratio = 0; - for (ArmorProperties prop : props) - { - if (level != prop.Priority) - { + for (ArmorProperties prop : props) { + if (level != prop.Priority) { damage -= (damage * ratio); ratio = 0; level = prop.Priority; @@ -485,37 +408,29 @@ public class Utils return (float) (damage / 25.0F); } - public static float applyPotionDamageCalculations(EntityLivingBase attackedEntity, DamageSource source, float damage) - { + public static float applyPotionDamageCalculations(EntityLivingBase attackedEntity, DamageSource source, float damage) { Potion resistance = MobEffects.RESISTANCE; - if (source.isDamageAbsolute()) - { + if (source.isDamageAbsolute()) { return damage; - } else - { - if (attackedEntity.isPotionActive(resistance) && source != DamageSource.OUT_OF_WORLD) - { + } else { + if (attackedEntity.isPotionActive(resistance) && source != DamageSource.OUT_OF_WORLD) { int i = (attackedEntity.getActivePotionEffect(resistance).getAmplifier() + 1) * 5; int j = 25 - i; float f = damage * (float) j; damage = f / 25.0F; } - if (damage <= 0.0F) - { + if (damage <= 0.0F) { return 0.0F; - } else - { + } else { int k = EnchantmentHelper.getEnchantmentModifierDamage(attackedEntity.getArmorInventoryList(), source); - if (k > 20) - { + if (k > 20) { k = 20; } - if (k > 0 && k <= 20) - { + if (k > 0 && k <= 20) { int l = 25 - k; float f1 = damage * (float) l; damage = f1 / 25.0F; @@ -529,42 +444,32 @@ public class Utils /** * Used to determine if stack1 can be placed into stack2. If stack2 is is empty * and stack1 isn't empty, returns true. Ignores stack size - * - * @param stack1 - * Stack that is placed into a slot - * @param stack2 - * Slot content that stack1 is placed into + * + * @param stack1 Stack that is placed into a slot + * @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) - { + public static boolean canCombine(ItemStack stack1, ItemStack stack2) { return stack1.isEmpty() && !stack2.isEmpty() || ItemHandlerHelper.canItemStacksStack(stack1, stack2); } /** - * @param stack1 - * Stack that is placed into a slot - * @param stack2 - * Slot content that stack1 is placed into + * @param stack1 Stack that is placed into a slot + * @param stack2 Slot content that stack1 is placed into * @return Stacks after stacking */ - public static ItemStack[] combineStacks(ItemStack stack1, ItemStack stack2, int transferMax) - { + public static ItemStack[] combineStacks(ItemStack stack1, ItemStack stack2, int transferMax) { ItemStack[] returned = new ItemStack[2]; - if (ItemHandlerHelper.canItemStacksStack(stack1, stack2)) - { + if (ItemHandlerHelper.canItemStacksStack(stack1, stack2)) { int transferedAmount = Math.min(transferMax, stack2.isEmpty() ? stack1.getCount() : Math.min(stack2.getMaxStackSize() - stack2.getCount(), stack1.getCount())); - if (transferedAmount > 0) - { + if (transferedAmount > 0) { ItemStack copyStack = stack1.splitStack(transferedAmount); - if (stack2.isEmpty()) - { + if (stack2.isEmpty()) { stack2 = copyStack; - } else - { + } else { stack2.grow(transferedAmount); } } @@ -577,27 +482,20 @@ public class Utils } /** - * @param stack1 - * Stack that is placed into a slot - * @param stack2 - * Slot content that stack1 is placed into + * @param stack1 Stack that is placed into a slot + * @param stack2 Slot content that stack1 is placed into * @return Stacks after stacking */ - public static ItemStack[] combineStacks(ItemStack stack1, ItemStack stack2) - { + public static ItemStack[] combineStacks(ItemStack stack1, ItemStack stack2) { ItemStack[] returned = new ItemStack[2]; - if (ItemHandlerHelper.canItemStacksStack(stack1, stack2)) - { + if (ItemHandlerHelper.canItemStacksStack(stack1, stack2)) { int transferedAmount = stack2.isEmpty() ? stack1.getCount() : Math.min(stack2.getMaxStackSize() - stack2.getCount(), stack1.getCount()); - if (transferedAmount > 0) - { + if (transferedAmount > 0) { ItemStack copyStack = stack1.splitStack(transferedAmount); - if (stack2.isEmpty()) - { + if (stack2.isEmpty()) { stack2 = copyStack; - } else - { + } else { stack2.grow(transferedAmount); } } @@ -609,42 +507,32 @@ public class Utils return returned; } - public static ItemStack insertStackIntoTile(ItemStack stack, TileEntity tile, EnumFacing dir) - { - if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir)) - { + public static ItemStack insertStackIntoTile(ItemStack stack, TileEntity tile, EnumFacing dir) { + if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir)) { IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir); return insertStackIntoTile(stack, handler); - } else if (tile instanceof IInventory) - { + } else if (tile instanceof IInventory) { return insertStackIntoInventory(stack, (IInventory) tile, dir); } return stack; } - public static int getNumberOfFreeSlots(TileEntity tile, EnumFacing dir) - { + public static int getNumberOfFreeSlots(TileEntity tile, EnumFacing dir) { int slots = 0; - if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir)) - { + if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir)) { IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir); - for (int i = 0; i < handler.getSlots(); i++) - { - if (handler.getStackInSlot(i).isEmpty()) - { + for (int i = 0; i < handler.getSlots(); i++) { + if (handler.getStackInSlot(i).isEmpty()) { slots++; } } - } else if (tile instanceof IInventory) - { - for (int i = 0; i < ((IInventory) tile).getSizeInventory(); i++) - { - if (((IInventory) tile).getStackInSlot(i).isEmpty()) - { + } else if (tile instanceof IInventory) { + for (int i = 0; i < ((IInventory) tile).getSizeInventory(); i++) { + if (((IInventory) tile).getStackInSlot(i).isEmpty()) { slots++; } } @@ -653,17 +541,14 @@ public class Utils return slots; } - public static ItemStack insertStackIntoTile(ItemStack stack, IItemHandler handler) - { + public static ItemStack insertStackIntoTile(ItemStack stack, IItemHandler handler) { int numberOfSlots = handler.getSlots(); ItemStack copyStack = stack.copy(); - for (int slot = 0; slot < numberOfSlots; slot++) - { + for (int slot = 0; slot < numberOfSlots; slot++) { copyStack = handler.insertItem(slot, copyStack, false); - if (copyStack.isEmpty()) - { + if (copyStack.isEmpty()) { return ItemStack.EMPTY; } } @@ -674,17 +559,15 @@ public class Utils /** * Inserts the desired stack into the tile up to a limit for the tile. * Respects capabilities. - * + * * @param stack * @param tile * @param dir * @param limit * @return */ - public static ItemStack insertStackIntoTile(ItemStack stack, TileEntity tile, EnumFacing dir, int limit) - { - if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir)) - { + public static ItemStack insertStackIntoTile(ItemStack stack, TileEntity tile, EnumFacing dir, int limit) { + if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir)) { IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir); int numberOfSlots = handler.getSlots(); @@ -692,39 +575,33 @@ public class Utils int numberMatching = 0; - for (int slot = 0; slot < numberOfSlots; slot++) - { + for (int slot = 0; slot < numberOfSlots; slot++) { ItemStack invStack = handler.getStackInSlot(slot); - if (!invStack.isEmpty() && ItemHandlerHelper.canItemStacksStack(stack, invStack)) - { + if (!invStack.isEmpty() && ItemHandlerHelper.canItemStacksStack(stack, invStack)) { numberMatching += invStack.getCount(); } } - if (numberMatching >= limit) - { + if (numberMatching >= limit) { return stack; } int newLimit = limit - numberMatching; - for (int slot = 0; slot < numberOfSlots; slot++) - { + for (int slot = 0; slot < numberOfSlots; slot++) { ItemStack newCopyStack = copyStack.copy(); newCopyStack.setCount(Math.min(copyStack.getCount(), newLimit)); newCopyStack = handler.insertItem(slot, newCopyStack, false); - if (newCopyStack.isEmpty()) - { + if (newCopyStack.isEmpty()) { return ItemStack.EMPTY; } newLimit -= (copyStack.getCount() - newCopyStack.getCount()); - if (newLimit <= 0) - { + if (newLimit <= 0) { return ItemStack.EMPTY; //TODO } @@ -732,42 +609,33 @@ public class Utils } return copyStack; - } else if (tile instanceof IInventory) - { + } else if (tile instanceof IInventory) { return insertStackIntoInventory(stack, (IInventory) tile, dir, limit); } return stack; } - public static ItemStack insertStackIntoInventory(ItemStack stack, IInventory inventory, EnumFacing dir) - { - if (stack.isEmpty()) - { + public static ItemStack insertStackIntoInventory(ItemStack stack, IInventory inventory, EnumFacing dir) { + if (stack.isEmpty()) { return ItemStack.EMPTY; } boolean[] canBeInserted = new boolean[inventory.getSizeInventory()]; - if (inventory instanceof ISidedInventory) - { + if (inventory instanceof ISidedInventory) { int[] array = ((ISidedInventory) inventory).getSlotsForFace(dir); - for (int in : array) - { + for (int in : array) { canBeInserted[in] = inventory.isItemValidForSlot(in, stack) && ((ISidedInventory) inventory).canInsertItem(in, stack, dir); } - } else - { - for (int i = 0; i < canBeInserted.length; i++) - { + } else { + for (int i = 0; i < canBeInserted.length; i++) { canBeInserted[i] = inventory.isItemValidForSlot(i, stack); } } - for (int i = 0; i < inventory.getSizeInventory(); i++) - { - if (!canBeInserted[i]) - { + for (int i = 0; i < inventory.getSizeInventory(); i++) { + if (!canBeInserted[i]) { continue; } @@ -775,8 +643,7 @@ public class Utils stack = combinedStacks[0]; inventory.setInventorySlotContents(i, combinedStacks[1]); - if (stack.isEmpty()) - { + if (stack.isEmpty()) { return ItemStack.EMPTY; } } @@ -784,15 +651,12 @@ public class Utils return stack; } - public static boolean canInsertStackFullyIntoInventory(ItemStack stack, IInventory inventory, EnumFacing dir) - { + public static boolean canInsertStackFullyIntoInventory(ItemStack stack, IInventory inventory, EnumFacing dir) { return canInsertStackFullyIntoInventory(stack, inventory, dir, false, 0); } - public static boolean canInsertStackFullyIntoInventory(ItemStack stack, IInventory inventory, EnumFacing dir, boolean fillToLimit, int limit) - { - if (stack.isEmpty()) - { + public static boolean canInsertStackFullyIntoInventory(ItemStack stack, IInventory inventory, EnumFacing dir, boolean fillToLimit, int limit) { + if (stack.isEmpty()) { return true; } @@ -800,68 +664,53 @@ public class Utils boolean[] canBeInserted = new boolean[inventory.getSizeInventory()]; - if (inventory instanceof ISidedInventory) - { + if (inventory instanceof ISidedInventory) { int[] array = ((ISidedInventory) inventory).getSlotsForFace(dir); - for (int in : array) - { + for (int in : array) { canBeInserted[in] = inventory.isItemValidForSlot(in, stack) && ((ISidedInventory) inventory).canInsertItem(in, stack, dir); } - } else - { - for (int i = 0; i < canBeInserted.length; i++) - { + } else { + for (int i = 0; i < canBeInserted.length; i++) { canBeInserted[i] = inventory.isItemValidForSlot(i, stack); } } int numberMatching = 0; - if (fillToLimit) - { - for (int i = 0; i < inventory.getSizeInventory(); i++) - { - if (!canBeInserted[i]) - { + if (fillToLimit) { + for (int i = 0; i < inventory.getSizeInventory(); i++) { + if (!canBeInserted[i]) { continue; } ItemStack invStack = inventory.getStackInSlot(i); - if (!invStack.isEmpty() && ItemHandlerHelper.canItemStacksStack(stack, invStack)) - { + if (!invStack.isEmpty() && ItemHandlerHelper.canItemStacksStack(stack, invStack)) { numberMatching += invStack.getCount(); } } } - if (fillToLimit && limit < stack.getCount() + numberMatching) - { + if (fillToLimit && limit < stack.getCount() + numberMatching) { return false; } - for (int i = 0; i < inventory.getSizeInventory(); i++) - { - if (!canBeInserted[i]) - { + for (int i = 0; i < inventory.getSizeInventory(); i++) { + if (!canBeInserted[i]) { continue; } ItemStack invStack = inventory.getStackInSlot(i); boolean canCombine = canCombine(stack, invStack); - if (canCombine) - { - if (invStack.isEmpty()) - { + if (canCombine) { + if (invStack.isEmpty()) { itemsLeft = 0; - } else - { + } else { itemsLeft -= (invStack.getMaxStackSize() - invStack.getCount()); } } - if (itemsLeft <= 0) - { + if (itemsLeft <= 0) { return true; } } @@ -872,65 +721,53 @@ public class Utils /** * Inserts the desired stack into the inventory up to a limit for the * inventory. - * + * * @param stack * @param inventory * @param dir * @param limit * @return */ - public static ItemStack insertStackIntoInventory(ItemStack stack, IInventory inventory, EnumFacing dir, int limit) - { - if (stack.isEmpty()) - { + public static ItemStack insertStackIntoInventory(ItemStack stack, IInventory inventory, EnumFacing dir, int limit) { + if (stack.isEmpty()) { return ItemStack.EMPTY; } boolean[] canBeInserted = new boolean[inventory.getSizeInventory()]; - if (inventory instanceof ISidedInventory) - { + if (inventory instanceof ISidedInventory) { int[] array = ((ISidedInventory) inventory).getSlotsForFace(dir); - for (int in : array) - { + for (int in : array) { canBeInserted[in] = ((ISidedInventory) inventory).canInsertItem(in, stack, dir); } - } else - { - for (int i = 0; i < canBeInserted.length; i++) - { + } else { + for (int i = 0; i < canBeInserted.length; i++) { canBeInserted[i] = true; } } int numberMatching = 0; - for (int i = 0; i < inventory.getSizeInventory(); i++) - { - if (!canBeInserted[i]) - { + for (int i = 0; i < inventory.getSizeInventory(); i++) { + if (!canBeInserted[i]) { continue; } ItemStack invStack = inventory.getStackInSlot(i); - if (!invStack.isEmpty() && canCombine(stack, invStack)) - { + if (!invStack.isEmpty() && canCombine(stack, invStack)) { numberMatching += invStack.getCount(); } } - if (numberMatching >= limit) - { + if (numberMatching >= limit) { return stack; } int newLimit = limit - numberMatching; - for (int i = 0; i < inventory.getSizeInventory(); i++) - { - if (!canBeInserted[i]) - { + for (int i = 0; i < inventory.getSizeInventory(); i++) { + if (!canBeInserted[i]) { continue; } @@ -942,8 +779,7 @@ public class Utils newLimit -= (prevStackSize - stack.getCount()); - if (newLimit <= 0 || stack.isEmpty()) - { + if (newLimit <= 0 || stack.isEmpty()) { return stack; } } @@ -951,64 +787,53 @@ public class Utils return stack; } - public static boolean isBlockLiquid(IBlockState state) - { + public static boolean isBlockLiquid(IBlockState state) { return (state instanceof IFluidBlock || state.getMaterial().isLiquid()); } - public static boolean isFlowingLiquid(World world, BlockPos pos, IBlockState state) - { + public static boolean isFlowingLiquid(World world, BlockPos pos, IBlockState state) { Block block = state.getBlock(); return ((block instanceof IFluidBlock && Math.abs(((IFluidBlock) block).getFilledPercentage(world, pos)) == 1) || (block instanceof BlockLiquid && block.getMetaFromState(state) != 0)); } - public static boolean spawnStackAtBlock(World world, BlockPos pos, @Nullable EnumFacing pushDirection, ItemStack stack) - { + public static boolean spawnStackAtBlock(World world, BlockPos pos, @Nullable EnumFacing pushDirection, ItemStack stack) { EntityItem entityItem = new EntityItem(world); BlockPos spawnPos = new BlockPos(pos); double velocity = 0.15D; - if (pushDirection != null) - { + if (pushDirection != null) { spawnPos.offset(pushDirection); - switch (pushDirection) - { - case DOWN: - { - entityItem.motionY = -velocity; - entityItem.setPosition(spawnPos.getX() + 0.5D, spawnPos.getY() - 1.0D, spawnPos.getZ() + 0.5D); - break; - } - case UP: - { - entityItem.motionY = velocity; - entityItem.setPosition(spawnPos.getX() + 0.5D, spawnPos.getY() + 1.0D, spawnPos.getZ() + 0.5D); - break; - } - case NORTH: - { - entityItem.motionZ = -velocity; - entityItem.setPosition(spawnPos.getX() + 0.5D, spawnPos.getY() + 0.5D, spawnPos.getZ() - 1.0D); - break; - } - case SOUTH: - { - entityItem.motionZ = velocity; - entityItem.setPosition(spawnPos.getX() + 0.5D, spawnPos.getY() + 0.5D, spawnPos.getZ() + 1.0D); - break; - } - case WEST: - { - entityItem.motionX = -velocity; - entityItem.setPosition(spawnPos.getX() - 1.0D, spawnPos.getY() + 0.5D, spawnPos.getZ() + 0.5D); - break; - } - case EAST: - { - entityItem.motionX = velocity; - entityItem.setPosition(spawnPos.getX() + 1.0D, spawnPos.getY() + 0.5D, spawnPos.getZ() + 0.5D); - break; - } + switch (pushDirection) { + case DOWN: { + entityItem.motionY = -velocity; + entityItem.setPosition(spawnPos.getX() + 0.5D, spawnPos.getY() - 1.0D, spawnPos.getZ() + 0.5D); + break; + } + case UP: { + entityItem.motionY = velocity; + entityItem.setPosition(spawnPos.getX() + 0.5D, spawnPos.getY() + 1.0D, spawnPos.getZ() + 0.5D); + break; + } + case NORTH: { + entityItem.motionZ = -velocity; + entityItem.setPosition(spawnPos.getX() + 0.5D, spawnPos.getY() + 0.5D, spawnPos.getZ() - 1.0D); + break; + } + case SOUTH: { + entityItem.motionZ = velocity; + entityItem.setPosition(spawnPos.getX() + 0.5D, spawnPos.getY() + 0.5D, spawnPos.getZ() + 1.0D); + break; + } + case WEST: { + entityItem.motionX = -velocity; + entityItem.setPosition(spawnPos.getX() - 1.0D, spawnPos.getY() + 0.5D, spawnPos.getZ() + 0.5D); + break; + } + case EAST: { + entityItem.motionX = velocity; + entityItem.setPosition(spawnPos.getX() + 1.0D, spawnPos.getY() + 0.5D, spawnPos.getZ() + 0.5D); + break; + } } } @@ -1016,13 +841,11 @@ public class Utils return world.spawnEntity(entityItem); } - public static boolean swapLocations(World initialWorld, BlockPos initialPos, World finalWorld, BlockPos finalPos) - { + public static boolean swapLocations(World initialWorld, BlockPos initialPos, World finalWorld, BlockPos finalPos) { return swapLocations(initialWorld, initialPos, finalWorld, finalPos, true); } - public static boolean swapLocations(World initialWorld, BlockPos initialPos, World finalWorld, BlockPos finalPos, boolean playSound) - { + public static boolean swapLocations(World initialWorld, BlockPos initialPos, World finalWorld, BlockPos finalPos, boolean playSound) { TileEntity initialTile = initialWorld.getTileEntity(initialPos); TileEntity finalTile = finalWorld.getTileEntity(finalPos); NBTTagCompound initialTag = new NBTTagCompound(); @@ -1038,8 +861,7 @@ public class Utils if ((initialStack.getBlock().equals(Blocks.AIR) && finalStack.getBlock().equals(Blocks.AIR)) || initialStack.getBlock() instanceof BlockPortal || finalStack.getBlock() instanceof BlockPortal) return false; - if (playSound) - { + if (playSound) { initialWorld.playSound(initialPos.getX(), initialPos.getY(), initialPos.getZ(), SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.AMBIENT, 1.0F, 1.0F, false); finalWorld.playSound(finalPos.getX(), finalPos.getY(), finalPos.getZ(), SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.AMBIENT, 1.0F, 1.0F, false); } @@ -1055,8 +877,7 @@ public class Utils IBlockState finalBlockState = finalWorld.getBlockState(finalPos); finalWorld.setBlockState(finalPos, initialBlockState, 3); - if (initialTile != null) - { + if (initialTile != null) { TileEntity newTileInitial = TileEntity.create(finalWorld, initialTag); @@ -1067,8 +888,7 @@ public class Utils initialWorld.setBlockState(initialPos, finalBlockState, 3); - if (finalTile != null) - { + if (finalTile != null) { TileEntity newTileFinal = TileEntity.create(initialWorld, finalTag); initialWorld.setTileEntity(initialPos, newTileFinal); @@ -1083,23 +903,18 @@ public class Utils } //Shamelessly ripped off of CoFH Lib - public static ItemStack consumeItem(ItemStack stack) - { + public static ItemStack consumeItem(ItemStack stack) { Item item = stack.getItem(); boolean largerStack = stack.getCount() > 1; - if (largerStack) - { + if (largerStack) { stack.shrink(1); } - if (item.hasContainerItem(stack)) - { + if (item.hasContainerItem(stack)) { ItemStack ret = item.getContainerItem(stack); - if (ret.isEmpty()) - { + if (ret.isEmpty()) { return ItemStack.EMPTY; } - if (ret.isItemStackDamageable() && ret.getItemDamage() > ret.getMaxDamage()) - { + if (ret.isItemStackDamageable() && ret.getItemDamage() > ret.getMaxDamage()) { ret = ItemStack.EMPTY; } return ret; @@ -1107,44 +922,35 @@ public class Utils return largerStack ? stack : ItemStack.EMPTY; } - public static void registerHandlers(Set eventHandlers) - { - for (ASMDataTable.ASMData data : eventHandlers) - { - try - { + public static void registerHandlers(Set eventHandlers) { + for (ASMDataTable.ASMData data : eventHandlers) { + try { Class handlerClass = Class.forName(data.getClassName()); Object handlerImpl = handlerClass.newInstance(); MinecraftForge.EVENT_BUS.register(handlerImpl); BloodMagic.instance.logger.debug("Registering event handler for class {}", data.getClassName()); - } catch (Exception e) - { + } catch (Exception e) { // No-op } } } - public static boolean hasUUID(ItemStack stack) - { + public static boolean hasUUID(ItemStack stack) { return stack.hasTagCompound() && stack.getTagCompound().hasKey(Constants.NBT.MOST_SIG) && stack.getTagCompound().hasKey(Constants.NBT.LEAST_SIG); } - public static UUID getUUID(ItemStack stack) - { - if (!hasUUID(stack)) - { + public static UUID getUUID(ItemStack stack) { + if (!hasUUID(stack)) { return null; } return new UUID(stack.getTagCompound().getLong(Constants.NBT.MOST_SIG), stack.getTagCompound().getLong(Constants.NBT.LEAST_SIG)); } - public static void setUUID(ItemStack stack) - { + public static void setUUID(ItemStack stack) { stack = NBTHelper.checkNBT(stack); - if (!stack.getTagCompound().hasKey(Constants.NBT.MOST_SIG) && !stack.getTagCompound().hasKey(Constants.NBT.LEAST_SIG)) - { + if (!stack.getTagCompound().hasKey(Constants.NBT.MOST_SIG) && !stack.getTagCompound().hasKey(Constants.NBT.LEAST_SIG)) { UUID itemUUID = UUID.randomUUID(); stack.getTagCompound().setLong(Constants.NBT.MOST_SIG, itemUUID.getMostSignificantBits()); stack.getTagCompound().setLong(Constants.NBT.LEAST_SIG, itemUUID.getLeastSignificantBits()); diff --git a/src/main/java/WayofTime/bloodmagic/util/handler/IMCHandler.java b/src/main/java/WayofTime/bloodmagic/util/handler/IMCHandler.java index 15bbf802..251a0a1b 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/IMCHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/IMCHandler.java @@ -1,21 +1,10 @@ package WayofTime.bloodmagic.util.handler; -import WayofTime.bloodmagic.api.BloodMagicAPI; -import WayofTime.bloodmagic.api.altar.EnumAltarComponent; -import WayofTime.bloodmagic.util.Utils; -import net.minecraft.block.Block; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.event.FMLInterModComms; -import net.minecraftforge.fml.common.registry.ForgeRegistries; -import net.minecraftforge.fml.common.registry.GameRegistry; -public class IMCHandler -{ +public class IMCHandler { - public static void handleIMC(FMLInterModComms.IMCEvent event) - { + public static void handleIMC(FMLInterModComms.IMCEvent event) { // TODO // for (FMLInterModComms.IMCMessage message : event.getMessages()) // { 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 1ef6e22f..c92e1267 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/ClientHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/ClientHandler.java @@ -1,17 +1,29 @@ package WayofTime.bloodmagic.util.handler.event; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.ConfigHandler; +import WayofTime.bloodmagic.annot.Handler; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.registry.RitualRegistry; +import WayofTime.bloodmagic.api.ritual.Ritual; +import WayofTime.bloodmagic.api.ritual.RitualComponent; +import WayofTime.bloodmagic.client.hud.HUDElement; import WayofTime.bloodmagic.client.key.KeyBindings; +import WayofTime.bloodmagic.client.render.block.RenderFakeBlocks; import WayofTime.bloodmagic.core.RegistrarBloodMagic; +import WayofTime.bloodmagic.item.ItemRitualDiviner; +import WayofTime.bloodmagic.item.sigil.ItemSigilHolding; +import WayofTime.bloodmagic.network.BloodMagicPacketHandler; +import WayofTime.bloodmagic.network.SigilHoldingPacketProcessor; +import WayofTime.bloodmagic.tile.TileMasterRitualStone; +import WayofTime.bloodmagic.util.GhostItemHelper; +import WayofTime.bloodmagic.util.helper.TextHelper; +import com.google.common.base.Stopwatch; +import com.google.common.collect.SetMultimap; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.block.model.*; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.EntityPlayer; @@ -24,11 +36,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; -import net.minecraftforge.client.event.ModelBakeEvent; -import net.minecraftforge.client.event.MouseEvent; -import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.client.event.*; import net.minecraftforge.client.event.sound.PlaySoundEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.entity.player.ItemTooltipEvent; @@ -38,36 +46,16 @@ import net.minecraftforge.fml.common.gameevent.InputEvent; import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.lwjgl.opengl.GL11; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.ConfigHandler; -import WayofTime.bloodmagic.annot.Handler; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.registry.RitualRegistry; -import WayofTime.bloodmagic.api.ritual.Ritual; -import WayofTime.bloodmagic.api.ritual.RitualComponent; -import WayofTime.bloodmagic.client.hud.HUDElement; -import WayofTime.bloodmagic.client.render.block.RenderFakeBlocks; -import WayofTime.bloodmagic.item.ItemRitualDiviner; -import WayofTime.bloodmagic.item.sigil.ItemSigilHolding; -import WayofTime.bloodmagic.network.BloodMagicPacketHandler; -import WayofTime.bloodmagic.network.SigilHoldingPacketProcessor; -import WayofTime.bloodmagic.tile.TileMasterRitualStone; -import WayofTime.bloodmagic.util.GhostItemHelper; -import WayofTime.bloodmagic.util.helper.TextHelper; - -import com.google.common.base.Stopwatch; -import com.google.common.collect.SetMultimap; +import java.util.*; @Handler @SideOnly(Side.CLIENT) -public class ClientHandler -{ +public class ClientHandler { // Quick toggle for error suppression. Set to false if you wish to hide model errors. public static final boolean SUPPRESS_ASSET_ERRORS = true; - + public static final List hudElements = new ArrayList(); public static TextureAtlasSprite ritualStoneBlank; public static TextureAtlasSprite ritualStoneWater; public static TextureAtlasSprite ritualStoneFire; @@ -75,57 +63,45 @@ public class ClientHandler public static TextureAtlasSprite ritualStoneAir; public static TextureAtlasSprite ritualStoneDawn; public static TextureAtlasSprite ritualStoneDusk; - public static TextureAtlasSprite blankBloodRune; public static TextureAtlasSprite stoneBrick; public static TextureAtlasSprite glowstone; public static TextureAtlasSprite bloodStoneBrick; public static TextureAtlasSprite beacon; public static TextureAtlasSprite crystalCluster; - public static Minecraft minecraft = Minecraft.getMinecraft(); - public static final List hudElements = new ArrayList(); - private static TileMasterRitualStone mrsHoloTile; private static Ritual mrsHoloRitual; private static EnumFacing mrsHoloDirection; private static boolean mrsHoloDisplay; @SubscribeEvent - public void onTooltipEvent(ItemTooltipEvent event) - { + public void onTooltipEvent(ItemTooltipEvent event) { ItemStack stack = event.getItemStack(); - if (stack.isEmpty()) - { + if (stack.isEmpty()) { return; } - if (GhostItemHelper.hasGhostAmount(stack)) - { + if (GhostItemHelper.hasGhostAmount(stack)) { int amount = GhostItemHelper.getItemGhostAmount(stack); - if (amount == 0) - { + if (amount == 0) { event.getToolTip().add(TextHelper.localize("tooltip.bloodmagic.ghost.everything")); - } else - { + } else { event.getToolTip().add(TextHelper.localize("tooltip.bloodmagic.ghost.amount", amount)); } } } @SubscribeEvent - public void onSoundEvent(PlaySoundEvent event) - { + public void onSoundEvent(PlaySoundEvent event) { EntityPlayer player = Minecraft.getMinecraft().player; - if (player != null && player.isPotionActive(RegistrarBloodMagic.DEAFNESS)) - { + if (player != null && player.isPotionActive(RegistrarBloodMagic.DEAFNESS)) { event.setResultSound(null); } } @SubscribeEvent - public void onTextureStitch(TextureStitchEvent.Pre event) - { + public void onTextureStitch(TextureStitchEvent.Pre event) { final String BLOCKS = "blocks"; ritualStoneBlank = forName(event.getMap(), "RitualStone", BLOCKS); @@ -145,21 +121,17 @@ public class ClientHandler } @SubscribeEvent - public void render(RenderWorldLastEvent event) - { + public void render(RenderWorldLastEvent event) { EntityPlayerSP player = minecraft.player; World world = player.getEntityWorld(); - if (mrsHoloTile != null) - { - if (world.getTileEntity(mrsHoloTile.getPos()) instanceof TileMasterRitualStone) - { + if (mrsHoloTile != null) { + if (world.getTileEntity(mrsHoloTile.getPos()) instanceof TileMasterRitualStone) { if (mrsHoloDisplay) renderRitualStones(mrsHoloTile, event.getPartialTicks()); else ClientHandler.setRitualHoloToNull(); - } else - { + } else { ClientHandler.setRitualHoloToNull(); } } @@ -174,20 +146,16 @@ public class ClientHandler } @SubscribeEvent - public void onMouseEvent(MouseEvent event) - { + public void onMouseEvent(MouseEvent event) { EntityPlayerSP player = Minecraft.getMinecraft().player; - if (event.getDwheel() != 0 && player != null && player.isSneaking()) - { + if (event.getDwheel() != 0 && player != null && player.isSneaking()) { ItemStack stack = player.getHeldItemMainhand(); - if (!stack.isEmpty()) - { + if (!stack.isEmpty()) { Item item = stack.getItem(); - if (item instanceof ItemSigilHolding) - { + if (item instanceof ItemSigilHolding) { cycleSigil(stack, player, event.getDwheel()); event.setCanceled(true); } @@ -196,8 +164,7 @@ public class ClientHandler } @SubscribeEvent - public void onKey(InputEvent event) - { + public void onKey(InputEvent event) { if (!minecraft.inGameHasFocus) return; @@ -207,8 +174,7 @@ public class ClientHandler } @SubscribeEvent - public void onHudRender(RenderGameOverlayEvent.Pre event) - { + public void onHudRender(RenderGameOverlayEvent.Pre event) { for (HUDElement element : hudElements) if (element.getElementType() == event.getType() && element.shouldRender(minecraft)) element.render(minecraft, event.getResolution(), event.getPartialTicks()); @@ -216,8 +182,7 @@ public class ClientHandler // Stolen from Chisel @SubscribeEvent - public void onModelBake(ModelBakeEvent event) - { + public void onModelBake(ModelBakeEvent event) { if (BloodMagic.IS_DEV && SUPPRESS_ASSET_ERRORS) return; @@ -253,8 +218,7 @@ public class ClientHandler // For some reason, we need some bad textures to be listed in the Crystal and Node models. This will hide that from the end user. @SubscribeEvent - public void onTextureStitch(TextureStitchEvent.Post event) - { + public void onTextureStitch(TextureStitchEvent.Post event) { if (BloodMagic.IS_DEV && SUPPRESS_ASSET_ERRORS) return; @@ -267,8 +231,7 @@ public class ClientHandler Set toRemove = new HashSet(); // Find our missing textures and mark them for removal. Cannot directly remove as it would cause a CME - if (missingTextures.containsKey(mc)) - { + if (missingTextures.containsKey(mc)) { Set missingMCTextures = missingTextures.get(mc); for (ResourceLocation texture : missingMCTextures) if (texture.getResourcePath().equalsIgnoreCase(String.format(format, "node")) || texture.getResourcePath().equalsIgnoreCase(String.format(format, "crystal"))) @@ -279,36 +242,14 @@ public class ClientHandler missingTextures.get(mc).removeAll(toRemove); // Make sure to only remove the bad MC domain if no other textures are missing - if (missingTextures.get(mc).isEmpty()) - { + if (missingTextures.get(mc).isEmpty()) { missingTextures.keySet().remove(mc); badTextureDomains.remove(mc); } BloodMagic.instance.logger.debug("Suppressed required texture errors in {}", stopwatch.stop()); } - public static void cycleSigil(ItemStack stack, EntityPlayer player, int dWheel) - { - int mode = dWheel; - if (!ConfigHandler.sigilHoldingSkipsEmptySlots) - { - mode = ItemSigilHolding.getCurrentItemOrdinal(stack); - mode = dWheel < 0 ? ItemSigilHolding.next(mode) : ItemSigilHolding.prev(mode); - } - - ItemSigilHolding.cycleToNextSigil(stack, mode); - BloodMagicPacketHandler.INSTANCE.sendToServer(new SigilHoldingPacketProcessor(player.inventory.currentItem, mode)); - ItemStack newStack = ItemSigilHolding.getItemStackInSlot(stack, ItemSigilHolding.getCurrentItemOrdinal(stack)); - player.sendStatusMessage(newStack.isEmpty() ? new TextComponentString("") : newStack.getTextComponent(), true); - } - - private static TextureAtlasSprite forName(TextureMap textureMap, String name, String dir) - { - return textureMap.registerSprite(new ResourceLocation(Constants.Mod.DOMAIN + dir + "/" + name)); - } - - private void renderRitualStones(EntityPlayerSP player, float partialTicks) - { + private void renderRitualStones(EntityPlayerSP player, float partialTicks) { World world = player.getEntityWorld(); ItemRitualDiviner ritualDiviner = (ItemRitualDiviner) player.inventory.getCurrentItem().getItem(); EnumFacing direction = ritualDiviner.getDirection(player.inventory.getCurrentItem()); @@ -328,40 +269,37 @@ public class ClientHandler double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks; double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks; - for (RitualComponent ritualComponent : ritual.getComponents()) - { + for (RitualComponent ritualComponent : ritual.getComponents()) { vX = vec3.add(ritualComponent.getOffset(direction)); double minX = vX.getX() - posX; double minY = vX.getY() - posY; double minZ = vX.getZ() - posZ; - if (!world.getBlockState(vX).isOpaqueCube()) - { + if (!world.getBlockState(vX).isOpaqueCube()) { TextureAtlasSprite texture = null; - switch (ritualComponent.getRuneType()) - { - case BLANK: - texture = ritualStoneBlank; - break; - case WATER: - texture = ritualStoneWater; - break; - case FIRE: - texture = ritualStoneFire; - break; - case EARTH: - texture = ritualStoneEarth; - break; - case AIR: - texture = ritualStoneAir; - break; - case DAWN: - texture = ritualStoneDawn; - break; - case DUSK: - texture = ritualStoneDusk; - break; + switch (ritualComponent.getRuneType()) { + case BLANK: + texture = ritualStoneBlank; + break; + case WATER: + texture = ritualStoneWater; + break; + case FIRE: + texture = ritualStoneFire; + break; + case EARTH: + texture = ritualStoneEarth; + break; + case AIR: + texture = ritualStoneAir; + break; + case DAWN: + texture = ritualStoneDawn; + break; + case DUSK: + texture = ritualStoneDusk; + break; } RenderFakeBlocks.drawFakeBlock(texture, minX, minY, minZ); @@ -371,8 +309,24 @@ public class ClientHandler GlStateManager.popMatrix(); } - public static void renderRitualStones(TileMasterRitualStone masterRitualStone, float partialTicks) - { + public static void cycleSigil(ItemStack stack, EntityPlayer player, int dWheel) { + int mode = dWheel; + if (!ConfigHandler.sigilHoldingSkipsEmptySlots) { + mode = ItemSigilHolding.getCurrentItemOrdinal(stack); + mode = dWheel < 0 ? ItemSigilHolding.next(mode) : ItemSigilHolding.prev(mode); + } + + ItemSigilHolding.cycleToNextSigil(stack, mode); + BloodMagicPacketHandler.INSTANCE.sendToServer(new SigilHoldingPacketProcessor(player.inventory.currentItem, mode)); + ItemStack newStack = ItemSigilHolding.getItemStackInSlot(stack, ItemSigilHolding.getCurrentItemOrdinal(stack)); + player.sendStatusMessage(newStack.isEmpty() ? new TextComponentString("") : newStack.getTextComponent(), true); + } + + private static TextureAtlasSprite forName(TextureMap textureMap, String name, String dir) { + return textureMap.registerSprite(new ResourceLocation(Constants.Mod.DOMAIN + dir + "/" + name)); + } + + public static void renderRitualStones(TileMasterRitualStone masterRitualStone, float partialTicks) { EntityPlayerSP player = minecraft.player; World world = player.getEntityWorld(); EnumFacing direction = mrsHoloDirection; @@ -392,40 +346,37 @@ public class ClientHandler double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks; double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks; - for (RitualComponent ritualComponent : ritual.getComponents()) - { + for (RitualComponent ritualComponent : ritual.getComponents()) { vX = vec3.add(ritualComponent.getOffset(direction)); double minX = vX.getX() - posX; double minY = vX.getY() - posY; double minZ = vX.getZ() - posZ; - if (!world.getBlockState(vX).isOpaqueCube()) - { + if (!world.getBlockState(vX).isOpaqueCube()) { TextureAtlasSprite texture = null; - switch (ritualComponent.getRuneType()) - { - case BLANK: - texture = ritualStoneBlank; - break; - case WATER: - texture = ritualStoneWater; - break; - case FIRE: - texture = ritualStoneFire; - break; - case EARTH: - texture = ritualStoneEarth; - break; - case AIR: - texture = ritualStoneAir; - break; - case DAWN: - texture = ritualStoneDawn; - break; - case DUSK: - texture = ritualStoneDusk; - break; + switch (ritualComponent.getRuneType()) { + case BLANK: + texture = ritualStoneBlank; + break; + case WATER: + texture = ritualStoneWater; + break; + case FIRE: + texture = ritualStoneFire; + break; + case EARTH: + texture = ritualStoneEarth; + break; + case AIR: + texture = ritualStoneAir; + break; + case DAWN: + texture = ritualStoneDawn; + break; + case DUSK: + texture = ritualStoneDusk; + break; } RenderFakeBlocks.drawFakeBlock(texture, minX, minY, minZ); @@ -435,16 +386,14 @@ public class ClientHandler GlStateManager.popMatrix(); } - public static void setRitualHolo(TileMasterRitualStone masterRitualStone, Ritual ritual, EnumFacing direction, boolean displayed) - { + public static void setRitualHolo(TileMasterRitualStone masterRitualStone, Ritual ritual, EnumFacing direction, boolean displayed) { mrsHoloDisplay = displayed; mrsHoloTile = masterRitualStone; mrsHoloRitual = ritual; mrsHoloDirection = direction; } - public static void setRitualHoloToNull() - { + public static void setRitualHoloToNull() { mrsHoloDisplay = false; mrsHoloTile = null; mrsHoloRitual = null; 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 ebebde12..366c9c1f 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/CraftingHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/CraftingHandler.java @@ -1,10 +1,17 @@ package WayofTime.bloodmagic.util.handler.event; -import java.util.ArrayList; -import java.util.List; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.ConfigHandler; +import WayofTime.bloodmagic.annot.Handler; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.event.AltarCraftedEvent; +import WayofTime.bloodmagic.api.iface.IUpgradeTrainer; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.api.util.helper.ItemHelper; +import WayofTime.bloodmagic.api.util.helper.NBTHelper; import WayofTime.bloodmagic.block.BlockLifeEssence; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.item.ItemInscriptionTool; import net.minecraft.init.Items; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.ItemBanner; @@ -16,38 +23,26 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import WayofTime.bloodmagic.ConfigHandler; -import WayofTime.bloodmagic.annot.Handler; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.event.AltarCraftedEvent; -import WayofTime.bloodmagic.api.iface.IUpgradeTrainer; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.api.util.helper.ItemHelper; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.item.ItemInscriptionTool; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; + +import java.util.ArrayList; +import java.util.List; @Handler -public class CraftingHandler -{ +public class CraftingHandler { // Sets the uses of crafted Inscription Tools to 10 @SubscribeEvent - public void onAltarCrafted(AltarCraftedEvent event) - { - if (event.getOutput() == null) - { + public void onAltarCrafted(AltarCraftedEvent event) { + if (event.getOutput() == null) { return; } - if (event.getOutput().getItem() instanceof ItemInscriptionTool) - { + if (event.getOutput().getItem() instanceof ItemInscriptionTool) { NBTHelper.checkNBT(event.getOutput()); event.getOutput().getTagCompound().setInteger(Constants.NBT.USES, 10); } - if (event.getOutput().getItem() == ForgeModContainer.getInstance().universalBucket && event.getAltarRecipe().getSyphon() == 1000) - { + if (event.getOutput().getItem() == ForgeModContainer.getInstance().universalBucket && event.getAltarRecipe().getSyphon() == 1000) { NBTTagCompound bucketTags = FluidUtil.getFilledBucket(new FluidStack(BlockLifeEssence.getLifeEssence(), Fluid.BUCKET_VOLUME)).getTagCompound(); event.getOutput().setTagCompound(bucketTags); } @@ -55,12 +50,9 @@ public class CraftingHandler // Handles crafting of: Revealing Upgrade Tome, Elytra Upgrade Tome, Combining Upgrade Tomes, Setting Upgrade for Trainer @SubscribeEvent - public void onAnvil(AnvilUpdateEvent event) - { - if (ConfigHandler.thaumcraftGogglesUpgrade) - { - if (event.getLeft().getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET && event.getRight().getItem() == Constants.Compat.THAUMCRAFT_GOGGLES && !event.getRight().isItemDamaged()) - { + public void onAnvil(AnvilUpdateEvent event) { + if (ConfigHandler.thaumcraftGogglesUpgrade) { + if (event.getLeft().getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET && event.getRight().getItem() == Constants.Compat.THAUMCRAFT_GOGGLES && !event.getRight().isItemDamaged()) { ItemStack output = new ItemStack(RegistrarBloodMagicItems.UPGRADE_TOME); output = NBTHelper.checkNBT(output); ItemHelper.LivingUpgrades.setKey(output, BloodMagic.MODID + ".upgrade.revealing"); @@ -73,10 +65,8 @@ public class CraftingHandler } } - if (event.getLeft().getItem() == RegistrarBloodMagicItems.SIGIL_HOLDING) - { - if (event.getRight().getItem() == Items.NAME_TAG) - { + if (event.getLeft().getItem() == RegistrarBloodMagicItems.SIGIL_HOLDING) { + if (event.getRight().getItem() == Items.NAME_TAG) { ItemStack output = event.getLeft().copy(); if (!output.hasTagCompound()) output.setTagCompound(new NBTTagCompound()); @@ -88,8 +78,7 @@ public class CraftingHandler return; } - if (event.getRight().getItem() == Items.DYE) - { + if (event.getRight().getItem() == Items.DYE) { EnumDyeColor dyeColor = ItemBanner.getBaseColor(event.getRight()); ItemStack output = event.getLeft().copy(); if (!output.hasTagCompound()) @@ -103,8 +92,7 @@ public class CraftingHandler } } - if (event.getLeft().getItem() == Items.BOOK && event.getRight().getItem() == Items.ELYTRA && !event.getRight().isItemDamaged()) - { + if (event.getLeft().getItem() == Items.BOOK && event.getRight().getItem() == Items.ELYTRA && !event.getRight().isItemDamaged()) { ItemStack output = new ItemStack(RegistrarBloodMagicItems.UPGRADE_TOME); output = NBTHelper.checkNBT(output); ItemHelper.LivingUpgrades.setKey(output, BloodMagic.MODID + ".upgrade.elytra"); @@ -116,16 +104,13 @@ public class CraftingHandler return; } - if (event.getLeft().getItem() == RegistrarBloodMagicItems.UPGRADE_TOME && event.getRight().getItem() == RegistrarBloodMagicItems.UPGRADE_TOME) - { + if (event.getLeft().getItem() == RegistrarBloodMagicItems.UPGRADE_TOME && event.getRight().getItem() == RegistrarBloodMagicItems.UPGRADE_TOME) { LivingArmourUpgrade leftUpgrade = ItemHelper.LivingUpgrades.getUpgrade(event.getLeft()); - if (leftUpgrade != null && !leftUpgrade.isDowngrade() && ItemHelper.LivingUpgrades.getKey(event.getLeft()).equals(ItemHelper.LivingUpgrades.getKey(event.getRight()))) - { + if (leftUpgrade != null && !leftUpgrade.isDowngrade() && ItemHelper.LivingUpgrades.getKey(event.getLeft()).equals(ItemHelper.LivingUpgrades.getKey(event.getRight()))) { int leftLevel = ItemHelper.LivingUpgrades.getLevel(event.getLeft()); int rightLevel = ItemHelper.LivingUpgrades.getLevel(event.getRight()); - if (leftLevel == rightLevel && leftLevel < leftUpgrade.getMaxTier() - 1) - { + if (leftLevel == rightLevel && leftLevel < leftUpgrade.getMaxTier() - 1) { ItemStack outputStack = event.getLeft().copy(); ItemHelper.LivingUpgrades.setLevel(outputStack, leftLevel + 1); event.setCost(leftLevel + 2); @@ -137,17 +122,14 @@ public class CraftingHandler } } - if (event.getLeft().getItem() instanceof IUpgradeTrainer && event.getRight().getItem() == RegistrarBloodMagicItems.UPGRADE_TOME) - { + if (event.getLeft().getItem() instanceof IUpgradeTrainer && event.getRight().getItem() == RegistrarBloodMagicItems.UPGRADE_TOME) { LivingArmourUpgrade rightUpgrade = ItemHelper.LivingUpgrades.getUpgrade(event.getRight()); - if (rightUpgrade != null) - { + if (rightUpgrade != null) { String key = ItemHelper.LivingUpgrades.getKey(event.getRight()); ItemStack outputStack = event.getLeft().copy(); List keyList = new ArrayList(); keyList.add(key); - if (((IUpgradeTrainer) event.getLeft().getItem()).setTrainedUpgrades(outputStack, keyList)) - { + if (((IUpgradeTrainer) event.getLeft().getItem()).setTrainedUpgrades(outputStack, keyList)) { event.setCost(1); event.setOutput(outputStack); 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 41c63451..74d75c62 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/GenericHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/GenericHandler.java @@ -1,14 +1,41 @@ package WayofTime.bloodmagic.util.handler.event; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; - import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.ConfigHandler; +import WayofTime.bloodmagic.annot.Handler; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.event.ItemBindEvent; +import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent; +import WayofTime.bloodmagic.api.event.TeleposeEvent; +import WayofTime.bloodmagic.api.iface.IBindable; +import WayofTime.bloodmagic.api.iface.ISentientTool; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.orb.BloodOrb; +import WayofTime.bloodmagic.api.orb.IBloodOrb; +import WayofTime.bloodmagic.api.saving.SoulNetwork; +import WayofTime.bloodmagic.api.soul.DemonWillHolder; +import WayofTime.bloodmagic.api.util.helper.*; import WayofTime.bloodmagic.api_impl.BloodMagicAPI; +import WayofTime.bloodmagic.block.BlockAltar; import WayofTime.bloodmagic.core.RegistrarBloodMagic; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; +import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; +import WayofTime.bloodmagic.item.ItemAltarMaker; +import WayofTime.bloodmagic.item.ItemExperienceBook; +import WayofTime.bloodmagic.item.armour.ItemLivingArmour; +import WayofTime.bloodmagic.item.gear.ItemPackSacrifice; +import WayofTime.bloodmagic.livingArmour.LivingArmour; +import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeBattleHungry; +import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSelfSacrifice; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice; +import WayofTime.bloodmagic.network.BloodMagicPacketHandler; +import WayofTime.bloodmagic.network.DemonAuraPacketProcessor; +import WayofTime.bloodmagic.potion.BMPotionUtils; +import WayofTime.bloodmagic.util.ChatUtil; +import WayofTime.bloodmagic.util.Utils; +import WayofTime.bloodmagic.util.helper.TextHelper; +import com.google.common.base.Strings; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.enchantment.EnchantmentHelper; @@ -50,69 +77,33 @@ import net.minecraftforge.fml.common.eventhandler.Event.Result; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import WayofTime.bloodmagic.ConfigHandler; -import WayofTime.bloodmagic.annot.Handler; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.event.ItemBindEvent; -import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent; -import WayofTime.bloodmagic.api.event.TeleposeEvent; -import WayofTime.bloodmagic.api.iface.IBindable; -import WayofTime.bloodmagic.api.iface.ISentientTool; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.api.orb.IBloodOrb; -import WayofTime.bloodmagic.api.saving.SoulNetwork; -import WayofTime.bloodmagic.api.soul.DemonWillHolder; -import WayofTime.bloodmagic.api.util.helper.BindableHelper; -import WayofTime.bloodmagic.api.util.helper.ItemHelper; -import WayofTime.bloodmagic.api.util.helper.NBTHelper; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -import WayofTime.bloodmagic.api.util.helper.PlayerHelper; -import WayofTime.bloodmagic.block.BlockAltar; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter; -import WayofTime.bloodmagic.item.ItemAltarMaker; -import WayofTime.bloodmagic.item.ItemExperienceBook; -import WayofTime.bloodmagic.item.armour.ItemLivingArmour; -import WayofTime.bloodmagic.item.gear.ItemPackSacrifice; -import WayofTime.bloodmagic.livingArmour.LivingArmour; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeBattleHungry; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSelfSacrifice; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice; -import WayofTime.bloodmagic.network.BloodMagicPacketHandler; -import WayofTime.bloodmagic.network.DemonAuraPacketProcessor; -import WayofTime.bloodmagic.potion.BMPotionUtils; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; -import WayofTime.bloodmagic.util.ChatUtil; -import WayofTime.bloodmagic.util.Utils; -import WayofTime.bloodmagic.util.helper.TextHelper; - -import com.google.common.base.Strings; import net.minecraftforge.fml.common.registry.EntityEntry; import net.minecraftforge.fml.common.registry.EntityRegistry; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; + @Handler -public class GenericHandler -{ +public class GenericHandler { public static Map bounceMap = new HashMap(); public static Map filledHandMap = new HashMap(); + private static Map targetTaskMap = new HashMap(); + private static Map attackTaskMap = new HashMap(); @SubscribeEvent - public void onEntityFall(LivingFallEvent event) - { - if (event.getEntityLiving() instanceof EntityPlayer) - { + public void onEntityFall(LivingFallEvent event) { + if (event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); - if (player.isPotionActive(RegistrarBloodMagic.BOUNCE) && !player.isSneaking() && event.getDistance() > 2) - { + if (player.isPotionActive(RegistrarBloodMagic.BOUNCE) && !player.isSneaking() && event.getDistance() > 2) { event.setDamageMultiplier(0); - if (player.getEntityWorld().isRemote) - { + if (player.getEntityWorld().isRemote) { player.motionY *= -0.9; player.fallDistance = 0; bounceMap.put(player, player.motionY); - } else - { + } else { player.fallDistance = 0; event.setCanceled(true); } @@ -121,23 +112,17 @@ public class GenericHandler } @SubscribeEvent - public void playerTickPost(TickEvent.PlayerTickEvent event) - { - if (event.phase == TickEvent.Phase.END && bounceMap.containsKey(event.player)) - { + public void playerTickPost(TickEvent.PlayerTickEvent event) { + if (event.phase == TickEvent.Phase.END && bounceMap.containsKey(event.player)) { event.player.motionY = bounceMap.remove(event.player); } - if (event.phase == TickEvent.Phase.END) - { - if (filledHandMap.containsKey(event.player)) - { + if (event.phase == TickEvent.Phase.END) { + if (filledHandMap.containsKey(event.player)) { int value = filledHandMap.get(event.player) - 1; - if (value <= 0) - { + if (value <= 0) { filledHandMap.remove(event.player); - } else - { + } else { filledHandMap.put(event.player, value); } } @@ -145,31 +130,24 @@ public class GenericHandler } @SubscribeEvent - public void onPlayerClick(PlayerInteractEvent event) - { - if (event.isCancelable() && event.getEntityPlayer().isPotionActive(RegistrarBloodMagic.CONSTRICT)) - { + public void onPlayerClick(PlayerInteractEvent event) { + if (event.isCancelable() && event.getEntityPlayer().isPotionActive(RegistrarBloodMagic.CONSTRICT)) { EntityPlayer player = event.getEntityPlayer(); int level = player.getActivePotionEffect(RegistrarBloodMagic.CONSTRICT).getAmplifier(); - if (event.getHand() == EnumHand.OFF_HAND || level > 1) - { + if (event.getHand() == EnumHand.OFF_HAND || level > 1) { event.setCanceled(true); } } } @SubscribeEvent - public void onPlayerDropItem(ItemTossEvent event) - { + public void onPlayerDropItem(ItemTossEvent event) { EntityItem itemEntity = event.getEntityItem(); - if (itemEntity != null) - { + if (itemEntity != null) { ItemStack stack = itemEntity.getItem(); Item item = stack.getItem(); - if (stack.hasTagCompound() && item instanceof ISentientTool) - { - if (((ISentientTool) item).spawnSentientEntityOnDrop(stack, event.getPlayer())) - { + if (stack.hasTagCompound() && item instanceof ISentientTool) { + if (((ISentientTool) item).spawnSentientEntityOnDrop(stack, event.getPlayer())) { event.setCanceled(true); } } @@ -177,8 +155,7 @@ public class GenericHandler } @SubscribeEvent - public void onExplosion(ExplosionEvent.Start event) - { + public void onExplosion(ExplosionEvent.Start event) { World world = event.getWorld(); Explosion exp = event.getExplosion(); Vec3d position = exp.getPosition(); @@ -186,12 +163,9 @@ public class GenericHandler AxisAlignedBB bb = new AxisAlignedBB(position.x - radius, position.y - radius, position.z - radius, position.x + radius, position.y + radius, position.z + radius); List specterList = world.getEntitiesWithinAABB(EntitySentientSpecter.class, bb); - if (!specterList.isEmpty()) - { - for (EntitySentientSpecter specter : specterList) - { - if (specter.absorbExplosion(exp)) - { + if (!specterList.isEmpty()) { + for (EntitySentientSpecter specter : specterList) { + if (specter.absorbExplosion(exp)) { event.setCanceled(true); return; } @@ -200,17 +174,14 @@ public class GenericHandler } @SubscribeEvent - public void onEntityHurt(LivingHurtEvent event) - { + public void onEntityHurt(LivingHurtEvent event) { if (event.getEntity().getEntityWorld().isRemote) return; - if (event.getSource().getTrueSource() instanceof EntityPlayer && !PlayerHelper.isFakePlayer((EntityPlayer) event.getSource().getTrueSource())) - { + if (event.getSource().getTrueSource() instanceof EntityPlayer && !PlayerHelper.isFakePlayer((EntityPlayer) event.getSource().getTrueSource())) { EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource(); - if (!player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty() && 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(); boolean shouldSyphon = pack.getStoredLP(player.getItemStackFromSlot(EntityEquipmentSlot.CHEST)) < pack.CAPACITY; @@ -221,16 +192,13 @@ public class GenericHandler ItemHelper.LPContainer.addLPToItem(player.getItemStackFromSlot(EntityEquipmentSlot.CHEST), totalLP, pack.CAPACITY); } - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { + if (armour != null) { LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.battleHunger", chestStack); - if (upgrade instanceof LivingArmourUpgradeBattleHungry) - { + if (upgrade instanceof LivingArmourUpgradeBattleHungry) { ((LivingArmourUpgradeBattleHungry) upgrade).resetTimer(); } } @@ -238,28 +206,20 @@ public class GenericHandler } } - private static Map targetTaskMap = new HashMap(); - private static Map attackTaskMap = new HashMap(); - // Handles sending the client the Demon Will Aura updates @SubscribeEvent - public void onLivingUpdate(LivingUpdateEvent event) - { - if (!event.getEntityLiving().getEntityWorld().isRemote) - { + public void onLivingUpdate(LivingUpdateEvent event) { + if (!event.getEntityLiving().getEntityWorld().isRemote) { EntityLivingBase entity = event.getEntityLiving(); if (entity instanceof EntityPlayer && entity.ticksExisted % 50 == 0) //TODO: Change to an incremental counter { sendPlayerDemonWillAura((EntityPlayer) entity); } - if (event.getEntityLiving() instanceof EntityAnimal) - { + if (event.getEntityLiving() instanceof EntityAnimal) { EntityAnimal animal = (EntityAnimal) event.getEntityLiving(); - if (animal.isPotionActive(RegistrarBloodMagic.SACRIFICIAL_LAMB)) - { - if (!targetTaskMap.containsKey(animal)) - { + if (animal.isPotionActive(RegistrarBloodMagic.SACRIFICIAL_LAMB)) { + if (!targetTaskMap.containsKey(animal)) { EntityAITarget task = new EntityAINearestAttackableTarget(animal, EntityMob.class, false); EntityAIBase attackTask = new EntityAIAttackMelee(animal, 1.0D, false); animal.targetTasks.addTask(1, task); @@ -268,14 +228,12 @@ public class GenericHandler attackTaskMap.put(animal, attackTask); } - if (animal.getAttackTarget() != null && animal.getDistanceSqToEntity(animal.getAttackTarget()) < 4) - { + if (animal.getAttackTarget() != null && animal.getDistanceSqToEntity(animal.getAttackTarget()) < 4) { animal.getEntityWorld().createExplosion(null, animal.posX, animal.posY + (double) (animal.height / 16.0F), animal.posZ, 2 + animal.getActivePotionEffect(RegistrarBloodMagic.SACRIFICIAL_LAMB).getAmplifier() * 1.5f, false); targetTaskMap.remove(animal); attackTaskMap.remove(animal); } - } else if (targetTaskMap.containsKey(animal)) - { + } else if (targetTaskMap.containsKey(animal)) { targetTaskMap.remove(animal); attackTaskMap.remove(animal); } @@ -284,69 +242,55 @@ public class GenericHandler EntityLivingBase entity = event.getEntityLiving(); - if (entity instanceof EntityPlayer) - { + if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; - if (player.isSneaking() && player.isPotionActive(RegistrarBloodMagic.CLING) && Utils.isPlayerBesideSolidBlockFace(player) && !player.onGround) - { - if (player.getEntityWorld().isRemote) - { + if (player.isSneaking() && player.isPotionActive(RegistrarBloodMagic.CLING) && Utils.isPlayerBesideSolidBlockFace(player) && !player.onGround) { + if (player.getEntityWorld().isRemote) { player.motionY = 0; player.motionX *= 0.8; player.motionZ *= 0.8; - } else - { + } else { player.fallDistance = 0; } } } - if (entity.isPotionActive(MobEffects.NIGHT_VISION)) - { + if (entity.isPotionActive(MobEffects.NIGHT_VISION)) { int duration = entity.getActivePotionEffect(MobEffects.NIGHT_VISION).getDuration(); - if (duration == Constants.Misc.NIGHT_VISION_CONSTANT_END) - { + if (duration == Constants.Misc.NIGHT_VISION_CONSTANT_END) { entity.removePotionEffect(MobEffects.NIGHT_VISION); } } - if (entity.isPotionActive(RegistrarBloodMagic.FIRE_FUSE)) - { + if (entity.isPotionActive(RegistrarBloodMagic.FIRE_FUSE)) { 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(RegistrarBloodMagic.FIRE_FUSE).getAmplifier(); int radius = r + 1; - if (entity.getActivePotionEffect(RegistrarBloodMagic.FIRE_FUSE).getDuration() <= 3) - { + if (entity.getActivePotionEffect(RegistrarBloodMagic.FIRE_FUSE).getDuration() <= 3) { entity.getEntityWorld().createExplosion(null, entity.posX, entity.posY, entity.posZ, radius, false); } } - if (entity.isPotionActive(RegistrarBloodMagic.PLANT_LEECH)) - { + if (entity.isPotionActive(RegistrarBloodMagic.PLANT_LEECH)) { int amplifier = entity.getActivePotionEffect(RegistrarBloodMagic.PLANT_LEECH).getAmplifier(); int timeRemaining = entity.getActivePotionEffect(RegistrarBloodMagic.PLANT_LEECH).getDuration(); - if (timeRemaining % 10 == 0) - { + if (timeRemaining % 10 == 0) { BMPotionUtils.damageMobAndGrowSurroundingPlants(entity, 2 + amplifier, 1, 0.5 * 3 / (amplifier + 3), 25 * (1 + amplifier)); } } } -// @SideOnly(Side.SERVER) - public void sendPlayerDemonWillAura(EntityPlayer player) - { - if (player instanceof EntityPlayerMP) - { + // @SideOnly(Side.SERVER) + public void sendPlayerDemonWillAura(EntityPlayer player) { + if (player instanceof EntityPlayerMP) { BlockPos pos = player.getPosition(); DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(player.getEntityWorld().provider.getDimension(), pos.getX() >> 4, pos.getZ() >> 4); - if (holder != null) - { + if (holder != null) { BloodMagicPacketHandler.sendTo(new DemonAuraPacketProcessor(holder), (EntityPlayerMP) player); - } else - { + } else { BloodMagicPacketHandler.sendTo(new DemonAuraPacketProcessor(new DemonWillHolder()), (EntityPlayerMP) player); } } @@ -354,12 +298,10 @@ public class GenericHandler // Handles destroying altar @SubscribeEvent - public void harvestEvent(PlayerEvent.HarvestCheck event) - { + public void harvestEvent(PlayerEvent.HarvestCheck event) { IBlockState state = event.getTargetBlock(); Block block = state.getBlock(); - if (block instanceof BlockAltar && event.getEntityPlayer() != null && event.getEntityPlayer() instanceof EntityPlayerMP && !event.getEntityPlayer().getHeldItemMainhand().isEmpty() && 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()))); } @@ -367,16 +309,14 @@ public class GenericHandler // Handle Teleposer block blacklist @SubscribeEvent - public void onTelepose(TeleposeEvent event) - { + public void onTelepose(TeleposeEvent event) { if (BloodMagicAPI.INSTANCE.getBlacklist().getTeleposer().contains(event.initialState) || BloodMagicAPI.INSTANCE.getBlacklist().getTeleposer().contains(event.finalState)) event.setCanceled(true); } // Handle Teleposer entity blacklist @SubscribeEvent - public void onTeleposeEntity(TeleposeEvent.Ent event) - { + public void onTeleposeEntity(TeleposeEvent.Ent event) { EntityEntry entry = EntityRegistry.getEntry(event.entity.getClass()); if (BloodMagicAPI.INSTANCE.getBlacklist().getTeleposerEntities().contains(entry.getRegistryName())) event.setCanceled(true); @@ -384,15 +324,13 @@ public class GenericHandler // Sets teleport cooldown for Teleposed entities to 5 ticks (1/4 second) instead of 150 (7.5 seconds) @SubscribeEvent - public void onTeleposeEntityPost(TeleposeEvent.Ent.Post event) - { + public void onTeleposeEntityPost(TeleposeEvent.Ent.Post event) { event.entity.timeUntilPortal = 5; } // Handles binding of IBindable's as well as setting a player's highest orb tier @SubscribeEvent - public void onInteract(PlayerInteractEvent.RightClickItem event) - { + public void onInteract(PlayerInteractEvent.RightClickItem event) { if (event.getWorld().isRemote) return; @@ -402,14 +340,11 @@ public class GenericHandler return; ItemStack held = event.getItemStack(); - if (!held.isEmpty() && held.getItem() instanceof IBindable) - { + if (!held.isEmpty() && held.getItem() instanceof IBindable) { held = NBTHelper.checkNBT(held); IBindable bindable = (IBindable) held.getItem(); - if (Strings.isNullOrEmpty(bindable.getOwnerUUID(held))) - { - if (bindable.onBind(player, held)) - { + if (Strings.isNullOrEmpty(bindable.getOwnerUUID(held))) { + if (bindable.onBind(player, held)) { String uuid = PlayerHelper.getUUIDFromPlayer(player).toString(); ItemBindEvent toPost = new ItemBindEvent(player, uuid, held); if (MinecraftForge.EVENT_BUS.post(toPost) || toPost.getResult() == Result.DENY) @@ -422,8 +357,7 @@ public class GenericHandler BindableHelper.setItemOwnerName(held, player.getDisplayNameString()); } - if (!held.isEmpty() && held.getItem() instanceof IBloodOrb) - { + if (!held.isEmpty() && held.getItem() instanceof IBloodOrb) { held = NBTHelper.checkNBT(held); IBloodOrb bloodOrb = (IBloodOrb) held.getItem(); SoulNetwork network = NetworkHelper.getSoulNetwork(player); @@ -438,21 +372,17 @@ public class GenericHandler } @SubscribeEvent - public void selfSacrificeEvent(SacrificeKnifeUsedEvent event) - { + public void selfSacrificeEvent(SacrificeKnifeUsedEvent event) { EntityPlayer player = event.player; - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { + if (armour != null) { StatTrackerSelfSacrifice.incrementCounter(armour, event.healthDrained / 2); LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.selfSacrifice", chestStack); - if (upgrade instanceof LivingArmourUpgradeSelfSacrifice) - { + if (upgrade instanceof LivingArmourUpgradeSelfSacrifice) { double modifier = ((LivingArmourUpgradeSelfSacrifice) upgrade).getSacrificeModifier(); event.lpAdded = (int) (event.lpAdded * (1 + modifier)); @@ -463,14 +393,12 @@ public class GenericHandler // Drop Blood Shards @SubscribeEvent - public void onLivingDrops(LivingDropsEvent event) - { + public void onLivingDrops(LivingDropsEvent event) { EntityLivingBase attackedEntity = event.getEntityLiving(); DamageSource source = event.getSource(); Entity entity = source.getTrueSource(); - if (entity != null && entity instanceof EntityPlayer) - { + if (entity != null && entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; ItemStack heldStack = player.getHeldItemMainhand(); @@ -483,24 +411,19 @@ public class GenericHandler // Experience Tome @SubscribeEvent(priority = EventPriority.LOWEST) - public void onExperiencePickup(PlayerPickupXpEvent event) - { + public void onExperiencePickup(PlayerPickupXpEvent event) { EntityPlayer player = event.getEntityPlayer(); ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantments.MENDING, player); - if (!itemstack.isEmpty() && 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.getEntityWorld().isRemote) - { - for (ItemStack stack : player.inventory.mainInventory) - { - if (stack.getItem() instanceof ItemExperienceBook) - { + if (!player.getEntityWorld().isRemote) { + for (ItemStack stack : player.inventory.mainInventory) { + if (stack.getItem() instanceof ItemExperienceBook) { ItemExperienceBook.addExperience(stack, event.getOrb().xpValue); event.getOrb().xpValue = 0; break; @@ -509,13 +432,11 @@ public class GenericHandler } } - private int xpToDurability(int xp) - { + private int xpToDurability(int xp) { return xp * 2; } - private int durabilityToXp(int durability) - { + private int durabilityToXp(int durability) { return durability / 2; } } 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 059c840d..903d77e9 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/LivingArmourHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/LivingArmourHandler.java @@ -1,7 +1,20 @@ package WayofTime.bloodmagic.util.handler.event; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.annot.Handler; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.core.RegistrarBloodMagic; +import WayofTime.bloodmagic.item.armour.ItemLivingArmour; +import WayofTime.bloodmagic.livingArmour.LivingArmour; +import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeCrippledArm; +import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeQuenched; +import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeSlowHeal; +import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeStormTrooper; +import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerArrowShot; +import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint; +import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerJump; +import WayofTime.bloodmagic.livingArmour.upgrade.*; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -25,49 +38,25 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import WayofTime.bloodmagic.annot.Handler; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.item.armour.ItemLivingArmour; -import WayofTime.bloodmagic.livingArmour.LivingArmour; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeCrippledArm; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeQuenched; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeSlowHeal; -import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeStormTrooper; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerArrowShot; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerJump; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeArrowShot; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeGrimReaperSprint; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeJump; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSpeed; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeStepAssist; @Handler -public class LivingArmourHandler -{ +public class LivingArmourHandler { @SubscribeEvent - public void onEntityHealed(LivingHealEvent event) - { - if (event.getEntityLiving() instanceof EntityPlayer) - { + public void onEntityHealed(LivingHealEvent event) { + if (event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntity(); - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { + if (armour != null) { double modifier = 1; LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.slowHeal", chestStack); - if (upgrade instanceof LivingArmourUpgradeSlowHeal) - { + if (upgrade instanceof LivingArmourUpgradeSlowHeal) { modifier *= ((LivingArmourUpgradeSlowHeal) upgrade).getHealingModifier(); } - if (modifier != 1) - { + if (modifier != 1) { event.setAmount((float) (event.getAmount() * modifier)); } } @@ -76,23 +65,18 @@ public class LivingArmourHandler } @SubscribeEvent - public void onMiningSpeedCheck(PlayerEvent.BreakSpeed event) - { + public void onMiningSpeedCheck(PlayerEvent.BreakSpeed event) { EntityPlayer player = event.getEntityPlayer(); - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { + if (armour != null) { double modifier = 1; - for (LivingArmourUpgrade upgrade : armour.upgradeMap.values()) - { + for (LivingArmourUpgrade upgrade : armour.upgradeMap.values()) { modifier *= upgrade.getMiningSpeedModifier(player); } - if (modifier != 1) - { + if (modifier != 1) { event.setNewSpeed((float) (event.getOriginalSpeed() * modifier)); } } @@ -101,31 +85,24 @@ public class LivingArmourHandler // Applies: Storm Trooper @SubscribeEvent - public void onEntityJoinedWorld(EntityJoinWorldEvent event) - { + public void onEntityJoinedWorld(EntityJoinWorldEvent event) { Entity owner = null; - if (event.getEntity() instanceof EntityArrow) - { + if (event.getEntity() instanceof EntityArrow) { owner = ((EntityArrow) event.getEntity()).shootingEntity; - } else if (event.getEntity() instanceof EntityThrowable) - { + } else if (event.getEntity() instanceof EntityThrowable) { owner = ((EntityThrowable) event.getEntity()).getThrower(); } - if (owner instanceof EntityPlayer) - { + if (owner instanceof EntityPlayer) { Entity projectile = event.getEntity(); EntityPlayer player = (EntityPlayer) owner; - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { + if (armour != null) { LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.stormTrooper", chestStack); - if (upgrade instanceof LivingArmourUpgradeStormTrooper) - { + if (upgrade instanceof LivingArmourUpgradeStormTrooper) { float velocityModifier = (float) (((LivingArmourUpgradeStormTrooper) upgrade).getArrowJiggle(player) * Math.sqrt(projectile.motionX * projectile.motionX + projectile.motionY * projectile.motionY + projectile.motionZ * projectile.motionZ)); projectile.motionX += 2 * (event.getWorld().rand.nextDouble() - 0.5) * velocityModifier; @@ -138,37 +115,29 @@ public class LivingArmourHandler } @SubscribeEvent - public void onPlayerClick(PlayerInteractEvent event) - { - if (event.isCancelable()) - { + public void onPlayerClick(PlayerInteractEvent event) { + if (event.isCancelable()) { EntityPlayer player = event.getEntityPlayer(); - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { - if (event.getHand() == EnumHand.OFF_HAND) - { + if (armour != null) { + if (event.getHand() == EnumHand.OFF_HAND) { LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.crippledArm", chestStack); - if (upgrade instanceof LivingArmourUpgradeCrippledArm) - { + if (upgrade instanceof LivingArmourUpgradeCrippledArm) { event.setCanceled(true); } } - if (event.getItemStack().getItemUseAction() == EnumAction.DRINK) - { + if (event.getItemStack().getItemUseAction() == EnumAction.DRINK) { ItemStack drinkStack = event.getItemStack(); //TODO: See if the item is a splash potion? Those should be usable. LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.quenched", chestStack); - if (upgrade instanceof LivingArmourUpgradeQuenched) - { + if (upgrade instanceof LivingArmourUpgradeQuenched) { event.setCanceled(true); } } @@ -179,24 +148,19 @@ public class LivingArmourHandler // Applies: Grim Reaper @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onEntityDeath(LivingDeathEvent event) - { - if (event.getEntityLiving() instanceof EntityPlayer) - { + public void onEntityDeath(LivingDeathEvent event) { + if (event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { + if (armour != null) { StatTrackerGrimReaperSprint.incrementCounter(armour); LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.grimReaper", chestStack); - if (upgrade instanceof LivingArmourUpgradeGrimReaperSprint && ((LivingArmourUpgradeGrimReaperSprint) upgrade).canSavePlayer(player)) - { + if (upgrade instanceof LivingArmourUpgradeGrimReaperSprint && ((LivingArmourUpgradeGrimReaperSprint) upgrade).canSavePlayer(player)) { ((LivingArmourUpgradeGrimReaperSprint) upgrade).applyEffectOnRebirth(player); event.setCanceled(true); event.setResult(Event.Result.DENY); @@ -210,26 +174,20 @@ public class LivingArmourHandler // Applies: Jump @SubscribeEvent - public void onJumpEvent(LivingEvent.LivingJumpEvent event) - { - if (event.getEntityLiving() instanceof EntityPlayer) - { + public void onJumpEvent(LivingEvent.LivingJumpEvent event) { + if (event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { + if (armour != null) { StatTrackerJump.incrementCounter(armour); - if (!player.isSneaking()) - { + if (!player.isSneaking()) { LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgradeFromNBT(BloodMagic.MODID + ".upgrade.jump", chestStack); - if (upgrade instanceof LivingArmourUpgradeJump) - { + if (upgrade instanceof LivingArmourUpgradeJump) { player.motionY += ((LivingArmourUpgradeJump) upgrade).getJumpModifier(); } } @@ -240,28 +198,21 @@ public class LivingArmourHandler // Applies: Step Assist, Speed Boost @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onEntityUpdate(LivingEvent.LivingUpdateEvent event) - { - if (event.getEntityLiving() instanceof EntityPlayer) - { + public void onEntityUpdate(LivingEvent.LivingUpdateEvent event) { + if (event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); boolean hasAssist = false; - if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.BOOST)) - { + if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.BOOST)) { hasAssist = true; player.stepHeight = Constants.Misc.ALTERED_STEP_HEIGHT; - } else - { - if (LivingArmour.hasFullSet(player)) - { + } else { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(chestStack); - if (armour != null) - { + if (armour != null) { LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.stepAssist", chestStack); - if (upgrade instanceof LivingArmourUpgradeStepAssist) - { + if (upgrade instanceof LivingArmourUpgradeStepAssist) { player.stepHeight = ((LivingArmourUpgradeStepAssist) upgrade).getStepAssist(); hasAssist = true; } @@ -274,31 +225,26 @@ public class LivingArmourHandler float percentIncrease = 0; - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(chestStack); - if (armour != null) - { + if (armour != null) { LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgradeFromNBT(BloodMagic.MODID + ".upgrade.movement", chestStack); - if (upgrade instanceof LivingArmourUpgradeSpeed) - { + if (upgrade instanceof LivingArmourUpgradeSpeed) { percentIncrease += 0.1f * ((LivingArmourUpgradeSpeed) upgrade).getSpeedModifier(); } } } - if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.BOOST)) - { + if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.BOOST)) { int i = event.getEntityLiving().getActivePotionEffect(RegistrarBloodMagic.BOOST).getAmplifier(); { percentIncrease += (i + 1) * 0.05f; } } - if (percentIncrease > 0 && (player.onGround || player.capabilities.isFlying) && (Math.abs(player.moveForward) > 0 || Math.abs(player.moveStrafing) > 0)) - { + if (percentIncrease > 0 && (player.onGround || player.capabilities.isFlying) && (Math.abs(player.moveForward) > 0 || Math.abs(player.moveStrafing) > 0)) { player.moveRelative(player.moveStrafing, player.moveForward, player.capabilities.isFlying ? (percentIncrease / 2.0f) : percentIncrease, 0.02F); } } @@ -307,8 +253,7 @@ public class LivingArmourHandler // Applies: Arrow Shot // Tracks: Arrow Shot @SubscribeEvent - public void onArrowFire(ArrowLooseEvent event) - { + public void onArrowFire(ArrowLooseEvent event) { World world = event.getEntityPlayer().getEntityWorld(); ItemStack stack = event.getBow(); EntityPlayer player = event.getEntityPlayer(); @@ -316,17 +261,14 @@ public class LivingArmourHandler if (world.isRemote) return; - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { + if (armour != null) { StatTrackerArrowShot.incrementCounter(armour); LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.arrowShot", chestStack); - if (upgrade instanceof LivingArmourUpgradeArrowShot) - { + if (upgrade instanceof LivingArmourUpgradeArrowShot) { int charge = event.getCharge(); float velocity = (float) charge / 20.0F; velocity = (velocity * velocity + velocity * 2.0F) / 3.0F; @@ -338,8 +280,7 @@ public class LivingArmourHandler velocity = 1.0F; int extraArrows = ((LivingArmourUpgradeArrowShot) upgrade).getExtraArrows(); - for (int n = 0; n < extraArrows; n++) - { + for (int n = 0; n < extraArrows; n++) { ItemStack arrowStack = new ItemStack(Items.ARROW); ItemArrow itemarrow = (ItemArrow) ((stack.getItem() instanceof ItemArrow ? arrowStack.getItem() : Items.ARROW)); EntityArrow entityarrow = itemarrow.createArrow(world, arrowStack, player); 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 e4d8ff82..78b03262 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/StatTrackerHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/StatTrackerHandler.java @@ -1,6 +1,15 @@ package WayofTime.bloodmagic.util.handler.event; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.annot.Handler; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.item.armour.ItemLivingArmour; +import WayofTime.bloodmagic.item.armour.ItemSentientArmour; +import WayofTime.bloodmagic.livingArmour.LivingArmour; +import WayofTime.bloodmagic.livingArmour.tracker.*; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeDigging; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeExperience; +import WayofTime.bloodmagic.util.Utils; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -17,49 +26,23 @@ import net.minecraftforge.event.entity.player.PlayerPickupXpEvent; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import WayofTime.bloodmagic.annot.Handler; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; -import WayofTime.bloodmagic.item.armour.ItemLivingArmour; -import WayofTime.bloodmagic.item.armour.ItemSentientArmour; -import WayofTime.bloodmagic.livingArmour.LivingArmour; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerArrowProtect; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerCriticalStrike; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerDigging; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerExperience; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerFallProtect; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGraveDigger; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerHealthboost; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerMeleeDamage; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerNightSight; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerPhysicalProtect; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSolarPowered; -import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSprintAttack; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeDigging; -import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeExperience; -import WayofTime.bloodmagic.util.Utils; @Handler -public class StatTrackerHandler -{ +public class StatTrackerHandler { private static float lastPlayerSwingStrength = 0; // Tracks: Digging, DigSlowdown @SubscribeEvent - public void blockBreakEvent(BlockEvent.BreakEvent event) - { + public void blockBreakEvent(BlockEvent.BreakEvent event) { EntityPlayer player = event.getPlayer(); - if (player != null) - { - if (LivingArmour.hasFullSet(player)) - { + if (player != null) { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); - if (chestStack.getItem() instanceof ItemLivingArmour) - { + if (chestStack.getItem() instanceof ItemLivingArmour) { LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { + if (armour != null) { StatTrackerDigging.incrementCounter(armour); LivingArmourUpgradeDigging.hasDug(armour); } @@ -70,25 +53,20 @@ public class StatTrackerHandler // Tracks: Health Boost @SubscribeEvent - public void onEntityHealed(LivingHealEvent event) - { + public void onEntityHealed(LivingHealEvent event) { EntityLivingBase healedEntity = event.getEntityLiving(); - if (!(healedEntity instanceof EntityPlayer)) - { + if (!(healedEntity instanceof EntityPlayer)) { return; } EntityPlayer player = (EntityPlayer) healedEntity; - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { + if (armour != null) { StatTrackerHealthboost.incrementCounter(armour, event.getAmount()); - if (player.getEntityWorld().canSeeSky(player.getPosition()) && player.getEntityWorld().provider.isDaytime()) - { + if (player.getEntityWorld().canSeeSky(player.getPosition()) && player.getEntityWorld().provider.isDaytime()) { StatTrackerSolarPowered.incrementCounter(armour, event.getAmount()); } } @@ -96,31 +74,26 @@ public class StatTrackerHandler } @SubscribeEvent - public void onLivingAttack(AttackEntityEvent event) - { + public void onLivingAttack(AttackEntityEvent event) { lastPlayerSwingStrength = event.getEntityPlayer().getCooledAttackStrength(0); } // Tracks: Fall Protect, Arrow Protect, Physical Protect, Grave Digger, Sprint Attack, Critical Strike, Nocturnal Prowess @SubscribeEvent - public void entityHurt(LivingHurtEvent event) - { + public void entityHurt(LivingHurtEvent event) { DamageSource source = event.getSource(); Entity sourceEntity = event.getSource().getTrueSource(); EntityLivingBase attackedEntity = event.getEntityLiving(); - if (attackedEntity instanceof EntityPlayer) - { + if (attackedEntity instanceof EntityPlayer) { EntityPlayer attackedPlayer = (EntityPlayer) attackedEntity; // Living Armor Handling - if (LivingArmour.hasFullSet(attackedPlayer)) - { + if (LivingArmour.hasFullSet(attackedPlayer)) { float amount = Math.min(Utils.getModifiedDamage(attackedPlayer, event.getSource(), event.getAmount()), attackedPlayer.getHealth()); ItemStack chestStack = attackedPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { + if (armour != null) { if (sourceEntity != null && !source.isMagicDamage() && !source.isProjectile()) StatTrackerPhysicalProtect.incrementCounter(armour, amount); @@ -130,36 +103,30 @@ public class StatTrackerHandler if (source.isProjectile()) StatTrackerArrowProtect.incrementCounter(armour, amount); } - } else - { + } else { ItemStack chestStack = attackedPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST); - if (chestStack.getItem() instanceof ItemSentientArmour) - { + if (chestStack.getItem() instanceof ItemSentientArmour) { ItemSentientArmour armour = (ItemSentientArmour) chestStack.getItem(); armour.onPlayerAttacked(chestStack, source, attackedPlayer); } } } - if (sourceEntity instanceof EntityPlayer) - { + if (sourceEntity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) sourceEntity; // Living Armor Handling - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { + if (armour != null) { ItemStack mainWeapon = player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND); event.setAmount((float) (event.getAmount() + lastPlayerSwingStrength * armour.getAdditionalDamageOnHit(event.getAmount(), player, attackedEntity, mainWeapon))); float amount = Math.min(Utils.getModifiedDamage(attackedEntity, event.getSource(), event.getAmount()), attackedEntity.getHealth()); - if (!source.isProjectile()) - { + if (!source.isProjectile()) { StatTrackerMeleeDamage.incrementCounter(armour, amount); if (player.getEntityWorld().getLight(player.getPosition()) <= 9) @@ -186,19 +153,15 @@ public class StatTrackerHandler // Tracks: Experienced @SubscribeEvent(priority = EventPriority.LOW) - public void onExperiencePickup(PlayerPickupXpEvent event) - { + public void onExperiencePickup(PlayerPickupXpEvent event) { EntityPlayer player = event.getEntityPlayer(); - if (LivingArmour.hasFullSet(player)) - { + if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); - if (armour != null) - { + if (armour != null) { LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.experienced", chestStack); - if (upgrade instanceof LivingArmourUpgradeExperience) - { + if (upgrade instanceof LivingArmourUpgradeExperience) { double modifier = ((LivingArmourUpgradeExperience) upgrade).getExperienceModifier(); double exp = event.getOrb().xpValue * (1 + modifier); 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 6c72690d..6fc490c9 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/WillHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/WillHandler.java @@ -1,10 +1,13 @@ package WayofTime.bloodmagic.util.handler.event; -import java.util.HashMap; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - +import WayofTime.bloodmagic.annot.Handler; +import WayofTime.bloodmagic.api.soul.*; import WayofTime.bloodmagic.core.RegistrarBloodMagic; +import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.demonAura.PosXY; +import WayofTime.bloodmagic.demonAura.WillChunk; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; +import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; @@ -25,37 +28,26 @@ import net.minecraftforge.event.world.ChunkDataEvent; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import WayofTime.bloodmagic.annot.Handler; -import WayofTime.bloodmagic.api.soul.DemonWillHolder; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.soul.IDemonWill; -import WayofTime.bloodmagic.api.soul.IDemonWillWeapon; -import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; -import WayofTime.bloodmagic.demonAura.PosXY; -import WayofTime.bloodmagic.demonAura.WillChunk; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow; -import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; + +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; @Handler -public class WillHandler -{ +public class WillHandler { private final HashMap serverTicks = new HashMap(); // Adds Will to player @SubscribeEvent - public void onItemPickup(EntityItemPickupEvent event) - { + public void onItemPickup(EntityItemPickupEvent event) { ItemStack stack = event.getItem().getItem(); - if (stack.getItem() instanceof IDemonWill) - { + if (stack.getItem() instanceof IDemonWill) { EntityPlayer player = event.getEntityPlayer(); EnumDemonWillType pickupType = ((IDemonWill) stack.getItem()).getType(stack); ItemStack remainder = PlayerDemonWillHandler.addDemonWill(player, stack); - if (remainder == null || ((IDemonWill) stack.getItem()).getWill(pickupType, stack) < 0.0001 || PlayerDemonWillHandler.isDemonWillFull(pickupType, player)) - { + if (remainder == null || ((IDemonWill) stack.getItem()).getWill(pickupType, stack) < 0.0001 || PlayerDemonWillHandler.isDemonWillFull(pickupType, player)) { stack.setCount(0); event.setResult(Event.Result.ALLOW); } @@ -63,14 +55,11 @@ public class WillHandler } @SubscribeEvent - public void onEntityAttacked(LivingDeathEvent event) - { - if (event.getSource() instanceof EntityDamageSourceIndirect) - { + public void onEntityAttacked(LivingDeathEvent event) { + if (event.getSource() instanceof EntityDamageSourceIndirect) { Entity sourceEntity = event.getSource().getImmediateSource(); - if (sourceEntity instanceof EntitySentientArrow) - { + if (sourceEntity instanceof EntitySentientArrow) { ((EntitySentientArrow) sourceEntity).reimbursePlayer(event.getEntityLiving(), event.getEntityLiving().getMaxHealth()); } } @@ -78,14 +67,12 @@ public class WillHandler // Add/Drop Demon Will for Player @SubscribeEvent - public void onLivingDrops(LivingDropsEvent event) - { + public void onLivingDrops(LivingDropsEvent event) { EntityLivingBase attackedEntity = event.getEntityLiving(); DamageSource source = event.getSource(); Entity entity = source.getTrueSource(); - if (attackedEntity.isPotionActive(RegistrarBloodMagic.SOUL_SNARE) && (attackedEntity instanceof EntityMob || attackedEntity.getEntityWorld().getDifficulty() == EnumDifficulty.PEACEFUL)) - { + if (attackedEntity.isPotionActive(RegistrarBloodMagic.SOUL_SNARE) && (attackedEntity instanceof EntityMob || attackedEntity.getEntityWorld().getDifficulty() == EnumDifficulty.PEACEFUL)) { PotionEffect eff = attackedEntity.getActivePotionEffect(RegistrarBloodMagic.SOUL_SNARE); int lvl = eff.getAmplifier(); @@ -94,26 +81,20 @@ public class WillHandler event.getDrops().add(new EntityItem(attackedEntity.getEntityWorld(), attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, soulStack)); } - if (entity != null && entity instanceof EntityPlayer) - { + if (entity != null && entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; ItemStack heldStack = player.getHeldItemMainhand(); - if (heldStack.getItem() instanceof IDemonWillWeapon && !player.getEntityWorld().isRemote) - { + if (heldStack.getItem() instanceof IDemonWillWeapon && !player.getEntityWorld().isRemote) { IDemonWillWeapon demonWillWeapon = (IDemonWillWeapon) heldStack.getItem(); List droppedSouls = demonWillWeapon.getRandomDemonWillDrop(attackedEntity, player, heldStack, event.getLootingLevel()); - if (!droppedSouls.isEmpty()) - { + if (!droppedSouls.isEmpty()) { ItemStack remainder; - for (ItemStack willStack : droppedSouls) - { + for (ItemStack willStack : droppedSouls) { remainder = PlayerDemonWillHandler.addDemonWill(player, willStack); - if (!remainder.isEmpty()) - { + if (!remainder.isEmpty()) { EnumDemonWillType pickupType = ((IDemonWill) remainder.getItem()).getType(remainder); - if (((IDemonWill) remainder.getItem()).getWill(pickupType, remainder) >= 0.0001) - { + if (((IDemonWill) remainder.getItem()).getWill(pickupType, remainder) >= 0.0001) { event.getDrops().add(new EntityItem(attackedEntity.getEntityWorld(), attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, remainder)); } } @@ -125,24 +106,20 @@ public class WillHandler } @SubscribeEvent - public void onServerWorldTick(TickEvent.WorldTickEvent event) - { + public void onServerWorldTick(TickEvent.WorldTickEvent event) { if (event.world.isRemote) return; int dim = event.world.provider.getDimension(); - if (event.phase == TickEvent.Phase.END) - { + if (event.phase == TickEvent.Phase.END) { if (!this.serverTicks.containsKey(dim)) this.serverTicks.put(dim, 0); int ticks = (this.serverTicks.get(dim)); - if (ticks % 20 == 0) - { + if (ticks % 20 == 0) { CopyOnWriteArrayList dirtyChunks = WorldDemonWillHandler.dirtyChunks.get(dim); - if ((dirtyChunks != null) && (dirtyChunks.size() > 0)) - { + if ((dirtyChunks != null) && (dirtyChunks.size() > 0)) { for (PosXY pos : dirtyChunks) event.world.markChunkDirty(new BlockPos(pos.x * 16, 5, pos.y * 16), null); @@ -156,8 +133,7 @@ public class WillHandler } @SubscribeEvent - public void chunkSave(ChunkDataEvent.Save event) - { + public void chunkSave(ChunkDataEvent.Save event) { int dim = event.getWorld().provider.getDimension(); ChunkPos loc = event.getChunk().getPos(); @@ -165,8 +141,7 @@ public class WillHandler event.getData().setTag("BloodMagic", nbt); WillChunk ac = WorldDemonWillHandler.getWillChunk(dim, loc.x, loc.z); - if (ac != null) - { + if (ac != null) { nbt.setShort("base", ac.getBase()); ac.getCurrentWill().writeToNBT(nbt, "current"); if (!event.getChunk().isLoaded()) @@ -175,18 +150,15 @@ public class WillHandler } @SubscribeEvent - public void chunkLoad(ChunkDataEvent.Load event) - { + public void chunkLoad(ChunkDataEvent.Load event) { int dim = event.getWorld().provider.getDimension(); - if (event.getData().getCompoundTag("BloodMagic").hasKey("base")) - { + if (event.getData().getCompoundTag("BloodMagic").hasKey("base")) { NBTTagCompound nbt = event.getData().getCompoundTag("BloodMagic"); short base = nbt.getShort("base"); DemonWillHolder current = new DemonWillHolder(); current.readFromNBT(nbt, "current"); WorldDemonWillHandler.addWillChunk(dim, event.getChunk(), base, current); - } else - { + } else { WorldDemonWillHandler.generateWill(event.getChunk()); } } diff --git a/src/main/java/WayofTime/bloodmagic/util/helper/NumeralHelper.java b/src/main/java/WayofTime/bloodmagic/util/helper/NumeralHelper.java index 8cea0dfa..c79afba7 100644 --- a/src/main/java/WayofTime/bloodmagic/util/helper/NumeralHelper.java +++ b/src/main/java/WayofTime/bloodmagic/util/helper/NumeralHelper.java @@ -2,13 +2,11 @@ package WayofTime.bloodmagic.util.helper; import java.util.TreeMap; -public class NumeralHelper -{ +public class NumeralHelper { private static final TreeMap romanNumerals = new TreeMap(); - static - { + static { romanNumerals.put(1000, "M"); romanNumerals.put(900, "CM"); romanNumerals.put(500, "D"); @@ -24,8 +22,7 @@ public class NumeralHelper romanNumerals.put(1, "I"); } - public static String toRoman(int arabic) - { + public static String toRoman(int arabic) { int convert = romanNumerals.floorKey(arabic); if (arabic == convert) return romanNumerals.get(convert); diff --git a/src/main/java/WayofTime/bloodmagic/util/helper/RecipeHelper.java b/src/main/java/WayofTime/bloodmagic/util/helper/RecipeHelper.java index 73d27fd3..069246a9 100644 --- a/src/main/java/WayofTime/bloodmagic/util/helper/RecipeHelper.java +++ b/src/main/java/WayofTime/bloodmagic/util/helper/RecipeHelper.java @@ -1,25 +1,19 @@ package WayofTime.bloodmagic.util.helper; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; import WayofTime.bloodmagic.api.recipe.TartaricForgeRecipe; import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry; import WayofTime.bloodmagic.api.registry.TartaricForgeRecipeRegistry; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.fml.common.registry.ForgeRegistries; -public class RecipeHelper -{ - public static IRecipe getRecipeForOutput(ItemStack stack) - { - for (IRecipe recipe : ForgeRegistries.RECIPES.getValues()) - { - if (recipe != null) - { +public class RecipeHelper { + public static IRecipe getRecipeForOutput(ItemStack stack) { + for (IRecipe recipe : ForgeRegistries.RECIPES.getValues()) { + if (recipe != null) { ItemStack resultStack = recipe.getRecipeOutput(); - if (!resultStack.isEmpty()) - { - if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) - { + if (!resultStack.isEmpty()) { + if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) { return recipe; } } @@ -29,17 +23,12 @@ public class RecipeHelper return null; } - public static AltarRecipeRegistry.AltarRecipe getAltarRecipeForOutput(ItemStack stack) - { - for (AltarRecipeRegistry.AltarRecipe recipe : AltarRecipeRegistry.getRecipes().values()) - { - if (recipe != null && !recipe.isFillable()) - { + public static AltarRecipeRegistry.AltarRecipe getAltarRecipeForOutput(ItemStack stack) { + for (AltarRecipeRegistry.AltarRecipe recipe : AltarRecipeRegistry.getRecipes().values()) { + if (recipe != null && !recipe.isFillable()) { ItemStack resultStack = recipe.getOutput(); - if (!resultStack.isEmpty()) - { - if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) - { + if (!resultStack.isEmpty()) { + if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) { return recipe; } } @@ -49,17 +38,12 @@ public class RecipeHelper return null; } - public static TartaricForgeRecipe getForgeRecipeForOutput(ItemStack stack) - { - for (TartaricForgeRecipe recipe : TartaricForgeRecipeRegistry.getRecipeList()) - { - if (recipe != null) - { + public static TartaricForgeRecipe getForgeRecipeForOutput(ItemStack stack) { + for (TartaricForgeRecipe recipe : TartaricForgeRecipeRegistry.getRecipeList()) { + if (recipe != null) { ItemStack resultStack = recipe.getRecipeOutput(); - if (!resultStack.isEmpty()) - { - if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) - { + if (!resultStack.isEmpty()) { + if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) { return recipe; } } diff --git a/src/main/java/WayofTime/bloodmagic/util/helper/TextHelper.java b/src/main/java/WayofTime/bloodmagic/util/helper/TextHelper.java index 08da2246..42b3a443 100644 --- a/src/main/java/WayofTime/bloodmagic/util/helper/TextHelper.java +++ b/src/main/java/WayofTime/bloodmagic/util/helper/TextHelper.java @@ -6,25 +6,20 @@ import org.apache.commons.lang3.text.WordUtils; import java.util.ArrayList; import java.util.List; -public class TextHelper -{ - public static String getFormattedText(String string) - { +public class TextHelper { + public static String getFormattedText(String string) { return string.replaceAll("&", "\u00A7"); } - public static String localize(String input, Object... format) - { + public static String localize(String input, Object... format) { return I18n.translateToLocalFormatted(input, format); } - public static String localizeEffect(String input, Object... format) - { + public static String localizeEffect(String input, Object... format) { return getFormattedText(localize(input, format)); } - public static String[] localizeAll(String[] input) - { + public static String[] localizeAll(String[] input) { String[] ret = new String[input.length]; for (int i = 0; i < input.length; i++) ret[i] = localize(input[i]); @@ -32,8 +27,7 @@ public class TextHelper return ret; } - public static String[] localizeAllEffect(String[] input) - { + public static String[] localizeAllEffect(String[] input) { String[] ret = new String[input.length]; for (int i = 0; i < input.length; i++) ret[i] = localizeEffect(input[i]); @@ -41,8 +35,7 @@ public class TextHelper return ret; } - public static ArrayList localizeAll(List input) - { + public static ArrayList localizeAll(List input) { ArrayList ret = new ArrayList(input.size()); for (int i = 0; i < input.size(); i++) ret.add(i, localize(input.get(i))); @@ -50,8 +43,7 @@ public class TextHelper return ret; } - public static ArrayList localizeAllEffect(List input) - { + public static ArrayList localizeAllEffect(List input) { ArrayList ret = new ArrayList(input.size()); for (int i = 0; i < input.size(); i++) ret.add(i, localizeEffect(input.get(i))); @@ -59,18 +51,15 @@ public class TextHelper return ret; } - public static String[] cutLongString(String string, int characters) - { + public static String[] cutLongString(String string, int characters) { return WordUtils.wrap(string, characters, "/cut", false).split("/cut"); } - public static String[] cutLongString(String string) - { + public static String[] cutLongString(String string) { return cutLongString(string, 30); } - public static boolean canTranslate(String key) - { + public static boolean canTranslate(String key) { return I18n.canTranslate(key); } }