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

4230 Zeilen
152 KiB
Diff

2016-03-01 01:23:45 +01:00
From fd78b8e2113ce1142bade02177cd0faa07b34ae7 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 1 Dec 2013 15:10:48 +1100
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
2014-11-28 02:17:45 +01:00
index 0000000..13602f0
--- /dev/null
+++ b/src/main/java/net/minecraft/server/AttributeRanged.java
2014-11-28 02:17:45 +01:00
@@ -0,0 +1,35 @@
+package net.minecraft.server;
+
+public class AttributeRanged extends AttributeBase {
+
+ private final double a;
+ private final double b;
+ private String c;
+
2014-11-28 02:17:45 +01:00
+ public AttributeRanged(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;
+ }
+
2014-11-28 02:17:45 +01:00
+ public String g() {
+ return this.c;
+ }
+
+ public double a(double d0) {
2014-11-28 02:17:45 +01:00
+ d0 = MathHelper.a(d0, this.a, this.b);
+ return d0;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/BlockAnvil.java b/src/main/java/net/minecraft/server/BlockAnvil.java
new file mode 100644
2016-02-29 22:33:06 +01:00
index 0000000..3199e5c
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockAnvil.java
2016-02-29 22:33:06 +01:00
@@ -0,0 +1,122 @@
+package net.minecraft.server;
+
2016-02-29 22:33:06 +01:00
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
2014-11-28 02:17:45 +01:00
+
+public class BlockAnvil extends BlockFalling {
+
2016-02-29 22:33:06 +01:00
+ public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
2014-11-28 02:17:45 +01:00
+ public static final BlockStateInteger DAMAGE = BlockStateInteger.of("damage", 0, 2);
2016-02-29 22:33:06 +01:00
+ protected static final AxisAlignedBB c = new AxisAlignedBB(0.0D, 0.0D, 0.125D, 1.0D, 1.0D, 0.875D);
+ protected static final AxisAlignedBB d = new AxisAlignedBB(0.125D, 0.0D, 0.0D, 0.875D, 1.0D, 1.0D);
+ protected static final Logger e = LogManager.getLogger();
+
+ protected BlockAnvil() {
+ super(Material.HEAVY);
2016-02-29 22:33:06 +01:00
+ this.w(this.blockStateList.getBlockData().set(BlockAnvil.FACING, EnumDirection.NORTH).set(BlockAnvil.DAMAGE, Integer.valueOf(0)));
+ this.d(0);
+ this.a(CreativeModeTab.c);
+ }
+
2016-02-29 22:33:06 +01:00
+ public boolean c(IBlockData iblockdata) {
+ return false;
+ }
+
2016-02-29 22:33:06 +01:00
+ public boolean b(IBlockData iblockdata) {
+ return false;
+ }
+
2014-11-28 02:17:45 +01:00
+ public IBlockData getPlacedState(World world, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2, int i, EntityLiving entityliving) {
+ EnumDirection enumdirection1 = entityliving.getDirection().e();
+
2016-02-29 22:33:06 +01:00
+ try {
+ return super.getPlacedState(world, blockposition, enumdirection, f, f1, f2, i, entityliving).set(BlockAnvil.FACING, enumdirection1).set(BlockAnvil.DAMAGE, Integer.valueOf(i >> 2));
+ } catch (IllegalArgumentException illegalargumentexception) {
+ if (!world.isClientSide) {
+ BlockAnvil.e.warn(String.format("Invalid damage property for anvil at %s. Found %d, must be in [0, 1, 2]", new Object[] { blockposition, Integer.valueOf(i >> 2)}));
+ if (entityliving instanceof EntityHuman) {
+ ((EntityHuman) entityliving).sendMessage(new ChatMessage("Invalid damage property. Please pick in [0, 1, 2]", new Object[0]));
+ }
+ }
+
+ return super.getPlacedState(world, blockposition, enumdirection, f, f1, f2, 0, entityliving).set(BlockAnvil.FACING, enumdirection1).set(BlockAnvil.DAMAGE, Integer.valueOf(0));
+ }
2014-11-28 02:17:45 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, EnumDirection enumdirection, float f, float f1, float f2) {
2015-02-28 12:36:22 +01:00
+ if (!world.isClientSide) {
+ entityhuman.openTileEntity(new BlockAnvil.TileEntityContainerAnvil(world, blockposition));
+ }
+
2014-11-28 02:17:45 +01:00
+ return true;
+ }
+
2014-11-28 02:17:45 +01:00
+ public int getDropData(IBlockData iblockdata) {
+ return ((Integer) iblockdata.get(BlockAnvil.DAMAGE)).intValue();
+ }
+
2016-02-29 22:33:06 +01:00
+ public AxisAlignedBB a(IBlockData iblockdata, IBlockAccess iblockaccess, BlockPosition blockposition) {
+ EnumDirection enumdirection = (EnumDirection) iblockdata.get(BlockAnvil.FACING);
+
2016-02-29 22:33:06 +01:00
+ return enumdirection.k() == EnumDirection.EnumAxis.X ? BlockAnvil.c : BlockAnvil.d;
+ }
+
2014-11-28 02:17:45 +01:00
+ protected void a(EntityFallingBlock entityfallingblock) {
+ entityfallingblock.a(true);
+ }
+
2014-11-28 02:17:45 +01:00
+ public void a_(World world, BlockPosition blockposition) {
2016-02-29 22:33:06 +01:00
+ world.triggerEffect(1031, blockposition, 0);
2014-11-28 02:17:45 +01:00
+ }
+
2014-11-28 02:17:45 +01:00
+ public IBlockData fromLegacyData(int i) {
+ return this.getBlockData().set(BlockAnvil.FACING, EnumDirection.fromType2(i & 3)).set(BlockAnvil.DAMAGE, Integer.valueOf((i & 15) >> 2));
+ }
+
2014-11-28 02:17:45 +01:00
+ public int toLegacyData(IBlockData iblockdata) {
+ byte b0 = 0;
2016-02-29 22:33:06 +01:00
+ int i = b0 | ((EnumDirection) iblockdata.get(BlockAnvil.FACING)).get2DRotationValue();
2014-11-28 02:17:45 +01:00
+
+ i |= ((Integer) iblockdata.get(BlockAnvil.DAMAGE)).intValue() << 2;
+ return i;
+ }
+
2016-02-29 22:33:06 +01:00
+ public IBlockData a(IBlockData iblockdata, EnumBlockRotation enumblockrotation) {
+ return iblockdata.getBlock() != this ? iblockdata : iblockdata.set(BlockAnvil.FACING, enumblockrotation.a((EnumDirection) iblockdata.get(BlockAnvil.FACING)));
+ }
+
2014-11-28 02:17:45 +01:00
+ protected BlockStateList getStateList() {
+ return new BlockStateList(this, new IBlockState[] { BlockAnvil.FACING, BlockAnvil.DAMAGE});
+ }
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ public static class TileEntityContainerAnvil implements ITileEntityContainer {
+
+ private final World a;
+ private final BlockPosition b;
+
+ public TileEntityContainerAnvil(World world, BlockPosition blockposition) {
+ this.a = world;
+ this.b = blockposition;
+ }
+
+ public String getName() {
+ return "anvil";
+ }
+
+ public boolean hasCustomName() {
+ return false;
+ }
+
+ public IChatBaseComponent getScoreboardDisplayName() {
+ return new ChatMessage(Blocks.ANVIL.a() + ".name", new Object[0]);
+ }
+
+ public Container createContainer(PlayerInventory playerinventory, EntityHuman entityhuman) {
+ return new ContainerAnvil(playerinventory, this.a, this.b, entityhuman);
+ }
+
+ public String getContainerName() {
+ return "minecraft:anvil";
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/BlockBrewingStand.java b/src/main/java/net/minecraft/server/BlockBrewingStand.java
new file mode 100644
2016-02-29 22:33:06 +01:00
index 0000000..2e6c63d
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockBrewingStand.java
2016-02-29 22:33:06 +01:00
@@ -0,0 +1,123 @@
+package net.minecraft.server;
+
+import java.util.List;
+import java.util.Random;
+
2016-02-29 22:33:06 +01:00
+public class BlockBrewingStand extends BlockTileEntity {
+
2014-11-28 02:17:45 +01:00
+ public static final BlockStateBoolean[] HAS_BOTTLE = new BlockStateBoolean[] { BlockStateBoolean.of("has_bottle_0"), BlockStateBoolean.of("has_bottle_1"), BlockStateBoolean.of("has_bottle_2")};
2016-02-29 22:33:06 +01:00
+ protected static final AxisAlignedBB b = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.125D, 1.0D);
+ protected static final AxisAlignedBB c = new AxisAlignedBB(0.4375D, 0.0D, 0.4375D, 0.5625D, 0.875D, 0.5625D);
+
+ public BlockBrewingStand() {
+ super(Material.ORE);
2016-02-29 22:33:06 +01:00
+ this.w(this.blockStateList.getBlockData().set(BlockBrewingStand.HAS_BOTTLE[0], Boolean.valueOf(false)).set(BlockBrewingStand.HAS_BOTTLE[1], Boolean.valueOf(false)).set(BlockBrewingStand.HAS_BOTTLE[2], Boolean.valueOf(false)));
+ }
+
2015-02-28 12:36:22 +01:00
+ public String getName() {
+ return LocaleI18n.get("item.brewingStand.name");
+ }
+
2016-02-29 22:33:06 +01:00
+ public boolean b(IBlockData iblockdata) {
+ return false;
+ }
+
2016-02-29 22:33:06 +01:00
+ public EnumRenderType a(IBlockData iblockdata) {
+ return EnumRenderType.MODEL;
+ }
+
+ public TileEntity a(World world, int i) {
+ return new TileEntityBrewingStand();
+ }
+
2016-02-29 22:33:06 +01:00
+ public boolean c(IBlockData iblockdata) {
+ return false;
+ }
+
2016-02-29 22:33:06 +01:00
+ public void a(IBlockData iblockdata, World world, BlockPosition blockposition, AxisAlignedBB axisalignedbb, List<AxisAlignedBB> list, Entity entity) {
+ a(blockposition, axisalignedbb, list, BlockBrewingStand.c);
+ a(blockposition, axisalignedbb, list, BlockBrewingStand.b);
+ }
+
2016-02-29 22:33:06 +01:00
+ public AxisAlignedBB a(IBlockData iblockdata, IBlockAccess iblockaccess, BlockPosition blockposition) {
+ return BlockBrewingStand.b;
+ }
+
2016-02-29 22:33:06 +01:00
+ public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, EnumDirection enumdirection, float f, float f1, float f2) {
2015-02-28 12:36:22 +01:00
+ if (world.isClientSide) {
+ return true;
+ } else {
2014-11-28 02:17:45 +01:00
+ TileEntity tileentity = world.getTileEntity(blockposition);
+
2014-11-28 02:17:45 +01:00
+ if (tileentity instanceof TileEntityBrewingStand) {
+ entityhuman.openContainer((TileEntityBrewingStand) tileentity);
2016-02-29 22:33:06 +01:00
+ entityhuman.b(StatisticList.O);
+ }
+
+ return true;
+ }
+ }
+
2014-11-28 02:17:45 +01:00
+ public void postPlace(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving, ItemStack itemstack) {
+ if (itemstack.hasName()) {
2014-11-28 02:17:45 +01:00
+ TileEntity tileentity = world.getTileEntity(blockposition);
+
+ if (tileentity instanceof TileEntityBrewingStand) {
+ ((TileEntityBrewingStand) tileentity).a(itemstack.getName());
+ }
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+
2014-11-28 02:17:45 +01:00
+ public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
+ TileEntity tileentity = world.getTileEntity(blockposition);
+
+ if (tileentity instanceof TileEntityBrewingStand) {
2014-11-28 02:17:45 +01:00
+ InventoryUtils.dropInventory(world, blockposition, (TileEntityBrewingStand) tileentity);
+ }
+
2014-11-28 02:17:45 +01:00
+ super.remove(world, blockposition, iblockdata);
+ }
+
2014-11-28 02:17:45 +01:00
+ public Item getDropType(IBlockData iblockdata, Random random, int i) {
+ return Items.BREWING_STAND;
+ }
+
2016-02-29 22:33:06 +01:00
+ public ItemStack a(World world, BlockPosition blockposition, IBlockData iblockdata) {
+ return new ItemStack(Items.BREWING_STAND);
+ }
+
+ public boolean isComplexRedstone(IBlockData iblockdata) {
2014-11-28 02:17:45 +01:00
+ return true;
+ }
+
2016-02-29 22:33:06 +01:00
+ public int d(IBlockData iblockdata, World world, BlockPosition blockposition) {
2014-11-28 02:17:45 +01:00
+ return Container.a(world.getTileEntity(blockposition));
+ }
+
2014-11-28 02:17:45 +01:00
+ public IBlockData fromLegacyData(int i) {
+ IBlockData iblockdata = this.getBlockData();
+
2014-11-28 02:17:45 +01:00
+ for (int j = 0; j < 3; ++j) {
+ iblockdata = iblockdata.set(BlockBrewingStand.HAS_BOTTLE[j], Boolean.valueOf((i & 1 << j) > 0));
+ }
+
2014-11-28 02:17:45 +01:00
+ return iblockdata;
+ }
+
2014-11-28 02:17:45 +01:00
+ public int toLegacyData(IBlockData iblockdata) {
+ int i = 0;
+
2014-11-28 02:17:45 +01:00
+ for (int j = 0; j < 3; ++j) {
+ if (((Boolean) iblockdata.get(BlockBrewingStand.HAS_BOTTLE[j])).booleanValue()) {
+ i |= 1 << j;
+ }
+ }
+
+ return i;
+ }
+
2014-11-28 02:17:45 +01:00
+ protected BlockStateList getStateList() {
+ return new BlockStateList(this, new IBlockState[] { BlockBrewingStand.HAS_BOTTLE[0], BlockBrewingStand.HAS_BOTTLE[1], BlockBrewingStand.HAS_BOTTLE[2]});
+ }
+}
2014-11-28 02:17:45 +01:00
diff --git a/src/main/java/net/minecraft/server/BlockHopper.java b/src/main/java/net/minecraft/server/BlockHopper.java
new file mode 100644
2016-02-29 22:33:06 +01:00
index 0000000..e30a2bb
--- /dev/null
2014-11-28 02:17:45 +01:00
+++ b/src/main/java/net/minecraft/server/BlockHopper.java
2016-02-29 22:33:06 +01:00
@@ -0,0 +1,169 @@
+package net.minecraft.server;
+
2014-11-28 02:17:45 +01:00
+import com.google.common.base.Predicate;
+import java.util.List;
+
2016-02-29 22:33:06 +01:00
+public class BlockHopper extends BlockTileEntity {
+
2015-02-28 12:36:22 +01:00
+ public static final BlockStateDirection FACING = BlockStateDirection.of("facing", new Predicate() {
+ public boolean a(EnumDirection enumdirection) {
+ return enumdirection != EnumDirection.UP;
+ }
+
+ public boolean apply(Object object) {
+ return this.a((EnumDirection) object);
+ }
+ });
2014-11-28 02:17:45 +01:00
+ public static final BlockStateBoolean ENABLED = BlockStateBoolean.of("enabled");
2016-02-29 22:33:06 +01:00
+ protected static final AxisAlignedBB c = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.625D, 1.0D);
+ protected static final AxisAlignedBB d = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.125D);
+ protected static final AxisAlignedBB e = new AxisAlignedBB(0.0D, 0.0D, 0.875D, 1.0D, 1.0D, 1.0D);
+ protected static final AxisAlignedBB f = new AxisAlignedBB(0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
+ protected static final AxisAlignedBB g = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D);
+
2014-11-28 02:17:45 +01:00
+ public BlockHopper() {
2015-02-28 12:36:22 +01:00
+ super(Material.ORE, MaterialMapColor.m);
2016-02-29 22:33:06 +01:00
+ this.w(this.blockStateList.getBlockData().set(BlockHopper.FACING, EnumDirection.DOWN).set(BlockHopper.ENABLED, Boolean.valueOf(true)));
2014-11-28 02:17:45 +01:00
+ this.a(CreativeModeTab.d);
+ }
+
2016-02-29 22:33:06 +01:00
+ public AxisAlignedBB a(IBlockData iblockdata, IBlockAccess iblockaccess, BlockPosition blockposition) {
+ return BlockHopper.j;
2014-11-28 02:17:45 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ public void a(IBlockData iblockdata, World world, BlockPosition blockposition, AxisAlignedBB axisalignedbb, List<AxisAlignedBB> list, Entity entity) {
+ a(blockposition, axisalignedbb, list, BlockHopper.c);
+ a(blockposition, axisalignedbb, list, BlockHopper.g);
+ a(blockposition, axisalignedbb, list, BlockHopper.f);
+ a(blockposition, axisalignedbb, list, BlockHopper.d);
+ a(blockposition, axisalignedbb, list, BlockHopper.e);
+ }
+
2014-11-28 02:17:45 +01:00
+ public IBlockData getPlacedState(World world, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2, int i, EntityLiving entityliving) {
+ EnumDirection enumdirection1 = enumdirection.opposite();
+
2014-11-28 02:17:45 +01:00
+ if (enumdirection1 == EnumDirection.UP) {
+ enumdirection1 = EnumDirection.DOWN;
+ }
+
2014-11-28 02:17:45 +01:00
+ return this.getBlockData().set(BlockHopper.FACING, enumdirection1).set(BlockHopper.ENABLED, Boolean.valueOf(true));
+ }
+
2014-11-28 02:17:45 +01:00
+ public TileEntity a(World world, int i) {
+ return new TileEntityHopper();
+ }
+
2014-11-28 02:17:45 +01:00
+ public void postPlace(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving, ItemStack itemstack) {
+ super.postPlace(world, blockposition, iblockdata, entityliving, itemstack);
+ if (itemstack.hasName()) {
+ TileEntity tileentity = world.getTileEntity(blockposition);
+
+ if (tileentity instanceof TileEntityHopper) {
+ ((TileEntityHopper) tileentity).a(itemstack.getName());
+ }
+ }
+
+ }
+
2016-02-29 22:33:06 +01:00
+ public boolean k(IBlockData iblockdata) {
+ return true;
+ }
+
2014-11-28 02:17:45 +01:00
+ public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) {
+ this.e(world, blockposition, iblockdata);
+ }
+
2016-02-29 22:33:06 +01:00
+ public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, EnumDirection enumdirection, float f, float f1, float f2) {
2015-02-28 12:36:22 +01:00
+ if (world.isClientSide) {
2014-11-28 02:17:45 +01:00
+ return true;
+ } else {
+ TileEntity tileentity = world.getTileEntity(blockposition);
+
+ if (tileentity instanceof TileEntityHopper) {
+ entityhuman.openContainer((TileEntityHopper) tileentity);
2016-02-29 22:33:06 +01:00
+ entityhuman.b(StatisticList.R);
2014-11-28 02:17:45 +01:00
+ }
+
+ return true;
+ }
+ }
+
+ public void doPhysics(World world, BlockPosition blockposition, IBlockData iblockdata, Block block) {
+ this.e(world, blockposition, iblockdata);
+ }
+
+ private void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
+ boolean flag = !world.isBlockIndirectlyPowered(blockposition);
+
+ if (flag != ((Boolean) iblockdata.get(BlockHopper.ENABLED)).booleanValue()) {
+ world.setTypeAndData(blockposition, iblockdata.set(BlockHopper.ENABLED, Boolean.valueOf(flag)), 4);
+ }
+
+ }
+
+ public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
+ TileEntity tileentity = world.getTileEntity(blockposition);
+
+ if (tileentity instanceof TileEntityHopper) {
+ InventoryUtils.dropInventory(world, blockposition, (TileEntityHopper) tileentity);
+ world.updateAdjacentComparators(blockposition, this);
+ }
+
+ super.remove(world, blockposition, iblockdata);
+ }
+
2016-02-29 22:33:06 +01:00
+ public EnumRenderType a(IBlockData iblockdata) {
+ return EnumRenderType.MODEL;
2014-11-28 02:17:45 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ public boolean c(IBlockData iblockdata) {
2014-11-28 02:17:45 +01:00
+ return false;
+ }
+
2016-02-29 22:33:06 +01:00
+ public boolean b(IBlockData iblockdata) {
2014-11-28 02:17:45 +01:00
+ return false;
+ }
+
2016-02-29 22:33:06 +01:00
+ public static EnumDirection e(int i) {
2014-11-28 02:17:45 +01:00
+ return EnumDirection.fromType1(i & 7);
+ }
+
+ public static boolean f(int i) {
+ return (i & 8) != 8;
+ }
+
2016-02-29 22:33:06 +01:00
+ public boolean isComplexRedstone(IBlockData iblockdata) {
2014-11-28 02:17:45 +01:00
+ return true;
+ }
+
2016-02-29 22:33:06 +01:00
+ public int d(IBlockData iblockdata, World world, BlockPosition blockposition) {
2014-11-28 02:17:45 +01:00
+ return Container.a(world.getTileEntity(blockposition));
+ }
+
+ public IBlockData fromLegacyData(int i) {
2016-02-29 22:33:06 +01:00
+ return this.getBlockData().set(BlockHopper.FACING, e(i)).set(BlockHopper.ENABLED, Boolean.valueOf(f(i)));
2014-11-28 02:17:45 +01:00
+ }
+
+ public int toLegacyData(IBlockData iblockdata) {
+ byte b0 = 0;
+ int i = b0 | ((EnumDirection) iblockdata.get(BlockHopper.FACING)).a();
+
+ if (!((Boolean) iblockdata.get(BlockHopper.ENABLED)).booleanValue()) {
+ i |= 8;
+ }
+
+ return i;
+ }
+
2016-02-29 22:33:06 +01:00
+ public IBlockData a(IBlockData iblockdata, EnumBlockRotation enumblockrotation) {
+ return iblockdata.set(BlockHopper.FACING, enumblockrotation.a((EnumDirection) iblockdata.get(BlockHopper.FACING)));
+ }
+
+ public IBlockData a(IBlockData iblockdata, EnumBlockMirror enumblockmirror) {
+ return iblockdata.a(enumblockmirror.a((EnumDirection) iblockdata.get(BlockHopper.FACING)));
+ }
+
2014-11-28 02:17:45 +01:00
+ protected BlockStateList getStateList() {
+ return new BlockStateList(this, new IBlockState[] { BlockHopper.FACING, BlockHopper.ENABLED});
+ }
+}
diff --git a/src/main/java/net/minecraft/server/BlockTNT.java b/src/main/java/net/minecraft/server/BlockTNT.java
new file mode 100644
2016-02-29 22:33:06 +01:00
index 0000000..54140f7
2014-11-28 02:17:45 +01:00
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockTNT.java
2016-02-29 22:33:06 +01:00
@@ -0,0 +1,98 @@
2014-11-28 02:17:45 +01:00
+package net.minecraft.server;
+
+public class BlockTNT extends Block {
+
+ public static final BlockStateBoolean EXPLODE = BlockStateBoolean.of("explode");
+
+ public BlockTNT() {
+ super(Material.TNT);
2016-02-29 22:33:06 +01:00
+ this.w(this.blockStateList.getBlockData().set(BlockTNT.EXPLODE, Boolean.valueOf(false)));
2014-11-28 02:17:45 +01:00
+ this.a(CreativeModeTab.d);
+ }
+
+ public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) {
+ super.onPlace(world, blockposition, iblockdata);
+ if (world.isBlockIndirectlyPowered(blockposition)) {
+ this.postBreak(world, blockposition, iblockdata.set(BlockTNT.EXPLODE, Boolean.valueOf(true)));
+ world.setAir(blockposition);
+ }
+
+ }
+
+ public void doPhysics(World world, BlockPosition blockposition, IBlockData iblockdata, Block block) {
+ if (world.isBlockIndirectlyPowered(blockposition)) {
+ this.postBreak(world, blockposition, iblockdata.set(BlockTNT.EXPLODE, Boolean.valueOf(true)));
+ world.setAir(blockposition);
+ }
+
+ }
+
+ public void wasExploded(World world, BlockPosition blockposition, Explosion explosion) {
2015-02-28 12:36:22 +01:00
+ if (!world.isClientSide) {
2015-07-30 09:22:16 +02:00
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), explosion.getSource());
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ entitytntprimed.setFuseTicks((short) (world.random.nextInt(entitytntprimed.getFuseTicks() / 4) + entitytntprimed.getFuseTicks() / 8));
2014-11-28 02:17:45 +01:00
+ world.addEntity(entitytntprimed);
+ }
+ }
+
+ public void postBreak(World world, BlockPosition blockposition, IBlockData iblockdata) {
+ this.a(world, blockposition, iblockdata, (EntityLiving) null);
+ }
+
+ public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving) {
2015-02-28 12:36:22 +01:00
+ if (!world.isClientSide) {
2014-11-28 02:17:45 +01:00
+ if (((Boolean) iblockdata.get(BlockTNT.EXPLODE)).booleanValue()) {
2015-02-28 12:36:22 +01:00
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), entityliving);
2014-11-28 02:17:45 +01:00
+
+ world.addEntity(entitytntprimed);
2016-02-29 22:33:06 +01:00
+ world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.gj, SoundCategory.BLOCKS, 1.0F, 1.0F);
2014-11-28 02:17:45 +01:00
+ }
+
+ }
+ }
+
2016-02-29 22:33:06 +01:00
+ public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, EnumDirection enumdirection, float f, float f1, float f2) {
+ if (itemstack != null && (itemstack.getItem() == Items.FLINT_AND_STEEL || itemstack.getItem() == Items.FIRE_CHARGE)) {
+ this.a(world, blockposition, iblockdata.set(BlockTNT.EXPLODE, Boolean.valueOf(true)), (EntityLiving) entityhuman);
+ world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 11);
+ if (itemstack.getItem() == Items.FLINT_AND_STEEL) {
+ itemstack.damage(1, entityhuman);
+ } else if (!entityhuman.abilities.canInstantlyBuild) {
+ --itemstack.count;
2014-11-28 02:17:45 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ return true;
+ } else {
+ return super.interact(world, blockposition, iblockdata, entityhuman, enumhand, itemstack, enumdirection, f, f1, f2);
+ }
2014-11-28 02:17:45 +01:00
+ }
+
+ public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
2015-02-28 12:36:22 +01:00
+ if (!world.isClientSide && entity instanceof EntityArrow) {
2014-11-28 02:17:45 +01:00
+ EntityArrow entityarrow = (EntityArrow) entity;
+
+ if (entityarrow.isBurning()) {
+ this.a(world, blockposition, world.getType(blockposition).set(BlockTNT.EXPLODE, Boolean.valueOf(true)), entityarrow.shooter instanceof EntityLiving ? (EntityLiving) entityarrow.shooter : null);
+ world.setAir(blockposition);
+ }
+ }
+
+ }
+
+ public boolean a(Explosion explosion) {
+ return false;
+ }
+
+ public IBlockData fromLegacyData(int i) {
+ return this.getBlockData().set(BlockTNT.EXPLODE, Boolean.valueOf((i & 1) > 0));
+ }
+
+ public int toLegacyData(IBlockData iblockdata) {
+ return ((Boolean) iblockdata.get(BlockTNT.EXPLODE)).booleanValue() ? 1 : 0;
+ }
+
+ protected BlockStateList getStateList() {
+ return new BlockStateList(this, new IBlockState[] { BlockTNT.EXPLODE});
+ }
+}
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-02-29 22:33:06 +01:00
index 0000000..3e4a31b
2014-11-28 02:17:45 +01:00
--- /dev/null
+++ b/src/main/java/net/minecraft/server/CommandDispatcher.java
2016-02-29 22:33:06 +01:00
@@ -0,0 +1,125 @@
2014-11-28 02:17:45 +01:00
+package net.minecraft.server;
+
+import java.util.Iterator;
+
+public class CommandDispatcher extends CommandHandler implements ICommandDispatcher {
+
2016-02-29 22:33:06 +01:00
+ private final MinecraftServer a;
+
+ public CommandDispatcher(MinecraftServer minecraftserver) {
+ this.a = minecraftserver;
2014-11-28 02:17:45 +01:00
+ 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()));
+ 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-02-29 22:33:06 +01:00
+ if (minecraftserver.aa()) {
2014-11-28 02:17:45 +01:00
+ 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()));
+ }
+
+ CommandAbstract.a((ICommandDispatcher) this);
+ }
+
+ public void a(ICommandListener icommandlistener, ICommand icommand, int i, String s, Object... aobject) {
+ boolean flag = true;
2016-02-29 22:33:06 +01:00
+ MinecraftServer minecraftserver = this.a;
2014-11-28 02:17:45 +01:00
+
+ if (!icommandlistener.getSendCommandFeedback()) {
+ flag = false;
+ }
+
2016-02-29 22:33:06 +01:00
+ ChatMessage chatmessage = new ChatMessage("chat.type.admin", new Object[] { icommandlistener.getName(), new ChatMessage(s, aobject)});
2015-02-28 12:36:22 +01:00
+
2016-02-29 22:33:06 +01:00
+ chatmessage.getChatModifier().setColor(EnumChatFormat.GRAY);
+ chatmessage.getChatModifier().setItalic(Boolean.valueOf(true));
+ if (flag) {
+ Iterator iterator = minecraftserver.getPlayerList().v().iterator();
2015-02-28 12:36:22 +01:00
+
2016-02-29 22:33:06 +01:00
+ while (iterator.hasNext()) {
+ EntityHuman entityhuman = (EntityHuman) iterator.next();
2015-02-28 12:36:22 +01:00
+
2016-02-29 22:33:06 +01: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();
2015-02-28 12:36:22 +01:00
+
2016-02-29 22:33:06 +01:00
+ if (flag1 || flag2 || !(icommandlistener instanceof RemoteControlCommandListener) && !(icommandlistener instanceof MinecraftServer)) {
+ entityhuman.sendMessage(chatmessage);
+ }
+ }
+ }
2015-02-28 12:36:22 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ if (icommandlistener != minecraftserver && minecraftserver.worldServer[0].getGameRules().getBoolean("logAdminCommands")) {
+ minecraftserver.sendMessage(chatmessage);
2015-02-28 12:36:22 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ boolean flag3 = minecraftserver.worldServer[0].getGameRules().getBoolean("sendCommandFeedback");
2015-02-28 12:36:22 +01:00
+
2016-02-29 22:33:06 +01:00
+ if (icommandlistener instanceof CommandBlockListenerAbstract) {
+ flag3 = ((CommandBlockListenerAbstract) icommandlistener).n();
2015-02-28 12:36:22 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ if ((i & 1) != 1 && flag3 || icommandlistener instanceof MinecraftServer) {
+ icommandlistener.sendMessage(new ChatMessage(s, aobject));
2015-02-28 12:36:22 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ }
+
+ protected MinecraftServer a() {
+ return this.a;
2015-02-28 12:36:22 +01:00
+ }
2014-11-28 02:17:45 +01:00
+}
diff --git a/src/main/java/net/minecraft/server/EnchantmentManager.java b/src/main/java/net/minecraft/server/EnchantmentManager.java
new file mode 100644
2016-02-29 22:33:06 +01:00
index 0000000..022d3c5
2014-11-28 02:17:45 +01:00
--- /dev/null
+++ b/src/main/java/net/minecraft/server/EnchantmentManager.java
2016-02-29 22:33:06 +01:00
@@ -0,0 +1,414 @@
2014-11-28 02:17:45 +01:00
+package net.minecraft.server;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
2016-02-29 22:33:06 +01:00
+import java.util.Map.Entry;
2014-11-28 02:17:45 +01:00
+
+public class EnchantmentManager {
+
+ private static final Random a = new Random();
2015-02-28 12:36:22 +01:00
+ private static final EnchantmentManager.EnchantmentModifierProtection b = new EnchantmentManager.EnchantmentModifierProtection((EnchantmentManager.SyntheticClass_1) null);
+ private static final EnchantmentManager.EnchantmentModifierDamage c = new EnchantmentManager.EnchantmentModifierDamage((EnchantmentManager.SyntheticClass_1) null);
+ private static final EnchantmentManager.EnchantmentModifierThorns d = new EnchantmentManager.EnchantmentModifierThorns((EnchantmentManager.SyntheticClass_1) null);
+ private static final EnchantmentManager.EnchantmentModifierArthropods e = new EnchantmentManager.EnchantmentModifierArthropods((EnchantmentManager.SyntheticClass_1) null);
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ public static int getEnchantmentLevel(Enchantment enchantment, ItemStack itemstack) {
2014-11-28 02:17:45 +01:00
+ if (itemstack == null) {
+ return 0;
+ } else {
+ NBTTagList nbttaglist = itemstack.getEnchantments();
+
+ if (nbttaglist == null) {
+ return 0;
+ } else {
2016-02-29 22:33:06 +01:00
+ for (int i = 0; i < nbttaglist.size(); ++i) {
+ Enchantment enchantment1 = Enchantment.c(nbttaglist.get(i).getShort("id"));
+ short short0 = nbttaglist.get(i).getShort("lvl");
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ if (enchantment1 == enchantment) {
+ return short0;
2014-11-28 02:17:45 +01:00
+ }
+ }
+
+ return 0;
+ }
+ }
+ }
+
2016-02-29 22:33:06 +01:00
+ public static Map<Enchantment, Integer> a(ItemStack itemstack) {
2014-11-28 02:17:45 +01:00
+ LinkedHashMap linkedhashmap = Maps.newLinkedHashMap();
+ NBTTagList nbttaglist = itemstack.getItem() == Items.ENCHANTED_BOOK ? Items.ENCHANTED_BOOK.h(itemstack) : itemstack.getEnchantments();
+
+ if (nbttaglist != null) {
+ for (int i = 0; i < nbttaglist.size(); ++i) {
2016-02-29 22:33:06 +01:00
+ Enchantment enchantment = Enchantment.c(nbttaglist.get(i).getShort("id"));
+ short short0 = nbttaglist.get(i).getShort("lvl");
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ linkedhashmap.put(enchantment, Integer.valueOf(short0));
2014-11-28 02:17:45 +01:00
+ }
+ }
+
+ return linkedhashmap;
+ }
+
2016-02-29 22:33:06 +01:00
+ public static void a(Map<Enchantment, Integer> map, ItemStack itemstack) {
2014-11-28 02:17:45 +01:00
+ NBTTagList nbttaglist = new NBTTagList();
2016-02-29 22:33:06 +01:00
+ Iterator iterator = map.entrySet().iterator();
2014-11-28 02:17:45 +01:00
+
+ while (iterator.hasNext()) {
2016-02-29 22:33:06 +01:00
+ Entry entry = (Entry) iterator.next();
+ Enchantment enchantment = (Enchantment) entry.getKey();
2014-11-28 02:17:45 +01:00
+
+ if (enchantment != null) {
2016-02-29 22:33:06 +01:00
+ int i = ((Integer) entry.getValue()).intValue();
2014-11-28 02:17:45 +01:00
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+
2016-02-29 22:33:06 +01:00
+ nbttagcompound.setShort("id", (short) Enchantment.getId(enchantment));
+ nbttagcompound.setShort("lvl", (short) i);
2014-11-28 02:17:45 +01:00
+ nbttaglist.add(nbttagcompound);
+ if (itemstack.getItem() == Items.ENCHANTED_BOOK) {
2016-02-29 22:33:06 +01:00
+ Items.ENCHANTED_BOOK.a(itemstack, new WeightedRandomEnchant(enchantment, i));
2014-11-28 02:17:45 +01:00
+ }
+ }
+ }
+
2016-02-29 22:33:06 +01:00
+ if (nbttaglist.isEmpty()) {
+ if (itemstack.hasTag()) {
+ itemstack.getTag().remove("ench");
2014-11-28 02:17:45 +01:00
+ }
2016-02-29 22:33:06 +01:00
+ } else if (itemstack.getItem() != Items.ENCHANTED_BOOK) {
+ itemstack.a("ench", (NBTBase) nbttaglist);
2014-11-28 02:17:45 +01:00
+ }
+
+ }
+
2015-02-28 12:36:22 +01:00
+ private static void a(EnchantmentManager.EnchantmentModifier enchantmentmanager_enchantmentmodifier, ItemStack itemstack) {
2014-11-28 02:17:45 +01:00
+ if (itemstack != null) {
+ NBTTagList nbttaglist = itemstack.getEnchantments();
+
+ if (nbttaglist != null) {
+ for (int i = 0; i < nbttaglist.size(); ++i) {
+ short short0 = nbttaglist.get(i).getShort("id");
+ short short1 = nbttaglist.get(i).getShort("lvl");
+
2016-02-29 22:33:06 +01:00
+ if (Enchantment.c(short0) != null) {
+ enchantmentmanager_enchantmentmodifier.a(Enchantment.c(short0), short1);
2014-11-28 02:17:45 +01:00
+ }
+ }
+
+ }
+ }
+ }
+
2016-02-29 22:33:06 +01:00
+ private static void a(EnchantmentManager.EnchantmentModifier enchantmentmanager_enchantmentmodifier, Iterable<ItemStack> iterable) {
+ Iterator iterator = iterable.iterator();
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ while (iterator.hasNext()) {
+ ItemStack itemstack = (ItemStack) iterator.next();
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ a(enchantmentmanager_enchantmentmodifier, itemstack);
2014-11-28 02:17:45 +01:00
+ }
+
+ }
+
2016-02-29 22:33:06 +01:00
+ public static int a(Iterable<ItemStack> iterable, DamageSource damagesource) {
2014-11-28 02:17:45 +01:00
+ EnchantmentManager.b.a = 0;
+ EnchantmentManager.b.b = damagesource;
2016-02-29 22:33:06 +01:00
+ a((EnchantmentManager.EnchantmentModifier) EnchantmentManager.b, iterable);
+ return EnchantmentManager.b.a;
2014-11-28 02:17:45 +01:00
+ }
+
+ public static float a(ItemStack itemstack, EnumMonsterType enummonstertype) {
+ EnchantmentManager.c.a = 0.0F;
+ EnchantmentManager.c.b = enummonstertype;
2015-02-28 12:36:22 +01:00
+ a((EnchantmentManager.EnchantmentModifier) EnchantmentManager.c, itemstack);
2014-11-28 02:17:45 +01:00
+ return EnchantmentManager.c.a;
+ }
+
+ public static void a(EntityLiving entityliving, Entity entity) {
+ EnchantmentManager.d.b = entity;
+ EnchantmentManager.d.a = entityliving;
+ if (entityliving != null) {
2016-02-29 22:33:06 +01:00
+ a((EnchantmentManager.EnchantmentModifier) EnchantmentManager.d, entityliving.aG());
2014-11-28 02:17:45 +01:00
+ }
+
+ if (entity instanceof EntityHuman) {
2016-02-29 22:33:06 +01:00
+ a((EnchantmentManager.EnchantmentModifier) EnchantmentManager.d, entityliving.getItemInMainHand());
2014-11-28 02:17:45 +01:00
+ }
+
+ }
+
+ public static void b(EntityLiving entityliving, Entity entity) {
+ EnchantmentManager.e.a = entityliving;
+ EnchantmentManager.e.b = entity;
+ if (entityliving != null) {
2016-02-29 22:33:06 +01:00
+ a((EnchantmentManager.EnchantmentModifier) EnchantmentManager.e, entityliving.aG());
2014-11-28 02:17:45 +01:00
+ }
+
+ if (entityliving instanceof EntityHuman) {
2016-02-29 22:33:06 +01:00
+ a((EnchantmentManager.EnchantmentModifier) EnchantmentManager.e, entityliving.getItemInMainHand());
2014-11-28 02:17:45 +01:00
+ }
+
+ }
+
2016-02-29 22:33:06 +01:00
+ public static int a(Enchantment enchantment, EntityLiving entityliving) {
+ Iterable iterable = enchantment.a(entityliving);
+
+ if (iterable == null) {
+ return 0;
+ } else {
+ int i = 0;
+ Iterator iterator = iterable.iterator();
+
+ while (iterator.hasNext()) {
+ ItemStack itemstack = (ItemStack) iterator.next();
+ int j = getEnchantmentLevel(enchantment, itemstack);
+
+ if (j > i) {
+ i = j;
+ }
+ }
+
+ return i;
+ }
+ }
+
2014-11-28 02:17:45 +01:00
+ public static int a(EntityLiving entityliving) {
2016-02-29 22:33:06 +01:00
+ return a(Enchantments.KNOCKBACK, entityliving);
2014-11-28 02:17:45 +01:00
+ }
+
+ public static int getFireAspectEnchantmentLevel(EntityLiving entityliving) {
2016-02-29 22:33:06 +01:00
+ return a(Enchantments.FIRE_ASPECT, entityliving);
2014-11-28 02:17:45 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ public static int getOxygenEnchantmentLevel(EntityLiving entityliving) {
+ return a(Enchantments.OXYGEN, entityliving);
2014-11-28 02:17:45 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ public static int d(EntityLiving entityliving) {
+ return a(Enchantments.DEPTH_STRIDER, entityliving);
2014-11-28 02:17:45 +01:00
+ }
+
+ public static int getDigSpeedEnchantmentLevel(EntityLiving entityliving) {
2016-02-29 22:33:06 +01:00
+ return a(Enchantments.DIG_SPEED, entityliving);
2014-11-28 02:17:45 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ public static int f(EntityLiving entityliving) {
+ return a(Enchantments.LUCK, entityliving);
2014-11-28 02:17:45 +01:00
+ }
+
+ public static int g(EntityLiving entityliving) {
2016-02-29 22:33:06 +01:00
+ return a(Enchantments.LURE, entityliving);
2014-11-28 02:17:45 +01:00
+ }
+
+ public static int h(EntityLiving entityliving) {
2016-02-29 22:33:06 +01:00
+ return a(Enchantments.LOOT_BONUS_MOBS, entityliving);
2014-11-28 02:17:45 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ public static boolean i(EntityLiving entityliving) {
+ return a(Enchantments.WATER_WORKER, entityliving) > 0;
2014-11-28 02:17:45 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ public static ItemStack b(Enchantment enchantment, EntityLiving entityliving) {
+ Iterable iterable = enchantment.a(entityliving);
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ if (iterable == null) {
+ return null;
+ } else {
+ ArrayList arraylist = Lists.newArrayList();
+ Iterator iterator = iterable.iterator();
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ while (iterator.hasNext()) {
+ ItemStack itemstack = (ItemStack) iterator.next();
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ if (itemstack != null && getEnchantmentLevel(enchantment, itemstack) > 0) {
+ arraylist.add(itemstack);
+ }
2014-11-28 02:17:45 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ return arraylist.isEmpty() ? null : (ItemStack) arraylist.get(entityliving.getRandom().nextInt(arraylist.size()));
+ }
2014-11-28 02:17:45 +01:00
+ }
+
+ public static int a(Random random, int i, int j, ItemStack itemstack) {
+ Item item = itemstack.getItem();
2016-02-29 22:33:06 +01:00
+ int k = item.c();
2014-11-28 02:17:45 +01:00
+
+ if (k <= 0) {
+ return 0;
+ } else {
+ if (j > 15) {
+ j = 15;
+ }
+
+ int l = random.nextInt(8) + 1 + (j >> 1) + random.nextInt(j + 1);
+
+ return i == 0 ? Math.max(l / 3, 1) : (i == 1 ? l * 2 / 3 + 1 : Math.max(l, j * 2));
+ }
+ }
+
2016-02-29 22:33:06 +01:00
+ public static ItemStack a(Random random, ItemStack itemstack, int i, boolean flag) {
+ boolean flag1 = itemstack.getItem() == Items.BOOK;
+ List list = b(random, itemstack, i, flag);
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ if (flag1) {
2014-11-28 02:17:45 +01:00
+ itemstack.setItem(Items.ENCHANTED_BOOK);
+ }
+
2016-02-29 22:33:06 +01:00
+ Iterator iterator = list.iterator();
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ while (iterator.hasNext()) {
+ WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) iterator.next();
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ if (flag1) {
+ Items.ENCHANTED_BOOK.a(itemstack, weightedrandomenchant);
+ } else {
+ itemstack.addEnchantment(weightedrandomenchant.enchantment, weightedrandomenchant.level);
2014-11-28 02:17:45 +01:00
+ }
+ }
+
+ return itemstack;
+ }
+
2016-02-29 22:33:06 +01:00
+ public static List<WeightedRandomEnchant> b(Random random, ItemStack itemstack, int i, boolean flag) {
+ ArrayList arraylist = Lists.newArrayList();
2014-11-28 02:17:45 +01:00
+ Item item = itemstack.getItem();
2016-02-29 22:33:06 +01:00
+ int j = item.c();
2014-11-28 02:17:45 +01:00
+
+ if (j <= 0) {
2016-02-29 22:33:06 +01:00
+ return arraylist;
2014-11-28 02:17:45 +01:00
+ } else {
2016-02-29 22:33:06 +01:00
+ i += 1 + random.nextInt(j / 4 + 1) + random.nextInt(j / 4 + 1);
2014-11-28 02:17:45 +01:00
+ float f = (random.nextFloat() + random.nextFloat() - 1.0F) * 0.15F;
+
2016-02-29 22:33:06 +01:00
+ i = MathHelper.clamp(Math.round((float) i + (float) i * f), 1, Integer.MAX_VALUE);
+ List list = a(i, itemstack, flag);
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ if (!list.isEmpty()) {
+ arraylist.add(WeightedRandom.a(random, list));
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ while (random.nextInt(50) <= i) {
+ a(list, (WeightedRandomEnchant) SystemUtils.a(arraylist));
+ if (list.isEmpty()) {
+ break;
2014-11-28 02:17:45 +01:00
+ }
2016-02-29 22:33:06 +01:00
+
+ arraylist.add(WeightedRandom.a(random, list));
+ i /= 2;
2014-11-28 02:17:45 +01:00
+ }
+ }
+
+ return arraylist;
+ }
+ }
+
2016-02-29 22:33:06 +01:00
+ public static void a(List<WeightedRandomEnchant> list, WeightedRandomEnchant weightedrandomenchant) {
+ Iterator iterator = list.iterator();
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ while (iterator.hasNext()) {
+ if (!weightedrandomenchant.enchantment.a(((WeightedRandomEnchant) iterator.next()).enchantment)) {
+ iterator.remove();
+ }
+ }
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ }
+
+ public static List<WeightedRandomEnchant> a(int i, ItemStack itemstack, boolean flag) {
+ ArrayList arraylist = Lists.newArrayList();
+ Item item = itemstack.getItem();
+ boolean flag1 = itemstack.getItem() == Items.BOOK;
+ Iterator iterator = Enchantment.enchantments.iterator();
+
+ while (iterator.hasNext()) {
+ Enchantment enchantment = (Enchantment) iterator.next();
2014-11-28 02:17:45 +01:00
+
2016-02-29 22:33:06 +01:00
+ if ((!enchantment.e() || flag) && (enchantment.itemTarget.canEnchant(item) || flag1)) {
+ for (int j = enchantment.getMaxLevel(); j > enchantment.getStartLevel() - 1; --j) {
+ if (i >= enchantment.a(j) && i <= enchantment.b(j)) {
+ arraylist.add(new WeightedRandomEnchant(enchantment, j));
+ break;
2014-11-28 02:17:45 +01:00
+ }
+ }
+ }
+ }
+
2016-02-29 22:33:06 +01:00
+ return arraylist;
2014-11-28 02:17:45 +01:00
+ }
+
2015-02-28 12:36:22 +01:00
+ static class SyntheticClass_1 { }
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ static final class EnchantmentModifierArthropods implements EnchantmentManager.EnchantmentModifier {
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ public EntityLiving a;
+ public Entity b;
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ private EnchantmentModifierArthropods() {}
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ public void a(Enchantment enchantment, int i) {
+ enchantment.a(this.a, this.b, i);
+ }
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ EnchantmentModifierArthropods(EnchantmentManager.SyntheticClass_1 enchantmentmanager_syntheticclass_1) {
+ this();
+ }
2014-11-28 02:17:45 +01:00
+ }
+
2015-02-28 12:36:22 +01:00
+ static final class EnchantmentModifierThorns implements EnchantmentManager.EnchantmentModifier {
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ public EntityLiving a;
+ public Entity b;
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ private EnchantmentModifierThorns() {}
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ public void a(Enchantment enchantment, int i) {
+ enchantment.b(this.a, this.b, i);
+ }
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ EnchantmentModifierThorns(EnchantmentManager.SyntheticClass_1 enchantmentmanager_syntheticclass_1) {
+ this();
+ }
2014-11-28 02:17:45 +01:00
+ }
+
2015-02-28 12:36:22 +01:00
+ static final class EnchantmentModifierDamage implements EnchantmentManager.EnchantmentModifier {
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ public float a;
+ public EnumMonsterType b;
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ private EnchantmentModifierDamage() {}
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ public void a(Enchantment enchantment, int i) {
+ this.a += enchantment.a(i, this.b);
+ }
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ EnchantmentModifierDamage(EnchantmentManager.SyntheticClass_1 enchantmentmanager_syntheticclass_1) {
+ this();
+ }
2014-11-28 02:17:45 +01:00
+ }
+
2015-02-28 12:36:22 +01:00
+ static final class EnchantmentModifierProtection implements EnchantmentManager.EnchantmentModifier {
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ public int a;
+ public DamageSource b;
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ private EnchantmentModifierProtection() {}
+
+ public void a(Enchantment enchantment, int i) {
+ this.a += enchantment.a(i, this.b);
+ }
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ EnchantmentModifierProtection(EnchantmentManager.SyntheticClass_1 enchantmentmanager_syntheticclass_1) {
+ this();
+ }
2014-11-28 02:17:45 +01:00
+ }
+
2015-02-28 12:36:22 +01:00
+ interface EnchantmentModifier {
+
+ void a(Enchantment enchantment, int i);
2014-11-28 02:17:45 +01:00
+ }
+}
diff --git a/src/main/java/net/minecraft/server/FileIOThread.java b/src/main/java/net/minecraft/server/FileIOThread.java
new file mode 100644
index 0000000..198b00f
--- /dev/null
+++ b/src/main/java/net/minecraft/server/FileIOThread.java
@@ -0,0 +1,75 @@
+package net.minecraft.server;
+
+import com.google.common.collect.Lists;
+import java.util.Collections;
+import java.util.List;
+
+public class FileIOThread implements Runnable {
+
+ private static final FileIOThread a = new FileIOThread();
+ private List<IAsyncChunkSaver> b = Collections.synchronizedList(Lists.<IAsyncChunkSaver>newArrayList());
+ private volatile long c;
+ private volatile long d;
+ private volatile boolean e;
+
+ private FileIOThread() {
+ Thread thread = new Thread(this, "File IO Thread");
+
+ thread.setPriority(1);
+ thread.start();
+ }
+
+ public static FileIOThread a() {
+ return FileIOThread.a;
+ }
+
+ public void run() {
+ while (true) {
+ this.c();
+ }
+ }
+
+ private void c() {
+ for (int i = 0; i < this.b.size(); ++i) {
+ IAsyncChunkSaver iasyncchunksaver = (IAsyncChunkSaver) this.b.get(i);
+ boolean flag = iasyncchunksaver.c();
+
+ if (!flag) {
+ this.b.remove(i--);
+ ++this.d;
+ }
+
+ try {
+ Thread.sleep(this.e ? 0L : 10L);
+ } catch (InterruptedException interruptedexception) {
+ interruptedexception.printStackTrace();
+ }
+ }
+
+ if (this.b.isEmpty()) {
+ try {
+ Thread.sleep(25L);
+ } catch (InterruptedException interruptedexception1) {
+ interruptedexception1.printStackTrace();
+ }
+ }
+
+ }
+
+ public void a(IAsyncChunkSaver iasyncchunksaver) {
+ if (!this.b.contains(iasyncchunksaver)) {
+ ++this.c;
+ this.b.add(iasyncchunksaver);
+ }
+ }
+
+ public void b() throws InterruptedException {
+ this.e = true;
+
+ while (this.c != this.d) {
+ Thread.sleep(10L);
+ }
+
+ this.e = false;
+ }
+}
2015-02-28 12:36:22 +01:00
diff --git a/src/main/java/net/minecraft/server/GameProfileBanEntry.java b/src/main/java/net/minecraft/server/GameProfileBanEntry.java
2014-11-28 02:17:45 +01:00
new file mode 100644
2015-02-28 12:36:22 +01:00
index 0000000..27ce9d9
2014-11-28 02:17:45 +01:00
--- /dev/null
2015-02-28 12:36:22 +01:00
+++ b/src/main/java/net/minecraft/server/GameProfileBanEntry.java
@@ -0,0 +1,47 @@
2014-11-28 02:17:45 +01:00
+package net.minecraft.server;
+
2015-02-28 12:36:22 +01:00
+import com.google.gson.JsonObject;
+import com.mojang.authlib.GameProfile;
+import java.util.Date;
+import java.util.UUID;
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+public class GameProfileBanEntry extends ExpirableListEntry<GameProfile> {
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ public GameProfileBanEntry(GameProfile gameprofile) {
+ this(gameprofile, (Date) null, (String) null, (Date) null, (String) null);
2014-11-28 02:17:45 +01:00
+ }
+
2015-02-28 12:36:22 +01:00
+ public GameProfileBanEntry(GameProfile gameprofile, Date date, String s, Date date1, String s1) {
+ super(gameprofile, date1, s, date1, s1);
2014-11-28 02:17:45 +01:00
+ }
+
2015-02-28 12:36:22 +01:00
+ public GameProfileBanEntry(JsonObject jsonobject) {
+ super(b(jsonobject), jsonobject);
2014-11-28 02:17:45 +01:00
+ }
+
2015-02-28 12:36:22 +01: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);
2014-11-28 02:17:45 +01:00
+ }
2015-02-28 12:36:22 +01:00
+ }
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ private static GameProfile b(JsonObject jsonobject) {
+ if (jsonobject.has("uuid") && jsonobject.has("name")) {
+ String s = jsonobject.get("uuid").getAsString();
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ UUID uuid;
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ try {
+ uuid = UUID.fromString(s);
+ } catch (Throwable throwable) {
+ return null;
+ }
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01: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-02-29 22:33:06 +01:00
index 0000000..16aaf1a
--- /dev/null
+++ b/src/main/java/net/minecraft/server/GenericAttributes.java
2016-02-29 22:33:06 +01:00
@@ -0,0 +1,116 @@
+package net.minecraft.server;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.UUID;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class GenericAttributes {
+
2016-02-29 22:33:06 +01:00
+ private static final Logger i = LogManager.getLogger();
2015-07-30 09:22:16 +02: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 22:23:26 +02:00
+ public static final IAttribute FOLLOW_RANGE = (new AttributeRanged((IAttribute) null, "generic.followRange", 32.0D, 0.0D, 2048.0D)).a("Follow Range");
2014-11-28 02:17:45 +01:00
+ public static final IAttribute c = (new AttributeRanged((IAttribute) null, "generic.knockbackResistance", 0.0D, 0.0D, 1.0D)).a("Knockback Resistance");
2015-07-30 09:22:16 +02: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-02-29 22:33:06 +01: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);
+ public static final IAttribute h = (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-02-29 22:33:06 +01: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-02-29 22:33:06 +01: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"));
+
+ if (attributeinstance != null) {
+ a(attributeinstance, nbttagcompound);
+ } else {
2016-02-29 22:33:06 +01:00
+ GenericAttributes.i.warn("Ignoring unknown attribute \'" + nbttagcompound.getString("Name") + "\'");
+ }
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+
+ 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));
+
2014-11-28 02:17:45 +01:00
+ if (attributemodifier != null) {
+ AttributeModifier attributemodifier1 = attributeinstance.a(attributemodifier.a());
+
+ if (attributemodifier1 != null) {
+ attributeinstance.c(attributemodifier1);
+ }
+
2014-11-28 02:17:45 +01:00
+ attributeinstance.b(attributemodifier);
+ }
+ }
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+
+ public static AttributeModifier a(NBTTagCompound nbttagcompound) {
2016-02-29 22:33:06 +01:00
+ UUID uuid = nbttagcompound.a("UUID");
+
2014-11-28 02:17:45 +01:00
+ try {
+ return new AttributeModifier(uuid, nbttagcompound.getString("Name"), nbttagcompound.getDouble("Amount"), nbttagcompound.getInt("Operation"));
+ } catch (Exception exception) {
2016-02-29 22:33:06 +01:00
+ GenericAttributes.i.warn("Unable to create attribute: " + exception.getMessage());
2014-11-28 02:17:45 +01:00
+ 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
2015-02-28 12:36:22 +01:00
index 0000000..8167fdd
--- /dev/null
+++ b/src/main/java/net/minecraft/server/IntCache.java
2015-02-28 12:36:22 +01:00
@@ -0,0 +1,63 @@
+package net.minecraft.server;
+
2014-11-28 02:17:45 +01:00
+import com.google.common.collect.Lists;
+import java.util.List;
+
+public class IntCache {
+
+ private static int a = 256;
2015-02-28 12:36:22 +01:00
+ private static List<int[]> b = Lists.newArrayList();
+ private static List<int[]> c = Lists.newArrayList();
+ private static List<int[]> d = Lists.newArrayList();
+ private static List<int[]> e = Lists.newArrayList();
+
+ public static synchronized int[] a(int i) {
+ int[] aint;
+
+ if (i <= 256) {
2014-11-28 02:17:45 +01:00
+ if (IntCache.b.isEmpty()) {
+ aint = new int[256];
2014-11-28 02:17:45 +01:00
+ IntCache.c.add(aint);
+ return aint;
+ } else {
2014-11-28 02:17:45 +01:00
+ aint = (int[]) IntCache.b.remove(IntCache.b.size() - 1);
+ IntCache.c.add(aint);
+ return aint;
+ }
2014-11-28 02:17:45 +01:00
+ } 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;
2014-11-28 02:17:45 +01:00
+ } else if (IntCache.d.isEmpty()) {
+ aint = new int[IntCache.a];
+ IntCache.e.add(aint);
+ return aint;
+ } else {
2014-11-28 02:17:45 +01:00
+ aint = (int[]) IntCache.d.remove(IntCache.d.size() - 1);
+ IntCache.e.add(aint);
+ return aint;
+ }
+ }
+
+ public static synchronized void a() {
2014-11-28 02:17:45 +01:00
+ if (!IntCache.d.isEmpty()) {
+ IntCache.d.remove(IntCache.d.size() - 1);
+ }
+
2014-11-28 02:17:45 +01:00
+ if (!IntCache.b.isEmpty()) {
+ IntCache.b.remove(IntCache.b.size() - 1);
+ }
+
2014-11-28 02:17:45 +01:00
+ IntCache.d.addAll(IntCache.e);
+ IntCache.b.addAll(IntCache.c);
+ IntCache.e.clear();
+ IntCache.c.clear();
+ }
+
+ public static synchronized String b() {
2014-11-28 02:17:45 +01:00
+ 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-02-29 22:33:06 +01:00
index 0000000..669940a
2014-11-28 02:17:45 +01:00
--- /dev/null
+++ b/src/main/java/net/minecraft/server/ItemDoor.java
2016-02-29 22:33:06 +01:00
@@ -0,0 +1,66 @@
2014-11-28 02:17:45 +01:00
+package net.minecraft.server;
+
+public class ItemDoor extends Item {
+
+ private Block a;
+
+ public ItemDoor(Block block) {
+ this.a = block;
+ this.a(CreativeModeTab.d);
+ }
+
2016-02-29 22:33:06 +01:00
+ public EnumInteractionResult a(ItemStack itemstack, EntityHuman entityhuman, World world, BlockPosition blockposition, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) {
2014-11-28 02:17:45 +01:00
+ if (enumdirection != EnumDirection.UP) {
2016-02-29 22:33:06 +01:00
+ return EnumInteractionResult.FAIL;
2014-11-28 02:17:45 +01:00
+ } else {
+ IBlockData iblockdata = world.getType(blockposition);
+ Block block = iblockdata.getBlock();
+
2016-02-29 22:33:06 +01:00
+ if (!block.a((IBlockAccess) world, blockposition)) {
2014-11-28 02:17:45 +01:00
+ blockposition = blockposition.shift(enumdirection);
+ }
+
2016-02-29 22:33:06 +01: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);
+ SoundEffectType soundeffecttype = this.a.w();
+
+ world.a(entityhuman, blockposition, soundeffecttype.e(), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F);
2014-11-28 02:17:45 +01:00
+ --itemstack.count;
2016-02-29 22:33:06 +01:00
+ return EnumInteractionResult.SUCCESS;
+ } else {
+ return EnumInteractionResult.FAIL;
2014-11-28 02:17:45 +01:00
+ }
+ }
+ }
+
2016-02-29 22:33:06 +01:00
+ public static void a(World world, BlockPosition blockposition, EnumDirection enumdirection, Block block, boolean flag) {
2014-11-28 02:17:45 +01:00
+ BlockPosition blockposition1 = blockposition.shift(enumdirection.e());
+ BlockPosition blockposition2 = blockposition.shift(enumdirection.f());
2016-02-29 22:33:06 +01:00
+ int i = (world.getType(blockposition2).l() ? 1 : 0) + (world.getType(blockposition2.up()).l() ? 1 : 0);
+ int j = (world.getType(blockposition1).l() ? 1 : 0) + (world.getType(blockposition1.up()).l() ? 1 : 0);
+ 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;
2014-11-28 02:17:45 +01:00
+ }
+
+ BlockPosition blockposition3 = blockposition.up();
2016-02-29 22:33:06 +01: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));
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ world.setTypeAndData(blockposition, iblockdata.set(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER), 2);
+ world.setTypeAndData(blockposition3, iblockdata.set(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2);
2014-11-28 02:17:45 +01:00
+ world.applyPhysics(blockposition, block);
+ world.applyPhysics(blockposition3, block);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/ItemSkull.java b/src/main/java/net/minecraft/server/ItemSkull.java
new file mode 100644
2016-02-29 22:33:06 +01:00
index 0000000..40338ae
--- /dev/null
+++ b/src/main/java/net/minecraft/server/ItemSkull.java
2016-02-29 22:33:06 +01:00
@@ -0,0 +1,123 @@
+package net.minecraft.server;
+
2014-11-28 02:17:45 +01:00
+import com.mojang.authlib.GameProfile;
+import java.util.UUID;
+
+public class ItemSkull extends Item {
+
2016-02-29 22:33:06 +01:00
+ private static final String[] a = new String[] { "skeleton", "wither", "zombie", "char", "creeper", "dragon"};
+
+ public ItemSkull() {
+ this.a(CreativeModeTab.c);
+ this.setMaxDurability(0);
+ this.a(true);
+ }
+
2016-02-29 22:33:06 +01:00
+ public EnumInteractionResult a(ItemStack itemstack, EntityHuman entityhuman, World world, BlockPosition blockposition, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) {
2014-11-28 02:17:45 +01:00
+ if (enumdirection == EnumDirection.DOWN) {
2016-02-29 22:33:06 +01:00
+ return EnumInteractionResult.FAIL;
+ } else {
2014-11-28 02:17:45 +01:00
+ IBlockData iblockdata = world.getType(blockposition);
+ Block block = iblockdata.getBlock();
2016-02-29 22:33:06 +01:00
+ boolean flag = block.a((IBlockAccess) world, blockposition);
+
2014-11-28 02:17:45 +01:00
+ if (!flag) {
2016-02-29 22:33:06 +01:00
+ if (!world.getType(blockposition).getMaterial().isBuildable()) {
+ return EnumInteractionResult.FAIL;
2014-11-28 02:17:45 +01:00
+ }
+
2014-11-28 02:17:45 +01:00
+ blockposition = blockposition.shift(enumdirection);
+ }
+
2016-02-29 22:33:06 +01:00
+ if (entityhuman.a(blockposition, enumdirection, itemstack) && Blocks.SKULL.canPlace(world, blockposition)) {
+ if (world.isClientSide) {
+ return EnumInteractionResult.SUCCESS;
+ } else {
+ world.setTypeAndData(blockposition, Blocks.SKULL.getBlockData().set(BlockSkull.FACING, enumdirection), 11);
2014-11-28 02:17:45 +01:00
+ int i = 0;
+
2014-11-28 02:17:45 +01:00
+ if (enumdirection == EnumDirection.UP) {
+ i = MathHelper.floor((double) (entityhuman.yaw * 16.0F / 360.0F) + 0.5D) & 15;
+ }
+
2014-11-28 02:17:45 +01:00
+ TileEntity tileentity = world.getTileEntity(blockposition);
+
2014-11-28 02:17:45 +01:00
+ if (tileentity instanceof TileEntitySkull) {
+ TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
+
2014-11-28 02:17:45 +01:00
+ if (itemstack.getData() == 3) {
+ GameProfile gameprofile = null;
+
2014-11-28 02:17:45 +01:00
+ if (itemstack.hasTag()) {
+ NBTTagCompound nbttagcompound = itemstack.getTag();
+
2014-11-28 02:17:45 +01:00
+ if (nbttagcompound.hasKeyOfType("SkullOwner", 10)) {
+ gameprofile = GameProfileSerializer.deserialize(nbttagcompound.getCompound("SkullOwner"));
2016-02-29 22:33:06 +01:00
+ } else if (nbttagcompound.hasKeyOfType("SkullOwner", 8) && !nbttagcompound.getString("SkullOwner").isEmpty()) {
2014-11-28 02:17:45 +01:00
+ gameprofile = new GameProfile((UUID) null, nbttagcompound.getString("SkullOwner"));
+ }
+ }
2014-11-28 02:17:45 +01:00
+
+ tileentityskull.setGameProfile(gameprofile);
+ } else {
+ tileentityskull.setSkullType(itemstack.getData());
+ }
+
2014-11-28 02:17:45 +01:00
+ tileentityskull.setRotation(i);
+ Blocks.SKULL.a(world, blockposition, tileentityskull);
+ }
+
2014-11-28 02:17:45 +01:00
+ --itemstack.count;
2016-02-29 22:33:06 +01:00
+ return EnumInteractionResult.SUCCESS;
+ }
2016-02-29 22:33:06 +01:00
+ } else {
+ return EnumInteractionResult.FAIL;
+ }
+ }
+ }
+
+ public int filterData(int i) {
+ return i;
+ }
+
2016-02-29 22:33:06 +01:00
+ public String f_(ItemStack itemstack) {
+ int i = itemstack.getData();
+
2014-11-28 02:17:45 +01:00
+ if (i < 0 || i >= ItemSkull.a.length) {
+ i = 0;
+ }
+
2014-11-28 02:17:45 +01:00
+ return super.getName() + "." + ItemSkull.a[i];
+ }
+
2014-11-28 02:17:45 +01:00
+ public String a(ItemStack itemstack) {
+ if (itemstack.getData() == 3 && itemstack.hasTag()) {
2014-11-28 02:17:45 +01:00
+ if (itemstack.getTag().hasKeyOfType("SkullOwner", 8)) {
+ return LocaleI18n.a("item.skull.player.name", new Object[] { itemstack.getTag().getString("SkullOwner")});
+ }
+
2014-11-28 02:17:45 +01:00
+ if (itemstack.getTag().hasKeyOfType("SkullOwner", 10)) {
+ NBTTagCompound nbttagcompound = itemstack.getTag().getCompound("SkullOwner");
+
+ if (nbttagcompound.hasKeyOfType("Name", 8)) {
+ return LocaleI18n.a("item.skull.player.name", new Object[] { nbttagcompound.getString("Name")});
+ }
+ }
+ }
+
2014-11-28 02:17:45 +01:00
+ return super.a(itemstack);
+ }
+
+ public boolean a(NBTTagCompound nbttagcompound) {
+ super.a(nbttagcompound);
2016-02-29 22:33:06 +01:00
+ if (nbttagcompound.hasKeyOfType("SkullOwner", 8) && !nbttagcompound.getString("SkullOwner").isEmpty()) {
2014-11-28 02:17:45 +01:00
+ GameProfile gameprofile = new GameProfile((UUID) null, nbttagcompound.getString("SkullOwner"));
+
+ gameprofile = TileEntitySkull.b(gameprofile);
+ nbttagcompound.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameprofile));
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/NBTBase.java b/src/main/java/net/minecraft/server/NBTBase.java
new file mode 100644
2015-02-28 12:36:22 +01:00
index 0000000..8756b63
--- /dev/null
+++ b/src/main/java/net/minecraft/server/NBTBase.java
2015-02-28 12:36:22 +01:00
@@ -0,0 +1,104 @@
+package net.minecraft.server;
+
+import java.io.DataInput;
+import java.io.DataOutput;
2015-02-28 12:36:22 +01:00
+import java.io.IOException;
+
+public abstract class NBTBase {
+
+ public static final String[] a = new String[] { "END", "BYTE", "SHORT", "INT", "LONG", "FLOAT", "DOUBLE", "BYTE[]", "STRING", "LIST", "COMPOUND", "INT[]"};
+
2015-02-28 12:36:22 +01:00
+ abstract void write(DataOutput dataoutput) throws IOException;
+
2015-02-28 12:36:22 +01:00
+ abstract void load(DataInput datainput, int i, NBTReadLimiter nbtreadlimiter) throws IOException;
+
+ public abstract String toString();
+
+ public abstract byte getTypeId();
+
+ protected NBTBase() {}
+
+ protected static NBTBase createTag(byte b0) {
+ switch (b0) {
+ case 0:
+ return new NBTTagEnd();
+
+ case 1:
+ return new NBTTagByte();
+
+ case 2:
+ return new NBTTagShort();
+
+ case 3:
+ return new NBTTagInt();
+
+ case 4:
+ return new NBTTagLong();
+
+ case 5:
+ return new NBTTagFloat();
+
+ case 6:
+ return new NBTTagDouble();
+
+ case 7:
+ return new NBTTagByteArray();
+
+ case 8:
+ return new NBTTagString();
+
+ case 9:
+ return new NBTTagList();
+
+ case 10:
+ return new NBTTagCompound();
+
+ case 11:
+ return new NBTTagIntArray();
+
+ default:
+ return null;
+ }
+ }
+
+ public abstract NBTBase clone();
+
2014-11-28 02:17:45 +01:00
+ public boolean isEmpty() {
+ return false;
+ }
+
+ public boolean equals(Object object) {
+ if (!(object instanceof NBTBase)) {
+ return false;
+ } else {
+ NBTBase nbtbase = (NBTBase) object;
+
+ return this.getTypeId() == nbtbase.getTypeId();
+ }
+ }
+
+ public int hashCode() {
+ return this.getTypeId();
+ }
+
+ protected String a_() {
+ return this.toString();
+ }
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ public abstract static class NBTNumber extends NBTBase {
+
+ protected NBTNumber() {}
+
+ public abstract long c();
+
+ public abstract int d();
+
+ public abstract short e();
+
+ public abstract byte f();
+
+ public abstract double g();
+
+ public abstract float h();
+ }
+}
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 12:36:22 +01:00
index 0000000..2a04b86
--- /dev/null
+++ b/src/main/java/net/minecraft/server/NBTCompressedStreamTools.java
2015-02-28 12:36:22 +01:00
@@ -0,0 +1,90 @@
+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 12:36:22 +01:00
+ public static NBTTagCompound a(InputStream inputstream) throws IOException {
+ 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 12:36:22 +01:00
+ public static void a(NBTTagCompound nbttagcompound, OutputStream outputstream) throws IOException {
+ DataOutputStream dataoutputstream = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(outputstream)));
+
+ try {
+ a(nbttagcompound, (DataOutput) dataoutputstream);
+ } finally {
+ dataoutputstream.close();
+ }
2015-02-28 12:36:22 +01:00
+
+ }
+
2015-02-28 12:36:22 +01:00
+ public static NBTTagCompound a(DataInputStream datainputstream) throws IOException {
+ return a((DataInput) datainputstream, NBTReadLimiter.a);
+ }
+
2015-02-28 12:36:22 +01:00
+ public static NBTTagCompound a(DataInput datainput, NBTReadLimiter nbtreadlimiter) throws IOException {
+ 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 12:36:22 +01:00
+ public static void a(NBTTagCompound nbttagcompound, DataOutput dataoutput) throws IOException {
+ a((NBTBase) nbttagcompound, dataoutput);
+ }
+
2015-02-28 12:36:22 +01:00
+ private static void a(NBTBase nbtbase, DataOutput dataoutput) throws IOException {
+ dataoutput.writeByte(nbtbase.getTypeId());
+ if (nbtbase.getTypeId() != 0) {
+ dataoutput.writeUTF("");
+ nbtbase.write(dataoutput);
+ }
+ }
+
2015-02-28 12:36:22 +01:00
+ private static NBTBase a(DataInput datainput, int i, NBTReadLimiter nbtreadlimiter) throws IOException {
+ 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");
+
2014-11-28 02:17:45 +01:00
+ crashreportsystemdetails.a("Tag name", (Object) "[UNNAMED TAG]");
+ crashreportsystemdetails.a("Tag type", (Object) Byte.valueOf(b0));
+ 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 22:23:26 +02:00
index 0000000..c6b5f70
--- /dev/null
+++ b/src/main/java/net/minecraft/server/NBTTagByteArray.java
2015-05-09 22:23:26 +02:00
@@ -0,0 +1,58 @@
+package net.minecraft.server;
+
+import java.io.DataInput;
+import java.io.DataOutput;
2015-02-28 12:36:22 +01: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 12:36:22 +01:00
+ void write(DataOutput dataoutput) throws IOException {
+ dataoutput.writeInt(this.data.length);
+ dataoutput.write(this.data);
+ }
+
2015-02-28 12:36:22 +01:00
+ void load(DataInput datainput, int i, NBTReadLimiter nbtreadlimiter) throws IOException {
2015-05-09 22:23:26 +02: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
2015-05-09 22:23:26 +02:00
index 0000000..5f17034
--- /dev/null
+++ b/src/main/java/net/minecraft/server/NBTTagIntArray.java
2015-05-09 22:23:26 +02:00
@@ -0,0 +1,76 @@
+package net.minecraft.server;
+
+import java.io.DataInput;
+import java.io.DataOutput;
2015-02-28 12:36:22 +01:00
+import java.io.IOException;
+import java.util.Arrays;
+
+public class NBTTagIntArray extends NBTBase {
+
+ private int[] data;
+
+ NBTTagIntArray() {}
+
+ public NBTTagIntArray(int[] aint) {
+ this.data = aint;
+ }
+
2015-02-28 12:36:22 +01:00
+ void write(DataOutput dataoutput) throws IOException {
+ dataoutput.writeInt(this.data.length);
+
+ for (int i = 0; i < this.data.length; ++i) {
+ dataoutput.writeInt(this.data[i]);
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+
2015-02-28 12:36:22 +01:00
+ void load(DataInput datainput, int i, NBTReadLimiter nbtreadlimiter) throws IOException {
2015-05-09 22:23:26 +02:00
+ 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();
+ }
2014-11-28 02:17:45 +01: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 + ",";
+ }
+
+ return s + "]";
+ }
+
+ public NBTBase clone() {
+ 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);
+ }
+
+ public int[] c() {
+ return this.data;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/NextTickListEntry.java b/src/main/java/net/minecraft/server/NextTickListEntry.java
new file mode 100644
2015-02-28 12:36:22 +01:00
index 0000000..648d255
--- /dev/null
+++ b/src/main/java/net/minecraft/server/NextTickListEntry.java
2014-11-28 02:17:45 +01:00
@@ -0,0 +1,56 @@
+package net.minecraft.server;
+
2015-02-28 12:36:22 +01:00
+public class NextTickListEntry implements Comparable<NextTickListEntry> {
+
2014-11-28 02:17:45 +01:00
+ private static long d;
+ private final Block e;
+ public final BlockPosition a;
+ public long b;
+ public int c;
2014-11-28 02:17:45 +01:00
+ private long f;
+
2014-11-28 02:17:45 +01:00
+ public NextTickListEntry(BlockPosition blockposition, Block block) {
+ this.f = (long) (NextTickListEntry.d++);
+ this.a = blockposition;
+ this.e = block;
+ }
+
+ public boolean equals(Object object) {
+ if (!(object instanceof NextTickListEntry)) {
+ return false;
+ } else {
+ NextTickListEntry nextticklistentry = (NextTickListEntry) object;
+
2014-11-28 02:17:45 +01:00
+ return this.a.equals(nextticklistentry.a) && Block.a(this.e, nextticklistentry.e);
+ }
+ }
+
+ public int hashCode() {
2014-11-28 02:17:45 +01:00
+ return this.a.hashCode();
+ }
+
+ public NextTickListEntry a(long i) {
2014-11-28 02:17:45 +01:00
+ this.b = i;
+ return this;
+ }
+
+ public void a(int i) {
2014-11-28 02:17:45 +01:00
+ this.c = i;
+ }
+
2014-11-28 02:17:45 +01:00
+ public int a(NextTickListEntry nextticklistentry) {
+ return this.b < nextticklistentry.b ? -1 : (this.b > nextticklistentry.b ? 1 : (this.c != nextticklistentry.c ? this.c - nextticklistentry.c : (this.f < nextticklistentry.f ? -1 : (this.f > nextticklistentry.f ? 1 : 0))));
+ }
+
+ public String toString() {
2014-11-28 02:17:45 +01:00
+ return Block.getId(this.e) + ": " + this.a + ", " + this.b + ", " + this.c + ", " + this.f;
+ }
+
+ public Block a() {
2014-11-28 02:17:45 +01:00
+ return this.e;
+ }
+
2015-02-28 12:36:22 +01:00
+ public int compareTo(NextTickListEntry object) {
2014-11-28 02:17:45 +01:00
+ return this.a((NextTickListEntry) object);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/NibbleArray.java b/src/main/java/net/minecraft/server/NibbleArray.java
new file mode 100644
2016-02-29 22:33:06 +01:00
index 0000000..1509c77
--- /dev/null
+++ b/src/main/java/net/minecraft/server/NibbleArray.java
2014-11-28 02:17:45 +01:00
@@ -0,0 +1,58 @@
+package net.minecraft.server;
+
+public class NibbleArray {
+
2014-11-28 02:17:45 +01:00
+ private final byte[] a;
+
2014-11-28 02:17:45 +01:00
+ public NibbleArray() {
+ this.a = new byte[2048];
+ }
+
2014-11-28 02:17:45 +01:00
+ public NibbleArray(byte[] abyte) {
+ this.a = abyte;
2014-11-28 02:17:45 +01:00
+ if (abyte.length != 2048) {
+ throw new IllegalArgumentException("ChunkNibbleArrays should be 2048 bytes not: " + abyte.length);
+ }
+ }
+
+ public int a(int i, int j, int k) {
2014-11-28 02:17:45 +01:00
+ return this.a(this.b(i, j, k));
+ }
+
+ public void a(int i, int j, int k, int l) {
2014-11-28 02:17:45 +01:00
+ 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);
+
2014-11-28 02:17:45 +01:00
+ if (this.b(i)) {
+ this.a[k] = (byte) (this.a[k] & 240 | j & 15);
+ } else {
2014-11-28 02:17:45 +01:00
+ this.a[k] = (byte) (this.a[k] & 15 | (j & 15) << 4);
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+
+ private boolean b(int i) {
+ return (i & 1) == 0;
+ }
+
+ private int c(int i) {
+ return i >> 1;
+ }
+
2016-02-29 22:33:06 +01:00
+ public byte[] asBytes() {
2014-11-28 02:17:45 +01:00
+ return this.a;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/OldChunkLoader.java b/src/main/java/net/minecraft/server/OldChunkLoader.java
new file mode 100644
2016-02-29 22:33:06 +01:00
index 0000000..30b1df3
--- /dev/null
+++ b/src/main/java/net/minecraft/server/OldChunkLoader.java
2015-02-28 12:36:22 +01:00
@@ -0,0 +1,145 @@
+package net.minecraft.server;
+
+public class OldChunkLoader {
+
2015-02-28 12:36:22 +01:00
+ public static OldChunkLoader.OldChunk a(NBTTagCompound nbttagcompound) {
+ int i = nbttagcompound.getInt("xPos");
+ int j = nbttagcompound.getInt("zPos");
2015-02-28 12:36:22 +01:00
+ OldChunkLoader.OldChunk oldchunkloader_oldchunk = new OldChunkLoader.OldChunk(i, j);
+
+ oldchunkloader_oldchunk.g = nbttagcompound.getByteArray("Blocks");
+ oldchunkloader_oldchunk.f = new OldNibbleArray(nbttagcompound.getByteArray("Data"), 7);
+ oldchunkloader_oldchunk.e = new OldNibbleArray(nbttagcompound.getByteArray("SkyLight"), 7);
+ oldchunkloader_oldchunk.d = new OldNibbleArray(nbttagcompound.getByteArray("BlockLight"), 7);
+ oldchunkloader_oldchunk.c = nbttagcompound.getByteArray("HeightMap");
+ oldchunkloader_oldchunk.b = nbttagcompound.getBoolean("TerrainPopulated");
+ oldchunkloader_oldchunk.h = nbttagcompound.getList("Entities", 10);
+ oldchunkloader_oldchunk.i = nbttagcompound.getList("TileEntities", 10);
+ oldchunkloader_oldchunk.j = nbttagcompound.getList("TileTicks", 10);
+
+ try {
2015-02-28 12:36:22 +01:00
+ oldchunkloader_oldchunk.a = nbttagcompound.getLong("LastUpdate");
+ } catch (ClassCastException classcastexception) {
2015-02-28 12:36:22 +01:00
+ oldchunkloader_oldchunk.a = (long) nbttagcompound.getInt("LastUpdate");
+ }
+
2015-02-28 12:36:22 +01:00
+ return oldchunkloader_oldchunk;
+ }
+
2015-02-28 12:36:22 +01:00
+ public static void a(OldChunkLoader.OldChunk oldchunkloader_oldchunk, NBTTagCompound nbttagcompound, WorldChunkManager worldchunkmanager) {
+ nbttagcompound.setInt("xPos", oldchunkloader_oldchunk.k);
+ nbttagcompound.setInt("zPos", oldchunkloader_oldchunk.l);
+ nbttagcompound.setLong("LastUpdate", oldchunkloader_oldchunk.a);
+ int[] aint = new int[oldchunkloader_oldchunk.c.length];
+
2015-02-28 12:36:22 +01:00
+ for (int i = 0; i < oldchunkloader_oldchunk.c.length; ++i) {
+ aint[i] = oldchunkloader_oldchunk.c[i];
+ }
+
+ nbttagcompound.setIntArray("HeightMap", aint);
2015-02-28 12:36:22 +01:00
+ nbttagcompound.setBoolean("TerrainPopulated", oldchunkloader_oldchunk.b);
+ NBTTagList nbttaglist = new NBTTagList();
+
+ int j;
2015-02-28 12:36:22 +01:00
+ int k;
+
2015-02-28 12:36:22 +01:00
+ for (int l = 0; l < 8; ++l) {
+ boolean flag = true;
+
+ for (j = 0; j < 16 && flag; ++j) {
2015-02-28 12:36:22 +01:00
+ k = 0;
+
2015-02-28 12:36:22 +01:00
+ while (k < 16 && flag) {
+ int i1 = 0;
+
+ while (true) {
+ if (i1 < 16) {
2015-02-28 12:36:22 +01:00
+ int j1 = j << 11 | i1 << 7 | k + (l << 4);
+ byte b0 = oldchunkloader_oldchunk.g[j1];
+
+ if (b0 == 0) {
+ ++i1;
+ continue;
+ }
+
+ flag = false;
+ }
+
2015-02-28 12:36:22 +01:00
+ ++k;
+ break;
+ }
+ }
+ }
+
+ if (!flag) {
+ byte[] abyte = new byte[4096];
2014-11-28 02:17:45 +01:00
+ NibbleArray nibblearray = new NibbleArray();
+ NibbleArray nibblearray1 = new NibbleArray();
+ NibbleArray nibblearray2 = new NibbleArray();
+
+ for (int k1 = 0; k1 < 16; ++k1) {
+ for (int l1 = 0; l1 < 16; ++l1) {
+ for (int i2 = 0; i2 < 16; ++i2) {
2015-02-28 12:36:22 +01:00
+ int j2 = k1 << 11 | i2 << 7 | l1 + (l << 4);
+ byte b1 = oldchunkloader_oldchunk.g[j2];
+
+ abyte[l1 << 8 | i2 << 4 | k1] = (byte) (b1 & 255);
2015-02-28 12:36:22 +01:00
+ nibblearray.a(k1, l1, i2, oldchunkloader_oldchunk.f.a(k1, l1 + (l << 4), i2));
+ nibblearray1.a(k1, l1, i2, oldchunkloader_oldchunk.e.a(k1, l1 + (l << 4), i2));
+ nibblearray2.a(k1, l1, i2, oldchunkloader_oldchunk.d.a(k1, l1 + (l << 4), i2));
+ }
+ }
+ }
+
+ NBTTagCompound nbttagcompound1 = new NBTTagCompound();
+
2015-02-28 12:36:22 +01:00
+ nbttagcompound1.setByte("Y", (byte) (l & 255));
+ nbttagcompound1.setByteArray("Blocks", abyte);
2016-02-29 22:33:06 +01:00
+ nbttagcompound1.setByteArray("Data", nibblearray.asBytes());
+ nbttagcompound1.setByteArray("SkyLight", nibblearray1.asBytes());
+ nbttagcompound1.setByteArray("BlockLight", nibblearray2.asBytes());
+ nbttaglist.add(nbttagcompound1);
+ }
+ }
+
+ nbttagcompound.set("Sections", nbttaglist);
+ byte[] abyte1 = new byte[256];
2015-02-28 12:36:22 +01:00
+ BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
+
2015-02-28 12:36:22 +01:00
+ for (j = 0; j < 16; ++j) {
+ for (k = 0; k < 16; ++k) {
+ blockposition_mutableblockposition.c(oldchunkloader_oldchunk.k << 4 | j, 0, oldchunkloader_oldchunk.l << 4 | k);
2016-02-29 22:33:06 +01:00
+ abyte1[k << 4 | j] = (byte) (BiomeBase.a(worldchunkmanager.getBiome(blockposition_mutableblockposition, Biomes.b)) & 255);
+ }
+ }
+
+ nbttagcompound.setByteArray("Biomes", abyte1);
2015-02-28 12:36:22 +01:00
+ nbttagcompound.set("Entities", oldchunkloader_oldchunk.h);
+ nbttagcompound.set("TileEntities", oldchunkloader_oldchunk.i);
+ if (oldchunkloader_oldchunk.j != null) {
+ nbttagcompound.set("TileTicks", oldchunkloader_oldchunk.j);
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+
2015-02-28 12:36:22 +01:00
+ public static class OldChunk {
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ public long a;
+ public boolean b;
+ public byte[] c;
+ public OldNibbleArray d;
+ public OldNibbleArray e;
+ public OldNibbleArray f;
+ public byte[] g;
+ public NBTTagList h;
+ public NBTTagList i;
+ public NBTTagList j;
+ public final int k;
+ public final int l;
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ public OldChunk(int i, int j) {
+ this.k = i;
+ this.l = j;
+ }
2014-11-28 02:17:45 +01:00
+ }
+}
2015-07-30 09:22:16 +02: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-02-29 22:33:06 +01:00
index 0000000..86f1be7
2015-07-30 09:22:16 +02: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-02-29 22:33:06 +01:00
+ this.a = packetdataserializer.g();
2015-07-30 09:22:16 +02:00
+ this.hostname = packetdataserializer.c(255);
+ this.port = packetdataserializer.readUnsignedShort();
2016-02-29 22:33:06 +01:00
+ this.d = EnumProtocol.a(packetdataserializer.g());
2015-07-30 09:22:16 +02:00
+ }
+
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
+ packetdataserializer.b(this.a);
+ packetdataserializer.a(this.hostname);
+ packetdataserializer.writeShort(this.port);
+ packetdataserializer.b(this.d.a());
+ }
+
+ public void a(PacketHandshakingInListener packethandshakinginlistener) {
+ packethandshakinginlistener.a(this);
+ }
+
+ public EnumProtocol a() {
+ return this.d;
+ }
+
+ public int b() {
+ return this.a;
+ }
+}
2015-03-15 23:18:05 +01: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-02-29 22:33:06 +01:00
index 0000000..cb0356e
2015-03-15 23:18:05 +01:00
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayInArmAnimation.java
2016-02-29 22:33:06 +01:00
@@ -0,0 +1,30 @@
2015-03-15 23:18:05 +01:00
+package net.minecraft.server;
+
+import java.io.IOException;
+
+public class PacketPlayInArmAnimation implements Packet<PacketListenerPlayIn> {
+
2016-02-29 22:33:06 +01:00
+ private EnumHand a;
+
2015-03-15 23:18:05 +01:00
+ public PacketPlayInArmAnimation() {}
+
2016-02-29 22:33:06 +01: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 23:18:05 +01:00
+
2016-02-29 22:33:06 +01:00
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
+ packetdataserializer.a((Enum) this.a);
+ }
2015-03-15 23:18:05 +01:00
+
+ public void a(PacketListenerPlayIn packetlistenerplayin) {
+ packetlistenerplayin.a(this);
+ }
2016-02-29 22:33:06 +01:00
+
+ public EnumHand a() {
+ return this.a;
+ }
2015-03-15 23:18:05 +01:00
+}
2014-11-28 02:17:45 +01:00
diff --git a/src/main/java/net/minecraft/server/PacketPlayInChat.java b/src/main/java/net/minecraft/server/PacketPlayInChat.java
new file mode 100644
2015-02-28 12:36:22 +01:00
index 0000000..0ab90f3
2014-11-28 02:17:45 +01:00
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayInChat.java
2015-02-28 12:36:22 +01:00
@@ -0,0 +1,34 @@
2014-11-28 02:17:45 +01:00
+package net.minecraft.server;
+
2015-02-28 12:36:22 +01:00
+import java.io.IOException;
+
+public class PacketPlayInChat implements Packet<PacketListenerPlayIn> {
2014-11-28 02:17:45 +01:00
+
+ private String a;
+
+ public PacketPlayInChat() {}
+
+ public PacketPlayInChat(String s) {
+ if (s.length() > 100) {
+ s = s.substring(0, 100);
+ }
+
+ this.a = s;
+ }
+
2015-02-28 12:36:22 +01:00
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
2014-11-28 02:17:45 +01:00
+ this.a = packetdataserializer.c(100);
+ }
+
2015-02-28 12:36:22 +01:00
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
2014-11-28 02:17:45 +01:00
+ packetdataserializer.a(this.a);
+ }
+
+ public void a(PacketListenerPlayIn packetlistenerplayin) {
+ packetlistenerplayin.a(this);
+ }
+
+ public String a() {
+ return this.a;
+ }
+}
2016-02-29 22:33:06 +01: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-02-29 22:33:06 +01:00
index 0000000..c5147b6
--- /dev/null
2016-02-29 22:33:06 +01:00
+++ b/src/main/java/net/minecraft/server/PacketPlayOutChat.java
@@ -0,0 +1,38 @@
+package net.minecraft.server;
+
2015-02-28 12:36:22 +01:00
+import java.io.IOException;
+
2016-02-29 22:33:06 +01:00
+public class PacketPlayOutChat implements Packet<PacketListenerPlayOut> {
+
2016-02-29 22:33:06 +01:00
+ private IChatBaseComponent a;
+ private byte b;
+
2016-02-29 22:33:06 +01:00
+ public PacketPlayOutChat() {}
+
2016-02-29 22:33:06 +01:00
+ public PacketPlayOutChat(IChatBaseComponent ichatbasecomponent) {
+ this(ichatbasecomponent, (byte) 1);
+ }
+
+ public PacketPlayOutChat(IChatBaseComponent ichatbasecomponent, byte b0) {
+ this.a = ichatbasecomponent;
+ this.b = b0;
2014-11-28 02:17:45 +01:00
+ }
+
2015-02-28 12:36:22 +01:00
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
2016-02-29 22:33:06 +01:00
+ this.a = packetdataserializer.f();
+ this.b = packetdataserializer.readByte();
2014-11-28 02:17:45 +01:00
+ }
+
2015-02-28 12:36:22 +01:00
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
2016-02-29 22:33:06 +01:00
+ packetdataserializer.a(this.a);
+ packetdataserializer.writeByte(this.b);
2014-11-28 02:17:45 +01:00
+ }
+
2014-11-28 02:17:45 +01:00
+ public void a(PacketListenerPlayOut packetlistenerplayout) {
+ packetlistenerplayout.a(this);
+ }
+
2016-02-29 22:33:06 +01:00
+ public boolean b() {
+ return this.b == 1 || this.b == 2;
+ }
2014-11-28 02:17:45 +01:00
+}
2016-02-29 22:33:06 +01:00
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
2014-11-28 02:17:45 +01:00
new file mode 100644
2016-02-29 22:33:06 +01:00
index 0000000..b5dc220
2014-11-28 02:17:45 +01:00
--- /dev/null
2016-02-29 22:33:06 +01:00
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
@@ -0,0 +1,110 @@
2014-11-28 02:17:45 +01:00
+package net.minecraft.server;
+
2016-02-29 22:33:06 +01:00
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
2015-02-28 12:36:22 +01:00
+import java.io.IOException;
+
2016-02-29 22:33:06 +01:00
+public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
+
2016-02-29 22:33:06 +01:00
+ private int a;
+ private int b;
+ private int c;
+ private byte[] d;
+ private boolean e;
+
2016-02-29 22:33:06 +01:00
+ public PacketPlayOutMapChunk() {}
+
2016-02-29 22:33:06 +01:00
+ public PacketPlayOutMapChunk(Chunk chunk, boolean flag, int i) {
+ this.a = chunk.locX;
+ this.b = chunk.locZ;
+ this.e = flag;
+ boolean flag1 = !chunk.getWorld().worldProvider.m();
+
2016-02-29 22:33:06 +01:00
+ this.d = new byte[a(chunk, flag, flag1, i)];
+ this.c = a(new PacketDataSerializer(this.f()), chunk, flag, flag1, i);
+ }
+
2016-02-29 22:33:06 +01:00
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
+ this.a = packetdataserializer.readInt();
+ this.b = packetdataserializer.readInt();
+ this.e = packetdataserializer.readBoolean();
+ this.c = packetdataserializer.g();
+ int i = packetdataserializer.g();
+
2016-02-29 22:33:06 +01:00
+ if (i > 2097152) {
+ throw new RuntimeException("Chunk Packet trying to allocate too much memory on read.");
+ } else {
+ this.d = new byte[i];
+ packetdataserializer.readBytes(this.d);
+ }
2016-02-29 22:33:06 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
+ packetdataserializer.writeInt(this.a);
+ packetdataserializer.writeInt(this.b);
+ packetdataserializer.writeBoolean(this.e);
+ packetdataserializer.b(this.c);
+ packetdataserializer.b(this.d.length);
+ packetdataserializer.writeBytes(this.d);
+ }
+
2016-02-29 22:33:06 +01:00
+ public void a(PacketListenerPlayOut packetlistenerplayout) {
+ packetlistenerplayout.a(this);
+ }
+
2016-02-29 22:33:06 +01:00
+ private ByteBuf f() {
+ ByteBuf bytebuf = Unpooled.wrappedBuffer(this.d);
+
2016-02-29 22:33:06 +01:00
+ bytebuf.writerIndex(0);
+ return bytebuf;
+ }
+
+ public static int a(PacketDataSerializer packetdataserializer, Chunk chunk, boolean flag, boolean flag1, int i) {
+ int j = 0;
+ ChunkSection[] achunksection = chunk.getSections();
+ int k = 0;
+
2016-02-29 22:33:06 +01:00
+ for (int l = achunksection.length; k < l; ++k) {
+ ChunkSection chunksection = achunksection[k];
+
+ if (chunksection != Chunk.a && (!flag || !chunksection.a()) && (i & 1 << k) != 0) {
+ j |= 1 << k;
+ chunksection.getBlocks().b(packetdataserializer);
+ packetdataserializer.writeBytes(chunksection.getEmittedLightArray().asBytes());
+ if (flag1) {
+ packetdataserializer.writeBytes(chunksection.getSkyLightArray().asBytes());
+ }
+ }
+ }
+
2016-02-29 22:33:06 +01:00
+ if (flag) {
+ packetdataserializer.writeBytes(chunk.getBiomeIndex());
+ }
+
2016-02-29 22:33:06 +01:00
+ return j;
2014-11-28 02:17:45 +01:00
+ }
+
2016-02-29 22:33:06 +01:00
+ protected static int a(Chunk chunk, boolean flag, boolean flag1, int i) {
+ int j = 0;
+ ChunkSection[] achunksection = chunk.getSections();
+ int k = 0;
+
2016-02-29 22:33:06 +01:00
+ for (int l = achunksection.length; k < l; ++k) {
+ ChunkSection chunksection = achunksection[k];
+
2016-02-29 22:33:06 +01:00
+ if (chunksection != Chunk.a && (!flag || !chunksection.a()) && (i & 1 << k) != 0) {
+ j += chunksection.getBlocks().a();
+ j += chunksection.getEmittedLightArray().asBytes().length;
+ if (flag1) {
+ j += chunksection.getSkyLightArray().asBytes().length;
+ }
+ }
+ }
+
2016-02-29 22:33:06 +01:00
+ if (flag) {
+ j += chunk.getBiomeIndex().length;
+ }
+
2016-02-29 22:33:06 +01:00
+ return j;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutOpenWindow.java b/src/main/java/net/minecraft/server/PacketPlayOutOpenWindow.java
new file mode 100644
2016-02-29 22:33:06 +01:00
index 0000000..2bcdc17
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutOpenWindow.java
2015-02-28 12:36:22 +01:00
@@ -0,0 +1,56 @@
+package net.minecraft.server;
+
2015-02-28 12:36:22 +01:00
+import java.io.IOException;
+
+public class PacketPlayOutOpenWindow implements Packet<PacketListenerPlayOut> {
+
+ private int a;
2014-11-28 02:17:45 +01:00
+ private String b;
+ private IChatBaseComponent c;
+ private int d;
2014-11-28 02:17:45 +01:00
+ private int e;
+
+ public PacketPlayOutOpenWindow() {}
+
2014-11-28 02:17:45 +01:00
+ public PacketPlayOutOpenWindow(int i, String s, IChatBaseComponent ichatbasecomponent) {
+ this(i, s, ichatbasecomponent, 0);
+ }
+
+ public PacketPlayOutOpenWindow(int i, String s, IChatBaseComponent ichatbasecomponent, int j) {
+ this.a = i;
2014-11-28 02:17:45 +01:00
+ this.b = s;
+ this.c = ichatbasecomponent;
+ this.d = j;
+ }
+
2014-11-28 02:17:45 +01:00
+ public PacketPlayOutOpenWindow(int i, String s, IChatBaseComponent ichatbasecomponent, int j, int k) {
+ this(i, s, ichatbasecomponent, j);
+ this.e = k;
+ }
+
2014-11-28 02:17:45 +01:00
+ public void a(PacketListenerPlayOut packetlistenerplayout) {
+ packetlistenerplayout.a(this);
+ }
+
2015-02-28 12:36:22 +01:00
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
+ this.a = packetdataserializer.readUnsignedByte();
2014-11-28 02:17:45 +01:00
+ this.b = packetdataserializer.c(32);
2016-02-29 22:33:06 +01:00
+ this.c = packetdataserializer.f();
+ this.d = packetdataserializer.readUnsignedByte();
2014-11-28 02:17:45 +01:00
+ if (this.b.equals("EntityHorse")) {
+ this.e = packetdataserializer.readInt();
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+
2015-02-28 12:36:22 +01:00
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
+ packetdataserializer.writeByte(this.a);
2014-11-28 02:17:45 +01:00
+ packetdataserializer.a(this.b);
+ packetdataserializer.a(this.c);
+ packetdataserializer.writeByte(this.d);
2014-11-28 02:17:45 +01:00
+ if (this.b.equals("EntityHorse")) {
+ packetdataserializer.writeInt(this.e);
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalSwell.java b/src/main/java/net/minecraft/server/PathfinderGoalSwell.java
new file mode 100644
2016-02-29 22:33:06 +01:00
index 0000000..bab71cc
2014-11-28 02:17:45 +01:00
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PathfinderGoalSwell.java
@@ -0,0 +1,39 @@
+package net.minecraft.server;
+
+public class PathfinderGoalSwell extends PathfinderGoal {
+
+ EntityCreeper a;
+ EntityLiving b;
+
+ public PathfinderGoalSwell(EntityCreeper entitycreeper) {
+ this.a = entitycreeper;
+ this.a(1);
+ }
+
+ public boolean a() {
+ EntityLiving entityliving = this.a.getGoalTarget();
+
2016-02-29 22:33:06 +01:00
+ return this.a.da() > 0 || entityliving != null && this.a.h(entityliving) < 9.0D;
2014-11-28 02:17:45 +01:00
+ }
+
+ public void c() {
2016-02-29 22:33:06 +01:00
+ this.a.getNavigation().o();
2014-11-28 02:17:45 +01:00
+ this.b = this.a.getGoalTarget();
+ }
+
+ public void d() {
+ this.b = null;
+ }
+
2014-11-28 02:17:45 +01:00
+ public void e() {
+ if (this.b == null) {
+ this.a.a(-1);
+ } else if (this.a.h(this.b) > 49.0D) {
+ this.a.a(-1);
+ } else if (!this.a.getEntitySenses().a(this.b)) {
+ this.a.a(-1);
+ } else {
+ this.a.a(1);
+ }
+ }
+}
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-02-29 22:33:06 +01:00
index 0000000..c29e3f7
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PersistentCollection.java
2016-02-29 22:33:06 +01:00
@@ -0,0 +1,183 @@
+package net.minecraft.server;
+
2014-11-28 02:17:45 +01:00
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+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;
+
+public class PersistentCollection {
+
2014-11-28 02:17:45 +01:00
+ private IDataManager b;
2015-02-28 12:36:22 +01:00
+ protected Map<String, PersistentBase> a = Maps.newHashMap();
+ private List<PersistentBase> c = Lists.newArrayList();
+ private Map<String, Short> d = Maps.newHashMap();
+
+ public PersistentCollection(IDataManager idatamanager) {
2014-11-28 02:17:45 +01:00
+ this.b = idatamanager;
+ this.b();
+ }
+
2015-02-28 12:36:22 +01:00
+ public PersistentBase get(Class<? extends PersistentBase> oclass, String s) {
2014-11-28 02:17:45 +01:00
+ PersistentBase persistentbase = (PersistentBase) this.a.get(s);
+
+ if (persistentbase != null) {
+ return persistentbase;
+ } else {
2014-11-28 02:17:45 +01:00
+ if (this.b != null) {
+ try {
2014-11-28 02:17:45 +01:00
+ File file = this.b.getDataFile(s);
+
2014-11-28 02:17:45 +01:00
+ if (file != null && file.exists()) {
+ try {
+ persistentbase = (PersistentBase) oclass.getConstructor(new Class[] { String.class}).newInstance(new Object[] { s});
+ } catch (Exception exception) {
+ throw new RuntimeException("Failed to instantiate " + oclass.toString(), exception);
+ }
+
2014-11-28 02:17:45 +01:00
+ FileInputStream fileinputstream = new FileInputStream(file);
+ NBTTagCompound nbttagcompound = NBTCompressedStreamTools.a((InputStream) fileinputstream);
+
+ fileinputstream.close();
+ persistentbase.a(nbttagcompound.getCompound("data"));
+ }
+ } catch (Exception exception1) {
+ exception1.printStackTrace();
+ }
+ }
+
+ if (persistentbase != null) {
2014-11-28 02:17:45 +01:00
+ this.a.put(s, persistentbase);
+ this.c.add(persistentbase);
+ }
+
+ return persistentbase;
+ }
+ }
+
+ public void a(String s, PersistentBase persistentbase) {
2014-11-28 02:17:45 +01:00
+ if (this.a.containsKey(s)) {
+ this.c.remove(this.a.remove(s));
+ }
2014-11-28 02:17:45 +01:00
+
+ this.a.put(s, persistentbase);
+ this.c.add(persistentbase);
+ }
+
+ 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-11-28 02:17:45 +01:00
+
+ }
+
+ private void a(PersistentBase persistentbase) {
2014-11-28 02:17:45 +01:00
+ if (this.b != null) {
+ try {
2014-11-28 02:17:45 +01:00
+ File file = this.b.getDataFile(persistentbase.id);
+
2014-11-28 02:17:45 +01:00
+ if (file != null) {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+
+ persistentbase.b(nbttagcompound);
+ NBTTagCompound nbttagcompound1 = new NBTTagCompound();
+
+ nbttagcompound1.set("data", nbttagcompound);
2014-11-28 02:17:45 +01:00
+ FileOutputStream fileoutputstream = new FileOutputStream(file);
+
+ NBTCompressedStreamTools.a(nbttagcompound1, (OutputStream) fileoutputstream);
+ fileoutputstream.close();
+ }
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+ }
+
+ private void b() {
+ try {
+ this.d.clear();
2014-11-28 02:17:45 +01:00
+ if (this.b == null) {
+ return;
+ }
+
2014-11-28 02:17:45 +01:00
+ File file = this.b.getDataFile("idcounts");
+
2014-11-28 02:17:45 +01:00
+ if (file != null && file.exists()) {
+ DataInputStream datainputstream = new DataInputStream(new FileInputStream(file));
+ 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;
2014-11-28 02:17:45 +01:00
+ short short0 = nbttagshort.e();
+
2014-11-28 02:17:45 +01:00
+ this.d.put(s, Short.valueOf(short0));
+ }
+ }
+ }
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
2014-11-28 02:17:45 +01: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);
2014-11-28 02:17:45 +01:00
+ if (this.b == null) {
+ return oshort.shortValue();
+ } else {
+ try {
2014-11-28 02:17:45 +01:00
+ File file = this.b.getDataFile("idcounts");
+
2014-11-28 02:17:45 +01:00
+ if (file != null) {
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+ Iterator iterator = this.d.keySet().iterator();
+
+ while (iterator.hasNext()) {
+ String s1 = (String) iterator.next();
+
2016-02-29 22:33:06 +01:00
+ nbttagcompound.setShort(s1, ((Short) this.d.get(s1)).shortValue());
+ }
+
2014-11-28 02:17:45 +01:00
+ DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(file));
+
+ NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream);
+ dataoutputstream.close();
+ }
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+
+ return oshort.shortValue();
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
new file mode 100644
2015-02-28 12:36:22 +01:00
index 0000000..b07e7d5
--- /dev/null
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
2015-02-28 12:36:22 +01:00
@@ -0,0 +1,67 @@
+package net.minecraft.server;
+
2014-11-28 02:17:45 +01:00
+import com.google.common.collect.Maps;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+public class RegionFileCache {
+
2015-02-28 12:36:22 +01:00
+ private static final Map<File, RegionFile> a = Maps.newHashMap();
+
2014-11-28 02:17:45 +01:00
+ public static synchronized RegionFile a(File file, int i, int j) {
+ File file1 = new File(file, "region");
+ File file2 = new File(file1, "r." + (i >> 5) + "." + (j >> 5) + ".mca");
+ RegionFile regionfile = (RegionFile) RegionFileCache.a.get(file2);
+
+ if (regionfile != null) {
+ return regionfile;
+ } else {
2014-11-28 02:17:45 +01:00
+ if (!file1.exists()) {
+ file1.mkdirs();
+ }
+
2014-11-28 02:17:45 +01:00
+ if (RegionFileCache.a.size() >= 256) {
+ a();
+ }
+
2014-11-28 02:17:45 +01:00
+ RegionFile regionfile1 = new RegionFile(file2);
+
2014-11-28 02:17:45 +01:00
+ RegionFileCache.a.put(file2, regionfile1);
+ return regionfile1;
+ }
+ }
+
+ public static synchronized void a() {
2014-11-28 02:17:45 +01:00
+ Iterator iterator = RegionFileCache.a.values().iterator();
+
+ while (iterator.hasNext()) {
+ RegionFile regionfile = (RegionFile) iterator.next();
+
+ try {
+ if (regionfile != null) {
+ regionfile.c();
+ }
+ } catch (IOException ioexception) {
+ ioexception.printStackTrace();
+ }
+ }
+
2014-11-28 02:17:45 +01:00
+ RegionFileCache.a.clear();
+ }
+
2014-11-28 02:17:45 +01:00
+ public static DataInputStream c(File file, int i, int j) {
+ RegionFile regionfile = a(file, i, j);
+
+ return regionfile.a(i & 31, j & 31);
+ }
+
2014-11-28 02:17:45 +01:00
+ public static DataOutputStream d(File file, int i, int j) {
+ RegionFile regionfile = a(file, i, j);
+
+ return regionfile.b(i & 31, j & 31);
+ }
+}
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-02-29 22:33:06 +01:00
index 0000000..968a1b7
--- /dev/null
+++ b/src/main/java/net/minecraft/server/ServerConnection.java
2015-02-28 12:36:22 +01:00
@@ -0,0 +1,175 @@
+package net.minecraft.server;
+
2014-11-28 02:17:45 +01:00
+import com.google.common.collect.Lists;
2015-02-28 12:36:22 +01:00
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
2014-11-28 02:17:45 +01:00
+import io.netty.bootstrap.ServerBootstrap;
2015-02-28 12:36:22 +01:00
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelException;
2014-11-28 02:17:45 +01:00
+import io.netty.channel.ChannelFuture;
2015-02-28 12:36:22 +01:00
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
2014-11-28 02:17:45 +01:00
+import io.netty.channel.EventLoopGroup;
2015-02-28 12:36:22 +01: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;
2014-11-28 02:17:45 +01:00
+import io.netty.channel.socket.nio.NioServerSocketChannel;
2015-02-28 12:36:22 +01:00
+import io.netty.handler.timeout.ReadTimeoutHandler;
+import io.netty.util.concurrent.Future;
2014-11-28 02:17:45 +01:00
+import io.netty.util.concurrent.GenericFutureListener;
2015-02-28 12:36:22 +01:00
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.Callable;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class ServerConnection {
+
2015-02-28 12:36:22 +01: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 12:36:22 +01: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 12:36:22 +01: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 12:36:22 +01:00
+ protected Object init() {
+ return this.a();
+ }
2015-02-28 12:36:22 +01: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 12:36:22 +01:00
+ public void a(InetAddress inetaddress, int i) throws IOException {
+ List list = this.g;
+
2015-02-28 12:36:22 +01:00
+ synchronized (this.g) {
+ Class oclass;
+ LazyInitVar lazyinitvar;
+
2016-02-29 22:33:06 +01:00
+ if (Epoll.isAvailable() && this.f.ae()) {
2015-02-28 12:36:22 +01: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-02-29 22:33:06 +01:00
+ networkmanager.setPacketListener(new HandshakeListener(ServerConnection.this.f, networkmanager));
2015-02-28 12:36:22 +01: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();
+
2014-11-28 02:17:45 +01:00
+ try {
+ channelfuture.channel().close().sync();
+ } catch (InterruptedException interruptedexception) {
2015-02-28 12:36:22 +01:00
+ ServerConnection.e.error("Interrupted whilst closing channel");
2014-11-28 02:17:45 +01:00
+ }
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+
+ public void c() {
2015-02-28 12:36:22 +01:00
+ List list = this.h;
+
2015-02-28 12:36:22 +01:00
+ synchronized (this.h) {
+ Iterator iterator = this.h.iterator();
+
+ while (iterator.hasNext()) {
2015-02-28 12:36:22 +01:00
+ final NetworkManager networkmanager = (NetworkManager) iterator.next();
+
2014-11-28 02:17:45 +01:00
+ if (!networkmanager.h()) {
2016-02-29 22:33:06 +01:00
+ if (networkmanager.isConnected()) {
2014-11-28 02:17:45 +01:00
+ try {
+ networkmanager.a();
+ } catch (Exception exception) {
2016-02-29 22:33:06 +01:00
+ if (networkmanager.isLocal()) {
2014-11-28 02:17:45 +01:00
+ CrashReport crashreport = CrashReport.a(exception, "Ticking memory connection");
+ CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Ticking connection");
+
2015-02-28 12:36:22 +01:00
+ crashreportsystemdetails.a("Connection", new Callable() {
+ public String a() throws Exception {
+ return networkmanager.toString();
+ }
+
+ public Object call() throws Exception {
+ return this.a();
+ }
+ });
2014-11-28 02:17:45 +01:00
+ throw new ReportedException(crashreport);
+ }
+
2015-02-28 12:36:22 +01:00
+ ServerConnection.e.warn("Failed to handle packet for " + networkmanager.getSocketAddress(), exception);
+ final ChatComponentText chatcomponenttext = new ChatComponentText("Internal server error");
+
2016-02-29 22:33:06 +01:00
+ networkmanager.sendPacket(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener() {
2015-05-09 22:23:26 +02:00
+ public void operationComplete(Future future) throws Exception {
2015-02-28 12:36:22 +01:00
+ networkmanager.close(chatcomponenttext);
+ }
+ }, new GenericFutureListener[0]);
2016-02-29 22:33:06 +01:00
+ networkmanager.stopReading();
2014-11-28 02:17:45 +01:00
+ }
2016-02-29 22:33:06 +01:00
+ } else {
+ iterator.remove();
+ networkmanager.handleDisconnection();
+ }
+ }
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+ }
+
+ public MinecraftServer d() {
2015-02-28 12:36:22 +01:00
+ return this.f;
+ }
+}
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-02-29 22:33:06 +01:00
index 0000000..76bd9c1
--- /dev/null
+++ b/src/main/java/net/minecraft/server/ServerStatisticManager.java
2015-02-28 12:36:22 +01:00
@@ -0,0 +1,212 @@
+package net.minecraft.server;
+
2014-11-28 02:17:45 +01:00
+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;
+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;
2014-11-28 02:17:45 +01:00
+import org.apache.commons.io.FileUtils;
+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 12:36:22 +01:00
+ private final Set<Statistic> e = Sets.newHashSet();
+ private int f = -300;
+ private boolean g = false;
+
2014-11-28 02:17:45 +01:00
+ public ServerStatisticManager(MinecraftServer minecraftserver, File file) {
+ this.c = minecraftserver;
2014-11-28 02:17:45 +01:00
+ this.d = file;
+ }
+
+ public void a() {
+ if (this.d.isFile()) {
+ try {
+ this.a.clear();
+ this.a.putAll(this.a(FileUtils.readFileToString(this.d)));
+ } catch (IOException ioexception) {
2014-11-28 02:17:45 +01:00
+ ServerStatisticManager.b.error("Couldn\'t read statistics file " + this.d, ioexception);
+ } catch (JsonParseException jsonparseexception) {
2014-11-28 02:17:45 +01:00
+ ServerStatisticManager.b.error("Couldn\'t parse statistics file " + this.d, jsonparseexception);
+ }
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+
+ public void b() {
+ try {
+ FileUtils.writeStringToFile(this.d, a(this.a));
+ } catch (IOException ioexception) {
2014-11-28 02:17:45 +01:00
+ ServerStatisticManager.b.error("Couldn\'t save stats", ioexception);
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+
+ public void setStatistic(EntityHuman entityhuman, Statistic statistic, int i) {
+ int j = statistic.d() ? this.getStatisticValue(statistic) : 0;
+
+ super.setStatistic(entityhuman, statistic, i);
+ this.e.add(statistic);
+ if (statistic.d() && j == 0 && i > 0) {
+ this.g = true;
2016-02-29 22:33:06 +01:00
+ if (this.c.ax()) {
+ this.c.getPlayerList().sendMessage(new ChatMessage("chat.type.achievement", new Object[] { entityhuman.getScoreboardDisplayName(), statistic.j()}));
+ }
+ }
2014-11-28 02:17:45 +01:00
+
+ if (statistic.d() && j > 0 && i == 0) {
+ this.g = true;
2016-02-29 22:33:06 +01:00
+ if (this.c.ax()) {
2014-11-28 02:17:45 +01:00
+ this.c.getPlayerList().sendMessage(new ChatMessage("chat.type.achievement.taken", new Object[] { entityhuman.getScoreboardDisplayName(), statistic.j()}));
+ }
+ }
+
+ }
+
2015-02-28 12:36:22 +01:00
+ public Set<Statistic> c() {
+ HashSet hashset = Sets.newHashSet(this.e);
+
+ this.e.clear();
+ this.g = false;
+ return hashset;
+ }
+
2015-02-28 12:36:22 +01:00
+ public Map<Statistic, StatisticWrapper> a(String s) {
+ 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();
+ Statistic statistic = StatisticList.getStatistic((String) entry.getKey());
+
+ 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]);
+
+ ijsonstatistic.a(jsonobject1.get("progress"));
+ statisticwrapper.a(ijsonstatistic);
+ } catch (Throwable throwable) {
2014-11-28 02:17:45 +01:00
+ ServerStatisticManager.b.warn("Invalid statistic progress in " + this.d, throwable);
+ }
+ }
+ }
+
+ hashmap.put(statistic, statisticwrapper);
+ } else {
2014-11-28 02:17:45 +01:00
+ ServerStatisticManager.b.warn("Invalid statistic in " + this.d + ": Don\'t know what " + (String) entry.getKey() + " is");
+ }
+ }
+
+ return hashmap;
+ }
+ }
+
2015-02-28 12:36:22 +01:00
+ public static String a(Map<Statistic, StatisticWrapper> map) {
+ 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) {
2014-11-28 02:17:45 +01:00
+ ServerStatisticManager.b.warn("Couldn\'t save statistic " + ((Statistic) entry.getKey()).e() + ": error serializing progress", throwable);
+ }
+
+ jsonobject.add(((Statistic) entry.getKey()).name, jsonobject1);
+ } else {
+ jsonobject.addProperty(((Statistic) entry.getKey()).name, Integer.valueOf(((StatisticWrapper) entry.getValue()).a()));
+ }
+ }
+
+ 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-11-28 02:17:45 +01:00
+
+ }
+
+ public void a(EntityPlayer entityplayer) {
2016-02-29 22:33:06 +01:00
+ int i = this.c.ap();
+ 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();
+
+ hashmap.put(statistic, Integer.valueOf(this.getStatisticValue(statistic)));
+ }
+ }
+
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutStatistic(hashmap));
+ }
+
+ public void updateStatistics(EntityPlayer entityplayer) {
+ HashMap hashmap = Maps.newHashMap();
+ Iterator iterator = AchievementList.e.iterator();
+
+ while (iterator.hasNext()) {
+ Achievement achievement = (Achievement) iterator.next();
+
+ if (this.hasAchievement(achievement)) {
+ hashmap.put(achievement, Integer.valueOf(this.getStatisticValue(achievement)));
+ this.e.remove(achievement);
+ }
+ }
+
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutStatistic(hashmap));
+ }
+
+ public boolean e() {
+ return this.g;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/StructureGenerator.java b/src/main/java/net/minecraft/server/StructureGenerator.java
new file mode 100644
2016-02-29 22:33:06 +01:00
index 0000000..dacba33
--- /dev/null
+++ b/src/main/java/net/minecraft/server/StructureGenerator.java
2016-02-29 22:33:06 +01:00
@@ -0,0 +1,239 @@
+package net.minecraft.server;
+
2014-11-28 02:17:45 +01:00
+import com.google.common.collect.Maps;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.concurrent.Callable;
+
+public abstract class StructureGenerator extends WorldGenBase {
+
2016-02-29 22:33:06 +01:00
+ private PersistentStructure a;
+ protected Map<Long, StructureStart> c = Maps.newHashMap();
+
+ public StructureGenerator() {}
+
+ public abstract String a();
+
2016-02-29 22:33:06 +01:00
+ protected final synchronized void a(World world, final int i, final int j, int k, int l, ChunkSnapshot chunksnapshot) {
+ this.a(world);
2016-02-29 22:33:06 +01:00
+ if (!this.c.containsKey(Long.valueOf(ChunkCoordIntPair.a(i, j)))) {
+ this.f.nextInt();
+
+ try {
+ if (this.a(i, j)) {
+ StructureStart structurestart = this.b(i, j);
+
2016-02-29 22:33:06 +01:00
+ this.c.put(Long.valueOf(ChunkCoordIntPair.a(i, j)), structurestart);
+ if (structurestart.a()) {
+ this.a(i, j, structurestart);
+ }
+ }
2014-11-28 02:17:45 +01:00
+
+ } catch (Throwable throwable) {
+ CrashReport crashreport = CrashReport.a(throwable, "Exception preparing structure feature");
+ CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Feature being prepared");
+
2015-02-28 12:36:22 +01:00
+ crashreportsystemdetails.a("Is feature chunk", new Callable() {
+ public String a() throws Exception {
+ return StructureGenerator.this.a(i, j) ? "True" : "False";
+ }
+
+ public Object call() throws Exception {
+ return this.a();
+ }
+ });
2014-11-28 02:17:45 +01:00
+ crashreportsystemdetails.a("Chunk location", (Object) String.format("%d,%d", new Object[] { Integer.valueOf(i), Integer.valueOf(j)}));
2015-02-28 12:36:22 +01:00
+ crashreportsystemdetails.a("Chunk pos hash", new Callable() {
+ 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 Callable() {
+ public String a() throws Exception {
+ return StructureGenerator.this.getClass().getCanonicalName();
+ }
+
+ public Object call() throws Exception {
+ return this.a();
+ }
+ });
+ throw new ReportedException(crashreport);
+ }
+ }
+ }
+
2016-02-29 22:33:06 +01:00
+ public synchronized boolean a(World world, Random random, ChunkCoordIntPair chunkcoordintpair) {
+ this.a(world);
2014-11-28 02:17:45 +01:00
+ int i = (chunkcoordintpair.x << 4) + 8;
+ int j = (chunkcoordintpair.z << 4) + 8;
+ boolean flag = false;
2016-02-29 22:33:06 +01:00
+ Iterator iterator = this.c.values().iterator();
+
+ while (iterator.hasNext()) {
+ StructureStart structurestart = (StructureStart) iterator.next();
+
2016-02-29 22:33:06 +01:00
+ if (structurestart.a() && structurestart.a(chunkcoordintpair) && structurestart.b().a(i, j, i + 15, j + 15)) {
2014-11-28 02:17:45 +01:00
+ 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;
+ }
+
2014-11-28 02:17:45 +01:00
+ public boolean b(BlockPosition blockposition) {
2016-02-29 22:33:06 +01:00
+ this.a(this.g);
2014-11-28 02:17:45 +01:00
+ return this.c(blockposition) != null;
+ }
+
2014-11-28 02:17:45 +01:00
+ protected StructureStart c(BlockPosition blockposition) {
2016-02-29 22:33:06 +01:00
+ Iterator iterator = this.c.values().iterator();
+
+ while (iterator.hasNext()) {
+ StructureStart structurestart = (StructureStart) iterator.next();
+
2016-02-29 22:33:06 +01:00
+ if (structurestart.a() && structurestart.b().b((BaseBlockPosition) blockposition)) {
+ Iterator iterator1 = structurestart.c().iterator();
+
+ while (iterator1.hasNext()) {
+ StructurePiece structurepiece = (StructurePiece) iterator1.next();
+
2014-11-28 02:17:45 +01:00
+ if (structurepiece.c().b((BaseBlockPosition) blockposition)) {
+ return structurestart;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
2016-02-29 22:33:06 +01:00
+ public boolean b(World world, BlockPosition blockposition) {
2014-11-28 02:17:45 +01:00
+ this.a(world);
2016-02-29 22:33:06 +01:00
+ Iterator iterator = this.c.values().iterator();
+
+ StructureStart structurestart;
+
+ do {
+ if (!iterator.hasNext()) {
+ return false;
+ }
+
+ structurestart = (StructureStart) iterator.next();
2016-02-29 22:33:06 +01:00
+ } while (!structurestart.a() || !structurestart.b().b((BaseBlockPosition) blockposition));
+
2014-11-28 02:17:45 +01:00
+ return true;
+ }
+
2014-11-28 02:17:45 +01:00
+ public BlockPosition getNearestGeneratedFeature(World world, BlockPosition blockposition) {
2016-02-29 22:33:06 +01:00
+ this.g = world;
+ this.a(world);
2016-02-29 22:33:06 +01:00
+ this.f.setSeed(world.getSeed());
+ long i = this.f.nextLong();
+ long j = this.f.nextLong();
2014-11-28 02:17:45 +01:00
+ long k = (long) (blockposition.getX() >> 4) * i;
+ long l = (long) (blockposition.getZ() >> 4) * j;
+
2016-02-29 22:33:06 +01:00
+ this.f.setSeed(k ^ l ^ world.getSeed());
2014-11-28 02:17:45 +01:00
+ this.a(world, blockposition.getX() >> 4, blockposition.getZ() >> 4, 0, 0, (ChunkSnapshot) null);
+ double d0 = Double.MAX_VALUE;
2014-11-28 02:17:45 +01:00
+ BlockPosition blockposition1 = null;
2016-02-29 22:33:06 +01:00
+ Iterator iterator = this.c.values().iterator();
+
2014-11-28 02:17:45 +01:00
+ BlockPosition blockposition2;
+ double d1;
+
+ while (iterator.hasNext()) {
+ StructureStart structurestart = (StructureStart) iterator.next();
+
2016-02-29 22:33:06 +01:00
+ if (structurestart.a()) {
+ StructurePiece structurepiece = (StructurePiece) structurestart.c().get(0);
+
2014-11-28 02:17:45 +01:00
+ blockposition2 = structurepiece.a();
2016-02-29 22:33:06 +01:00
+ d1 = blockposition2.k(blockposition);
+ if (d1 < d0) {
+ d0 = d1;
2014-11-28 02:17:45 +01:00
+ blockposition1 = blockposition2;
+ }
+ }
+ }
+
2014-11-28 02:17:45 +01:00
+ if (blockposition1 != null) {
+ return blockposition1;
+ } else {
2016-02-29 22:33:06 +01:00
+ List list = this.E_();
+
+ if (list != null) {
2014-11-28 02:17:45 +01:00
+ BlockPosition blockposition3 = null;
+ Iterator iterator1 = list.iterator();
+
+ while (iterator1.hasNext()) {
2014-11-28 02:17:45 +01:00
+ blockposition2 = (BlockPosition) iterator1.next();
2016-02-29 22:33:06 +01:00
+ d1 = blockposition2.k(blockposition);
+ if (d1 < d0) {
+ d0 = d1;
2014-11-28 02:17:45 +01:00
+ blockposition3 = blockposition2;
+ }
+ }
+
2014-11-28 02:17:45 +01:00
+ return blockposition3;
+ } else {
+ return null;
+ }
+ }
+ }
+
2016-02-29 22:33:06 +01:00
+ protected List<BlockPosition> E_() {
+ return null;
+ }
+
2016-02-29 22:33:06 +01:00
+ 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 {
2016-02-29 22:33:06 +01:00
+ 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) {
2016-02-29 22:33:06 +01:00
+ this.c.put(Long.valueOf(ChunkCoordIntPair.a(i, j)), structurestart);
+ }
+ }
+ }
+ }
+ }
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+
+ private void a(int i, int j, StructureStart structurestart) {
2016-02-29 22:33:06 +01:00
+ 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);
+}
diff --git a/src/main/java/net/minecraft/server/WorldGenForestTree.java b/src/main/java/net/minecraft/server/WorldGenForestTree.java
new file mode 100644
2016-02-29 22:33:06 +01:00
index 0000000..1753f3c
--- /dev/null
+++ b/src/main/java/net/minecraft/server/WorldGenForestTree.java
2015-02-28 12:36:22 +01:00
@@ -0,0 +1,178 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+public class WorldGenForestTree extends WorldGenTreeAbstract {
+
2015-02-28 12:36:22 +01:00
+ private static final IBlockData a = Blocks.LOG2.getBlockData().set(BlockLog2.VARIANT, BlockWood.EnumLogVariant.DARK_OAK);
+ private static final IBlockData b = Blocks.LEAVES2.getBlockData().set(BlockLeaves2.VARIANT, BlockWood.EnumLogVariant.DARK_OAK).set(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
+
+ public WorldGenForestTree(boolean flag) {
+ super(flag);
+ }
+
2014-11-28 02:17:45 +01:00
+ public boolean generate(World world, Random random, BlockPosition blockposition) {
+ int i = random.nextInt(3) + random.nextInt(2) + 6;
2015-02-28 12:36:22 +01:00
+ int j = blockposition.getX();
+ int k = blockposition.getY();
+ int l = blockposition.getZ();
+
2015-02-28 12:36:22 +01:00
+ if (k >= 1 && k + i + 1 < 256) {
+ BlockPosition blockposition1 = blockposition.down();
+ Block block = world.getType(blockposition1).getBlock();
+
2015-02-28 12:36:22 +01:00
+ if (block != Blocks.GRASS && block != Blocks.DIRT) {
+ return false;
+ } else if (!this.a(world, blockposition, i)) {
+ return false;
+ } else {
2015-02-28 12:36:22 +01:00
+ this.a(world, blockposition1);
+ this.a(world, blockposition1.east());
+ this.a(world, blockposition1.south());
+ this.a(world, blockposition1.south().east());
+ EnumDirection enumdirection = EnumDirection.EnumDirectionLimit.HORIZONTAL.a(random);
+ int i1 = i - random.nextInt(4);
+ int j1 = 2 - random.nextInt(3);
+ int k1 = j;
+ int l1 = l;
+ int i2 = k + i - 1;
+
+ int j2;
+ int k2;
+
+ for (j2 = 0; j2 < i; ++j2) {
+ if (j2 >= i1 && j1 > 0) {
+ k1 += enumdirection.getAdjacentX();
+ l1 += enumdirection.getAdjacentZ();
+ --j1;
+ }
+
2015-02-28 12:36:22 +01:00
+ k2 = k + j2;
+ BlockPosition blockposition2 = new BlockPosition(k1, k2, l1);
2016-02-29 22:33:06 +01:00
+ Material material = world.getType(blockposition2).getMaterial();
+
2015-02-28 12:36:22 +01:00
+ if (material == Material.AIR || material == Material.LEAVES) {
+ this.b(world, blockposition2);
+ this.b(world, blockposition2.east());
+ this.b(world, blockposition2.south());
+ this.b(world, blockposition2.east().south());
+ }
2015-02-28 12:36:22 +01:00
+ }
+
2015-02-28 12:36:22 +01:00
+ for (j2 = -2; j2 <= 0; ++j2) {
+ for (k2 = -2; k2 <= 0; ++k2) {
+ byte b0 = -1;
+
+ this.a(world, k1 + j2, i2 + b0, l1 + k2);
+ this.a(world, 1 + k1 - j2, i2 + b0, l1 + k2);
+ this.a(world, k1 + j2, i2 + b0, 1 + l1 - k2);
+ this.a(world, 1 + k1 - j2, i2 + b0, 1 + l1 - k2);
+ if ((j2 > -2 || k2 > -1) && (j2 != -1 || k2 != -2)) {
+ byte b1 = 1;
+
+ this.a(world, k1 + j2, i2 + b1, l1 + k2);
+ this.a(world, 1 + k1 - j2, i2 + b1, l1 + k2);
+ this.a(world, k1 + j2, i2 + b1, 1 + l1 - k2);
+ this.a(world, 1 + k1 - j2, i2 + b1, 1 + l1 - k2);
+ }
+ }
2015-02-28 12:36:22 +01:00
+ }
+
2015-02-28 12:36:22 +01:00
+ if (random.nextBoolean()) {
+ this.a(world, k1, i2 + 2, l1);
+ this.a(world, k1 + 1, i2 + 2, l1);
+ this.a(world, k1 + 1, i2 + 2, l1 + 1);
+ this.a(world, k1, i2 + 2, l1 + 1);
+ }
+
2015-02-28 12:36:22 +01:00
+ for (j2 = -3; j2 <= 4; ++j2) {
+ for (k2 = -3; k2 <= 4; ++k2) {
+ if ((j2 != -3 || k2 != -3) && (j2 != -3 || k2 != 4) && (j2 != 4 || k2 != -3) && (j2 != 4 || k2 != 4) && (Math.abs(j2) < 3 || Math.abs(k2) < 3)) {
+ this.a(world, k1 + j2, i2, l1 + k2);
+ }
+ }
2015-02-28 12:36:22 +01:00
+ }
+
2015-02-28 12:36:22 +01:00
+ for (j2 = -1; j2 <= 2; ++j2) {
+ for (k2 = -1; k2 <= 2; ++k2) {
+ if ((j2 < 0 || j2 > 1 || k2 < 0 || k2 > 1) && random.nextInt(3) <= 0) {
+ int l2 = random.nextInt(3) + 2;
+
2015-02-28 12:36:22 +01:00
+ int i3;
+
2015-02-28 12:36:22 +01:00
+ for (i3 = 0; i3 < l2; ++i3) {
+ this.b(world, new BlockPosition(j + j2, i2 - i3 - 1, l + k2));
+ }
+
2015-02-28 12:36:22 +01:00
+ int j3;
+
2015-02-28 12:36:22 +01:00
+ for (i3 = -1; i3 <= 1; ++i3) {
+ for (j3 = -1; j3 <= 1; ++j3) {
+ this.a(world, k1 + j2 + i3, i2, l1 + k2 + j3);
+ }
2015-02-28 12:36:22 +01:00
+ }
+
2015-02-28 12:36:22 +01:00
+ for (i3 = -2; i3 <= 2; ++i3) {
+ for (j3 = -2; j3 <= 2; ++j3) {
+ if (Math.abs(i3) != 2 || Math.abs(j3) != 2) {
+ this.a(world, k1 + j2 + i3, i2 - 1, l1 + k2 + j3);
+ }
+ }
+ }
+ }
+ }
+ }
2015-02-28 12:36:22 +01:00
+
+ return true;
+ }
+ } else {
+ return false;
+ }
+ }
+
2015-02-28 12:36:22 +01:00
+ private boolean a(World world, BlockPosition blockposition, int i) {
+ int j = blockposition.getX();
+ int k = blockposition.getY();
+ int l = blockposition.getZ();
+ BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
+
+ for (int i1 = 0; i1 <= i + 1; ++i1) {
+ byte b0 = 1;
+
+ if (i1 == 0) {
+ b0 = 0;
+ }
+
+ if (i1 >= i - 1) {
+ b0 = 2;
+ }
+
+ for (int j1 = -b0; j1 <= b0; ++j1) {
+ for (int k1 = -b0; k1 <= b0; ++k1) {
+ if (!this.a(world.getType(blockposition_mutableblockposition.c(j + j1, k + i1, l + k1)).getBlock())) {
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private void b(World world, BlockPosition blockposition) {
+ if (this.a(world.getType(blockposition).getBlock())) {
+ this.a(world, blockposition, WorldGenForestTree.a);
+ }
+
+ }
+
+ private void a(World world, int i, int j, int k) {
2015-02-28 12:36:22 +01:00
+ BlockPosition blockposition = new BlockPosition(i, j, k);
2016-02-29 22:33:06 +01:00
+ Material material = world.getType(blockposition).getMaterial();
+
2016-02-29 22:33:06 +01:00
+ if (material == Material.AIR) {
2015-02-28 12:36:22 +01:00
+ this.a(world, blockposition, WorldGenForestTree.b);
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+}
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-02-29 22:33:06 +01:00
index 0000000..462dc76
--- /dev/null
+++ b/src/main/java/net/minecraft/server/WorldGenLargeFeature.java
2016-02-29 22:33:06 +01:00
@@ -0,0 +1,139 @@
+package net.minecraft.server;
+
2014-11-28 02:17:45 +01:00
+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-02-29 22:33:06 +01: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});
+ private List<BiomeBase.BiomeMeta> b;
+ private int d;
+ private int h;
+
+ public WorldGenLargeFeature() {
2016-02-29 22:33:06 +01:00
+ this.b = Lists.newArrayList();
+ this.d = 32;
+ this.h = 8;
2016-02-29 22:33:06 +01:00
+ this.b.add(new BiomeBase.BiomeMeta(EntityWitch.class, 1, 1, 1));
+ }
+
2015-02-28 12:36:22 +01: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-02-29 22:33:06 +01:00
+ this.d = MathHelper.a((String) entry.getValue(), this.d, this.h + 1);
+ }
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+
+ public String a() {
+ return "Temple";
+ }
+
+ protected boolean a(int i, int j) {
+ int k = i;
+ int l = j;
+
+ if (i < 0) {
2016-02-29 22:33:06 +01:00
+ i -= this.d - 1;
+ }
+
+ if (j < 0) {
2016-02-29 22:33:06 +01:00
+ j -= this.d - 1;
+ }
+
2016-02-29 22:33:06 +01:00
+ int i1 = i / this.d;
+ int j1 = j / this.d;
+ Random random = this.g.a(i1, j1, 14357617);
+
2016-02-29 22:33:06 +01:00
+ i1 *= this.d;
+ j1 *= this.d;
+ i1 += random.nextInt(this.d - this.h);
+ j1 += random.nextInt(this.d - this.h);
+ if (k == i1 && l == j1) {
2016-02-29 22:33:06 +01:00
+ BiomeBase biomebase = this.g.getWorldChunkManager().getBiome(new BlockPosition(k * 16 + 8, 0, l * 16 + 8));
2014-11-28 02:17:45 +01:00
+
+ if (biomebase == null) {
+ return false;
+ }
+
2016-02-29 22:33:06 +01:00
+ Iterator iterator = WorldGenLargeFeature.a.iterator();
+
+ while (iterator.hasNext()) {
+ BiomeBase biomebase1 = (BiomeBase) iterator.next();
+
+ if (biomebase == biomebase1) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ protected StructureStart b(int i, int j) {
2016-02-29 22:33:06 +01:00
+ return new WorldGenLargeFeature.WorldGenLargeFeatureStart(this.g, this.f, i, j);
+ }
+
2014-11-28 02:17:45 +01:00
+ public boolean a(BlockPosition blockposition) {
+ StructureStart structurestart = this.c(blockposition);
+
2015-02-28 12:36:22 +01:00
+ if (structurestart != null && structurestart instanceof WorldGenLargeFeature.WorldGenLargeFeatureStart && !structurestart.a.isEmpty()) {
2016-02-29 22:33:06 +01:00
+ StructurePiece structurepiece = (StructurePiece) structurestart.a.get(0);
+
2015-02-28 12:36:22 +01:00
+ return structurepiece instanceof WorldGenRegistration.WorldGenWitchHut;
+ } else {
+ return false;
+ }
+ }
+
2015-02-28 12:36:22 +01:00
+ public List<BiomeBase.BiomeMeta> b() {
2016-02-29 22:33:06 +01:00
+ return this.b;
+ }
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01:00
+ public static class WorldGenLargeFeatureStart extends StructureStart {
+
+ public WorldGenLargeFeatureStart() {}
+
+ public WorldGenLargeFeatureStart(World world, Random random, int i, int j) {
2016-02-29 22:33:06 +01:00
+ this(world, random, i, j, world.getBiome(new BlockPosition(i * 16 + 8, 0, j * 16 + 8)));
+ }
2015-02-28 12:36:22 +01:00
+
2016-02-29 22:33:06 +01: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 12:36:22 +01:00
+ WorldGenRegistration.WorldGenWitchHut worldgenregistration_worldgenwitchhut = new WorldGenRegistration.WorldGenWitchHut(random, i * 16, j * 16);
+
+ this.a.add(worldgenregistration_worldgenwitchhut);
2016-02-29 22:33:06 +01: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 12:36:22 +01: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-02-29 22:33:06 +01:00
+ this.d();
2015-02-28 12:36:22 +01:00
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/WorldGenPackedIce2.java b/src/main/java/net/minecraft/server/WorldGenPackedIce2.java
new file mode 100644
2016-02-29 22:33:06 +01:00
index 0000000..1364bbc
--- /dev/null
+++ b/src/main/java/net/minecraft/server/WorldGenPackedIce2.java
2016-02-29 22:33:06 +01:00
@@ -0,0 +1,103 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+public class WorldGenPackedIce2 extends WorldGenerator {
+
+ public WorldGenPackedIce2() {}
+
2014-11-28 02:17:45 +01:00
+ public boolean generate(World world, Random random, BlockPosition blockposition) {
+ while (world.isEmpty(blockposition) && blockposition.getY() > 2) {
+ blockposition = blockposition.down();
+ }
+
2014-11-28 02:17:45 +01:00
+ if (world.getType(blockposition).getBlock() != Blocks.SNOW) {
+ return false;
+ } else {
2014-11-28 02:17:45 +01:00
+ blockposition = blockposition.up(random.nextInt(4));
+ int i = random.nextInt(4) + 7;
+ int j = i / 4 + random.nextInt(2);
+
2014-11-28 02:17:45 +01:00
+ if (j > 1 && random.nextInt(60) == 0) {
+ blockposition = blockposition.up(10 + random.nextInt(30));
+ }
+
2014-11-28 02:17:45 +01:00
+ int k;
+ int l;
+
2014-11-28 02:17:45 +01:00
+ for (k = 0; k < i; ++k) {
+ float f = (1.0F - (float) k / (float) i) * (float) j;
+
2014-11-28 02:17:45 +01:00
+ l = MathHelper.f(f);
+
2014-11-28 02:17:45 +01:00
+ for (int i1 = -l; i1 <= l; ++i1) {
+ float f1 = (float) MathHelper.a(i1) - 0.25F;
+
2014-11-28 02:17:45 +01:00
+ for (int j1 = -l; j1 <= l; ++j1) {
+ float f2 = (float) MathHelper.a(j1) - 0.25F;
+
2014-11-28 02:17:45 +01:00
+ if ((i1 == 0 && j1 == 0 || f1 * f1 + f2 * f2 <= f * f) && (i1 != -l && i1 != l && j1 != -l && j1 != l || random.nextFloat() <= 0.75F)) {
2016-02-29 22:33:06 +01:00
+ IBlockData iblockdata = world.getType(blockposition.a(i1, k, j1));
+ Block block = iblockdata.getBlock();
+
2016-02-29 22:33:06 +01:00
+ if (iblockdata.getMaterial() == Material.AIR || block == Blocks.DIRT || block == Blocks.SNOW || block == Blocks.ICE) {
2015-02-28 12:36:22 +01:00
+ this.a(world, blockposition.a(i1, k, j1), Blocks.PACKED_ICE.getBlockData());
+ }
+
2014-11-28 02:17:45 +01:00
+ if (k != 0 && l > 1) {
2016-02-29 22:33:06 +01:00
+ iblockdata = world.getType(blockposition.a(i1, -k, j1));
+ block = iblockdata.getBlock();
+ if (iblockdata.getMaterial() == Material.AIR || block == Blocks.DIRT || block == Blocks.SNOW || block == Blocks.ICE) {
2015-02-28 12:36:22 +01:00
+ this.a(world, blockposition.a(i1, -k, j1), Blocks.PACKED_ICE.getBlockData());
+ }
+ }
+ }
+ }
+ }
+ }
+
2014-11-28 02:17:45 +01:00
+ k = j - 1;
+ if (k < 0) {
+ k = 0;
+ } else if (k > 1) {
+ k = 1;
+ }
+
2014-11-28 02:17:45 +01:00
+ for (int k1 = -k; k1 <= k; ++k1) {
+ l = -k;
+
2014-11-28 02:17:45 +01:00
+ while (l <= k) {
+ BlockPosition blockposition1 = blockposition.a(k1, -1, l);
+ int l1 = 50;
+
2014-11-28 02:17:45 +01:00
+ if (Math.abs(k1) == 1 && Math.abs(l) == 1) {
+ l1 = random.nextInt(5);
+ }
+
+ while (true) {
2014-11-28 02:17:45 +01:00
+ if (blockposition1.getY() > 50) {
2016-02-29 22:33:06 +01:00
+ IBlockData iblockdata1 = world.getType(blockposition1);
+ Block block1 = iblockdata1.getBlock();
+
2016-02-29 22:33:06 +01:00
+ if (iblockdata1.getMaterial() == Material.AIR || block1 == Blocks.DIRT || block1 == Blocks.SNOW || block1 == Blocks.ICE || block1 == Blocks.PACKED_ICE) {
2015-02-28 12:36:22 +01:00
+ this.a(world, blockposition1, Blocks.PACKED_ICE.getBlockData());
2014-11-28 02:17:45 +01:00
+ blockposition1 = blockposition1.down();
+ --l1;
2014-11-28 02:17:45 +01:00
+ if (l1 <= 0) {
+ blockposition1 = blockposition1.down(random.nextInt(5) + 1);
+ l1 = random.nextInt(5);
+ }
+ continue;
+ }
+ }
+
2014-11-28 02:17:45 +01:00
+ ++l;
+ break;
+ }
+ }
+ }
+
+ return true;
+ }
+ }
+}
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-02-29 22:33:06 +01:00
index 0000000..2f43742
--- /dev/null
+++ b/src/main/java/net/minecraft/server/WorldGenVillage.java
2015-02-28 12:36:22 +01:00
@@ -0,0 +1,138 @@
+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-02-29 22:33:06 +01:00
+ public static final List<BiomeBase> a = Arrays.asList(new BiomeBase[] { Biomes.c, Biomes.d, Biomes.K});
+ private int b;
+ private int d;
+ private int h;
+
+ public WorldGenVillage() {
2016-02-29 22:33:06 +01:00
+ this.d = 32;
+ this.h = 8;
+ }
+
2015-02-28 12:36:22 +01: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-02-29 22:33:06 +01:00
+ this.b = MathHelper.a((String) entry.getValue(), this.b, 0);
+ } else if (((String) entry.getKey()).equals("distance")) {
2016-02-29 22:33:06 +01:00
+ this.d = MathHelper.a((String) entry.getValue(), this.d, this.h + 1);
+ }
+ }
2014-11-28 02:17:45 +01:00
+
+ }
+
+ public String a() {
+ return "Village";
+ }
+
+ protected boolean a(int i, int j) {
+ int k = i;
+ int l = j;
+
+ if (i < 0) {
2016-02-29 22:33:06 +01:00
+ i -= this.d - 1;
+ }
+
+ if (j < 0) {
2016-02-29 22:33:06 +01:00
+ j -= this.d - 1;
+ }
+
2016-02-29 22:33:06 +01:00
+ int i1 = i / this.d;
+ int j1 = j / this.d;
+ Random random = this.g.a(i1, j1, 10387312);
+
2016-02-29 22:33:06 +01:00
+ i1 *= this.d;
+ j1 *= this.d;
+ i1 += random.nextInt(this.d - this.h);
+ j1 += random.nextInt(this.d - this.h);
+ if (k == i1 && l == j1) {
2016-02-29 22:33:06 +01:00
+ boolean flag = this.g.getWorldChunkManager().a(k * 16 + 8, l * 16 + 8, 0, WorldGenVillage.a);
+
+ if (flag) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ protected StructureStart b(int i, int j) {
2016-02-29 22:33:06 +01:00
+ return new WorldGenVillage.WorldGenVillageStart(this.g, this.f, i, j, this.b);
+ }
2014-11-28 02:17:45 +01:00
+
2015-02-28 12:36:22 +01: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-02-29 22:33:06 +01:00
+ worldgenvillagepieces_worldgenvillagestartpiece.a((StructurePiece) worldgenvillagepieces_worldgenvillagestartpiece, this.a, random);
2015-02-28 12:36:22 +01:00
+ List list1 = worldgenvillagepieces_worldgenvillagestartpiece.g;
+ List list2 = worldgenvillagepieces_worldgenvillagestartpiece.f;
+
+ int l;
+
+ while (!list1.isEmpty() || !list2.isEmpty()) {
+ StructurePiece structurepiece;
+
+ if (list1.isEmpty()) {
+ l = random.nextInt(list2.size());
+ structurepiece = (StructurePiece) list2.remove(l);
2016-02-29 22:33:06 +01:00
+ structurepiece.a((StructurePiece) worldgenvillagepieces_worldgenvillagestartpiece, this.a, random);
2015-02-28 12:36:22 +01:00
+ } else {
+ l = random.nextInt(list1.size());
+ structurepiece = (StructurePiece) list1.remove(l);
2016-02-29 22:33:06 +01:00
+ structurepiece.a((StructurePiece) worldgenvillagepieces_worldgenvillagestartpiece, this.a, random);
2015-02-28 12:36:22 +01:00
+ }
+ }
+
2016-02-29 22:33:06 +01:00
+ this.d();
2015-02-28 12:36:22 +01: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-02-29 22:33:06 +01:00
+ public boolean a() {
2015-02-28 12:36:22 +01: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");
+ }
+ }
+}
2016-02-29 22:33:06 +01:00
diff --git a/src/main/java/net/minecraft/server/WorldGenVillagePieces.java b/src/main/java/net/minecraft/server/WorldGenVillagePieces.java
index 35d3ed1..dfd1474 100644
--- a/src/main/java/net/minecraft/server/WorldGenVillagePieces.java
+++ b/src/main/java/net/minecraft/server/WorldGenVillagePieces.java
@@ -282,10 +282,10 @@ public class WorldGenVillagePieces {
protected void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
- nbttagcompound.setInt("CA", Block.REGISTRY.a(this.a));
- nbttagcompound.setInt("CB", Block.REGISTRY.a(this.b));
- nbttagcompound.setInt("CC", Block.REGISTRY.a(this.c));
- nbttagcompound.setInt("CD", Block.REGISTRY.a(this.d));
+ nbttagcompound.setInt("CA", Block.REGISTRY.a(this.a)); // Spigot - decompile error
+ nbttagcompound.setInt("CB", Block.REGISTRY.a(this.b)); // Spigot - decompile error
+ nbttagcompound.setInt("CC", Block.REGISTRY.a(this.c)); // Spigot - decompile error
+ nbttagcompound.setInt("CD", Block.REGISTRY.a(this.d)); // Spigot - decompile error
}
protected void b(NBTTagCompound nbttagcompound) {
@@ -413,8 +413,8 @@ public class WorldGenVillagePieces {
protected void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
- nbttagcompound.setInt("CA", Block.REGISTRY.a(this.a));
- nbttagcompound.setInt("CB", Block.REGISTRY.a(this.b));
+ nbttagcompound.setInt("CA", Block.REGISTRY.a(this.a)); // Spigot - decompile error
+ nbttagcompound.setInt("CB", Block.REGISTRY.a(this.b)); // Spigot - decompile error
}
protected void b(NBTTagCompound nbttagcompound) {
@@ -1602,7 +1602,7 @@ public class WorldGenVillagePieces {
entityvillager.setPositionRotation((double) j1 + 0.5D, (double) k1, (double) l1 + 0.5D, 0.0F, 0.0F);
entityvillager.prepare(world.D(new BlockPosition(entityvillager)), (GroupDataEntity) null);
entityvillager.setProfession(this.c(i1, entityvillager.getProfession()));
- world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason
+ world.addEntity(entityvillager);
}
}
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-02-29 22:33:06 +01:00
2.5.0