Update to support new forge registry system
This commit is contained in:
parent
c8dfcb3ba5
commit
ba644982fe
14 changed files with 43 additions and 49 deletions
|
@ -28,8 +28,10 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import reborncore.RebornRegistry;
|
||||
import reborncore.common.tile.TileMachineBase;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.Core;
|
||||
|
@ -409,25 +411,14 @@ public class ModBlocks {
|
|||
|
||||
public static void registerBlock(Block block, String name) {
|
||||
name = name.toLowerCase();
|
||||
block.setRegistryName(ModInfo.MOD_ID, name);
|
||||
block.setUnlocalizedName(ModInfo.MOD_ID + ":" + name);
|
||||
GameRegistry.register(block);
|
||||
GameRegistry.register(new ItemBlock(block), block.getRegistryName());
|
||||
RebornRegistry.registerBlock(block, new ResourceLocation(ModInfo.MOD_ID, name));
|
||||
}
|
||||
|
||||
public static void registerBlock(Block block, Class<? extends ItemBlock> itemclass, String name) {
|
||||
name = name.toLowerCase();
|
||||
block.setRegistryName(ModInfo.MOD_ID, name);
|
||||
block.setUnlocalizedName(ModInfo.MOD_ID + ":" + name);
|
||||
GameRegistry.register(block);
|
||||
try {
|
||||
ItemBlock itemBlock = itemclass.getConstructor(Block.class).newInstance(block);
|
||||
itemBlock.setRegistryName(ModInfo.MOD_ID, name);
|
||||
GameRegistry.register(itemBlock);
|
||||
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
RebornRegistry.registerBlock(block, itemclass, new ResourceLocation(ModInfo.MOD_ID, name));
|
||||
}
|
||||
|
||||
public static void registerOreDict() {
|
||||
|
|
|
@ -30,6 +30,7 @@ import net.minecraft.item.ItemBlock;
|
|||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import reborncore.RebornRegistry;
|
||||
import reborncore.api.fuel.FluidPowerManager;
|
||||
import techreborn.blocks.fluid.BlockFluidBase;
|
||||
import techreborn.blocks.fluid.BlockFluidTechReborn;
|
||||
|
@ -323,8 +324,6 @@ public class ModFluids {
|
|||
}
|
||||
|
||||
public static void registerBlock(Block block, String name) {
|
||||
block.setRegistryName(name);
|
||||
GameRegistry.register(block);
|
||||
GameRegistry.register(new ItemBlock(block), block.getRegistryName());
|
||||
RebornRegistry.registerBlock(block, name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.item.Item;
|
|||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import reborncore.RebornRegistry;
|
||||
import reborncore.api.power.IEnergyInterfaceItem;
|
||||
import reborncore.api.power.IEnergyItemInfo;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
|
@ -349,7 +350,7 @@ public class ModItems {
|
|||
|
||||
public static void registerItem(Item item, String name) {
|
||||
item.setRegistryName(name);
|
||||
GameRegistry.register(item);
|
||||
RebornRegistry.registerItem(item);
|
||||
if (item.getClass().isInstance(IEnergyItemInfo.class)) {
|
||||
if (!item.getClass().isInstance(IEnergyInterfaceItem.class)) {
|
||||
Core.logHelper.error(name + " was not patched with the power mixin. This is a error, the item may not work as intended.");
|
||||
|
|
|
@ -27,6 +27,7 @@ package techreborn.init;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.registries.GameData;
|
||||
|
||||
/**
|
||||
* Created by Mark on 20/03/2016.
|
||||
|
@ -45,7 +46,9 @@ public class ModSounds {
|
|||
|
||||
private static SoundEvent getSound(String str) {
|
||||
ResourceLocation resourceLocation = new ResourceLocation("techreborn", str);
|
||||
return GameRegistry.register(new SoundEvent(resourceLocation).setRegistryName(resourceLocation));
|
||||
SoundEvent soundEvent = new SoundEvent(resourceLocation);
|
||||
soundEvent.setRegistryName(resourceLocation);
|
||||
return GameData.register_impl(soundEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue