Redid the grave

This commit is contained in:
Adubbz 2013-07-10 07:05:03 +10:00
parent 3cb6f7f4fd
commit b04700a6a1
8 changed files with 139 additions and 272 deletions

View file

@ -6,17 +6,14 @@ import net.minecraft.client.model.ModelSlime;
import net.minecraft.client.particle.EntityBreakingFX;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraftforge.client.MinecraftForgeClient;
import biomesoplenty.api.Blocks;
import biomesoplenty.api.Items;
import biomesoplenty.blocks.renderers.AltarRenderer;
import biomesoplenty.blocks.renderers.FoliageRenderer;
import biomesoplenty.blocks.renderers.ItemGraveRenderer;
import biomesoplenty.blocks.renderers.GraveRenderer;
import biomesoplenty.blocks.renderers.PlantsRenderer;
import biomesoplenty.blocks.renderers.PuddleRender;
import biomesoplenty.blocks.renderers.RenderUtils;
import biomesoplenty.blocks.renderers.SmallBlockRenderer;
import biomesoplenty.blocks.renderers.TileEntityGraveRenderer;
import biomesoplenty.entities.EntityGlob;
import biomesoplenty.entities.EntityJungleSpider;
import biomesoplenty.entities.EntityRosester;
@ -28,8 +25,6 @@ import biomesoplenty.entities.render.RenderJungleSpider;
import biomesoplenty.entities.render.RenderRosester;
import biomesoplenty.particles.EntityDandelionFX;
import biomesoplenty.particles.EntitySteamFX;
import biomesoplenty.tileentities.TileEntityGrave;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class ClientProxy extends CommonProxy {
@ -40,14 +35,12 @@ public class ClientProxy extends CommonProxy {
@Override
public void registerRenderers()
{
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityGrave.class, new TileEntityGraveRenderer());
MinecraftForgeClient.registerItemRenderer(Blocks.grave.get().blockID, new ItemGraveRenderer());
RenderUtils.altarModel = RenderingRegistry.getNextAvailableRenderId();
RenderUtils.foliageModel = RenderingRegistry.getNextAvailableRenderId();;
RenderUtils.plantsModel = RenderingRegistry.getNextAvailableRenderId();;
RenderUtils.puddleModel = RenderingRegistry.getNextAvailableRenderId();;
RenderUtils.bonesModel = RenderingRegistry.getNextAvailableRenderId();;
RenderUtils.foliageModel = RenderingRegistry.getNextAvailableRenderId();
RenderUtils.plantsModel = RenderingRegistry.getNextAvailableRenderId();
RenderUtils.puddleModel = RenderingRegistry.getNextAvailableRenderId();
RenderUtils.bonesModel = RenderingRegistry.getNextAvailableRenderId();
RenderUtils.graveModel = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerEntityRenderingHandler(EntityMudball.class, new RenderSnowball(Items.mudball.get(), 0));
RenderingRegistry.registerEntityRenderingHandler(EntityDart.class, new RenderDart());
@ -61,6 +54,7 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerBlockHandler(new SmallBlockRenderer());
RenderingRegistry.registerBlockHandler(new AltarRenderer());
RenderingRegistry.registerBlockHandler(new PuddleRender());
RenderingRegistry.registerBlockHandler(new GraveRenderer());
}
@Override

View file

@ -7,21 +7,17 @@ import net.minecraft.client.particle.EntityDiggingFX;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.tileentities.TileEntityGrave;
import biomesoplenty.blocks.renderers.RenderUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockGrave extends Block
{
public static Icon blank;
public BlockGrave(int id)
{
super(id, Material.rock);
@ -33,13 +29,7 @@ public class BlockGrave extends Block
@Override
public void registerIcons(IconRegister iconRegister)
{
blank = iconRegister.registerIcon("biomesoplenty:blank");
}
@Override
public Icon getIcon(int side, int meta)
{
return blank;
blockIcon = iconRegister.registerIcon("stone");
}
@Override
@ -63,80 +53,6 @@ public class BlockGrave extends Block
}
}
@Override
@SideOnly(Side.CLIENT)
public boolean addBlockHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer)
{
int i1 = worldObj.getBlockId(target.blockX, target.blockY, target.blockZ);
if (i1 != 0)
{
Block block = Block.stone;
float f = 0.1F;
double d0 = (double)target.blockX + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (double)(f * 2.0F)) + (double)f + block.getBlockBoundsMinX();
double d1 = (double)target.blockY + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (double)(f * 2.0F)) + (double)f + block.getBlockBoundsMinY();
double d2 = (double)target.blockZ + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (double)(f * 2.0F)) + (double)f + block.getBlockBoundsMinZ();
if (target.sideHit == 0)
{
d1 = (double)target.blockY + block.getBlockBoundsMinY() - (double)f;
}
if (target.sideHit == 1)
{
d1 = (double)target.blockY + block.getBlockBoundsMaxY() + (double)f;
}
if (target.sideHit == 2)
{
d2 = (double)target.blockZ + block.getBlockBoundsMinZ() - (double)f;
}
if (target.sideHit == 3)
{
d2 = (double)target.blockZ + block.getBlockBoundsMaxZ() + (double)f;
}
if (target.sideHit == 4)
{
d0 = (double)target.blockX + block.getBlockBoundsMinX() - (double)f;
}
if (target.sideHit == 5)
{
d0 = (double)target.blockX + block.getBlockBoundsMaxX() + (double)f;
}
effectRenderer.addEffect((new EntityDiggingFX(worldObj, d0, d1, d2, 0.0D, 0.0D, 0.0D, block, 0)).applyColourMultiplier(target.blockX, target.blockY, target.blockZ).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
}
return true;
}
@Override
@SideOnly(Side.CLIENT)
public boolean addBlockDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer)
{
byte b0 = 4;
for (int j1 = 0; j1 < b0; ++j1)
{
for (int k1 = 0; k1 < b0; ++k1)
{
for (int l1 = 0; l1 < b0; ++l1)
{
double d0 = (double)x + ((double)j1 + 0.5D) / (double)b0;
double d1 = (double)y + ((double)k1 + 0.5D) / (double)b0;
double d2 = (double)z + ((double)l1 + 0.5D) / (double)b0;
int i2 = world.rand.nextInt(6);
effectRenderer.addEffect(new EntityDiggingFX(world, d0, d1, d2, d0 - (double)x - 0.5D, d1 - (double)y - 0.5D, d2 - (double)z - 0.5D, Block.stone, i2, meta).applyColourMultiplier(x, y, z));
}
}
}
return true;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int par2, int par3, int par4)
{
@ -145,21 +61,15 @@ public class BlockGrave extends Block
switch (meta)
{
case 0:
this.setBlockBounds(0.0F, 0.0F, 0.31F, 1.0F, 1.5F, 0.69F);
this.setBlockBounds(0.0F, 0.0F, 0.31F, 1.0F, 1.625F, 0.69F);
break;
case 1:
this.setBlockBounds(0.31F, 0.0F, 0.0F, 0.69F, 1.5F, 1.0F);
this.setBlockBounds(0.0F, -1.0F, 0.31F, 1.0F, 0.625F, 0.69F);
break;
}
}
@Override
public boolean hasTileEntity(int metadata)
{
return true;
}
@Override
public boolean renderAsNormalBlock()
{
@ -173,14 +83,14 @@ public class BlockGrave extends Block
}
@Override
public TileEntity createTileEntity(World world, int metadata)
public int getRenderType()
{
return new TileEntityGrave();
return RenderUtils.graveModel;
}
@Override
public int getRenderType()
public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
{
return -1;
return true;
}
}

