Fixed mounting blocks on yourself in 1.8

Added temp fix so 1.8 players can ride dragons again.
Removed Block form in parkour and fly for block form.
This commit is contained in:
Jonathan Williams 2014-10-01 02:12:11 -07:00
parent c2b84cc60f
commit 9b2a2cbbd6
7 changed files with 109 additions and 69 deletions

View File

@ -26,6 +26,7 @@ import net.minecraft.server.v1_7_R4.WatchableObject;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
@ -179,13 +180,15 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
if (attachPacket.c == owner.getEntityId())
{
packetInfo.setCancelled(true);
//verifier.bypassProcess(new PacketPlayOutEntityDestroy(attachPacket.b));
/*
System.out.println("Adding patch item.");
System.out.println("Yea, adding patch mount item.");
if (_entityMap.get(owner).containsKey(attachPacket.b))
{
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner).get(attachPacket.b)));
}
PacketPlayOutSpawnEntityLiving armorPacket = new PacketPlayOutSpawnEntityLiving();
armorPacket.a = _fakeIdCounter++;
armorPacket.b = (byte) EntityType.SLIME.getTypeId();
armorPacket.a = UtilEnt.getNewEntityId();
armorPacket.b = (byte) 30;
armorPacket.c = (int)EnumEntitySize.SIZE_2.a(100);
armorPacket.d = (int)MathHelper.floor(64 * 32.0D);
armorPacket.e = (int)EnumEntitySize.SIZE_2.a(100);
@ -257,16 +260,21 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
armorPacket.l = watcher;
verifier.bypassProcess(packet);
attachPacket.c = armorPacket.a;
// Spawn armor packet
verifier.bypassProcess(armorPacket);
PacketPlayOutAttachEntity attachPacket2 = new PacketPlayOutAttachEntity();
attachPacket2.c = owner.getEntityId();
attachPacket2.b = attachPacket.a;
attachPacket2.b = armorPacket.a;
attachPacket2.a = 0;
verifier.bypassProcess(packet);
*/
// Send armor attach to player.
verifier.bypassProcess(attachPacket2);
// Change original packet to attach to armor stand
attachPacket.c = armorPacket.a;
_entityMap.get(owner).put(attachPacket.b, armorPacket.a);
}
}
}

View File

