From 5ad3c0eda101991a80cc79ba75009c4d2f7e2277 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Thu, 13 Oct 2016 19:58:39 -0400 Subject: [PATCH] Added new potion effects for bouncing as well as clinging to walls - the sigils will come later (Hai, Yulife~) --- .../bloodmagic/livingArmour/LivingArmour.java | 2 - .../bloodmagic/registry/ModPotions.java | 6 ++- .../bloodmagic/registry/ModRecipes.java | 5 +- .../java/WayofTime/bloodmagic/util/Utils.java | 23 ++++++++ .../util/handler/event/GenericHandler.java | 52 +++++++++++++++++++ 5 files changed, 83 insertions(+), 5 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java b/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java index 8a2f5f70..6c880de0 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java @@ -221,8 +221,6 @@ public class LivingArmour implements ILivingArmour } } - boolean allowOnlyDowngrades = player.isPotionActive(ModPotions.immuneSuppress); - for (Entry entry : trackerMap.entrySet()) { StatTracker tracker = entry.getValue(); diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModPotions.java b/src/main/java/WayofTime/bloodmagic/registry/ModPotions.java index 23375920..a5e0f4f7 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModPotions.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModPotions.java @@ -21,7 +21,8 @@ public class ModPotions public static Potion plantLeech; public static Potion deafness; - public static Potion immuneSuppress; + public static Potion bounce; + public static Potion cling; public static void init() { @@ -49,7 +50,8 @@ public class ModPotions constrict = registerPotion("Constriction", new ResourceLocation("constrict"), true, 0x000000, 6, 0); plantLeech = registerPotion("Plant Leech", new ResourceLocation("plantLeech"), true, 0x000000, 7, 0); deafness = registerPotion("Deaf", new ResourceLocation("deafness"), true, 0x000000, 0, 1); - immuneSuppress = registerPotion("(-) Immunity", new ResourceLocation("immuneSuppress"), true, 0x000000, 1, 1); + bounce = registerPotion("Bounce", new ResourceLocation("bounce"), false, 0x000000, 1, 1); + cling = registerPotion("Cling", new ResourceLocation("cling"), false, 0x000000, 2, 1); // heavyHeart = new PotionBloodMagic("Heavy Heart", new // ResourceLocation(resourceLocation + // heavyHeart.getName().toLowerCase()), true, 0, 0, 0); diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java b/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java index b7088f96..d7a816e3 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java @@ -455,10 +455,13 @@ public class ModRecipes addPotionRecipe(1000, 1, new ItemStack(Items.GLASS_BOTTLE), new PotionEffect(MobEffects.INVISIBILITY, 2 * 60 * 20)); addPotionRecipe(1000, 1, new ItemStack(Items.POISONOUS_POTATO), new PotionEffect(MobEffects.SATURATION, 1)); addPotionRecipe(1000, 1, new ItemStack(ModItems.BLOOD_SHARD, 1, 0), new PotionEffect(MobEffects.HEALTH_BOOST, 2 * 60 * 20)); + addPotionRecipe(100, 1, new ItemStack(Blocks.SLIME_BLOCK), new PotionEffect(ModPotions.bounce, 2 * 60 * 20)); + addPotionRecipe(100, 1, new ItemStack(Items.STRING), new PotionEffect(ModPotions.cling, 2 * 60 * 20)); addPotionRecipe(1000, 1, new ItemStack(Items.BEETROOT), new PotionEffect(ModPotions.deafness, 450)); - AlchemyTableRecipeRegistry.registerRecipe(new AlchemyTablePotionRecipe(5000, 100, 4, ItemLivingArmourPointsUpgrade.getStack(ItemLivingArmourPointsUpgrade.DRAFT_ANGELUS), new PotionEffect(ModPotions.immuneSuppress, 15 * 60 * 20))); +// AlchemyTableRecipeRegistry.registerRecipe(new AlchemyTablePotionRecipe(5000, 100, 4, new ItemStack(Blocks.SLIME_BLOCK), new PotionEffect(ModPotions.bounce, 15 * 60 * 20))); +// AlchemyTableRecipeRegistry.registerRecipe(new AlchemyTablePotionRecipe(5000, 100, 4, new ItemStack(Items.STRING), new PotionEffect(ModPotions.bounce, 15 * 60 * 20))); } static ItemStack mundaneLengtheningStack = ItemComponent.getStack(ItemComponent.CATALYST_LENGTH_1); diff --git a/src/main/java/WayofTime/bloodmagic/util/Utils.java b/src/main/java/WayofTime/bloodmagic/util/Utils.java index d6aa4353..e39e3f8c 100644 --- a/src/main/java/WayofTime/bloodmagic/util/Utils.java +++ b/src/main/java/WayofTime/bloodmagic/util/Utils.java @@ -93,6 +93,29 @@ public class Utils return null; } + public static boolean isPlayerBesideSolidBlockFace(EntityPlayer player) + { + World world = player.worldObj; + double minimumDistanceFromAxis = 0.7; + BlockPos centralPos = player.getPosition(); + 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) + { + continue; + } + IBlockState state = world.getBlockState(offsetPos); + if (state.isSideSolid(world, offsetPos, facing.getOpposite())) + { + return true; + } + } + + return false; + } + public static boolean canPlayerSeeDemonWill(EntityPlayer player) { ItemStack[] mainInventory = player.inventory.mainInventory; 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 d5b906fe..852f62ca 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/GenericHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/GenericHandler.java @@ -1,6 +1,8 @@ package WayofTime.bloodmagic.util.handler.event; +import java.util.HashMap; import java.util.List; +import java.util.Map; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -28,6 +30,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.item.ItemTossEvent; import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -36,6 +39,7 @@ import net.minecraftforge.event.world.ExplosionEvent; 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.BloodMagicAPI; @@ -71,6 +75,7 @@ import WayofTime.bloodmagic.potion.BMPotionUtils; import WayofTime.bloodmagic.registry.ModItems; import WayofTime.bloodmagic.registry.ModPotions; import WayofTime.bloodmagic.util.ChatUtil; +import WayofTime.bloodmagic.util.Utils; import WayofTime.bloodmagic.util.helper.TextHelper; import com.google.common.base.Strings; @@ -78,6 +83,42 @@ import com.google.common.base.Strings; @Handler public class GenericHandler { + public Map bounceMap = new HashMap(); + + @SubscribeEvent + public void onEntityFall(LivingFallEvent event) + { + if (event.getEntityLiving() instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) event.getEntityLiving(); + if (player.isPotionActive(ModPotions.bounce) && !player.isSneaking() && event.getDistance() > 2) + { + event.setDamageMultiplier(0); + + if (player.worldObj.isRemote) + { + player.motionY *= -0.9; + player.isAirBorne = true; + player.onGround = false; + bounceMap.put(player, player.motionY); + } else + { + player.fallDistance = 0; + event.setCanceled(true); + } + } + } + } + + @SubscribeEvent + public void playerTickPost(TickEvent.PlayerTickEvent event) + { + if (event.phase == TickEvent.Phase.END && bounceMap.containsKey(event.player)) + { + event.player.motionY = bounceMap.remove(event.player); + } + } + @SubscribeEvent public void onPlayerClick(PlayerInteractEvent event) { @@ -187,6 +228,17 @@ public class GenericHandler EntityLivingBase entity = event.getEntityLiving(); + if (entity instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) entity; + if (player.worldObj.isRemote && player.isSneaking() && player.isPotionActive(ModPotions.cling) && Utils.isPlayerBesideSolidBlockFace(player) && !player.onGround) + { + player.motionY = 0; + player.motionX *= 0.8; + player.motionZ *= 0.8; + } + } + if (entity.isPotionActive(MobEffects.NIGHT_VISION)) { int duration = entity.getActivePotionEffect(MobEffects.NIGHT_VISION).getDuration();