Make leashes not break (WITHOUT packets ;))
This commit is contained in:
parent
f25c592a6d
commit
cd70305afb
@ -1,6 +1,8 @@
|
||||
package mineplex.core.gadget.types;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -10,6 +12,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
@ -21,8 +24,11 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
public abstract class BalloonGadget extends Gadget
|
||||
{
|
||||
|
||||
private static final List<Entity> ENTITY_LIST = new ArrayList<>();
|
||||
private static final Map<UUID, Map<EntityType, UtilBalloons>> PLAYER_BALLOONS = new HashMap<>();
|
||||
|
||||
private Map<UUID, UtilBalloons> _playerBalloons = new HashMap<>();
|
||||
private List<Entity> _entities = new ArrayList<>();
|
||||
private EntityType _balloon;
|
||||
|
||||
public BalloonGadget(GadgetManager manager, String name, String[] desc, int cost, Material material, byte data, EntityType balloon, String... altNames)
|
||||
@ -117,4 +123,10 @@ public abstract class BalloonGadget extends Gadget
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,10 +38,7 @@ public class UtilBalloons
|
||||
_speed = 0.2;
|
||||
_idleTime = 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);
|
||||
spawnBat();
|
||||
}
|
||||
|
||||
public void update()
|
||||
@ -49,6 +46,9 @@ public class UtilBalloons
|
||||
// Update bat
|
||||
_bat.teleport(_player.getLocation());
|
||||
|
||||
if (((LivingEntity) _balloon).getLeashHolder() == null)
|
||||
((LivingEntity) _balloon).setLeashHolder(_bat);
|
||||
|
||||
//Update Target
|
||||
if (UtilMath.offset(_player.getEyeLocation(), _target) > 3 || UtilMath.offset(_balloonLoc, _target) < 1)
|
||||
_target = getNewTarget();
|
||||
@ -93,7 +93,7 @@ public class UtilBalloons
|
||||
|
||||
private Location getNewTarget()
|
||||
{
|
||||
return _player.getEyeLocation().add(Math.random() * 6 - 3, Math.random() * 10, Math.random() * 6 - 3);
|
||||
return _player.getEyeLocation().add(Math.random() * 6 - 3, Math.random() * 7.5, Math.random() * 6 - 3);
|
||||
}
|
||||
|
||||
public Entity getBalloon()
|
||||
@ -106,4 +106,13 @@ public class UtilBalloons
|
||||
return _bat;
|
||||
}
|
||||
|
||||
private void spawnBat()
|
||||
{
|
||||
_bat = _player.getWorld().spawn(_player.getLocation(), Bat.class);
|
||||
((LivingEntity) _balloon).setLeashHolder(_bat);
|
||||
_bat.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false, false));
|
||||
UtilEnt.silence(_bat, true);
|
||||
((LivingEntity) _balloon).setShouldBreakLeash(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user