@ -1,5 +1,8 @@
package mineplex.core.gadget.gadgets;
import java.util.ArrayList;
import java.util.List;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
@ -8,9 +11,11 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.disguises.DisguiseCat;
import mineplex.core.disguise.disguises.DisguiseChicken;
import mineplex.core.gadget.event.GadgetBlockEvent;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
@ -24,20 +29,17 @@ import org.bukkit.entity.Player;
public class BlockForm
{
public MorphBlock Host;
public Player Player;
private MorphBlock _host;
private Player _player;
private Material _mat;
private Block _block;
private Location _loc;
public BlockForm(MorphBlock host, Player player, Material mat)
{
Host = host;
Player = player;
_host = host;
_player = player;
_mat = mat;
_loc = player.getLocation();
@ -48,21 +50,21 @@ public class BlockForm
public void Apply()
{
//Remove Old
if (Player.getPassenger() != null)
if (_player.getPassenger() != null)
{
Recharge.Instance.useForce(Player, "PassengerChange", 100);
Recharge.Instance.useForce(_player, "PassengerChange", 100);
Player.getPassenger().remove();
Player.eject();
_player.getPassenger().remove();
_player.eject();
}
((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32));
((CraftEntity)_player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32));
//Player > Chicken
DisguiseChicken disguise = new DisguiseChicken(Player);
DisguiseChicken disguise = new DisguiseChicken(_player);
disguise.setBaby();
disguise.setSoundDisguise(new DisguiseCat(Player));
Host.Manager.getDisguiseManager().disguise(disguise);
disguise.setSoundDisguise(new DisguiseCat(_player));
_host.Manager.getDisguiseManager().disguise(disguise);
//Apply Falling Block
FallingBlockCheck();
@ -70,63 +72,70 @@ public class BlockForm
//Inform
String blockName = F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false));
if (!blockName.contains("Block"))
UtilPlayer.message(Player, F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false) + " Block") + "!"));
UtilPlayer.message(_player, F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false) + " Block") + "!"));
else
UtilPlayer.message(Player, F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false)) + "!"));
UtilPlayer.message(_player, F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false)) + "!"));
//Sound
Player.playSound(Player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f);
_player.playSound(_player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f);
}
public void Remove()
{
SolidifyRemove();
Host.Manager.getDisguiseManager().undisguise(Player);
_host.Manager.getDisguiseManager().undisguise(_player);
//Remove FB
if (Player.getPassenger() != null)
if (_player.getPassenger() != null)
{
Recharge.Instance.useForce(Player, "PassengerChange", 100);
Recharge.Instance.useForce(_player, "PassengerChange", 100);
Player.getPassenger().remove();
Player.eject();
_player.getPassenger().remove();
_player.eject();
}
((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0));
((CraftEntity)_player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0));
}
public void SolidifyUpdate()
{
if (!Player.isSprinting())
((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32));
if (!_player.isSprinting())
((CraftEntity)_player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32));
//Not a Block
if (_block == null)
{
//Moved
if (!_loc.getBlock().equals(Player.getLocation().getBlock()))
if (!_loc.getBlock().equals(_player.getLocation().getBlock()))
{
Player.setExp(0);
_loc = Player.getLocation();
_player.setExp(0);
_loc = _player.getLocation();
}
//Unmoved
else
{
double hideBoost = 0.025;
Player.setExp((float) Math.min(0.999f, Player.getExp() + hideBoost));
_player.setExp((float) Math.min(0.999f, _player.getExp() + hideBoost));
//Set Block
if (Player.getExp() >= 0.999f)
if (_player.getExp() >= 0.999f)
{
Block block = Player.getLocation().getBlock();
Block block = _player.getLocation().getBlock();
List<Block> blockList = new ArrayList<Block>();
blockList.add(block);
GadgetBlockEvent event = new GadgetBlockEvent(_host, blockList);
Bukkit.getServer().getPluginManager().callEvent(event);
//Not Able
if (block.getType() != Material.AIR || !UtilBlock.solid(block.getRelative(BlockFace.DOWN)))
if (block.getType() != Material.AIR || !UtilBlock.solid(block.getRelative(BlockFace.DOWN)) || event.getBlocks().isEmpty())
{
UtilPlayer.message(Player, F.main("Game", "You cannot become a Solid Block here."));
Player.setExp(0f);
UtilPlayer.message(_player, F.main("Game", "You cannot become a Solid Block here."));
_player.setExp(0f);
return;
}
@ -134,7 +143,7 @@ public class BlockForm
_block = block;
//Effect
Player.playEffect(Player.getLocation(), Effect.STEP_SOUND, _mat);
_player.playEffect(_player.getLocation(), Effect.STEP_SOUND, _mat);
//block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, _mat);
//Display
@ -144,7 +153,7 @@ public class BlockForm
//Host.Manager.GetCondition().Factory().Cloak("Disguised as Block", Player, Player, 60000, false, false);
//Sound
Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 2f);
_player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1f, 2f);
}
}
}
@ -152,7 +161,7 @@ public class BlockForm
else
{
//Moved
if (!_loc.getBlock().equals(Player.getLocation().getBlock()))
if (!_loc.getBlock().equals(_player.getLocation().getBlock()))
{
SolidifyRemove();
}
@ -172,12 +181,12 @@ public class BlockForm
_block = null;
}
Player.setExp(0f);
_player.setExp(0f);
//Host.Manager.GetCondition().EndCondition(Player, null, "Disguised as Block");
//Inform
Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 0.5f);
_player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1f, 0.5f);
FallingBlockCheck();
}
@ -189,20 +198,20 @@ public class BlockForm
return;
//Remove Old
if (Player.getPassenger() != null)
if (_player.getPassenger() != null)
{
Recharge.Instance.useForce(Player, "PassengerChange", 100);
Recharge.Instance.useForce(_player, "PassengerChange", 100);
Player.getPassenger().remove();
Player.eject();
_player.getPassenger().remove();
_player.eject();
}
//Others
for (Player other : UtilServer.getPlayers())
other.sendBlockChange(Player.getLocation(), _mat, (byte)0);
other.sendBlockChange(_player.getLocation(), _mat, (byte)0);
//Self
Player.sendBlockChange(Player.getLocation(), 36, (byte)0);
_player.sendBlockChange(_player.getLocation(), 36, (byte)0);
FallingBlockCheck();
}
@ -214,27 +223,27 @@ public class BlockForm
return;
//Recreate Falling
if (Player.getPassenger() == null || !Player.getPassenger().isValid())
if (_player.getPassenger() == null || !_player.getPassenger().isValid())
{
if (!Recharge.Instance.use(Player, "PassengerChange", 100, false, false))
if (!Recharge.Instance.use(_player, "PassengerChange", 100, false, false))
return;
//Falling Block
FallingBlock block = Player.getWorld().spawnFallingBlock(Player.getEyeLocation(), _mat, (byte)0);
FallingBlock block = _player.getWorld().spawnFallingBlock(_player.getEyeLocation(), _mat, (byte)0);
//No Arrow Collision
((CraftFallingSand)block).getHandle().spectating = true;
Player.setPassenger(block);
_player.setPassenger(block);
Host.fallingBlockRegister(block);
_host.fallingBlockRegister(block);
}
//Ensure Falling doesnt Despawn
else
{
((CraftFallingSand)Player.getPassenger()).getHandle().ticksLived = 1;
Player.getPassenger().setTicksLived(1);
((CraftFallingSand)_player.getPassenger()).getHandle().ticksLived = 1;
_player.getPassenger().setTicksLived(1);
}
}

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;
@ -21,6 +22,8 @@ import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.event.StackerEvent;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.gadget.event.GadgetBlockEvent;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;

