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.

Dklory

Members
  • Joined

  • Last visited

Everything posted by Dklory

  1. So I have to remove that string? P.s. Sorry for my errors but I'm Italian
  2. there are all furnace's that I used: Block Furnace: public class BlockQuartzFurnace extends BlockContainer { private Random quartzRand; @SideOnly(Side.CLIENT) private Icon QuartzIconTop; private Icon QuartzIconBottom; @SideOnly(Side.CLIENT) private Icon QuartzIconFront; private Icon QuartzIconSide; private Icon QuartzIconFrontActive; private boolean isActive = true; private static boolean keepFurnaceInventory; public BlockQuartzFurnace(int par1, boolean par2Boolean) { super(par1, Material.rock); this.setCreativeTab(CreativeTabs.tabBlock); quartzRand = new Random(); } public void onBlockAdded(World par1World, int par2, int par3, int par4) { super.onBlockAdded(par1World, par2, par3, par4); this.setDefaultDirection(par1World, par2, par3, par4); par1World.markBlockForUpdate(par2, par3, par4); } private void setDefaultDirection(World par1World, int x, int y, int z) { TileEntity blockEntity = par1World.getBlockTileEntity(x, y, z); if (par1World.isRemote) { return; } int i = par1World.getBlockId(x, y, z - 1); int j = par1World.getBlockId(x, y, z + 1); int k = par1World.getBlockId(x - 1, y, z); int l = par1World.getBlockId(x + 1, y, z); byte b0 = 3; if (Block.opaqueCubeLookup[i] && !Block.opaqueCubeLookup[j]) { b0 = 3; } if (Block.opaqueCubeLookup[j] && !Block.opaqueCubeLookup[i]) { b0 = 2; } if (Block.opaqueCubeLookup[k] && !Block.opaqueCubeLookup[l]) { b0 = 5; } if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[k]) { b0 = 4; } ((TileEntityQuartzFurnace) blockEntity).setFrontDirection(b0); } @Override public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EPlayer, int par6, float par7, float par8, float par9) { TileEntityQuartzFurnace tileentityrefiner = (TileEntityQuartzFurnace) par1World.getBlockTileEntity(par2, par3, par4); if (tileentityrefiner != null) { par5EPlayer.openGui(mod_SecretMod.instance, 0, par1World, par2, par3, par4); } return true; } public Icon getBlockTexture(IBlockAccess access, int x, int y, int z, int side) { int front = 0; TileEntity tile = ModLoader.getMinecraftInstance().getIntegratedServer().worldServers[0].getBlockTileEntity(x, y, z); if (tile != null) { front = ((TileEntityQuartzFurnace) tile).getFrontDirection(); } else { ModLoader.getMinecraftInstance().getIntegratedServer().worldServers[0].markBlockForUpdate(x, y, z); } switch (side) { case 0: return QuartzIconBottom; case 1: return QuartzIconTop; default: if (side == front) { return ((TileEntityQuartzFurnace) tile).isActive() ? QuartzIconFrontActive : QuartzIconFront; } else { return QuartzIconSide; } } } public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { if (!keepFurnaceInventory) { TileEntityQuartzFurnace Refiner = (TileEntityQuartzFurnace) par1World.getBlockTileEntity(par2, par3, par4); if (Refiner != null) { for (int i = 0; i < Refiner.getSizeInventory(); i++) { ItemStack IS = Refiner.getStackInSlot(i); if (IS != null) { float j = this.quartzRand.nextFloat() * 0.8F + 0.1F; float k = this.quartzRand.nextFloat() * 0.8F + 0.1F; float l = this.quartzRand.nextFloat() * 0.8F + 0.1F; while (IS.stackSize > 0) { int m = this.quartzRand.nextInt(21) + 10; if (m > IS.stackSize) { m = IS.stackSize; } IS.stackSize -= m; EntityItem n = new EntityItem(par1World, (double) ((float) par2 + j), (double) ((float) par3 + k), (double) ((float) par4 + l), new ItemStack(IS.itemID, m, IS.getItemDamage())); if (IS.hasTagCompound()) { n.getEntityItem().setTagCompound((NBTTagCompound) IS.getTagCompound().copy()); } float o = 0.05F; n.motionX = (double) ((float) this.quartzRand.nextGaussian() * o); n.motionZ = (double) ((float) this.quartzRand.nextGaussian() * o); n.motionY = (double) ((float) this.quartzRand.nextGaussian() * o); par1World.spawnEntityInWorld(n); } } } } } super.breakBlock(par1World, par2, par3, par4, par5, par6); } @SideOnly(Side.CLIENT) public Icon getIcon(int par1, int par2) { switch (par1) { case 0: return QuartzIconBottom; case 1: return QuartzIconTop; case 2: return QuartzIconSide; case 3: return QuartzIconFront; case 4: return QuartzIconSide; case 5: return QuartzIconSide; default: return QuartzIconSide; } } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { Object planetgeeks; this.QuartzIconSide = iconRegister.registerIcon("secretmod:quartzFurnace_side"); this.QuartzIconFront = iconRegister.registerIcon("secretmod:quartzFurnace_front_Idle"); this.QuartzIconFrontActive = iconRegister.registerIcon("secretmod:quartzFurnace_front_active"); this.QuartzIconBottom = iconRegister.registerIcon("secretmod:quartzFurnace_top"); this.QuartzIconTop = iconRegister.registerIcon("secretmod:quartzFurnace_top"); } @Override public TileEntity createNewTileEntity(World world) { return new TileEntityQuartzFurnace(); } } TileEntityFurnace: public class TileEntityQuartzFurnace extends TileEntity implements IInventory { private ItemStack goldItemStacks[]; /** The number of ticks that the furnace will keep burning */ public int goldBurnTime; private boolean isActive; /** * The number of ticks that a fresh copy of the currently-burning item would * keep the furnace burning for */ public int goldItemBurnTime; /** The number of ticks that the current item has been cooking for */ public int goldCookTime; public int front; public TileEntityQuartzFurnace() { goldItemStacks = new ItemStack[3]; goldBurnTime = 0; goldItemBurnTime = 0; goldCookTime = 0; } public void setFrontDirection(int f) { this.front = f; } public int getFrontDirection() { return this.front; } /** * Returns the number of slots in the inventory. */ public int getSizeInventory() { return goldItemStacks.length; } /** * Returns the stack in slot i */ public ItemStack getStackInSlot(int par1) { return goldItemStacks[par1]; } /** * Decrease the size of the stack in slot (first int arg) by the amount of * the second int arg. Returns the new stack. */ public ItemStack decrStackSize(int par1, int par2) { if (goldItemStacks[par1] != null) { if (goldItemStacks[par1].stackSize <= par2) { ItemStack itemstack = goldItemStacks[par1]; goldItemStacks[par1] = null; return itemstack; } ItemStack itemstack1 = goldItemStacks[par1].splitStack(par2); if (goldItemStacks[par1].stackSize == 0) { goldItemStacks[par1] = null; } return itemstack1; } 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 (goldItemStacks[par1] != null) { ItemStack itemstack = goldItemStacks[par1]; goldItemStacks[par1] = null; return itemstack; } 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) { goldItemStacks[par1] = par2ItemStack; if (par2ItemStack != null && par2ItemStack.stackSize > getInventoryStackLimit()) { par2ItemStack.stackSize = getInventoryStackLimit(); } } /** * Returns the name of the inventory. */ public String getInvName() { return "container.goldOven"; } /** * Reads a tile entity from NBT. */ public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items"); goldItemStacks = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.tagAt(i); byte byte0 = nbttagcompound.getByte("Slot"); if (byte0 >= 0 && byte0 < goldItemStacks.length) { goldItemStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound); } } front = par1NBTTagCompound.getInteger("FrontDirection"); goldBurnTime = par1NBTTagCompound.getShort("BurnTime"); goldCookTime = par1NBTTagCompound.getShort("CookTime"); goldItemBurnTime = getItemBurnTime(goldItemStacks[1]); } /** * Writes a tile entity to NBT. */ public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); par1NBTTagCompound.setInteger("FrontDirection", (int) front); par1NBTTagCompound.setShort("BurnTime", (short) goldBurnTime); par1NBTTagCompound.setShort("CookTime", (short) goldCookTime); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < goldItemStacks.length; i++) { if (goldItemStacks[i] != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setByte("Slot", (byte) i); goldItemStacks[i].writeToNBT(nbttagcompound); nbttaglist.appendTag(nbttagcompound); } } par1NBTTagCompound.setTag("Items", nbttaglist); } /** * 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; } /** * 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 (goldCookTime * par1) / 200; } /** * 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 (goldItemBurnTime == 0) { goldItemBurnTime = 200; } return (goldBurnTime * par1) / goldItemBurnTime; } /** * Returns true if the furnace is currently burning */ public boolean isBurning() { return goldBurnTime > 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.goldBurnTime > 0; boolean var2 = false; if (this.goldBurnTime > 0) { --this.goldBurnTime; } if (!this.worldObj.isRemote) { if (this.goldBurnTime == 0 && this.canSmelt()) { this.goldItemBurnTime = this.goldBurnTime = getItemBurnTime(this.goldItemStacks[1]); if (this.goldBurnTime > 0) { var2 = true; if (this.goldItemStacks[1] != null) { --this.goldItemStacks[1].stackSize; if (this.goldItemStacks[1].stackSize == 0) { Item var3 = this.goldItemStacks[1].getItem().getContainerItem(); this.goldItemStacks[1] = var3 == null ? null : new ItemStack(var3); } } } } if (this.isBurning() && this.canSmelt()) { ++this.goldCookTime; if (this.goldCookTime == 200) { this.goldCookTime = 0; this.smeltItem(); var2 = true; } } else { this.goldCookTime = 0; } if (var1 != this.goldBurnTime > 0) { var2 = true; this.validate(); } } boolean check = isActive; isActive = isBurning(); if (isActive != check) { this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } if (var2) { this.onInventoryChanged(); } } /** * Returns true if the furnace can smelt an item, i.e. has a source item, * destination stack isn't full, etc. */ private boolean canSmelt() { if (goldItemStacks[0] == null) { return false; } ItemStack itemstack = RecipesQuartzFurnace.smelting().getSmeltingResult(goldItemStacks[0].getItem().itemID); if (itemstack == null) { return false; } if (goldItemStacks[2] == null) { return true; } if (!goldItemStacks[2].isItemEqual(itemstack)) { return false; } if (goldItemStacks[2].stackSize < getInventoryStackLimit() && goldItemStacks[2].stackSize < goldItemStacks[2].getMaxStackSize()) { return true; } return goldItemStacks[2].stackSize < itemstack.getMaxStackSize(); } /** * Turn one item from the furnace source stack into the appropriate smelted * item in the furnace result stack */ public void smeltItem() { if (this.canSmelt()) { ItemStack var1 = RecipesQuartzFurnace.smelting().getSmeltingResult(this.goldItemStacks[0].getItem().itemID); if (this.goldItemStacks[2] == null) { this.goldItemStacks[2] = var1.copy(); } else if (this.goldItemStacks[2].itemID == var1.itemID) { ++this.goldItemStacks[2].stackSize; } --this.goldItemStacks[0].stackSize; if (this.goldItemStacks[0].stackSize == 0) { Item var2 = this.goldItemStacks[0].getItem().getContainerItem(); this.goldItemStacks[0] = var2 == null ? null : new ItemStack(var2); } } } /** * Return true if item is a fuel source (getItemBurnTime() > 0). */ public static boolean isItemFuel(ItemStack par0ItemStack) { return getItemBurnTime(par0ItemStack) > 0; } /** * Returns the number of ticks that the supplied fuel item will keep the * furnace burning, or 0 if the item isn't fuel */ public static int getItemBurnTime(ItemStack par1ItemStack) { if (par1ItemStack == null) { return 0; } int i = par1ItemStack.getItem().itemID; if (i < 256 && Block.blocksList[i].blockMaterial == Material.wood) { return 300; } if (i == Item.stick.itemID) { return 100; } if (i == Item.coal.itemID) { return 1600; } if (i == Item.bucketLava.itemID) { return 20000; } if (i == Block.sapling.blockID) { return 100; } if (i == Item.blazeRod.itemID) { return 2400; } else { return ModLoader.addAllFuel(par1ItemStack.itemID, par1ItemStack.getItemDamage()); } } /** * 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() { } public boolean isActive() { return this.isActive; } @Override public boolean isInvNameLocalized() { // TODO Auto-generated method stub return true; } @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { // TODO Auto-generated method stub return true; } public void setGuiDisplayName(String displayName) { // TODO Auto-generated method stub } } Container: public class ContainerQuartzFurnace extends Container { private TileEntityQuartzFurnace goldOven; private int lastGoldOvenCookTime; private int lastGoldOvenBurnTime; private int lastGoldOvenItemBurnTime; public ContainerQuartzFurnace(InventoryPlayer par1InventoryPlayer, TileEntityQuartzFurnace par2TileEntityGoldOven) { lastGoldOvenCookTime = 0; lastGoldOvenBurnTime = 0; lastGoldOvenItemBurnTime = 0; goldOven = par2TileEntityGoldOven; addSlotToContainer(new Slot(par2TileEntityGoldOven, 0, 56, 17)); addSlotToContainer(new Slot(par2TileEntityGoldOven, 1, 56, 53)); addSlotToContainer(new slotQuartzFurnace(par1InventoryPlayer.player, par2TileEntityGoldOven, 2, 116, 35)); for (int i = 0; i < 3; i++) { for (int k = 0; k < 9; k++) { addSlotToContainer(new Slot(par1InventoryPlayer, k + i * 9 + 9, 8 + k * 18, 84 + i * 18)); } } for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(par1InventoryPlayer, j, 8 + j * 18, 142)); } } /** * Updates crafting matrix; called from onCraftMatrixChanged. Args: none */ public void detectAndSendChanges() { super.detectAndSendChanges(); Iterator var1 = this.crafters.iterator(); while (var1.hasNext()) { ICrafting var2 = (ICrafting)var1.next(); if (this.lastGoldOvenCookTime != this.goldOven.goldCookTime) { var2.sendProgressBarUpdate(this, 0, this.goldOven.goldCookTime); } if (this.lastGoldOvenBurnTime != this.goldOven.goldBurnTime) { var2.sendProgressBarUpdate(this, 1, this.goldOven.goldBurnTime); } if (this.lastGoldOvenItemBurnTime != this.goldOven.goldItemBurnTime) { var2.sendProgressBarUpdate(this, 2, this.goldOven.goldItemBurnTime); } } this.lastGoldOvenCookTime = this.goldOven.goldCookTime; this.lastGoldOvenBurnTime = this.goldOven.goldBurnTime; this.lastGoldOvenItemBurnTime = this.goldOven.goldItemBurnTime; } public void updateProgressBar(int par1, int par2) { if (par1 == 0) { goldOven.goldCookTime = par2; } if (par1 == 1) { goldOven.goldBurnTime = par2; } if (par1 == 2) { goldOven.goldItemBurnTime = par2; } } public boolean canInteractWith(EntityPlayer par1EntityPlayer) { return goldOven.isUseableByPlayer(par1EntityPlayer); } /** * Called to transfer a stack from one inventory to the other eg. when shift clicking. */ @Override public ItemStack transferStackInSlot(EntityPlayer player, int slotnumber) { ItemStack itemstack = null; Slot slot = (Slot)inventorySlots.get(slotnumber); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (slotnumber == 2) { if (!mergeItemStack(itemstack1, 3, 39, true)) { return null; } slot.onSlotChange(itemstack1, itemstack); } else if (slotnumber == 1 || slotnumber == 0) { if (!mergeItemStack(itemstack1, 3, 39, false)) { return null; } } else if (RecipesQuartzFurnace.smelting().getSmeltingResult(itemstack1.getItem().itemID) != null) { if (!mergeItemStack(itemstack1, 0, 1, false)) { return null; } } else if (TileEntityQuartzFurnace.isItemFuel(itemstack1)) { if (!mergeItemStack(itemstack1, 1, 2, false)) { return null; } } else if (slotnumber >= 3 && slotnumber < 30) { if (!mergeItemStack(itemstack1, 30, 39, false)) { return null; } } else if (slotnumber >= 30 && slotnumber < 39 && !mergeItemStack(itemstack1, 3, 30, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack(null); } else { slot.onSlotChanged(); } if (itemstack1.stackSize == itemstack.stackSize) { return null; } slot.onPickupFromSlot(player, itemstack); } return itemstack; } } guihandler: public class GuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { TileEntity tile_entity = world.getBlockTileEntity(x, y, z); if (id == 0) { return new ContainerQuartzFurnace(player.inventory, (TileEntityQuartzFurnace) tile_entity); } return null; } @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { TileEntity tile_entity = world.getBlockTileEntity(x, y, z); if (id == 0) { return new GuiQuartzFurnace(player.inventory, (TileEntityQuartzFurnace) tile_entity); } return null; } } GuiFurnace: @SideOnly(Side.CLIENT) public class GuiQuartzFurnace extends GuiContainer { private static final ResourceLocation furnaceGuiTextures = new ResourceLocation("textures/gui/container/furnace.png"); private TileEntityQuartzFurnace furnaceInventory; public GuiQuartzFurnace(InventoryPlayer par1InventoryPlayer, TileEntityQuartzFurnace par2TileEntityFurnace) { super(new ContainerQuartzFurnace(par1InventoryPlayer, par2TileEntityFurnace)); this.furnaceInventory = par2TileEntityFurnace; } /** * Draw the foreground layer for the GuiContainer (everything in front of the items) */ protected void drawGuiContainerForegroundLayer(int par1, int par2) { String s = this.furnaceInventory.isInvNameLocalized() ? this.furnaceInventory.getInvName() : I18n.getString(this.furnaceInventory.getInvName()); this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752); this.fontRenderer.drawString(I18n.getString("Refiner"), 8, this.ySize - 96 + 2, 4210752); } /** * Draw the background layer for the GuiContainer (everything behind the items) */ protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(furnaceGuiTextures); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); int i1; if (this.furnaceInventory.isBurning()) { i1 = this.furnaceInventory.getBurnTimeRemainingScaled(12); this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2); } i1 = this.furnaceInventory.getCookProgressScaled(24); this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16); } } RecipesFurnace: public class RecipesQuartzFurnace { private static final RecipesQuartzFurnace goldOvenBase = new RecipesQuartzFurnace(); /** The list of smelting results. */ private Map goldOvenList = new HashMap(); private Map goldOvenExperience = new HashMap(); /** * Used to call methods addSmelting and getSmeltingResult. */ public static final RecipesQuartzFurnace smelting() { return goldOvenBase; } private RecipesQuartzFurnace() { addSmelting(Block.dirt.blockID, new ItemStack(Block.cobblestone, 1, 0), 0.7F); addSmelting(Item.porkCooked.itemID ,new ItemStack(Item.porkRaw, 1,0), 0.7F); addSmelting(mod_SecretMod.EnderBlock.blockID, new ItemStack(mod_SecretMod.EnderOre,1),0.5F); addSmelting(mod_SecretMod.UltimateOre.blockID, new ItemStack(mod_SecretMod.UltimateIngot,1),0.5F); addSmelting(mod_SecretMod.GreenOre.blockID, new ItemStack(mod_SecretMod.GreenIngot,1),0.5F); } /** * Adds a smelting recipe. */ public void addSmelting(int id, ItemStack itemStack, float experience) { goldOvenList.put(Integer.valueOf(id), itemStack); this.goldOvenExperience.put(Integer.valueOf(itemStack.itemID), Float.valueOf(experience)); } /** * Returns the smelting result of an item. */ public ItemStack getSmeltingResult(int id) { return (ItemStack)goldOvenList.get(Integer.valueOf(id)); } public Map getSmeltingList() { return goldOvenList; } public float getExperience(int par1) { return this.goldOvenExperience.containsKey(Integer.valueOf(par1)) ? ((Float)this.goldOvenExperience.get(Integer.valueOf(par1))).floatValue() : 0.0F; } } SlotFurnace: public class slotQuartzFurnace extends Slot { /** The player that is using the GUI where this slot resides. */ private EntityPlayer thePlayer; private int field_75228_b; public slotQuartzFurnace(EntityPlayer par1EntityPlayer, IInventory par2IInventory, int par3, int par4, int par5) { super(par2IInventory, par3, par4, par5); this.thePlayer = par1EntityPlayer; } /** * Check if the stack is a valid item for this slot. Always true beside for the armor slots. */ public boolean isItemValid(ItemStack par1ItemStack) { return false; } /** * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new * stack. */ public ItemStack decrStackSize(int par1) { if (this.getHasStack()) { this.field_75228_b += Math.min(par1, this.getStack().stackSize); } return super.decrStackSize(par1); } /** * Called when the player picks up an item from an inventory slot */ public void func_82870_a(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) { this.onCrafting(par2ItemStack); super.onPickupFromSlot(par1EntityPlayer, par2ItemStack); } /** * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an * internal count then calls onCrafting(item). */ protected void onCrafting(ItemStack par1ItemStack, int par2) { this.field_75228_b += par2; this.onCrafting(par1ItemStack); } /** * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. */ protected void onCrafting(ItemStack par1ItemStack) { par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.field_75228_b); if (!this.thePlayer.worldObj.isRemote) { int var2 = this.field_75228_b; float var3 = RecipesQuartzFurnace.smelting().getExperience(par1ItemStack.itemID); int var4; if (var3 == 0.0F) { var2 = 0; } else if (var3 < 1.0F) { var4 = MathHelper.floor_float((float)var2 * var3); if (var4 < MathHelper.ceiling_float_int((float)var2 * var3) && (float)Math.random() < (float)var2 * var3 - (float)var4) { ++var4; } var2 = var4; } while (var2 > 0) { var4 = EntityXPOrb.getXPSplit(var2); var2 -= var4; this.thePlayer.worldObj.spawnEntityInWorld(new EntityXPOrb(this.thePlayer.worldObj, this.thePlayer.posX, this.thePlayer.posY + 0.5D, this.thePlayer.posZ + 0.5D, var4)); } } this.field_75228_b = 0; } }
  3. !) I don't Use Modloader, but I use Forge 2) Your code is wrong: 3) When I place the Furnace, this is in the same position, always:
  4. I use Forge, I don't use ModLoader
  5. Great biomee!!
  6. The block doesn't get place where I want
  7. Help me please
  8. and TileEntityFurnace: package SecretMod.tilentity; import SecretMod.gui.RecipesQuartzFurnace; 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.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.src.ModLoader; import net.minecraft.tileentity.TileEntity; public class TileEntityQuartzFurnace extends TileEntity implements IInventory { private ItemStack goldItemStacks[]; /** The number of ticks that the furnace will keep burning */ public int goldBurnTime; private boolean isActive; /** * The number of ticks that a fresh copy of the currently-burning item would * keep the furnace burning for */ public int goldItemBurnTime; /** The number of ticks that the current item has been cooking for */ public int goldCookTime; public int front; public TileEntityQuartzFurnace() { goldItemStacks = new ItemStack[3]; goldBurnTime = 0; goldItemBurnTime = 0; goldCookTime = 0; } public void setFrontDirection(int f) { this.front = f; } public int getFrontDirection() { return this.front; } /** * Returns the number of slots in the inventory. */ public int getSizeInventory() { return goldItemStacks.length; } /** * Returns the stack in slot i */ public ItemStack getStackInSlot(int par1) { return goldItemStacks[par1]; } /** * Decrease the size of the stack in slot (first int arg) by the amount of * the second int arg. Returns the new stack. */ public ItemStack decrStackSize(int par1, int par2) { if (goldItemStacks[par1] != null) { if (goldItemStacks[par1].stackSize <= par2) { ItemStack itemstack = goldItemStacks[par1]; goldItemStacks[par1] = null; return itemstack; } ItemStack itemstack1 = goldItemStacks[par1].splitStack(par2); if (goldItemStacks[par1].stackSize == 0) { goldItemStacks[par1] = null; } return itemstack1; } 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 (goldItemStacks[par1] != null) { ItemStack itemstack = goldItemStacks[par1]; goldItemStacks[par1] = null; return itemstack; } 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) { goldItemStacks[par1] = par2ItemStack; if (par2ItemStack != null && par2ItemStack.stackSize > getInventoryStackLimit()) { par2ItemStack.stackSize = getInventoryStackLimit(); } } /** * Returns the name of the inventory. */ public String getInvName() { return "container.goldOven"; } /** * Reads a tile entity from NBT. */ public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items"); goldItemStacks = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.tagAt(i); byte byte0 = nbttagcompound.getByte("Slot"); if (byte0 >= 0 && byte0 < goldItemStacks.length) { goldItemStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound); } } front = par1NBTTagCompound.getInteger("FrontDirection"); goldBurnTime = par1NBTTagCompound.getShort("BurnTime"); goldCookTime = par1NBTTagCompound.getShort("CookTime"); goldItemBurnTime = getItemBurnTime(goldItemStacks[1]); } /** * Writes a tile entity to NBT. */ public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); par1NBTTagCompound.setInteger("FrontDirection", (int) front); par1NBTTagCompound.setShort("BurnTime", (short) goldBurnTime); par1NBTTagCompound.setShort("CookTime", (short) goldCookTime); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < goldItemStacks.length; i++) { if (goldItemStacks[i] != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setByte("Slot", (byte) i); goldItemStacks[i].writeToNBT(nbttagcompound); nbttaglist.appendTag(nbttagcompound); } } par1NBTTagCompound.setTag("Items", nbttaglist); } /** * 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; } /** * 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 (goldCookTime * par1) / 200; } /** * 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 (goldItemBurnTime == 0) { goldItemBurnTime = 200; } return (goldBurnTime * par1) / goldItemBurnTime; } /** * Returns true if the furnace is currently burning */ public boolean isBurning() { return goldBurnTime > 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.goldBurnTime > 0; boolean var2 = false; if (this.goldBurnTime > 0) { --this.goldBurnTime; } if (!this.worldObj.isRemote) { if (this.goldBurnTime == 0 && this.canSmelt()) { this.goldItemBurnTime = this.goldBurnTime = getItemBurnTime(this.goldItemStacks[1]); if (this.goldBurnTime > 0) { var2 = true; if (this.goldItemStacks[1] != null) { --this.goldItemStacks[1].stackSize; if (this.goldItemStacks[1].stackSize == 0) { Item var3 = this.goldItemStacks[1].getItem().getContainerItem(); this.goldItemStacks[1] = var3 == null ? null : new ItemStack(var3); } } } } if (this.isBurning() && this.canSmelt()) { ++this.goldCookTime; if (this.goldCookTime == 200) { this.goldCookTime = 0; this.smeltItem(); var2 = true; } } else { this.goldCookTime = 0; } if (var1 != this.goldBurnTime > 0) { var2 = true; this.validate(); } } boolean check = isActive; isActive = isBurning(); if (isActive != check) { this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } if (var2) { this.onInventoryChanged(); } } /** * Returns true if the furnace can smelt an item, i.e. has a source item, * destination stack isn't full, etc. */ private boolean canSmelt() { if (goldItemStacks[0] == null) { return false; } ItemStack itemstack = RecipesQuartzFurnace.smelting().getSmeltingResult(goldItemStacks[0].getItem().itemID); if (itemstack == null) { return false; } if (goldItemStacks[2] == null) { return true; } if (!goldItemStacks[2].isItemEqual(itemstack)) { return false; } if (goldItemStacks[2].stackSize < getInventoryStackLimit() && goldItemStacks[2].stackSize < goldItemStacks[2].getMaxStackSize()) { return true; } return goldItemStacks[2].stackSize < itemstack.getMaxStackSize(); } /** * Turn one item from the furnace source stack into the appropriate smelted * item in the furnace result stack */ public void smeltItem() { if (this.canSmelt()) { ItemStack var1 = RecipesQuartzFurnace.smelting().getSmeltingResult(this.goldItemStacks[0].getItem().itemID); if (this.goldItemStacks[2] == null) { this.goldItemStacks[2] = var1.copy(); } else if (this.goldItemStacks[2].itemID == var1.itemID) { ++this.goldItemStacks[2].stackSize; } --this.goldItemStacks[0].stackSize; if (this.goldItemStacks[0].stackSize == 0) { Item var2 = this.goldItemStacks[0].getItem().getContainerItem(); this.goldItemStacks[0] = var2 == null ? null : new ItemStack(var2); } } } /** * Return true if item is a fuel source (getItemBurnTime() > 0). */ public static boolean isItemFuel(ItemStack par0ItemStack) { return getItemBurnTime(par0ItemStack) > 0; } /** * Returns the number of ticks that the supplied fuel item will keep the * furnace burning, or 0 if the item isn't fuel */ public static int getItemBurnTime(ItemStack par1ItemStack) { if (par1ItemStack == null) { return 0; } int i = par1ItemStack.getItem().itemID; if (i < 256 && Block.blocksList[i].blockMaterial == Material.wood) { return 300; } if (i == Item.stick.itemID) { return 100; } if (i == Item.coal.itemID) { return 1600; } if (i == Item.bucketLava.itemID) { return 20000; } if (i == Block.sapling.blockID) { return 100; } if (i == Item.blazeRod.itemID) { return 2400; } else { return ModLoader.addAllFuel(par1ItemStack.itemID, par1ItemStack.getItemDamage()); } } /** * Do not make give this method the name canInteractWith because it clashes * with Container */ public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) { if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this) { return false; } return par1EntityPlayer.getDistanceSq((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D; } public void openChest() { } public void closeChest() { } public boolean isActive() { return this.isActive; } @Override public boolean isInvNameLocalized() { // TODO Auto-generated method stub return true; } @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { // TODO Auto-generated method stub return true; } }
  9. When I try to place my BlockFurnace the block is in a random position!! this is the code of QuartzFurnace: package SecretMod.blocks; import java.util.Random; 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.creativetab.CreativeTabs; 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.src.ModLoader; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import SecretMod.mod_SecretMod; import SecretMod.tilentity.TileEntityQuartzFurnace; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockQuartzFurnace extends BlockContainer { private Random quartzRand; @SideOnly(Side.CLIENT) private Icon QuartzIconTop; private Icon QuartzIconBottom; @SideOnly(Side.CLIENT) private Icon QuartzIconFront; private Icon QuartzIconSide; private Icon QuartzIconFrontActive; private boolean isActive = true; private static boolean keepFurnaceInventory; public BlockQuartzFurnace(int par1, boolean par2Boolean) { super(par1, Material.rock); this.setCreativeTab(CreativeTabs.tabBlock); quartzRand = new Random(); } public void onBlockAdded(World par1World, int par2, int par3, int par4) { super.onBlockAdded(par1World, par2, par3, par4); this.setDefaultDirection(par1World, par2, par3, par4); par1World.markBlockForUpdate(par2, par3, par4); } private void setDefaultDirection(World par1World, int x, int y, int z) { TileEntity blockEntity = par1World.getBlockTileEntity(x, y, z); if (par1World.isRemote) { return; } int i = par1World.getBlockId(x, y, z - 1); int j = par1World.getBlockId(x, y, z + 1); int k = par1World.getBlockId(x - 1, y, z); int l = par1World.getBlockId(x + 1, y, z); byte b0 = 3; if (Block.opaqueCubeLookup[i] && !Block.opaqueCubeLookup[j]) { b0 = 3; } if (Block.opaqueCubeLookup[j] && !Block.opaqueCubeLookup[i]) { b0 = 2; } if (Block.opaqueCubeLookup[k] && !Block.opaqueCubeLookup[l]) { b0 = 5; } if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[k]) { b0 = 4; } ((TileEntityQuartzFurnace) blockEntity).setFrontDirection(b0); } @Override public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EPlayer, int par6, float par7, float par8, float par9) { TileEntityQuartzFurnace tileentityrefiner = (TileEntityQuartzFurnace) par1World.getBlockTileEntity(par2, par3, par4); if (tileentityrefiner != null) { par5EPlayer.openGui(mod_SecretMod.instance, 0, par1World, par2, par3, par4); } return true; } public Icon getBlockTexture(IBlockAccess access, int x, int y, int z, int side) { int front = 0; TileEntity tile = ModLoader.getMinecraftInstance().getIntegratedServer().worldServers[0].getBlockTileEntity(x, y, z); if (tile != null) { front = ((TileEntityQuartzFurnace) tile).getFrontDirection(); } else { ModLoader.getMinecraftInstance().getIntegratedServer().worldServers[0].markBlockForUpdate(x, y, z); } switch (side) { case 0: return QuartzIconBottom; case 1: return QuartzIconTop; default: if (side == front) { return ((TileEntityQuartzFurnace) tile).isActive() ? QuartzIconFrontActive : QuartzIconFront; } else { return QuartzIconSide; } } } public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { if (!keepFurnaceInventory) { TileEntityQuartzFurnace Refiner = (TileEntityQuartzFurnace) par1World.getBlockTileEntity(par2, par3, par4); if (Refiner != null) { for (int i = 0; i < Refiner.getSizeInventory(); i++) { ItemStack IS = Refiner.getStackInSlot(i); if (IS != null) { float j = this.quartzRand.nextFloat() * 0.8F + 0.1F; float k = this.quartzRand.nextFloat() * 0.8F + 0.1F; float l = this.quartzRand.nextFloat() * 0.8F + 0.1F; while (IS.stackSize > 0) { int m = this.quartzRand.nextInt(21) + 10; if (m > IS.stackSize) { m = IS.stackSize; } IS.stackSize -= m; EntityItem n = new EntityItem(par1World, (double) ((float) par2 + j), (double) ((float) par3 + k), (double) ((float) par4 + l), new ItemStack(IS.itemID, m, IS.getItemDamage())); if (IS.hasTagCompound()) { n.getEntityItem().setTagCompound((NBTTagCompound) IS.getTagCompound().copy()); } float o = 0.05F; n.motionX = (double) ((float) this.quartzRand.nextGaussian() * o); n.motionZ = (double) ((float) this.quartzRand.nextGaussian() * o); n.motionY = (double) ((float) this.quartzRand.nextGaussian() * o); par1World.spawnEntityInWorld(n); } } } } } super.breakBlock(par1World, par2, par3, par4, par5, par6); } @SideOnly(Side.CLIENT) public Icon getIcon(int par1, int par2) { switch (par1) { case 0: return QuartzIconBottom; case 1: return QuartzIconTop; case 2: return QuartzIconSide; case 3: return QuartzIconFront; case 4: return QuartzIconSide; case 5: return QuartzIconSide; default: return QuartzIconSide; } } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { Object planetgeeks; this.QuartzIconSide = iconRegister.registerIcon("secretmod:quartzFurnace_side"); this.QuartzIconFront = iconRegister.registerIcon("secretmod:quartzFurnace_front_Idle"); this.QuartzIconFrontActive = iconRegister.registerIcon("secretmod:quartzFurnace_front_active"); this.QuartzIconBottom = iconRegister.registerIcon("secretmod:quartzFurnace_top"); this.QuartzIconTop = iconRegister.registerIcon("secretmod:quartzFurnace_top"); } @Override public TileEntity createNewTileEntity(World world) { return new TileEntityQuartzFurnace(); } } OnBlockAdded: public void onBlockAdded(World par1World, int par2, int par3, int par4) { super.onBlockAdded(par1World, par2, par3, par4); this.setDefaultDirection(par1World, par2, par3, par4); par1World.markBlockForUpdate(par2, par3, par4); } setDefaultDirection: private void setDefaultDirection(World par1World, int x, int y, int z) { TileEntity blockEntity = par1World.getBlockTileEntity(x, y, z); if (par1World.isRemote) { return; } int i = par1World.getBlockId(x, y, z - 1); int j = par1World.getBlockId(x, y, z + 1); int k = par1World.getBlockId(x - 1, y, z); int l = par1World.getBlockId(x + 1, y, z); byte b0 = 3; if (Block.opaqueCubeLookup[i] && !Block.opaqueCubeLookup[j]) { b0 = 3; } if (Block.opaqueCubeLookup[j] && !Block.opaqueCubeLookup[i]) { b0 = 2; } if (Block.opaqueCubeLookup[k] && !Block.opaqueCubeLookup[l]) { b0 = 5; } if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[k]) { b0 = 4; } ((TileEntityQuartzFurnace) blockEntity).setFrontDirection(b0); } PLEASE HEMP ME! THE FURNACE IS IN A RANDOM POSITION!! I NEED YOUR HELP
  10. this is for minecraft 1.6.X?
  11. how to make a configuration file (Block and Item ID)?! What is the code for this? please Reply to this post! Thank you!!
  12. what is the code to add new drops to vanilla mobs? package SecretMod.events; import SecretMod.mod_SecretMod; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.passive.EntitySheep; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.living.LivingDropsEvent; public class SheepMeatDrops { @ForgeSubscribe public void CustomDrops(LivingDropsEvent var1) { EntityLiving var2 = var1.entityLiving; if(var2 instanceof EntitySheep) { var2.dropItem(mod_SecretMod.SheepMeat, 1); } } } this is right??
  13. Gui: container: Slot: Block:
  14. please reply to this post!!!
  15. replace with this: [spoiler]package (modName).world; import java.util.Random; import (modName).mod_SecretMod; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenMinable; import cpw.mods.fml.common.IWorldGenerator; public class (ClassName) implements IWorldGenerator { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch(world.provider.dimensionId){ case -1: generateNether(world, random, chunkZ, chunkZ); break; case 0: generateSurface(world, random, chunkX*16, chunkZ*16); break; case 1: generateEnd(); break; } } private void generateEnd() { } private void generateSurface(World world, Random random, int chunkX, int chunkZ) { for (int i = 0; i < 9; i++){ int randPosX = chunkX + random.nextInt(16); int randPosZ = chunkZ + random.nextInt(16); int randPosY = 45 + random.nextInt(5); (new WorldGenMinable(mod_(ModName).(ORENAME).blockID, 9)).generate(world, random,randPosX, randPosY, randPosZ); } } private void generateNether(World world, Random random, int chunkX, int chunkZ) { for (int i = 0; i < 5; i++){ int randPosX = chunkX + random.nextInt(16); int randPosZ = chunkZ + random.nextInt(16); int randPosY = 60 + random.nextInt(10); (new WorldGenMinableNether(mod_(ModName).(BlockName).blockID,1, 4)).generate(world, random,randPosX, randPosY, randPosZ); } } } [/spoiler]
  16. hi Guys when i try placing the block to make it face West it faces East,Every other side works any ideas. thanks This is the code: PLEASE HELP ME!!!!!!

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.