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.

Raizunne

Members
  • Joined

  • Last visited

Everything posted by Raizunne

  1. Yup just looked at that and it works but when I try to check if the world is not remote the code is not executed, dont really know why. Here's what I'm trying to do: public void breakThisBlock(Block block, World world, int x, int y, int z){ Random random = new Random(); int r = random.nextInt(1); if(block instanceof IPlantable && r==0){ if(!world.isRemote){ world.func_147480_a(x, y-1, z, true); } } }
  2. Hi! Im trying to make an item that grows crops and breaks them. Im using the world.updateTick() and setting it to update the block when a random happens and another that breaks the block. But when I use it, nothing happens when calling if "!world.isRemote" and when I dont use that I get ghost blocks and items. This is probably a silly mistake but I tried fixing it for about 5 hours (with some additions here and there with the item ) Here's my code @Override public void onUsingTick(ItemStack itemstack, EntityPlayer player, int count) { super.onUsingTick(itemstack, player, count); Random random = new Random(); int number = random.nextInt(5); int x = (int)player.serverPosX; int y = (int)player.serverPosY; int z = (int)player.serverPosZ; Block block1 = player.worldObj.getBlock(x, y-1, z); Block block2 = player.worldObj.getBlock(x+1, y-1, z); Block block3 = player.worldObj.getBlock(x, y-1, z+1); Block block4 = player.worldObj.getBlock(x+1, y-1, z+1); Block block5 = player.worldObj.getBlock(x+1, y-1, z-1); Block block6 = player.worldObj.getBlock(x-1, y-1, z+1); Block block7 = player.worldObj.getBlock(x-1, y-1, z-1); Block block8 = player.worldObj.getBlock(x-1, y-1, z); Block block9 = player.worldObj.getBlock(x, y-1, z-1); switch(itemstack.stackTagCompound.getInteger("mode")){ case 0: updateThisBlock(block1, player.worldObj, x, y, z); updateThisBlock(block2, player.worldObj, x+1, y, z); updateThisBlock(block3, player.worldObj, x, y, z+1); updateThisBlock(block4, player.worldObj, x+1, y, z+1); updateThisBlock(block5, player.worldObj, x+1, y, z-1); updateThisBlock(block6, player.worldObj, x-1, y, z-1); updateThisBlock(block7, player.worldObj, x-1, y, z+1); updateThisBlock(block8, player.worldObj, x-1, y, z); updateThisBlock(block9, player.worldObj, x, y, z-1); break; case 1: breakThisBlock(block1, player.worldObj, x, y, z); breakThisBlock(block2, player.worldObj, x+1, y, z); breakThisBlock(block3, player.worldObj, x, y, z+1); breakThisBlock(block4, player.worldObj, x+1, y, z+1); breakThisBlock(block5, player.worldObj, x+1, y, z-1); breakThisBlock(block6, player.worldObj, x-1, y, z-1); breakThisBlock(block7, player.worldObj, x-1, y, z+1); breakThisBlock(block8, player.worldObj, x-1, y, z); breakThisBlock(block9, player.worldObj, x, y, z-1); } } public void updateThisBlock(Block block, World world, int x, int y, int z){ Random random = new Random(); int r = random.nextInt(4); if(block instanceof IPlantable && r == 3){ if(!world.isRemote){ System.out.println("Updated"); world.scheduleBlockUpdate(x, y-1, z, block, 20); block.updateTick(world, x, y-1, z, random); } } } public void breakThisBlock(Block block, World world, int x, int y, int z){ Random random = new Random(); int r = random.nextInt(1); List<ItemStack> items = new ArrayList(); if(block instanceof IPlantable && r==0){ items.addAll(block.getDrops(world, x, y-1, z, world.getBlockMetadata(x, y-1, z), 1)); if(!world.isRemote){ world.setBlockToAir(x, y-1, z); for(ItemStack stackerino : items){ world.spawnEntityInWorld(new EntityItem(world, x, y, z, stackerino)); } } } } Thanks in advance!
  3. Yup that worked! Thank you sir! I also had to make it so that it checked if the duration was 1 because 0 == deactivated so it was unreachable code. Here's the code for any future reference or anyone that would like it //FLIGHT POTION if(event.entity instanceof EntityPlayer){ EntityPlayer player = (EntityPlayer)event.entity; boolean world = event.entity.worldObj.isRemote; boolean flying = false; if(player.isPotionActive(Miscellany.flightPotion.getId())){ player.capabilities.allowFlying=true; flying=true; if(player.getActivePotionEffect(Miscellany.flightPotion).getDuration()==1){ player.capabilities.isFlying=false; player.capabilities.allowFlying=false; player.sendPlayerAbilities(); } } }
  4. Im making a flight potion (originality at its best), but when my potion effect ends, the player does not drop to the ground. Here's my potion event. //FLIGHT POTION if(event.entity instanceof EntityPlayer){ EntityPlayer player = (EntityPlayer)event.entity; boolean world = event.entity.worldObj.isRemote; if(player.isPotionActive(Miscellany.flightPotion.getId())){ player.capabilities.allowFlying=true; if(player.getActivePotionEffect(Miscellany.flightPotion).getDuration()<10){ player.capabilities.allowFlying=false; player.removePotionEffect(Miscellany.flightPotion.getId()); } } } What am I doing wrong? I have tried using !world.isRemote but no luck Thanks in advance!
  5. Try adding break; after each of the cases. No Java expert here but this has happened to me before
  6. Worked like a charm! Thank you very much sir! Also thanks for the tip on naming classes! Was used to naming with first lower and then upper case, dont know why
  7. I'm making a book for my mod. At first when you open the book you are presented with an index, after that another index with a more specific list of items or blocks. The problem is that when I click in one of the menus, it instantly clicks on the second menu that is on the same coordinate. Here's a gfy explaining my interface and my problem Basicly, what I want is index > subindex > item/block entry And its going index >item/block entry If my code for my GUI is needed, here it is:GitHub // Code is messy, just started getting into Java
  8. Hi! Im learning how to use forge, so my code will probably be very messy and overcomplicated. I have some problems and some questions: Displaying block texture in item form [sOLVED] In my GUI I have a crafting table that displays the items needed to craft an item. Some of the recepies need blocks and Im using itemRender.renderItemAndEffectIntoGUI but that needs an Item, so I cant use Blocks like Blocks.chest(?). What can I use to render a block in its item form inside a GUI? EDIT: Figured out! Had to change all of my Items into Itemstacks, form the start insted of calling them all Items form the start. renderToolTip rendering below everything else In my crafting GUI I have it so that when you mouse over the icon of an item it gives you its name in the form a of a tool tip like it would in your inventory, but when you mouse over it, the tooltip appears below the text and the icons, is there some way to change it to appear ontop? Here's an image of my GUI
  9. That did it! Thank you very much
  10. Im guessing it's because you are using the "msg.config_update.name" as a String
  11. Im trying to render vanilla items, in their 16x16 texture (which I guess its the problem, since its not 256x256(?)), is this possible or is there something easier to do to render items iniside a GUI? Im using: Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/items/bed.png")); drawTexturedModalRect(posX + 80, posY + 80, 0, 0, 16, 16); I can render easily from my mod's assets folder, but when it comes to using Minecraft's assets it just doesn't work Thanks in advance!

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.