View file

@ -0,0 +1,119 @@
package biomesoplenty.blocks.renderers;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
public class GraveRenderer implements ISimpleBlockRenderingHandler
{
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{
if (modelId == RenderUtils.graveModel)
{
int meta = world.getBlockMetadata(x, y, z);
float pixel = 0.0625F;
if (meta == 0)
{
//Base
renderer.setRenderBounds(pixel*5, 0, pixel*5, pixel*11, pixel*3, pixel*11);
renderer.renderStandardBlock(block, x, y, z);
//Base pole
renderer.setRenderBounds(pixel*6, pixel*3, pixel*6, pixel*10, pixel*11, pixel*10);
renderer.renderStandardBlock(block, x, y, z);
//Head horizontal bottom
renderer.setRenderBounds(0, pixel*11, pixel*5, pixel*16, pixel*14, pixel*11);
renderer.renderStandardBlock(block, x, y, z);
}
else if (meta == 1)
{
//Head vertical side 0
renderer.setRenderBounds(pixel*13, pixel*-2, pixel*5, pixel*16, pixel*8, pixel*11);
renderer.renderStandardBlock(block, x, y, z);
//Head vertical side 1
renderer.setRenderBounds(0, pixel*-2, pixel*5, pixel*3, pixel*8, pixel*11);
renderer.renderStandardBlock(block, x, y, z);
//Cross vertical side 1
renderer.setRenderBounds(pixel*6, pixel*-3, pixel*7, pixel*10, pixel*14, pixel*9);
renderer.renderStandardBlock(block, x, y, z);
//Head horizontal middle 0
renderer.setRenderBounds(pixel*-4, pixel*1, pixel*7, pixel*6, pixel*5, pixel*9);
renderer.renderStandardBlock(block, x, y, z);
//Head horizontal middle 1
renderer.setRenderBounds(pixel*10, pixel*1, pixel*7, pixel*20, pixel*5, pixel*9);
renderer.renderStandardBlock(block, x, y, z);
//Head horizontal top
renderer.setRenderBounds(0, pixel*8, pixel*5, pixel*16, pixel*11, pixel*11);
renderer.renderStandardBlock(block, x, y, z);
}
}
return true;
}
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
{
if (modelID == RenderUtils.graveModel)
{
Tessellator tessellator = Tessellator.instance;
if (metadata == 0)
{
renderer.setRenderBounds(0.374F, 0.0F, 0.374F, 0.626F, 1.0F, 0.626F);
RenderUtils.renderStandardInvBlock(renderer, block, metadata);
}
else if (metadata == 1)
{
renderer.setRenderBounds(0.187F, 0.0F, 0.187F, 0.813F, 1.0F, 0.813F);
RenderUtils.renderStandardInvBlock(renderer, block, metadata);
}
else if (metadata == 3)
{
renderer.setRenderBounds(0.374F, 0.374F, 0.0F, 0.626F, 0.626F, 1.0F);
RenderUtils.renderStandardInvBlock(renderer, block, metadata);
}
else if (metadata == 4)
{
renderer.setRenderBounds(0.0F, 0.374F, 0.374F, 1.0F, 0.626F, 0.626F);
RenderUtils.renderStandardInvBlock(renderer, block, metadata);
}
else if (metadata == 5)
{
renderer.setRenderBounds(0.187F, 0.187F, 0.0F, 0.813F, 0.813F, 1.0F);
RenderUtils.renderStandardInvBlock(renderer, block, metadata);
}
else if (metadata == 6)
{
renderer.setRenderBounds(0.0F, 0.187F, 0.187F, 1.0F, 0.813F, 0.813F);
RenderUtils.renderStandardInvBlock(renderer, block, metadata);
}
else
{
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
RenderUtils.renderStandardInvBlock(renderer, block, metadata);
}
}
}
@Override
public boolean shouldRender3DInInventory()
{
return true;
}
@Override
public int getRenderId()
{
return RenderUtils.graveModel;
}
}

