Fixed Blocks having an Item Renderer in the inventory

This commit is contained in:
Ellpeck 2015-11-13 18:56:15 +01:00
parent 9932432854
commit ed74026667
22 changed files with 106 additions and 142 deletions

View file

@ -50,7 +50,7 @@ public class BlockCoffeeMachine extends BlockContainerBase implements IActAddIte
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.COFFEE_MACHINE_RENDER_ID; return AssetUtil.coffeeMachineRenderId;
} }
@Override @Override

View file

@ -53,7 +53,7 @@ public class BlockCompost extends BlockContainerBase implements IActAddItemOrBlo
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.COMPOST_RENDER_ID; return AssetUtil.compostRenderId;
} }
@Override @Override

View file

@ -47,7 +47,7 @@ public class BlockFishingNet extends BlockContainerBase implements IActAddItemOr
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.FISHING_NET_RENDER_ID; return AssetUtil.fishingNetRenderId;
} }
@Override @Override

View file

@ -49,7 +49,7 @@ public class BlockFurnaceSolar extends BlockContainerBase implements IActAddItem
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.FURNACE_SOLAR_RENDER_ID; return AssetUtil.furnaceSolarRenderId;
} }
@Override @Override

View file

@ -41,7 +41,7 @@ public class BlockLaserRelay extends BlockContainerBase implements IActAddItemOr
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.LASER_RELAY_RENDER_ID; return AssetUtil.laserRelayRenderId;
} }
@Override @Override

View file

@ -44,7 +44,7 @@ public class BlockPhantomBooster extends BlockContainerBase implements IActAddIt
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.PHANTOM_BOOSTER_RENDER_ID; return AssetUtil.phantomBoosterRenderId;
} }
@Override @Override

View file

@ -47,7 +47,7 @@ public class BlockSmileyCloud extends BlockContainerBase implements IActAddItemO
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.SMILEY_CLOUD_RENDER_ID; return AssetUtil.smileyCloudRenderId;
} }
@Override @Override

View file

@ -0,0 +1,54 @@
/*
* This file ("RenderInventory.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.blocks.render;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
public class RenderInventory implements ISimpleBlockRenderingHandler{
private RenderTileEntity tileRender;
private int renderID;
public RenderInventory(RenderTileEntity tileRender, int renderID){
this.tileRender = tileRender;
this.renderID = renderID;
}
@Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer){
GL11.glPushMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(this.tileRender.resLoc);
GL11.glTranslatef(0F, 1F, 0F);
GL11.glRotatef(180F, 1F, 0F, 0F);
this.tileRender.theModel.render(0.0625F);
GL11.glPopMatrix();
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer){
return false;
}
@Override
public boolean shouldRender3DInInventory(int modelId){
return true;
}
@Override
public int getRenderId(){
return this.renderID;
}
}

View file

@ -1,88 +0,0 @@
/*
* This file ("RenderItems.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.blocks.render;
import ellpeck.actuallyadditions.util.ModUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
public class RenderItems implements IItemRenderer{
ModelBaseAA theModel;
ResourceLocation theTexture;
public RenderItems(ModelBaseAA model){
this.theModel = model;
this.theTexture = new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/blocks/models/"+this.theModel.getName()+".png");
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type){
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper){
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack stack, Object... data){
switch(type){
case INVENTORY:
GL11.glPushMatrix();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(-0.5F, -1.27F, 0.5F);
GL11.glRotatef(180F, 0F, 1F, 0F);
Minecraft.getMinecraft().renderEngine.bindTexture(theTexture);
theModel.render(0.0625F);
GL11.glPopMatrix();
break;
case EQUIPPED:
GL11.glPushMatrix();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(0.6F, -1.2F, -0.0F);
GL11.glRotatef(180F, 0F, 1F, 0F);
Minecraft.getMinecraft().renderEngine.bindTexture(theTexture);
theModel.render(0.0625F);
GL11.glPopMatrix();
break;
case EQUIPPED_FIRST_PERSON:
GL11.glPushMatrix();
GL11.glScalef(1.2F, 1.2F, 1.2F);
GL11.glRotatef(180, 2F, -0F, 0.1F);
GL11.glTranslatef(1.5F, -1.2F, -0.3F);
GL11.glRotatef(180F, 0F, 1F, 0F);
Minecraft.getMinecraft().renderEngine.bindTexture(theTexture);
theModel.render(0.0625F);
GL11.glPopMatrix();
break;
default:
GL11.glPushMatrix();
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(0.0F, -1.27F, 0.0F);
GL11.glRotatef(180F, 0F, 1F, 0F);
Minecraft.getMinecraft().renderEngine.bindTexture(theTexture);
theModel.render(0.0625F);
GL11.glPopMatrix();
break;
}
}
}

View file

@ -10,6 +10,7 @@
package ellpeck.actuallyadditions.blocks.render; package ellpeck.actuallyadditions.blocks.render;
import ellpeck.actuallyadditions.blocks.render.model.ModelBaseAA;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;

View file

@ -10,6 +10,7 @@
package ellpeck.actuallyadditions.blocks.render; package ellpeck.actuallyadditions.blocks.render;
import ellpeck.actuallyadditions.blocks.render.model.ModelBaseAA;
import ellpeck.actuallyadditions.misc.cloud.ISmileyCloudEasterEgg; import ellpeck.actuallyadditions.misc.cloud.ISmileyCloudEasterEgg;
import ellpeck.actuallyadditions.misc.cloud.SmileyCloudEasterEggs; import ellpeck.actuallyadditions.misc.cloud.SmileyCloudEasterEggs;
import ellpeck.actuallyadditions.proxy.ClientProxy; import ellpeck.actuallyadditions.proxy.ClientProxy;

View file

@ -10,6 +10,7 @@
package ellpeck.actuallyadditions.blocks.render; package ellpeck.actuallyadditions.blocks.render;
import ellpeck.actuallyadditions.blocks.render.model.ModelBaseAA;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -19,7 +20,7 @@ import org.lwjgl.opengl.GL11;
public class RenderTileEntity extends TileEntitySpecialRenderer{ public class RenderTileEntity extends TileEntitySpecialRenderer{
public ModelBaseAA theModel; public ModelBaseAA theModel;
protected ResourceLocation resLoc; public ResourceLocation resLoc;
public RenderTileEntity(ModelBaseAA model){ public RenderTileEntity(ModelBaseAA model){
this.theModel = model; this.theModel = model;

View file

@ -8,7 +8,7 @@
* © 2015 Ellpeck * © 2015 Ellpeck
*/ */
package ellpeck.actuallyadditions.blocks.render; package ellpeck.actuallyadditions.blocks.render.model;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;

View file

@ -8,7 +8,7 @@
* © 2015 Ellpeck * © 2015 Ellpeck
*/ */
package ellpeck.actuallyadditions.blocks.render; package ellpeck.actuallyadditions.blocks.render.model;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;

View file

@ -8,7 +8,7 @@
* © 2015 Ellpeck * © 2015 Ellpeck
*/ */
package ellpeck.actuallyadditions.blocks.render; package ellpeck.actuallyadditions.blocks.render.model;
import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;

View file

@ -8,7 +8,7 @@
* © 2015 Ellpeck * © 2015 Ellpeck
*/ */
package ellpeck.actuallyadditions.blocks.render; package ellpeck.actuallyadditions.blocks.render.model;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;

View file

@ -8,7 +8,7 @@
* © 2015 Ellpeck * © 2015 Ellpeck
*/ */
package ellpeck.actuallyadditions.blocks.render; package ellpeck.actuallyadditions.blocks.render.model;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;

View file

@ -8,7 +8,7 @@
* © 2015 Ellpeck * © 2015 Ellpeck
*/ */
package ellpeck.actuallyadditions.blocks.render; package ellpeck.actuallyadditions.blocks.render.model;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;

View file

@ -8,7 +8,7 @@
* © 2015 Ellpeck * © 2015 Ellpeck
*/ */
package ellpeck.actuallyadditions.blocks.render; package ellpeck.actuallyadditions.blocks.render.model;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;

View file

@ -8,7 +8,7 @@
* © 2015 Ellpeck * © 2015 Ellpeck
*/ */
package ellpeck.actuallyadditions.blocks.render; package ellpeck.actuallyadditions.blocks.render.model;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;

View file

@ -17,8 +17,11 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.common.registry.VillagerRegistry;
import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.blocks.render.RenderInventory;
import ellpeck.actuallyadditions.blocks.render.*; import ellpeck.actuallyadditions.blocks.render.RenderLaserRelay;
import ellpeck.actuallyadditions.blocks.render.RenderSmileyCloud;
import ellpeck.actuallyadditions.blocks.render.RenderTileEntity;
import ellpeck.actuallyadditions.blocks.render.model.*;
import ellpeck.actuallyadditions.config.values.ConfigBoolValues; import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.event.InitEvents; import ellpeck.actuallyadditions.event.InitEvents;
@ -28,9 +31,8 @@ import ellpeck.actuallyadditions.util.AssetUtil;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.playerdata.PersistentClientData; import ellpeck.actuallyadditions.util.playerdata.PersistentClientData;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.MinecraftForgeClient;
import java.io.File; import java.io.File;
import java.util.Calendar; import java.util.Calendar;
@ -65,34 +67,21 @@ public class ClientProxy implements IProxy{
InitEvents.initClient(); InitEvents.initClient();
AssetUtil.COMPOST_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); AssetUtil.compostRenderId = RenderingRegistry.getNextAvailableRenderId();
AssetUtil.FISHING_NET_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); AssetUtil.fishingNetRenderId = RenderingRegistry.getNextAvailableRenderId();
AssetUtil.FURNACE_SOLAR_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); AssetUtil.furnaceSolarRenderId = RenderingRegistry.getNextAvailableRenderId();
AssetUtil.COFFEE_MACHINE_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); AssetUtil.coffeeMachineRenderId = RenderingRegistry.getNextAvailableRenderId();
AssetUtil.PHANTOM_BOOSTER_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); AssetUtil.phantomBoosterRenderId = RenderingRegistry.getNextAvailableRenderId();
AssetUtil.SMILEY_CLOUD_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); AssetUtil.smileyCloudRenderId = RenderingRegistry.getNextAvailableRenderId();
AssetUtil.LASER_RELAY_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); AssetUtil.laserRelayRenderId = RenderingRegistry.getNextAvailableRenderId();
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCompost.class, new RenderTileEntity(new ModelCompost())); registerRenderer(TileEntityCompost.class, new RenderTileEntity(new ModelCompost()), AssetUtil.compostRenderId);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockCompost), new RenderItems(new ModelCompost())); registerRenderer(TileEntityFishingNet.class, new RenderTileEntity(new ModelFishingNet()), AssetUtil.fishingNetRenderId);
registerRenderer(TileEntityFurnaceSolar.class, new RenderTileEntity(new ModelFurnaceSolar()), AssetUtil.furnaceSolarRenderId);
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFishingNet.class, new RenderTileEntity(new ModelFishingNet())); registerRenderer(TileEntityCoffeeMachine.class, new RenderTileEntity(new ModelCoffeeMachine()), AssetUtil.coffeeMachineRenderId);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockFishingNet), new RenderItems(new ModelFishingNet())); registerRenderer(TileEntityPhantomBooster.class, new RenderTileEntity(new ModelPhantomBooster()), AssetUtil.phantomBoosterRenderId);
registerRenderer(TileEntitySmileyCloud.class, new RenderSmileyCloud(new ModelSmileyCloud()), AssetUtil.smileyCloudRenderId);
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFurnaceSolar.class, new RenderTileEntity(new ModelFurnaceSolar())); registerRenderer(TileEntityLaserRelay.class, new RenderLaserRelay(new ModelLaserRelay()), AssetUtil.laserRelayRenderId);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockFurnaceSolar), new RenderItems(new ModelFurnaceSolar()));
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCoffeeMachine.class, new RenderTileEntity(new ModelCoffeeMachine()));
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockCoffeeMachine), new RenderItems(new ModelCoffeeMachine()));
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPhantomBooster.class, new RenderTileEntity(new ModelPhantomBooster()));
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockPhantomBooster), new RenderItems(new ModelPhantomBooster()));
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySmileyCloud.class, new RenderSmileyCloud(new ModelSmileyCloud()));
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockSmileyCloud), new RenderItems(new ModelSmileyCloud()));
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLaserRelay.class, new RenderLaserRelay(new ModelLaserRelay()));
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockLaserRelay), new RenderItems(new ModelLaserRelay()));
VillagerRegistry.instance().registerVillagerSkin(ConfigIntValues.JAM_VILLAGER_ID.getValue(), new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/entity/villager/jamVillager.png")); VillagerRegistry.instance().registerVillagerSkin(ConfigIntValues.JAM_VILLAGER_ID.getValue(), new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/entity/villager/jamVillager.png"));
} }
@ -103,4 +92,9 @@ public class ClientProxy implements IProxy{
SpecialRenderInit.init(); SpecialRenderInit.init();
} }
private static void registerRenderer(Class<? extends TileEntity> tileClass, RenderTileEntity tileRender, int renderID){
ClientRegistry.bindTileEntitySpecialRenderer(tileClass, tileRender);
RenderingRegistry.registerBlockHandler(new RenderInventory(tileRender, renderID));
}
} }

View file

@ -28,13 +28,14 @@ import org.lwjgl.opengl.GL11;
public class AssetUtil{ public class AssetUtil{
public static final ResourceLocation GUI_INVENTORY_LOCATION = getGuiLocation("guiInventory"); public static final ResourceLocation GUI_INVENTORY_LOCATION = getGuiLocation("guiInventory");
public static int COMPOST_RENDER_ID;
public static int FISHING_NET_RENDER_ID; public static int compostRenderId;
public static int FURNACE_SOLAR_RENDER_ID; public static int fishingNetRenderId;
public static int COFFEE_MACHINE_RENDER_ID; public static int furnaceSolarRenderId;
public static int PHANTOM_BOOSTER_RENDER_ID; public static int coffeeMachineRenderId;
public static int SMILEY_CLOUD_RENDER_ID; public static int phantomBoosterRenderId;
public static int LASER_RELAY_RENDER_ID; public static int smileyCloudRenderId;
public static int laserRelayRenderId;
public static ResourceLocation getGuiLocation(String file){ public static ResourceLocation getGuiLocation(String file){
return new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/gui/"+file+".png"); return new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/gui/"+file+".png");