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.

tiffit

Forge Modder
  • Joined

  • Last visited

Everything posted by tiffit

  1. I have programming experience, but adapting minecraft code is very hard. The log is hard cause its abstract and I have tried to change some stuff but it just ends up crashing when I go to my custom creative tab.
  2. Like I said, the code has changed quite some, mainly for the wood and leaf block class.
  3. Does anyone know of a good 1.7.2 tutorial on custom tree or anyone know how to make one. I DON'T want a 1.6.4 tutorial because the code has changed quite alot.
  4. Wow! That worked! Thanks!
  5. Oh ok, thanks! Can anyone show me where the source code download is for Trove? I can't find it. Thanks!
  6. mod author(s) for what mod? my mod? cause I am the author my my own mod.
  7. Here is my pizzaovenrecipies class because that seems to be where the problem is comming from
  8. Try scratchforfun: its for 1.6.2 but he also has an update video for it.
  9. So whenever I try building my mod using gradle this is what comes up:
  10. Yea, I'm looking for the same thing for my mod. Btw, I love your mod, Ive always used it!
  11. Blocks - .setBlockName("PutStuffHere") Items - .setUnlocalizedName("PutStuffHere");
  12. nope, no jumps, even highlighted each bracket to see which one is missplaced.
  13. Yea, its me again, and yea, I need help with the furnace again. Ok, so this time, the item won't smelt. When I put my fuel in in the fuel slot and whenI put what I want to smelt in my top slot, the furnace turns on (texture change, and fire in the gui starts working). But, the progress bar in the middle of the gui doesn't work, and the item in the top slot would just stay there, not going anywhere, not smelting, just sits there. Anyways, here is my code: Gui: package com.tiffit.MoFoodMod.PizzaOven; import org.lwjgl.opengl.GL11; import com.tiffit.MoFoodMod.lib.References; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.util.ResourceLocation; import net.minecraft.client.resources.I18n; public class GuiPizzaOven extends GuiContainer{ public static final ResourceLocation texture = new ResourceLocation("mofoodmod", "textures/gui/PizzaOven.png"); public TileEntityPizzaOven pizzaOven; public GuiPizzaOven(InventoryPlayer inventoryPlayer, TileEntityPizzaOven entity) { super(new ContainerPizzaOven(inventoryPlayer, entity)); this.pizzaOven = entity; this.xSize = 176; this.ySize = 166; } public void drawGuiForegroundLayer(int par1, int par2){ String name = this.pizzaOven.isInvNameLocalized() ? this.pizzaOven.getInvName() : I18n.format(this.pizzaOven.getInvName()); this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752); } protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { GL11.glColor4f(1F, 1F, 1F, 1F); Minecraft.getMinecraft().getTextureManager().bindTexture(texture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); if(this.pizzaOven.isBurning()){ int k = this.pizzaOven.getBurnTimeRemainingScaled(12); drawTexturedModalRect(guiLeft + 56, guiTop + 36 + 12 - k, 176, 12-k, 14, k + 2); } int k = this.pizzaOven.getCookProgressScaled(24); drawTexturedModalRect(guiLeft + 79, guiTop + 34, 176, 14, k + 1, 20); } } TileEntity package com.tiffit.MoFoodMod.PizzaOven; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import com.tiffit.MoFoodMod.ModBase; public class TileEntityPizzaOven extends TileEntity implements ISidedInventory{ private String localizedName; private static final int[] slots_top = new int[]{0}; private static final int[] slots_bottom = new int[]{2, 1}; private static final int[] slots_side = new int[]{1}; private ItemStack[] slots = new ItemStack[3]; public int furnaceSpeed = 50; public int burnTime; public int currentItemBurnTime; public int cookTime; public int getSizeInventory(){ return this.slots.length; } public String getInvName(){ return this.isInvNameLocalized() ? this.localizedName : "container.PizzaOven" ; } public boolean isInvNameLocalized(){ return this.localizedName != null && this.localizedName.length() > 0; } public void setGuiDisplayName(String displayName) { this.localizedName = displayName; } @Override public ItemStack getStackInSlot(int var1) { return this.slots[var1]; } @Override public ItemStack decrStackSize(int var1, int var2) { if(this.slots[var1] != null){ ItemStack itemstack; if(this.slots[var1].stackSize <= var2){ itemstack = this.slots[var1]; this.slots[var1] = null; return itemstack; }else{ itemstack = this.slots[var1].splitStack(var2); if(this.slots[var1].stackSize == 0){ this.slots[var1] = null; } return itemstack; } } return null; } @Override public ItemStack getStackInSlotOnClosing(int i) { if(this.slots[i] != null){ ItemStack itemstack = this.slots[i]; this.slots[i] = null; return itemstack; } return null; } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { this.slots[i] = itemstack; if(itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()){ itemstack.stackSize = this.getInventoryStackLimit(); } } @Override public String getInventoryName() { return "Pizza Oven"; } @Override public boolean hasCustomInventoryName() { return true; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer var1) { return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : var1.getDistanceSq((double)this.xCoord + 0.5D,(double) this.yCoord + 0.5D,(double) this.zCoord + 0.5D) <= 64.0D; } @Override public void openInventory() { } @Override public void closeInventory() { } public boolean isBurning(){ return this.burnTime > 0; } @Override public void updateEntity(){ boolean flag = this.burnTime > 0; boolean flag1 = false; if(isBurning()){ this.burnTime--; } if(!this.worldObj.isRemote){ if(this.burnTime == 0 && this.canSmelt()){ this.currentItemBurnTime = this.burnTime = getItemBurnTime(this.slots[1]); if(isBurning()){ flag1 = true; if(this.slots[1] != null){ this.slots[1].stackSize--; if(this.slots[1].stackSize == 0){ this.slots[1] = this.slots[1].getItem().getContainerItem(this.slots[1]); } } } if(this.isBurning() && this.canSmelt()){ this.cookTime++; if(this.cookTime == this.furnaceSpeed){ this.cookTime = 0; this.smeltItem(); flag1 = true; } }else{ this.cookTime = 0; } } if(flag != this.burnTime > 0){ flag1 = true; PizzaOven.updatePizzaOvenBlockState(this.burnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); } } if(flag1){ this.markDirty(); } } private void smeltItem() { if(this.canSmelt()){ ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.slots[0]); if(this.slots[2] == null){ this.slots[2] = itemstack.copy(); }else if(this.slots[2].isItemEqual(itemstack)){ this.slots[2].stackSize += itemstack.stackSize; } this.slots[0].stackSize--; if(this.slots[0].stackSize <= 0){ this.slots[0] = null; } } } private boolean canSmelt() { if(this.slots[0] == null){ return false; }else{ PizzaOvenRecipies.INSTANCE.addRecipe(new ItemStack(ModBase.TacoBeef), new ItemStack(ModBase.Bacon)); ItemStack itemstack = PizzaOvenRecipies.INSTANCE.findResult(this.slots[0]); if(itemstack == null) return false; if(this.slots[2] == null) return true; if(!this.slots[2].isItemEqual(itemstack)) return false; int result = this.slots[2].stackSize + itemstack.stackSize; return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); } } public static int getItemBurnTime(ItemStack itemstack){ if(itemstack == null){ return 0; }else{ Item item = itemstack.getItem(); if(itemstack.getItem() == Items.coal)return 50; return 0; } } public static boolean isItemFuel(ItemStack itemstack){ return getItemBurnTime (itemstack) > 0; } @Override public boolean isItemValidForSlot(int var1, ItemStack itemstack) { return var1 == 2 ? false :(var1 == 1 ? isItemFuel(itemstack): true); } @Override public int[] getAccessibleSlotsFromSide(int var1) { return var1 == 0 ? slots_bottom : (var1 == 1 ? slots_top : slots_side); } @Override public boolean canInsertItem(int i, ItemStack itemstack, int j) { return this.isItemValidForSlot(i, itemstack); } @Override public boolean canExtractItem(int i, ItemStack itemstack, int j) { return j != 0 || i != 1 || itemstack.getItem() == Items.bucket; } public int getBurnTimeRemainingScaled(int i) { if(this.currentItemBurnTime == 0){ this.currentItemBurnTime = this.furnaceSpeed; } return this.burnTime * i / this.currentItemBurnTime; } public int getCookProgressScaled(int i) { return this.cookTime * i / this.furnaceSpeed; } public void readFromNBT(NBTTagCompound nbt){ super.readFromNBT(nbt); NBTTagList list = nbt.getTagList("Items", 10); this.slots = new ItemStack[this.getSizeInventory()]; for(int i = 0; i < list.tagCount(); i++){ NBTTagCompound compound = list.getCompoundTagAt(i); byte b = compound.getByte("Slot"); if(b >= 0 && b < this.slots.length){ this.slots[b] = ItemStack.loadItemStackFromNBT(compound); } } this.burnTime = nbt.getShort("BurnTime"); this.cookTime = nbt.getShort("CookTime"); this.currentItemBurnTime = getItemBurnTime(this.slots[1]); if(nbt.hasKey("CustomName")){ this.localizedName= nbt.getString("CustomName"); } } public void writeToNBT(NBTTagCompound nbt){ super.writeToNBT(nbt); nbt.setShort("BurnTime", (short) this.burnTime); nbt.setShort("CookTime", (short) this.cookTime); NBTTagList list = new NBTTagList(); for(int i = 0; i < this.slots.length; i++){ if(this.slots[i] != null){ NBTTagCompound compound = new NBTTagCompound(); compound.setByte("Slot", (byte) i); this.slots[i].writeToNBT(compound); list.appendTag(compound); } } nbt.setTag("Items", list); if(this.isInvNameLocalized()){ nbt.setString("CustomName", this.localizedName); } } }
  14. Ok, thanks, I finally got it to work, you can close the topic now
  15. Locking it seems great
  16. I have read the whole thing many, many times, even fixed some errors, but still, I can't figure out how to put it in my tileentity class. Its kind of obvious how to add a new recipe tho, I got that.
  17. OH DERP! I forgot to set getInventoryStackLimit() to 64 instead of 0. Any moderator mind if they could remove this topic?
  18. Ok, so heres the problem, I have a custom furnace, and its pretty much finished, except there is one problem. The itemstack isn't working. So when I place an item in a slot in the furnace it duplicates. So then there is one item in the slot and one item my mouse is holding. Also, I cannot stack items. My TileEntityClass (You probably don't need this): package com.tiffit.MoFoodMod.PizzaOven; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.tileentity.TileEntity; public class TileEntityPizzaOven extends TileEntity implements ISidedInventory{ private String localizedName; private static final int[] slots_top = new int[]{0}; private static final int[] slots_bottom = new int[]{2, 1}; private static final int[] slots_side = new int[]{1}; private ItemStack[] slots = new ItemStack[3]; public int furnaceSpeed = 800; public int burnTime; public int currentItemBurnTime; public int cookTime; public int getSizeInventory(){ return this.slots.length; } public String getInvName(){ return this.isInvNameLocalized() ? this.localizedName : "container.PizzaOven" ; } public boolean isInvNameLocalized(){ return this.localizedName != null && this.localizedName.length() > 0; } public void setGuiDisplayName(String displayName) { this.localizedName = displayName; } @Override public ItemStack getStackInSlot(int var1) { return this.slots[var1]; } @Override public ItemStack decrStackSize(int var1, int var2) { if(this.slots[var1] != null){ ItemStack itemstack; if(this.slots[var1].stackSize <= var2){ itemstack = this.slots[var1]; this.slots[var1] = null; return itemstack; }else{ itemstack = this.slots[var1].splitStack(var2); if(this.slots[var1].stackSize == 0){ this.slots[var1] = null; } return itemstack; } } return null; } @Override public ItemStack getStackInSlotOnClosing(int i) { if(this.slots[i] != null){ ItemStack itemstack = this.slots[i]; this.slots[i] = null; return itemstack; } return null; } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { this.slots[i] = itemstack; if(itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()){ itemstack.stackSize = this.getInventoryStackLimit(); } } @Override public String getInventoryName() { return null; } @Override public boolean hasCustomInventoryName() { return false; } @Override public int getInventoryStackLimit() { return 0; } @Override public boolean isUseableByPlayer(EntityPlayer var1) { return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : var1.getDistanceSq((double)this.xCoord + 0.5D,(double) this.yCoord + 0.5D,(double) this.zCoord + 0.5D) <= 64.0D; } @Override public void openInventory() { } @Override public void closeInventory() { } public boolean isBurning(){ return this.burnTime > 0; } @Override public void updateEntity(){ boolean flag = this.burnTime > 0; boolean flag1 = false; if(isBurning()){ this.burnTime--; } if(!this.worldObj.isRemote){ if(this.burnTime == 0 && this.canSmelt()){ this.currentItemBurnTime = this.burnTime = getItemBurnTime(this.slots[1]); if(isBurning()){ flag1 = true; if(this.slots[1] != null){ this.slots[1].stackSize--; if(this.slots[1].stackSize == 0){ this.slots[1] = this.slots[1].getItem().getContainerItem(this.slots[1]); } } } if(this.isBurning() && this.canSmelt()){ this.cookTime++; if(this.cookTime == this.furnaceSpeed){ this.cookTime = 0; this.smeltItem(); flag1 = true; } }else{ this.cookTime = 0; } } if(flag != this.burnTime > 0){ flag1 = true; PizzaOven.updatePizzaOvenBlockState(this.burnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); } } if(flag1){ this.markDirty(); } } private void smeltItem() { if(this.canSmelt()){ ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.slots[0]); if(this.slots[2] == null){ this.slots[2] = itemstack.copy(); }else if(this.slots[2].isItemEqual(itemstack)){ this.slots[2].stackSize += itemstack.stackSize; } this.slots[0].stackSize--; if(this.slots[0].stackSize <= 0){ this.slots[0] = null; } } } private boolean canSmelt() { if(this.slots[0] == null){ return false; }else{ ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.slots[0]); if(itemstack == null) return false; if(this.slots[2] == null) return true; if(!this.slots[2].isItemEqual(itemstack)) return false; int result = this.slots[2].stackSize + itemstack.stackSize; return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); } } public static int getItemBurnTime(ItemStack itemstack){ if(itemstack == null){ return 0; }else{ Item item = itemstack.getItem(); if(itemstack.getItem() == Items.coal)return 400; return 0; } } public static boolean isItemFuel(ItemStack itemstack){ return getItemBurnTime (itemstack) > 0; } @Override public boolean isItemValidForSlot(int var1, ItemStack itemstack) { return var1 == 2 ? false :(var1 == 1 ? isItemFuel(itemstack): true); } @Override public int[] getAccessibleSlotsFromSide(int var1) { return var1 == 0 ? slots_bottom : (var1 == 1 ? slots_top : slots_side); } @Override public boolean canInsertItem(int i, ItemStack itemstack, int j) { return this.isItemValidForSlot(i, itemstack); } @Override public boolean canExtractItem(int i, ItemStack itemstack, int j) { return j != 0 || i != 1 || itemstack.getItem() == Items.bucket; } public int getBurnTimeRemainingScaled(int i) { if(this.currentItemBurnTime == 0){ this.currentItemBurnTime = this.furnaceSpeed; } return this.burnTime * i / this.currentItemBurnTime; } public int getCookProgressScaled(int i) { return this.cookTime * i / this.furnaceSpeed; } } My container class: package com.tiffit.MoFoodMod.PizzaOven; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.inventory.SlotFurnace; import net.minecraft.item.ItemStack; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class ContainerPizzaOven extends Container{ private TileEntityPizzaOven pizzaOven; public int lastBurnTime; public int lastItemBurnTime; public int lastCookTime; public ContainerPizzaOven(InventoryPlayer inventory, TileEntityPizzaOven tileentity){ this.pizzaOven = tileentity; this.addSlotToContainer(new Slot(tileentity, 0, 56, 17)); this.addSlotToContainer(new Slot(tileentity, 1, 56, 53)); this.addSlotToContainer(new SlotFurnace(inventory.player, tileentity, 2, 116, 35)); for(int i = 0; i < 3; i++){ for(int j = 0; j < 9; j++){ this.addSlotToContainer(new Slot(inventory, j + i*9 + 9, 8 + j*18, 84 + i*18)); } } for(int i = 0; i < 9; i++){ this.addSlotToContainer(new Slot (inventory, i, 8 + i*18, 142)); } } public void addCraftingToCrafters(ICrafting icrafting){ super.addCraftingToCrafters(icrafting); icrafting.sendProgressBarUpdate(this, 0, this.pizzaOven.cookTime); icrafting.sendProgressBarUpdate(this, 1, this.pizzaOven.burnTime); icrafting.sendProgressBarUpdate(this, 2, this.pizzaOven.currentItemBurnTime); } public void detectAndSendChanges(){ super.detectAndSendChanges(); } @SideOnly(Side.CLIENT) public void updateProgressBar(int slot, int newValue){ if(slot == 0)this.pizzaOven.cookTime = newValue; if(slot == 1)this.pizzaOven.burnTime = newValue; if(slot == 2)this.pizzaOven.currentItemBurnTime = newValue; } public ItemStack transferStackInSlot(EntityPlayer player, int slot){ return null; } public boolean canInteractWith(EntityPlayer var1) { return this.pizzaOven.isUseableByPlayer(var1); } }
  19. This is from the snowball class and might be what your looking for. Just put this in your class for the gun. You probably need to change this around because whenever you right click, the gun dissapears too. /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote) { par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer)); } return par1ItemStack; }
  20. OMG! Your the best! I thought you would just say "learn it yourself" or something, but no! You actually did it! +1 Karma Edit: What do I put in my TileEntity class? For the vanilla recipies I would put: ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.slots[0]);
  21. I know basic java, but im new to modding. You don't have to do this, but it would be great if you told my exactly what to do. If you don't want to, its ok, i'll keep trying to find out myself.
  22. Really, all you need is a HashMap<ItemStack,ItemStack>. Please, explain more. I know where the hash map thing is, but what do I do with it? Where do I put it (like do I create a method for it or add it to my mod base class)?
  23. Have you seen the mc code? its pretty hard to use and work with....
  24. That's exactly what I said, except I didn't include the manual on how to use your IDE. This is not a "How to use eclipse" forum. I know, but hey, why not?

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.