use of com.almuradev.almura.feature.complex.item.almanac.network.ClientboundWorldPositionInformationPacket in project Almura by AlmuraDev.
the class FarmersAlmanacItem method onItemUse.
@SuppressWarnings("ConstantConditions")
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
final Player spongePlayer = (Player) player;
if (!spongePlayer.hasPermission("almura.item.farmers_almanac")) {
spongePlayer.sendMessage(Text.of("Access denied, missing permission: ", TextColors.AQUA, "almura.item.farmers_" + "almanac", TextColors.WHITE, "."));
return EnumActionResult.FAIL;
}
final Block block = world.getBlockState(pos).getBlock();
if (block instanceof BlockFarmland | block instanceof BlockCrops) {
final Biome biome = world.getBiome(pos);
final float biomeTemperature = biome.getTemperature(pos);
final float biomeRainfall = biome.getRainfall();
final int blockLight = world.getLightFor(EnumSkyBlock.BLOCK, pos);
final int skyLight = world.getLightFor(EnumSkyBlock.SKY, pos) - world.getSkylightSubtracted();
player.swingArm(hand);
network.sendTo(spongePlayer, new ClientboundWorldPositionInformationPacket(pos.getX(), pos.getY(), pos.getZ(), hitX, hitY, hitZ, biome.getRegistryName().toString(), biomeTemperature, biomeRainfall, blockLight, skyLight));
} else {
spongePlayer.sendMessage(Text.of("The ", TextColors.AQUA, "Farmer's Almanac", TextColors.WHITE, " can only be " + "used on crops or farmland."));
}
}
return EnumActionResult.PASS;
}
Aggregations