Jump to content

Recommended Posts

Posted

hi, im trying to make a custom render for a block that has parts rotating while its active (much like a mill in a windmill). so far i have got it to render, but i cant figure out how to do the rotations. atm, it is either always rotating, not rotating or if one rotates all other blocks of the same type rotate. can anybody help me? here is the code = (sorry, its very messy)

 

BlockGrinder:

 

 

package naturemod.common.blocks;

 

import java.util.Random;

 

import naturemod.common.Nature;

import naturemod.common.lib.NatureBlocks;

import net.minecraft.block.Block;

import net.minecraft.block.BlockContainer;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.entity.EntityLiving;

import net.minecraft.entity.item.EntityItem;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemStack;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.AxisAlignedBB;

import net.minecraft.util.MathHelper;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class BlockGrinder extends BlockContainer

{

    /**

    * Is the random generator used by grinder to drop the inventory contents in random directions.

    */

    private static Random grinderRand = new Random();

 

    /** True if this is an active grinder, false if idle */

    private final boolean isActive;

 

    /**

    * This flag is used to prevent the grinder inventory to be dropped upon block removal, is used internally when the

    * grinder block changes from idle to active and vice-versa.

    */

    private static boolean keepgrinderInventory = false;

 

    public BlockGrinder(int par1, boolean par2)

    {

        super(par1, Material.rock);

        this.isActive = par2;

        this.setUnlocalizedName("Grinder");

    }

 

    public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4, Block block)

    {

return null;

    }

 

public boolean isOpaqueCube()

    {

        return false;

    }

 

@Override

public boolean renderAsNormalBlock()

{

return false;

}

 

@Override

public int getRenderType()

{

return -1;

}

 

    public TileEntity createNewTileEntity(World par1World)

    {

        TileEntityGrinder tileentitygrinder = new TileEntityGrinder();

        return tileentitygrinder;

    }

 

    /**

    * Returns the ID of the items to drop on destruction.

    */

    public int idDropped(int par1, Random par2Random, int par3)

    {

        return NatureBlocks.grinderIdle.blockID;

    }

 

    /**

    * Called whenever the block is added into the world. Args: world, x, y, z

    */

    public void onBlockAdded(World par1World, int par2, int par3, int par4)

    {

    updateRender(par1World, par2, par3, par4); //Used For Blocks Just Added

        super.onBlockAdded(par1World, par2, par3, par4);

    }

 

 

    /*

    @SideOnly(Side.CLIENT)

    public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)

    {

        if (this.isActive)

        {

    float f = (float) par2 + 0.5F;

    float f1 = (float) par3 + 0.0F + (par5Random.nextFloat() * 6F) / 16F;

    float f2 = (float) par4 + 0.5F;

    float f3 = 0.52F;

    float f4 = par5Random.nextFloat() * 0.6F - 0.3F;

 

    par1World.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);

    par1World.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);

    par1World.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);

    par1World.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);

        }

    }

    */

   

    /**

    * Called upon block activation (right click on the block.)

    */

    public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)

    {

        if (par1World.isRemote)

        {

            return true;

        }

        else

        {

            TileEntityGrinder var10 = (TileEntityGrinder)par1World.getBlockTileEntity(par2, par3, par4);

 

            if (var10 != null)

            {

            par5EntityPlayer.openGui(Nature.instance, 0, par1World, par2, par3, par4);

            }

 

            return true;

        }

    }

   

    /**

    * Update which block ID the grinder is using depending on whether or not it is burning

    */

    //@SideOnly(Side.CLIENT)

    public static void updateGrinderBlockState(boolean par0, World par1World, int par2, int par3, int par4)

    {

        int l = par1World.getBlockMetadata(par2, par3, par4);

        TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4);

        TileEntityGrinder tileEntity = new TileEntityGrinder();

        keepgrinderInventory = true;

       

        if (par0)

        {

            par1World.setBlock(par2, par3, par4, NatureBlocks.grinderActive.blockID);

            System.out.println("X"+"*"+par2+"");System.out.println("Y"+"*"+par3+"");System.out.println("Z"+"*"+par4+"");

            System.out.println("Active");

        }

        else

        {

            par1World.setBlock(par2, par3, par4, NatureBlocks.grinderIdle.blockID);

            System.out.println("DeActivated");

        }

 

        keepgrinderInventory = false;

        par1World.setBlockMetadataWithNotify(par2, par3, par4, l, 2);

 

        if (tileentity != null)

        {

            tileentity.validate();

            par1World.setBlockTileEntity(par2, par3, par4, tileentity);

        }

    }

   

    /**

    * ejects contained items into the world, and notifies neighbours of an update, as appropriate

    */

    public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)

    {

        if (!keepgrinderInventory)

        {

            TileEntityGrinder var7 = (TileEntityGrinder)par1World.getBlockTileEntity(par2, par3, par4);

 

            if (var7 != null)

            {

                for (int var8 = 0; var8 < var7.getSizeInventory(); ++var8)

                {

                    ItemStack var9 = var7.getStackInSlot(var8);

 

                    if (var9 != null)

                    {

                        float var10 = this.grinderRand.nextFloat() * 0.8F + 0.1F;

                        float var11 = this.grinderRand.nextFloat() * 0.8F + 0.1F;

                        float var12 = this.grinderRand.nextFloat() * 0.8F + 0.1F;

 

                        while (var9.stackSize > 0)

                        {

                            int var13 = this.grinderRand.nextInt(21) + 10;

 

                            if (var13 > var9.stackSize)

                            {

                                var13 = var9.stackSize;

                            }

 

                            var9.stackSize -= var13;

                            EntityItem var14 = new EntityItem(par1World, (double)((float)par2 + var10), (double)((float)par3 + var11), (double)((float)par4 + var12), new ItemStack(var9.itemID, var13, var9.getItemDamage()));

 

                            if (var9.hasTagCompound())

                            {

                            var14.getEntityItem().setTagCompound((NBTTagCompound)var9.getTagCompound().copy());

                            }

 

                            float var15 = 0.05F;

                            var14.motionX = (double)((float)this.grinderRand.nextGaussian() * var15);

                            var14.motionY = (double)((float)this.grinderRand.nextGaussian() * var15 + 0.2F);

                            var14.motionZ = (double)((float)this.grinderRand.nextGaussian() * var15);

                            par1World.spawnEntityInWorld(var14);

                        }

                    }

                }

            }

        }

 

        super.breakBlock(par1World, par2, par3, par4, par5, par6);

    }

   

    @SideOnly(Side.CLIENT)

 

    /**

    * A randomly called display update to be able to add particles or other items for display

    */

    public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)

    {

        if (this.isActive)

        {

            int l = par1World.getBlockMetadata(par2, par3, par4);

            float f = (float)par2 + 0.5F;

            float f1 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;

            float f2 = (float)par4 + 0.5F;

            float f3 = 0.52F;

            float f4 = par5Random.nextFloat() * 0.6F - 0.3F;

 

            if (l == 0)

            {

                par1World.spawnParticle("smoke", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D);

                par1World.spawnParticle("smoke", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D);

                par1World.spawnParticle("smoke", (double)(f + f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D);

                par1World.spawnParticle("smoke", (double)(f + f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D);

                par1World.spawnParticle("smoke", (double)(f + f4), (double)f1, (double)(f2 - f3), 0.0D, 0.0D, 0.0D);

                par1World.spawnParticle("smoke", (double)(f + f4), (double)f1, (double)(f2 - f3), 0.0D, 0.0D, 0.0D);

                par1World.spawnParticle("smoke", (double)(f + f4), (double)f1, (double)(f2 + f3), 0.0D, 0.0D, 0.0D);

                par1World.spawnParticle("smoke", (double)(f + f4), (double)f1, (double)(f2 + f3), 0.0D, 0.0D, 0.0D);

            }

           

            updateRender(par1World, par2, par3, par4); //For When The World Is Loaded

        }

    }

   

    private void updateRender(World par1World, int par2, int par3, int par4)

    {

    TileEntityGrinder tileEntity = (TileEntityGrinder)par1World.getBlockTileEntity(par2, par3, par4);

    if(this.isActive)

    {

    tileEntity.Active = true;

    }

 

    }

   

@Override

@SideOnly(Side.CLIENT)

public void registerIcons(IconRegister par1IconRegister) {

        this.blockIcon = par1IconRegister.registerIcon("wood");

}

}

 

 

 

 

TileEntityGrinder:

 

 

package naturemod.common.blocks;

 

import naturemod.common.recipes.GrinderRecipes;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.inventory.IInventory;

import net.minecraft.item.Item;

import net.minecraft.item.ItemBlock;

import net.minecraft.item.ItemHoe;

import net.minecraft.item.ItemStack;

import net.minecraft.item.ItemSword;

import net.minecraft.item.ItemTool;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.nbt.NBTTagList;

import net.minecraft.tileentity.TileEntity;

import net.minecraftforge.common.ForgeDirection;

import net.minecraftforge.common.ISidedInventory;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class TileEntityGrinder extends TileEntity implements IInventory, ISidedInventory

{

public boolean Active = false;

 

public float grindAngle;

 

    /** The angle of the lid last tick */

    public float prevGrindAngle;

    /**

    * The ItemStacks that hold the items currently being used in the grinder

    */

    private ItemStack[] grinderItemStacks = new ItemStack[3];

 

    /** The number of ticks that the grinder will keep burning */

    public int grinderBurnTime = -1;

 

    /**

    * The number of ticks that a fresh copy of the currently-burning item would keep the grinder burning for

    */

    public int currentItemBurnTime = -1;

 

    /** The number of ticks that the current item has been cooking for */

    public int grinderCookTime = 0;

 

    /**

    * Returns the number of slots in the inventory.

    */

    public int getSizeInventory()

    {

        return this.grinderItemStacks.length;

    }

 

    /**

    * Returns the stack in slot i

    */

    public ItemStack getStackInSlot(int par1)

    {

        return this.grinderItemStacks[par1];

    }

 

    /**

    * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a

    * new stack.

    */

    public ItemStack decrStackSize(int par1, int par2)

    {

        if (this.grinderItemStacks[par1] != null)

        {

            ItemStack var3;

 

            if (this.grinderItemStacks[par1].stackSize <= par2)

            {

                var3 = this.grinderItemStacks[par1];

                this.grinderItemStacks[par1] = null;

                return var3;

            }

            else

            {

                var3 = this.grinderItemStacks[par1].splitStack(par2);

 

                if (this.grinderItemStacks[par1].stackSize == 0)

                {

                    this.grinderItemStacks[par1] = null;

                }

 

                return var3;

            }

        }

        else

        {

            return null;

        }

    }

 

    /**

    * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -

    * like when you close a workbench GUI.

    */

    public ItemStack getStackInSlotOnClosing(int par1)

    {

        if (this.grinderItemStacks[par1] != null)

        {

            ItemStack var2 = this.grinderItemStacks[par1];

            this.grinderItemStacks[par1] = null;

            return var2;

        }

        else

        {

            return null;

        }

    }

 

    /**

    * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).

    */

    public void setInventorySlotContents(int par1, ItemStack par2ItemStack)

    {

        this.grinderItemStacks[par1] = par2ItemStack;

 

        if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())

        {

            par2ItemStack.stackSize = this.getInventoryStackLimit();

        }

    }

 

    /**

    * Returns the name of the inventory.

    */

    public String getInvName()

    {

        return "container.grinder";

    }

 

    /**

    * Reads a tile entity from NBT.

    */

    public void readFromNBT(NBTTagCompound par1NBTTagCompound)

    {

        super.readFromNBT(par1NBTTagCompound);

        NBTTagList var2 = par1NBTTagCompound.getTagList("Items");

        this.grinderItemStacks = new ItemStack[this.getSizeInventory()];

 

        for (int var3 = 0; var3 < var2.tagCount(); ++var3)

        {

            NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);

            byte var5 = var4.getByte("Slot");

 

            if (var5 >= 0 && var5 < this.grinderItemStacks.length)

            {

                this.grinderItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);

            }

        }

 

        this.grinderBurnTime = par1NBTTagCompound.getShort("BurnTime");

        this.grinderCookTime = par1NBTTagCompound.getShort("CookTime");

        this.currentItemBurnTime = getItemBurnTime(this.grinderItemStacks[1]);

    }

 

    /**

    * Writes a tile entity to NBT.

    */

    public void writeToNBT(NBTTagCompound par1NBTTagCompound)

    {

        super.writeToNBT(par1NBTTagCompound);

        par1NBTTagCompound.setShort("BurnTime", (short)this.grinderBurnTime);

        par1NBTTagCompound.setShort("CookTime", (short)this.grinderCookTime);

        NBTTagList var2 = new NBTTagList();

 

        for (int var3 = 0; var3 < this.grinderItemStacks.length; ++var3)

        {

            if (this.grinderItemStacks[var3] != null)

            {

                NBTTagCompound var4 = new NBTTagCompound();

                var4.setByte("Slot", (byte)var3);

                this.grinderItemStacks[var3].writeToNBT(var4);

                var2.appendTag(var4);

            }

        }

 

        par1NBTTagCompound.setTag("Items", var2);

    }

 

    /**

    * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't

    * this more of a set than a get?*

    */

    public int getInventoryStackLimit()

    {

        return 64;

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * Returns an integer between 0 and the passed value representing how close the current item is to being completely

    * cooked

    */

    public int getCookProgressScaled(int par1)

    {

        return this.grinderCookTime * par1 / 200;

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * Returns an integer between 0 and the passed value representing how much burn time is left on the current fuel

    * item, where 0 means that the item is exhausted and the passed value means that the item is fresh

    */

    public int getBurnTimeRemainingScaled(int par1)

    {

        if (this.currentItemBurnTime == 0)

        {

            this.currentItemBurnTime = 200;

        }

 

        return this.grinderBurnTime * par1 / this.currentItemBurnTime;

    }

 

    /**

    * Returns true if the grinder is currently burning

    */

    public boolean isBurning()

    {

        return this.grinderBurnTime < 0;

    }

   

    public boolean isGrinding()

    {

        return this.grinderCookTime < 0;

    }

 

    /**

    * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count

    * ticks and creates a new spawn inside its implementation.

    */

    public void updateEntity()

    {

        boolean var1 = this.grinderCookTime > 0;

        boolean var2 = false;

 

        if (this.grinderBurnTime < 0)

        {

            --this.grinderBurnTime;

        }

 

        if (!this.worldObj.isRemote)

        {

                if (this.grinderBurnTime > 0)

                {

                    var2 = true;

 

                    if (this.grinderItemStacks[1] != null)

                    {

                        --this.grinderItemStacks[1].stackSize;

 

                        if (this.grinderItemStacks[1].stackSize == 0)

                        {

                            this.grinderItemStacks[1] = this.grinderItemStacks[1].getItem().getContainerItemStack(grinderItemStacks[1]);

                        }

                    }

            }

 

            if (this.canSmelt())

            {

                ++this.grinderCookTime;

 

                if (this.grinderCookTime == 500)

                {

                    this.grinderCookTime = 0;

                    this.smeltItem();

                    var2 = true;

                }

            }

            else

            {

                this.grinderCookTime = 0;

            }

 

            if (var1 != this.grinderCookTime > 0)

            {

                var2 = true;

                BlockGrinder.updateGrinderBlockState(this.grinderCookTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);

            }

        }

 

        if (var2)

        {

            this.onInventoryChanged();

        }

    }

 

    /**

    * Returns true if the grinder can smelt an item, i.e. has a source item, destination stack isn't full, etc.

    */

    private boolean canSmelt()

    {

        if (this.grinderItemStacks[0] == null)

        {

            return false;

        }

        else

        {

            ItemStack var1 = GrinderRecipes.smelting().getSmeltingResult(this.grinderItemStacks[0]);

            if (var1 == null) return false;

            if (this.grinderItemStacks[2] == null) return true;

            if (!this.grinderItemStacks[2].isItemEqual(var1)) return false;

            int result = grinderItemStacks[2].stackSize + var1.stackSize;

            return (result <= getInventoryStackLimit() && result <= var1.getMaxStackSize());

        }

    }

 

    /**

    * Turn one item from the grinder source stack into the appropriate smelted item in the grinder result stack

    */

    public void smeltItem()

    {

        if (this.canSmelt())

        {

            ItemStack var1 = GrinderRecipes.smelting().getSmeltingResult(this.grinderItemStacks[0]);

 

            if (this.grinderItemStacks[2] == null)

            {

                this.grinderItemStacks[2] = var1.copy();

            }

            else if (this.grinderItemStacks[2].isItemEqual(var1))

            {

                grinderItemStacks[2].stackSize += var1.stackSize;

            }

 

            --this.grinderItemStacks[0].stackSize;

 

            if (this.grinderItemStacks[0].stackSize <= 0)

            {

                this.grinderItemStacks[0] = null;

            }

        }

    }

 

    /**

    * Returns the number of ticks that the supplied fuel item will keep the grinder burning, or 0 if the item isn't

    * fuel

    */

    public static int getItemBurnTime(ItemStack par0ItemStack)

    {

        if (par0ItemStack == null)

        {

            return 0;

        }

        else

        {

            int var1 = par0ItemStack.getItem().itemID;

            Item var2 = par0ItemStack.getItem();

 

            if (par0ItemStack.getItem() instanceof ItemBlock && Block.blocksList[var1] != null)

            {

                Block var3 = Block.blocksList[var1];

 

                if (var3 == Block.woodSingleSlab)

                {

                    return 150;

                }

 

                if (var3.blockMaterial == Material.wood)

                {

                    return 300;

                }

            }

 

            if (var2 instanceof ItemTool && ((ItemTool) var2).getToolMaterialName().equals("WOOD")) return 200;

            //if (var2 instanceof ItemSword && ((ItemSword) var2).func_77825_f().equals("WOOD")) return 200;

            if (var2 instanceof ItemHoe && ((ItemHoe) var2).func_77842_f().equals("WOOD")) return 200;

            if (var1 == Item.stick.itemID) return 100;

            if (var1 == Item.coal.itemID) return 1600;

            if (var1 == Item.bucketLava.itemID) return 20000;

            if (var1 == Block.sapling.blockID) return 100;

            if (var1 == Item.blazeRod.itemID) return 2400;

            return GameRegistry.getFuelValue(par0ItemStack);

        }

    }

 

    /**

    * Return true if item is a fuel source (getItemBurnTime() > 0).

    */

    public static boolean isItemFuel(ItemStack par0ItemStack)

    {

        return getItemBurnTime(par0ItemStack) > 0;

    }

 

    /**

    * Do not make give this method the name canInteractWith because it clashes with Container

    */

    public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)

    {

        return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;

    }

 

    public void openChest() {}

 

    public void closeChest() {}

 

    @Override

    public int getStartInventorySide(ForgeDirection side)

    {

        if (side == ForgeDirection.DOWN) return 1;

        if (side == ForgeDirection.UP) return 0;

        return 2;

    }

 

    @Override

    public int getSizeInventorySide(ForgeDirection side)

    {

        return 1;

    }

 

@Override

public boolean isInvNameLocalized() {

// TODO Auto-generated method stub

return false;

}

 

@Override

public boolean isStackValidForSlot(int i, ItemStack itemstack) {

// TODO Auto-generated method stub

return false;

}

}

 

 

 

 

