Everything posted by Alanzote
-
[RESOLVED][1.7.10] Background Music?
Lol, I din't noticed... Fixed! Thanks!
-
[RESOLVED][1.7.10] Background Music?
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:
-
[RESOLVED][1.7.10] Background Music?
Can you give me a little example?
-
[RESOLVED][1.7.10] Background Music?
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.
-
[RESOLVED][1.7.10] Background Music?
In forge is there a way to add Background Music? Like "Calm 1" sound in Minecraft?
-
[RESOLVED][1.7.10] How can I make a Battery Item Based In Durability?
Thanks For that! Worked!
-
[RESOLVED][1.7.10] How can I make a Battery Item Based In Durability?
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)
-
[RESOLVED][1.7.10] How can I make a Battery Item Based In Durability?
RESULT: Without ToolMaterial the game Crashes before Mojang Logo
-
[RESOLVED][1.7.10] How can I make a Battery Item Based In Durability?
Just Inclrease/decreate what? That's True I don't need to Use ToolMaterial Fort that... Trying with "setMaxDamage"
-
[RESOLVED][1.7.10] How can I make a Battery Item Based In Durability?
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.
-
[RESOLVED][1.7.10] How can I make a Battery Item Based In Durability?
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!
-
[RESOLVED][1.7.10] How can I make a Battery Item Based In Durability?
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?
-
[RESOLVED][1.7.10] How can I make a Battery Item Based In Durability?
Allready checked! But they are [1.6.4] so It won't work on 1.7.10, also, I think I found a way...
-
[RESOLVED][1.7.10] How can I make a Battery Item Based In Durability?
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?
-
[RESOLVED][1.7.10] How can I make a Battery Item Based In Durability?
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!
-
[1.7.10] NBT.setFloat and NBT.getFloat not working
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()); } }
-
[1.7.10] NBT.setFloat and NBT.getFloat not working
Changing nbt.GetInteger to nbt.getFloat didn't work!
-
[1.7.10] NBT.setFloat and NBT.getFloat not working
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.
-
[1.7.10] [Resolved] Show Item Durability Bar
I've tried finding ways to allways show an Item Durability Bar, but I can't find a function. Have any Ideas? Thanks
-
[1.7.10] [Resolved] How to check Item in Slot - TileEntity Interface
LOL! I am so stupid. I've adjusted the value to 100 and the power bar filled up!
-
[1.7.10] [Resolved] How to check Item in Slot - TileEntity Interface
I am making some kind of furnace, that uses power and has an output.
-
[1.7.10] [Resolved] How to check Item in Slot - TileEntity Interface
I used array 0. It is not giving the power.
-
[1.7.10] [Resolved] How to check Item in Slot - TileEntity Interface
I've tried accessing these arrays: 1 and 2. It is still now working.
-
[1.7.10] [Resolved] How to check Item in Slot - TileEntity Interface
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!
-
[1.7.10] [Resolved] How to check Item in Slot - TileEntity Interface
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.
IPS spam blocked by CleanTalk.