Skip to content

Commit

Permalink
Update fully to 1.9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphan1 committed May 23, 2016
1 parent c7ed715 commit 85e2b8a
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 47 deletions.
Expand Up @@ -282,15 +282,15 @@ else if (catchType == CatchType.FISH) {
private ItemStack catchRandomJunk() {
fishHook.owner.a(StatisticList.A, 1);
LootTableInfo.a playerFishEvent2 = new LootTableInfo.a((WorldServer)fishHook.getWorld());
// TODO: 1.9.4: playerFishEvent2.a((float)EnchantmentManager.f(fishHook.owner) + fishHook.owner.db());
playerFishEvent2.a((float)EnchantmentManager.f(fishHook.owner) + fishHook.owner.dc());
List<ItemStack> itemStacks = fishHook.getWorld().ak().a(LootTables.am).a(CoreUtilities.getRandom(), playerFishEvent2.a());
return itemStacks.get(CoreUtilities.getRandom().nextInt(itemStacks.size()));
}

private ItemStack catchRandomTreasure() {
fishHook.owner.a(StatisticList.B, 1);
LootTableInfo.a playerFishEvent2 = new LootTableInfo.a((WorldServer)fishHook.getWorld());
// TODO: 1.9.4: playerFishEvent2.a((float)EnchantmentManager.f(fishHook.owner) + fishHook.owner.db());
playerFishEvent2.a((float)EnchantmentManager.f(fishHook.owner) + fishHook.owner.dc());
List<ItemStack> itemStacks = fishHook.getWorld().ak().a(LootTables.an).a(CoreUtilities.getRandom(), playerFishEvent2.a());
return itemStacks.get(CoreUtilities.getRandom().nextInt(itemStacks.size()));
}
Expand All @@ -299,7 +299,7 @@ private ItemStack catchRandomFish() {
//float f3 = f - f2;
fishHook.owner.a(StatisticList.z, 1);
LootTableInfo.a playerFishEvent2 = new LootTableInfo.a((WorldServer)fishHook.getWorld());
// TODO: 1.9.4: playerFishEvent2.a((float)EnchantmentManager.f(fishHook.owner) + fishHook.owner.db());
playerFishEvent2.a((float)EnchantmentManager.f(fishHook.owner) + fishHook.owner.dc());
List<ItemStack> itemStacks = fishHook.getWorld().ak().a(LootTables.ao).a(CoreUtilities.getRandom(), playerFishEvent2.a());
return itemStacks.get(CoreUtilities.getRandom().nextInt(itemStacks.size()));
}
Expand Down
Expand Up @@ -199,7 +199,7 @@ public void NPCCompleteDestination(NavigationCompleteEvent event) {
handle.yaw = returnLocation.getYaw();
handle.pitch = returnLocation.getPitch();
// !--- START NMS OBFUSCATED
// TODO: 1.9.4: handle.az = handle.yaw; // The head's yaw
handle.aA = handle.yaw; // The head's yaw
// !--- END NMS OBFUSCATED
pushed = false;
// Push Return action
Expand Down
Expand Up @@ -5,7 +5,12 @@
import net.aufdemrand.denizen.objects.properties.item.ItemSkullskin;
import net.aufdemrand.denizen.utilities.packets.PacketHelper;
import net.aufdemrand.denizencore.utilities.debugging.dB;
import net.minecraft.server.v1_9_R2.*;
import net.minecraft.server.v1_9_R2.EntityHuman;
import net.minecraft.server.v1_9_R2.EntityPlayer;
import net.minecraft.server.v1_9_R2.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_9_R2.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_9_R2.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_9_R2.PacketPlayOutRespawn;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
Expand All @@ -27,14 +32,14 @@ public class PlayerProfileEditor {

private static final Map<UUID, GameProfile> fakeProfiles = new HashMap<UUID, GameProfile>();
private static final Field playerGameProfile, gameProfileId, gameProfileName;
private static final Field playerInfo_action;// TODO: 1.9.4: , playerInfo_data;
// TODO: 1.9.4: private static final Field playerInfoData_latency, playerInfoData_gameMode,
// TODO: 1.9.4: playerInfoData_gameProfile, playerInfoData_displayName;
private static final Field playerInfo_action, playerInfo_data;
private static final Field playerInfoData_latency, playerInfoData_gameMode,
playerInfoData_gameProfile, playerInfoData_displayName;

static {
Map<String, Field> fields = PacketHelper.registerFields(PacketPlayOutPlayerInfo.class);
playerInfo_action = fields.get("a");
// TODO: 1.9.4: playerInfo_data = fields.get("b");
playerInfo_data = fields.get("b");
Field profileField = null;
Field profileIdField = null;
Field profileNameField = null;
Expand All @@ -43,14 +48,12 @@ public class PlayerProfileEditor {
Field pidGameProfile = null;
Field pidDisplayName = null;
try {
profileField = EntityHuman.class.getDeclaredField("bR");
profileField = EntityHuman.class.getDeclaredField("bS");
profileField.setAccessible(true);
profileIdField = GameProfile.class.getDeclaredField("id");
profileIdField.setAccessible(true);
profileNameField = GameProfile.class.getDeclaredField("name");
profileNameField.setAccessible(true);
// TODO: 1.9.4:
/*
pidLatency = PacketPlayOutPlayerInfo.PlayerInfoData.class.getDeclaredField("b");
pidLatency.setAccessible(true);
pidGameMode = PacketPlayOutPlayerInfo.PlayerInfoData.class.getDeclaredField("c");
Expand All @@ -59,21 +62,17 @@ public class PlayerProfileEditor {
pidGameProfile.setAccessible(true);
pidDisplayName = PacketPlayOutPlayerInfo.PlayerInfoData.class.getDeclaredField("e");
pidDisplayName.setAccessible(true);
*/
}
catch (Exception e) {
dB.echoError(e);
}
playerGameProfile = profileField;
gameProfileId = profileIdField;
gameProfileName = profileNameField;
// TODO: 1.9.4:
/*
playerInfoData_latency = pidLatency;
playerInfoData_gameMode = pidGameMode;
playerInfoData_gameProfile = pidGameProfile;
playerInfoData_displayName = pidDisplayName;
*/
DenizenAPI.getCurrentInstance().getServer().getPluginManager()
.registerEvents(new PlayerProfileEditorListener(), DenizenAPI.getCurrentInstance());
}
Expand All @@ -84,16 +83,13 @@ public static void updatePlayerProfiles(PacketPlayOutPlayerInfo packet) {
if (action != EnumPlayerInfoAction.ADD_PLAYER) {
return;
}
// TODO: 1.9.4:
/*
List<PlayerInfoData> dataList = (List<PlayerInfoData>) playerInfo_data.get(packet);
for (PlayerInfoData data : dataList) {
List<PacketPlayOutPlayerInfo.PlayerInfoData> dataList = (List<PacketPlayOutPlayerInfo.PlayerInfoData>) playerInfo_data.get(packet);
for (PacketPlayOutPlayerInfo.PlayerInfoData data : dataList) {
GameProfile gameProfile = data.a();
if (fakeProfiles.containsKey(gameProfile.getId())) {
playerInfoData_gameProfile.set(data, fakeProfiles.get(gameProfile.getId()));
}
}
*/
}
catch (Exception e) {
dB.echoError(e);
Expand Down
Expand Up @@ -17,7 +17,7 @@ public EntityFakePlayer(MinecraftServer minecraftserver, WorldServer worldserver
NetworkManager networkManager = new FakeNetworkManager(EnumProtocolDirection.CLIENTBOUND);
playerConnection = new FakePlayerConnection(minecraftserver, networkManager, this);
networkManager.setPacketListener(playerConnection);
// TODO: 1.9.4: datawatcher.set(EntityHuman.bp, (byte) 127);
datawatcher.set(EntityHuman.bq, (byte) 127);
worldserver.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
}

Expand Down
Expand Up @@ -43,16 +43,15 @@ public static void toggleAI(Entity entity, boolean hasAI) {
if (!(nmsEntity instanceof EntityInsentient)) {
return;
}
// TODO: 1.9.4: ((EntityInsentient) nmsEntity).m(!hasAI);
((EntityInsentient) nmsEntity).setAI(!hasAI);
}

public static boolean isAIDisabled(Entity entity) {
net.minecraft.server.v1_9_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
if (!(nmsEntity instanceof EntityInsentient)) {
return true;
}
// TODO: 1.9.4: return ((EntityInsentient) nmsEntity).cR();
return false;
return ((EntityInsentient) nmsEntity).hasAI();
}

public static double getSpeed(Entity entity) {
Expand Down
@@ -1,9 +1,12 @@
package net.aufdemrand.denizen.utilities.packets;

import net.aufdemrand.denizen.utilities.debugging.dB;
import net.minecraft.server.v1_9_R2.BlockPosition;
import net.minecraft.server.v1_9_R2.ChatComponentText;
import net.minecraft.server.v1_9_R2.IChatBaseComponent;
import net.minecraft.server.v1_9_R2.NBTTagCompound;
import net.minecraft.server.v1_9_R2.PacketPlayOutTileEntityData;
import net.minecraft.server.v1_9_R2.TileEntity;
import net.minecraft.server.v1_9_R2.TileEntitySign;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
import org.bukkit.entity.Player;
Expand All @@ -13,39 +16,42 @@

public class SignUpdate {

// TODO: 1.9.4:
/*
private static final Field sign_world, sign_location, sign_lines;
private static final Field block_location, block_action, block_nbt;

static {
Map<String, Field> fields = PacketHelper.registerFields(PacketPlayOutUpdateSign.class);
sign_world = fields.get("a");
sign_location = fields.get("b");
sign_lines = fields.get("c");
Map<String, Field> fields = PacketHelper.registerFields(PacketPlayOutTileEntityData.class);
block_location = fields.get("a");
block_action = fields.get("b");
block_nbt = fields.get("c");
}

public static PacketPlayOutUpdateSign getSignUpdatePacket(Location location, String[] lines) {
PacketPlayOutUpdateSign signUpdatePacket = new PacketPlayOutUpdateSign();
public static PacketPlayOutTileEntityData getSignUpdatePacket(TileEntitySign sign, String[] lines) {
PacketPlayOutTileEntityData signUpdatePacket = new PacketPlayOutTileEntityData();
try {
sign_world.set(signUpdatePacket, ((CraftWorld) location.getWorld()).getHandle());
sign_location.set(signUpdatePacket, new BlockPosition(location.getBlockX(),
location.getBlockY(), location.getBlockZ()));
sign_lines.set(signUpdatePacket, new IChatBaseComponent[]{
lines[0] != null ? new ChatComponentText(lines[0]) : null,
lines[1] != null ? new ChatComponentText(lines[1]) : null,
lines[2] != null ? new ChatComponentText(lines[2]) : null,
lines[3] != null ? new ChatComponentText(lines[3]) : null
});
block_location.set(signUpdatePacket, sign.getPosition());
block_action.set(signUpdatePacket, 9);
IChatBaseComponent[] realLines = sign.lines;
sign.lines[0] = lines[0] != null ? new ChatComponentText(lines[0]) : null;
sign.lines[1] = lines[1] != null ? new ChatComponentText(lines[1]) : null;
sign.lines[2] = lines[2] != null ? new ChatComponentText(lines[2]) : null;
sign.lines[3] = lines[3] != null ? new ChatComponentText(lines[3]) : null;
block_nbt.set(signUpdatePacket, sign.save(new NBTTagCompound()));
System.arraycopy(realLines, 0, sign.lines, 0, 4);
}
catch (Exception e) {
dB.echoError(e);
}
return signUpdatePacket;
}*/
}

public static void updateSign(Player player, Location location, String[] lines) {
// TODO: 1.9.4: PacketPlayOutUpdateSign signUpdatePacket = getSignUpdatePacket(location, lines);
// TODO: 1.9.4: PacketHelper.sendPacket(player, signUpdatePacket);
TileEntity tileEntity = ((CraftWorld)location.getWorld()).getTileEntityAt(location.getBlockX(),
location.getBlockY(), location.getBlockZ());
if (tileEntity == null || !(tileEntity instanceof TileEntitySign)) {
return;
}
PacketPlayOutTileEntityData signUpdatePacket = getSignUpdatePacket((TileEntitySign)tileEntity, lines);
PacketHelper.sendPacket(player, signUpdatePacket);
}

}

0 comments on commit 85e2b8a

Please sign in to comment.