Jump to content

Elyon

Members
  • Posts

    270
  • Joined

  • Last visited

Everything posted by Elyon

  1. Yeah ... that is pretty weird alright.
  2. Why not look in BlockPortal.java? Alternatively/additionally, you can inherit from BlockPortal and just override the code you need to.
  3. If you are developing for 1.7.2+, I believe you should use @SubscribeEvent instead of @ForgeSubscribe.
  4. I don't know. Toy around with GL11.glScalef , maybe? Remember to GL11.push - and GL11.popMatrix .
  5. Hint: You can use [ code ] tags for short snippets of code, or paste as a gist for syntax highlighting and line numbers Random rnd = new Random(); // Make this a private field and only initialise it once, instead. int num = rnd.nextInt(5); // Put the switch below in a private method, and call that instead. switch (num) { case 0: world.setBlock(x, y+1, z, this, 0, 3); break; case 1: world.setBlock(x, y, z+1, this, 0, 3); break; case 2: world.setBlock(x, y, z-1, this, 0, 3); break; case 3: world.setBlock(x+1, y, z, this, 0, 3); break; case 4: world.setBlock(x-1, y, z, this, 0, 3); break; } num2 = rnd.nextInt(4); if (num2 >= num) { ++num2; } // Call the private method you called above. Random#nextInt(n) returns an integer between 0 and n, not including n. In your code, you first check if num == 0 . Even if it is, you still check if it is 1 , 2 and so on. You also instantiate not one, but two instances of Random(). You can simply instantiate the random once, perhaps in your constructor, and then use that same random continuously. You have a while-loop that is not guaranteed to ever terminate. Of course, it mostly will - but it could run anywhere from 0 to infinity times, if you're unlucky. Simply decrease the number of possible outcomes of the random number, and increment the outcome if it is the same or larger than the actual number you want to exclude as an option. If you're into Big O notation, this changes the complexity of your code from O(∞) to O(1), assuming the Random#nextInt call is O(1) still. Either way, the code above should be both more concise, more maintainable and more performant - especially if you follow the hints I have given you in the comments of the code. Enjoy
  6. Hint: You can use [ code ] tags inside [ spoiler ] tags, or you can paste as a gist for syntax highlight and line numbers I am not sure why you call getBlockLightValue and getBlockLightOpacity with the same coordinates every time. Assuming you want to call it on the block you are spreading to, and assuming you only want one such conversion per random tick, this would be a way to do it more concisely: for (int i = x-1; i <= x+1; ++i) { for (int j = z-1; j <= z+1; ++j) { if (world.getBlock(i, y, j) == Blocks.grass && world.getBlockLightValue(i, y, j) >= 4 && world.getBlockLightOpacity(i, y, j) <= 2) { world.setBlock(i, y, j, Blocks.glass); } } } Keep in mind that this converts horisontally exclusively.
  7. I think you are adding identical models into your models in the setLivingAnimations() . You are supposed to initialise your model geometry in the constructor, and just change rotation points and angles in setLivingAnimations . Essentially, you are adding geometry every animation frame rather than manipulating what you already have. Have a look at how ModelHorse does it; a relatively complicated model and animation set, yet no performance issues around it.
  8. Elyon

    -

    Oh, has @SideOnly been deprecated in favour of World#isRemote? I wish I had known ...
  9. renderWorldBlock is cached. I used a TileEntitySpecialRenderer instead, which solved all but the lighting issues.
  10. That is correct.
  11. Forge gives you a previously unassigned ID, now in 1.7.2+. As larsgerrits stated, you don't have to worry about IDs.
  12. Move the setBlockMetadataWithNotify call into the if-block, or alternatively make metaToBe a method-local scope variable.
  13. Do you have a model handy?
  14. The code I pasted is fixed, apart from random:fizz -> random.fizz .
  15. Use [ code ] tags for short snippets of code, please - like so: @Override public boolean onBlockActivated(World world, int parX, int parY, int parZ, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { ItemStack stack = player.inventory.getCurrentItem(); if(stack != null && stack.getItem() == Items.slime_ball) { metaToBe = 1; world.playSoundAtEntity(player, "random:fizz", 0.7F, 0.8F); } world.setBlockMetadataWithNotify(parX, parY, parZ, metaToBe, 3); return false; }
  16. Elyon

    -

    A bit, but these forums are exclusively English, I believe. @SideOnly(Side.CLIENT) public boolean onBlockActivated(World w, int i, int j, int k, EntityPlayer player, int l, float m, float n, float o) { TD_TileEntity_SpeedFurnace tileentityfurnace = (TD_TileEntity_SpeedFurnace)w.getTileEntity(i, j, k); if (tileentityfurnace != null) { player.openGui(Main.instance, 1, w, i, j, k); } return true; }
  17. Elyon

    -

    From the Wikipedia article on Tautology (logic): The statement is always true. Have a look at the argument forms of Propositional logic. It will help immensely when using boolean statements in the future, as well as in general. Besides, don't you want to open the GUI specifically when the world is remote, ie. when the code is run on the client?
  18. Elyon

    -

    @SideOnly(Side.CLIENT) means w.isRemote is a tautology.
  19. None of those method calls should change anything around spawn, and they definitely shouldn't obliterate it. I am interested: How did it obliterate the area? What was the effect? Can you reproduce this effect?
  20. Have a go at 1.7.2, and post some code that doesn't work as you expect it to - preferably with an error log.
  21. Why not give it a go, or read through some vanilla code to see if it will? If it doesn't equip the armour itself, you'll just have to add that functionality
  22. 1.7.2 is not only supported, it is recommended.
  23. While Java does pass-by-reference, this is not true for primitive types such as ints. What you are essentially doing here is this: Store the food's max item use duration in local variable i Subtract 16 from i Discard the results and carry on I recommend looking into Scope of variables. You will need to make a new class for your food items, inheriting from ItemFood and making sure to @Override getMaxItemUseDuration to make it return something specific based on what armour the consumer is wearing.
  24. What about your code does not seem to be working? Are you getting any errors, or is it simply not generating the structures and everything else you have added works well?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.