use of ebf.tim.registry.TransportRegistry in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class ClientProxy method register.
/**
* <h2>Client Register</h2>
* Used for registering client only functions and redirecting registering the items in the train registry with their own textures and models.
*/
@Override
public void register() {
super.register();
GameRegistry.registerBlock(lampBlock, "lampblock");
lampBlock.setLightLevel(1f);
//register the fluid icons
fluidOil.setIcons(BlockLiquid.getLiquidIcon("water_still"), BlockLiquid.getLiquidIcon("water_flow"));
//trains and rollingstock
int index = 0;
while (TransportRegistry.listTrains(index) != null) {
TransportRegistry reg = TransportRegistry.listTrains(index);
RenderingRegistry.registerEntityRenderingHandler(reg.trainClass, new RenderEntity(reg.model, reg.texture, reg.bogieModels));
index++;
}
//hitboxes
RenderingRegistry.registerEntityRenderingHandler(HitboxHandler.MultipartHitbox.class, nullRender);
//bogies
RenderingRegistry.registerEntityRenderingHandler(EntityBogie.class, nullRender);
//seats
RenderingRegistry.registerEntityRenderingHandler(EntitySeat.class, nullRender);
//player scaler
RenderingRegistry.registerEntityRenderingHandler(EntityPlayer.class, new RenderScaledPlayer());
//GameRegistry.registerBlock(new BlockRailOverride(), Item);
ClientRegistry.bindTileEntitySpecialRenderer(BlockRailOverride.renderTileEntity.class, new TileEntitySpecialRenderer() {
@Override
public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) {
GL11.glPushMatrix();
GL11.glTranslated(p_147500_2_ + 0.5, p_147500_4_ + 0.3, p_147500_6_ + 0.5);
GL11.glScaled(1, 0.5, 1);
switch(p_147500_1_.getBlockMetadata()) {
//straight
case 1:
{
GL11.glRotatef(180, 1, 0, 0);
Minecraft.getMinecraft().getTextureManager().bindTexture(URIRegistry.MODEL_RAIL_TEXTURE.getResource("RailStraight.png"));
railStraightModel.render(null, 0, 0, 0, 0, 0, 0);
break;
}
case 0:
{
GL11.glRotatef(180, 1, 0, 1f);
Minecraft.getMinecraft().getTextureManager().bindTexture(URIRegistry.MODEL_RAIL_TEXTURE.getResource("RailStraight.png"));
railStraightModel.render(null, 0, 0, 0, 0, 0, 0);
break;
}
//TODO: model is upsidedown i think...
case 6:
{
GL11.glRotatef(180, 1, 0, 0);
GL11.glRotatef(270, 0, 1, 0);
Minecraft.getMinecraft().getTextureManager().bindTexture(URIRegistry.MODEL_RAIL_TEXTURE.getResource("RailCurveVerySmall.png"));
railCurveModel.render(null, 0, 0, 0, 0, 0, 0);
break;
}
case 7:
{
GL11.glRotatef(180, 1, 0, 0);
Minecraft.getMinecraft().getTextureManager().bindTexture(URIRegistry.MODEL_RAIL_TEXTURE.getResource("RailCurveVerySmall.png"));
railCurveModel.render(null, 0, 0, 0, 0, 0, 0);
break;
}
case 8:
{
GL11.glRotatef(180, 1, 0, 0);
GL11.glRotatef(90, 0, 1, 0);
Minecraft.getMinecraft().getTextureManager().bindTexture(URIRegistry.MODEL_RAIL_TEXTURE.getResource("RailCurveVerySmall.png"));
railCurveModel.render(null, 0, 0, 0, 0, 0, 0);
break;
}
case 9:
{
GL11.glRotatef(180, 1, 0, 0);
GL11.glRotatef(180, 0, 1, 0);
Minecraft.getMinecraft().getTextureManager().bindTexture(URIRegistry.MODEL_RAIL_TEXTURE.getResource("RailCurveVerySmall.png"));
railCurveModel.render(null, 0, 0, 0, 0, 0, 0);
break;
}
}
GL11.glPopMatrix();
}
});
//keybinds
ClientRegistry.registerKeyBinding(KeyLamp);
ClientRegistry.registerKeyBinding(KeyInventory);
ClientRegistry.registerKeyBinding(KeyAccelerate);
ClientRegistry.registerKeyBinding(KeyReverse);
//register the transport HUD.
HUDTrain hud = new HUDTrain();
FMLCommonHandler.instance().bus().register(hud);
MinecraftForge.EVENT_BUS.register(hud);
}
use of ebf.tim.registry.TransportRegistry in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class TrainsInMotion method init.
/**
* <h2>Registries</h2>
* register everything here.
* blocks and items handle themselves in their own class, but entities we have to handle a bit different by doing it here.
*
* networking we have packets for each major channel type, its more overhead overall but it will help significantly to prevent delays.
*
* This could be done in pre-init but that would brake compatibility with Dragon API and a number of 3rd party mods.
*/
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
//loop for registering the entities. the values needed are the class, entity name, entity ID, mod instance, update range, update rate, and if it does velocity things,
cpw.mods.fml.common.registry.EntityRegistry.registerModEntity(EntityBogie.class, "Bogie", 15, TrainsInMotion.instance, 60, 1, true);
cpw.mods.fml.common.registry.EntityRegistry.registerModEntity(EntitySeat.class, "Seat", 16, TrainsInMotion.instance, 60, 2, true);
int index = 0;
///now we loop for every value in the train registry and registry it, when the index reaches a null value, then it will stop.
while (TransportRegistry.listTrains(index) != null) {
TransportRegistry registry = TransportRegistry.listTrains(index);
cpw.mods.fml.common.registry.EntityRegistry.registerModEntity(registry.trainClass, registry.item.getUnlocalizedName().replace("item", "entity"), index + 17, TrainsInMotion.instance, 60, 1, true);
GameRegistry.registerItem(registry.item, registry.item.getUnlocalizedName().substring(5));
index++;
}
//register the networking instances and channels
TrainsInMotion.keyChannel = NetworkRegistry.INSTANCE.newSimpleChannel("TiM.key");
TrainsInMotion.keyChannel.registerMessage(PacketKeyPress.Handler.class, PacketKeyPress.class, 1, Side.SERVER);
TrainsInMotion.keyChannel.registerMessage(PacketMount.Handler.class, PacketMount.class, 2, Side.SERVER);
TrainsInMotion.keyChannel.registerMessage(PacketRemove.Handler.class, PacketRemove.class, 3, Side.SERVER);
//register the worldgen
GameRegistry.registerWorldGenerator(new OreGen(), 0);
//register the event handler
MinecraftForge.EVENT_BUS.register(eventManager);
FMLCommonHandler.instance().bus().register(eventManager);
//register GUI, model renders, Keybinds, client only blocks, and HUD
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
proxy.register();
}
use of ebf.tim.registry.TransportRegistry in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class TileEntitySlotManager method findMatchingRecipe.
/**
* <h2>recipe manager</h2>
* manages crafting recipes, and their outputs.
* the current implementation only supports shaped recipes.
*/
private ItemStack findMatchingRecipe() {
//if this is for a crafting table
if (craftingTable != null) {
int index = 0;
//for every train and rollingstock in the registry, check the recipe
while (TransportRegistry.listTrains(index) != null) {
TransportRegistry registry = TransportRegistry.listTrains(index);
int i = 0;
//check each item value, if one is false, set i to 20, which makes it return null
for (; i < 8; i++) {
if (craftingTable.getStackInSlot(i) == null) {
if (registry.recipe[i] != null) {
i = 20;
}
} else {
if (registry.recipe[i] != craftingTable.getStackInSlot(i).getItem()) {
i = 20;
}
}
}
//if i is 8 (remember this is a 0 system so 8 is actually 9 slots) that means the recipe was correct, so return the proper itemstack.
if (i == 8) {
return new ItemStack(registry.item, 1);
}
index++;
}
}
return null;
}
Aggregations