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
@@ -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");
}
}