use of org.orecruncher.dsurround.network.PacketEnvironment in project DynamicSurroundings by OreCruncher.
the class EnvironmentService method tickEvent.
@SubscribeEvent
public void tickEvent(@Nonnull final TickEvent.PlayerTickEvent event) {
if (event.phase == Phase.END && event.side == Side.SERVER) {
final EntityPlayer player = event.player;
final VillageCollection villageCollection = player.getEntityWorld().getVillageCollection();
boolean inVillage = false;
final List<Village> villages = villageCollection.getVillageList();
if (villages.size() > 0) {
final BlockPos pos = player.getPosition();
for (final Village v : villages) if (v.isBlockPosWithinSqVillageRadius(pos)) {
inVillage = true;
break;
}
}
final PacketEnvironment packet = new PacketEnvironment(inVillage);
Network.sendToPlayer((EntityPlayerMP) player, packet);
}
}
Aggregations