spigot/CraftBukkit-Patches/0003-mc-dev-imports.patch

2405 lines
85 KiB
Diff
Raw Normal View History

2016-11-17 12:41:12 +11:00
From 61559ba95b6503be3c50ac0d75ef68a99aa7751e Mon Sep 17 00:00:00 2001
2013-04-10 14:06:41 +10:00
From: md_5 <md_5@live.com.au>
2013-12-01 15:13:58 +11:00
Date: Sun, 1 Dec 2013 15:10:48 +1100
2013-04-10 14:06:41 +10:00
Subject: [PATCH] mc-dev imports
Imported files which are only modified by Spigot, not upstream. Files here should be completely unmodified aside from trivial changes such as adding throws statements to ensure proper compilation. You may need to add unrelated files in order to ensure a compilable result in the face of synthetic methods.
diff --git a/src/main/java/net/minecraft/server/AttributeRanged.java b/src/main/java/net/minecraft/server/AttributeRanged.java
new file mode 100644
2016-05-10 21:48:25 +10:00
index 0000000..130597c
--- /dev/null
+++ b/src/main/java/net/minecraft/server/AttributeRanged.java
2016-05-10 21:48:25 +10:00
@@ -0,0 +1,37 @@
+package net.minecraft.server;
+
2016-05-10 21:48:25 +10:00
+import javax.annotation.Nullable;
+
+public class AttributeRanged extends AttributeBase {
+
+ private final double a;
+ private final double b;
+ private String c;
+
2016-05-10 21:48:25 +10:00
+ public AttributeRanged(@Nullable IAttribute iattribute, String s, double d0, double d1, double d2) {
+ super(iattribute, s, d0);
+ this.a = d1;
+ this.b = d2;
+ if (d1 > d2) {
+ throw new IllegalArgumentException("Minimum value cannot be bigger than maximum value!");
+ } else if (d0 < d1) {
+ throw new IllegalArgumentException("Default value cannot be lower than minimum value!");
+ } else if (d0 > d2) {
+ throw new IllegalArgumentException("Default value cannot be bigger than maximum value!");
+ }
+ }
+
+ public AttributeRanged a(String s) {
+ this.c = s;
+ return this;
+ }
+
+ public String g() {
+ return this.c;
+ }
+
+ public double a(double d0) {
+ d0 = MathHelper.a(d0, this.a, this.b);
+ return d0;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/CommandDispatcher.java b/src/main/java/net/minecraft/server/CommandDispatcher.java
new file mode 100644
2016-11-17 12:41:12 +11:00
index 0000000..b4ef581
--- /dev/null
+++ b/src/main/java/net/minecraft/server/CommandDispatcher.java
2016-11-17 12:41:12 +11:00
@@ -0,0 +1,128 @@
+package net.minecraft.server;
+
+import java.util.Iterator;
+
+public class CommandDispatcher extends CommandHandler implements ICommandDispatcher {
+
2016-03-01 08:33:06 +11:00
+ private final MinecraftServer a;
+
+ public CommandDispatcher(MinecraftServer minecraftserver) {
+ this.a = minecraftserver;
+ this.a((ICommand) (new CommandTime()));
+ this.a((ICommand) (new CommandGamemode()));
+ this.a((ICommand) (new CommandDifficulty()));
+ this.a((ICommand) (new CommandGamemodeDefault()));
+ this.a((ICommand) (new CommandKill()));
+ this.a((ICommand) (new CommandToggleDownfall()));
+ this.a((ICommand) (new CommandWeather()));
+ this.a((ICommand) (new CommandXp()));
+ this.a((ICommand) (new CommandTp()));
2016-06-09 11:43:56 +10:00
+ this.a((ICommand) (new CommandTeleport()));
+ this.a((ICommand) (new CommandGive()));
+ this.a((ICommand) (new CommandReplaceItem()));
+ this.a((ICommand) (new CommandStats()));
+ this.a((ICommand) (new CommandEffect()));
+ this.a((ICommand) (new CommandEnchant()));
+ this.a((ICommand) (new CommandParticle()));
+ this.a((ICommand) (new CommandMe()));
+ this.a((ICommand) (new CommandSeed()));
+ this.a((ICommand) (new CommandHelp()));
+ this.a((ICommand) (new CommandDebug()));
+ this.a((ICommand) (new CommandTell()));
+ this.a((ICommand) (new CommandSay()));
+ this.a((ICommand) (new CommandSpawnpoint()));
+ this.a((ICommand) (new CommandSetWorldSpawn()));
+ this.a((ICommand) (new CommandGamerule()));
+ this.a((ICommand) (new CommandClear()));
+ this.a((ICommand) (new CommandTestFor()));
+ this.a((ICommand) (new CommandSpreadPlayers()));
+ this.a((ICommand) (new CommandPlaySound()));
+ this.a((ICommand) (new CommandScoreboard()));
+ this.a((ICommand) (new CommandExecute()));
+ this.a((ICommand) (new CommandTrigger()));
+ this.a((ICommand) (new CommandAchievement()));
+ this.a((ICommand) (new CommandSummon()));
+ this.a((ICommand) (new CommandSetBlock()));
+ this.a((ICommand) (new CommandFill()));
+ this.a((ICommand) (new CommandClone()));
+ this.a((ICommand) (new CommandTestForBlocks()));
+ this.a((ICommand) (new CommandBlockData()));
+ this.a((ICommand) (new CommandTestForBlock()));
+ this.a((ICommand) (new CommandTellRaw()));
+ this.a((ICommand) (new CommandWorldBorder()));
+ this.a((ICommand) (new CommandTitle()));
+ this.a((ICommand) (new CommandEntityData()));
2016-05-10 21:48:25 +10:00
+ this.a((ICommand) (new CommandStopSound()));
2016-11-17 12:41:12 +11:00
+ this.a((ICommand) (new CommandLocate()));
+ if (minecraftserver.aa()) {
+ this.a((ICommand) (new CommandOp()));
+ this.a((ICommand) (new CommandDeop()));
+ this.a((ICommand) (new CommandStop()));
+ this.a((ICommand) (new CommandSaveAll()));
+ this.a((ICommand) (new CommandSaveOff()));
+ this.a((ICommand) (new CommandSaveOn()));
+ this.a((ICommand) (new CommandBanIp()));
+ this.a((ICommand) (new CommandPardonIP()));
+ this.a((ICommand) (new CommandBan()));
+ this.a((ICommand) (new CommandBanList()));
+ this.a((ICommand) (new CommandPardon()));
+ this.a((ICommand) (new CommandKick()));
+ this.a((ICommand) (new CommandList()));
+ this.a((ICommand) (new CommandWhitelist()));
+ this.a((ICommand) (new CommandIdleTimeout()));
+ } else {
+ this.a((ICommand) (new CommandPublish()));
2015-02-28 11:36:22 +00:00
+ }
+
+ CommandAbstract.a((ICommandDispatcher) this);
+ }
+
+ public void a(ICommandListener icommandlistener, ICommand icommand, int i, String s, Object... aobject) {
+ boolean flag = true;
+ MinecraftServer minecraftserver = this.a;
+
+ if (!icommandlistener.getSendCommandFeedback()) {
+ flag = false;
2015-02-28 11:36:22 +00:00
+ }
+
+ ChatMessage chatmessage = new ChatMessage("chat.type.admin", new Object[] { icommandlistener.getName(), new ChatMessage(s, aobject)});
+
+ chatmessage.getChatModifier().setColor(EnumChatFormat.GRAY);
+ chatmessage.getChatModifier().setItalic(Boolean.valueOf(true));
+ if (flag) {
+ Iterator iterator = minecraftserver.getPlayerList().v().iterator();
+
+ while (iterator.hasNext()) {
+ EntityHuman entityhuman = (EntityHuman) iterator.next();
2015-02-28 11:36:22 +00:00
+
+ if (entityhuman != icommandlistener && minecraftserver.getPlayerList().isOp(entityhuman.getProfile()) && icommand.canUse(this.a, icommandlistener)) {
+ boolean flag1 = icommandlistener instanceof MinecraftServer && this.a.s();
+ boolean flag2 = icommandlistener instanceof RemoteControlCommandListener && this.a.r();
+
+ if (flag1 || flag2 || !(icommandlistener instanceof RemoteControlCommandListener) && !(icommandlistener instanceof MinecraftServer)) {
+ entityhuman.sendMessage(chatmessage);
+ }
+ }
+ }
2015-02-28 11:36:22 +00:00
+ }
+
+ if (icommandlistener != minecraftserver && minecraftserver.worldServer[0].getGameRules().getBoolean("logAdminCommands")) {
+ minecraftserver.sendMessage(chatmessage);
+ }
+
+ boolean flag3 = minecraftserver.worldServer[0].getGameRules().getBoolean("sendCommandFeedback");
+
+ if (icommandlistener instanceof CommandBlockListenerAbstract) {
+ flag3 = ((CommandBlockListenerAbstract) icommandlistener).n();
+ }
+
+ if ((i & 1) != 1 && flag3 || icommandlistener instanceof MinecraftServer) {
+ icommandlistener.sendMessage(new ChatMessage(s, aobject));
+ }
+
+ }
+
+ protected MinecraftServer a() {
+ return this.a;
+ }
+}
2015-02-28 11:36:22 +00:00
diff --git a/src/main/java/net/minecraft/server/GameProfileBanEntry.java b/src/main/java/net/minecraft/server/GameProfileBanEntry.java
new file mode 100644
2015-02-28 11:36:22 +00:00
index 0000000..27ce9d9
--- /dev/null
2015-02-28 11:36:22 +00:00
+++ b/src/main/java/net/minecraft/server/GameProfileBanEntry.java
@@ -0,0 +1,47 @@
+package net.minecraft.server;
+
2015-02-28 11:36:22 +00:00
+import com.google.gson.JsonObject;
+import com.mojang.authlib.GameProfile;
+import java.util.Date;
+import java.util.UUID;
+
2015-02-28 11:36:22 +00:00
+public class GameProfileBanEntry extends ExpirableListEntry<GameProfile> {
+
2015-02-28 11:36:22 +00:00
+ public GameProfileBanEntry(GameProfile gameprofile) {
+ this(gameprofile, (Date) null, (String) null, (Date) null, (String) null);
+ }
+
2015-02-28 11:36:22 +00:00
+ public GameProfileBanEntry(GameProfile gameprofile, Date date, String s, Date date1, String s1) {
+ super(gameprofile, date1, s, date1, s1);
+ }
+
2015-02-28 11:36:22 +00:00
+ public GameProfileBanEntry(JsonObject jsonobject) {
+ super(b(jsonobject), jsonobject);
+ }
+
2015-02-28 11:36:22 +00:00
+ protected void a(JsonObject jsonobject) {
+ if (this.getKey() != null) {
+ jsonobject.addProperty("uuid", ((GameProfile) this.getKey()).getId() == null ? "" : ((GameProfile) this.getKey()).getId().toString());
+ jsonobject.addProperty("name", ((GameProfile) this.getKey()).getName());
+ super.a(jsonobject);
+ }
2015-02-28 11:36:22 +00:00
+ }
+
2015-02-28 11:36:22 +00:00
+ private static GameProfile b(JsonObject jsonobject) {
+ if (jsonobject.has("uuid") && jsonobject.has("name")) {
+ String s = jsonobject.get("uuid").getAsString();
+
2015-02-28 11:36:22 +00:00
+ UUID uuid;
+
2015-02-28 11:36:22 +00:00
+ try {
+ uuid = UUID.fromString(s);
+ } catch (Throwable throwable) {
+ return null;
+ }
+
2015-02-28 11:36:22 +00:00
+ return new GameProfile(uuid, jsonobject.get("name").getAsString());
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/GenericAttributes.java b/src/main/java/net/minecraft/server/GenericAttributes.java
new file mode 100644
2016-11-17 12:41:12 +11:00
index 0000000..15ad9fa
--- /dev/null
+++ b/src/main/java/net/minecraft/server/GenericAttributes.java
2016-05-10 21:48:25 +10:00
@@ -0,0 +1,119 @@
+package net.minecraft.server;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.UUID;
2016-05-10 21:48:25 +10:00
+import javax.annotation.Nullable;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class GenericAttributes {
+
2016-03-30 22:20:25 +01:00
+ private static final Logger j = LogManager.getLogger();
2015-07-30 17:22:16 +10:00
+ public static final IAttribute maxHealth = (new AttributeRanged((IAttribute) null, "generic.maxHealth", 20.0D, 0.0D, 1024.0D)).a("Max Health").a(true);
2015-05-09 21:23:26 +01:00
+ public static final IAttribute FOLLOW_RANGE = (new AttributeRanged((IAttribute) null, "generic.followRange", 32.0D, 0.0D, 2048.0D)).a("Follow Range");
+ public static final IAttribute c = (new AttributeRanged((IAttribute) null, "generic.knockbackResistance", 0.0D, 0.0D, 1.0D)).a("Knockback Resistance");
2015-07-30 17:22:16 +10:00
+ public static final IAttribute MOVEMENT_SPEED = (new AttributeRanged((IAttribute) null, "generic.movementSpeed", 0.699999988079071D, 0.0D, 1024.0D)).a("Movement Speed").a(true);
+ public static final IAttribute ATTACK_DAMAGE = new AttributeRanged((IAttribute) null, "generic.attackDamage", 2.0D, 0.0D, 2048.0D);
2016-03-01 08:33:06 +11:00
+ public static final IAttribute f = (new AttributeRanged((IAttribute) null, "generic.attackSpeed", 4.0D, 0.0D, 1024.0D)).a(true);
+ public static final IAttribute g = (new AttributeRanged((IAttribute) null, "generic.armor", 0.0D, 0.0D, 30.0D)).a(true);
2016-03-30 22:20:25 +01:00
+ public static final IAttribute h = (new AttributeRanged((IAttribute) null, "generic.armorToughness", 0.0D, 0.0D, 20.0D)).a(true);
+ public static final IAttribute i = (new AttributeRanged((IAttribute) null, "generic.luck", 0.0D, -1024.0D, 1024.0D)).a(true);
+
+ public static NBTTagList a(AttributeMapBase attributemapbase) {
+ NBTTagList nbttaglist = new NBTTagList();
+ Iterator iterator = attributemapbase.a().iterator();
+
+ while (iterator.hasNext()) {
+ AttributeInstance attributeinstance = (AttributeInstance) iterator.next();
+
+ nbttaglist.add(a(attributeinstance));
+ }
+
+ return nbttaglist;
+ }
+
+ private static NBTTagCompound a(AttributeInstance attributeinstance) {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ IAttribute iattribute = attributeinstance.getAttribute();
+
+ nbttagcompound.setString("Name", iattribute.getName());
+ nbttagcompound.setDouble("Base", attributeinstance.b());
+ Collection collection = attributeinstance.c();
+
+ if (collection != null && !collection.isEmpty()) {
+ NBTTagList nbttaglist = new NBTTagList();
+ Iterator iterator = collection.iterator();
+
+ while (iterator.hasNext()) {
+ AttributeModifier attributemodifier = (AttributeModifier) iterator.next();
+
+ if (attributemodifier.e()) {
+ nbttaglist.add(a(attributemodifier));
+ }
+ }
+
+ nbttagcompound.set("Modifiers", nbttaglist);
+ }
+
+ return nbttagcompound;
+ }
+
2016-03-01 08:33:06 +11:00
+ public static NBTTagCompound a(AttributeModifier attributemodifier) {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+
+ nbttagcompound.setString("Name", attributemodifier.b());
+ nbttagcompound.setDouble("Amount", attributemodifier.d());
+ nbttagcompound.setInt("Operation", attributemodifier.c());
2016-03-01 08:33:06 +11:00
+ nbttagcompound.a("UUID", attributemodifier.a());
+ return nbttagcompound;
+ }
+
+ public static void a(AttributeMapBase attributemapbase, NBTTagList nbttaglist) {
+ for (int i = 0; i < nbttaglist.size(); ++i) {
+ NBTTagCompound nbttagcompound = nbttaglist.get(i);
+ AttributeInstance attributeinstance = attributemapbase.a(nbttagcompound.getString("Name"));
+
2016-11-17 12:41:12 +11:00
+ if (attributeinstance == null) {
2016-06-09 11:43:56 +10:00
+ GenericAttributes.j.warn("Ignoring unknown attribute \'{}\'", new Object[] { nbttagcompound.getString("Name")});
2016-11-17 12:41:12 +11:00
+ } else {
+ a(attributeinstance, nbttagcompound);
+ }
+ }
+
+ }
+
+ private static void a(AttributeInstance attributeinstance, NBTTagCompound nbttagcompound) {
+ attributeinstance.setValue(nbttagcompound.getDouble("Base"));
+ if (nbttagcompound.hasKeyOfType("Modifiers", 9)) {
+ NBTTagList nbttaglist = nbttagcompound.getList("Modifiers", 10);
+
+ for (int i = 0; i < nbttaglist.size(); ++i) {
+ AttributeModifier attributemodifier = a(nbttaglist.get(i));
+
+ if (attributemodifier != null) {
+ AttributeModifier attributemodifier1 = attributeinstance.a(attributemodifier.a());
+
+ if (attributemodifier1 != null) {
+ attributeinstance.c(attributemodifier1);
+ }
+
+ attributeinstance.b(attributemodifier);
+ }
+ }
+ }
+
+ }
+
2016-05-10 21:48:25 +10:00
+ @Nullable
+ public static AttributeModifier a(NBTTagCompound nbttagcompound) {
2016-03-01 08:33:06 +11:00
+ UUID uuid = nbttagcompound.a("UUID");
+
+ try {
+ return new AttributeModifier(uuid, nbttagcompound.getString("Name"), nbttagcompound.getDouble("Amount"), nbttagcompound.getInt("Operation"));
+ } catch (Exception exception) {
2016-06-09 11:43:56 +10:00
+ GenericAttributes.j.warn("Unable to create attribute: {}", new Object[] { exception.getMessage()});
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/IntCache.java b/src/main/java/net/minecraft/server/IntCache.java
new file mode 100644
2016-06-09 11:43:56 +10:00
index 0000000..d916050
--- /dev/null
+++ b/src/main/java/net/minecraft/server/IntCache.java
2015-02-28 11:36:22 +00:00
@@ -0,0 +1,63 @@
+package net.minecraft.server;
+
+import com.google.common.collect.Lists;
+import java.util.List;
+
+public class IntCache {
+
+ private static int a = 256;
2016-06-09 11:43:56 +10:00
+ private static final List<int[]> b = Lists.newArrayList();
+ private static final List<int[]> c = Lists.newArrayList();
+ private static final List<int[]> d = Lists.newArrayList();
+ private static final List<int[]> e = Lists.newArrayList();
+
+ public static synchronized int[] a(int i) {
+ int[] aint;
+
+ if (i <= 256) {
+ if (IntCache.b.isEmpty()) {
+ aint = new int[256];
+ IntCache.c.add(aint);
+ return aint;
+ } else {
+ aint = (int[]) IntCache.b.remove(IntCache.b.size() - 1);
+ IntCache.c.add(aint);
+ return aint;
+ }
+ } else if (i > IntCache.a) {
+ IntCache.a = i;
+ IntCache.d.clear();
+ IntCache.e.clear();
+ aint = new int[IntCache.a];
+ IntCache.e.add(aint);
+ return aint;
+ } else if (IntCache.d.isEmpty()) {
+ aint = new int[IntCache.a];
+ IntCache.e.add(aint);
+ return aint;
+ } else {
+ aint = (int[]) IntCache.d.remove(IntCache.d.size() - 1);
+ IntCache.e.add(aint);
+ return aint;
+ }
+ }
+
+ public static synchronized void a() {
+ if (!IntCache.d.isEmpty()) {
+ IntCache.d.remove(IntCache.d.size() - 1);
+ }
+
+ if (!IntCache.b.isEmpty()) {
+ IntCache.b.remove(IntCache.b.size() - 1);
+ }
+
+ IntCache.d.addAll(IntCache.e);
+ IntCache.b.addAll(IntCache.c);
+ IntCache.e.clear();
+ IntCache.c.clear();
+ }
+
+ public static synchronized String b() {
+ return "cache: " + IntCache.d.size() + ", tcache: " + IntCache.b.size() + ", allocated: " + IntCache.e.size() + ", tallocated: " + IntCache.c.size();
+ }
+}
diff --git a/src/main/java/net/minecraft/server/ItemDoor.java b/src/main/java/net/minecraft/server/ItemDoor.java
new file mode 100644
2016-11-17 12:41:12 +11:00
index 0000000..b325563
--- /dev/null
+++ b/src/main/java/net/minecraft/server/ItemDoor.java
2016-11-17 12:41:12 +11:00
@@ -0,0 +1,68 @@
+package net.minecraft.server;
+
+public class ItemDoor extends Item {
+
2016-06-09 11:43:56 +10:00
+ private final Block a;
+
+ public ItemDoor(Block block) {
+ this.a = block;
+ this.a(CreativeModeTab.d);
+ }
+
2016-11-17 12:41:12 +11:00
+ public EnumInteractionResult a(EntityHuman entityhuman, World world, BlockPosition blockposition, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) {
+ if (enumdirection != EnumDirection.UP) {
2016-03-01 08:33:06 +11:00
+ return EnumInteractionResult.FAIL;
+ } else {
+ IBlockData iblockdata = world.getType(blockposition);
+ Block block = iblockdata.getBlock();
+
2016-03-01 08:33:06 +11:00
+ if (!block.a((IBlockAccess) world, blockposition)) {
+ blockposition = blockposition.shift(enumdirection);
+ }
+
2016-11-17 12:41:12 +11:00
+ ItemStack itemstack = entityhuman.b(enumhand);
+
2016-03-01 08:33:06 +11:00
+ if (entityhuman.a(blockposition, enumdirection, itemstack) && this.a.canPlace(world, blockposition)) {
+ EnumDirection enumdirection1 = EnumDirection.fromAngle((double) entityhuman.yaw);
+ int i = enumdirection1.getAdjacentX();
+ int j = enumdirection1.getAdjacentZ();
+ boolean flag = i < 0 && f2 < 0.5F || i > 0 && f2 > 0.5F || j < 0 && f > 0.5F || j > 0 && f < 0.5F;
+
+ a(world, blockposition, enumdirection1, this.a, flag);
2016-11-17 12:41:12 +11:00
+ SoundEffectType soundeffecttype = this.a.getStepSound();
2016-03-01 08:33:06 +11:00
+
+ world.a(entityhuman, blockposition, soundeffecttype.e(), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F);
2016-11-17 12:41:12 +11:00
+ itemstack.subtract(1);
2016-03-01 08:33:06 +11:00
+ return EnumInteractionResult.SUCCESS;
+ } else {
+ return EnumInteractionResult.FAIL;
+ }
+ }
+ }
+
2016-03-01 08:33:06 +11:00
+ public static void a(World world, BlockPosition blockposition, EnumDirection enumdirection, Block block, boolean flag) {
+ BlockPosition blockposition1 = blockposition.shift(enumdirection.e());
+ BlockPosition blockposition2 = blockposition.shift(enumdirection.f());
2016-11-17 12:41:12 +11:00
+ int i = (world.getType(blockposition2).m() ? 1 : 0) + (world.getType(blockposition2.up()).m() ? 1 : 0);
+ int j = (world.getType(blockposition1).m() ? 1 : 0) + (world.getType(blockposition1.up()).m() ? 1 : 0);
2016-03-01 08:33:06 +11:00
+ boolean flag1 = world.getType(blockposition2).getBlock() == block || world.getType(blockposition2.up()).getBlock() == block;
+ boolean flag2 = world.getType(blockposition1).getBlock() == block || world.getType(blockposition1.up()).getBlock() == block;
+
+ if ((!flag1 || flag2) && j <= i) {
+ if (flag2 && !flag1 || j < i) {
+ flag = false;
+ }
+ } else {
+ flag = true;
+ }
+
+ BlockPosition blockposition3 = blockposition.up();
2016-03-01 08:33:06 +11:00
+ boolean flag3 = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition3);
+ IBlockData iblockdata = block.getBlockData().set(BlockDoor.FACING, enumdirection).set(BlockDoor.HINGE, flag ? BlockDoor.EnumDoorHinge.RIGHT : BlockDoor.EnumDoorHinge.LEFT).set(BlockDoor.POWERED, Boolean.valueOf(flag3)).set(BlockDoor.OPEN, Boolean.valueOf(flag3));
+
2015-02-28 11:36:22 +00:00
+ world.setTypeAndData(blockposition, iblockdata.set(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER), 2);
+ world.setTypeAndData(blockposition3, iblockdata.set(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2);
2016-11-17 12:41:12 +11:00
+ world.applyPhysics(blockposition, block, false);
+ world.applyPhysics(blockposition3, block, false);
+ }
+}
2014-07-27 20:46:24 +10:00
diff --git a/src/main/java/net/minecraft/server/NBTCompressedStreamTools.java b/src/main/java/net/minecraft/server/NBTCompressedStreamTools.java
new file mode 100644
2015-02-28 11:36:22 +00:00
index 0000000..2a04b86
2014-07-27 20:46:24 +10:00
--- /dev/null
+++ b/src/main/java/net/minecraft/server/NBTCompressedStreamTools.java
2015-02-28 11:36:22 +00:00
@@ -0,0 +1,90 @@
2014-07-27 20:46:24 +10:00
+package net.minecraft.server;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+public class NBTCompressedStreamTools {
+
2015-02-28 11:36:22 +00:00
+ public static NBTTagCompound a(InputStream inputstream) throws IOException {
2014-07-27 20:46:24 +10:00
+ DataInputStream datainputstream = new DataInputStream(new BufferedInputStream(new GZIPInputStream(inputstream)));
+
+ NBTTagCompound nbttagcompound;
+
+ try {
+ nbttagcompound = a((DataInput) datainputstream, NBTReadLimiter.a);
+ } finally {
+ datainputstream.close();
+ }
+
+ return nbttagcompound;
+ }
+
2015-02-28 11:36:22 +00:00
+ public static void a(NBTTagCompound nbttagcompound, OutputStream outputstream) throws IOException {
2014-07-27 20:46:24 +10:00
+ DataOutputStream dataoutputstream = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(outputstream)));
+
+ try {
+ a(nbttagcompound, (DataOutput) dataoutputstream);
+ } finally {
+ dataoutputstream.close();
+ }
2015-02-28 11:36:22 +00:00
+
2014-07-27 20:46:24 +10:00
+ }
+
2015-02-28 11:36:22 +00:00
+ public static NBTTagCompound a(DataInputStream datainputstream) throws IOException {
2014-07-27 20:46:24 +10:00
+ return a((DataInput) datainputstream, NBTReadLimiter.a);
+ }
+
2015-02-28 11:36:22 +00:00
+ public static NBTTagCompound a(DataInput datainput, NBTReadLimiter nbtreadlimiter) throws IOException {
2014-07-27 20:46:24 +10:00
+ NBTBase nbtbase = a(datainput, 0, nbtreadlimiter);
+
+ if (nbtbase instanceof NBTTagCompound) {
+ return (NBTTagCompound) nbtbase;
+ } else {
+ throw new IOException("Root tag must be a named compound tag");
+ }
+ }
+
2015-02-28 11:36:22 +00:00
+ public static void a(NBTTagCompound nbttagcompound, DataOutput dataoutput) throws IOException {
2014-07-27 20:46:24 +10:00
+ a((NBTBase) nbttagcompound, dataoutput);
+ }
+
2015-02-28 11:36:22 +00:00
+ private static void a(NBTBase nbtbase, DataOutput dataoutput) throws IOException {
2014-07-27 20:46:24 +10:00
+ dataoutput.writeByte(nbtbase.getTypeId());
+ if (nbtbase.getTypeId() != 0) {
+ dataoutput.writeUTF("");
+ nbtbase.write(dataoutput);
+ }
+ }
+
2015-02-28 11:36:22 +00:00
+ private static NBTBase a(DataInput datainput, int i, NBTReadLimiter nbtreadlimiter) throws IOException {
2014-07-27 20:46:24 +10:00
+ byte b0 = datainput.readByte();
+
+ if (b0 == 0) {
+ return new NBTTagEnd();
+ } else {
+ datainput.readUTF();
+ NBTBase nbtbase = NBTBase.createTag(b0);
+
+ try {
+ nbtbase.load(datainput, i, nbtreadlimiter);
+ return nbtbase;
+ } catch (IOException ioexception) {
+ CrashReport crashreport = CrashReport.a(ioexception, "Loading NBT data");
+ CrashReportSystemDetails crashreportsystemdetails = crashreport.a("NBT Tag");
+
+ crashreportsystemdetails.a("Tag name", (Object) "[UNNAMED TAG]");
+ crashreportsystemdetails.a("Tag type", (Object) Byte.valueOf(b0));
2014-07-27 20:46:24 +10:00
+ throw new ReportedException(crashreport);
+ }
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/NBTTagByteArray.java b/src/main/java/net/minecraft/server/NBTTagByteArray.java
new file mode 100644
2015-05-09 21:23:26 +01:00
index 0000000..c6b5f70
--- /dev/null
+++ b/src/main/java/net/minecraft/server/NBTTagByteArray.java
2015-05-09 21:23:26 +01:00
@@ -0,0 +1,58 @@
+package net.minecraft.server;
+
+import java.io.DataInput;
+import java.io.DataOutput;
2015-02-28 11:36:22 +00:00
+import java.io.IOException;
+import java.util.Arrays;
+
+public class NBTTagByteArray extends NBTBase {
+
+ private byte[] data;
+
+ NBTTagByteArray() {}
+
+ public NBTTagByteArray(byte[] abyte) {
+ this.data = abyte;
+ }
+
2015-02-28 11:36:22 +00:00
+ void write(DataOutput dataoutput) throws IOException {
+ dataoutput.writeInt(this.data.length);
+ dataoutput.write(this.data);
+ }
+
2015-02-28 11:36:22 +00:00
+ void load(DataInput datainput, int i, NBTReadLimiter nbtreadlimiter) throws IOException {
2015-05-09 21:23:26 +01:00
+ nbtreadlimiter.a(192L);
+ int j = datainput.readInt();
+
+ nbtreadlimiter.a((long) (8 * j));
+ this.data = new byte[j];
+ datainput.readFully(this.data);
+ }
+
+ public byte getTypeId() {
+ return (byte) 7;
+ }
+
+ public String toString() {
+ return "[" + this.data.length + " bytes]";
+ }
+
+ public NBTBase clone() {
+ byte[] abyte = new byte[this.data.length];
+
+ System.arraycopy(this.data, 0, abyte, 0, this.data.length);
+ return new NBTTagByteArray(abyte);
+ }
+
+ public boolean equals(Object object) {
+ return super.equals(object) ? Arrays.equals(this.data, ((NBTTagByteArray) object).data) : false;
+ }
+
+ public int hashCode() {
+ return super.hashCode() ^ Arrays.hashCode(this.data);
+ }
+
+ public byte[] c() {
+ return this.data;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/NBTTagIntArray.java b/src/main/java/net/minecraft/server/NBTTagIntArray.java
new file mode 100644
2016-06-09 11:43:56 +10:00
index 0000000..4aa2d89
--- /dev/null
+++ b/src/main/java/net/minecraft/server/NBTTagIntArray.java
2016-06-09 11:43:56 +10:00
@@ -0,0 +1,84 @@
+package net.minecraft.server;
+
+import java.io.DataInput;
+import java.io.DataOutput;
2015-02-28 11:36:22 +00:00
+import java.io.IOException;
+import java.util.Arrays;
+
+public class NBTTagIntArray extends NBTBase {
+
+ private int[] data;
2013-04-10 14:06:41 +10:00
+
+ NBTTagIntArray() {}
2013-04-10 14:06:41 +10:00
+
+ public NBTTagIntArray(int[] aint) {
+ this.data = aint;
2013-04-10 14:06:41 +10:00
+ }
+
+ void write(DataOutput dataoutput) throws IOException {
+ dataoutput.writeInt(this.data.length);
2016-06-09 11:43:56 +10:00
+ int[] aint = this.data;
+ int i = aint.length;
+
+ for (int j = 0; j < i; ++j) {
+ int k = aint[j];
+
2016-06-09 11:43:56 +10:00
+ dataoutput.writeInt(k);
+ }
2013-04-10 14:06:41 +10:00
+
+ }
+
+ void load(DataInput datainput, int i, NBTReadLimiter nbtreadlimiter) throws IOException {
+ nbtreadlimiter.a(192L);
+ int j = datainput.readInt();
+
+ nbtreadlimiter.a((long) (32 * j));
+ this.data = new int[j];
+
+ for (int k = 0; k < j; ++k) {
+ this.data[k] = datainput.readInt();
+ }
+
+ }
2013-04-10 14:06:41 +10:00
+
+ public byte getTypeId() {
+ return (byte) 11;
+ }
+
+ public String toString() {
+ String s = "[";
+ int[] aint = this.data;
+ int i = aint.length;
+
+ for (int j = 0; j < i; ++j) {
+ int k = aint[j];
+
+ s = s + k + ",";
2013-04-10 14:06:41 +10:00
+ }
+
+ return s + "]";
+ }
+
2016-06-09 11:43:56 +10:00
+ public NBTTagIntArray c() {
+ int[] aint = new int[this.data.length];
+
+ System.arraycopy(this.data, 0, aint, 0, this.data.length);
+ return new NBTTagIntArray(aint);
+ }
+
+ public boolean equals(Object object) {
+ return super.equals(object) ? Arrays.equals(this.data, ((NBTTagIntArray) object).data) : false;
+ }
+
+ public int hashCode() {
+ return super.hashCode() ^ Arrays.hashCode(this.data);
+ }
+
2016-06-09 11:43:56 +10:00
+ public int[] d() {
+ return this.data;
2013-04-10 14:06:41 +10:00
+ }
2016-06-09 11:43:56 +10:00
+
+ public NBTBase clone() {
+ return this.c();
+ }
2013-04-10 14:06:41 +10:00
+}
2016-07-30 11:33:13 +10:00
diff --git a/src/main/java/net/minecraft/server/NibbleArray.java b/src/main/java/net/minecraft/server/NibbleArray.java
new file mode 100644
index 0000000..1509c77
--- /dev/null
+++ b/src/main/java/net/minecraft/server/NibbleArray.java
@@ -0,0 +1,58 @@
+package net.minecraft.server;
+
+public class NibbleArray {
+
+ private final byte[] a;
+
+ public NibbleArray() {
+ this.a = new byte[2048];
+ }
+
+ public NibbleArray(byte[] abyte) {
+ this.a = abyte;
+ if (abyte.length != 2048) {
+ throw new IllegalArgumentException("ChunkNibbleArrays should be 2048 bytes not: " + abyte.length);
+ }
+ }
+
+ public int a(int i, int j, int k) {
+ return this.a(this.b(i, j, k));
+ }
+
+ public void a(int i, int j, int k, int l) {
+ this.a(this.b(i, j, k), l);
+ }
+
+ private int b(int i, int j, int k) {
+ return j << 8 | k << 4 | i;
+ }
+
+ public int a(int i) {
+ int j = this.c(i);
+
+ return this.b(i) ? this.a[j] & 15 : this.a[j] >> 4 & 15;
+ }
+
+ public void a(int i, int j) {
+ int k = this.c(i);
+
+ if (this.b(i)) {
+ this.a[k] = (byte) (this.a[k] & 240 | j & 15);
+ } else {
+ this.a[k] = (byte) (this.a[k] & 15 | (j & 15) << 4);
+ }
+
+ }
+
+ private boolean b(int i) {
+ return (i & 1) == 0;
+ }
+
+ private int c(int i) {
+ return i >> 1;
+ }
+
+ public byte[] asBytes() {
+ return this.a;
+ }
+}
2015-07-30 17:22:16 +10:00
diff --git a/src/main/java/net/minecraft/server/PacketHandshakingInSetProtocol.java b/src/main/java/net/minecraft/server/PacketHandshakingInSetProtocol.java
new file mode 100644
2016-03-30 22:20:25 +01:00
index 0000000..1cb9d60
2015-07-30 17:22:16 +10:00
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketHandshakingInSetProtocol.java
@@ -0,0 +1,39 @@
+package net.minecraft.server;
+
+import java.io.IOException;
+
+public class PacketHandshakingInSetProtocol implements Packet<PacketHandshakingInListener> {
+
+ private int a;
+ public String hostname;
+ public int port;
+ private EnumProtocol d;
+
+ public PacketHandshakingInSetProtocol() {}
+
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
2016-03-01 08:33:06 +11:00
+ this.a = packetdataserializer.g();
2016-03-30 22:20:25 +01:00
+ this.hostname = packetdataserializer.e(255);
2015-07-30 17:22:16 +10:00
+ this.port = packetdataserializer.readUnsignedShort();
2016-03-01 08:33:06 +11:00
+ this.d = EnumProtocol.a(packetdataserializer.g());
2015-07-30 17:22:16 +10:00
+ }
+
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
2016-03-30 22:20:25 +01:00
+ packetdataserializer.d(this.a);
2015-07-30 17:22:16 +10:00
+ packetdataserializer.a(this.hostname);
+ packetdataserializer.writeShort(this.port);
2016-03-30 22:20:25 +01:00
+ packetdataserializer.d(this.d.a());
2015-07-30 17:22:16 +10:00
+ }
+
+ public void a(PacketHandshakingInListener packethandshakinginlistener) {
+ packethandshakinginlistener.a(this);
+ }
+
+ public EnumProtocol a() {
+ return this.d;
+ }
+
+ public int b() {
+ return this.a;
+ }
+}
2015-03-15 22:18:05 +00:00
diff --git a/src/main/java/net/minecraft/server/PacketPlayInArmAnimation.java b/src/main/java/net/minecraft/server/PacketPlayInArmAnimation.java
new file mode 100644
2016-03-01 08:33:06 +11:00
index 0000000..cb0356e
2015-03-15 22:18:05 +00:00
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayInArmAnimation.java
2016-03-01 08:33:06 +11:00
@@ -0,0 +1,30 @@
2015-03-15 22:18:05 +00:00
+package net.minecraft.server;
+
+import java.io.IOException;
+
+public class PacketPlayInArmAnimation implements Packet<PacketListenerPlayIn> {
+
2016-03-01 08:33:06 +11:00
+ private EnumHand a;
+
2015-03-15 22:18:05 +00:00
+ public PacketPlayInArmAnimation() {}
+
2016-03-01 08:33:06 +11:00
+ public PacketPlayInArmAnimation(EnumHand enumhand) {
+ this.a = enumhand;
+ }
+
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
+ this.a = (EnumHand) packetdataserializer.a(EnumHand.class);
+ }
2015-03-15 22:18:05 +00:00
+
2016-03-01 08:33:06 +11:00
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
+ packetdataserializer.a((Enum) this.a);
+ }
2015-03-15 22:18:05 +00:00
+
+ public void a(PacketListenerPlayIn packetlistenerplayin) {
+ packetlistenerplayin.a(this);
+ }
2016-03-01 08:33:06 +11:00
+
+ public EnumHand a() {
+ return this.a;
+ }
2015-03-15 22:18:05 +00:00
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayInBlockPlace.java b/src/main/java/net/minecraft/server/PacketPlayInBlockPlace.java
new file mode 100644
index 0000000..43310e8
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayInBlockPlace.java
@@ -0,0 +1,30 @@
+package net.minecraft.server;
+
+import java.io.IOException;
+
+public class PacketPlayInBlockPlace implements Packet<PacketListenerPlayIn> {
+
+ private EnumHand a;
+
+ public PacketPlayInBlockPlace() {}
+
+ public PacketPlayInBlockPlace(EnumHand enumhand) {
+ this.a = enumhand;
+ }
+
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
+ this.a = (EnumHand) packetdataserializer.a(EnumHand.class);
+ }
+
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
+ packetdataserializer.a((Enum) this.a);
+ }
+
+ public void a(PacketListenerPlayIn packetlistenerplayin) {
+ packetlistenerplayin.a(this);
+ }
+
+ public EnumHand a() {
+ return this.a;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayInChat.java b/src/main/java/net/minecraft/server/PacketPlayInChat.java
new file mode 100644
2016-11-17 12:41:12 +11:00
index 0000000..3dd4e28
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayInChat.java
2015-02-28 11:36:22 +00:00
@@ -0,0 +1,34 @@
+package net.minecraft.server;
+
2015-02-28 11:36:22 +00:00
+import java.io.IOException;
+
+public class PacketPlayInChat implements Packet<PacketListenerPlayIn> {
+
+ private String a;
+
+ public PacketPlayInChat() {}
+
+ public PacketPlayInChat(String s) {
2016-11-17 12:41:12 +11:00
+ if (s.length() > 256) {
+ s = s.substring(0, 256);
+ }
+
+ this.a = s;
+ }
+
2015-02-28 11:36:22 +00:00
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
2016-11-17 12:41:12 +11:00
+ this.a = packetdataserializer.e(256);
+ }
+
2015-02-28 11:36:22 +00:00
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
+ packetdataserializer.a(this.a);
+ }
+
+ public void a(PacketListenerPlayIn packetlistenerplayin) {
+ packetlistenerplayin.a(this);
+ }
+
+ public String a() {
+ return this.a;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayInUseItem.java b/src/main/java/net/minecraft/server/PacketPlayInUseItem.java
new file mode 100644
2016-11-17 12:41:12 +11:00
index 0000000..bdcda81
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayInUseItem.java
@@ -0,0 +1,61 @@
+package net.minecraft.server;
+
+import java.io.IOException;
+
+public class PacketPlayInUseItem implements Packet<PacketListenerPlayIn> {
+
+ private BlockPosition a;
+ private EnumDirection b;
+ private EnumHand c;
+ private float d;
+ private float e;
+ private float f;
+
+ public PacketPlayInUseItem() {}
+
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
+ this.a = packetdataserializer.e();
+ this.b = (EnumDirection) packetdataserializer.a(EnumDirection.class);
+ this.c = (EnumHand) packetdataserializer.a(EnumHand.class);
2016-11-17 12:41:12 +11:00
+ this.d = packetdataserializer.readFloat();
+ this.e = packetdataserializer.readFloat();
+ this.f = packetdataserializer.readFloat();
+ }
+
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
+ packetdataserializer.a(this.a);
+ packetdataserializer.a((Enum) this.b);
+ packetdataserializer.a((Enum) this.c);
2016-11-17 12:41:12 +11:00
+ packetdataserializer.writeFloat(this.d);
+ packetdataserializer.writeFloat(this.e);
+ packetdataserializer.writeFloat(this.f);
+ }
+
+ public void a(PacketListenerPlayIn packetlistenerplayin) {
+ packetlistenerplayin.a(this);
+ }
+
+ public BlockPosition a() {
+ return this.a;
+ }
+
+ public EnumDirection b() {
+ return this.b;
+ }
+
+ public EnumHand c() {
+ return this.c;
+ }
+
+ public float d() {
+ return this.d;
+ }
+
+ public float e() {
+ return this.e;
+ }
+
+ public float f() {
+ return this.f;
+ }
+}
2016-03-01 08:33:06 +11:00
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutChat.java b/src/main/java/net/minecraft/server/PacketPlayOutChat.java
new file mode 100644
2016-11-17 12:41:12 +11:00
index 0000000..24462f1
--- /dev/null
2016-03-01 08:33:06 +11:00
+++ b/src/main/java/net/minecraft/server/PacketPlayOutChat.java
2016-11-17 12:41:12 +11:00
@@ -0,0 +1,42 @@
+package net.minecraft.server;
+
2015-02-28 11:36:22 +00:00
+import java.io.IOException;
+
2016-03-01 08:33:06 +11:00
+public class PacketPlayOutChat implements Packet<PacketListenerPlayOut> {
+
2016-03-01 08:33:06 +11:00
+ private IChatBaseComponent a;
+ private byte b;
+
2016-03-01 08:33:06 +11:00
+ public PacketPlayOutChat() {}
+
2016-03-01 08:33:06 +11:00
+ public PacketPlayOutChat(IChatBaseComponent ichatbasecomponent) {
+ this(ichatbasecomponent, (byte) 1);
+ }
+
+ public PacketPlayOutChat(IChatBaseComponent ichatbasecomponent, byte b0) {
+ this.a = ichatbasecomponent;
+ this.b = b0;
+ }
+
2015-02-28 11:36:22 +00:00
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
2016-03-01 08:33:06 +11:00
+ this.a = packetdataserializer.f();
+ this.b = packetdataserializer.readByte();
+ }
+
2015-02-28 11:36:22 +00:00
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
2016-03-01 08:33:06 +11:00
+ packetdataserializer.a(this.a);
+ packetdataserializer.writeByte(this.b);
+ }
+
+ public void a(PacketListenerPlayOut packetlistenerplayout) {
+ packetlistenerplayout.a(this);
+ }
+
2016-03-01 08:33:06 +11:00
+ public boolean b() {
+ return this.b == 1 || this.b == 2;
+ }
2016-11-17 12:41:12 +11:00
+
+ public byte c() {
+ return this.b;
+ }
+}
2014-08-08 19:57:11 +10:00
diff --git a/src/main/java/net/minecraft/server/PersistentCollection.java b/src/main/java/net/minecraft/server/PersistentCollection.java
new file mode 100644
2016-06-09 11:43:56 +10:00
index 0000000..fe59b75
2014-08-08 19:57:11 +10:00
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PersistentCollection.java
2016-05-10 21:48:25 +10:00
@@ -0,0 +1,182 @@
2014-08-08 19:57:11 +10:00
+package net.minecraft.server;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
2014-08-08 19:57:11 +10:00
+import java.io.DataInputStream;
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
2016-05-10 21:48:25 +10:00
+import javax.annotation.Nullable;
2014-08-08 19:57:11 +10:00
+
+public class PersistentCollection {
+
2016-06-09 11:43:56 +10:00
+ private final IDataManager b;
2015-02-28 11:36:22 +00:00
+ protected Map<String, PersistentBase> a = Maps.newHashMap();
2016-06-09 11:43:56 +10:00
+ private final List<PersistentBase> c = Lists.newArrayList();
+ private final Map<String, Short> d = Maps.newHashMap();
2014-08-08 19:57:11 +10:00
+
+ public PersistentCollection(IDataManager idatamanager) {
+ this.b = idatamanager;
2014-08-08 19:57:11 +10:00
+ this.b();
+ }
+
2016-05-10 21:48:25 +10:00
+ @Nullable
2015-02-28 11:36:22 +00:00
+ public PersistentBase get(Class<? extends PersistentBase> oclass, String s) {
+ PersistentBase persistentbase = (PersistentBase) this.a.get(s);
2014-08-08 19:57:11 +10:00
+
+ if (persistentbase != null) {
+ return persistentbase;
+ } else {
+ if (this.b != null) {
2014-08-08 19:57:11 +10:00
+ try {
+ File file = this.b.getDataFile(s);
2014-08-08 19:57:11 +10:00
+
+ if (file != null && file.exists()) {
2014-08-08 19:57:11 +10:00
+ try {
+ persistentbase = (PersistentBase) oclass.getConstructor(new Class[] { String.class}).newInstance(new Object[] { s});
+ } catch (Exception exception) {
2016-06-09 11:43:56 +10:00
+ throw new RuntimeException("Failed to instantiate " + oclass, exception);
2014-08-08 19:57:11 +10:00
+ }
+
+ FileInputStream fileinputstream = new FileInputStream(file);
2014-08-08 19:57:11 +10:00
+ NBTTagCompound nbttagcompound = NBTCompressedStreamTools.a((InputStream) fileinputstream);
+
+ fileinputstream.close();
+ persistentbase.a(nbttagcompound.getCompound("data"));
+ }
+ } catch (Exception exception1) {
+ exception1.printStackTrace();
+ }
+ }
+
+ if (persistentbase != null) {
+ this.a.put(s, persistentbase);
2014-08-08 19:57:11 +10:00
+ this.c.add(persistentbase);
+ }
+
+ return persistentbase;
+ }
+ }
+
+ public void a(String s, PersistentBase persistentbase) {
+ if (this.a.containsKey(s)) {
+ this.c.remove(this.a.remove(s));
2014-08-08 19:57:11 +10:00
+ }
+
+ this.a.put(s, persistentbase);
+ this.c.add(persistentbase);
2014-08-08 19:57:11 +10:00
+ }
+
+ public void a() {
+ for (int i = 0; i < this.c.size(); ++i) {
+ PersistentBase persistentbase = (PersistentBase) this.c.get(i);
+
+ if (persistentbase.d()) {
+ this.a(persistentbase);
+ persistentbase.a(false);
+ }
+ }
+
2014-08-08 19:57:11 +10:00
+ }
+
+ private void a(PersistentBase persistentbase) {
+ if (this.b != null) {
2014-08-08 19:57:11 +10:00
+ try {
+ File file = this.b.getDataFile(persistentbase.id);
2014-08-08 19:57:11 +10:00
+
+ if (file != null) {
2014-08-08 19:57:11 +10:00
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+
2016-05-10 21:48:25 +10:00
+ nbttagcompound.set("data", persistentbase.b(new NBTTagCompound()));
+ FileOutputStream fileoutputstream = new FileOutputStream(file);
2014-08-08 19:57:11 +10:00
+
2016-05-10 21:48:25 +10:00
+ NBTCompressedStreamTools.a(nbttagcompound, (OutputStream) fileoutputstream);
2014-08-08 19:57:11 +10:00
+ fileoutputstream.close();
+ }
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+
2014-08-08 19:57:11 +10:00
+ }
+ }
+
+ private void b() {
+ try {
+ this.d.clear();
+ if (this.b == null) {
2014-08-08 19:57:11 +10:00
+ return;
+ }
+
+ File file = this.b.getDataFile("idcounts");
2014-08-08 19:57:11 +10:00
+
+ if (file != null && file.exists()) {
+ DataInputStream datainputstream = new DataInputStream(new FileInputStream(file));
2014-08-08 19:57:11 +10:00
+ NBTTagCompound nbttagcompound = NBTCompressedStreamTools.a(datainputstream);
+
+ datainputstream.close();
+ Iterator iterator = nbttagcompound.c().iterator();
+
+ while (iterator.hasNext()) {
+ String s = (String) iterator.next();
+ NBTBase nbtbase = nbttagcompound.get(s);
+
+ if (nbtbase instanceof NBTTagShort) {
+ NBTTagShort nbttagshort = (NBTTagShort) nbtbase;
2016-06-09 11:43:56 +10:00
+ short short0 = nbttagshort.f();
2014-08-08 19:57:11 +10:00
+
+ this.d.put(s, Short.valueOf(short0));
2014-08-08 19:57:11 +10:00
+ }
+ }
+ }
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+
2014-08-08 19:57:11 +10:00
+ }
+
+ public int a(String s) {
+ Short oshort = (Short) this.d.get(s);
+
+ if (oshort == null) {
+ oshort = Short.valueOf((short) 0);
+ } else {
+ oshort = Short.valueOf((short) (oshort.shortValue() + 1));
+ }
+
+ this.d.put(s, oshort);
+ if (this.b == null) {
2014-08-08 19:57:11 +10:00
+ return oshort.shortValue();
+ } else {
+ try {
+ File file = this.b.getDataFile("idcounts");
2014-08-08 19:57:11 +10:00
+
+ if (file != null) {
2014-08-08 19:57:11 +10:00
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ Iterator iterator = this.d.keySet().iterator();
+
+ while (iterator.hasNext()) {
+ String s1 = (String) iterator.next();
+
2016-03-01 08:33:06 +11:00
+ nbttagcompound.setShort(s1, ((Short) this.d.get(s1)).shortValue());
2014-08-08 19:57:11 +10:00
+ }
+
+ DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(file));
2014-08-08 19:57:11 +10:00
+
+ NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream);
+ dataoutputstream.close();
+ }
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+
+ return oshort.shortValue();
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/ServerConnection.java b/src/main/java/net/minecraft/server/ServerConnection.java
new file mode 100644
2016-11-17 12:41:12 +11:00
index 0000000..1abc6b6
--- /dev/null
+++ b/src/main/java/net/minecraft/server/ServerConnection.java
2016-05-10 21:48:25 +10:00
@@ -0,0 +1,174 @@
+package net.minecraft.server;
+
+import com.google.common.collect.Lists;
2015-02-28 11:36:22 +00:00
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import io.netty.bootstrap.ServerBootstrap;
2015-02-28 11:36:22 +00:00
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelException;
+import io.netty.channel.ChannelFuture;
2015-02-28 11:36:22 +00:00
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
2015-02-28 11:36:22 +00:00
+import io.netty.channel.epoll.Epoll;
+import io.netty.channel.epoll.EpollEventLoopGroup;
+import io.netty.channel.epoll.EpollServerSocketChannel;
+import io.netty.channel.local.LocalEventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
2015-02-28 11:36:22 +00:00
+import io.netty.handler.timeout.ReadTimeoutHandler;
+import io.netty.util.concurrent.Future;
+import io.netty.util.concurrent.GenericFutureListener;
2015-02-28 11:36:22 +00:00
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class ServerConnection {
+
2015-02-28 11:36:22 +00:00
+ private static final Logger e = LogManager.getLogger();
+ public static final LazyInitVar<NioEventLoopGroup> a = new LazyInitVar() {
+ protected NioEventLoopGroup a() {
+ return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Server IO #%d").setDaemon(true).build());
+ }
+
2015-02-28 11:36:22 +00:00
+ protected Object init() {
+ return this.a();
+ }
+ };
+ public static final LazyInitVar<EpollEventLoopGroup> b = new LazyInitVar() {
+ protected EpollEventLoopGroup a() {
+ return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).build());
+ }
+
2015-02-28 11:36:22 +00:00
+ protected Object init() {
+ return this.a();
+ }
+ };
+ public static final LazyInitVar<LocalEventLoopGroup> c = new LazyInitVar() {
+ protected LocalEventLoopGroup a() {
+ return new LocalEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Local Server IO #%d").setDaemon(true).build());
+ }
+
2015-02-28 11:36:22 +00:00
+ protected Object init() {
+ return this.a();
+ }
2015-02-28 11:36:22 +00:00
+ };
+ private final MinecraftServer f;
+ public volatile boolean d;
+ private final List<ChannelFuture> g = Collections.synchronizedList(Lists.<ChannelFuture>newArrayList());
+ private final List<NetworkManager> h = Collections.synchronizedList(Lists.<NetworkManager>newArrayList());
+
+ public ServerConnection(MinecraftServer minecraftserver) {
+ this.f = minecraftserver;
+ this.d = true;
+ }
+
2015-02-28 11:36:22 +00:00
+ public void a(InetAddress inetaddress, int i) throws IOException {
+ List list = this.g;
+
2015-02-28 11:36:22 +00:00
+ synchronized (this.g) {
+ Class oclass;
+ LazyInitVar lazyinitvar;
+
2016-11-17 12:41:12 +11:00
+ if (Epoll.isAvailable() && this.f.af()) {
2015-02-28 11:36:22 +00:00
+ oclass = EpollServerSocketChannel.class;
+ lazyinitvar = ServerConnection.b;
+ ServerConnection.e.info("Using epoll channel type");
+ } else {
+ oclass = NioServerSocketChannel.class;
+ lazyinitvar = ServerConnection.a;
+ ServerConnection.e.info("Using default channel type");
+ }
+
+ this.g.add(((ServerBootstrap) ((ServerBootstrap) (new ServerBootstrap()).channel(oclass)).childHandler(new ChannelInitializer() {
+ protected void initChannel(Channel channel) throws Exception {
+ try {
+ channel.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(true));
+ } catch (ChannelException channelexception) {
+ ;
+ }
+
+ channel.pipeline().addLast("timeout", new ReadTimeoutHandler(30)).addLast("legacy_query", new LegacyPingHandler(ServerConnection.this)).addLast("splitter", new PacketSplitter()).addLast("decoder", new PacketDecoder(EnumProtocolDirection.SERVERBOUND)).addLast("prepender", new PacketPrepender()).addLast("encoder", new PacketEncoder(EnumProtocolDirection.CLIENTBOUND));
+ NetworkManager networkmanager = new NetworkManager(EnumProtocolDirection.SERVERBOUND);
+
+ ServerConnection.this.h.add(networkmanager);
+ channel.pipeline().addLast("packet_handler", networkmanager);
2016-03-01 08:33:06 +11:00
+ networkmanager.setPacketListener(new HandshakeListener(ServerConnection.this.f, networkmanager));
2015-02-28 11:36:22 +00:00
+ }
+ }).group((EventLoopGroup) lazyinitvar.c()).localAddress(inetaddress, i)).bind().syncUninterruptibly());
+ }
+ }
+
+ public void b() {
+ this.d = false;
+ Iterator iterator = this.g.iterator();
+
+ while (iterator.hasNext()) {
+ ChannelFuture channelfuture = (ChannelFuture) iterator.next();
+
+ try {
+ channelfuture.channel().close().sync();
+ } catch (InterruptedException interruptedexception) {
2015-02-28 11:36:22 +00:00
+ ServerConnection.e.error("Interrupted whilst closing channel");
+ }
+ }
+
+ }
+
+ public void c() {
2015-02-28 11:36:22 +00:00
+ List list = this.h;
+
2015-02-28 11:36:22 +00:00
+ synchronized (this.h) {
+ Iterator iterator = this.h.iterator();
+
+ while (iterator.hasNext()) {
2015-02-28 11:36:22 +00:00
+ final NetworkManager networkmanager = (NetworkManager) iterator.next();
+
+ if (!networkmanager.h()) {
2016-03-01 08:33:06 +11:00
+ if (networkmanager.isConnected()) {
+ try {
+ networkmanager.a();
+ } catch (Exception exception) {
2016-03-01 08:33:06 +11:00
+ if (networkmanager.isLocal()) {
+ CrashReport crashreport = CrashReport.a(exception, "Ticking memory connection");
+ CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Ticking connection");
+
2016-05-10 21:48:25 +10:00
+ crashreportsystemdetails.a("Connection", new CrashReportCallable() {
2015-02-28 11:36:22 +00:00
+ public String a() throws Exception {
+ return networkmanager.toString();
+ }
+
+ public Object call() throws Exception {
+ return this.a();
+ }
+ });
+ throw new ReportedException(crashreport);
+ }
+
2016-06-09 11:43:56 +10:00
+ ServerConnection.e.warn("Failed to handle packet for {}", new Object[] { networkmanager.getSocketAddress(), exception});
2015-02-28 11:36:22 +00:00
+ final ChatComponentText chatcomponenttext = new ChatComponentText("Internal server error");
+
2016-03-01 08:33:06 +11:00
+ networkmanager.sendPacket(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener() {
2015-05-09 21:23:26 +01:00
+ public void operationComplete(Future future) throws Exception {
2015-02-28 11:36:22 +00:00
+ networkmanager.close(chatcomponenttext);
+ }
+ }, new GenericFutureListener[0]);
2016-03-01 08:33:06 +11:00
+ networkmanager.stopReading();
+ }
2016-03-01 08:33:06 +11:00
+ } else {
+ iterator.remove();
+ networkmanager.handleDisconnection();
+ }
+ }
+ }
+
+ }
+ }
+
+ public MinecraftServer d() {
2015-02-28 11:36:22 +00:00
+ return this.f;
+ }
+}
2014-01-08 22:00:00 +00:00
diff --git a/src/main/java/net/minecraft/server/ServerStatisticManager.java b/src/main/java/net/minecraft/server/ServerStatisticManager.java
new file mode 100644
2016-11-17 12:41:12 +11:00
index 0000000..277e98f
2014-01-08 22:00:00 +00:00
--- /dev/null
+++ b/src/main/java/net/minecraft/server/ServerStatisticManager.java
2015-02-28 11:36:22 +00:00
@@ -0,0 +1,212 @@
2014-01-08 22:00:00 +00:00
+package net.minecraft.server;
+
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonParser;
2014-01-08 22:00:00 +00:00
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import org.apache.commons.io.FileUtils;
2014-01-08 22:00:00 +00:00
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class ServerStatisticManager extends StatisticManager {
+
+ private static final Logger b = LogManager.getLogger();
+ private final MinecraftServer c;
+ private final File d;
2015-02-28 11:36:22 +00:00
+ private final Set<Statistic> e = Sets.newHashSet();
2014-01-08 22:00:00 +00:00
+ private int f = -300;
2016-06-09 11:43:56 +10:00
+ private boolean g;
2014-01-08 22:00:00 +00:00
+
+ public ServerStatisticManager(MinecraftServer minecraftserver, File file) {
2014-01-08 22:00:00 +00:00
+ this.c = minecraftserver;
+ this.d = file;
2014-01-08 22:00:00 +00:00
+ }
+
+ public void a() {
+ if (this.d.isFile()) {
+ try {
+ this.a.clear();
+ this.a.putAll(this.a(FileUtils.readFileToString(this.d)));
+ } catch (IOException ioexception) {
2016-06-09 11:43:56 +10:00
+ ServerStatisticManager.b.error("Couldn\'t read statistics file {}", new Object[] { this.d, ioexception});
2014-01-08 22:00:00 +00:00
+ } catch (JsonParseException jsonparseexception) {
2016-06-09 11:43:56 +10:00
+ ServerStatisticManager.b.error("Couldn\'t parse statistics file {}", new Object[] { this.d, jsonparseexception});
2014-01-08 22:00:00 +00:00
+ }
+ }
+
2014-01-08 22:00:00 +00:00
+ }
+
+ public void b() {
+ try {
+ FileUtils.writeStringToFile(this.d, a(this.a));
+ } catch (IOException ioexception) {
+ ServerStatisticManager.b.error("Couldn\'t save stats", ioexception);
2014-01-08 22:00:00 +00:00
+ }
+
2014-01-08 22:00:00 +00:00
+ }
+
2014-03-23 00:06:43 +00:00
+ public void setStatistic(EntityHuman entityhuman, Statistic statistic, int i) {
+ int j = statistic.d() ? this.getStatisticValue(statistic) : 0;
2014-01-08 22:00:00 +00:00
+
2014-03-23 00:06:43 +00:00
+ super.setStatistic(entityhuman, statistic, i);
2014-01-08 22:00:00 +00:00
+ this.e.add(statistic);
+ if (statistic.d() && j == 0 && i > 0) {
+ this.g = true;
2016-11-17 12:41:12 +11:00
+ if (this.c.ay()) {
2014-01-08 22:00:00 +00:00
+ this.c.getPlayerList().sendMessage(new ChatMessage("chat.type.achievement", new Object[] { entityhuman.getScoreboardDisplayName(), statistic.j()}));
+ }
+ }
+
+ if (statistic.d() && j > 0 && i == 0) {
+ this.g = true;
2016-11-17 12:41:12 +11:00
+ if (this.c.ay()) {
+ this.c.getPlayerList().sendMessage(new ChatMessage("chat.type.achievement.taken", new Object[] { entityhuman.getScoreboardDisplayName(), statistic.j()}));
+ }
+ }
+
2014-01-08 22:00:00 +00:00
+ }
+
2015-02-28 11:36:22 +00:00
+ public Set<Statistic> c() {
2014-01-08 22:00:00 +00:00
+ HashSet hashset = Sets.newHashSet(this.e);
+
+ this.e.clear();
+ this.g = false;
+ return hashset;
+ }
+
2015-02-28 11:36:22 +00:00
+ public Map<Statistic, StatisticWrapper> a(String s) {
2014-01-08 22:00:00 +00:00
+ JsonElement jsonelement = (new JsonParser()).parse(s);
+
+ if (!jsonelement.isJsonObject()) {
+ return Maps.newHashMap();
+ } else {
+ JsonObject jsonobject = jsonelement.getAsJsonObject();
+ HashMap hashmap = Maps.newHashMap();
+ Iterator iterator = jsonobject.entrySet().iterator();
+
+ while (iterator.hasNext()) {
+ Entry entry = (Entry) iterator.next();
2014-03-23 00:06:43 +00:00
+ Statistic statistic = StatisticList.getStatistic((String) entry.getKey());
2014-01-08 22:00:00 +00:00
+
+ if (statistic != null) {
+ StatisticWrapper statisticwrapper = new StatisticWrapper();
+
+ if (((JsonElement) entry.getValue()).isJsonPrimitive() && ((JsonElement) entry.getValue()).getAsJsonPrimitive().isNumber()) {
+ statisticwrapper.a(((JsonElement) entry.getValue()).getAsInt());
+ } else if (((JsonElement) entry.getValue()).isJsonObject()) {
+ JsonObject jsonobject1 = ((JsonElement) entry.getValue()).getAsJsonObject();
+
+ if (jsonobject1.has("value") && jsonobject1.get("value").isJsonPrimitive() && jsonobject1.get("value").getAsJsonPrimitive().isNumber()) {
+ statisticwrapper.a(jsonobject1.getAsJsonPrimitive("value").getAsInt());
+ }
+
+ if (jsonobject1.has("progress") && statistic.l() != null) {
+ try {
+ Constructor constructor = statistic.l().getConstructor(new Class[0]);
+ IJsonStatistic ijsonstatistic = (IJsonStatistic) constructor.newInstance(new Object[0]);
+
2014-03-23 00:06:43 +00:00
+ ijsonstatistic.a(jsonobject1.get("progress"));
2014-01-08 22:00:00 +00:00
+ statisticwrapper.a(ijsonstatistic);
+ } catch (Throwable throwable) {
2016-06-09 11:43:56 +10:00
+ ServerStatisticManager.b.warn("Invalid statistic progress in {}", new Object[] { this.d, throwable});
2014-01-08 22:00:00 +00:00
+ }
+ }
+ }
+
+ hashmap.put(statistic, statisticwrapper);
+ } else {
2016-06-09 11:43:56 +10:00
+ ServerStatisticManager.b.warn("Invalid statistic in {}: Don\'t know what {} is", new Object[] { this.d, entry.getKey()});
2014-01-08 22:00:00 +00:00
+ }
+ }
+
+ return hashmap;
+ }
+ }
+
2015-02-28 11:36:22 +00:00
+ public static String a(Map<Statistic, StatisticWrapper> map) {
2014-01-08 22:00:00 +00:00
+ JsonObject jsonobject = new JsonObject();
+ Iterator iterator = map.entrySet().iterator();
+
+ while (iterator.hasNext()) {
+ Entry entry = (Entry) iterator.next();
+
+ if (((StatisticWrapper) entry.getValue()).b() != null) {
+ JsonObject jsonobject1 = new JsonObject();
+
+ jsonobject1.addProperty("value", Integer.valueOf(((StatisticWrapper) entry.getValue()).a()));
+
+ try {
+ jsonobject1.add("progress", ((StatisticWrapper) entry.getValue()).b().a());
+ } catch (Throwable throwable) {
2016-06-09 11:43:56 +10:00
+ ServerStatisticManager.b.warn("Couldn\'t save statistic {}: error serializing progress", new Object[] { ((Statistic) entry.getKey()).e(), throwable});
2014-01-08 22:00:00 +00:00
+ }
+
2014-03-23 00:06:43 +00:00
+ jsonobject.add(((Statistic) entry.getKey()).name, jsonobject1);
2014-01-08 22:00:00 +00:00
+ } else {
2014-03-23 00:06:43 +00:00
+ jsonobject.addProperty(((Statistic) entry.getKey()).name, Integer.valueOf(((StatisticWrapper) entry.getValue()).a()));
2014-01-08 22:00:00 +00:00
+ }
+ }
+
+ return jsonobject.toString();
+ }
+
+ public void d() {
+ Iterator iterator = this.a.keySet().iterator();
+
+ while (iterator.hasNext()) {
+ Statistic statistic = (Statistic) iterator.next();
+
+ this.e.add(statistic);
+ }
+
2014-01-08 22:00:00 +00:00
+ }
+
+ public void a(EntityPlayer entityplayer) {
2016-11-17 12:41:12 +11:00
+ int i = this.c.aq();
2014-01-08 22:00:00 +00:00
+ HashMap hashmap = Maps.newHashMap();
+
+ if (this.g || i - this.f > 300) {
+ this.f = i;
+ Iterator iterator = this.c().iterator();
+
+ while (iterator.hasNext()) {
+ Statistic statistic = (Statistic) iterator.next();
+
2014-03-23 00:06:43 +00:00
+ hashmap.put(statistic, Integer.valueOf(this.getStatisticValue(statistic)));
2014-01-08 22:00:00 +00:00
+ }
+ }
+
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutStatistic(hashmap));
+ }
+
2014-03-23 00:06:43 +00:00
+ public void updateStatistics(EntityPlayer entityplayer) {
2014-01-08 22:00:00 +00:00
+ HashMap hashmap = Maps.newHashMap();
+ Iterator iterator = AchievementList.e.iterator();
+
+ while (iterator.hasNext()) {
+ Achievement achievement = (Achievement) iterator.next();
+
2014-07-09 10:23:19 +10:00
+ if (this.hasAchievement(achievement)) {
2014-03-23 00:06:43 +00:00
+ hashmap.put(achievement, Integer.valueOf(this.getStatisticValue(achievement)));
2014-01-08 22:00:00 +00:00
+ this.e.remove(achievement);
+ }
+ }
+
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutStatistic(hashmap));
+ }
+
+ public boolean e() {
+ return this.g;
+ }
+}
2016-11-17 12:41:12 +11:00
diff --git a/src/main/java/net/minecraft/server/StructureGenerator.java b/src/main/java/net/minecraft/server/StructureGenerator.java
new file mode 100644
index 0000000..0aaf72f
--- /dev/null
+++ b/src/main/java/net/minecraft/server/StructureGenerator.java
@@ -0,0 +1,240 @@
+package net.minecraft.server;
+
+import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
+import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectIterator;
+import java.util.Iterator;
+import java.util.Random;
+import javax.annotation.Nullable;
+
+public abstract class StructureGenerator extends WorldGenBase {
+
+ private PersistentStructure a;
+ protected Long2ObjectMap<StructureStart> c = new Long2ObjectOpenHashMap(1024);
+
+ public StructureGenerator() {}
+
+ public abstract String a();
+
+ protected final synchronized void a(World world, final int i, final int j, int k, int l, ChunkSnapshot chunksnapshot) {
+ this.a(world);
+ if (!this.c.containsKey(ChunkCoordIntPair.a(i, j))) {
+ this.f.nextInt();
+
+ try {
+ if (this.a(i, j)) {
+ StructureStart structurestart = this.b(i, j);
+
+ this.c.put(ChunkCoordIntPair.a(i, j), structurestart);
+ if (structurestart.a()) {
+ this.a(i, j, structurestart);
+ }
+ }
+
+ } catch (Throwable throwable) {
+ CrashReport crashreport = CrashReport.a(throwable, "Exception preparing structure feature");
+ CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Feature being prepared");
+
+ crashreportsystemdetails.a("Is feature chunk", new CrashReportCallable() {
+ public String a() throws Exception {
+ return StructureGenerator.this.a(i, j) ? "True" : "False";
+ }
+
+ public Object call() throws Exception {
+ return this.a();
+ }
+ });
+ crashreportsystemdetails.a("Chunk location", (Object) String.format("%d,%d", new Object[] { Integer.valueOf(i), Integer.valueOf(j)}));
+ crashreportsystemdetails.a("Chunk pos hash", new CrashReportCallable() {
+ public String a() throws Exception {
+ return String.valueOf(ChunkCoordIntPair.a(i, j));
+ }
+
+ public Object call() throws Exception {
+ return this.a();
+ }
+ });
+ crashreportsystemdetails.a("Structure type", new CrashReportCallable() {
+ public String a() throws Exception {
+ return StructureGenerator.this.getClass().getCanonicalName();
+ }
+
+ public Object call() throws Exception {
+ return this.a();
+ }
+ });
+ throw new ReportedException(crashreport);
+ }
+ }
+ }
+
+ public synchronized boolean a(World world, Random random, ChunkCoordIntPair chunkcoordintpair) {
+ this.a(world);
+ int i = (chunkcoordintpair.x << 4) + 8;
+ int j = (chunkcoordintpair.z << 4) + 8;
+ boolean flag = false;
+ ObjectIterator objectiterator = this.c.values().iterator();
+
+ while (objectiterator.hasNext()) {
+ StructureStart structurestart = (StructureStart) objectiterator.next();
+
+ if (structurestart.a() && structurestart.a(chunkcoordintpair) && structurestart.b().a(i, j, i + 15, j + 15)) {
+ structurestart.a(world, random, new StructureBoundingBox(i, j, i + 15, j + 15));
+ structurestart.b(chunkcoordintpair);
+ flag = true;
+ this.a(structurestart.e(), structurestart.f(), structurestart);
+ }
+ }
+
+ return flag;
+ }
+
+ public boolean b(BlockPosition blockposition) {
+ this.a(this.g);
+ return this.c(blockposition) != null;
+ }
+
+ @Nullable
+ protected StructureStart c(BlockPosition blockposition) {
+ ObjectIterator objectiterator = this.c.values().iterator();
+
+ while (objectiterator.hasNext()) {
+ StructureStart structurestart = (StructureStart) objectiterator.next();
+
+ if (structurestart.a() && structurestart.b().b((BaseBlockPosition) blockposition)) {
+ Iterator iterator = structurestart.c().iterator();
+
+ while (iterator.hasNext()) {
+ StructurePiece structurepiece = (StructurePiece) iterator.next();
+
+ if (structurepiece.d().b((BaseBlockPosition) blockposition)) {
+ return structurestart;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public boolean a(World world, BlockPosition blockposition) {
+ this.a(world);
+ ObjectIterator objectiterator = this.c.values().iterator();
+
+ StructureStart structurestart;
+
+ do {
+ if (!objectiterator.hasNext()) {
+ return false;
+ }
+
+ structurestart = (StructureStart) objectiterator.next();
+ } while (!structurestart.a() || !structurestart.b().b((BaseBlockPosition) blockposition));
+
+ return true;
+ }
+
+ @Nullable
+ public abstract BlockPosition getNearestGeneratedFeature(World world, BlockPosition blockposition, boolean flag);
+
+ protected void a(World world) {
+ if (this.a == null) {
+ this.a = (PersistentStructure) world.a(PersistentStructure.class, this.a());
+ if (this.a == null) {
+ this.a = new PersistentStructure(this.a());
+ world.a(this.a(), (PersistentBase) this.a);
+ } else {
+ NBTTagCompound nbttagcompound = this.a.a();
+ Iterator iterator = nbttagcompound.c().iterator();
+
+ while (iterator.hasNext()) {
+ String s = (String) iterator.next();
+ NBTBase nbtbase = nbttagcompound.get(s);
+
+ if (nbtbase.getTypeId() == 10) {
+ NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbtbase;
+
+ if (nbttagcompound1.hasKey("ChunkX") && nbttagcompound1.hasKey("ChunkZ")) {
+ int i = nbttagcompound1.getInt("ChunkX");
+ int j = nbttagcompound1.getInt("ChunkZ");
+ StructureStart structurestart = WorldGenFactory.a(nbttagcompound1, world);
+
+ if (structurestart != null) {
+ this.c.put(ChunkCoordIntPair.a(i, j), structurestart);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ private void a(int i, int j, StructureStart structurestart) {
+ this.a.a(structurestart.a(i, j), i, j);
+ this.a.c();
+ }
+
+ protected abstract boolean a(int i, int j);
+
+ protected abstract StructureStart b(int i, int j);
+
+ protected static BlockPosition a(World world, StructureGenerator structuregenerator, BlockPosition blockposition, int i, int j, int k, boolean flag, int l, boolean flag1) {
+ int i1 = blockposition.getX() >> 4;
+ int j1 = blockposition.getZ() >> 4;
+ int k1 = 0;
+
+ for (Random random = new Random(); k1 <= l; ++k1) {
+ for (int l1 = -k1; l1 <= k1; ++l1) {
+ boolean flag2 = l1 == -k1 || l1 == k1;
+
+ for (int i2 = -k1; i2 <= k1; ++i2) {
+ boolean flag3 = i2 == -k1 || i2 == k1;
+
+ if (flag2 || flag3) {
+ int j2 = i1 + i * l1;
+ int k2 = j1 + i * i2;
+
+ if (j2 < 0) {
+ j2 -= i - 1;
+ }
+
+ if (k2 < 0) {
+ k2 -= i - 1;
+ }
+
+ int l2 = j2 / i;
+ int i3 = k2 / i;
+ Random random1 = world.a(l2, i3, k);
+
+ l2 *= i;
+ i3 *= i;
+ if (flag) {
+ l2 += (random1.nextInt(i - j) + random1.nextInt(i - j)) / 2;
+ i3 += (random1.nextInt(i - j) + random1.nextInt(i - j)) / 2;
+ } else {
+ l2 += random1.nextInt(i - j);
+ i3 += random1.nextInt(i - j);
+ }
+
+ WorldGenBase.a(world.getSeed(), random, l2, i3);
+ random.nextInt();
+ if (structuregenerator.a(l2, i3)) {
+ if (!flag1 || !world.b(l2, i3)) {
+ return new BlockPosition((l2 << 4) + 8, 64, (i3 << 4) + 8);
+ }
+ } else if (k1 == 0) {
+ break;
+ }
+ }
+ }
+
+ if (k1 == 0) {
+ break;
+ }
+ }
+ }
+
+ return null;
+ }
+}
2016-07-12 20:30:14 +10:00
diff --git a/src/main/java/net/minecraft/server/TileEntitySkull.java b/src/main/java/net/minecraft/server/TileEntitySkull.java
new file mode 100644
2016-11-17 12:41:12 +11:00
index 0000000..6e91a22
2016-07-12 20:30:14 +10:00
--- /dev/null
+++ b/src/main/java/net/minecraft/server/TileEntitySkull.java
@@ -0,0 +1,152 @@
+package net.minecraft.server;
+
+import com.google.common.collect.Iterables;
+import com.mojang.authlib.GameProfile;
+import com.mojang.authlib.minecraft.MinecraftSessionService;
+import com.mojang.authlib.properties.Property;
+import java.util.UUID;
+import javax.annotation.Nullable;
+
+public class TileEntitySkull extends TileEntity implements ITickable {
+
+ private int a;
+ public int rotation;
+ private GameProfile g;
+ private int h;
+ private boolean i;
+ private static UserCache j;
+ private static MinecraftSessionService k;
+
+ public TileEntitySkull() {}
+
+ public static void a(UserCache usercache) {
+ TileEntitySkull.j = usercache;
+ }
+
+ public static void a(MinecraftSessionService minecraftsessionservice) {
+ TileEntitySkull.k = minecraftsessionservice;
+ }
+
+ public NBTTagCompound save(NBTTagCompound nbttagcompound) {
+ super.save(nbttagcompound);
+ nbttagcompound.setByte("SkullType", (byte) (this.a & 255));
+ nbttagcompound.setByte("Rot", (byte) (this.rotation & 255));
+ if (this.g != null) {
+ NBTTagCompound nbttagcompound1 = new NBTTagCompound();
+
+ GameProfileSerializer.serialize(nbttagcompound1, this.g);
+ nbttagcompound.set("Owner", nbttagcompound1);
+ }
+
+ return nbttagcompound;
+ }
+
+ public void a(NBTTagCompound nbttagcompound) {
+ super.a(nbttagcompound);
+ this.a = nbttagcompound.getByte("SkullType");
+ this.rotation = nbttagcompound.getByte("Rot");
+ if (this.a == 3) {
+ if (nbttagcompound.hasKeyOfType("Owner", 10)) {
+ this.g = GameProfileSerializer.deserialize(nbttagcompound.getCompound("Owner"));
+ } else if (nbttagcompound.hasKeyOfType("ExtraType", 8)) {
+ String s = nbttagcompound.getString("ExtraType");
+
+ if (!UtilColor.b(s)) {
+ this.g = new GameProfile((UUID) null, s);
+ this.h();
+ }
+ }
+ }
+
+ }
+
2016-11-17 12:41:12 +11:00
+ public void F_() {
2016-07-12 20:30:14 +10:00
+ if (this.a == 5) {
+ if (this.world.isBlockIndirectlyPowered(this.position)) {
+ this.i = true;
+ ++this.h;
+ } else {
+ this.i = false;
+ }
+ }
+
+ }
+
+ @Nullable
+ public GameProfile getGameProfile() {
+ return this.g;
+ }
+
+ @Nullable
+ public PacketPlayOutTileEntityData getUpdatePacket() {
2016-11-17 12:41:12 +11:00
+ return new PacketPlayOutTileEntityData(this.position, 4, this.d());
2016-07-12 20:30:14 +10:00
+ }
+
2016-11-17 12:41:12 +11:00
+ public NBTTagCompound d() {
2016-07-12 20:30:14 +10:00
+ return this.save(new NBTTagCompound());
+ }
+
+ public void setSkullType(int i) {
+ this.a = i;
+ this.g = null;
+ }
+
+ public void setGameProfile(@Nullable GameProfile gameprofile) {
+ this.a = 3;
+ this.g = gameprofile;
+ this.h();
+ }
+
+ private void h() {
+ this.g = b(this.g);
+ this.update();
+ }
+
+ public static GameProfile b(GameProfile gameprofile) {
+ if (gameprofile != null && !UtilColor.b(gameprofile.getName())) {
+ if (gameprofile.isComplete() && gameprofile.getProperties().containsKey("textures")) {
+ return gameprofile;
+ } else if (TileEntitySkull.j != null && TileEntitySkull.k != null) {
+ GameProfile gameprofile1 = TileEntitySkull.j.getProfile(gameprofile.getName());
+
+ if (gameprofile1 == null) {
+ return gameprofile;
+ } else {
+ Property property = (Property) Iterables.getFirst(gameprofile1.getProperties().get("textures"), (Object) null);
+
+ if (property == null) {
+ gameprofile1 = TileEntitySkull.k.fillProfileProperties(gameprofile1, true);
+ }
+
+ return gameprofile1;
+ }
+ } else {
+ return gameprofile;
+ }
+ } else {
+ return gameprofile;
+ }
+ }
+
+ public int getSkullType() {
+ return this.a;
+ }
+
+ public void setRotation(int i) {
+ this.rotation = i;
+ }
+
+ public void a(EnumBlockMirror enumblockmirror) {
+ if (this.world != null && this.world.getType(this.getPosition()).get(BlockSkull.FACING) == EnumDirection.UP) {
+ this.rotation = enumblockmirror.a(this.rotation, 16);
+ }
+
+ }
+
+ public void a(EnumBlockRotation enumblockrotation) {
+ if (this.world != null && this.world.getType(this.getPosition()).get(BlockSkull.FACING) == EnumDirection.UP) {
+ this.rotation = enumblockrotation.a(this.rotation, 16);
+ }
+
+ }
+}
diff --git a/src/main/java/net/minecraft/server/WorldGenLargeFeature.java b/src/main/java/net/minecraft/server/WorldGenLargeFeature.java
new file mode 100644
2016-11-17 12:41:12 +11:00
index 0000000..5781a17
--- /dev/null
+++ b/src/main/java/net/minecraft/server/WorldGenLargeFeature.java
2016-11-17 12:41:12 +11:00
@@ -0,0 +1,144 @@
+package net.minecraft.server;
+
+import com.google.common.collect.Lists;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Map.Entry;
+
+public class WorldGenLargeFeature extends StructureGenerator {
+
2016-03-01 08:33:06 +11:00
+ private static final List<BiomeBase> a = Arrays.asList(new BiomeBase[] { Biomes.d, Biomes.s, Biomes.w, Biomes.x, Biomes.h, Biomes.n, Biomes.F});
2016-06-09 11:43:56 +10:00
+ private final List<BiomeBase.BiomeMeta> b;
2016-03-01 08:33:06 +11:00
+ private int d;
2016-06-09 11:43:56 +10:00
+ private final int h;
+
+ public WorldGenLargeFeature() {
2016-03-01 08:33:06 +11:00
+ this.b = Lists.newArrayList();
+ this.d = 32;
+ this.h = 8;
2016-03-01 08:33:06 +11:00
+ this.b.add(new BiomeBase.BiomeMeta(EntityWitch.class, 1, 1, 1));
+ }
+
2015-02-28 11:36:22 +00:00
+ public WorldGenLargeFeature(Map<String, String> map) {
+ this();
+ Iterator iterator = map.entrySet().iterator();
+
+ while (iterator.hasNext()) {
+ Entry entry = (Entry) iterator.next();
+
+ if (((String) entry.getKey()).equals("distance")) {
2016-06-09 11:43:56 +10:00
+ this.d = MathHelper.a((String) entry.getValue(), this.d, 9);
+ }
+ }
+
+ }
+
+ public String a() {
+ return "Temple";
+ }
+
+ protected boolean a(int i, int j) {
+ int k = i;
+ int l = j;
+
+ if (i < 0) {
2016-03-01 08:33:06 +11:00
+ i -= this.d - 1;
+ }
+
+ if (j < 0) {
2016-03-01 08:33:06 +11:00
+ j -= this.d - 1;
+ }
+
2016-03-01 08:33:06 +11:00
+ int i1 = i / this.d;
+ int j1 = j / this.d;
+ Random random = this.g.a(i1, j1, 14357617);
+
2016-03-01 08:33:06 +11:00
+ i1 *= this.d;
+ j1 *= this.d;
2016-06-09 11:43:56 +10:00
+ i1 += random.nextInt(this.d - 8);
+ j1 += random.nextInt(this.d - 8);
+ if (k == i1 && l == j1) {
2016-03-01 08:33:06 +11:00
+ BiomeBase biomebase = this.g.getWorldChunkManager().getBiome(new BlockPosition(k * 16 + 8, 0, l * 16 + 8));
+
+ if (biomebase == null) {
+ return false;
+ }
+
2016-03-01 08:33:06 +11:00
+ Iterator iterator = WorldGenLargeFeature.a.iterator();
+
+ while (iterator.hasNext()) {
+ BiomeBase biomebase1 = (BiomeBase) iterator.next();
+
+ if (biomebase == biomebase1) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
2016-11-17 12:41:12 +11:00
+ public BlockPosition getNearestGeneratedFeature(World world, BlockPosition blockposition, boolean flag) {
+ this.g = world;
+ return a(world, this, blockposition, this.d, 8, 14357617, false, 100, flag);
+ }
+
+ protected StructureStart b(int i, int j) {
2016-03-01 08:33:06 +11:00
+ return new WorldGenLargeFeature.WorldGenLargeFeatureStart(this.g, this.f, i, j);
+ }
+
+ public boolean a(BlockPosition blockposition) {
+ StructureStart structurestart = this.c(blockposition);
+
2015-02-28 11:36:22 +00:00
+ if (structurestart != null && structurestart instanceof WorldGenLargeFeature.WorldGenLargeFeatureStart && !structurestart.a.isEmpty()) {
2016-03-01 08:33:06 +11:00
+ StructurePiece structurepiece = (StructurePiece) structurestart.a.get(0);
+
2015-02-28 11:36:22 +00:00
+ return structurepiece instanceof WorldGenRegistration.WorldGenWitchHut;
+ } else {
+ return false;
+ }
+ }
+
2015-02-28 11:36:22 +00:00
+ public List<BiomeBase.BiomeMeta> b() {
2016-03-01 08:33:06 +11:00
+ return this.b;
+ }
+
2015-02-28 11:36:22 +00:00
+ public static class WorldGenLargeFeatureStart extends StructureStart {
+
+ public WorldGenLargeFeatureStart() {}
+
+ public WorldGenLargeFeatureStart(World world, Random random, int i, int j) {
2016-03-01 08:33:06 +11:00
+ this(world, random, i, j, world.getBiome(new BlockPosition(i * 16 + 8, 0, j * 16 + 8)));
+ }
2015-02-28 11:36:22 +00:00
+
2016-03-01 08:33:06 +11:00
+ public WorldGenLargeFeatureStart(World world, Random random, int i, int j, BiomeBase biomebase) {
+ super(i, j);
+ if (biomebase != Biomes.w && biomebase != Biomes.x) {
+ if (biomebase == Biomes.h) {
2015-02-28 11:36:22 +00:00
+ WorldGenRegistration.WorldGenWitchHut worldgenregistration_worldgenwitchhut = new WorldGenRegistration.WorldGenWitchHut(random, i * 16, j * 16);
+
+ this.a.add(worldgenregistration_worldgenwitchhut);
2016-03-01 08:33:06 +11:00
+ } else if (biomebase != Biomes.d && biomebase != Biomes.s) {
+ if (biomebase == Biomes.n || biomebase == Biomes.F) {
+ WorldGenRegistration.b worldgenregistration_b = new WorldGenRegistration.b(random, i * 16, j * 16);
+
+ this.a.add(worldgenregistration_b);
+ }
+ } else {
2015-02-28 11:36:22 +00:00
+ WorldGenRegistration.WorldGenPyramidPiece worldgenregistration_worldgenpyramidpiece = new WorldGenRegistration.WorldGenPyramidPiece(random, i * 16, j * 16);
+
+ this.a.add(worldgenregistration_worldgenpyramidpiece);
+ }
+ } else {
+ WorldGenRegistration.WorldGenJungleTemple worldgenregistration_worldgenjungletemple = new WorldGenRegistration.WorldGenJungleTemple(random, i * 16, j * 16);
+
+ this.a.add(worldgenregistration_worldgenjungletemple);
+ }
+
2016-03-01 08:33:06 +11:00
+ this.d();
2015-02-28 11:36:22 +00:00
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/WorldGenVillage.java b/src/main/java/net/minecraft/server/WorldGenVillage.java
new file mode 100644
2016-11-17 12:41:12 +11:00
index 0000000..11a6ef7
--- /dev/null
+++ b/src/main/java/net/minecraft/server/WorldGenVillage.java
2016-11-17 12:41:12 +11:00
@@ -0,0 +1,143 @@
+package net.minecraft.server;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Map.Entry;
+
+public class WorldGenVillage extends StructureGenerator {
+
2016-06-09 11:43:56 +10:00
+ public static final List<BiomeBase> a = Arrays.asList(new BiomeBase[] { Biomes.c, Biomes.d, Biomes.K, Biomes.g});
2016-03-01 08:33:06 +11:00
+ private int b;
+ private int d;
2016-06-09 11:43:56 +10:00
+ private final int h;
+
+ public WorldGenVillage() {
2016-03-01 08:33:06 +11:00
+ this.d = 32;
+ this.h = 8;
+ }
+
2015-02-28 11:36:22 +00:00
+ public WorldGenVillage(Map<String, String> map) {
+ this();
+ Iterator iterator = map.entrySet().iterator();
+
+ while (iterator.hasNext()) {
+ Entry entry = (Entry) iterator.next();
+
+ if (((String) entry.getKey()).equals("size")) {
2016-03-01 08:33:06 +11:00
+ this.b = MathHelper.a((String) entry.getValue(), this.b, 0);
+ } else if (((String) entry.getKey()).equals("distance")) {
2016-06-09 11:43:56 +10:00
+ this.d = MathHelper.a((String) entry.getValue(), this.d, 9);
+ }
+ }
+
+ }
+
+ public String a() {
+ return "Village";
+ }
+
+ protected boolean a(int i, int j) {
+ int k = i;
+ int l = j;
+
+ if (i < 0) {
2016-03-01 08:33:06 +11:00
+ i -= this.d - 1;
+ }
+
+ if (j < 0) {
2016-03-01 08:33:06 +11:00
+ j -= this.d - 1;
+ }
+
2016-03-01 08:33:06 +11:00
+ int i1 = i / this.d;
+ int j1 = j / this.d;
+ Random random = this.g.a(i1, j1, 10387312);
+
2016-03-01 08:33:06 +11:00
+ i1 *= this.d;
+ j1 *= this.d;
2016-06-09 11:43:56 +10:00
+ i1 += random.nextInt(this.d - 8);
+ j1 += random.nextInt(this.d - 8);
+ if (k == i1 && l == j1) {
2016-03-01 08:33:06 +11:00
+ boolean flag = this.g.getWorldChunkManager().a(k * 16 + 8, l * 16 + 8, 0, WorldGenVillage.a);
+
+ if (flag) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
2016-11-17 12:41:12 +11:00
+ public BlockPosition getNearestGeneratedFeature(World world, BlockPosition blockposition, boolean flag) {
+ this.g = world;
+ return a(world, this, blockposition, this.d, 8, 10387312, false, 100, flag);
+ }
+
+ protected StructureStart b(int i, int j) {
2016-03-01 08:33:06 +11:00
+ return new WorldGenVillage.WorldGenVillageStart(this.g, this.f, i, j, this.b);
+ }
+
2015-02-28 11:36:22 +00:00
+ public static class WorldGenVillageStart extends StructureStart {
+
+ private boolean c;
+
+ public WorldGenVillageStart() {}
+
+ public WorldGenVillageStart(World world, Random random, int i, int j, int k) {
+ super(i, j);
+ List list = WorldGenVillagePieces.a(random, k);
+ WorldGenVillagePieces.WorldGenVillageStartPiece worldgenvillagepieces_worldgenvillagestartpiece = new WorldGenVillagePieces.WorldGenVillageStartPiece(world.getWorldChunkManager(), 0, random, (i << 4) + 2, (j << 4) + 2, list, k);
+
+ this.a.add(worldgenvillagepieces_worldgenvillagestartpiece);
2016-03-01 08:33:06 +11:00
+ worldgenvillagepieces_worldgenvillagestartpiece.a((StructurePiece) worldgenvillagepieces_worldgenvillagestartpiece, this.a, random);
2016-06-09 11:43:56 +10:00
+ List list1 = worldgenvillagepieces_worldgenvillagestartpiece.f;
+ List list2 = worldgenvillagepieces_worldgenvillagestartpiece.e;
2015-02-28 11:36:22 +00:00
+
+ int l;
+
+ while (!list1.isEmpty() || !list2.isEmpty()) {
+ StructurePiece structurepiece;
+
+ if (list1.isEmpty()) {
+ l = random.nextInt(list2.size());
+ structurepiece = (StructurePiece) list2.remove(l);
2016-03-01 08:33:06 +11:00
+ structurepiece.a((StructurePiece) worldgenvillagepieces_worldgenvillagestartpiece, this.a, random);
2015-02-28 11:36:22 +00:00
+ } else {
+ l = random.nextInt(list1.size());
+ structurepiece = (StructurePiece) list1.remove(l);
2016-03-01 08:33:06 +11:00
+ structurepiece.a((StructurePiece) worldgenvillagepieces_worldgenvillagestartpiece, this.a, random);
2015-02-28 11:36:22 +00:00
+ }
+ }
+
2016-03-01 08:33:06 +11:00
+ this.d();
2015-02-28 11:36:22 +00:00
+ l = 0;
+ Iterator iterator = this.a.iterator();
+
+ while (iterator.hasNext()) {
+ StructurePiece structurepiece1 = (StructurePiece) iterator.next();
+
+ if (!(structurepiece1 instanceof WorldGenVillagePieces.WorldGenVillageRoadPiece)) {
+ ++l;
+ }
+ }
+
+ this.c = l > 2;
+ }
+
2016-03-01 08:33:06 +11:00
+ public boolean a() {
2015-02-28 11:36:22 +00:00
+ return this.c;
+ }
+
+ public void a(NBTTagCompound nbttagcompound) {
+ super.a(nbttagcompound);
+ nbttagcompound.setBoolean("Valid", this.c);
+ }
+
+ public void b(NBTTagCompound nbttagcompound) {
+ super.b(nbttagcompound);
+ this.c = nbttagcompound.getBoolean("Valid");
+ }
+ }
+}
diff --git a/src/main/java/org/spigotmc/SneakyThrow.java b/src/main/java/org/spigotmc/SneakyThrow.java
new file mode 100644
index 0000000..31fc0a9
--- /dev/null
+++ b/src/main/java/org/spigotmc/SneakyThrow.java
@@ -0,0 +1,15 @@
+package org.spigotmc;
+
+public class SneakyThrow
+{
+
+ public static void sneaky(Throwable t)
+ {
+ throw SneakyThrow.<RuntimeException>superSneaky( t );
+ }
+
+ private static <T extends Throwable> T superSneaky(Throwable t) throws T
+ {
+ throw (T) t;
+ }
+}
--
2016-11-17 12:41:12 +11:00
2.9.3