Added bat so players can use items in hand with the leash
Changed silence method so it works :toot:
This commit is contained in:
parent
c11755558e
commit
6712ad427b
@ -6,6 +6,25 @@ import java.util.HashMap;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityBat;
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityCreature;
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityEnderDragon;
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityHuman;
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityInsentient;
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityLiving;
|
||||||
|
import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
|
||||||
|
import net.minecraft.server.v1_8_R3.NBTTagCompound;
|
||||||
|
import net.minecraft.server.v1_8_R3.NavigationAbstract;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityHeadRotation;
|
||||||
|
import net.minecraft.server.v1_8_R3.PathfinderGoal;
|
||||||
|
import net.minecraft.server.v1_8_R3.PathfinderGoalLookAtPlayer;
|
||||||
|
import net.minecraft.server.v1_8_R3.PathfinderGoalMoveTowardsRestriction;
|
||||||
|
import net.minecraft.server.v1_8_R3.PathfinderGoalRandomLookaround;
|
||||||
|
import net.minecraft.server.v1_8_R3.PathfinderGoalSelector;
|
||||||
|
import net.minecraft.server.v1_8_R3.WorldServer;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -29,24 +48,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
|
|
||||||
import net.minecraft.server.v1_8_R3.EntityBat;
|
|
||||||
import net.minecraft.server.v1_8_R3.EntityCreature;
|
|
||||||
import net.minecraft.server.v1_8_R3.EntityEnderDragon;
|
|
||||||
import net.minecraft.server.v1_8_R3.EntityHuman;
|
|
||||||
import net.minecraft.server.v1_8_R3.EntityInsentient;
|
|
||||||
import net.minecraft.server.v1_8_R3.EntityLiving;
|
|
||||||
import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
|
|
||||||
import net.minecraft.server.v1_8_R3.NavigationAbstract;
|
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity;
|
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityHeadRotation;
|
|
||||||
import net.minecraft.server.v1_8_R3.PathfinderGoal;
|
|
||||||
import net.minecraft.server.v1_8_R3.PathfinderGoalLookAtPlayer;
|
|
||||||
import net.minecraft.server.v1_8_R3.PathfinderGoalMoveTowardsRestriction;
|
|
||||||
import net.minecraft.server.v1_8_R3.PathfinderGoalRandomLookaround;
|
|
||||||
import net.minecraft.server.v1_8_R3.PathfinderGoalSelector;
|
|
||||||
import net.minecraft.server.v1_8_R3.WorldServer;
|
|
||||||
|
|
||||||
public class UtilEnt
|
public class UtilEnt
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -67,7 +68,13 @@ public class UtilEnt
|
|||||||
|
|
||||||
public static void silence(Entity entity, boolean silence)
|
public static void silence(Entity entity, boolean silence)
|
||||||
{
|
{
|
||||||
((CraftEntity)entity).getHandle().setSilent(silence);
|
net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||||
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
|
nmsEntity.c(tag);
|
||||||
|
tag.setByte("Silent", (byte) 1);
|
||||||
|
nmsEntity.f(tag);
|
||||||
|
// Not working right now
|
||||||
|
//((CraftEntity)entity).getHandle().setSilent(silence);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ghost(Entity entity, boolean ghost, boolean invisible)
|
public static void ghost(Entity entity, boolean ghost, boolean invisible)
|
||||||
|
@ -3,7 +3,6 @@ package mineplex.core.gadget.gadgets.balloons;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Ageable;
|
import org.bukkit.entity.Ageable;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
@ -27,7 +26,7 @@ public class BalloonItem extends BalloonGadget
|
|||||||
Entity entity = player.getWorld().spawnEntity(player.getLocation(), _balloonType.getEntityType());
|
Entity entity = player.getWorld().spawnEntity(player.getLocation(), _balloonType.getEntityType());
|
||||||
if (_balloonType.isBaby() && entity instanceof Ageable)
|
if (_balloonType.isBaby() && entity instanceof Ageable)
|
||||||
((Ageable) entity).setBaby();
|
((Ageable) entity).setBaby();
|
||||||
((LivingEntity) entity).setLeashHolder(player);
|
//((LivingEntity) entity).setLeashHolder(player);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import java.util.Map;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Bat;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -76,6 +77,8 @@ public abstract class BalloonGadget extends Gadget
|
|||||||
UtilBalloons utilBalloons = PLAYER_BALLOONS.get(player.getUniqueId()).get(_balloon);
|
UtilBalloons utilBalloons = PLAYER_BALLOONS.get(player.getUniqueId()).get(_balloon);
|
||||||
Entity entity = utilBalloons.getBalloon();
|
Entity entity = utilBalloons.getBalloon();
|
||||||
entity.remove();
|
entity.remove();
|
||||||
|
Bat bat = utilBalloons.getBat();
|
||||||
|
bat.remove();
|
||||||
PLAYER_BALLOONS.get(player.getUniqueId()).remove(_balloon);
|
PLAYER_BALLOONS.get(player.getUniqueId()).remove(_balloon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
package mineplex.core.gadget.util;
|
package mineplex.core.gadget.util;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Bat;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilAlg;
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
|
||||||
public class UtilBalloons
|
public class UtilBalloons
|
||||||
@ -22,6 +27,7 @@ public class UtilBalloons
|
|||||||
private Vector _direction;
|
private Vector _direction;
|
||||||
private double _speed;
|
private double _speed;
|
||||||
private long _idleTime;
|
private long _idleTime;
|
||||||
|
private Bat _bat;
|
||||||
|
|
||||||
public UtilBalloons(Player player, Entity balloon)
|
public UtilBalloons(Player player, Entity balloon)
|
||||||
{
|
{
|
||||||
@ -32,10 +38,17 @@ public class UtilBalloons
|
|||||||
_speed = 0.2;
|
_speed = 0.2;
|
||||||
_idleTime = 0;
|
_idleTime = 0;
|
||||||
_direction = new Vector(1, 0, 0);
|
_direction = new Vector(1, 0, 0);
|
||||||
|
_bat = player.getWorld().spawn(player.getLocation(), Bat.class);
|
||||||
|
_bat.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false, false));
|
||||||
|
((LivingEntity) balloon).setLeashHolder(_bat);
|
||||||
|
UtilEnt.silence(_bat, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update()
|
public void update()
|
||||||
{
|
{
|
||||||
|
// Update bat
|
||||||
|
_bat.teleport(_player.getLocation());
|
||||||
|
|
||||||
//Update Target
|
//Update Target
|
||||||
if (UtilMath.offset(_player.getEyeLocation(), _target) > 3 || UtilMath.offset(_balloonLoc, _target) < 1)
|
if (UtilMath.offset(_player.getEyeLocation(), _target) > 3 || UtilMath.offset(_balloonLoc, _target) < 1)
|
||||||
_target = getNewTarget();
|
_target = getNewTarget();
|
||||||
@ -88,4 +101,9 @@ public class UtilBalloons
|
|||||||
return _balloon;
|
return _balloon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Bat getBat()
|
||||||
|
{
|
||||||
|
return _bat;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user