Jump to content

FiveShipHUN

Members
  • Posts

    2
  • Joined

  • Last visited

FiveShipHUN's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  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
×
×
  • Create New...

Important Information

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