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.

Alanzote

Forge Modder
  • Joined

  • Last visited

Everything posted by Alanzote

  1. Lol, I din't noticed... Fixed! Thanks!
  2. Can you give me a little example? For learning how to handle events (this is worth learning as it is a powerful modding approach) I have a tutorial here: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html For the random part, that is just Java. Always remember that in Minecraft modding that you can do anything that Java can do. For example, Java has the Random class: http://docs.oracle.com/javase/7/docs/api/java/util/Random.html Use the random class to generate a number, use an if statement to compare that number to some chance, and if the chance happens play the sound. Note that the client tick handler is fired 20 times per second. So if you want 6 minutes on average between playing the sound, you need the chance to play to be less than 1/3600. I am getting an Error in My Event Class: My EventClass:
  3. Can you give me a little example?
  4. Ok, I got how to play the sound! It Works! Now I just need like a random event, you know, minecraft music random plays, something like that.
  5. In forge is there a way to add Background Music? Like "Calm 1" sound in Minecraft?
  6. Sorry, it was a Stupid Error! =( I forgot to make if(slots[0] !=null) so then CRASH, but now worked, I used setMaxDamage(int); on the Item and it worked, perfectly! Now just need the "slow down" on the power adding(means that when I add power it will slowly add, not add in one single tick)
  7. RESULT: Without ToolMaterial the game Crashes before Mojang Logo
  8. Just Inclrease/decreate what? That's True I don't need to Use ToolMaterial Fort that... Trying with "setMaxDamage"
  9. I just want to slow down the power add, the ToolMaterial works for every block that needs power, but if I use as a normal variable, I can't change it using a TileEntity, that's why a ToolMaterial, also, I don't need to save things into NBTTAG, the game saves auto then.
  10. Got It in a Very Very Very Stupid Way! I made the Item as a pickaxe and I used ToolMaterial in it adding Durability as Power, and when you add the Item to the GUI I made, it uses slot[0].setItemDamage(slot[0].getItemDamage() + 10) so it damages the item trought time it is there and add power, when the Item has no Durability it won't add. So, latest problem is: How can I slow down The For?! For Code: if(ItemStack.areItemStacksEqual(slots[0], new ItemStack(ITEM))) { if(slots[0].getItemDamage() >= slots[0].getMaxDamage()) { } else { for(i=0;i<10000;i++){ power = power+1; slots[0].setItemDamage(slots[0].getItemDamage() + 1); } } How can I slow this down? Also, make the ToolMaterial worse than Gold and Wood, it does no damaged to blocks!
  11. My idea was using a Material for the Item - MaxDurability as the MaxPower - Durability as CurrentPower - but the way I found was: create 2 variables: MaxPower and Power both defined, then on getDurabilityBarForDisplay I divide them Power/MaxPower, it gives me what I want, but using another block, how can I change this variables?
  12. Allready checked! But they are [1.6.4] so It won't work on 1.7.10, also, I think I found a way...
  13. I know about that, I've also created a ToolMaterial, but I can't assign a material to a normal Item that has no "abilities"(Sword, Hoe, Pickaxe...) So How do I do that?
  14. Hello! I am making a technical mod, I know a lot in GUI, Models, Blocks, but I know a little bit in Items... =( And I want to make a Battery that shows a Durability Bar and this bar represents it's energy like this photo: http://vignette2.wikia.nocookie.net/mctechnicpack/images/6/6f/Powering_a_machine.png/revision/latest?cb=20120311220125[/img] and when I add the item to the GUI(Allready made) you see the bar depleting just like some technical mods.(Like it is damaging the Item) Thanks!
  15. Here is the NBT Saving and Writing COde: @Override public void readFromNBT(NBTTagCompound nbt){ super.readFromNBT(nbt); facingDirection = nbt.getInteger("facingDirection"); NBTTagList list = nbt.getTagList("Slots", 10); power = nbt.getFloat("POWER"); this.slots = new ItemStack[getSizeInventory()]; for(int i = 0; i < list.tagCount(); i++){ NBTTagCompound item = list.getCompoundTagAt(i); byte b = item.getByte("Item"); if(b >= 0 && b < this.slots.length){ this.slots[b] = ItemStack.loadItemStackFromNBT(item); } } if(nbt.hasKey("CustomName")){ this.setInventoryName(nbt.getString("CustomName")); } } @Override public void writeToNBT(NBTTagCompound nbt){ super.writeToNBT(nbt); nbt.setFloat("POWER", power); nbt.setInteger("facingDirection", facingDirection); NBTTagList list = new NBTTagList(); for(int i = 0; i < this.slots.length; i++) { if(this.slots[i] != null){ NBTTagCompound item = new NBTTagCompound(); item.setByte("item", (byte)i); this.slots[i].writeToNBT(item); list.appendTag(item); } } nbt.setTag("Slots", list); if(this.hasCustomInventoryName()){ nbt.setString("CustomName", this.getInventoryName()); } }
  16. Changing nbt.GetInteger to nbt.getFloat didn't work!
  17. I am trying to save a float named "power": public float power; On WriteToNBT I use: super.writeToNBT(nbt) nbt.setFloat("POWER",power); On ReadFromNBT I use: super.readFromNBT(nbt) power = nbt.getInteger("POWER"); Using the Code: if(ItemStack.areItemStacksEqual(slots[0], new ItemStack(//Some Item here))) I check for an Item in Slot 0, and then I add the power. After world reloads the nbt looses the "POWER" float and every power that has been stored is deleted. Any Ideas? Thanks.
  18. I've tried finding ways to allways show an Item Durability Bar, but I can't find a function. Have any Ideas? Thanks
  19. LOL! I am so stupid. I've adjusted the value to 100 and the power bar filled up!
  20. I am making some kind of furnace, that uses power and has an output.
  21. I used array 0. It is not giving the power.
  22. I've tried accessing these arrays: 1 and 2. It is still now working.
  23. I used slots with the ID of the slot after it: slots[1] I got no error, but I am getting a minecraft crash Report, It's about the ticking: Thanks!
  24. Hi, sorry for the delay, I've been searching for a way to do this, I think I found it: public void updateEntity(){ if(ItemStack.areItemStacksEqual(new ItemStack(Item.Cobblestone), slots)) { power += 10; } else { } } I need to check the Item in slot, here is my ItemStack variable that stores the content: private ItemStack[] slots = new ItemStack[2]; but It says that I am using a wrong type of ItemStack in the 2Nd variable of the Content, here is all my TileEntity Code: package com.gpa.startrekmod.tileentities; import java.util.List; import com.gpa.startrekmod.blocks.STModBlocks; import com.gpa.startrekmod.items.STModItems; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; public class TileEntityReplicatorBlock extends TileEntity implements ISidedInventory { private ItemStack[] slots = new ItemStack[2]; private final String IventoryName = "Replicator"; private int facingDirection; public int maxPower = 100000; public float power; public void updateEntity(){ if(ItemStack.areItemStacksEqual(new ItemStack(STModItems.EnergyCell), slots)) { power += 10; } else { } if(power > maxPower) power = maxPower; } public int getPowerScaled(int scaled) { return (int) (this.power * scaled / this.maxPower); } @Override public void readFromNBT(NBTTagCompound nbt){ super.readFromNBT(nbt); facingDirection = nbt.getInteger("facingDirection"); NBTTagList list = nbt.getTagList("Slots", 10); this.slots = new ItemStack[getSizeInventory()]; for(int i = 0; i < list.tagCount(); i++){ NBTTagCompound item = list.getCompoundTagAt(i); byte b = item.getByte("Item"); if(b >= 0 && b < this.slots.length){ this.slots[b] = ItemStack.loadItemStackFromNBT(item); } } this.power = nbt.getInteger("REPPower"); if(nbt.hasKey("CustomName")){ this.setInventoryName(nbt.getString("CustomName")); } } @Override public void writeToNBT(NBTTagCompound nbt){ super.writeToNBT(nbt); nbt.setFloat("REPPower", this.power); nbt.setInteger("facingDirection", facingDirection); NBTTagList list = new NBTTagList(); for(int i = 0; i < this.slots.length; i++) { if(this.slots[i] != null){ NBTTagCompound item = new NBTTagCompound(); item.setByte("item", (byte)i); this.slots[i].writeToNBT(item); list.appendTag(item); } } nbt.setTag("Slots", list); if(this.hasCustomInventoryName()){ nbt.setString("CustomName", this.getInventoryName()); } } public int getSizeInventory() { return this.slots.length; } public ItemStack getStackInSlot(int i) { return this.slots[i]; } public ItemStack decrStackSize(int i, int j) { if(this.slots[i] != null) { ItemStack itemstack; if(this.slots[i].stackSize <= j) { itemstack = this.slots[i]; this.slots[i] = null; return itemstack; }else{ itemstack = this.slots[i].splitStack(j); if(this.slots[i].stackSize == 0) { this.slots[i] = null; } return itemstack; } } return null; } public ItemStack getStackInSlotOnClosing(int i) { if(this.slots[i] != null) { ItemStack itemstack = this.slots[i]; this.slots[i] = null; return itemstack; } return null; } public void setInventorySlotContents(int i, ItemStack itemstack) { this.slots[i] = itemstack; if(itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()){ itemstack.stackSize = this.getInventoryStackLimit(); } } public String getInventoryName() { return null; } public void setInventoryName() { } public boolean hasCustomInventoryName() { return false; } public int getInventoryStackLimit() { return 64; } public void setInventoryName(String string){ } public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { return false; } public void openInventory() { } public void closeInventory() { } public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { return false; } public int[] getAccessibleSlotsFromSide(int p_94128_1_) { return null; } public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { return false; } public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { return false; } @Override public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); this.writeToNBT(tag); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag); } } For some reason the spoiler tab is not working. Thanks.

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.