View File

@ -3,9 +3,13 @@ package mineplex.core.mount;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEnderDragon;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -24,6 +28,8 @@ public class DragonData
public float Pitch = 0;
public Vector Velocity = new Vector(0,0,0);
public Entity Chicken;
public DragonData(DragonMount dragonMount, Player rider)
{
@ -35,15 +41,27 @@ public class DragonData
Pitch = UtilAlg.GetPitch(rider.getLocation().getDirection());
Location = rider.getLocation();
//Spawn Dragon
Dragon = rider.getWorld().spawn(rider.getLocation(), EnderDragon.class);
UtilEnt.Vegetate(Dragon);
UtilEnt.ghost(Dragon, true, false);
rider.getWorld().playSound(rider.getLocation(), Sound.ENDERDRAGON_GROWL, 20f, 1f);
rider.getWorld().playSound(rider.getLocation(), Sound.ENDERDRAGON_GROWL, 20f, 1f);
Dragon.setPassenger(Rider);
Chicken = rider.getWorld().spawn(rider.getLocation(), Chicken.class);
Dragon.setPassenger(Chicken);
Chicken.setPassenger(Rider);
Bukkit.getServer().getScheduler().runTaskLater(Host.Manager.GetPlugin(), new Runnable()
{
public void run()
{
Chicken.setPassenger(Rider);
}
}, 10L);
}
public void Move()

View File

@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseChicken;
public class DragonMount extends Mount<DragonData>
{
@ -42,6 +43,7 @@ public class DragonMount extends Mount<DragonData>
if (data != null)
{
data.Dragon.remove();
data.Chicken.remove();
//Inform
UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(GetName()) + "."));

View File

@ -76,7 +76,7 @@ public class MountDragon extends DragonMount
continue;
}
if (!data.Dragon.isValid() || data.Dragon.getPassenger() == null)
if (!data.Dragon.isValid() || data.Dragon.getPassenger().getPassenger() == null)
{
data.Dragon.remove();
toRemove.add(player);

View File

@ -45,7 +45,7 @@ public class JumpManager extends MiniPlugin
//Chicken Cancel
DisguiseBase disguise = Manager.GetDisguise().getDisguise(player);
if (disguise != null && (disguise instanceof DisguiseChicken || disguise instanceof DisguiseBat || disguise instanceof DisguiseEnderman))
if (disguise != null && ((disguise instanceof DisguiseChicken && !((DisguiseChicken)disguise).isBaby()) || disguise instanceof DisguiseBat || disguise instanceof DisguiseEnderman))
return;
event.setCancelled(true);