RenderGrinder:

 

 

package naturemod.client.renders;

 

import naturemod.client.models.ModelGrinder;

import naturemod.common.blocks.BlockGrinder;

import naturemod.common.blocks.TileEntityGrinder;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.tileentity.TileEntityChest;

 

import org.lwjgl.opengl.GL11;

import org.lwjgl.opengl.GL12;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

@SideOnly(Side.CLIENT)

public class RenderGrinder extends TileEntitySpecialRenderer

{

private ModelGrinder aModel;

private BlockGrinder grinder;

private double angle;

private double angle1;

 

public RenderGrinder()

{

aModel = new ModelGrinder();

}

 

public void renderAModelAt(TileEntityGrinder tileEntity, double d, double d1, double d2, float f)

{

  int i = 0;

 

  if (tileEntity.func_70309_m()) {

  i = tileEntity.getBlockMetadata();

  }

 

    GL11.glPushMatrix();

    GL11.glEnable(GL12.GL_RESCALE_NORMAL);

GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F);

GL11.glRotatef(180, 0F, 0F, 1F);

bindTextureByName("/Nature/textures/blocks/grinder.png");

aModel.renderModel(0.0625F);

aModel.renderGrindWheel1();

aModel.renderGrindWheel2();

float f1 = tileEntity.prevGrindAngle + (tileEntity.grindAngle - tileEntity.prevGrindAngle) * f;

    angle = angle + 0.01;

angle1 = angle1 - 0.01;

f1 = 1.0F - f1;

    f1 = 1.0F - f1 * f1 * f1;

if(tileEntity.Active == true)

{

aModel.GrindWheel.rotateAngleY = -(f1 * (float)Math.PI / 2.0F);

aModel.GrindWheel1.rotateAngleY = (float)angle1;

}

GL11.glDisable(GL12.GL_RESCALE_NORMAL);

    GL11.glPopMatrix();

 

}

 

public boolean shouldRender3DInInventory()

{

    // This is where it asks if you want the renderInventory part called or not.

    return true; // Change to 'true' if you want the Inventory render to be called.

}

 

public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)

{

    this.renderAModelAt((TileEntityGrinder)par1TileEntity, par2, par4, par6, par8);

}

}

 

 

 

ModelGrinder:

 

 

package naturemod.client.models;

 

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelRenderer;

import net.minecraft.entity.Entity;

 

public class ModelGrinder extends ModelBase

{

  //fields

public ModelRenderer Base;

    public ModelRenderer Pilar;

    public ModelRenderer Pilar1;

    public ModelRenderer Pilar2;

    public ModelRenderer Pilar3;

    public ModelRenderer Pole;

    public ModelRenderer GrindWheel = (new ModelRenderer(this, 0, 19)).setTextureSize(128, 64);

    public ModelRenderer GrindWheel1;

    public ModelRenderer Hopper;

    public ModelRenderer HopperSide;

    public ModelRenderer HopperSide1;

    public ModelRenderer HopperSide2;

    public ModelRenderer HopperSide3;

    public ModelRenderer Strut;

    public ModelRenderer StrutTop;

    public ModelRenderer Strut1;

    public ModelRenderer StrutTop1;

    public ModelRenderer Strut2;

    public ModelRenderer Strut3;

    public ModelRenderer StrutTop3;

    public ModelRenderer StrutTop2;

    public ModelRenderer Item;

 

  public ModelGrinder()

  {

    textureWidth = 128;

    textureHeight = 64;

   

      Base = new ModelRenderer(this, 0, 0);

      Base.addBox(0F, 0F, 0F, 16, 3, 16);

      Base.setRotationPoint(-8F, 21F, -8F);

      Base.setTextureSize(128, 64);

      Base.mirror = true;

      setRotation(Base, 0F, 0F, 0F);

      Pilar = new ModelRenderer(this, 0, 32);

      Pilar.addBox(0F, 0F, 0F, 14, 2, 1);

      Pilar.setRotationPoint(-7F, 19F, 6.5F);

      Pilar.setTextureSize(128, 64);

      Pilar.mirror = true;

      setRotation(Pilar, 0F, 0F, 0F);

      Pilar1 = new ModelRenderer(this, 0, 32);

      Pilar1.addBox(0F, 0F, 0F, 1, 2, 14);

      Pilar1.setRotationPoint(6.5F, 19F, -7F);

      Pilar1.setTextureSize(128, 64);

      Pilar1.mirror = true;

      setRotation(Pilar1, 0F, 0F, 0F);

      Pilar2 = new ModelRenderer(this, 0, 32);

      Pilar2.addBox(0F, 0F, 0F, 14, 2, 1);

      Pilar2.setRotationPoint(-7F, 19F, -7.5F);

      Pilar2.setTextureSize(128, 64);

      Pilar2.mirror = true;

      setRotation(Pilar2, 0F, 0F, 0F);

      Pilar3 = new ModelRenderer(this, 0, 32);

      Pilar3.addBox(0F, 0F, 0F, 1, 2, 14);

      Pilar3.setRotationPoint(-7.5F, 19F, -7F);

      Pilar3.setTextureSize(128, 64);

      Pilar3.mirror = true;

      setRotation(Pilar3, 0F, 0F, 0F);

      Pole = new ModelRenderer(this, 44, 19);

      Pole.addBox(0F, 0F, 0F, 2, 7, 2);

      Pole.setRotationPoint(-1F, 14F, -1F);

      Pole.setTextureSize(128, 64);

      Pole.mirror = true;

      //addBox(Pole, 0F, 0F, 0F, 2, 7, 2);

      setRotation(Pole, 0F, 0F, 0F);

      GrindWheel.addBox(-5.5F, 0F, -5.5F, 11, 2, 11);

      GrindWheel.setRotationPoint(0F, 17F, 0F);

      //GrindWheel.mirror = true;

      setRotation(GrindWheel, 0F, 0F, 0F);

      GrindWheel1 = new ModelRenderer(this, 0, 19);

      GrindWheel1.addBox(-5.5F, 0F, -5.5F, 11, 2, 11);

      GrindWheel1.setRotationPoint(0F, 14.8F, 0F);

      GrindWheel1.setTextureSize(128, 64);

      GrindWheel1.mirror = true;

      setRotation(GrindWheel1, 0F, 0F, 0F);

      Hopper = new ModelRenderer(this, 52, 19);

      Hopper.addBox(0F, 0F, 0F, 6, 1, 6);

      Hopper.setRotationPoint(-3F, 13F, -3F);

      Hopper.setTextureSize(128, 64);

      Hopper.mirror = true;

      setRotation(Hopper, 0F, 0F, 0F);

      HopperSide = new ModelRenderer(this, 30, 32);

      HopperSide.addBox(0F, 0F, 0F, 1, 4, 7);

      HopperSide.setRotationPoint(-4F, 10F, -3F);

      HopperSide.setTextureSize(128, 64);

      HopperSide.mirror = true;

      setRotation(HopperSide, 0F, 0F, 0F);

      HopperSide1 = new ModelRenderer(this, 30, 32);

      HopperSide1.addBox(0F, 0F, 0F, 1, 4, 7);

      HopperSide1.setRotationPoint(3F, 10F, -4F);

      HopperSide1.setTextureSize(128, 64);

      HopperSide1.mirror = true;

      setRotation(HopperSide1, 0F, 0F, 0F);

      HopperSide2 = new ModelRenderer(this, 30, 32);

      HopperSide2.addBox(0F, 0F, 0F, 7, 4, 1);

      HopperSide2.setRotationPoint(-4F, 10F, -4F);

      HopperSide2.setTextureSize(128, 64);

      HopperSide2.mirror = true;

      setRotation(HopperSide2, 0F, 0F, 0F);

      HopperSide3 = new ModelRenderer(this, 30, 32);

      HopperSide3.addBox(0F, 0F, 0F, 7, 4, 1);

      HopperSide3.setRotationPoint(-3F, 10F, 3F);

      HopperSide3.setTextureSize(128, 64);

      HopperSide3.mirror = true;

      setRotation(HopperSide3, 0F, 0F, 0F);

      Strut = new ModelRenderer(this, 64, 0);

      Strut.addBox(0F, 0F, 0F, 1, 10, 2);

      Strut.setRotationPoint(7F, 11F, -1F);

      Strut.setTextureSize(128, 64);

      Strut.mirror = true;

      setRotation(Strut, 0F, 0F, 0F);

      StrutTop = new ModelRenderer(this, 70, 0);

      StrutTop.addBox(0F, 0F, 0F, 4, 1, 2);

      StrutTop.setRotationPoint(3F, 11F, -1F);

      StrutTop.setTextureSize(128, 64);

      StrutTop.mirror = true;

      setRotation(StrutTop, 0F, 0F, 0F);

      Strut1 = new ModelRenderer(this, 64, 0);

      Strut1.addBox(0F, 0F, 0F, 1, 10, 2);

      Strut1.setRotationPoint(-8F, 11F, -1F);

      Strut1.setTextureSize(128, 64);

      Strut1.mirror = true;

      setRotation(Strut1, 0F, 0F, 0F);

      StrutTop1 = new ModelRenderer(this, 70, 0);

      StrutTop1.addBox(0F, 0F, 0F, 4, 1, 2);

      StrutTop1.setRotationPoint(-7F, 11F, -1F);

      StrutTop1.setTextureSize(128, 64);

      StrutTop1.mirror = true;

      setRotation(StrutTop1, 0F, 0F, 0F);

      Strut2 = new ModelRenderer(this, 64, 0);

      Strut2.addBox(0F, 0F, 0F, 2, 10, 1);

      Strut2.setRotationPoint(-1F, 11F, -8F);

      Strut2.setTextureSize(128, 64);

      Strut2.mirror = true;

      setRotation(Strut2, 0F, 0F, 0F);

      Strut3 = new ModelRenderer(this, 64, 0);

      Strut3.addBox(0F, 0F, 0F, 2, 10, 1);

      Strut3.setRotationPoint(-1F, 11F, 7F);

      Strut3.setTextureSize(128, 64);

      Strut3.mirror = true;

      setRotation(Strut3, 0F, 0F, 0F);

      StrutTop3 = new ModelRenderer(this, 70, 0);

      StrutTop3.addBox(0F, 0F, 0F, 2, 1, 4);

      StrutTop3.setRotationPoint(-1F, 11F, 3F);

      StrutTop3.setTextureSize(128, 64);

      StrutTop3.mirror = true;

      setRotation(StrutTop3, 0F, 0F, 0F);

      StrutTop2 = new ModelRenderer(this, 70, 0);

      StrutTop2.addBox(0F, 0F, 0F, 2, 1, 4);

      StrutTop2.setRotationPoint(-1F, 11F, -7F);

      StrutTop2.setTextureSize(128, 64);

      StrutTop2.mirror = true;

      setRotation(StrutTop2, 0F, 0F, 0F);

      Item = new ModelRenderer(this, 64, 12);

      Item.addBox(0F, 0F, 0F, 6, 1, 6);

      Item.setRotationPoint(-3F, 11F, -3F);

      Item.setTextureSize(128, 64);

      Item.mirror = true;

      setRotation(Item, 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, entity);

    Base.render(f5);

    Pilar.render(f5);

    Pilar1.render(f5);

    Pilar2.render(f5);

    Pilar3.render(f5);

    Pole.render(f5);

    GrindWheel.render(f5);

    GrindWheel1.render(f5);

    Hopper.render(f5);

    HopperSide.render(f5);

    HopperSide1.render(f5);

    HopperSide2.render(f5);

    HopperSide3.render(f5);

    Strut.render(f5);

    StrutTop.render(f5);

    Strut1.render(f5);

    StrutTop1.render(f5);

    Strut2.render(f5);

    Strut3.render(f5);

    StrutTop3.render(f5);

    StrutTop2.render(f5);

    Item.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, Entity entity)

  {

    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);

  }

  */

 

  public void renderModel(float f1)

  {

    Base.render(f1);

    Pilar.render(f1);

    Pilar1.render(f1);

    Pilar2.render(f1);

    Pilar3.render(f1);

    Pole.render(f1);

    Hopper.render(f1);

    HopperSide.render(f1);

    HopperSide1.render(f1);

    HopperSide2.render(f1);

    HopperSide3.render(f1);

    Strut.render(f1);

    StrutTop.render(f1);

    Strut1.render(f1);

    StrutTop1.render(f1);

    Strut2.render(f1);

    Strut3.render(f1);

    StrutTop3.render(f1);

    StrutTop2.render(f1);

    Item.render(f1);

  }

 

  public void renderGrindWheel1()

  {

  GrindWheel.render(0.0625F);

  }

 

  public void renderGrindWheel2()

  {

  GrindWheel1.render(0.0625F);

  }

}

 

 

 

Posted

You should look up how the vanilla beacon does it. The best way to do this is to use math (Sin and Cosine) and offset your x, y, and z positions accordingly. If you don't know basic geometry to be able to do this, now's a better time than ever to learn.

width=336 height=83http://img836.imageshack.us/img836/1237/cooltext624963071.png[/img]

I make games, minecraft mods/plugins, and some graphic art.

 

Current Project: LoECraft - An industrial minecraft server with its own modpack and custom launcher.

Posted

As this is a techne model you can just add offset to the Cubes and then make them rotate around the blue ball you see in techne using "setRotationAngles" Function.

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Posted

thanks for the help but that inst exactly what im after. the block is similar to a furnace, so when the block is active i want part of the model to be moving, however every other block using the model, that isnt active also moves.

Posted

thanks for the help but that inst exactly what im after. the block is similar to a furnace, so when the block is active i want part of the model to be moving, however every other block using the model, that isnt active also moves.

 

You need to translate the cube in the Model file, not in the render file.

like (warning: pseudocode!):

GLPushMatrix()
GLTranslate(X, Y, Z)
cube.render(par1Float)
GLPopMatrix()

 

How to get the value into your Model file? Add a variable in your model class and set it in the render file.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Reach Out To Rapid Digital: What sapp Info: +1 41 4 80 7 14 85 Email INFO: rap iddi gita lrecov ery @ exe cs. com Hello, my name is Jayson, and I’m 35 years old from the United Kingdom. My family and I recently endured an incredibly challenging experience that I wouldn’t wish on anyone. We became victims of a cryptocurrency investment fraud scheme that saw us lose a staggering $807,000 in USDT and Bitcoins. The fraudsters had created a convincing facade, and we were lured into investing, only to discover later that the platform was a complete scam. We were left devastated, not just financially, but emotionally, as we had trusted these people and believed in the legitimacy of the investment. After the initial shock wore off, we desperately searched for ways to recover the lost funds. It seemed like an impossible task, and we felt as though there was no hope. That’s when, by sheer luck, we stumbled across a post about Rapid Digital Recovery, a cryptocurrency and funds recovery organization with a proven track record in cybersecurity and fraud recovery. We decided to reach out to them, and from the first interaction, we were impressed with their professionalism and transparency. They explained the recovery process in detail and reassured us that they had the skills and expertise to track down the perpetrators and recover our funds. This gave us a renewed sense of hope, something we hadn’t felt in months. What truly stood out during our experience with Rapid Digital Recovery was their dedication to the recovery process. The team went above and beyond, using sophisticated tracking tools and cyber forensics to gather critical information. Within a matter of weeks, they had successfully located the funds and traced the scam back to the fraudsters responsible. They worked with the authorities to ensure the criminals were held accountable for their actions. To our relief, the team at Rapid Digital Recovery was able to recover every single penny we had lost. The funds were returned in full, and the sense of closure we felt was invaluable. We couldn’t have imagined such a positive outcome in the early stages of our recovery journey, and we are deeply grateful for the work they did. If you ever find yourself in a similar situation, I highly recommend contacting Rapid Digital Recovery. Their expertise, transparency, and dedication to their clients make them the go-to choice for anyone seeking to recover lost cryptocurrency or funds. They truly gave us back our financial future.  
    • This is my first time modding anything, so maybe just skill issue. I'm using Forge 54.0.12 and Temurin 21.0.5+11-LTS I wanted to create a custom keybind and to check whether it works I'd like to send a chat message. I tried using Minecraft.getInstance().player.sendSystemMessage(Component.literal("test")); but IntelliJ couldnt resolve sendSystemMessage(...). Since I saw people using it in earlier versions, I tried the same thing with 1.20.6(- 50.1.0), where it works fine, now I can't figure out if this is intentional and whether there are other options for sending chat messages. On that note, is there more documentation than https://docs.minecraftforge.net/en/1.21.x/? It seems very incomplete compared to something like the Oracle Java docs
    • Hi, i'm having this error and I wanna fix it. we try: -Reload drivers -Eliminate .minecraft -Eliminate Java -Restart launcher -Verify if minecraft is using gpu -Mods  in .minecraft is empty -Install the latest and recomended version of forge idk what i have to do, help me pls. the lastest log is: https://mclo.gs/WAMao8x  
    • Read the FAQ, Rule #2. (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/)  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.