Fix beacon rendering. Not sure why this works but it does.

This commit is contained in:
tterrag1098 committed 2015-06-25 15:06:12 -04:00
1 parent f3154d839d
commit ef2b440d92
3 files changed
+75 -18

No files matched your search

@@ -1,10 +1,5 @@
package com.cricketcraft.chisel.block;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import com.cricketcraft.chisel.block.tileentity.TileEntityCarvableBeacon;
import com.cricketcraft.chisel.init.ChiselTabs;
import net.minecraft.block.BlockBeacon;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -13,14 +8,23 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import com.cricketcraft.chisel.block.tileentity.TileEntityCarvableBeacon;
import com.cricketcraft.chisel.init.ChiselTabs;
public class BlockCarvableBeacon extends BlockBeacon implements ICarvable {
public static int renderId;
public CarvableHelper carverHelper;
public BlockCarvableBeacon() {
super();
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
setLightLevel(5.0F);
setBlockTextureName("beacon");
carverHelper = new CarvableHelper(this);
}
@@ -44,6 +48,11 @@ public class BlockCarvableBeacon extends BlockBeacon implements ICarvable {
}
}
@Override
public int getRenderType() {
return renderId;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, player, stack);
@@ -52,12 +61,7 @@ public class BlockCarvableBeacon extends BlockBeacon implements ICarvable {
((TileEntityCarvableBeacon) world.getTileEntity(x, y, z)).func_145999_a(stack.getDisplayName());
}
}
@Override
public int getRenderType(){
return 34;
}
@Override
public IVariationInfo getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
@@ -1,21 +1,36 @@
package com.cricketcraft.chisel.client.render.tile;
import com.cricketcraft.chisel.block.tileentity.TileEntityCarvableBeacon;
import java.awt.Color;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBeacon;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntityBeaconRenderer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemDye;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import com.cricketcraft.chisel.block.tileentity.TileEntityCarvableBeacon;
public class RenderCarvableBeacon extends TileEntityBeaconRenderer{
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class RenderCarvableBeacon extends TileEntityBeaconRenderer implements ISimpleBlockRenderingHandler {
private static final ResourceLocation texture = new ResourceLocation("textures/entity/beacon_beam.png");
private int renderId;
public RenderCarvableBeacon() {
this.renderId = RenderingRegistry.getNextAvailableRenderId();
}
public void renderTileEntityAt(TileEntityCarvableBeacon beacon, double x, double y, double z, float partialTicks) {
float f1 = beacon.func_146002_i();
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
@@ -111,4 +126,36 @@ public class RenderCarvableBeacon extends TileEntityBeaconRenderer{
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) {
this.renderTileEntityAt((TileEntityCarvableBeacon) tile, x, y, z, partialTicks);
}
@Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
renderer.renderBlockAsItem(Blocks.beacon, 0, 1);
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
float f = 0.1875F;
renderer.setOverrideBlockTexture(renderer.getBlockIcon(Blocks.glass));
renderer.renderStandardBlockWithAmbientOcclusion(block, x, y, z, 1, 1, 1);
renderer.renderAllFaces = true;
renderer.setOverrideBlockTexture(renderer.getBlockIcon(Blocks.obsidian));
renderer.setRenderBounds(0.125D, 0.00625D, 0.125D, 0.875D, (double)f, 0.875D);
renderer.renderStandardBlockWithAmbientOcclusion(block, x, y, z, 1, 1, 1);
renderer.setOverrideBlockTexture(renderer.getBlockIcon(Blocks.beacon));
renderer.setRenderBounds(0.1875D, (double)f, 0.1875D, 0.8125D, 0.875D, 0.8125D);
renderer.renderStandardBlockWithAmbientOcclusion(block, x, y, z, 1, 1, 1);
renderer.renderAllFaces = false;
renderer.clearOverrideBlockTexture();
return true;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public int getRenderId() {
return renderId;
}
}
@@ -1,5 +1,6 @@
package com.cricketcraft.chisel.proxy;
import com.cricketcraft.chisel.block.BlockCarvableBeacon;
import com.cricketcraft.chisel.block.tileentity.TileEntityAutoChisel;
import com.cricketcraft.chisel.block.tileentity.TileEntityCarvableBeacon;
import com.cricketcraft.chisel.block.tileentity.TileEntityPresent;
@@ -15,6 +16,7 @@ import com.cricketcraft.chisel.entity.EntityCloudInABottle;
import com.cricketcraft.chisel.entity.EntitySmashingRock;
import com.cricketcraft.chisel.init.ChiselBlocks;
import com.cricketcraft.chisel.init.ChiselItems;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.client.Minecraft;
@@ -41,15 +43,19 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerBlockHandler(new RendererEldritch());
RenderingRegistry.registerBlockHandler(new RendererLayeredGlow());
RenderingRegistry.registerBlockHandler(new RendererSimpleLayered());
RenderingRegistry.registerBlockHandler(new RendererMultiLayer());
RenderAutoChisel rac = new RenderAutoChisel();
RenderingRegistry.registerBlockHandler(rac);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ChiselBlocks.autoChisel), rac);
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAutoChisel.class, rac);
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCarvableBeacon.class, new RenderCarvableBeacon());
RenderCarvableBeacon rcb = new RenderCarvableBeacon();
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCarvableBeacon.class, rcb);
RenderingRegistry.registerBlockHandler(rcb);
BlockCarvableBeacon.renderId = rcb.getRenderId();
RenderPresent rp = new RenderPresent();
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ChiselBlocks.present), rp);
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPresent.class, rp);