Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I'm attempting to create a new furnace built like the coke oven furnace in Railcraft. However, I have no idea how to approach this. Thus far, I have the following files present.

 

package insanegravy.herbcraft.common;

import net.minecraft.src.EntityPlayer;
import net.minecraft.src.FurnaceRecipes;
import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;

public class TileOvenBrick extends TileEntity implements IMatrixEntity, IInventory, ISidedInventory {
private ItemStack[] furnaceItemStacks = new ItemStack[3];

public TileOvenBrick() {

}

@Override
public boolean isValidCombination() {
	TileOvenBrick[] x = (TileOvenBrick[]) getXBound();
	TileOvenBrick[] y = (TileOvenBrick[]) getYBound();
	TileOvenBrick[] z = (TileOvenBrick[]) getZBound();

	return (Math.abs(x[0].xCoord - x[1].xCoord) == 1) && (Math.abs(y[0].yCoord - y[1].yCoord) == 1) && (Math.abs(z[0].zCoord - z[1].zCoord) == 1);
}

public static TileOvenBrick getAbove(TileOvenBrick tile) {
	TileEntity above = tile.worldObj.getBlockTileEntity(tile.xCoord, tile.yCoord + 1, tile.zCoord);

	if (above instanceof TileOvenBrick) {
		return (TileOvenBrick) above;
	} else {
		return null;
	}
}

public static TileOvenBrick getBelow(TileOvenBrick tile) {
	TileEntity below = tile.worldObj.getBlockTileEntity(tile.xCoord, tile.yCoord - 1, tile.zCoord);

	if (below instanceof TileOvenBrick) {
		return (TileOvenBrick) below;
	} else {
		return null;
	}
}

public static TileOvenBrick getNextX(TileOvenBrick tile) {
	TileEntity nextX = tile.worldObj.getBlockTileEntity(tile.xCoord + 1, tile.yCoord, tile.zCoord);

	if (nextX instanceof TileOvenBrick) {
		return (TileOvenBrick) nextX;
	} else {
		return null;
	}
}

public static TileOvenBrick getPrevX(TileOvenBrick tile) {
	TileEntity prevX = tile.worldObj.getBlockTileEntity(tile.xCoord - 1, tile.yCoord, tile.zCoord);

	if (prevX instanceof TileOvenBrick) {
		return (TileOvenBrick) prevX;
	} else {
		return null;
	}
}

public static TileOvenBrick getNextZ(TileOvenBrick tile) {
	TileEntity nextZ = tile.worldObj.getBlockTileEntity(tile.xCoord, tile.yCoord, tile.zCoord + 1);

	if (nextZ instanceof TileOvenBrick) {
		return (TileOvenBrick) nextZ;
	} else {
		return null;
	}
}

public static TileOvenBrick getPrevZ(TileOvenBrick tile) {
	TileEntity prevZ = tile.worldObj.getBlockTileEntity(tile.xCoord, tile.yCoord, tile.zCoord - 1);

	if (prevZ instanceof TileOvenBrick) {
		return (TileOvenBrick) prevZ;
	} else {
		return null;
	}
}

@Override
public TileEntity[] getXBound() {
	TileEntity[] result = new TileOvenBrick[2];
	TileOvenBrick nextX = this;
	TileOvenBrick prevX = this;

	for(; {
		TileOvenBrick temp = getNextX(nextX);

		if (temp != null) {
			nextX = temp;
		} else {
			result[0] = nextX;
			break;
		}
	}

	for(; {
		TileOvenBrick temp = getPrevX(prevX);

		if (temp != null) {
			prevX = temp;
		} else {
			result[1] = prevX;
			break;
		}
	}

	return result;
}

@Override
public TileEntity[] getYBound() {
	TileEntity[] result = new TileOvenBrick[2];
	TileOvenBrick nextY = this;
	TileOvenBrick prevY = this;

	for(; {
		TileOvenBrick temp = getAbove(nextY);

		if (temp != null) {
			nextY = temp;
		} else {
			result[0] = nextY;
			break;
		}
	}

	for(; {
		TileOvenBrick temp = getBelow(prevY);

		if (temp != null) {
			prevY = temp;
		} else {
			result[1] = prevY;
			break;
		}
	}

	return result;
}

@Override
public TileEntity[] getZBound() {
	TileEntity[] result = new TileOvenBrick[2];
	TileOvenBrick nextZ = this;
	TileOvenBrick prevZ = this;

	for(; {
		TileOvenBrick temp = getNextZ(nextZ);

		if (temp != null) {
			nextZ = temp;
		} else {
			result[0] = nextZ;
			break;
		}
	}

	for(; {
		TileOvenBrick temp = getPrevZ(prevZ);

		if (temp != null) {
			prevZ = temp;
		} else {
			result[1] = prevZ;
			break;
		}
	}

	return result;
}

 public void smeltItem() {
	 if (this.canSmelt()) {
            ItemStack var1 = FurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);

            if (this.furnaceItemStacks[2] == null)
            {
                this.furnaceItemStacks[2] = var1.copy();
            }
            else if (this.furnaceItemStacks[2].isItemEqual(var1))
            {
                furnaceItemStacks[2].stackSize += var1.stackSize;
            }

            --this.furnaceItemStacks[0].stackSize;

            if (this.furnaceItemStacks[0].stackSize <= 0)
            {
                this.furnaceItemStacks[0] = null;
            }
        }
    }

 private boolean canSmelt() {
	 if (this.furnaceItemStacks[0] == null) {
            return false;
        } else {
        	ItemStack var1 = FurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);
            if (var1 == null) return false;
            if (this.furnaceItemStacks[2] == null) return true;
            if (!this.furnaceItemStacks[2].isItemEqual(var1)) return false;
            int result = furnaceItemStacks[2].stackSize + var1.stackSize;
            return (result <= getInventoryStackLimit() && result <= var1.getMaxStackSize());
        }
}

public int getInventoryStackLimit() {
	return 64;
}

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

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

@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 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

}
}

 

package insanegravy.herbcraft.common;

import java.util.Random;

import net.minecraft.src.Block;
import net.minecraft.src.BlockContainer;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.Material;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;

public class BlockOvenBrick extends BlockContainer {

public BlockOvenBrick(int par1, int par2) {
	super(par1, par2, Material.rock);
}

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

@Override
public boolean renderAsNormalBlock() {
	return false;
}

public boolean isOpaqueCube() {
        return false;
    }

@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
	TileOvenBrick brick = (TileOvenBrick) par1World.getBlockTileEntity(par2, par3, par4);

	if (brick != null && brick.isValidCombination()) {
		return true;
	} else {
		return false;
	}
}

public int idDropped(int par1, Random par2Random, int par3) {
        return modHerbcraft.BlockOvenBrick.blockID;
    }
}

 

Beyond this, I have no idea what I'm supposed to do. If the blocks are placed in the proper arrangement, how do I get them to behave as a single unit?

You can take a look in the Railcraft's Source code. That's the best way in learning programming in any language or API.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.