mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
More work, game loads and runs now.
Moved Registry events to directly AFTER PreInit instead of before. This allows modders to register handlers for it without @EventBusSubscriber. It also allows you to register custom things needed before the construction of blocks or items such as Fluids. TODO: Move Fluids to a real registry. @ObjectHolder can now be used on private fields. Reworked FMLModIdMappingEvent to include data for all registries. Tile Entities are now registrable.
This commit is contained in:
1 parent
a26d89c876
commit
dee84dc1e4
21 files changed
+230
-278
No files matched your search
@@ -28,6 +28,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.animation.Animation;
|
||||
@@ -91,6 +92,7 @@ public class ModelAnimationDebug
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
{
|
||||
GameRegistry.registerTileEntity(Chest.class, MODID + ":" + "tile_" + blockName);
|
||||
event.getRegistry().register(
|
||||
new Block(Material.WOOD)
|
||||
{
|
||||
@@ -196,77 +198,66 @@ public class ModelAnimationDebug
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
B3DLoader.INSTANCE.addDomain(MODID);
|
||||
ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation(TEST_ITEM.getRegistryName(), "inventory"));
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(Chest.class, new AnimationTESR<Chest>()
|
||||
{
|
||||
@Override
|
||||
public void handleEvents(Chest chest, float time, Iterable<Event> pastEvents)
|
||||
{
|
||||
chest.handleEvents(time, pastEvents);
|
||||
}
|
||||
});
|
||||
String entityName = MODID + ":entity_chest";
|
||||
//EntityRegistry.registerGlobalEntityID(EntityChest.class, entityName, EntityRegistry.findGlobalUniqueEntityId());
|
||||
EntityRegistry.registerModEntity(new ResourceLocation(entityName), EntityChest.class, entityName, 0, ModelAnimationDebug.instance, 64, 20, true, 0xFFAAAA00, 0xFFDDDD00);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityChest.class, new IRenderFactory<EntityChest>()
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public Render<EntityChest> createRenderFor(RenderManager manager)
|
||||
{
|
||||
/*model = ModelLoaderRegistry.getModel(new ResourceLocation(ModelLoaderRegistryDebug.MODID, "block/chest.b3d"));
|
||||
if(model instanceof IRetexturableModel)
|
||||
{
|
||||
model = ((IRetexturableModel)model).retexture(ImmutableMap.of("#chest", "entity/chest/normal"));
|
||||
}
|
||||
if(model instanceof IModelCustomData)
|
||||
{
|
||||
model = ((IModelCustomData)model).process(ImmutableMap.of("mesh", "[\"Base\", \"Lid\"]"));
|
||||
}*/
|
||||
ResourceLocation location = new ModelResourceLocation(new ResourceLocation(MODID, blockName), "entity");
|
||||
return new RenderLiving<EntityChest>(manager, new net.minecraftforge.client.model.animation.AnimationModelBase<EntityChest>(location, new VertexLighterSmoothAo(Minecraft.getMinecraft().getBlockColors()))
|
||||
{
|
||||
@Override
|
||||
public void handleEvents(EntityChest chest, float time, Iterable<Event> pastEvents)
|
||||
{
|
||||
chest.handleEvents(time, pastEvents);
|
||||
}
|
||||
}, 0.5f)
|
||||
{
|
||||
protected ResourceLocation getEntityTexture(EntityChest entity)
|
||||
{
|
||||
return TextureMap.LOCATION_BLOCKS_TEXTURE;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static abstract class CommonProxy
|
||||
{
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
GameRegistry.registerTileEntity(Chest.class, MODID + ":" + "tile_" + blockName);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract IAnimationStateMachine load(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters);
|
||||
public IAnimationStateMachine load(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters){ return null; };
|
||||
}
|
||||
|
||||
public static class ServerProxy extends CommonProxy
|
||||
{
|
||||
@Nullable
|
||||
public IAnimationStateMachine load(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static class ServerProxy extends CommonProxy {}
|
||||
|
||||
public static class ClientProxy extends CommonProxy
|
||||
{
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
super.preInit(event);
|
||||
B3DLoader.INSTANCE.addDomain(MODID);
|
||||
ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation(TEST_ITEM.getRegistryName(), "inventory"));
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(Chest.class, new AnimationTESR<Chest>()
|
||||
{
|
||||
@Override
|
||||
public void handleEvents(Chest chest, float time, Iterable<Event> pastEvents)
|
||||
{
|
||||
chest.handleEvents(time, pastEvents);
|
||||
}
|
||||
});
|
||||
String entityName = MODID + ":entity_chest";
|
||||
//EntityRegistry.registerGlobalEntityID(EntityChest.class, entityName, EntityRegistry.findGlobalUniqueEntityId());
|
||||
EntityRegistry.registerModEntity(new ResourceLocation(entityName), EntityChest.class, entityName, 0, ModelAnimationDebug.instance, 64, 20, true, 0xFFAAAA00, 0xFFDDDD00);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityChest.class, new IRenderFactory<EntityChest>()
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public Render<EntityChest> createRenderFor(RenderManager manager)
|
||||
{
|
||||
/*model = ModelLoaderRegistry.getModel(new ResourceLocation(ModelLoaderRegistryDebug.MODID, "block/chest.b3d"));
|
||||
if(model instanceof IRetexturableModel)
|
||||
{
|
||||
model = ((IRetexturableModel)model).retexture(ImmutableMap.of("#chest", "entity/chest/normal"));
|
||||
}
|
||||
if(model instanceof IModelCustomData)
|
||||
{
|
||||
model = ((IModelCustomData)model).process(ImmutableMap.of("mesh", "[\"Base\", \"Lid\"]"));
|
||||
}*/
|
||||
ResourceLocation location = new ModelResourceLocation(new ResourceLocation(MODID, blockName), "entity");
|
||||
return new RenderLiving<EntityChest>(manager, new net.minecraftforge.client.model.animation.AnimationModelBase<EntityChest>(location, new VertexLighterSmoothAo(Minecraft.getMinecraft().getBlockColors()))
|
||||
{
|
||||
@Override
|
||||
public void handleEvents(EntityChest chest, float time, Iterable<Event> pastEvents)
|
||||
{
|
||||
chest.handleEvents(time, pastEvents);
|
||||
}
|
||||
}, 0.5f)
|
||||
{
|
||||
protected ResourceLocation getEntityTexture(EntityChest entity)
|
||||
{
|
||||
return TextureMap.LOCATION_BLOCKS_TEXTURE;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public IAnimationStateMachine load(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters)
|
||||
{
|
||||
@@ -305,7 +296,6 @@ public class ModelAnimationDebug
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
logger = event.getModLog();
|
||||
proxy.preInit(event);
|
||||
}
|
||||
|
||||
public static class Chest extends TileEntity
|
||||
|
||||
Reference in new issue
Block a user