Jump to content

Recommended Posts

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?

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

    • Hello all. I'm currently grappling with the updateShape method in a custom class extending Block.  My code currently looks like this: The conditionals in CheckState are there to switch blockstate properties, which is working fine, as it functions correctly every time in getStateForPlacement.  The problem I'm running into is that when I update a state, the blocks seem to call CheckState with the position of the block which was changed updated last.  If I build a wall I can see the same change propagate across. My question thus is this: is updateShape sending its return to the neighbouring block?  Is each block not independently executing the updateShape method, thus inserting its own current position?  The first statement appears to be true, and the second false (each block is not independently executing the method). I have tried to fix this by saving the block's own position to a variable myPos at inception, and then feeding this in as CheckState(myPos) but this causes a worse outcome, where all blocks take the update of the first modified block, rather than just their neighbour.  This raises more questions than it answers, obviously: how is a different instance's variable propagating here?  I also tried changing it so that CheckState did not take a BlockPos, but had myPos built into the body - same problem. I have previously looked at neighbourUpdate and onNeighbourUpdate, but could not find a way to get this to work at all.  One post on here about updatePostPlacement and other methods has proven itself long superceded.  All other sources on the net seem to be out of date. Many thanks in advance for any help you might offer me, it's been several days now of trying to get this work and several weeks of generally trying to get round this roadblock.  - Sandermall
    • sorry, I might be stupid, but how do I open it? because the only options I have are too X out, copy it, which doesn't work and send crash report, which doesn't show it to me, also, sorry for taking so long.
    • Can you reproduce this with version 55.0.21? A whole lot of plant placement issues were just fixed in this PR.
    • Necro'ing that thread to ask if you found a solution ? I'm encountering the same crash on loading the world. I created the world in Creative to test my MP, went into survival to test combat, died, crashed on respawn and since then crash on loading the world. Deactivating Oculus isn't fixing it either, and I don't have Optifine (Twilight forest is incompatible)
  • Topics

×
×
  • Create New...

Important Information

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