Jump to content

shieldbug1

Forge Modder
  • Posts

    404
  • Joined

  • Last visited

Everything posted by shieldbug1

  1. And just a tip, instead of having all those if's in your update tick you could use for loops to make it look nicer (although it is completely optional) for(int i = -1; i < 2; i++) { for(int j = -1; j < 2; j++) { for(int k = -1; k < 2; k++) { if(world.getBlock(x+i, y+j, z+k) != Blocks.air || world.getBlock(x+i, y+j, z+k) != this) { world.setBlock(x+i, y+j, z+k, this); } } } } This is generally better practice than a large amount of if statements. Also the != this is there so it doesn't replace itself as that would be pointless.
  2. I'm not exactly sure what you want to do. From what I understood you want a function that checks if there are certain blocks in certain locations, and return if there isn't? If so your method should be a boolean rather than a void, and then return false if any block isn't what you want it to be, and then otherwise return true. Something like public boolean blockCheck(World world, int x, int y, int z) { if(world.getBlock(x,y,z) != Blocks.grass || world.getBlock(x + 15, y, z) != Blocks.grass || world.getBlock(x + 15, y, z + 12) != Blocks.grass || world.getBlock(x, y, z + 12) != Blocks.grass) { return false; } return true; }
  3. You need to override the method getItem(World world, int x, int y, int z) in your block class, I think.
  4. Create a class for your event handling, then register that class using MinecraftForge.EVENT_BUS.register(InstanceOfYourEventHandlerClass); In that class create a method like the one I posted earlier.
  5. I'm not sure what you mean exactly. Do you want your block to be completely unbreakable (like bedrock) unless someone uses your pickaxe, in which case it breaks normally? If so you can just not worry about setting the harvest level of the block, and use the BlockEvent.BreakEvent, check if the block that's being harvested is your block, check if the item that is being used is your pickaxe, and if not cancel the event. Something like @SubscribeEvent public void onBlockBroken(BlockEvent.BreakEvent event) { if(event.block instanceof YourBlockType && !(event.getPlayer().inventory.getCurrentItem().getItem() instanceof YourPickaxe) { event.setCancelled(true); } } EDIT: I forgot to mention, you'd also want to check that event.getPlayer().getCurrentItem() != null before calling geItem() because I believe if the player is using an empty hand getItem() on null throws a NPE.
  6. Is that code in the constructor? The way I did potion effects for players with blocks was using an event handler class and subscribing to LivingUpdateEvent (I think there might be a PlayerUpdateEvent but I'm not sure). Then make sure the entity from the event is an instance of EntityPlayer, and if so, check if any blocks nearby are the block you're looking for, then just apply the potion effect to the player. I'm pretty sure if all you want to do is add a potion effect then Events are the best way to handle it. Otherwise if you want to do more I think you can use the updateEntity method in a TileEntity.
  7. First of all, I'd like to apologise if this is the wrong place to post this and it's supposed to go in the ForgeGradle sub-forum instead, but the "NO SUPPORT REQUESTS" post kind of threw me off. Today I decided to get back into trying to mod after a while, and I saw all this new stuff. I read up on it, watched tutorials then attempted to do it myself. However, everytime I try to run "gradlew.bat setupDecompWorkspace", after a whole lot of dots it gives me this error: Now I've searched up this error as much as I could, and from what I've seen, it's usually caused by firewall or such. I've made sure that my firewall is down, and I can download the file that it attempts to download by itself through my browser (gradle-1.11-bin.zip). I've only found one other thread with this error to do with ForgeGradel somewhere on the minecraft forums, and that post was never resolved, and it wasn't of much help. I'm sure I'm probably making a really stupid mistake, but if you know how I can fix this, please let me know. Thanks.
  8. Simply use: Block.Whatever.BlockID Hope I helped~
×
×
  • Create New...

Important Information

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