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.

FiveShipHUN

Members
  • Joined

  • Last visited

  1. Thanks the help! Here's the code @Override public void onBlockPlacedBy(World world, BlockPos pos1, BlockState state, LivingEntity placer, ItemStack stack) { if (!world.isRemote()) { ServerWorld w = world.getServer().getWorld(placer.dimension); BlockPos pos2 = w.findNearestStructure("Village", pos1, 100, false); if (pos2 == null) { destroyIt(world, pos1, state, placer, stack); return; } double i = pos1.getX() - pos2.getX(); double j = pos1.getZ() - pos2.getZ(); double d = MathHelper.sqrt((float) (i * i + j * j)); if (d > 100) { destroyIt(world, pos1, state, placer, stack); return; } } } private void destroyIt(World world, BlockPos pos1, BlockState state, LivingEntity placer, ItemStack stack) { if(placer instanceof PlayerEntity) { world.destroyBlock(pos1, !((PlayerEntity) placer).isCreative()); ((PlayerEntity) placer) .sendMessage(new TranslationTextComponent("block.cae.colony_table.placedInWrongPlace")); } }
  2. I'd like to create a block which can be placed only in a village. Is there a way to find out whether the given coordinates/BlockPos is inside a village or not? This is my current code (not so much): @Override public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { if (!world.isRemote()) { } } (The uploaded file contains the code above.) EventSubscriber.java

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.