Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SubscribeEvent
- public void onPlayerInteract(PlayerInteractEvent event) {
- if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK
- && event.action != PlayerInteractEvent.Action.RIGHT_CLICK_AIR) {
- return;
- }
- Random rand = new Random();
- int x = event.x;
- int y = event.y;
- int z = event.z;
- MovingObjectPosition mop = MOPHelper.getMovingObjectPositionFromPlayer(event.world, event.entityPlayer, true);
- if (mop == null || mop.typeOfHit != MovingObjectType.BLOCK) {
- return;
- }
- else {
- x = mop.blockX;
- y = mop.blockY;
- z = mop.blockZ;
- String biome = event.world.getBiomeGenForCoords(x, z).biomeName;
- boolean isFluid = event.world.getBlock(x, y, z).getMaterial().isLiquid();
- if (event.world.getBlock(x, y, z) == Blocks.water) {
- if (event.entityPlayer.isSneaking() == true && isFluid == true) {
- if (event.entityPlayer.getCurrentEquippedItem() == null) {
- timer++;
- if (timer > 10) {
- timer = 0;
- //PLAYERCONTAINER IS NULL FOR SOME REASON
- PlayerContainer playerContainer = PlayerContainer.getPlayer(event.entityPlayer);
- // System.out.println(playerContainer);
- if (playerContainer != null) {
- // playerContainer.getStats().setStats(thirstToSet, playerContainer.getStats().thirstSaturation);
- // playerContainer.addStats(1, 1);
- }
- event.entityPlayer.swingItem();
- if (biome != "River") {
- event.entityPlayer.worldObj.playSoundAtEntity(event.entityPlayer, "random.drink", 0.75f, 1.5f);
- int randstore = rand.nextInt(100);
- if (randstore <= 20) {
- event.entityPlayer.addPotionEffect(new PotionEffect(Potion.weakness.id, 60 * 20, 0));
- event.entityPlayer.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 60 * 20, 0));
- event.entityPlayer.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 60 * 20, 0));
- }
- if (randstore == 0) {
- event.entityPlayer.attackEntityFrom(DamageThirst.generic, 1f);
- }
- } else if (biome == "River") {
- event.entityPlayer.worldObj.playSoundAtEntity(event.entityPlayer, "random.drink", 1f, 1.2f);
- }
- }
- }
- return;
- } else {
- return;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement