BloodMagic/src/main/java/WayofTime/bloodmagic/meteor/MeteorRegistry.java

45 lines
1.7 KiB
Java
Raw Normal View History

package WayofTime.bloodmagic.meteor;
2017-08-15 21:30:48 -07:00
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;
2017-08-15 21:30:48 -07:00
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MeteorRegistry {
public static Map<ItemStackWrapper, Meteor> meteorMap = new HashMap<ItemStackWrapper, Meteor>();
2017-08-15 21:30:48 -07:00
public static void registerMeteor(ItemStack stack, Meteor holder) {
ItemStackWrapper wrapper = ItemStackWrapper.getHolder(stack);
2017-08-15 21:30:48 -07:00
if (wrapper != null) {
meteorMap.put(wrapper, holder);
}
}
2017-08-15 21:30:48 -07:00
public static void registerMeteor(ItemStack stack, List<MeteorComponent> componentList, float explosionStrength, int radius) {
Meteor holder = new Meteor(stack, componentList, explosionStrength, radius);
registerMeteor(stack, holder);
}
2017-08-15 21:30:48 -07:00
public static boolean hasMeteorForItem(ItemStack stack) {
ItemStackWrapper wrapper = ItemStackWrapper.getHolder(stack);
return wrapper != null && meteorMap.containsKey(wrapper);
}
2017-08-15 21:30:48 -07:00
public static Meteor getMeteorForItem(ItemStack stack) {
ItemStackWrapper wrapper = ItemStackWrapper.getHolder(stack);
return wrapper != null ? meteorMap.get(wrapper) : null;
}
2017-08-15 21:30:48 -07:00
public static void generateMeteorForItem(ItemStack stack, World world, BlockPos pos, IBlockState fillerBlock, double radiusModifier, double explosionModifier, double fillerChance) {
Meteor holder = getMeteorForItem(stack);
2017-08-15 21:30:48 -07:00
if (holder != null) {
holder.generateMeteor(world, pos, fillerBlock, radiusModifier, explosionModifier, fillerChance);
}
}
}