Jump to content

Need advice/help with getting a custom model chest working.


Rivendark2013

Recommended Posts

Ok, i know when im truly stumped.

 

Im trying to figure out how to add a Custom Modeled Chest into the game.

 

The only tutorials ive been able to find are outdated and or done for ModLoader.

 

Ill post the mess i have, in hopes someone can either tell me what ive messed up, or point me to a tutorial or repository that can get me back on track.

 

What i cant figure out is how to go from the outdated ML tutorials, to current forge, and whether i need to render my model as a block, tile entity, ect.

 

Any help will be greatly appriciated.

 

Ill also leave my github repo link here if that makes it easier for people to untangle this mess i have right now.

 

https://github.com/Rivendark/quantumassembly

 

my base file: QuantumAssembly.java

public class QuantumAssembly {
@Instance("quantumassembly")
public static QuantumAssembly instance;

public static CreativeTabs tabMachine = new QuantumAssemblyMachineTab(CreativeTabs.getNextID(), 
		"Rivendark_QuantumAssemblyMachineTab");

public static String blockTextureFile = "/gfx/BlankSheet.png";

public static int QuantumStorageBlock_ID = 250;

public static int QuantumStorageBlock_IID = -6;

public static int QuantumStorageBlock_TID = 0;

public static int QuantumStorageBlock_RID;

public static Material QuantumStorageBlock_Material = Material.iron;

public static Block QuantumStorageBlock = new BlockQuantumStorage();

//public static Item QuantumStorageItemBlock = (new ItemBlockQuantumStorage(QuantumStorageBlock_IID, QuantumStorageBlock)
		//.setItemName("ItemQuantumStorageBlock"));

public static QuantumAssemblyProxy proxy;

@Init
public void load(FMLInitializationEvent event){
	//NetworkRegistry.instance().registerGuiHandler(this, proxy);
	proxy.registerBlocks();
	//proxy.registerTiles();
	proxy.addNames();
	proxy.addRecipes();
	proxy.registerRenderThings();

	QuantumStorageBlock.getBlockTextureFromSide(0);

}

 

Proxy file:

public class QuantumAssemblyProxy implements IGuiHandler {

@SidedProxy(clientSide = "rivendark.mods.quantumassembly.core.QuantumAssemblyProxyClient",
		serverSide = "rivendark.mods.quantumassembly.core.QuantumAssemblyProxy")
public static QuantumAssemblyProxy proxy;

public void registerRenderThings() {


}

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
		int x, int y, int z) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
		int x, int y, int z) {
	// TODO Auto-generated method stub
	return null;
}

public void registerTiles(){

}

public void registerBlocks(){
	GameRegistry.registerBlock(QuantumAssembly.QuantumStorageBlock, "rivendark_QuantumStorageBlock");
}

public void addNames(){
	LanguageRegistry.addName(QuantumAssembly.QuantumStorageBlock, "Quantum Storage Unit");
}

public void addRecipes(){

}

 

Client Proxy File:

public class QuantumAssemblyProxyClient extends QuantumAssemblyProxy {
@Override
public void registerRenderThings(){
	MinecraftForgeClient.preloadTexture(QuantumAssembly.blockTextureFile); //To Do.
	QuantumAssembly.QuantumStorageBlock_RID = RenderingRegistry.instance().getNextAvailableRenderId();
	RenderingRegistry.instance().registerBlockHandler(
			QuantumAssembly.QuantumStorageBlock_RID,new QuantumStorageBlockRenderer());
}
}

 

Block File:

public class BlockQuantumStorage extends BlockContainer {

public BlockQuantumStorage() {
	super(QuantumAssembly.QuantumStorageBlock_ID, QuantumAssembly.QuantumStorageBlock_TID, Material.iron);

	//tileClass = class1;

	this.setTextureFile(QuantumAssembly.blockTextureFile);
	this.setBlockName("Rivendark_BlockQuantumStorage");
	this.setHardness(5.0F);
	this.setResistance(150.0F);
	this.setStepSound(super.soundMetalFootstep);
	this.setCreativeTab(QuantumAssembly.tabMachine);
	this.setRequiresSelfNotify();
}

@Override
public boolean onBlockActivated(World world, int x, int y, int z,
		EntityPlayer player, int idk, float what, float these, float are){
	TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
	if(tileEntity == null || player.isSneaking()){
		return false;
	}
	player.openGui(QuantumAssembly.instance, 0, world, x, y, z);
	return true;
}

@Override
 public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
       // dropItems(world, x, y, z);
        super.breakBlock(world, x, y, z, par5, par6);
}

private void dropItems(World world, int x, int y, int z) {
	Random rand = new Random();
	TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
	if(!(tileEntity instanceof IInventory)){
		return;
	}
	IInventory inv = (IInventory) tileEntity;

	for(int i = 0; i < inv.getSizeInventory(); i++){
		ItemStack item = inv.getStackInSlot(i);
		if(item != null && item.stackSize > 0){
			float rx = rand.nextFloat() * 0.8F + 0.1F;
			float ry = rand.nextFloat() * 0.8F + 0.1F;
			float rz = rand.nextFloat() * 0.8F + 0.1F;

			EntityItem entityItem = new EntityItem(world, x + rx, y + ry, z + rz,
					new ItemStack(item.itemID, item.stackSize, item.getItemDamage()));
			if(item.hasTagCompound()){
				entityItem.func_92014_d().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
			}

			float factor = 0.05F;
			entityItem.motionX = rand.nextGaussian() * factor;
			entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
			entityItem.motionZ = rand.nextGaussian() * factor;
			world.spawnEntityInWorld(entityItem);
			item.stackSize = 0;
		}
	}
}

@SideOnly(Side.CLIENT)
public int getBlockTextureFromSide(int i){
	return QuantumAssembly.QuantumStorageBlock_TID;
}

@Override
public TileEntity createNewTileEntity(World var1) {
	return new TileQuantumStorage();
}

public TileEntity getBlockEntity(){
		return new TileQuantumStorage();
}

public int getRenderType(){
	return QuantumAssembly.QuantumStorageBlock_RID;
}

public boolean isQpaqueCube(){
	return false;
}

public boolean renderAsNormalBlock(){
	return false;
}	

 

TileEntityRenderer File:

public class QuantumStorageTileEntityRenderer extends TileEntitySpecialRenderer {

private QuantumStorageModel quantumStorageModel;

public QuantumStorageTileEntityRenderer(){
	quantumStorageModel = new QuantumStorageModel();
}

@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) {
	renderAModelAt((TileQuantumStorage) tile, x, y, z, f);
}

public void renderAModelAt(TileQuantumStorage tile, double x, double y, double z, float f){
	bindTextureByName("../core/gfx/QuantumStorageTexture.png");

	GL11.glPushMatrix();
	GL11.glTranslatef((float)+x + 0.5F, (float)+y + 0.5F, (float)+z + 0.5F);
	GL11.glRotatef(0, 0.0F, 1.0F, 0.0F);
	GL11.glScalef(1.0F, -1F, -1F);
	quantumStorageModel.renderModel(0.0625F);
	GL11.glPopMatrix();
}

}

 

Tile File:

public class TileQuantumStorage extends TileEntity implements IInventory {

private ItemStack[] inv;

public TileQuantumStorage(){

}

@Override
public int getSizeInventory() {
	// TODO Auto-generated method stub
	return 0;
}

@Override
public ItemStack getStackInSlot(int var1) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public ItemStack decrStackSize(int var1, int var2) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public ItemStack getStackInSlotOnClosing(int var1) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public void setInventorySlotContents(int var1, ItemStack var2) {
	// TODO Auto-generated method stub

}

@Override
public String getInvName() {
	// TODO Auto-generated method stub
	return null;
}

@Override
public int getInventoryStackLimit() {
	// TODO Auto-generated method stub
	return 0;
}

@Override
public boolean isUseableByPlayer(EntityPlayer var1) {
	// TODO Auto-generated method stub
	return false;
}

@Override
public void openChest() {
	// TODO Auto-generated method stub

}

@Override
public void closeChest() {
	// TODO Auto-generated method stub

}
}

 

 

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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