View file

@ -1,86 +0,0 @@
package biomesoplenty.blocks.renderers;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import biomesoplenty.blocks.models.ModelGrave0;
import cpw.mods.fml.client.FMLClientHandler;
public class ItemGraveRenderer implements IItemRenderer
{
private ModelGrave0 modelGrave;
public ItemGraveRenderer()
{
modelGrave = new ModelGrave0();
}
@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 item, Object... data)
{
switch(type)
{
case ENTITY:
{
renderGrave(-0.5f, 1.5f, -0.5f, 2.5f);
return;
}
case EQUIPPED:
{
renderGrave(0f, 2.5f, 0f, 3f);
return;
}
case EQUIPPED_FIRST_PERSON:
{
renderGrave(0f, 1.25f, 0f, 2f);
return;
}
case INVENTORY:
{
renderGrave(0f, 0f, 0f, 1.45f);
return;
}
default:return;
}
}
private void renderGrave(float x, float y, float z, float scale)
{
//The PushMatrix tells the renderer to "start" doing something.
GL11.glPushMatrix();
//This is setting the initial location.
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.80F, (float) z + 0.5F);
//This is the texture of your block. It's pathed to be the same place as your other blocks here.
FMLClientHandler.instance().getClient().renderEngine.func_110577_a(new ResourceLocation("biomesoplenty:textures/models/grave.png"));
//This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again!
GL11.glPushMatrix();
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
GL11.glScalef(scale, scale, scale);
//A reference to your Model file. Again, very important.
modelGrave.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
//Tell it to stop rendering for both the PushMatrix's
GL11.glPopMatrix();
GL11.glPopMatrix();
}
}

View file

@ -18,6 +18,7 @@ public class RenderUtils
public static int plantsModel = -1;
public static int puddleModel = -1;
public static int bonesModel = -1;
public static int graveModel = -1;
public static void renderStandardInvBlock(RenderBlocks renderblocks, Block block, int meta)
{

View file

@ -1,59 +0,0 @@
package biomesoplenty.blocks.renderers;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import biomesoplenty.blocks.models.ModelGrave0;
import biomesoplenty.tileentities.TileEntityGrave;
import cpw.mods.fml.client.FMLClientHandler;
public class TileEntityGraveRenderer extends TileEntitySpecialRenderer
{
private ModelGrave0 modelGrave = new ModelGrave0();
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float tick)
{
World world = tileentity.worldObj;
int meta = world.getBlockMetadata(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord);
if (meta == 0)
{
renderModelAt((TileEntityGrave)tileentity, x, y, z, tick, 0.0F);
}
else
{
renderModelAt((TileEntityGrave)tileentity, x, y, z, tick, 1.0F);
}
}
public void renderModelAt(TileEntityGrave tileentity1, double x, double y, double z, float ticks, float rotation)
{
//The PushMatrix tells the renderer to "start" doing something.
GL11.glPushMatrix();
//This is setting the initial location.
GL11.glTranslatef((float) x + 0.5F, (float) y + 2.25F, (float) z + 0.5F);
//This is the texture of your block. It's pathed to be the same place as your other blocks here.
FMLClientHandler.instance().getClient().renderEngine.func_110577_a(new ResourceLocation("biomesoplenty:textures/models/grave.png"));
//This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again!
GL11.glPushMatrix();
GL11.glRotatef(180F, rotation, 0.0F, 1.0F);
GL11.glScalef(1.5F, 1.5F, 1.5F);
//A reference to your Model file. Again, very important.
modelGrave.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
//Tell it to stop rendering for both the PushMatrix's
GL11.glPopMatrix();
GL11.glPopMatrix();
}
}

View file

@ -73,7 +73,6 @@ import biomesoplenty.items.ItemBOPAmethyst;
import biomesoplenty.items.ItemBOPIvy;
import biomesoplenty.items.ItemBOPWillow;
import biomesoplenty.tileentities.TileEntityAltar;
import biomesoplenty.tileentities.TileEntityGrave;
import com.google.common.base.Optional;
@ -284,7 +283,6 @@ public class BOPBlocks
private static void registerTileEntities()
{
GameRegistry.registerTileEntity(TileEntityAltar.class, "tileEntityAltar");
GameRegistry.registerTileEntity(TileEntityGrave.class, "tileEntityGrave");
}
private static void addGrassPlants()

View file

@ -1,10 +0,0 @@
package biomesoplenty.tileentities;
import net.minecraft.tileentity.TileEntity;
public class TileEntityGrave extends TileEntity
{
public TileEntityGrave()
{
}
}