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.

Moritz

Forge Modder
  • Joined

  • Last visited

Everything posted by Moritz

  1. Sorry to say but you are wrong. I did find it out after 5 minutes i postet this question! Thanks to powercraft! the code is like this: public void updateEntity() { for(int i = 0; i < getSizeInventory; i++) { if(getStackInSlot(i) == null) { isEmpty = true; } else { isEmpty = false; } if (getStackInSlot(i).stackSize == Math.min(getInventoryStackLimit(), getStackInSlot(i).getMaxStackSize())) { isFull = true; } else { isFull = false; } } }
  2. I want to detect the stacksize in the inventory. But it will not work! file 242 lines (195 sloc) 5.142 kb EditRawBlameHistory 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 package speiger.src.tinychest.common.tileentity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; public abstract class TileEntityAdvancedTinyChest extends TileEntity implements IInventory { private String inventoryName; private ItemStack[] advTinyChest; private int facing = 0; private static boolean isFull = false; private static boolean isEmpty = true; private int maxstack = 0; private int stacksizes = 0; private int inventorymaxstack = 0; private int inventorystack = 64; public TileEntityAdvancedTinyChest(String name, int par1) { inventoryName = name; advTinyChest = new ItemStack[par1]; } public int getSizeInventory() { return this.advTinyChest.length; } public ItemStack getStackInSlot(int par1) { return this.advTinyChest[par1]; } public ItemStack decrStackSize(int par1, int par2) { if (this.advTinyChest[par1] != null) { ItemStack var3; if (this.advTinyChest[par1].stackSize <= par2) { var3 = this.advTinyChest[par1]; this.advTinyChest[par1] = null; return var3; } else { var3 = this.advTinyChest[par1].splitStack(par2); if (this.advTinyChest[par1].stackSize == 0) { this.advTinyChest[par1] = null; } return var3; } } else { return null; } } public ItemStack getStackInSlotOnClosing(int par1) { if (this.advTinyChest[par1] != null) { ItemStack var2 = this.advTinyChest[par1]; this.advTinyChest[par1] = null; return var2; } else { return null; } } public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { this.advTinyChest[par1] = par2ItemStack; if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) { par2ItemStack.stackSize = this.getInventoryStackLimit(); } } public String getInvName() { return inventoryName; } public int getInventoryStackLimit() { return 64; } public boolean isUseableByPlayer(EntityPlayer var1) { return true; } public void openChest() { } public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); this.advTinyChest = new ItemStack[this.getSizeInventory()]; for (int var3 = 0; var3 < var2.tagCount(); ++var3) { NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3); byte var5 = var4.getByte("Slot"); if (var5 >= 0 && var5 < this.advTinyChest.length) { this.advTinyChest[var5] = ItemStack.loadItemStackFromNBT(var4); } } facing = par1NBTTagCompound.getInteger("face"); } /** * Writes a tile entity to NBT. */ public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); par1NBTTagCompound.setInteger("face", facing); NBTTagList var2 = new NBTTagList(); for (int var3 = 0; var3 < this.advTinyChest.length; ++var3) { if (this.advTinyChest[var3] != null) { NBTTagCompound var4 = new NBTTagCompound(); var4.setByte("Slot", (byte)var3); this.advTinyChest[var3].writeToNBT(var4); var2.appendTag(var4); } } par1NBTTagCompound.setTag("Items", var2); } @Override public void updateEntity() { // the - 1 prevent it from crashing! for(int i = 0; i < getSizeInventory() - 1; i++) { maxstack += advTinyChest[i].getMaxStackSize(); stacksizes += advTinyChest[i].stackSize; inventorymaxstack += getInventoryStackLimit(); } if(maxstack == stacksizes || maxstack == inventorymaxstack) { isFull = true; } else if(maxstack == 0) { isFull = false; } else { isFull = false; } if(stacksizes == 0) { isEmpty = true; } else { isEmpty = false; } } public boolean isFull() { return isFull; } public boolean isEmpty() { return isEmpty; } public void closeChest() { } public void setFacing(int i) { facing = i; } public int getFacing() { return facing; } public void InventoryLimitUP(int i) { if(inventorystack > 64) { inventorystack = 64; } inventorystack += i; } public void InventoryLimitDown(int i) { if(inventorystack < 1) { inventorystack = 1; } inventorystack -= i; } }
  3. Hello. I did find out how to make the facing (thanks to cpws Iron chest and Ic2) But now I have the problem that the blocks does have all the same facing (when i place an other block all other Blocks faces to his side too) How can i fix this bug? Source Here: Block: file 239 lines (190 sloc) 5.642 kb EditRawBlameHistory 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 package speiger.src.tinychest.common.blocks; import java.util.List; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import speiger.src.api.common.addonslib.tinychest.TinyChestIDs; import speiger.src.tinychest.TinyChest; import speiger.src.tinychest.common.tileentity.TileEntityBasicTinyChest; import speiger.src.tinychest.common.tileentity.basic.*; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockTinyChest extends BlockContainer { private static TinyChestIDs tiny; public BlockTinyChest(int id) { super(id, Material.iron); this.setCreativeTab(TinyChest.tinyChest); } public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3) { par3.add(new ItemStack(par1, 1, 0)); par3.add(new ItemStack(par1, 1, 1)); par3.add(new ItemStack(par1, 1, 2)); par3.add(new ItemStack(par1, 1, 3)); par3.add(new ItemStack(par1, 1, 4)); par3.add(new ItemStack(par1, 1, 5)); par3.add(new ItemStack(par1, 1, 6)); par3.add(new ItemStack(par1, 1, 7)); par3.add(new ItemStack(par1, 1, ); } public int quantityDropped(Random par1Random) { return 1; } public int damageDropped(int par1) { return par1; } public int idDropped(int par1, Random par2Random, int par3) { return this.blockID; } public boolean onBlockActivated(World par1, int par2, int par3, int par4, EntityPlayer par5, int par6, float par7, float par8, float par9) { if(par5.isSneaking()) { return false; } if(!par1.isRemote) { int id = 0; int meta = par1.getBlockMetadata(par2, par3, par4); if(meta == 0) { id = tiny.tinychestguieins; } else if(meta == 1) { id = tiny.tinychestguizwei; } else if(meta == 2) { id = tiny.tinychestguidrei; } else if(meta == 3) { id = tiny.tinychestguivier; } else if(meta == 4) { id = tiny.tinychestguifunf; } else if(meta == 5) { id = tiny.tinychestguisechs; } else if(meta == 6) { id = tiny.tinychestguisieben; } else if(meta == 7) { id = tiny.tinychestguiacht; } else if(meta == { id = tiny.tinychestguineun; } TileEntityBasicTinyChest tile = (TileEntityBasicTinyChest)par1.getBlockTileEntity(par2, par3, par4); if(tile != null) { par5.openGui(TinyChest.instance, id, par1, par2, par3, par4); return true; } } return true; } @Override public boolean isOpaqueCube() { return false; } @Override public TileEntity createNewTileEntity(World var1) { return null; } @Override public TileEntity createNewTileEntity(World var1, int meta) { if(meta == 0) return new BasicTinyChestEins(); else if(meta == 1) return new BasicTinyChestZwei(); else if(meta == 2) return new BasicTinyChestDrei(); else if(meta == 3) return new BasicTinyChestVier(); else if(meta == 4) return new BasicTinyChestFunf(); else if(meta == 5) return new BasicTinyChestSechs(); else if(meta == 6) return new BasicTinyChestSieben(); else if(meta == 7) return new BasicTinyChestAcht(); else if(meta == return new BasicTinyChestNeun(); return null; } @SideOnly(Side.CLIENT) @Override public int getBlockTexture(IBlockAccess var1, int var2, int var3, int var4, int side) { int meta = var1.getBlockMetadata(var2, var3, var4); TileEntityBasicTinyChest tile = (TileEntityBasicTinyChest)var1.getBlockTileEntity(var2, var3, var4); if(side == tile.getFacing()) { if(meta == 0) return 1; else if(meta == 1) return 2; else if(meta == 2) return 3; else if(meta == 3) return 4; else if(meta == 4) return 5; else if(meta == 5) return 6; else if(meta == 6) return 7; else if(meta == 7) return 8; else if(meta == return 9; else return 0; } else if(side == 0 || side == 1) { return 0; } else { return 10; } } @Override public void onBlockPlacedBy(World var1, int var2, int var3, int var4, EntityLiving var5) { if (!var1.isRemote) { TileEntityBasicTinyChest var6 = (TileEntityBasicTinyChest)var1.getBlockTileEntity(var2, var3, var4); if (var5 == null) { var6.setFacing(2); } else { int var7 = MathHelper.floor_double((double)(var5.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; switch (var7) { case 0: var6.setFacing(2); break; case 1: var6.setFacing(5); break; case 2: var6.setFacing(3); break; case 3: var6.setFacing(4); } } } } } TileEntity: file 178 lines (137 sloc) 4.01 kb EditRawBlameHistory 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 package speiger.src.tinychest.common.tileentity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; public abstract class TileEntityBasicTinyChest extends TileEntity implements IInventory { private String InventoryName; private ItemStack[] TinyInventory; private static int face = 0; public TileEntityBasicTinyChest() { } public TileEntityBasicTinyChest(String par1, int par2) { InventoryName = par1; TinyInventory = new ItemStack[par2]; } public int getSizeInventory() { return this.TinyInventory.length; } public ItemStack getStackInSlot(int par1) { return this.TinyInventory[par1]; } public ItemStack decrStackSize(int par1, int par2) { if (this.TinyInventory[par1] != null) { ItemStack var3; if (this.TinyInventory[par1].stackSize <= par2) { var3 = this.TinyInventory[par1]; this.TinyInventory[par1] = null; return var3; } else { var3 = this.TinyInventory[par1].splitStack(par2); if (this.TinyInventory[par1].stackSize == 0) { this.TinyInventory[par1] = null; } return var3; } } else { return null; } } public ItemStack getStackInSlotOnClosing(int par1) { if (this.TinyInventory[par1] != null) { ItemStack var2 = this.TinyInventory[par1]; this.TinyInventory[par1] = null; return var2; } else { return null; } } public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { this.TinyInventory[par1] = par2ItemStack; if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) { par2ItemStack.stackSize = this.getInventoryStackLimit(); } } public String getInvName() { return InventoryName; } public int getInventoryStackLimit() { return 64; } public boolean isUseableByPlayer(EntityPlayer var1) { return true; } public void openChest() { } public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); this.TinyInventory = new ItemStack[this.getSizeInventory()]; for (int var3 = 0; var3 < var2.tagCount(); ++var3) { NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3); byte var5 = var4.getByte("Slot"); if (var5 >= 0 && var5 < this.TinyInventory.length) { this.TinyInventory[var5] = ItemStack.loadItemStackFromNBT(var4); } } face = par1NBTTagCompound.getInteger("face"); } /** * Writes a tile entity to NBT. */ public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); par1NBTTagCompound.setInteger("face", face); NBTTagList var2 = new NBTTagList(); for (int var3 = 0; var3 < this.TinyInventory.length; ++var3) { if (this.TinyInventory[var3] != null) { NBTTagCompound var4 = new NBTTagCompound(); var4.setByte("Slot", (byte)var3); this.TinyInventory[var3].writeToNBT(var4); var2.appendTag(var4); } } par1NBTTagCompound.setTag("Items", var2); } public void closeChest() { } public void setFacing(int i) { face = i; } public int getFacing() { return face; } }
  4. Nobody know how to make a redstone Signal?
  5. . I made whole Mod which is makeing a lots of repair/damage recipes. I used Forloops for this. like this: for(int i = 0; i < yourItem.getMaxItemDamage(); i++) { GameRegistry.addRecipe(new ItemStack(yourItem, 1, i - extradamage), new Object [] {"XY", 'X', new ItemStack(yourItem, 1, i), 'Y', new ItemStack(repairItem, 1, 0)}); } and the forloops was about 10k. And it was about 2,5mio recipes. and the game starts to lag.
  6. This was only my thinking in that time i wrote the answer i do not made these classes but maybe i make it like this concept.
  7. Also you can add more Damage when you make you own ItemStack i am working on something like that to make a decoblockmod working. When you craft something than you can use the addEnchantment() function. And with this way you can add your own damage.
  8. There Are Ways to extend The blockID but this is not easy and it could create a lot of lag when you are using the blocks. Look at Redpower. When you are using much covers and do not have a highspeedpc than the FPS goes down with a speed that is no longer funny! I do not say That Elorams Mod is not Awsome! Redpower 2 Is an Awsome mod but it Create a lot of lag. But i am amazed that she made over 1000 Blocks in more than 1 Block. But everything has his price!
  9. public Icon getIconFromDamage(ItemStack par1) { } With that you can make much Differend Icons. ^^ You do not need use damage for differend Icons you also can use internale integer or shorts. I hope that helps^^
  10. Thanks to the Iron Chest mod. Which show me indirektly how to make the facing! But i have to test it.^^ And my Redstone Problem is Still there and an answer or a tutorial how it works would be nice!
  11. private static void removeRecipe(ItemStack resultItem) { List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList(); for (int i = 0; i < recipes.size(); i++) { IRecipe tmpRecipe = recipes.get(i); if (tmpRecipe instanceof ShapedRecipes) { ShapedRecipes recipe = (ShapedRecipes)tmpRecipe; ItemStack recipeResult = recipe.getRecipeOutput(); if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) { recipes.remove(i--); } } } } i copied the it from TFC the code have to be inside your commonproxy and it have to look like this if you want to remove a recipe removeRecipe(new ItemStack(Block.blockGold, 1)); you have to make the output too! removeRecipe(new ItemStack(block, size, meta)); if the output is not the same as the in the recipe the function will not work!
  12. I know i asked for these Questions a week ago but i did not found a way to fix my Problems. Here i try to make a facing and failed! I had to choose the ic2 way (metadata about textures) the facing add a number and than the number says to the texture how it looks. The problem is i can not private it to a block. (block 1 = 2 have the same texture but differend facings) and my Block Metadata would be about 37 If i would use the normal way! Source of the Block with facing error: https://github.com/Speiger/DynamicTools/blob/master/spmod_common/speiger/src/tinychest/common/blocks/BlockTinyChest.java now to the redstone part. I do not get A redstone Signal! nothing and i do not know how it works. and there is no good tutorial there outside. Here the source with the meta block with my redstone problem: https://github.com/Speiger/DynamicTools/blob/master/spmod_common/speiger/src/tinychest/common/blocks/BlockAdvTinyChest.java I need help because i have no clue how to fix it. (and with redstone i have no clue what i am doing) and yes i read alot source and learning java but my time is limited and i do not understand every code from beginning. Thanks for reading. Speiger.
  13. Its not hard as you think. (I make the rightclick version. Its easier) public class ItemCharge extends Item { //Now the Constructure with maxDamage public ItemCharge(int id, int maxDamage) { super(id); setMaxDamage(maxdamage); } //Now the charging and discharging part! public ItemStack onItemRightClick(ItemStack par1, World par2, EntityPlayer par3) { if(!par3.isSneaking() && par1.getItemDamage() < par1.getMaxDamage()) { par1.damageItem(1, par3); } else { par1.damageItem(-1, par3); } } } now you have your chargeable version of an item. I hope it does help you. I have one more hint for you! Get Yourself opensource minecraft mods Be creative. And Learn Java!
  14. You made this: static Item youritem = new YourItem(id); but every block and item have to be like this: public static Item youritem = new YourItem(id); you forgot the public. that could be your problem^^ and if not i do not know what the problem could be.
  15. ok. But how can i detect the stacksize in a inventory? I mean is the stacksize greater than null or is the stacksize null or is the stacksize max? How can i detect that?
  16. Something what is not a normal kind of error. Something like that: BlockID = 0 BlockID <= -1 And some errors about my OneSlotTinyChest (Advanced) And he links to the (my link i postet) public void updateEntity() { if(worldObj.isRemote) { for(int i = 0; i < getSizeInventory(); i++) { if(advTinyChest.stackSize >= this.getInventoryStackLimit()) { isFull = true; } else if(advTinyChest.stackSize < this.getInventoryStackLimit() && advTinyChest.stackSize == advTinyChest.getMaxStackSize()) { isFull = true; } else { isFull = false; } if(advTinyChest == null) { isEmpty = true; } else { isEmpty = false; } } } } Please look into my source
  17. Hello I am working on my tiny Chest and now ill startet with my facing things. But i do not works. I have no clue how it works i just copied out of an other modsource (ic2) Can someone explain it to me? Everyone who want to read it here. https://github.com/Speiger/DynamicTools/blob/master/spmod_common/speiger/src/tinychest
  18. Hello. i have problems with detecting the stacksize. Everytime i start a world the game crashes (not internal server shut down) Here the source of the TileEntity https://github.com/Speiger/DynamicTools/blob/master/spmod_common/speiger/src/tinychest/common/tileentity/TileEntityAdvancedTinyChest.java
  19. ok. This is an answer that kinda help me. Thanks. I am still learning java.
  20. Explain me how it works because i do not understand the code!!!!!!!!!!
  21. Solved. I used The Dispenser to understand! This was easier as i thought. if you want to read the source here: https://github.com/Speiger/DynamicTools/tree/master/spmod_common/speiger/src
  22. I have IC2 Source, RedPower source and much more. They have redstone signals. i read it but i do not understand it!
  23. Hello. I am working on a mod which called Tiny Chest. So i did work on it but now i have problems i want to make the block to provide a redstone Signal. But i tried and fail every time. i have no clue how this works! Here is the Sourcecode of my mod (last update failed and the redstonecode is not online.): https://github.com/Speiger/DynamicTools/tree/master/spmod_common/speiger/src So my problem is how can i make a redstone Signal on a Specail Side?
  24. I try to make a transferIteminslot, But every time i try to make it the game crashes. Can someone explain me how that work.
  25. You did understand nothing. here my codeidea: private String dna = "null"; private String username = "null"; public ItemStack onRightClickItem(ItemStack par1, World par2, EntityPlayer par3) { if(username == "null") { username = par3.username; } return par1; } public void onUpdate(....boolean par5) { if(par5) { checkDNA(); } } public void checkDNA(); { if(dna == "null" && !username == "null") { if(username.startsWith("a") { // do stuff; } else { //dostuff } } }

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.