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.

knokko

Members
  • Joined

  • Last visited

Everything posted by knokko

  1. I haven't copied everything from you blindly, I have copied the things I thought I would need. I can't find wat that fracture exactly is, I don't know I need that or not. Why do you think I haven't all the methods that you have. I will go away thursday to another country where probably no free wifi is. That is why I want to know the answer, I am trying to access it from other classes without making the int static. But I can't figure out how.
  2. Mana is not static anymore, all errors are gone, markDirty() works succesfull now. But how can I edit the mana from other classes now? If I try it, eclipse says that I have to make mana static. So what have I to do now? here is the new class code: package enderpower.magic; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.WorldSavedData; public class Magic extends WorldSavedData{ private int mana; private static final String IDENTIFIER = "enderpower"; public Magic(String identifier) { super(identifier); } public Magic(){ super(IDENTIFIER); } @Override public void readFromNBT(NBTTagCompound nbt) { setMana(nbt.getInteger("mana")); } @Override public void writeToNBT(NBTTagCompound nbt) { nbt.setInteger("mana", getMana()); } public static Magic get(World world) { Magic data = (Magic)world.loadItemData(Magic.class, IDENTIFIER); if (data == null) { data = new Magic(); world.setItemData(IDENTIFIER, data); } return data; } public int getMana() { return this.mana; } public void setMana(int mana) { this.mana = mana; this.markDirty(); } }
  3. Than I think this must be getBlockName instead of getUnlocalizedName.
  4. I allways get errors if I write this.markDirty(); So where can I place it and what have I to do with the integer to let it all work? EDIT: If I place .markDirty() in setMana I get the error "Cannot make a static reference to the non-static method markDirty() from the type WorldSavedData" if I change the modifier of setMana to non static I get the error in an other class that says "Cannot make a static reference to the non-static method setMana(int) from the type Magic" and says I have to change the modifier of setMana to static. the class code: public class Magic extends WorldSavedData{ public static int mana; private static final String IDENTIFIER = "enderpower"; public Magic(String identifier) { super(identifier); } public Magic(){ super(IDENTIFIER); } @Override public void readFromNBT(NBTTagCompound nbt) { setMana(nbt.getInteger("mana")); } @Override public void writeToNBT(NBTTagCompound nbt) { nbt.setInteger("mana", getMana()); } public static Magic get(World world) { Magic data = (Magic)world.loadItemData(Magic.class, IDENTIFIER); if (data == null) { data = new Magic(); world.setItemData(IDENTIFIER, data); } return data; } public static int getMana() { return Magic.mana; } public void setMana(int mana) { Magic.mana = mana; this.markDirty(); } } here is the code in the class that tries to edit the mana: public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){ Magic.setMana(Magic.getMana() + 1); return true; } with the error "Cannot make a static reference to the non-static method setMana(int) from the type Magic" and the quick fix "change modifier of 'setMana() ' to 'static'." What can I do to let is save the mana and work correctly?
  5. I have searched on the web what static means. I dont see the problem with making it static, I want that everybody shares the mana so why shouldnt it be static? And I still dont understand how .markDirty() works.
  6. Techne is a good program for modeling, but my computer doesn't like it. So how did you model without techne?
  7. setUnlocalizedName is for items and setBlockName is for blocks. Maybe this is the big problem?
  8. I am wondering this to, but nobody had replied on the topic I have made a week ago :-(.
  9. I have made a setter and a getter, but eclipse said every time that mana must be static. And I dont understand how to use markDirty(); But this is the first time I am using worldsaveddata so dont be surprised I am doing something wrong. Here is the updates code: package enderpower.magic; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.WorldSavedData; public class Magic extends WorldSavedData{ private static int mana; private static final String IDENTIFIER = "enderpower"; public Magic(String identifier) { super(identifier); } public Magic(){ super(IDENTIFIER); } @Override public void readFromNBT(NBTTagCompound nbt) { setMana(nbt.getInteger("mana")); } @Override public void writeToNBT(NBTTagCompound nbt) { nbt.setInteger("mana", getMana()); } public static Magic get(World world) { Magic data = (Magic)world.loadItemData(Magic.class, IDENTIFIER); if (data == null) { data = new Magic(); world.setItemData(IDENTIFIER, data); } return data; } public static int getMana() { return Magic.mana; } public static void setMana(int mana) { Magic.mana = mana; } } Here is the way I am using my setter: It said I had to make everything static. public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){ Magic.setMana(Magic.getMana() + 1); return true; }
  10. Look in Referenced Libraries and forgeSRC to find the minecraft classes. Look in the package net.minecraft.block and copy the repeater class.
  11. I have tried the tutorial above but it doesn't save my mana at all. I havent written everything in the example because I want to only use 1 class for the mana, and I havent all the classes of diesieben. Here is the code, I think I only need the finishing touch now. package enderpower.magic; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.WorldSavedData; public class Magic extends WorldSavedData{ public static int mana; private static final String IDENTIFIER = "mana"; public Magic(String identifier) { super(identifier); } public Magic(){ super(IDENTIFIER); } @Override public void readFromNBT(NBTTagCompound nbt) { mana = nbt.getInteger("mana"); } @Override public void writeToNBT(NBTTagCompound nbt) { nbt.setInteger("mana", mana); } public static Magic get(World world) { Magic data = (Magic)world.loadItemData(Magic.class, IDENTIFIER); if (data == null) { data = new Magic(); world.setItemData(IDENTIFIER, data); } return data; } }
  12. I have googled to find how worldsaveddata works, but I didn't understand it. Can anybody explain it so I can understand it?
  13. hello guys, I have a problem with mana. I want to save the mana in the world so players will have to share it. But I just don't know how that works. I am going to make blocks that produce mana so this will work finer. Does anybody know how I can save mana in the world and not in players?
  14. hello people, I am trying to make a new mod that spawns blocks of my other mod in the world. But I cant use the blocks of my other mod. So only if the new mod is installed the blocks from the old mod generate in the world. But I have used gradlew build on my old mod and I put in in the mods folder in the new mod folder. But this let the game crash in eclipse. Does anybody know how this works?
  15. I need the class where you register your armor and the class where you register your armor and I need to know what exactly not works. Cant you wear the armor? Does the game crash?
  16. I looked in the grass code. And in my class I changed randomDisplayTick in updateTick and added needs random tick. Now every problem is just fixed.
  17. hello people, I have made a block with many bugs I don't understand. problem 1: If I restart minecraft, all the block changes to grass. problem 2: if I hit the block, the block gives the texture for grass for a half second. problem 3: If I am close enough, the block spreads as fast as I can run. But if I am further away, the block doesn't spread at all. problem 4: if an entity walks over the block, the wither effect doesnt work, it is a sort of corrupt. here is the class: package enderpower.Blocks; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import enderpower.lib.R; import enderpower.main.Enderpower; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class CursedGrass extends Block { @SideOnly(Side.CLIENT) private IIcon field_149991_b; @SideOnly(Side.CLIENT) private IIcon field_149993_M; @SideOnly(Side.CLIENT) private IIcon field_149994_N; @SideOnly(Side.CLIENT) public IIcon getIcon(int p_149691_1_, int p_149691_2_) { return p_149691_1_ == 1 ? this.field_149991_b : (p_149691_1_ == 0 ? Blocks.dirt.getBlockTextureFromSide(p_149691_1_) : this.blockIcon); } @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) { if (p_149673_5_ == 1) { return this.field_149991_b; } else if (p_149673_5_ == 0) { return Blocks.dirt.getBlockTextureFromSide(p_149673_5_); } else { Material material = p_149673_1_.getBlock(p_149673_2_, p_149673_3_ + 1, p_149673_4_).getMaterial(); return material != Material.snow && material != Material.craftedSnow ? this.blockIcon : this.field_149993_M; } } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister p_149651_1_) { this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); this.field_149991_b = p_149651_1_.registerIcon(this.getTextureName() + "_top"); this.field_149994_N = p_149651_1_.registerIcon(this.getTextureName() + "_side_overlay"); } protected CursedGrass() { super(Material.grass); } public void randomDisplayTick(World world, int x, int y, int z, Random random){ if(world.getBlock(x + 1, y, z) == Blocks.grass){ world.setBlock(x + 1, y, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y, z) == Blocks.grass){ world.setBlock(x - 1, y, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y, z + 1) == Blocks.grass){ world.setBlock(x + 1, y, z + 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y, z + 1) == Blocks.grass){ world.setBlock(x - 1, y, z + 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y, z - 1) == Blocks.grass){ world.setBlock(x + 1, y, z - 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y, z - 1) == Blocks.grass){ world.setBlock(x - 1, y, z - 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x, y + 1, z) == Blocks.grass){ world.setBlock(x, y + 1, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y + 1, z) == Blocks.grass){ world.setBlock(x + 1, y + 1, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y + 1, z) == Blocks.grass){ world.setBlock(x - 1, y + 1, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y + 1, z + 1) == Blocks.grass){ world.setBlock(x + 1, y + 1, z + 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y + 1, z + 1) == Blocks.grass){ world.setBlock(x - 1, y + 1, z + 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y + 1, z - 1) == Blocks.grass){ world.setBlock(x + 1, y + 1, z - 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y + 1, z - 1) == Blocks.grass){ world.setBlock(x - 1, y + 1, z - 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x, y - 1, z) == Blocks.grass){ world.setBlock(x, y - 1, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y - 1, z) == Blocks.grass){ world.setBlock(x + 1, y - 1, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y - 1, z) == Blocks.grass){ world.setBlock(x - 1, y - 1, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y - 1, z + 1) == Blocks.grass){ world.setBlock(x + 1, y - 1, z + 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y - 1, z + 1) == Blocks.grass){ world.setBlock(x - 1, y - 1, z + 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y - 1, z - 1) == Blocks.grass){ world.setBlock(x + 1, y - 1, z - 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y - 1, z - 1) == Blocks.grass){ world.setBlock(x - 1, y - 1, z - 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x, y + 1, z) == Blocks.tallgrass){ world.setBlock(x, y + 1, z, Blocks.air); } if(world.getBlock(x, y + 1, z) == Blocks.double_plant){ world.setBlock(x, y + 1, z, Blocks.air); } if(world.getBlock(x, y + 2, z) == Blocks.double_plant){ world.setBlock(x, y + 2, z, Blocks.air); } } @Override public void onEntityWalking(World world, int x, int y, int z, Entity entity){ ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(20, 400, 0, true)); System.out.println("anyone walked over the block"); } }
  18. I have found many other problems with the block. I am going to open an another topic about this block. The topic will be called "problems with cursed grass".
  19. I have pushed the entities over the block. But now I have found what goes wrong: every entity that walks over the block get the wither effect. But I have changed my gamemode to survival and I had the effect, but it didnt hurt me anyway, only my hearts were gray. And there weren't any particles on me to. Does anybody know why the wither effect doesn't hurt anyone.
  20. I have done what you have said. And I have used "system.out.printin(anyone walked over the block)" In the console appears everytime any entity walks over the block "anyone walked over the block." But only I get the wither effect. I have added the @Override annotation but there happens the same as before. I am going to look now how the wither gives potion effects to all entities. EDIT: it is now @Override public void onEntityWalking(World world, int x, int y, int z, Entity entity){ ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.wither.id, 20 * 20, 1)); System.out.println("anyone walked over the block"); } This is the stuff in the EntityWitherSkull class. But it still only works on me. please help.
  21. hello people, I have a different question this time. I was trying to make a block that gives entities the wither effect if they walk over the block. but only I get the wither effect if I walk over the block. Does anybody know why it doesnt work?
  22. In Minecraft forge for 1.7.2, the clientside must be the package where the class is + "." and than the class name. But I am not sure this works for you because you are in 1.7.10.
  23. Thank you all, I have used this tutorial and it automatically saves now.
  24. this is not NBT I think. this is written in my main file (Enderpower.class): public static int mana; in one of my wand files(BlastWand.class) is written : @Override public ItemStack onItemRightClick(ItemStack itemstack, World world,EntityPlayer player) { if(Enderpower.mana >= 99){ world.spawnEntityInWorld(new BlastBall(world, player)); Enderpower.mana = Enderpower.mana - 50; } return itemstack; } I hope you understand how it works now. I dont think this is saved in NBT.
  25. hello, I am trying to add mana(magic) to my mod. I have used "public static int mana" (without the quotes). I made a block that can show my mana without any problems. But if I restart minecraft in and outside eclipse, the mana is resetted to 0. Does anybody know why it resets after I restart minecraft?

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.