Implemented Ritual of Grounding, a Ritual to change gravity behavior (#1501)
* Implemented Ritual of Grounding, a Ritual to change gravity behavior [x] <- x are new potion effects - (NoMod) moves entities towards the ground, prevents jumping [Grounded] - (Raw) affects players - (Corrosive) disables gravity [Suspension] - (Destructive) increases fall damage [Heavy Heart] - (Steadfast) affects bosses - (Vengeful) stronger effects, (+Corrosive) applies levitation (+Destructive) stronger effect [Grounded] prevents jumping and moves entities towards the ground, higher amplifiers cause a faster descend, interesting interaction with Sigil of Air [Suspension] disables gravity (keeps movement) [Heavy Heart] increases fall height and fall damage multiplier by 1 per level. Fixed a possible division by 0 in RitualConder. Saved event entity variable in PotionEventHandlers. Made rune configuration more readable in RitualHarvest. Signed-off-by: tobias <angryaeon@icloud.com> * Fixed Ritual area * Lists are cleared on world unload.
This commit is contained in:
parent
865968a4b8
commit
827ee85e81
7 changed files with 335 additions and 95 deletions
|
@ -29,6 +29,7 @@ import WayofTime.bloodmagic.network.DemonAuraPacketProcessor;
|
|||
import WayofTime.bloodmagic.orb.BloodOrb;
|
||||
import WayofTime.bloodmagic.orb.IBloodOrb;
|
||||
import WayofTime.bloodmagic.potion.BMPotionUtils;
|
||||
import WayofTime.bloodmagic.potion.PotionEventHandlers;
|
||||
import WayofTime.bloodmagic.ritual.IMasterRitualStone;
|
||||
import WayofTime.bloodmagic.ritual.RitualManager;
|
||||
import WayofTime.bloodmagic.soul.DemonWillHolder;
|
||||
|
@ -76,6 +77,7 @@ import net.minecraftforge.event.entity.player.PlayerEvent;
|
|||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerPickupXpEvent;
|
||||
import net.minecraftforge.event.world.ExplosionEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
@ -87,10 +89,10 @@ import java.util.*;
|
|||
|
||||
@Mod.EventBusSubscriber(modid = BloodMagic.MODID)
|
||||
public class GenericHandler {
|
||||
public static Map<EntityPlayer, Double> bounceMap = new HashMap<>();
|
||||
public static Map<EntityPlayer, Integer> filledHandMap = new HashMap<>();
|
||||
private static Map<EntityAnimal, EntityAITarget> targetTaskMap = new HashMap<>();
|
||||
private static Map<EntityAnimal, EntityAIBase> attackTaskMap = new HashMap<>();
|
||||
public static Map<World, Map<EntityPlayer, Double>> bounceMapMap = new HashMap<>();
|
||||
public static Map<World, Map<EntityPlayer, Integer>> filledHandMapMap = new HashMap<>();
|
||||
private static Map<World, Map<EntityAnimal, EntityAITarget>> targetTaskMapMap = new HashMap<>();
|
||||
private static Map<World, Map<EntityAnimal, EntityAIBase>> attackTaskMapMap = new HashMap<>();
|
||||
public static Set<IMasterRitualStone> featherRitualSet;
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -103,7 +105,7 @@ public class GenericHandler {
|
|||
if (player.getEntityWorld().isRemote) {
|
||||
player.motionY *= -0.9;
|
||||
player.fallDistance = 0;
|
||||
bounceMap.put(player, player.motionY);
|
||||
bounceMapMap.get(player.getEntityWorld()).put(player, player.motionY);
|
||||
} else {
|
||||
player.fallDistance = 0;
|
||||
event.setCanceled(true);
|
||||
|
@ -114,10 +116,13 @@ public class GenericHandler {
|
|||
|
||||
@SubscribeEvent
|
||||
public static void playerTickPost(TickEvent.PlayerTickEvent event) {
|
||||
World world = event.player.getEntityWorld();
|
||||
Map<EntityPlayer, Double> bounceMap = bounceMapMap.get(world);
|
||||
if (event.phase == TickEvent.Phase.END && bounceMap.containsKey(event.player)) {
|
||||
event.player.motionY = bounceMap.remove(event.player);
|
||||
}
|
||||
|
||||
Map<EntityPlayer, Integer> filledHandMap = filledHandMapMap.get(world);
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
if (filledHandMap.containsKey(event.player)) {
|
||||
int value = filledHandMap.get(event.player) - 1;
|
||||
|
@ -217,6 +222,9 @@ public class GenericHandler {
|
|||
sendPlayerDemonWillAura((EntityPlayer) entity);
|
||||
}
|
||||
|
||||
World world = entity.getEntityWorld();
|
||||
Map<EntityAnimal, EntityAITarget> targetTaskMap = targetTaskMapMap.get(world);
|
||||
Map<EntityAnimal, EntityAIBase> attackTaskMap = attackTaskMapMap.get(world);
|
||||
if (event.getEntityLiving() instanceof EntityAnimal) {
|
||||
EntityAnimal animal = (EntityAnimal) event.getEntityLiving();
|
||||
if (animal.isPotionActive(RegistrarBloodMagic.SACRIFICIAL_LAMB)) {
|
||||
|
@ -449,4 +457,26 @@ public class GenericHandler {
|
|||
private static int durabilityToXp(int durability) {
|
||||
return durability / 2;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onWorldLoad(WorldEvent.Load event) {
|
||||
World world = event.getWorld();
|
||||
bounceMapMap.computeIfAbsent(world, k -> new HashMap<>());
|
||||
filledHandMapMap.computeIfAbsent(world, k -> new HashMap<>());
|
||||
attackTaskMapMap.computeIfAbsent(world, k -> new HashMap<>());
|
||||
targetTaskMapMap.computeIfAbsent(world, k -> new HashMap<>());
|
||||
PotionEventHandlers.flightListMap.computeIfAbsent(world, k -> new ArrayList<>());
|
||||
PotionEventHandlers.noGravityListMap.computeIfAbsent(world, k -> new ArrayList<>());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onWorldUnload(WorldEvent.Unload event) {
|
||||
World world = event.getWorld();
|
||||
bounceMapMap.get(world).clear();
|
||||
filledHandMapMap.get(world).clear();
|
||||
attackTaskMapMap.get(world).clear();
|
||||
targetTaskMapMap.get(world).clear();
|
||||
PotionEventHandlers.flightListMap.get(world).clear();
|
||||
PotionEventHandlers.noGravityListMap.get(world).clear();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue