Mark of the Falling Tower now demands sacrifices again (#1222)
This commit is contained in:
parent
7167aba23c
commit
fa59e7000a
|
@ -1,23 +1,22 @@
|
||||||
package WayofTime.bloodmagic.meteor;
|
package WayofTime.bloodmagic.meteor;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.apibutnotreally.ItemStackWrapper;
|
import com.google.common.collect.Maps;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class MeteorRegistry {
|
public class MeteorRegistry {
|
||||||
public static Map<ItemStackWrapper, Meteor> meteorMap = new HashMap<ItemStackWrapper, Meteor>();
|
|
||||||
|
public static Map<ItemStack, Meteor> meteorMap = Maps.newHashMap();
|
||||||
|
|
||||||
public static void registerMeteor(ItemStack stack, Meteor holder) {
|
public static void registerMeteor(ItemStack stack, Meteor holder) {
|
||||||
ItemStackWrapper wrapper = ItemStackWrapper.getHolder(stack);
|
if (!stack.isEmpty())
|
||||||
if (wrapper != null) {
|
meteorMap.put(stack, holder);
|
||||||
meteorMap.put(wrapper, holder);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMeteor(ItemStack stack, List<MeteorComponent> componentList, float explosionStrength, int radius) {
|
public static void registerMeteor(ItemStack stack, List<MeteorComponent> componentList, float explosionStrength, int radius) {
|
||||||
|
@ -25,20 +24,21 @@ public class MeteorRegistry {
|
||||||
registerMeteor(stack, holder);
|
registerMeteor(stack, holder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasMeteorForItem(ItemStack stack) {
|
@Nullable
|
||||||
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);
|
if (stack.isEmpty())
|
||||||
return wrapper != null ? meteorMap.get(wrapper) : null;
|
return null;
|
||||||
|
|
||||||
|
for (Map.Entry<ItemStack, Meteor> entry : meteorMap.entrySet())
|
||||||
|
if (ItemStack.areItemsEqual(stack, entry.getKey()))
|
||||||
|
return entry.getValue();
|
||||||
|
|
||||||
|
return 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);
|
Meteor meteor = getMeteorForItem(stack);
|
||||||
if (holder != null) {
|
if (meteor != null)
|
||||||
holder.generateMeteor(world, pos, fillerBlock, radiusModifier, explosionModifier, fillerChance);
|
meteor.generateMeteor(world, pos, fillerBlock, radiusModifier, explosionModifier, fillerChance);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import WayofTime.bloodmagic.apibutnotreally.ritual.*;
|
||||||
import WayofTime.bloodmagic.apibutnotreally.soul.EnumDemonWillType;
|
import WayofTime.bloodmagic.apibutnotreally.soul.EnumDemonWillType;
|
||||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||||
import WayofTime.bloodmagic.entity.projectile.EntityMeteor;
|
import WayofTime.bloodmagic.entity.projectile.EntityMeteor;
|
||||||
|
import WayofTime.bloodmagic.meteor.Meteor;
|
||||||
import WayofTime.bloodmagic.meteor.MeteorRegistry;
|
import WayofTime.bloodmagic.meteor.MeteorRegistry;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -50,10 +51,11 @@ public class RitualMeteor extends Ritual {
|
||||||
|
|
||||||
for (EntityItem entityItem : itemList) {
|
for (EntityItem entityItem : itemList) {
|
||||||
ItemStack stack = entityItem.getItem();
|
ItemStack stack = entityItem.getItem();
|
||||||
if (MeteorRegistry.hasMeteorForItem(stack)) {
|
Meteor meteor = MeteorRegistry.getMeteorForItem(stack);
|
||||||
EntityMeteor meteor = new EntityMeteor(world, pos.getX(), 260, pos.getZ(), 0, -0.1, 0, radiusModifier, explosionModifier, fillerChance);
|
if (meteor != null) {
|
||||||
meteor.setMeteorStack(stack.copy());
|
EntityMeteor entityMeteor = new EntityMeteor(world, pos.getX(), 260, pos.getZ(), 0, -0.1, 0, radiusModifier, explosionModifier, fillerChance);
|
||||||
world.spawnEntity(meteor);
|
entityMeteor.setMeteorStack(stack.copy());
|
||||||
|
world.spawnEntity(entityMeteor);
|
||||||
|
|
||||||
entityItem.setDead();
|
entityItem.setDead();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue