Jump to content

Recommended Posts

Posted

Hi there, I am trying to make a block with a custom model using the latest recommended build of Forge.

 

For some reason, the block in the player's hand is a grey grass-top texture, and when the block is placed, it is a bounding box with nothing inside it.

 

Any help would be appreciated.

 

BaseWaterdude.java

package com.waterdude.mod;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.src.ModLoader;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler;
import cpw.mods.fml.common.SidedProxy;

import com.waterdude.mod.blocks.BlockArcaneFurnace;
import com.waterdude.mod.blocks.BlockMVBattery;
import com.waterdude.mod.blocks.BlockOre1;
import com.waterdude.mod.core.handlers.ClientPacketHandler;
import com.waterdude.mod.core.handlers.GuiHandler;
import com.waterdude.mod.core.handlers.ServerPacketHandler;
import com.waterdude.mod.core.CommonProxy;
import com.waterdude.mod.core.TileEntityArcaneFurnace;
import com.waterdude.mod.core.TileEntityMVBattery;
import com.waterdude.mod.core.IBlockRenderer;
import com.waterdude.mod.core.WorldGenMinableW;
import com.waterdude.mod.items.ItemEnergyDust;
import com.waterdude.mod.items.ItemFusedDust;
import com.waterdude.mod.items.ItemMVBattery;

@NetworkMod(clientSideRequired=true,serverSideRequired=false,

clientPacketHandlerSpec = @SidedPacketHandler(channels = {"TutorialGeneral" }, packetHandler = ClientPacketHandler.class), 
serverPacketHandlerSpec = @SidedPacketHandler(channels = {}, packetHandler = ServerPacketHandler.class)) 

@Mod(modid="ManaAndMagic",name="Mana and Magic",version="1.0.0") 

public class BaseWaterdude 
{ 

@Instance("ManaAndMagic")
public static BaseWaterdude instance = new BaseWaterdude();

@SidedProxy(clientSide = "com.waterdude.mod.core.ClientProxy", serverSide = "com.waterdude.mod.core.CommonProxy")
public static CommonProxy proxy;

public static Item itemFusedDust = new ItemFusedDust(17050).setIconIndex(0).setTextureFile("/ManaAndMagic/WaterdudeItems.png");
public static Item itemEnergyDust = new ItemEnergyDust(17051).setIconIndex(1).setTextureFile("/ManaAndMagic/WaterdudeItems.png");
//public static Item mvbItem = new ItemMVBattery(17052).setIconIndex(2).setTextureFile("/ManaAndMagic/WaterdudeItems.png");

public static Block blockOre1 = new BlockOre1(180);
public static Block afActive = new BlockArcaneFurnace(182, true).setHardness(3.5F).setStepSound(Block.soundStoneFootstep).setBlockName("afActive").setRequiresSelfNotify().setLightValue(0.875F);
public static Block afIdle = new BlockArcaneFurnace(181, false).setHardness(3.5F).setStepSound(Block.soundStoneFootstep).setBlockName("afIdle").setRequiresSelfNotify().setCreativeTab(CreativeTabs.tabMisc);

private GuiHandler guiHandler = new GuiHandler();

public static int mvbRenderID;
public static int mvbTexture;

public void renderInvBlock(RenderBlocks var1, Block var2, int var3, int var4)
{
	renderInvBlock(var1, var2, var3, var4);

	if (var2 == mvb)
	{
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityMVBattery(), 0.0D, 0.0D, 0.0D, 0.0F);
	}
}

@Init
public void Init(FMLInitializationEvent event)
{ 
	RenderingRegistry.registerBlockHandler(new IBlockRenderer());
     
    mvbRenderID = RenderingRegistry.getNextAvailableRenderId();

	NetworkRegistry.instance().registerGuiHandler(this, proxy); 
	GameRegistry.registerWorldGenerator(new WorldGenMinableW());

	NetworkRegistry.instance().registerGuiHandler(this, guiHandler);
	GameRegistry.registerTileEntity(TileEntityArcaneFurnace.class,"tileEntityArcaneFurnace");

	proxy.registerBlocks();
	proxy.addNames();
	proxy.addRecipes();
	proxy.registerRenderInformation();
}

public static Block mvb = new BlockMVBattery(183, mvbRenderID, TileEntityMVBattery.class).setHardness(4.5F).setStepSound(Block.soundMetalFootstep).setBlockName("mvb").setRequiresSelfNotify().setCreativeTab(CreativeTabs.tabMisc);

}

 

ModelMVBattery.java

package com.waterdude.mod.core;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelMVBattery extends ModelBase
{
  //fields
    ModelRenderer Shape1;
    ModelRenderer Shape2;
    ModelRenderer Shape3;
    ModelRenderer Shape4;
    ModelRenderer Shape5;
  
  public ModelMVBattery()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      Shape1 = new ModelRenderer(this, 19, 0);
      Shape1.addBox(0F, 0F, 0F, 6, 1, 6);
      Shape1.setRotationPoint(-3F, 23F, -3F);
      Shape1.setTextureSize(64, 32);
      Shape1.mirror = true;
      setRotation(Shape1, 0F, 0F, 0F);
      Shape2 = new ModelRenderer(this, 0, 5);
      Shape2.addBox(0F, 0F, 0F, 4, 3, 4);
      Shape2.setRotationPoint(-2F, 20F, -2F);
      Shape2.setTextureSize(64, 32);
      Shape2.mirror = true;
      setRotation(Shape2, 0F, 0F, 0F);
      Shape3 = new ModelRenderer(this, 19, ;
      Shape3.addBox(0F, 0F, 0F, 6, 1, 6);
      Shape3.setRotationPoint(-3F, 19F, -3F);
      Shape3.setTextureSize(64, 32);
      Shape3.mirror = true;
      setRotation(Shape3, 0F, 0F, 0F);
      Shape4 = new ModelRenderer(this, 0, 13);
      Shape4.addBox(0F, 0F, 0F, 4, 3, 4);
      Shape4.setRotationPoint(-2F, 16F, -2F);
      Shape4.setTextureSize(64, 32);
      Shape4.mirror = true;
      setRotation(Shape4, 0F, 0F, 0F);
      Shape5 = new ModelRenderer(this, 19, 16);
      Shape5.addBox(0F, 0F, 0F, 6, 1, 6);
      Shape5.setRotationPoint(-3F, 15F, -3F);
      Shape5.setTextureSize(64, 32);
      Shape5.mirror = true;
      setRotation(Shape5, 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);
    Shape1.render(f5);
    Shape2.render(f5);
    Shape3.render(f5);
    Shape4.render(f5);
    Shape5.render(f5);
  }
  public void renderModel(float f5)
  {
    Shape1.render(f5);
    Shape2.render(f5);
    Shape3.render(f5);
    Shape4.render(f5);
    Shape5.render(f5);
  }
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }

}

 

BlockMVBattery.java

package com.waterdude.mod.blocks;

import java.util.List;
import java.util.Random;

import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

import com.waterdude.mod.BaseWaterdude;
import com.waterdude.mod.core.TileEntityMVBattery;

public class BlockMVBattery extends BlockContainer
{
public BlockMVBattery(int par1, int par2, Class class1)
{

	super(par1, par2, Material.rock);
	this.setCreativeTab(CreativeTabs.tabMisc);
	this.setRequiresSelfNotify();

}


/*public int idDropped()
{
	return BaseWaterdude.mvbItem.itemID;
}*/



public int quantityDropped(Random par1Random)
{
	return 1;
}

    @Override
    public int getRenderType()
    {
        
        return BaseWaterdude.mvbRenderID;
    }


public boolean isOpaqueCube() 
{
	return false;
} 

public boolean renderAsNormalBlock() 
{
	return false;
} 

public TileEntity getBlockEntity() 
{
	return new TileEntityMVBattery();

}


public TileEntity createNewTileEntity(World var1)
{
	return new TileEntityMVBattery();

}


}

 

IBlockRenderer (got this from the wiki, not too sure on it)

package com.waterdude.mod.core;

import com.waterdude.mod.BaseWaterdude;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;

public class IBlockRenderer implements ISimpleBlockRenderingHandler
{
    public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
    {
	renderInventoryBlock(block, metadata, modelID, renderer);

	if (block == BaseWaterdude.mvb)
	{
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityMVBattery(), 0.0D, 0.0D, 0.0D, 0.0F);
	}
         
    }

    public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
    {
         // Your renderring code
         return false;
    }

    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 int getRenderId()
    {
         // This is one place we need that renderId from earlier.
         return BaseWaterdude.mvbRenderID;
    }
}

 

TileEntityMVBattery.java

package com.waterdude.mod.core;

import net.minecraft.tileentity.TileEntity;

public class TileEntityMVBattery extends TileEntity
{
public TileEntityMVBattery()
{

} 
}

 

TileEntityMVBatteryRenderer.java

package com.waterdude.mod.core;

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

import java.util.Random;

import org.lwjgl.opengl.GL11;

public class TileEntityMVBatteryRenderer extends TileEntitySpecialRenderer
{
private ModelMVBattery model;

public TileEntityMVBatteryRenderer()
{
	model = new ModelMVBattery();
}

public void renderAModelAt(TileEntityMVBattery tile, double d, double d1, double d2, float f)
{
	int i =0;

	if(tile.worldObj != null) 
	{
		i =(tile.worldObj.getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord)); 
	}

	bindTextureByName("/ManaAndMagic/mvb.png");

	GL11.glPushMatrix(); 
	GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F);
	GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); 
	GL11.glScalef(1.0F, -1F, -1F); 
	model.renderModel(0.0625F); 
	GL11.glPopMatrix(); 
}



public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f)
{
	renderAModelAt((TileEntityMVBattery) tileentity, d, d1, d2, f);
}
}

 

If you need to see any other classes, just ask.

 

Posted

How is the item rendering not causing an infinite loop? You call the method within the method...within the method...within the method...etc.

 

Either way that's probably your problem so try commenting it out. (put '//' in front of it)

 

Unless there's a 'super' in front of that you removed for some reason but I don't think that works either.

Posted

I found this thread that might help shed some light on things: http://www.minecraftforge.net/forum/index.php/topic,3389.0.html

 

I'm not sure how good the solved code is nowadays, but some things I noticed:

 

-Since a Tile Entity is involved, it might be better to use a custom Tile Entity renderer, like they mention and write an example of later in the thread, rather than use the block rendering handlers.

-BlockVelvetTable.java, which extends BlockContainer, uses the getTextureFile() method we're more familiar with. Maybe BlockMVBattery.java should do the same, since it also extends BlockContainer?

Posted

IT WORKED!!!! sorry for all caps. thank you thank you thank you. I just had to add

ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySuperCalc.class, new RenderSuperCalc());

to the client proxy. now how do I change to collision bounds so they just take up the area that the block is in.

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

    • Having problems with forge installation on headless arch linux, regardless of forge-server from yay or manual wget, Cant find class error and results in net/minecraft/world/waypoints/Waypoint$Icon.class   net/minecraft/world/waypoints/Waypoint.class   net/minecraft/world/waypoints/WaypointManager.class   net/minecraft/world/waypoints/WaypointStyleAsset.class   net/minecraft/world/waypoints/WaypointStyleAssets.class   net/minecraft/world/waypoints/WaypointTransmitter$BlockConnection.class   net/minecraft/world/waypoints/WaypointTransmitter$ChunkConnection.class   net/minecraft/world/waypoints/WaypointTransmitter$Connection.class   net/minecraft/world/waypoints/WaypointTransmitter$EntityAzimuthConnection.class   net/minecraft/world/waypoints/WaypointTransmitter$EntityBlockConnection.class   net/minecraft/world/waypoints/WaypointTransmitter$EntityChunkConnection.class   net/minecraft/world/waypoints/WaypointTransmitter.class   version.json   Processor failed, invalid outputs:     /srv/minecraft/./libraries/net/minecraft/server/1.21.6/server-1.21.6-official.jar       Expected: b1448d2c947e923ccd63224defc3b51e5a72a98d       Actual:   5f30bf411bd0d1208baca6b7be1584442f4f6579 There was an error during installation
    • This is my first time setting up a minecraft server, and I had wanted to add modding capabilities with forge but I keep getting errors while installing? I have tried installing several versions of forge but i have ended up getting unable to find class and checksum errors? Same thing when trying yay -S forge-server The only thing that works is installing the vanilla minecraft server from minecraft itself?   net/minecraft/util/parsing/packrat/Atom.class   net/minecraft/util/parsing/packrat/CachedParseState$CacheEntry.class   net/minecraft/util/parsing/packrat/CachedParseState$PositionCache.class   net/minecraft/util/parsing/packrat/CachedParseState$Silent.class   net/minecraft/util/parsing/packrat/CachedParseState$SimpleControl.class   net/minecraft/util/parsing/packrat/CachedParseState.class   net/minecraft/util/parsing/packrat/Control$1.class   net/minecraft/util/parsing/packrat/Control.class   net/minecraft/util/parsing/packrat/DelayedException.class   net/minecraft/util/parsing/packrat/Dictionary$Entry.class   net/minecraft/util/parsing/packrat/Dictionary$Reference.class   net/minecraft/util/parsing/packrat/Dictionary.class   net/minecraft/util/parsing/packrat/ErrorCollector$LongestOnly$MutableErrorEntry.class   net/minecraft/util/parsing/packrat/ErrorCollector$LongestOnly.class   net/minecraft/util/parsing/packrat/ErrorCollector$Nop.class   net/minecraft/util/parsing/packrat/ErrorCollector.class   net/minecraft/util/parsing/packrat/ErrorEntry.class   net/minecraft/util/parsing/packrat/NamedRule.class   net/minecraft/util/parsing/packrat/ParseState.class   net/minecraft/util/parsing/packrat/Rule$RuleAction.class   net/minecraft/util/parsing/packrat/Rule$SimpleRuleAction.class   net/minecraft/util/parsing/packrat/Rule$WrappedTerm.class Processor failed, invalid outputs:     /srv/minecraft/./libraries/net/minecraft/server/1.21.6/server-1.21.6-official.jar       Expected: b1448d2c947e923ccd63224defc3b51e5a72a98d       Actual:   5f30bf411bd0d1208baca6b7be1584442f4f6579 There was an error during installation  
    • Fight with others to gain more hearts.
    • I wanted to try out Immersive railroading mod + Miszko's train resource pack, but everytime i create a world. it just gives me saving world after the map icon shows 100% and then crashes..   latest.log here https://drive.google.com/file/d/14v1pGCoytqyDvVwPayfUkYolmxcZ7z6-/view?usp=sharing
    • https://mclo.gs/yYaROad make a new pack base and just readded each mod. now it gets stuck at loaded config  
  • Topics

×
×
  • Create New...

Important Information

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