Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Commit

Permalink
Handling for #97
Browse files Browse the repository at this point in the history
  • Loading branch information
robotia committed Mar 12, 2016
1 parent d50eacc commit 82ad45d
Showing 1 changed file with 42 additions and 36 deletions.
78 changes: 42 additions & 36 deletions patches/net/minecraft/network/NetHandlerPlayServer.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,11 @@
this.netManager.disableAutoRead();
}

@@ -182,6 +297,15 @@
@@ -180,8 +295,18 @@
this.playerEntity.setEntityActionState(p_147358_1_.func_149620_c(), p_147358_1_.func_149616_d(), p_147358_1_.func_149618_e(), p_147358_1_.func_149617_f());
}

+ boolean trigger = false;
public void processPlayer(C03PacketPlayer p_147347_1_)
{
+ // CraftBukkit start - Check for NaN
Expand All @@ -231,7 +234,7 @@
WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
this.field_147366_g = true;

@@ -199,8 +323,72 @@
@@ -199,8 +324,75 @@
}
}

Expand Down Expand Up @@ -271,8 +274,11 @@
+
+ Location oldTo = to.clone();
+ PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
+ this.server.getPluginManager().callEvent(event);
+
+ trigger = !trigger;
+ if(trigger)
+ this.server.getPluginManager().callEvent(event);
+
+ // If the event is cancelled we move the player back to their old location.
+ if (event.isCancelled())
+ {
Expand Down Expand Up @@ -305,7 +311,7 @@
double d1;
double d2;
double d3;
@@ -280,13 +468,6 @@
@@ -280,13 +472,6 @@
d3 = p_147347_1_.func_149472_e();
d4 = p_147347_1_.func_149471_f() - p_147347_1_.func_149467_d();

Expand All @@ -319,7 +325,7 @@
if (Math.abs(p_147347_1_.func_149464_c()) > 3.2E7D || Math.abs(p_147347_1_.func_149472_e()) > 3.2E7D)
{
this.kickPlayerFromServer("Illegal position");
@@ -318,7 +499,7 @@
@@ -318,7 +503,7 @@
double d9 = Math.max(Math.abs(d6), Math.abs(this.playerEntity.motionZ));
double d10 = d7 * d7 + d8 * d8 + d9 * d9;

Expand All @@ -328,7 +334,7 @@
{
logger.warn(this.playerEntity.getCommandSenderName() + " moved too quickly! " + d4 + "," + d5 + "," + d6 + " (" + d7 + ", " + d8 + ", " + d9 + ")");
this.setPlayerLocation(this.lastPosX, this.lastPosY, this.lastPosZ, this.playerEntity.rotationYaw, this.playerEntity.rotationPitch);
@@ -413,21 +594,85 @@
@@ -413,21 +598,85 @@

public void setPlayerLocation(double p_147364_1_, double p_147364_3_, double p_147364_5_, float p_147364_7_, float p_147364_8_)
{
Expand Down Expand Up @@ -419,7 +425,7 @@
this.playerEntity.dropOneItem(false);
}
else if (p_147345_1_.func_149506_g() == 3)
@@ -490,7 +735,17 @@
@@ -490,7 +739,17 @@
}
else
{
Expand All @@ -437,7 +443,7 @@
}
}
else if (p_147345_1_.func_149506_g() == 2)
@@ -517,6 +772,34 @@
@@ -517,6 +776,34 @@
public void processPlayerBlockPlacement(C08PacketPlayerBlockPlacement p_147346_1_)
{
WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
Expand Down Expand Up @@ -472,7 +478,7 @@
ItemStack itemstack = this.playerEntity.inventory.getCurrentItem();
boolean flag = false;
boolean placeResult = true;
@@ -532,12 +815,20 @@
@@ -532,12 +819,20 @@
{
return;
}
Expand All @@ -495,7 +501,7 @@
}
else if (p_147346_1_.func_149571_d() >= this.serverController.getBuildLimit() - 1 && (p_147346_1_.func_149568_f() == 1 || p_147346_1_.func_149571_d() >= this.serverController.getBuildLimit()))
{
@@ -548,17 +839,24 @@
@@ -548,17 +843,24 @@
}
else
{
Expand Down Expand Up @@ -528,7 +534,7 @@
flag = true;
}

@@ -615,7 +913,7 @@
@@ -615,7 +917,7 @@
this.playerEntity.openContainer.detectAndSendChanges();
this.playerEntity.isChangingQuantityOnly = false;

Expand All @@ -537,7 +543,7 @@
{
this.sendPacket(new S2FPacketSetSlot(this.playerEntity.openContainer.windowId, slot.slotNumber, this.playerEntity.inventory.getCurrentItem()));
}
@@ -624,14 +922,34 @@
@@ -624,14 +926,34 @@

public void onDisconnect(IChatComponent p_147231_1_)
{
Expand Down Expand Up @@ -577,7 +583,7 @@
if (this.serverController.isSinglePlayer() && this.playerEntity.getCommandSenderName().equals(this.serverController.getServerOwner()))
{
logger.info("Stopping singleplayer server as player logged out");
@@ -657,6 +975,18 @@
@@ -657,6 +979,18 @@
}
}

Expand All @@ -596,7 +602,7 @@
try
{
this.netManager.scheduleOutboundPacket(p_147359_1_, new GenericFutureListener[0]);
@@ -679,20 +1009,37 @@
@@ -679,20 +1013,37 @@

public void processHeldItemChange(C09PacketHeldItemChange p_147355_1_)
{
Expand Down Expand Up @@ -635,7 +641,7 @@
{
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("chat.cannotSend", new Object[0]);
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
@@ -708,51 +1055,385 @@
@@ -708,51 +1059,385 @@
{
if (!ChatAllowedCharacters.isAllowedCharacter(s.charAt(i)))
{
Expand Down Expand Up @@ -1033,7 +1039,7 @@
if (p_147357_1_.func_149513_d() == 1)
{
this.playerEntity.setSneaking(true);
@@ -772,7 +1453,7 @@
@@ -772,7 +1457,7 @@
else if (p_147357_1_.func_149513_d() == 3)
{
this.playerEntity.wakeUpPlayer(false, true, true);
Expand All @@ -1042,7 +1048,7 @@
}
else if (p_147357_1_.func_149513_d() == 6)
{
@@ -789,8 +1470,20 @@
@@ -789,8 +1474,20 @@

public void processUseEntity(C02PacketUseEntity p_147340_1_)
{
Expand All @@ -1064,7 +1070,7 @@
this.playerEntity.func_143004_u();

if (entity != null)
@@ -805,9 +1498,53 @@
@@ -805,9 +1502,53 @@

if (this.playerEntity.getDistanceSqToEntity(entity) < d0)
{
Expand Down Expand Up @@ -1118,7 +1124,7 @@
}
else if (p_147340_1_.func_149565_c() == C02PacketUseEntity.Action.ATTACK)
{
@@ -819,6 +1556,13 @@
@@ -819,6 +1560,13 @@
}

this.playerEntity.attackTargetEntityWithCurrentItem(entity);
Expand All @@ -1132,7 +1138,7 @@
}
}
}
@@ -834,8 +1578,19 @@
@@ -834,8 +1582,19 @@
case 1:
if (this.playerEntity.playerConqueredTheEnd)
{
Expand All @@ -1153,7 +1159,7 @@
else if (this.playerEntity.getServerForPlayer().getWorldInfo().isHardcoreModeEnabled())
{
if (this.serverController.isSinglePlayer() && this.playerEntity.getCommandSenderName().equals(this.serverController.getServerOwner()))
@@ -871,17 +1626,461 @@
@@ -871,17 +1630,461 @@

public void processCloseWindow(C0DPacketCloseWindow p_147356_1_)
{
Expand Down Expand Up @@ -1616,7 +1622,7 @@
if (ItemStack.areItemStacksEqual(p_147351_1_.func_149546_g(), itemstack))
{
this.playerEntity.playerNetServerHandler.sendPacket(new S32PacketConfirmTransaction(p_147351_1_.func_149548_c(), p_147351_1_.func_149547_f(), true));
@@ -903,6 +2102,12 @@
@@ -903,6 +2106,12 @@
}

this.playerEntity.sendContainerAndContentsToPlayer(this.playerEntity.openContainer, arraylist);
Expand All @@ -1629,7 +1635,7 @@
}
}
}
@@ -925,9 +2130,61 @@
@@ -925,9 +2134,61 @@
boolean flag = p_147344_1_.func_149627_c() < 0;
ItemStack itemstack = p_147344_1_.func_149625_d();
boolean flag1 = p_147344_1_.func_149627_c() >= 1 && p_147344_1_.func_149627_c() < 36 + InventoryPlayer.getHotbarSize();
Expand Down Expand Up @@ -1692,7 +1698,7 @@
if (flag1 && flag2 && flag3)
{
if (itemstack == null)
@@ -956,6 +2213,11 @@
@@ -956,6 +2217,11 @@

public void processConfirmTransaction(C0FPacketConfirmTransaction p_147339_1_)
{
Expand All @@ -1704,7 +1710,7 @@
Short oshort = (Short)this.field_147372_n.lookup(this.playerEntity.openContainer.windowId);

if (oshort != null && p_147339_1_.func_149533_d() == oshort.shortValue() && this.playerEntity.openContainer.windowId == p_147339_1_.func_149532_c() && !this.playerEntity.openContainer.isPlayerNotUsingContainer(this.playerEntity))
@@ -966,6 +2228,11 @@
@@ -966,6 +2232,11 @@

public void processUpdateSign(C12PacketUpdateSign p_147343_1_)
{
Expand All @@ -1716,23 +1722,23 @@
this.playerEntity.func_143004_u();
WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);

@@ -980,6 +2247,7 @@
@@ -980,6 +2251,7 @@
if (!tileentitysign.func_145914_a() || tileentitysign.func_145911_b() != this.playerEntity)
{
this.serverController.logWarning("Player " + this.playerEntity.getCommandSenderName() + " just tried to change non-editable sign");
+ this.sendPacket(new S33PacketUpdateSign(p_147343_1_.func_149588_c(), p_147343_1_.func_149586_d(), p_147343_1_.func_149585_e(), tileentitysign.signText)); // CraftBukkit
return;
}
}
@@ -990,6 +2258,7 @@
@@ -990,6 +2262,7 @@
for (j = 0; j < 4; ++j)
{
boolean flag = true;
+ p_147343_1_.func_149589_f()[j] = p_147343_1_.func_149589_f()[j].replaceAll("\uF700", "").replaceAll("\uF701", ""); // Spigot - Mac OSX sends weird chars

if (p_147343_1_.func_149589_f()[j].length() > 15)
{
@@ -1018,7 +2287,29 @@
@@ -1018,7 +2291,29 @@
int k = p_147343_1_.func_149586_d();
i = p_147343_1_.func_149585_e();
TileEntitySign tileentitysign1 = (TileEntitySign)tileentity;
Expand Down Expand Up @@ -1763,7 +1769,7 @@
tileentitysign1.markDirty();
worldserver.markBlockForUpdate(j, k, i);
}
@@ -1041,7 +2332,22 @@
@@ -1041,7 +2336,22 @@

public void processPlayerAbilities(C13PacketPlayerAbilities p_147348_1_)
{
Expand All @@ -1787,7 +1793,7 @@
}

public void processTabComplete(C14PacketTabComplete p_147341_1_)
@@ -1093,16 +2399,18 @@
@@ -1093,16 +2403,18 @@
{
if (itemstack.getItem() == Items.writable_book && itemstack.getItem() == itemstack1.getItem())
{
Expand All @@ -1810,7 +1816,7 @@
}
finally
{
@@ -1135,19 +2443,18 @@
@@ -1135,19 +2447,18 @@

if (itemstack.getItem() == Items.written_book && itemstack1.getItem() == Items.writable_book)
{
Expand All @@ -1836,7 +1842,7 @@
}
finally
{
@@ -1174,9 +2481,12 @@
@@ -1174,9 +2485,12 @@
((ContainerMerchant)container).setCurrentRecipeIndex(i);
}
}
Expand All @@ -1850,7 +1856,7 @@
}
}
else if ("MC|AdvCdm".equals(p_147349_1_.func_149559_c()))
@@ -1222,9 +2532,12 @@
@@ -1222,9 +2536,12 @@
this.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.setCommand.success", new Object[] {s1}));
}
}
Expand All @@ -1865,7 +1871,7 @@
}
finally
{
@@ -1257,9 +2570,12 @@
@@ -1257,9 +2574,12 @@
tileentitybeacon.markDirty();
}
}
Expand All @@ -1880,7 +1886,7 @@
}
}
}
@@ -1281,6 +2597,13 @@
@@ -1281,6 +2601,13 @@
containerrepair.updateItemName("");
}
}
Expand All @@ -1894,7 +1900,7 @@
}
}

@@ -1292,6 +2615,21 @@
@@ -1292,6 +2619,21 @@
}
}

Expand Down

0 comments on commit 82ad45d

Please sign in to comment.