Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**La déclaration dans mon ModID.java */
- public static int rt1 = 0; // Le render
- public static final Block tenteVerte = new tb1(2022).setUnlocalizedName("tenteVerte"); // La déclaration
- //-----------------------------------------------------------------------------------------
- /**La classe tb1 (abréviation personnelle, j'aime crypter mes sources moi-même comme je peux :D*/
- package ageOfDoom.common;
- import java.util.Iterator;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockContainer;
- import net.minecraft.block.material.Material;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.player.EnumStatus;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraft.util.ChunkCoordinates;
- import net.minecraft.world.World;
- import net.minecraft.world.biome.BiomeGenBase;
- public final class tb1 extends BlockContainer{ // The rendered block needs to extend BlockContainer
- public static final int[][] footBlockToHeadBlockMap = new int[][] {{0, 1}, { -1, 0}, {0, -1}, {1, 0}};
- public tb1(int id)
- {
- // Most of this is standard block stuffs
- super(id, Material.wood);
- this.setHardness(1.0F);
- this.setStepSound(this.soundWoodFootstep);
- this.setCreativeTab(CreativeTabs.tabBlock);
- this.setUnlocalizedName("tenteVerte");
- this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
- }
- public static boolean isBlockHeadOfBed(int par0)
- {
- return (par0 & 8) != 0;
- }
- /**
- * Return whether or not the bed is occupied.
- */
- public static boolean isBedOccupied(int par0)
- {
- return (par0 & 4) != 0;
- }
- public static int getDirection(int par0)
- {
- return par0 & 3;
- }
- @Override
- public TileEntity createNewTileEntity(World world){
- return new ttb1(); // This is a method required by BlockContainer, it just returns a new instance of the tile
- }
- @Override
- public boolean renderAsNormalBlock(){
- return false; // You need this for this to render properly, return false as it will probably not be a block
- }
- @Override
- public boolean isOpaqueCube(){
- return false; // This is also required for it to render properly
- }
- @Override
- public int getRenderType(){
- return ModAOD.rt1; // You return the integer in the SimpleMod class that you defined as the render ID
- }
- @Override
- public int getRenderBlockPass(){
- return 1; // Always return 1 it is needed as well for correct rendering
- }
- }
- //---------------------------------------------------------------------
- /** La classe ttb1 (la TileEntity en gros)*/
- package ageOfDoom.common;
- import net.minecraft.tileentity.TileEntity;
- public final class ttb1 extends TileEntity{
- // Nothing special will go in here just yet
- }
- //---------------------------------------------------------------------
- /**Voici ce que j'ai mis dans mon ClientProxy*/
- public static int renderTenteID;
- @Override
- public void initRender()
- {
- ModAOD.rt1 = RenderingRegistry.getNextAvailableRenderId(); // Set the value of the render ID
- MinecraftForgeClient.registerItemRenderer(ModAOD.tenteVerte.blockID, new ibtr()); // Bind the Item renderer to the itemID
- ClientRegistry.bindTileEntitySpecialRenderer(ttb1.class, new tesrb1()); // Bind the TESR to the tile clas
- GameRegistry.registerTileEntity(ttb1.class, "ttb1"); // register the tile class
- }
- //-----------------------------------------------------------------
- /**Alors ici c'est le... TESR (?) j'ai pas trop suivi ce à quoi ça correspondait, c'était des codes anglais sans tutoriel expliqué ^^*/
- package ageOfDoom.common;
- import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
- import net.minecraft.tileentity.TileEntity;
- import org.lwjgl.opengl.GL11;
- import ageOfDoom.blocks.render.model.ModelTent;
- import cpw.mods.fml.client.FMLClientHandler;
- public final class tesrb1 extends TileEntitySpecialRenderer{ // You need to extend TileEntitySpecial Renderer for this to work
- private final ModelTent model; // Keep an instance of the model
- public tesrb1(){
- this.model = new ModelTent(); // Instantate the instance of the model in the constructor
- }
- public void renderAModelAt(tesrb1 tileentity1, double d, double d1, double d2, float f)
- {
- GL11.glPushMatrix();
- GL11.glTranslatef((float)d + 0.5F, (float)d1 + 0.5F, (float)d2 + 0.5F);
- bindTextureByName("Ageofdoom:tenteVerte");
- GL11.glPushMatrix();
- GL11.glPopMatrix();
- GL11.glPopMatrix();
- }
- @Override
- public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float scale){
- FMLClientHandler.instance().getClient();/*.func_110577_a(new ResourceLocation("AgeofDoom:tenteVerte.png"));*/ // This will bind the texture of the barrel, please follow a ResourceLocation tutorial on what to do with the resources
- GL11.glPushMatrix(); // Always call GL11.glPushMatrix() first, it will submit the matrix that is modified back into position
- GL11.glDisable(GL11.GL_LIGHTING); // You don't need this but it is recomended, try commenting this out and see what it does for you. It just enables a lighter feel for the texture
- GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); // This will translate the block to the specific coordinate so it can render right, you always wanna adjust by 0.5F, 1.5F, 0.5F
- GL11.glScalef(1.0F, -1.0F, -1.0F); // This is the scale of the block, normally it will be 1.0F, -1.0F, -1.0F
- GL11.glRotatef(0.0F, 0.0F, 0.0F, 0.0F); // This can be ignored if you want to just have it as is, but this will allow you to rotate the block, more on this will come in the tile tutorial
- bindTextureByName("/mods/ageofdoom/textures/blocks/tenteVerte.png");
- model.render(); // Call the model render function
- GL11.glEnable(GL11.GL_LIGHTING); // Remember to enable it Lighting here if you disabled it above
- GL11.glPopMatrix(); // Always call GL11.glPopMatrix() last because it will pop the matrix out for modification
- }
- }
- //---------------------------------------------------------------------------------
- /**Et pour finir le rendu dans l'inventaire!*/
- package ageOfDoom.common;
- import net.minecraft.block.Block;
- import net.minecraft.item.ItemStack;
- import net.minecraftforge.client.IItemRenderer;
- import org.lwjgl.opengl.GL11;
- import ageOfDoom.blocks.render.model.ModelTent;
- import cpw.mods.fml.client.FMLClientHandler;
- public final class ibtr implements IItemRenderer{ // This class needs to implement IItemRenderer
- private final ModelTent model; // Instance of teh ModelBarrel
- public ibtr(){
- this.model = new ModelTent(); // Populate the instance in the constructor
- }
- @Override
- public boolean handleRenderType(ItemStack item, ItemRenderType type){
- return true; // Always return true
- }
- @Override
- public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper){
- return true; // Always return true
- }
- @Override
- public void renderItem(ItemRenderType type, ItemStack item, Object... data) { // You probably wanna switch the type so you can determine the seperate renders for Entity, Inventory, Equipped
- switch(type)
- {
- case ENTITY:
- renderTente(0.5F, -0.5F, 0.5F, 1.0F);
- break; // Remember to break or return out of a switch block or it will call all up till a new break / return
- case EQUIPPED:
- renderTente(0.5F, -0.5F, 0.5F, 1.0F);
- break;
- case INVENTORY:
- renderTente(0.5F, -0.5F, 0.5F, 1.0F);
- break;
- default: // Don't forget a default case
- break;
- }
- }
- // All the code follows the same suit as the TESRBlockBarrel class did except for the binding of the texture is farther in the stack
- private void renderTente(float x, float y, float z, float scale){
- GL11.glPushMatrix();
- GL11.glDisable(GL11.GL_LIGHTING);
- GL11.glScalef(scale, scale, scale);
- GL11.glTranslatef(x, y, z);
- GL11.glRotatef(0.0F, 0.0F, 0.0F, 0.0F);
- //FMLClientHandler.instance().getClient().renderEngine.func_110577_a(new ResourceLocation("Ageofdoom:tenteVerte.png"));
- model.render();
- GL11.glEnable(GL11.GL_LIGHTING);
- GL11.glPopMatrix();
- }
- }
- /**Pour finir voici mon Model*/
- package ageOfDoom.blocks.render.model;
- import net.minecraft.client.model.ModelBase;
- import net.minecraft.client.model.ModelRenderer;
- import net.minecraft.entity.Entity;
- public class ModelTent extends ModelBase
- {
- //fields
- ModelRenderer Shape1;
- ModelRenderer Shape2;
- ModelRenderer Shape31;
- ModelRenderer Shape3;
- ModelRenderer Shape4;
- ModelRenderer Shape5;
- ModelRenderer Shape6;
- ModelRenderer Shape7;
- ModelRenderer Shape8;
- ModelRenderer Shape9;
- ModelRenderer Shape10;
- public ModelTent()
- {
- textureWidth = 256;
- textureHeight = 128;
- Shape1 = new ModelRenderer(this, 0, 0);
- Shape1.addBox(0F, 0F, 0F, 17, 1, 48);
- Shape1.setRotationPoint(-32F, 23F, -24F);
- Shape1.setTextureSize(256, 128);
- setRotation(Shape1, 0F, 0F, -0.7064006F);
- Shape2 = new ModelRenderer(this, 0, 0);
- Shape2.addBox(0F, 0F, 0F, 17, 1, 48);
- Shape2.setRotationPoint(20.5F, 13F, -24F);
- Shape2.setTextureSize(256, 128);
- setRotation(Shape2, 0F, 0F, 0.7064046F);
- Shape31 = new ModelRenderer(this, 0, 49);
- Shape31.addBox(0F, 0F, 0F, 17, 1, 48);
- Shape31.setRotationPoint(11F, 1.5F, -24F);
- Shape31.setTextureSize(256, 128);
- setRotation(Shape31, 0F, 0F, 0.8552113F);
- Shape3 = new ModelRenderer(this, 0, 49);
- Shape3.addBox(0F, 0F, 0F, 17, 1, 48);
- Shape3.setRotationPoint(-21.5F, 14.5F, -24F);
- Shape3.setTextureSize(256, 128);
- setRotation(Shape3, 0F, 0F, -0.8552113F);
- Shape4 = new ModelRenderer(this, 0, 49);
- Shape4.addBox(0F, 0F, 0F, 17, 1, 48);
- Shape4.setRotationPoint(-11F, 2.5F, -24F);
- Shape4.setTextureSize(256, 128);
- setRotation(Shape4, 0F, 0F, -0.837758F);
- Shape5 = new ModelRenderer(this, 0, 49);
- Shape5.addBox(0F, 0F, 0F, 17, 1, 48);
- Shape5.setRotationPoint(0.5F, -10.5F, -24F);
- Shape5.setTextureSize(256, 128);
- setRotation(Shape5, 0F, 0F, 0.8518859F);
- Shape6 = new ModelRenderer(this, 130, 0);
- Shape6.addBox(0F, 0F, 0F, 2, 10, 2);
- Shape6.setRotationPoint(-30.73333F, 16F, -23F);
- Shape6.setTextureSize(256, 128);
- setRotation(Shape6, 0F, 0F, 0F);
- Shape7 = new ModelRenderer(this, 130, 0);
- Shape7.addBox(0F, 0F, 0F, 2, 10, 2);
- Shape7.setRotationPoint(30.46667F, 16F, -23F);
- Shape7.setTextureSize(256, 128);
- setRotation(Shape7, 0F, 0F, 0F);
- Shape8 = new ModelRenderer(this, 130, 0);
- Shape8.addBox(0F, 0F, 0F, 2, 10, 2);
- Shape8.setRotationPoint(-30.7F, 16F, 21F);
- Shape8.setTextureSize(256, 128);
- setRotation(Shape8, 0F, 0F, 0F);
- Shape9 = new ModelRenderer(this, 130, 0);
- Shape9.addBox(0F, 0F, 0F, 2, 10, 2);
- Shape9.setRotationPoint(30F, 16F, 21F);
- Shape9.setTextureSize(256, 128);
- setRotation(Shape9, 0F, 0F, 0F);
- Shape10 = new ModelRenderer(this, 130, 12);
- Shape10.addBox(0F, 0F, 0F, 16, 3, 32);
- Shape10.setRotationPoint(-8F, 21F, -16F);
- Shape10.setTextureSize(256, 128);
- setRotation(Shape10, 0F, 0F, 0F);
- }
- public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
- {
- super.render(entity, f, f1, f2, f3, f4, f5);
- setRotationAngles(f, f1, f2, f3, f4, f5);
- Shape1.render(f5);
- Shape2.render(f5);
- Shape31.render(f5);
- Shape3.render(f5);
- Shape4.render(f5);
- Shape5.render(f5);
- Shape6.render(f5);
- Shape7.render(f5);
- Shape8.render(f5);
- Shape9.render(f5);
- Shape10.render(f5);
- }
- public void render()
- {
- float f5 = 0.0625F;
- Shape1.render(f5);
- Shape2.render(f5);
- Shape31.render(f5);
- Shape3.render(f5);
- Shape4.render(f5);
- Shape5.render(f5);
- Shape6.render(f5);
- Shape7.render(f5);
- Shape8.render(f5);
- Shape9.render(f5);
- Shape10.render(f5);
- }
- private void setRotation(ModelRenderer model, float x, float y, float z)
- {
- model.rotateAngleX = x;
- model.rotateAngleY = y;
- model.rotateAngleZ = z;
- }
- public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
- {
- super.setRotationAngles(f, f1, f2, f3, f4, f5, null);
- }
- }
- // Voilà, désolé, c'était très mal rangé \:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement