Move block, item, potion and enchantment registries over to the @ObjectHolder system and reorganise the potion classes a bit

This commit is contained in:
Electroblob77
2019-01-05 22:59:45 +00:00
parent eb2abdfbe9
commit 212fbe51df
8 changed files with 474 additions and 420 deletions
@@ -3,10 +3,10 @@ package electroblob.wizardry.potion;
import java.util.List;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.client.DrawingUtils;
import electroblob.wizardry.constants.Constants;
import electroblob.wizardry.entity.construct.EntityDecay;
import electroblob.wizardry.registry.WizardryPotions;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
@@ -21,12 +21,10 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@Mod.EventBusSubscriber
public class PotionDecay extends Potion {
private static final ResourceLocation ICON = new ResourceLocation(Wizardry.MODID, "textures/gui/decay_icon.png");
public class PotionDecay extends PotionMagicEffect {
public PotionDecay(boolean isBadEffect, int liquidColour){
super(isBadEffect, liquidColour);
super(isBadEffect, liquidColour, new ResourceLocation(Wizardry.MODID, "textures/gui/potion_icon_decay.png"));
// This needs to be here because registerPotionAttributeModifier doesn't like it if the potion has no name yet.
this.setPotionName("potion." + Wizardry.MODID + ":decay");
this.registerPotionAttributeModifier(SharedMonsterAttributes.MOVEMENT_SPEED,
@@ -46,20 +44,6 @@ public class PotionDecay extends Potion {
target.attackEntityFrom(DamageSource.WITHER, 1);
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc){
mc.renderEngine.bindTexture(ICON);
WizardryUtilities.drawTexturedRect(x + 6, y + 7, 0, 0, 18, 18, 18, 18);
}
@Override
@SideOnly(Side.CLIENT)
public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha){
mc.renderEngine.bindTexture(ICON);
WizardryUtilities.drawTexturedRect(x + 3, y + 3, 0, 0, 18, 18, 18, 18);
}
@SubscribeEvent
public static void onLivingUpdateEvent(LivingUpdateEvent event){
@@ -1,14 +1,13 @@
package electroblob.wizardry.potion;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.client.DrawingUtils;
import electroblob.wizardry.constants.Constants;
import electroblob.wizardry.registry.WizardryPotions;
import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.ParticleBuilder.Type;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
@@ -19,12 +18,10 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@Mod.EventBusSubscriber
public class PotionFrost extends Potion implements ICustomPotionParticles {
private static final ResourceLocation ICON = new ResourceLocation(Wizardry.MODID, "textures/gui/frost_icon.png");
public class PotionFrost extends PotionMagicEffect implements ICustomPotionParticles {
public PotionFrost(boolean isBadEffect, int liquidColour){
super(isBadEffect, liquidColour);
super(isBadEffect, liquidColour, new ResourceLocation(Wizardry.MODID, "textures/gui/potion_icon_frost.png"));
// This needs to be here because registerPotionAttributeModifier doesn't like it if the potion has no name yet.
this.setPotionName("potion." + Wizardry.MODID + ":frost");
// With -0.5 as the 'amount', frost 1 slows the entity down by a half and frost 2 roots it to the spot
@@ -33,27 +30,8 @@ public class PotionFrost extends Potion implements ICustomPotionParticles {
// More UUIDs: 85602e0b-4801-4a87-94f3-bf617c97014e
}
@Override
public void performEffect(EntityLivingBase entitylivingbase, int strength){
// Nothing here because this potion works on attribute modifiers.
}
@Override
public void spawnCustomParticle(World world, double x, double y, double z){
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc){
mc.renderEngine.bindTexture(ICON);
WizardryUtilities.drawTexturedRect(x + 6, y + 7, 0, 0, 18, 18, 18, 18);
}
@Override
@SideOnly(Side.CLIENT)
public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha){
mc.renderEngine.bindTexture(ICON);
WizardryUtilities.drawTexturedRect(x + 3, y + 3, 0, 0, 18, 18, 18, 18);
ParticleBuilder.create(Type.SNOW).pos(x, y, z).time(15 + world.rand.nextInt(5)).spawn(world);
}
@@ -1,7 +1,6 @@
package electroblob.wizardry.potion;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.util.WizardryUtilities;
import electroblob.wizardry.client.DrawingUtils;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
@@ -9,15 +8,17 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
/** Class for all potions that work on events only. */
/**
* As of Wizardry 4.2, this class is used by all of wizardry's potions. Potions that work solely on events
* instantiate this class directly, all other potions extend it.
*/
public class PotionMagicEffect extends Potion {
private static final ResourceLocation ICONS = new ResourceLocation(Wizardry.MODID, "textures/gui/potion_icons.png");
private final int textureIndex;
private final ResourceLocation texture;
public PotionMagicEffect(boolean isBadEffect, int liquidColour, int textureIndex){
public PotionMagicEffect(boolean isBadEffect, int liquidColour, ResourceLocation texture){
super(isBadEffect, liquidColour);
this.textureIndex = textureIndex;
this.texture = texture;
}
@Override
@@ -28,17 +29,20 @@ public class PotionMagicEffect extends Potion {
@Override
@SideOnly(Side.CLIENT)
public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc){
mc.renderEngine.bindTexture(ICONS);
WizardryUtilities.drawTexturedRect(x + 6, y + 7, 18 * (textureIndex % 4), 18 * (textureIndex / 4), 18, 18, 72,
72);
drawIcon(x + 6, y + 7, effect, mc);
}
@Override
@SideOnly(Side.CLIENT)
public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha){
mc.renderEngine.bindTexture(ICONS);
WizardryUtilities.drawTexturedRect(x + 3, y + 3, 18 * (textureIndex % 4), 18 * (textureIndex / 4), 18, 18, 72,
72);
net.minecraft.client.renderer.GlStateManager.color(1, 1, 1, alpha);
drawIcon(x + 3, y + 3, effect, mc);
}
@SideOnly(Side.CLIENT)
protected void drawIcon(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc){
mc.renderEngine.bindTexture(texture);
DrawingUtils.drawTexturedRect(x, y, 0, 0, 18, 18, 18, 18);
}
}
@@ -1,13 +1,16 @@
package electroblob.wizardry.potion;
import net.minecraft.util.ResourceLocation;
/**
* Same as {@link PotionMagicEffect}, but also implements {@link ICustomPotionParticles} to allow anonymous classes to
* extend it and add their own particles.
* extend it and add their own particles. It is advised that all other (named) classes extend and implement the
* underlying class and interface rather than extending this class.
*/
public abstract class PotionMagicEffectParticles extends PotionMagicEffect implements ICustomPotionParticles {
public PotionMagicEffectParticles(boolean isBadEffect, int liquidColour, int textureIndex){
super(isBadEffect, liquidColour, textureIndex);
public PotionMagicEffectParticles(boolean isBadEffect, int liquidColour, ResourceLocation texture){
super(isBadEffect, liquidColour, texture);
}
}
@@ -1,20 +1,13 @@
package electroblob.wizardry.registry;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.block.BlockArcaneWorkbench;
import electroblob.wizardry.block.BlockCrystalFlower;
import electroblob.wizardry.block.BlockCrystalOre;
import electroblob.wizardry.block.BlockMagicLight;
import electroblob.wizardry.block.BlockSnare;
import electroblob.wizardry.block.BlockSpectral;
import electroblob.wizardry.block.BlockStatue;
import electroblob.wizardry.block.BlockTransportationStone;
import electroblob.wizardry.block.BlockVanishingCobweb;
import electroblob.wizardry.block.*;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
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.ObjectHolder;
import net.minecraftforge.registries.IForgeRegistry;
/**
@@ -23,6 +16,7 @@ import net.minecraftforge.registries.IForgeRegistry;
* @author Electroblob
* @since Wizardry 2.1
*/
@ObjectHolder(Wizardry.MODID)
@Mod.EventBusSubscriber
public final class WizardryBlocks {
@@ -33,23 +27,19 @@ public final class WizardryBlocks {
// setSoundType should be public, but in this particular version it isn't... which is a bit of a pain.
public static final Block arcane_workbench = new BlockArcaneWorkbench().setHardness(1.0F).setCreativeTab(WizardryTabs.WIZARDRY);
public static final Block crystal_ore = new BlockCrystalOre(Material.ROCK).setHardness(3.0F).setCreativeTab(WizardryTabs.WIZARDRY);
public static final Block petrified_stone = new BlockStatue(Material.ROCK).setHardness(1.5F).setResistance(10.0F);
public static final Block ice_statue = new BlockStatue(Material.ICE).setHardness(0.5F).setLightOpacity(3);
public static final Block magic_light = new BlockMagicLight(Material.CIRCUITS);
public static final Block crystal_flower = new BlockCrystalFlower(Material.PLANTS).setHardness(0.0F).setCreativeTab(WizardryTabs.WIZARDRY);
public static final Block snare = new BlockSnare(Material.PLANTS).setHardness(0.0F);
public static final Block transportation_stone = new BlockTransportationStone(Material.ROCK).setHardness(0.3F).setLightLevel(0.5f).setLightOpacity(0).setCreativeTab(WizardryTabs.WIZARDRY);
public static final Block spectral_block = new BlockSpectral(Material.GLASS).setLightLevel(0.7f).setLightOpacity(0).setBlockUnbreakable().setResistance(6000000.0F);
public static final Block crystal_block = new Block(Material.IRON).setHardness(5.0F).setResistance(10.0F).setCreativeTab(WizardryTabs.WIZARDRY);
public static final Block meteor = new Block(Material.ROCK).setLightLevel(1);
public static final Block vanishing_cobweb = new BlockVanishingCobweb(Material.WEB).setLightOpacity(1).setHardness(4.0F);
static{
// This is here because Block#setHarvestLevel isn't chainable.
crystal_block.setHarvestLevel("pickaxe", 2);
}
public static final Block arcane_workbench = null;
public static final Block crystal_ore = null;
public static final Block petrified_stone = null;
public static final Block ice_statue = null;
public static final Block magic_light = null;
public static final Block crystal_flower = null;
public static final Block snare = null;
public static final Block transportation_stone = null;
public static final Block spectral_block = null;
public static final Block crystal_block = null;
public static final Block meteor = null;
public static final Block vanishing_cobweb = null;
public static final Block runestone = null;
/**
* Sets both the registry and unlocalised names of the given block, then registers it with the given registry. Use
@@ -57,11 +47,11 @@ public final class WizardryBlocks {
* construction, for convenience and consistency.
*
* @param registry The registry to register the given block to.
* @param item The block to register.
* @param name The name of the block, without the mod ID or the .name stuff. The registry name will be
* {@code ebwizardry:[name]}. The unlocalised name will be {@code tile.ebwizardry:[name].name}.
* @param item The block to register.
*/
public static void registerBlock(IForgeRegistry<Block> registry, Block block, String name){
public static void registerBlock(IForgeRegistry<Block> registry, String name, Block block){
block.setRegistryName(Wizardry.MODID, name);
block.setUnlocalizedName(block.getRegistryName().toString());
registry.register(block);
@@ -71,18 +61,20 @@ public final class WizardryBlocks {
public static void register(RegistryEvent.Register<Block> event){
IForgeRegistry<Block> registry = event.getRegistry();
registerBlock(registry, "arcane_workbench", new BlockArcaneWorkbench().setHardness(1.0F).setCreativeTab(WizardryTabs.WIZARDRY));
registerBlock(registry, "crystal_ore", new BlockCrystalOre(Material.ROCK).setHardness(3.0F).setCreativeTab(WizardryTabs.WIZARDRY));
registerBlock(registry, "petrified_stone", new BlockStatue(Material.ROCK).setHardness(1.5F).setResistance(10.0F));
registerBlock(registry, "ice_statue", new BlockStatue(Material.ICE).setHardness(0.5F).setLightOpacity(3));
registerBlock(registry, "magic_light", new BlockMagicLight(Material.CIRCUITS));
registerBlock(registry, "crystal_flower", new BlockCrystalFlower(Material.PLANTS).setHardness(0.0F).setCreativeTab(WizardryTabs.WIZARDRY));
registerBlock(registry, "snare", new BlockSnare(Material.PLANTS).setHardness(0.0F));
registerBlock(registry, "transportation_stone", new BlockTransportationStone(Material.ROCK).setHardness(0.3F).setLightLevel(0.5f).setLightOpacity(0).setCreativeTab(WizardryTabs.WIZARDRY));
registerBlock(registry, "spectral_block", new BlockSpectral(Material.GLASS).setLightLevel(0.7f).setLightOpacity(0).setBlockUnbreakable().setResistance(6000000.0F));
registerBlock(registry, "crystal_block", new BlockCrystal(Material.IRON).setHardness(5.0F).setResistance(10.0F).setCreativeTab(WizardryTabs.WIZARDRY));
registerBlock(registry, "meteor", new Block(Material.ROCK).setLightLevel(1));
registerBlock(registry, "vanishing_cobweb", new BlockVanishingCobweb(Material.WEB).setLightOpacity(1).setHardness(4.0F));
registerBlock(registry, "runestone", new BlockRunestone(Material.ROCK));
registerBlock(registry, arcane_workbench, "arcane_workbench");
registerBlock(registry, crystal_ore, "crystal_ore");
registerBlock(registry, petrified_stone, "petrified_stone");
registerBlock(registry, ice_statue, "ice_statue");
registerBlock(registry, magic_light, "magic_light");
registerBlock(registry, crystal_flower, "crystal_flower");
registerBlock(registry, snare, "snare");
registerBlock(registry, transportation_stone, "transportation_stone");
registerBlock(registry, spectral_block, "spectral_block");
registerBlock(registry, crystal_block, "crystal_block");
registerBlock(registry, meteor, "meteor");
registerBlock(registry, vanishing_cobweb, "vanishing_cobweb");
}
}
@@ -26,20 +26,17 @@ public final class WizardryEnchantments {
// All of these have custom classes, so the unlocalised name (referred to simply as 'name' for enchantments) is
// dealt with inside those classes.
public static final Enchantment magic_sword = new EnchantmentMagicSword().setRegistryName(Wizardry.MODID,
"magic_sword");
public static final Enchantment magic_bow = new EnchantmentTimed().setRegistryName(Wizardry.MODID, "magic_bow");
public static final Enchantment flaming_weapon = new EnchantmentTimed().setRegistryName(Wizardry.MODID,
"flaming_weapon");
public static final Enchantment freezing_weapon = new EnchantmentTimed().setRegistryName(Wizardry.MODID,
"freezing_weapon");
public static final Enchantment magic_sword = null;
public static final Enchantment magic_bow = null;
public static final Enchantment flaming_weapon = null;
public static final Enchantment freezing_weapon = null;
@SubscribeEvent
public static void register(RegistryEvent.Register<Enchantment> event){
event.getRegistry().register(magic_sword);
event.getRegistry().register(magic_bow);
event.getRegistry().register(flaming_weapon);
event.getRegistry().register(freezing_weapon);
event.getRegistry().register(new EnchantmentMagicSword().setRegistryName(Wizardry.MODID, "magic_sword"));
event.getRegistry().register(new EnchantmentTimed().setRegistryName(Wizardry.MODID, "magic_bow"));
event.getRegistry().register(new EnchantmentTimed().setRegistryName(Wizardry.MODID, "flaming_weapon"));
event.getRegistry().register(new EnchantmentTimed().setRegistryName(Wizardry.MODID, "freezing_weapon"));
}
}
@@ -40,6 +40,7 @@ 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.ObjectHolder;
import net.minecraftforge.registries.IForgeRegistry;
/**
@@ -49,144 +50,145 @@ import net.minecraftforge.registries.IForgeRegistry;
* @author Electroblob
* @since Wizardry 2.1
*/
@ObjectHolder(Wizardry.MODID)
@Mod.EventBusSubscriber
public final class WizardryItems {
public static final Item magic_crystal = new Item().setCreativeTab(WizardryTabs.WIZARDRY);
public static final Item magic_wand = new ItemWand(Tier.BASIC, null);
public static final Item apprentice_wand = new ItemWand(Tier.APPRENTICE, null);
public static final Item advanced_wand = new ItemWand(Tier.ADVANCED, null);
public static final Item master_wand = new ItemWand(Tier.MASTER, null);
public static final Item arcane_tome = new ItemArcaneTome();
public static final Item wizard_handbook = new ItemWizardHandbook();
public static final Item spell_book = new ItemSpellBook();
public static final Item basic_fire_wand = new ItemWand(Tier.BASIC, Element.FIRE);
public static final Item basic_ice_wand = new ItemWand(Tier.BASIC, Element.ICE);
public static final Item basic_lightning_wand = new ItemWand(Tier.BASIC, Element.LIGHTNING);
public static final Item basic_necromancy_wand = new ItemWand(Tier.BASIC, Element.NECROMANCY);
public static final Item basic_earth_wand = new ItemWand(Tier.BASIC, Element.EARTH);
public static final Item basic_sorcery_wand = new ItemWand(Tier.BASIC, Element.SORCERY);
public static final Item basic_healing_wand = new ItemWand(Tier.BASIC, Element.HEALING);
public static final Item apprentice_fire_wand = new ItemWand(Tier.APPRENTICE, Element.FIRE);
public static final Item apprentice_ice_wand = new ItemWand(Tier.APPRENTICE, Element.ICE);
public static final Item apprentice_lightning_wand = new ItemWand(Tier.APPRENTICE, Element.LIGHTNING);
public static final Item apprentice_necromancy_wand = new ItemWand(Tier.APPRENTICE, Element.NECROMANCY);
public static final Item apprentice_earth_wand = new ItemWand(Tier.APPRENTICE, Element.EARTH);
public static final Item apprentice_sorcery_wand = new ItemWand(Tier.APPRENTICE, Element.SORCERY);
public static final Item apprentice_healing_wand = new ItemWand(Tier.APPRENTICE, Element.HEALING);
public static final Item advanced_fire_wand = new ItemWand(Tier.ADVANCED, Element.FIRE);
public static final Item advanced_ice_wand = new ItemWand(Tier.ADVANCED, Element.ICE);
public static final Item advanced_lightning_wand = new ItemWand(Tier.ADVANCED, Element.LIGHTNING);
public static final Item advanced_necromancy_wand = new ItemWand(Tier.ADVANCED, Element.NECROMANCY);
public static final Item advanced_earth_wand = new ItemWand(Tier.ADVANCED, Element.EARTH);
public static final Item advanced_sorcery_wand = new ItemWand(Tier.ADVANCED, Element.SORCERY);
public static final Item advanced_healing_wand = new ItemWand(Tier.ADVANCED, Element.HEALING);
public static final Item master_fire_wand = new ItemWand(Tier.MASTER, Element.FIRE);
public static final Item master_ice_wand = new ItemWand(Tier.MASTER, Element.ICE);
public static final Item master_lightning_wand = new ItemWand(Tier.MASTER, Element.LIGHTNING);
public static final Item master_necromancy_wand = new ItemWand(Tier.MASTER, Element.NECROMANCY);
public static final Item master_earth_wand = new ItemWand(Tier.MASTER, Element.EARTH);
public static final Item master_sorcery_wand = new ItemWand(Tier.MASTER, Element.SORCERY);
public static final Item master_healing_wand = new ItemWand(Tier.MASTER, Element.HEALING);
public static final Item spectral_sword = new ItemSpectralSword(ToolMaterial.IRON);
public static final Item spectral_pickaxe = new ItemSpectralPickaxe(ToolMaterial.IRON);
public static final Item spectral_bow = new ItemSpectralBow();
public static final Item mana_flask = new Item().setCreativeTab(WizardryTabs.WIZARDRY);
public static final Item storage_upgrade = new Item().setCreativeTab(WizardryTabs.WIZARDRY);
public static final Item siphon_upgrade = new Item().setCreativeTab(WizardryTabs.WIZARDRY);
public static final Item condenser_upgrade = new Item().setCreativeTab(WizardryTabs.WIZARDRY);
public static final Item range_upgrade = new Item().setCreativeTab(WizardryTabs.WIZARDRY);
public static final Item duration_upgrade = new Item().setCreativeTab(WizardryTabs.WIZARDRY);
public static final Item cooldown_upgrade = new Item().setCreativeTab(WizardryTabs.WIZARDRY);
public static final Item blast_upgrade = new Item().setCreativeTab(WizardryTabs.WIZARDRY);
public static final Item attunement_upgrade = new Item().setCreativeTab(WizardryTabs.WIZARDRY);
public static final Item magic_silk = new Item().setCreativeTab(WizardryTabs.WIZARDRY);
public static final Item.ToolMaterial MAGICAL = EnumHelper.addToolMaterial("MAGICAL", 3, 1000, 8.0f, 4.0f, 0);
public static final Item flaming_axe = new ItemFlamingAxe(MAGICAL);
public static final Item frost_axe = new ItemFrostAxe(MAGICAL);
public static final Item firebomb = new ItemFirebomb();
public static final Item poison_bomb = new ItemPoisonBomb();
public static final Item blank_scroll = new ItemBlankScroll();
public static final Item scroll = new ItemScroll();
// The only way to get these is in dungeon chests (They are legendary, after all. Wizards don't just have them.
// Also if they were sold you could buy four from the same wizard - and that's no fun at all!)
public static final Item armour_upgrade = new ItemArmourUpgrade();
public static final ArmorMaterial SILK = EnumHelper.addArmorMaterial("SILK",
"wizardry/textures/armour/wizard_armour", 15, new int[]{0, 0, 0, 0}, 0,
SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0.0F);
// Saw a post somewhere that said you have to put these in the init methods rather than defining them as constants.
// I *think* that's because the post was for a newer Minecraft version, where custom armour has its own renderer or
// something, meaning it would be done a lot like the entity rendering registry in ClientProxy. This is all working
// fine it seems, so I'm not going to fiddle with it, but it might be useful to know if I update versions again.
public static final Item wizard_hat = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.HEAD, null);
public static final Item wizard_robe = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.CHEST, null);
public static final Item wizard_leggings = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.LEGS, null);
public static final Item wizard_boots = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.FEET, null);
/** Keeping the material fields in here means {@code @ObjectHolder} ignores them. In actual fact, I could have just
* made them private since wizardry only uses them within this class, but in case someone needs them elsewhere I've
* used this trick instead to keep them public. */
public static final class Materials {
public static final Item wizard_hat_fire = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.HEAD, Element.FIRE);
public static final Item wizard_robe_fire = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.CHEST, Element.FIRE);
public static final Item wizard_leggings_fire = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.LEGS, Element.FIRE);
public static final Item wizard_boots_fire = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.FEET, Element.FIRE);
public static final Item wizard_hat_ice = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.HEAD, Element.ICE);
public static final Item wizard_robe_ice = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.CHEST, Element.ICE);
public static final Item wizard_leggings_ice = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.LEGS, Element.ICE);
public static final Item wizard_boots_ice = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.FEET, Element.ICE);
public static final Item wizard_hat_lightning = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.HEAD, Element.LIGHTNING);
public static final Item wizard_robe_lightning = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.CHEST, Element.LIGHTNING);
public static final Item wizard_leggings_lightning = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.LEGS, Element.LIGHTNING);
public static final Item wizard_boots_lightning = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.FEET, Element.LIGHTNING);
public static final Item wizard_hat_necromancy = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.HEAD, Element.NECROMANCY);
public static final Item wizard_robe_necromancy = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.CHEST, Element.NECROMANCY);
public static final Item wizard_leggings_necromancy = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.LEGS, Element.NECROMANCY);
public static final Item wizard_boots_necromancy = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.FEET, Element.NECROMANCY);
public static final Item wizard_hat_earth = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.HEAD, Element.EARTH);
public static final Item wizard_robe_earth = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.CHEST, Element.EARTH);
public static final Item wizard_leggings_earth = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.LEGS, Element.EARTH);
public static final Item wizard_boots_earth = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.FEET, Element.EARTH);
public static final Item wizard_hat_sorcery = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.HEAD, Element.SORCERY);
public static final Item wizard_robe_sorcery = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.CHEST, Element.SORCERY);
public static final Item wizard_leggings_sorcery = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.LEGS, Element.SORCERY);
public static final Item wizard_boots_sorcery = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.FEET, Element.SORCERY);
public static final Item wizard_hat_healing = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.HEAD, Element.HEALING);
public static final Item wizard_robe_healing = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.CHEST, Element.HEALING);
public static final Item wizard_leggings_healing = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.LEGS, Element.HEALING);
public static final Item wizard_boots_healing = new ItemWizardArmour(SILK, 1, EntityEquipmentSlot.FEET, Element.HEALING);
public static final Item spectral_helmet = new ItemSpectralArmour(ArmorMaterial.IRON, 1, EntityEquipmentSlot.HEAD);
public static final Item spectral_chestplate = new ItemSpectralArmour(ArmorMaterial.IRON, 1, EntityEquipmentSlot.CHEST);
public static final Item spectral_leggings = new ItemSpectralArmour(ArmorMaterial.IRON, 1, EntityEquipmentSlot.LEGS);
public static final Item spectral_boots = new ItemSpectralArmour(ArmorMaterial.IRON, 1, EntityEquipmentSlot.FEET);
public static final Map<EntityEquipmentSlot, Item> SPECTRAL_ARMOUR_MAP = ImmutableMap.of(
EntityEquipmentSlot.HEAD, spectral_helmet, EntityEquipmentSlot.CHEST, spectral_chestplate,
EntityEquipmentSlot.LEGS, spectral_leggings, EntityEquipmentSlot.FEET, spectral_boots);
public static final ToolMaterial MAGICAL = EnumHelper.addToolMaterial("MAGICAL", 3, 1000, 8.0f, 4.0f, 0);
public static final ArmorMaterial SILK = EnumHelper.addArmorMaterial("SILK", "wizardry/textures/armour/wizard_armour",
15, new int[]{0, 0, 0, 0}, 0, WizardrySounds.ITEM_ARMOUR_EQUIP_SILK, 0.0F);
}
public static final Item smoke_bomb = new ItemSmokeBomb();
// This is the most concise way I can think of to register the items. Really, I'd prefer it if there was only one
// point where all the items were listed, but that's not possible within the current system unless you use an array,
// which means you lose the individual fields...
public static final Item identification_scroll = new ItemIdentificationScroll();
public static final Item magic_crystal = null;
public static final Item magic_wand = null;
public static final Item apprentice_wand = null;
public static final Item advanced_wand = null;
public static final Item master_wand = null;
public static final Item arcane_tome = null;
public static final Item wizard_handbook = null;
public static final Item spell_book = null;
public static final Item basic_fire_wand = null;
public static final Item basic_ice_wand = null;
public static final Item basic_lightning_wand = null;
public static final Item basic_necromancy_wand = null;
public static final Item basic_earth_wand = null;
public static final Item basic_sorcery_wand = null;
public static final Item basic_healing_wand = null;
public static final Item apprentice_fire_wand = null;
public static final Item apprentice_ice_wand = null;
public static final Item apprentice_lightning_wand = null;
public static final Item apprentice_necromancy_wand = null;
public static final Item apprentice_earth_wand = null;
public static final Item apprentice_sorcery_wand = null;
public static final Item apprentice_healing_wand = null;
public static final Item advanced_fire_wand = null;
public static final Item advanced_ice_wand = null;
public static final Item advanced_lightning_wand = null;
public static final Item advanced_necromancy_wand = null;
public static final Item advanced_earth_wand = null;
public static final Item advanced_sorcery_wand = null;
public static final Item advanced_healing_wand = null;
public static final Item master_fire_wand = null;
public static final Item master_ice_wand = null;
public static final Item master_lightning_wand = null;
public static final Item master_necromancy_wand = null;
public static final Item master_earth_wand = null;
public static final Item master_sorcery_wand = null;
public static final Item master_healing_wand = null;
public static final Item spectral_sword = null;
public static final Item spectral_pickaxe = null;
public static final Item spectral_bow = null;
public static final Item medium_mana_flask = null;
public static final Item storage_upgrade = null;
public static final Item siphon_upgrade = null;
public static final Item condenser_upgrade = null;
public static final Item range_upgrade = null;
public static final Item duration_upgrade = null;
public static final Item cooldown_upgrade = null;
public static final Item blast_upgrade = null;
public static final Item attunement_upgrade = null;
public static final Item magic_silk = null;
public static final Item flaming_axe = null;
public static final Item frost_axe = null;
public static final Item firebomb = null;
public static final Item poison_bomb = null;
public static final Item blank_scroll = null;
public static final Item scroll = null;
public static final Item armour_upgrade = null;
public static final Item wizard_hat = null;
public static final Item wizard_robe = null;
public static final Item wizard_leggings = null;
public static final Item wizard_boots = null;
public static final Item wizard_hat_fire = null;
public static final Item wizard_robe_fire = null;
public static final Item wizard_leggings_fire = null;
public static final Item wizard_boots_fire = null;
public static final Item wizard_hat_ice = null;
public static final Item wizard_robe_ice = null;
public static final Item wizard_leggings_ice = null;
public static final Item wizard_boots_ice = null;
public static final Item wizard_hat_lightning = null;
public static final Item wizard_robe_lightning = null;
public static final Item wizard_leggings_lightning = null;
public static final Item wizard_boots_lightning = null;
public static final Item wizard_hat_necromancy = null;
public static final Item wizard_robe_necromancy = null;
public static final Item wizard_leggings_necromancy = null;
public static final Item wizard_boots_necromancy = null;
public static final Item wizard_hat_earth = null;
public static final Item wizard_robe_earth = null;
public static final Item wizard_leggings_earth = null;
public static final Item wizard_boots_earth = null;
public static final Item wizard_hat_sorcery = null;
public static final Item wizard_robe_sorcery = null;
public static final Item wizard_leggings_sorcery = null;
public static final Item wizard_boots_sorcery = null;
public static final Item wizard_hat_healing = null;
public static final Item wizard_robe_healing = null;
public static final Item wizard_leggings_healing = null;
public static final Item wizard_boots_healing = null;
public static final Item spectral_helmet = null;
public static final Item spectral_chestplate = null;
public static final Item spectral_leggings = null;
public static final Item spectral_boots = null;
public static final Item smoke_bomb = null;
public static final Item identification_scroll = null;
private static final Map<Pair<Tier, Element>, Item> WAND_MAP = new HashMap<>();
private static final Map<Pair<EntityEquipmentSlot, Element>, Item> ARMOUR_MAP = new HashMap<>();
@@ -303,23 +305,60 @@ public final class WizardryItems {
/**
* Sets both the registry and unlocalised names of the given item, then registers it with the given registry. Use
* this instead of {@link Item#setRegistryName(String)} and {@link Item#setUnlocalizedName(String)} during
* construction, for convenience and consistency.
* construction, for convenience and consistency. As of wizardry 4.2, this also automatically adds it to the order
* list for its creative tab if that tab is a {@link CreativeTabListed}, meaning the order can be defined simply
* by the order in which the items are registered in this class.
*
* @param registry The registry to register the given item to.
* @param item The item to register.
* @param name The name of the item, without the mod ID or the .name stuff. The registry name will be
* {@code ebwizardry:[name]}. The unlocalised name will be {@code item.ebwizardry:[name].name}.
* @param item The item to register.
*/
public static void registerItem(IForgeRegistry<Item> registry, Item item, String name){
// It now makes sense to have the name first, since it's shorter than an entire item declaration.
public static void registerItem(IForgeRegistry<Item> registry, String name, Item item){
registerItem(registry, name, item, false);
}
/**
* Sets both the registry and unlocalised names of the given item, then registers it with the given registry. Use
* this instead of {@link Item#setRegistryName(String)} and {@link Item#setUnlocalizedName(String)} during
* construction, for convenience and consistency. As of wizardry 4.2, this also automatically adds it to the order
* list for its creative tab if that tab is a {@link CreativeTabListed}, meaning the order can be defined simply
* by the order in which the items are registered in this class.
*
* @param registry The registry to register the given item to.
* @param name The name of the item, without the mod ID or the .name stuff. The registry name will be
* {@code ebwizardry:[name]}. The unlocalised name will be {@code item.ebwizardry:[name].name}.
* @param item The item to register.
* @param setTabIcon True to set this item as the icon for its creative tab.
*/
// It now makes sense to have the name first, since it's shorter than an entire item declaration.
public static void registerItem(IForgeRegistry<Item> registry, String name, Item item, boolean setTabIcon){
item.setRegistryName(Wizardry.MODID, name);
item.setUnlocalizedName(item.getRegistryName().toString());
registry.register(item);
if(setTabIcon && item.getCreativeTab() instanceof CreativeTabSorted){
((CreativeTabSorted)item.getCreativeTab()).setIconItem(new ItemStack(item));
}
if(item.getCreativeTab() instanceof CreativeTabListed){
((CreativeTabListed)item.getCreativeTab()).order.add(item);
}
}
/** Registers an ItemBlock afor the given block, with the same registry name as that block. */
/** Registers an ItemBlock for the given block, with the same registry name as that block. As of wizardry 4.2, this
* also automatically adds it to the order list for its creative tab if that tab is a {@link CreativeTabListed},
* meaning the order can be defined simply by the order in which the items are registered in this class. */
private static void registerItemBlock(IForgeRegistry<Item> registry, Block block){
// We don't need to keep a reference to the ItemBlock, so this can all be done in one line.
registry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
// We don't need to keep a reference to the ItemBlock
Item itemblock = new ItemBlock(block).setRegistryName(block.getRegistryName());
registry.register(itemblock);
if(block.getCreativeTabToDisplayOn() instanceof CreativeTabListed){
((CreativeTabListed)block.getCreativeTabToDisplayOn()).order.add(itemblock);
}
}
}
@SubscribeEvent
@@ -336,126 +375,134 @@ public final class WizardryItems {
registerItemBlock(registry, WizardryBlocks.crystal_block);
// Items
registerItem(registry, "magic_crystal", new ItemCrystal());
registerItem(registry, magic_crystal, "magic_crystal");
registerItem(registry, "magic_wand", new ItemWand(Tier.BASIC, null));
registerItem(registry, "apprentice_wand", new ItemWand(Tier.APPRENTICE, null));
registerItem(registry, "advanced_wand", new ItemWand(Tier.ADVANCED, null));
registerItem(registry, "master_wand", new ItemWand(Tier.MASTER, null));
registerItem(registry, magic_wand, "magic_wand");
registerItem(registry, apprentice_wand, "apprentice_wand");
registerItem(registry, advanced_wand, "advanced_wand");
registerItem(registry, master_wand, "master_wand");
registerItem(registry, "arcane_tome", new ItemArcaneTome());
registerItem(registry, "wizard_handbook", new ItemWizardHandbook(), true);
registerItem(registry, "spell_book", new ItemSpellBook(), true);
registerItem(registry, spell_book, "spell_book");
registerItem(registry, arcane_tome, "arcane_tome");
registerItem(registry, wizard_handbook, "wizard_handbook");
registerItem(registry, "basic_fire_wand", new ItemWand(Tier.BASIC, Element.FIRE));
registerItem(registry, "apprentice_fire_wand", new ItemWand(Tier.APPRENTICE, Element.FIRE));
registerItem(registry, "advanced_fire_wand", new ItemWand(Tier.ADVANCED, Element.FIRE));
registerItem(registry, "master_fire_wand", new ItemWand(Tier.MASTER, Element.FIRE));
registerItem(registry, "basic_ice_wand", new ItemWand(Tier.BASIC, Element.ICE));
registerItem(registry, "apprentice_ice_wand", new ItemWand(Tier.APPRENTICE, Element.ICE));
registerItem(registry, "advanced_ice_wand", new ItemWand(Tier.ADVANCED, Element.ICE));
registerItem(registry, "master_ice_wand", new ItemWand(Tier.MASTER, Element.ICE));
registerItem(registry, "basic_lightning_wand", new ItemWand(Tier.BASIC, Element.LIGHTNING));
registerItem(registry, "apprentice_lightning_wand", new ItemWand(Tier.APPRENTICE, Element.LIGHTNING));
registerItem(registry, "advanced_lightning_wand", new ItemWand(Tier.ADVANCED, Element.LIGHTNING));
registerItem(registry, "master_lightning_wand", new ItemWand(Tier.MASTER, Element.LIGHTNING));
registerItem(registry, "basic_necromancy_wand", new ItemWand(Tier.BASIC, Element.NECROMANCY));
registerItem(registry, "apprentice_necromancy_wand", new ItemWand(Tier.APPRENTICE, Element.NECROMANCY));
registerItem(registry, "advanced_necromancy_wand", new ItemWand(Tier.ADVANCED, Element.NECROMANCY));
registerItem(registry, "master_necromancy_wand", new ItemWand(Tier.MASTER, Element.NECROMANCY));
registerItem(registry, "basic_earth_wand", new ItemWand(Tier.BASIC, Element.EARTH));
registerItem(registry, "apprentice_earth_wand", new ItemWand(Tier.APPRENTICE, Element.EARTH));
registerItem(registry, "advanced_earth_wand", new ItemWand(Tier.ADVANCED, Element.EARTH));
registerItem(registry, "master_earth_wand", new ItemWand(Tier.MASTER, Element.EARTH));
registerItem(registry, "basic_sorcery_wand", new ItemWand(Tier.BASIC, Element.SORCERY));
registerItem(registry, "apprentice_sorcery_wand", new ItemWand(Tier.APPRENTICE, Element.SORCERY));
registerItem(registry, "advanced_sorcery_wand", new ItemWand(Tier.ADVANCED, Element.SORCERY));
registerItem(registry, "master_sorcery_wand", new ItemWand(Tier.MASTER, Element.SORCERY));
registerItem(registry, "basic_healing_wand", new ItemWand(Tier.BASIC, Element.HEALING));
registerItem(registry, "apprentice_healing_wand", new ItemWand(Tier.APPRENTICE, Element.HEALING));
registerItem(registry, "advanced_healing_wand", new ItemWand(Tier.ADVANCED, Element.HEALING));
registerItem(registry, "master_healing_wand", new ItemWand(Tier.MASTER, Element.HEALING));
registerItem(registry, basic_fire_wand, "basic_fire_wand");
registerItem(registry, basic_ice_wand, "basic_ice_wand");
registerItem(registry, basic_lightning_wand, "basic_lightning_wand");
registerItem(registry, basic_necromancy_wand, "basic_necromancy_wand");
registerItem(registry, basic_earth_wand, "basic_earth_wand");
registerItem(registry, basic_sorcery_wand, "basic_sorcery_wand");
registerItem(registry, basic_healing_wand, "basic_healing_wand");
registerItem(registry, "spectral_sword", new ItemSpectralSword(ToolMaterial.IRON));
registerItem(registry, "spectral_pickaxe", new ItemSpectralPickaxe(ToolMaterial.IRON));
registerItem(registry, "spectral_bow", new ItemSpectralBow());
registerItem(registry, apprentice_fire_wand, "apprentice_fire_wand");
registerItem(registry, apprentice_ice_wand, "apprentice_ice_wand");
registerItem(registry, apprentice_lightning_wand, "apprentice_lightning_wand");
registerItem(registry, apprentice_necromancy_wand, "apprentice_necromancy_wand");
registerItem(registry, apprentice_earth_wand, "apprentice_earth_wand");
registerItem(registry, apprentice_sorcery_wand, "apprentice_sorcery_wand");
registerItem(registry, apprentice_healing_wand, "apprentice_healing_wand");
registerItem(registry, "medium_mana_flask", new Item().setCreativeTab(WizardryTabs.WIZARDRY));
registerItem(registry, advanced_fire_wand, "advanced_fire_wand");
registerItem(registry, advanced_ice_wand, "advanced_ice_wand");
registerItem(registry, advanced_lightning_wand, "advanced_lightning_wand");
registerItem(registry, advanced_necromancy_wand, "advanced_necromancy_wand");
registerItem(registry, advanced_earth_wand, "advanced_earth_wand");
registerItem(registry, advanced_sorcery_wand, "advanced_sorcery_wand");
registerItem(registry, advanced_healing_wand, "advanced_healing_wand");
registerItem(registry, "storage_upgrade", new Item().setCreativeTab(WizardryTabs.WIZARDRY));
registerItem(registry, "siphon_upgrade", new Item().setCreativeTab(WizardryTabs.WIZARDRY));
registerItem(registry, "condenser_upgrade", new Item().setCreativeTab(WizardryTabs.WIZARDRY));
registerItem(registry, "range_upgrade", new Item().setCreativeTab(WizardryTabs.WIZARDRY));
registerItem(registry, "duration_upgrade", new Item().setCreativeTab(WizardryTabs.WIZARDRY));
registerItem(registry, "cooldown_upgrade", new Item().setCreativeTab(WizardryTabs.WIZARDRY));
registerItem(registry, "blast_upgrade", new Item().setCreativeTab(WizardryTabs.WIZARDRY));
registerItem(registry, "attunement_upgrade", new Item().setCreativeTab(WizardryTabs.WIZARDRY));
registerItem(registry, master_fire_wand, "master_fire_wand");
registerItem(registry, master_ice_wand, "master_ice_wand");
registerItem(registry, master_lightning_wand, "master_lightning_wand");
registerItem(registry, master_necromancy_wand, "master_necromancy_wand");
registerItem(registry, master_earth_wand, "master_earth_wand");
registerItem(registry, master_sorcery_wand, "master_sorcery_wand");
registerItem(registry, master_healing_wand, "master_healing_wand");
registerItem(registry, "magic_silk", new Item().setCreativeTab(WizardryTabs.WIZARDRY));
registerItem(registry, spectral_sword, "spectral_sword");
registerItem(registry, spectral_pickaxe, "spectral_pickaxe");
registerItem(registry, spectral_bow, "spectral_bow");
registerItem(registry, "flaming_axe", new ItemFlamingAxe(Materials.MAGICAL));
registerItem(registry, "frost_axe", new ItemFrostAxe(Materials.MAGICAL));
registerItem(registry, mana_flask, "mana_flask");
registerItem(registry, "firebomb", new ItemFirebomb());
registerItem(registry, "poison_bomb", new ItemPoisonBomb());
registerItem(registry, storage_upgrade, "storage_upgrade");
registerItem(registry, siphon_upgrade, "siphon_upgrade");
registerItem(registry, condenser_upgrade, "condenser_upgrade");
registerItem(registry, range_upgrade, "range_upgrade");
registerItem(registry, duration_upgrade, "duration_upgrade");
registerItem(registry, cooldown_upgrade, "cooldown_upgrade");
registerItem(registry, blast_upgrade, "blast_upgrade");
registerItem(registry, attunement_upgrade, "attunement_upgrade");
registerItem(registry, "blank_scroll", new ItemBlankScroll());
registerItem(registry, "scroll", new ItemScroll());
registerItem(registry, flaming_axe, "flaming_axe");
registerItem(registry, frost_axe, "frost_axe");
// The only way to get these is in dungeon chests (They are legendary, after all. Wizards don't just have them.
// Also if they were sold you could buy four from the same wizard - and that's no fun at all!)
registerItem(registry, "armour_upgrade", new ItemArmourUpgrade());
registerItem(registry, "wizard_hat", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.HEAD, null), true);
registerItem(registry, "wizard_robe", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.CHEST, null));
registerItem(registry, "wizard_leggings", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.LEGS, null));
registerItem(registry, "wizard_boots", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.FEET, null));
registerItem(registry, firebomb, "firebomb");
registerItem(registry, poison_bomb, "poison_bomb");
registerItem(registry, "wizard_hat_fire", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.HEAD, Element.FIRE));
registerItem(registry, "wizard_robe_fire", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.CHEST, Element.FIRE));
registerItem(registry, "wizard_leggings_fire", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.LEGS, Element.FIRE));
registerItem(registry, "wizard_boots_fire", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.FEET, Element.FIRE));
registerItem(registry, blank_scroll, "blank_scroll");
registerItem(registry, scroll, "scroll");
registerItem(registry, "wizard_hat_ice", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.HEAD, Element.ICE));
registerItem(registry, "wizard_robe_ice", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.CHEST, Element.ICE));
registerItem(registry, "wizard_leggings_ice", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.LEGS, Element.ICE));
registerItem(registry, "wizard_boots_ice", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.FEET, Element.ICE));
registerItem(registry, armour_upgrade, "armour_upgrade");
registerItem(registry, "wizard_hat_lightning", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.HEAD, Element.LIGHTNING));
registerItem(registry, "wizard_robe_lightning", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.CHEST, Element.LIGHTNING));
registerItem(registry, "wizard_leggings_lightning", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.LEGS, Element.LIGHTNING));
registerItem(registry, "wizard_boots_lightning", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.FEET, Element.LIGHTNING));
registerItem(registry, magic_silk, "magic_silk");
registerItem(registry, "wizard_hat_necromancy", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.HEAD, Element.NECROMANCY));
registerItem(registry, "wizard_robe_necromancy", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.CHEST, Element.NECROMANCY));
registerItem(registry, "wizard_leggings_necromancy", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.LEGS, Element.NECROMANCY));
registerItem(registry, "wizard_boots_necromancy", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.FEET, Element.NECROMANCY));
registerItem(registry, wizard_hat, "wizard_hat");
registerItem(registry, wizard_robe, "wizard_robe");
registerItem(registry, wizard_leggings, "wizard_leggings");
registerItem(registry, wizard_boots, "wizard_boots");
registerItem(registry, "wizard_hat_earth", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.HEAD, Element.EARTH));
registerItem(registry, "wizard_robe_earth", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.CHEST, Element.EARTH));
registerItem(registry, "wizard_leggings_earth", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.LEGS, Element.EARTH));
registerItem(registry, "wizard_boots_earth", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.FEET, Element.EARTH));
registerItem(registry, wizard_hat_fire, "wizard_hat_fire");
registerItem(registry, wizard_robe_fire, "wizard_robe_fire");
registerItem(registry, wizard_leggings_fire, "wizard_leggings_fire");
registerItem(registry, wizard_boots_fire, "wizard_boots_fire");
registerItem(registry, "wizard_hat_sorcery", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.HEAD, Element.SORCERY));
registerItem(registry, "wizard_robe_sorcery", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.CHEST, Element.SORCERY));
registerItem(registry, "wizard_leggings_sorcery", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.LEGS, Element.SORCERY));
registerItem(registry, "wizard_boots_sorcery", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.FEET, Element.SORCERY));
registerItem(registry, wizard_hat_ice, "wizard_hat_ice");
registerItem(registry, wizard_robe_ice, "wizard_robe_ice");
registerItem(registry, wizard_leggings_ice, "wizard_leggings_ice");
registerItem(registry, wizard_boots_ice, "wizard_boots_ice");
registerItem(registry, "wizard_hat_healing", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.HEAD, Element.HEALING));
registerItem(registry, "wizard_robe_healing", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.CHEST, Element.HEALING));
registerItem(registry, "wizard_leggings_healing", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.LEGS, Element.HEALING));
registerItem(registry, "wizard_boots_healing", new ItemWizardArmour(Materials.SILK, 1, EntityEquipmentSlot.FEET, Element.HEALING));
registerItem(registry, wizard_hat_lightning, "wizard_hat_lightning");
registerItem(registry, wizard_robe_lightning, "wizard_robe_lightning");
registerItem(registry, wizard_leggings_lightning, "wizard_leggings_lightning");
registerItem(registry, wizard_boots_lightning, "wizard_boots_lightning");
registerItem(registry, "spectral_helmet", new ItemSpectralArmour(ArmorMaterial.IRON, 1, EntityEquipmentSlot.HEAD));
registerItem(registry, "spectral_chestplate", new ItemSpectralArmour(ArmorMaterial.IRON, 1, EntityEquipmentSlot.CHEST));
registerItem(registry, "spectral_leggings", new ItemSpectralArmour(ArmorMaterial.IRON, 1, EntityEquipmentSlot.LEGS));
registerItem(registry, "spectral_boots", new ItemSpectralArmour(ArmorMaterial.IRON, 1, EntityEquipmentSlot.FEET));
registerItem(registry, "smoke_bomb", new ItemSmokeBomb());
registerItem(registry, wizard_hat_necromancy, "wizard_hat_necromancy");
registerItem(registry, wizard_robe_necromancy, "wizard_robe_necromancy");
registerItem(registry, wizard_leggings_necromancy, "wizard_leggings_necromancy");
registerItem(registry, wizard_boots_necromancy, "wizard_boots_necromancy");
registerItem(registry, wizard_hat_earth, "wizard_hat_earth");
registerItem(registry, wizard_robe_earth, "wizard_robe_earth");
registerItem(registry, wizard_leggings_earth, "wizard_leggings_earth");
registerItem(registry, wizard_boots_earth, "wizard_boots_earth");
registerItem(registry, wizard_hat_sorcery, "wizard_hat_sorcery");
registerItem(registry, wizard_robe_sorcery, "wizard_robe_sorcery");
registerItem(registry, wizard_leggings_sorcery, "wizard_leggings_sorcery");
registerItem(registry, wizard_boots_sorcery, "wizard_boots_sorcery");
registerItem(registry, wizard_hat_healing, "wizard_hat_healing");
registerItem(registry, wizard_robe_healing, "wizard_robe_healing");
registerItem(registry, wizard_leggings_healing, "wizard_leggings_healing");
registerItem(registry, wizard_boots_healing, "wizard_boots_healing");
registerItem(registry, spectral_helmet, "spectral_helmet");
registerItem(registry, spectral_chestplate, "spectral_chestplate");
registerItem(registry, spectral_leggings, "spectral_leggings");
registerItem(registry, spectral_boots, "spectral_boots");
registerItem(registry, smoke_bomb, "smoke_bomb");
registerItem(registry, identification_scroll, "identification_scroll");
registerItem(registry, "identification_scroll", new ItemIdentificationScroll());
registerItem(registry, "test_artefact", new ItemArtefact(EnumRarity.UNCOMMON));
}
}
}
@@ -1,19 +1,19 @@
package electroblob.wizardry.registry;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.potion.PotionDecay;
import electroblob.wizardry.potion.PotionFrost;
import electroblob.wizardry.potion.PotionMagicEffect;
import electroblob.wizardry.potion.PotionMagicEffectParticles;
import electroblob.wizardry.potion.*;
import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.ParticleBuilder.Type;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.attributes.AbstractAttributeMap;
import net.minecraft.potion.Potion;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
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.ObjectHolder;
import net.minecraftforge.registries.IForgeRegistry;
/**
@@ -22,73 +22,39 @@ import net.minecraftforge.registries.IForgeRegistry;
* @author Electroblob
* @since Wizardry 2.1
*/
@ObjectHolder(Wizardry.MODID)
@Mod.EventBusSubscriber
public final class WizardryPotions {
/* Interestingly, setting the colour to black stops the particles from rendering. This is great, however, the black
* colour then 'mixes' with other potions that are applied. Whilst this is a bit annoying, for the amount it is
* likely to get noticed it is certainly preferable to always making showParticles false, because now I can give the
* user the option (via commands) of having one of my potion effects without particles, and more importantly the
* potion effect HUD still gets displayed. TODO: Backport to 1.7.10, assuming it also works in that version. This
* means also changing whenever the potion effect is added such that it is NOT ambient. */
public static final Potion frost = new PotionFrost(true, 0); // Colour was 0x38ddec (was arbitrary anyway)
public static final Potion transience = new PotionMagicEffectParticles(false, 0, 0){
@Override
public void spawnCustomParticle(World world, double x, double y, double z){
ParticleBuilder.create(Type.DUST).pos(x, y, z).colour(0.8f, 0.8f, 1.0f).shaded(true).spawn(world);
}
}.setBeneficial(); // 0xffe89b
public static final Potion fireskin = new PotionMagicEffectParticles(false, 0, 1){
@Override
public void spawnCustomParticle(World world, double x, double y, double z){
world.spawnParticle(EnumParticleTypes.FLAME, x, y, z, 0, 0, 0);
}
@Override
public void performEffect(EntityLivingBase entitylivingbase, int strength){
entitylivingbase.extinguish(); // Stops melee mobs that are on fire from setting the player on fire,
// without allowing the player to actually stand in fire or swim in lava without taking damage.
};
}.setBeneficial(); // 0xff2f02
public static final Potion ice_shroud = new PotionMagicEffectParticles(false, 0, 2){
@Override
public void spawnCustomParticle(World world, double x, double y, double z){
float brightness = 0.5f + (world.rand.nextFloat() / 2);
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).colour(brightness, brightness + 0.1f, 1.0f).gravity(true).spawn(world);
ParticleBuilder.create(Type.SNOW).pos(x, y, z).spawn(world);
}
}.setBeneficial(); // 0x52f1ff
public static final Potion static_aura = new PotionMagicEffectParticles(false, 0, 3){
@Override
public void spawnCustomParticle(World world, double x, double y, double z){
ParticleBuilder.create(Type.SPARK).pos(x, y, z).spawn(world);
}
}.setBeneficial(); // 0x0070ff
public static final Potion decay = new PotionDecay(true, 0x3c006c);
public static final Potion sixth_sense = new PotionMagicEffect(false, 0xc6ff01, 4).setBeneficial();
public static final Potion arcane_jammer = new PotionMagicEffect(false, 0xcf4aa2, 5);
public static final Potion mind_trick = new PotionMagicEffect(true, 0x601683, 6);
public static final Potion mind_control = new PotionMagicEffect(true, 0x320b44, 7);
public static final Potion font_of_mana = new PotionMagicEffect(false, 0xffe5bb, 8).setBeneficial();
public static final Potion fear = new PotionMagicEffect(true, 0xbd0100, 9);
public static final Potion frost = null;
public static final Potion transience = null;
public static final Potion fireskin = null;
public static final Potion ice_shroud = null;
public static final Potion static_aura = null;
public static final Potion decay = null;
public static final Potion sixth_sense = null;
public static final Potion arcane_jammer = null;
public static final Potion mind_trick = null;
public static final Potion mind_control = null;
public static final Potion font_of_mana = null;
public static final Potion fear = null;
public static final Potion curse_of_soulbinding = null;
public static final Potion paralysis = null;
public static final Potion muffle = null;
public static final Potion ward = null;
public static final Potion slow_time = null;
/**
* Sets both the registry and unlocalised names of the given potion, then registers it with the given registry. Use
* this instead of {@link Potion#setRegistryName(String)} and {@link Potion#setUnlocalizedName(String)} during
* this instead of {@link Potion#setRegistryName(String)} and {@link Potion#setPotionName(String)} during
* construction, for convenience and consistency.
*
* @param registry The registry to register the given potion to.
* @param potion The potion to register.
* @param name The name of the potion, without the mod ID or the .name stuff. The registry name will be
* {@code ebwizardry:[name]}. The unlocalised name will be {@code potion.ebwizardry:[name].name}.
* @param potion The potion to register.
*/
public static void registerPotion(IForgeRegistry<Potion> registry, Potion potion, String name){
public static void registerPotion(IForgeRegistry<Potion> registry, String name, Potion potion){
potion.setRegistryName(Wizardry.MODID, name);
// For some reason, Potion#getName() doesn't prepend "potion." itself, so it has to be done here.
potion.setPotionName("potion." + potion.getRegistryName().toString());
@@ -100,18 +66,101 @@ public final class WizardryPotions {
IForgeRegistry<Potion> registry = event.getRegistry();
registerPotion(registry, frost, "frost");
registerPotion(registry, transience, "transience");
registerPotion(registry, fireskin, "fireskin");
registerPotion(registry, ice_shroud, "ice_shroud");
registerPotion(registry, static_aura, "static_aura");
registerPotion(registry, decay, "decay");
registerPotion(registry, sixth_sense, "sixth_sense");
registerPotion(registry, arcane_jammer, "arcane_jammer");
registerPotion(registry, mind_trick, "mind_trick");
registerPotion(registry, mind_control, "mind_control");
registerPotion(registry, font_of_mana, "font_of_mana");
registerPotion(registry, fear, "fear");
// Interestingly, setting the colour to black stops the particles from rendering.
registerPotion(registry, "frost", new PotionFrost(true, 0)); // Colour was 0x38ddec (was arbitrary anyway)
registerPotion(registry, "transience", new PotionMagicEffectParticles(false, 0,
new ResourceLocation(Wizardry.MODID, "potion_icon_transience")){
@Override
public void spawnCustomParticle(World world, double x, double y, double z){
ParticleBuilder.create(Type.DUST).pos(x, y, z).clr(0.8f, 0.8f, 1.0f).shaded(true).spawn(world);
}
}.setBeneficial()); // 0xffe89b
registerPotion(registry, "fireskin", new PotionMagicEffectParticles(false, 0,
new ResourceLocation(Wizardry.MODID, "potion_icon_fireskin")){
@Override
public void spawnCustomParticle(World world, double x, double y, double z){
world.spawnParticle(EnumParticleTypes.FLAME, x, y, z, 0, 0, 0);
}
@Override
public void performEffect(EntityLivingBase entitylivingbase, int strength){
entitylivingbase.extinguish(); // Stops melee mobs that are on fire from setting the player on fire,
// without allowing the player to actually stand in fire or swim in lava without taking damage.
};
}.setBeneficial()); // 0xff2f02
registerPotion(registry, "ice_shroud", new PotionMagicEffectParticles(false, 0,
new ResourceLocation(Wizardry.MODID, "potion_icon_ice_shroud")){
@Override
public void spawnCustomParticle(World world, double x, double y, double z){
float brightness = 0.5f + (world.rand.nextFloat() / 2);
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).clr(brightness, brightness + 0.1f, 1.0f).gravity(true).spawn(world);
ParticleBuilder.create(Type.SNOW).pos(x, y, z).spawn(world);
}
}.setBeneficial()); // 0x52f1ff
registerPotion(registry, "static_aura", new PotionMagicEffectParticles(false, 0,
new ResourceLocation(Wizardry.MODID, "potion_icon_static_aura")){
@Override
public void spawnCustomParticle(World world, double x, double y, double z){
ParticleBuilder.create(Type.SPARK).pos(x, y, z).spawn(world);
}
}.setBeneficial()); // 0x0070ff
registerPotion(registry, "decay", new PotionDecay(true, 0x3c006c));
registerPotion(registry, "sixth_sense", new PotionMagicEffect(false, 0xc6ff01,
new ResourceLocation(Wizardry.MODID, "potion_icon_sixth_sense")){
@Override
public void removeAttributesModifiersFromEntity(EntityLivingBase target, AbstractAttributeMap attributeMapIn, int amplifier){
// Reset the shader
if(target.world.isRemote && target == net.minecraft.client.Minecraft.getMinecraft().player){
net.minecraft.client.Minecraft.getMinecraft().entityRenderer.stopUseShader();
}
}
}.setBeneficial());
registerPotion(registry, "arcane_jammer", new PotionMagicEffect(true, 0xcf4aa2,
new ResourceLocation(Wizardry.MODID, "potion_icon_arcane_jammer")));
registerPotion(registry, "mind_trick", new PotionMagicEffect(true, 0x601683,
new ResourceLocation(Wizardry.MODID, "potion_icon_mind_trick")));
registerPotion(registry, "mind_control", new PotionMagicEffect(true, 0x320b44,
new ResourceLocation(Wizardry.MODID, "potion_icon_mind_control")));
registerPotion(registry, "font_of_mana", new PotionMagicEffect(false, 0xffe5bb,
new ResourceLocation(Wizardry.MODID, "potion_icon_font_of_mana")).setBeneficial());
registerPotion(registry, "fear", new PotionMagicEffect(true, 0xbd0100,
new ResourceLocation(Wizardry.MODID, "potion_icon_fear")));
registerPotion(registry, "curse_of_soulbinding", new Curse(true, 0x0f000f,
new ResourceLocation(Wizardry.MODID, "potion_icon_curse_of_soulbinding")){
@Override // We're not removing any attributes, but it's called when we want it to be so...
public void removeAttributesModifiersFromEntity(EntityLivingBase entity, net.minecraft.entity.ai.attributes.AbstractAttributeMap attributeMapIn, int amplifier){
// TODO: Hmmmm...
}
});
registerPotion(registry, "paralysis", new PotionMagicEffectParticles(true, 0,
new ResourceLocation(Wizardry.MODID, "potion_icon_paralysis")){
@Override
public void spawnCustomParticle(World world, double x, double y, double z){
ParticleBuilder.create(Type.SPARK).pos(x, y, z).spawn(world);
}
});
registerPotion(registry, "muffle", new PotionMagicEffect(false, 0x4464d9,
new ResourceLocation(Wizardry.MODID, "potion_icon_muffle")).setBeneficial());
registerPotion(registry, "ward", new PotionMagicEffect(false, 0xc991d0,
new ResourceLocation(Wizardry.MODID, "potion_icon_ward")).setBeneficial());
registerPotion(registry, "slow_time", new PotionSlowTime(false, 0x5be3bb).setBeneficial());
}
}