From ffe49c3d17d1d1fb36e483d72f25c20684bd25a9 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Sun, 7 Sep 2014 15:45:58 -0500 Subject: [PATCH] Implement a few 1.8 features Blocks, items, few odds and ends diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java index 24e84d6..8c50956 100644 --- a/src/main/java/net/minecraft/server/Block.java +++ b/src/main/java/net/minecraft/server/Block.java @@ -21,6 +21,7 @@ public class Block { public static final StepSound n = new StepSound("snow", 1.0F, 1.0F); public static final StepSound o = new StepSoundLadder("ladder", 1.0F, 1.0F); public static final StepSound p = new StepSoundAnvil("anvil", 0.3F, 1.0F); + public static final StepSound qS = new StepSound("slime", 1.0F, 1.0F); // Slime step sound protected boolean q; protected int r; protected boolean s; @@ -262,7 +263,7 @@ public class Block { REGISTRY.a(148, "heavy_weighted_pressure_plate", (new BlockPressurePlateWeighted("iron_block", Material.ORE, 150)).c(0.5F).a(f).c("weightedPlate_heavy")); REGISTRY.a(149, "unpowered_comparator", (new BlockRedstoneComparator(false)).c(0.0F).a(f).c("comparator").H().d("comparator_off")); REGISTRY.a(150, "powered_comparator", (new BlockRedstoneComparator(true)).c(0.0F).a(0.625F).a(f).c("comparator").H().d("comparator_on")); - REGISTRY.a(151, "daylight_detector", (new BlockDaylightDetector()).c(0.2F).a(f).c("daylightDetector").d("daylight_detector")); + REGISTRY.a(151, "daylight_detector", (new BlockDaylightDetector(false)).c(0.2F).a(f).c("daylightDetector").d("daylight_detector")); // PaperSpigot add false for day/night sensor REGISTRY.a(152, "redstone_block", (new BlockRedstone(MaterialMapColor.f)).c(5.0F).b(10.0F).a(j).c("blockRedstone").d("redstone_block")); REGISTRY.a(153, "quartz_ore", (new BlockOre()).c(3.0F).b(5.0F).a(i).c("netherquartz").d("quartz_ore")); REGISTRY.a(154, "hopper", (new BlockHopper()).c(3.0F).b(8.0F).a(f).c("hopper").d("hopper")); @@ -278,12 +279,44 @@ public class Block { REGISTRY.a(162, "log2", (new BlockLog2()).c("log").d("log")); REGISTRY.a(163, "acacia_stairs", (new BlockStairs(block1, 4)).c("stairsWoodAcacia")); REGISTRY.a(164, "dark_oak_stairs", (new BlockStairs(block1, 5)).c("stairsWoodDarkOak")); + // PaperSpigot start - Add new 1.8 blocks + REGISTRY.a(165, "slime", (new BlockSlime(true)).a(qS)); + REGISTRY.a(166, "barrier", (new Block(Material.STONE)).s().b(6000000.0F).a(i).c("barrier").H().d("barrier")); + REGISTRY.a(167, "iron_trapdoor", (new BlockTrapdoor(Material.ORE).c(5.0F).a(f).c("ironTrapdoor").H().d("ironTrapdoor"))); + REGISTRY.a(168, "prismarine" , (new BlockPrismarine().c(1.5F).b(10.0F).a(i).c("prismarine"))); + REGISTRY.a(169, "sea_lantern", (new BlockLightStone(Material.SHATTERABLE).c(0.3F).a(k).a(1.0F).c("sea_lantern"))); + // PaperSpigot end REGISTRY.a(170, "hay_block", (new BlockHay()).c(0.5F).a(h).c("hayBlock").a(CreativeModeTab.b).d("hay_block")); REGISTRY.a(171, "carpet", (new BlockCarpet()).c(0.1F).a(l).c("woolCarpet").g(0)); REGISTRY.a(172, "hardened_clay", (new BlockHardenedClay()).c(1.25F).b(7.0F).a(i).c("clayHardened").d("hardened_clay")); REGISTRY.a(173, "coal_block", (new Block(Material.STONE)).c(5.0F).b(10.0F).a(i).c("blockCoal").a(CreativeModeTab.b).d("coal_block")); REGISTRY.a(174, "packed_ice", (new BlockPackedIce()).c(0.5F).a(k).c("icePacked").d("ice_packed")); REGISTRY.a(175, "double_plant", new BlockTallPlant()); + // PaperSpigot start - More new 1.8 blocks + REGISTRY.a(176, "standing_banner", (new BlockStationary(Material.WOOL)).c(1.0F).a(f).c("banner")); + REGISTRY.a(177, "wall_banner", (new BlockStationary(Material.WOOL)).c(1.0F).a(f).c("banner")); + REGISTRY.a(178, "daylight_detector_inverted", new BlockDaylightDetector(true)); + Block block12 = (new BlockSandStone()).a(i).c(0.8F).c("redSandStone"); + REGISTRY.a(179, "red_sandstone", block12); + REGISTRY.a(180, "red_sandstone_stairs", (new BlockStairs(block12, 0).c("stairsRedSandStone"))); + REGISTRY.a(181, "double_stone_slab2", (new BlockStep(true)).c(2.0F).b(10.0F).a(i).c("stoneSlab2")); + REGISTRY.a(182, "stone_slab2", (new BlockStep(false)).c(2.0F).b(10.0F).a(i).c("stoneSlab2")); + REGISTRY.a(183, "spruce_fence_gate", new BlockFenceGate().c(2.0F).b(5.0F).a(f).c("spruceFenceGate")); + REGISTRY.a(184, "birch_fence_gate", new BlockFenceGate().c(2.0F).b(5.0F).a(f).c("birchFenceGate")); + REGISTRY.a(185, "jungle_fence_gate", new BlockFenceGate().c(2.0F).b(5.0F).a(f).c("jungleFenceGate")); + REGISTRY.a(186, "dark_oak_fence_gate", new BlockFenceGate().c(2.0F).b(5.0F).a(f).c("darkOakFenceGate")); + REGISTRY.a(187, "acacia_fence_gate", new BlockFenceGate().c(2.0F).b(5.0F).a(f).c("acaciaFenceGate")); + REGISTRY.a(188, "spruce_fence", (new BlockFence("planks_spruce", Material.WOOD)).c(2.0F).b(5.0F).a(f).c("spruceFence")); + REGISTRY.a(189, "birch_fence", (new BlockFence("planks_birch", Material.WOOD)).c(2.0F).b(5.0F).a(f).c("birchFence")); + REGISTRY.a(190, "jungle_fence", (new BlockFence("planks_jungle", Material.WOOD)).c(2.0F).b(5.0F).a(f).c("jungleFence")); + REGISTRY.a(191, "dark_oak_fence", (new BlockFence("planks_dark_oak", Material.WOOD)).c(2.0F).b(5.0F).a(5).c("darkOakFence")); + REGISTRY.a(192, "acacia_fence", (new BlockFence("planks_acacia", Material.WOOD)).c(2.0F).b(5.0F).a(5).c("acaciaFence")); + REGISTRY.a(193, "spruce_door", (new BlockDoor(Material.WOOD)).c(3.0F).a(f).c("doorSpruce")); + REGISTRY.a(194, "birch_door", (new BlockDoor(Material.WOOD)).c(3.0F).a(f).c("doorBirch")); + REGISTRY.a(195, "jungle_door", (new BlockDoor(Material.WOOD)).c(3.0F).a(f).c("doorJungle")); + REGISTRY.a(196, "acacia_door", (new BlockDoor(Material.WOOD)).c(3.0F).a(f).c("doorAcacia")); + REGISTRY.a(197, "dark_oak_door", (new BlockDoor(Material.WOOD)).c(3.0F).a(f).c("doorDarkOak")); + // PaperSpigot end Iterator iterator = REGISTRY.iterator(); while (iterator.hasNext()) { diff --git a/src/main/java/net/minecraft/server/BlockDaylightDetector.java b/src/main/java/net/minecraft/server/BlockDaylightDetector.java index 1298610..9ec14ef 100644 --- a/src/main/java/net/minecraft/server/BlockDaylightDetector.java +++ b/src/main/java/net/minecraft/server/BlockDaylightDetector.java @@ -5,11 +5,13 @@ import java.util.Random; public class BlockDaylightDetector extends BlockContainer { private IIcon[] a = new IIcon[2]; + private boolean alternate = false; // PaperSpigot - day/night sensor - public BlockDaylightDetector() { + public BlockDaylightDetector(boolean alternate) { // PaperSpigot - day/night sensor super(Material.WOOD); this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.375F, 1.0F); this.a(CreativeModeTab.d); + this.alternate = alternate; // PaperSpigot - day/night sensor } public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { @@ -31,32 +33,13 @@ public class BlockDaylightDetector extends BlockContainer { int l = world.getData(i, j, k); int i1 = world.b(EnumSkyBlock.SKY, i, j, k) - world.j; float f = world.d(1.0F); - - if (f < 3.1415927F) { - f += (0.0F - f) * 0.2F; - } else { - f += (6.2831855F - f) * 0.2F; - } - - // PaperSpigot start - Configurable "inversion" for daylight detectors - if (world.paperSpigotConfig.invertedDaylightDetectors) { - i1 = Math.round((float) i1 * MathHelper.cos(f) * -1 + 15); - if (i1 < 10) { - i1 = 0; - } - - if (i1 > 9) { - i1 = 15; - } - } else { - i1 = Math.round((float) i1 * MathHelper.cos(f)); - if (i1 < 0) { - i1 = 0; - } - - if (i1 > 15) { - i1 = 15; - } + // PaperSpigot backport 1.8 daylight/night detector logic + float f2 = f < 3.1415927F ? 0.0F : 6.2831855F; + f += (f2 - f) * 0.2F; + i1 = Math.round((float) i1 * thing(f)); + i1 = anotherThing(i1, 0, 15); + if (this.alternate || world.paperSpigotConfig.invertedDaylightDetectors) { + i1 = 15 - i1; } // PaperSpigot end @@ -82,4 +65,16 @@ public class BlockDaylightDetector extends BlockContainer { public TileEntity a(World world, int i) { return new TileEntityLightDetector(); } + + // PaperSpigot start - Backport necessary helpers + private static final float[] b = new float[65536]; + + public static float thing(float f) { + return b[(int) (f * 10430.378F + 16384.0F) & '\uffff']; + } + + public static int anotherThing(int var0, int var1, int var2) { + return var0 < var1 ? var1 : (var0 > var2 ? var2 : var0); + } + // PaperSpigot end } diff --git a/src/main/java/net/minecraft/server/BlockDoor.java b/src/main/java/net/minecraft/server/BlockDoor.java index 9c3ae2e..00052a3 100644 --- a/src/main/java/net/minecraft/server/BlockDoor.java +++ b/src/main/java/net/minecraft/server/BlockDoor.java @@ -6,6 +6,9 @@ import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit public class BlockDoor extends Block { + // PaperSpigot start - 1.8 door type compatibility + public static final String[] a = new String[] { }; + protected BlockDoor(Material material) { super(material); float f = 0.5F; @@ -197,7 +200,8 @@ public class BlockDoor extends Block { } public Item getDropType(int i, Random random, int j) { - return (i & 8) != 0 ? null : (this.material == Material.ORE ? Items.IRON_DOOR : Items.WOOD_DOOR); + // PaperSpigot - backport 1.8 door drop handling + return this == Blocks.IRON_DOOR_BLOCK ? Items.IRON_DOOR : (this == Blocks.SPRUCE_DOOR_BLOCK ? Items.SPRUCE_DOOR : (this == Blocks.BIRCH_DOOR_BLOCK ? Items.BIRCH_DOOR : (this == Blocks.JUNGLE_DOOR_BLOCK ? Items.JUNGLE_DOOR : (this == Blocks.ACACIA_DOOR_BLOCK ? Items.ACACIA_DOOR : (this == Blocks.DARK_OAK_DOOR_BLOCK ? Items.DARK_OAK_DOOR : Items.WOOD_DOOR))))); } public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { diff --git a/src/main/java/net/minecraft/server/BlockPrismarine.java b/src/main/java/net/minecraft/server/BlockPrismarine.java new file mode 100644 index 0000000..0a2cd71 --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockPrismarine.java @@ -0,0 +1,17 @@ +package net.minecraft.server; + +public class BlockPrismarine extends Block { + + // Created by PaperSpigot for compatibility reasons, by no means is this necessarily the actual NMS representation + + public static final String[] a = new String[] { "prismarine", "prismarine_bricks", "dark_prismarine"}; + + public BlockPrismarine() { + super(Material.STONE); + this.a(CreativeModeTab.b); + } + + public int getDropData(int i) { + return i; + } +} diff --git a/src/main/java/net/minecraft/server/BlockRedSandStone.java b/src/main/java/net/minecraft/server/BlockRedSandStone.java new file mode 100644 index 0000000..29284ad --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockRedSandStone.java @@ -0,0 +1,17 @@ +package net.minecraft.server; + +public class BlockRedSandStone extends Block { + + // Created by PaperSpigot for compatibility reasons, by no means is this necessarily the actual NMS representation + + public static final String[] a = new String[] { "red_sandstone", "chiseled_red_sandstone", "smooth_red_sandstone"}; + + public BlockRedSandStone() { + super(Material.STONE); + this.a(CreativeModeTab.b); + } + + public int getDropData(int i) { + return i; + } +} diff --git a/src/main/java/net/minecraft/server/BlockSlime.java b/src/main/java/net/minecraft/server/BlockSlime.java new file mode 100644 index 0000000..74cb6e6 --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockSlime.java @@ -0,0 +1,11 @@ +package net.minecraft.server; + +public class BlockSlime extends BlockHalfTransparent { + + // Created by PaperSpigot for compatibility reasons, by no means is this necessarily the actual NMS representation + + public BlockSlime(boolean flag) { + super("slime", Material.SHATTERABLE, flag); + this.a(CreativeModeTab.b); + } +} diff --git a/src/main/java/net/minecraft/server/BlockStone.java b/src/main/java/net/minecraft/server/BlockStone.java index 33be3e3..65d625d 100644 --- a/src/main/java/net/minecraft/server/BlockStone.java +++ b/src/main/java/net/minecraft/server/BlockStone.java @@ -4,11 +4,20 @@ import java.util.Random; public class BlockStone extends Block { + // PaperSpigot - Add 1.8 block variants + public static final String[] a = new String[] { "default", "granite", "polished_granite", "diorite", "polished_diorite", "andesite", "polished_andesite" }; + public BlockStone() { super(Material.STONE); this.a(CreativeModeTab.b); } + // PaperSpigot start - Add 1.8 block variants + public int getDropData(int i) { + return i; + } + // PaperSpigot end + public Item getDropType(int i, Random random, int j) { return Item.getItemOf(Blocks.COBBLESTONE); } diff --git a/src/main/java/net/minecraft/server/Blocks.java b/src/main/java/net/minecraft/server/Blocks.java index c36e7fb..c03745a 100644 --- a/src/main/java/net/minecraft/server/Blocks.java +++ b/src/main/java/net/minecraft/server/Blocks.java @@ -173,5 +173,25 @@ public class Blocks { public static final BlockTallPlant DOUBLE_PLANT = (BlockTallPlant) Block.REGISTRY.get("double_plant"); public static final BlockStainedGlass STAINED_GLASS = (BlockStainedGlass) Block.REGISTRY.get("stained_glass"); public static final BlockStainedGlassPane STAINED_GLASS_PANE = (BlockStainedGlassPane) Block.REGISTRY.get("stained_glass_pane"); + // PaperSpigot start - Add 1.8 blocks + public static final BlockPrismarine PRISMARINE = (BlockPrismarine) Block.REGISTRY.get("prismarine"); + public static final Block RED_SANDSTONE = (Block) Block.REGISTRY.get("red_sandstone"); + public static final Block SPRUCE_DOOR_BLOCK = (Block) Block.REGISTRY.get("spruce_door"); + public static final Block BIRCH_DOOR_BLOCK = (Block) Block.REGISTRY.get("birch_door"); + public static final Block JUNGLE_DOOR_BLOCK = (Block) Block.REGISTRY.get("jungle_door"); + public static final Block ACACIA_DOOR_BLOCK = (Block) Block.REGISTRY.get("acacia_door"); + public static final Block DARK_OAK_DOOR_BLOCK = (Block) Block.REGISTRY.get("dark_oak_door"); + public static final Block SLIME = (Block) Block.REGISTRY.get("slime"); + public static final Block SPRUCE_FENCE = (Block) Block.REGISTRY.get("spruce_fence"); + public static final Block BIRCH_FENCE = (Block) Block.REGISTRY.get("birch_fence"); + public static final Block JUNGLE_FENCE = (Block) Block.REGISTRY.get("jungle_fence"); + public static final Block DARK_OAK_FENCE = (Block) Block.REGISTRY.get("dark_oak_fence"); + public static final Block ACACIA_FENCE = (Block) Block.REGISTRY.get("acacia_fence"); + public static final Block SPRUCE_FENCE_GATE = (Block) Block.REGISTRY.get("spruce_fence_gate"); + public static final Block BIRCH_FENCE_GATE = (Block) Block.REGISTRY.get("birch_fence_gate"); + public static final Block JUNGLE_FENCE_GATE = (Block) Block.REGISTRY.get("jungle_fence_gate"); + public static final Block DARK_OAK_FENCE_GATE = (Block) Block.REGISTRY.get("dark_oak_fence_gate"); + public static final Block ACACIA_FENCE_GATE = (Block) Block.REGISTRY.get("acacia_fence_gate"); + // PaperSpigot end } diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java index e2fbdc4..7b9acf2 100644 --- a/src/main/java/net/minecraft/server/CraftingManager.java +++ b/src/main/java/net/minecraft/server/CraftingManager.java @@ -37,11 +37,11 @@ public class CraftingManager { this.registerShapedRecipe(new ItemStack(Items.PAPER, 3), new Object[] { "###", Character.valueOf('#'), Items.SUGAR_CANE}); this.registerShapelessRecipe(new ItemStack(Items.BOOK, 1), new Object[] { Items.PAPER, Items.PAPER, Items.PAPER, Items.LEATHER}); this.registerShapelessRecipe(new ItemStack(Items.BOOK_AND_QUILL, 1), new Object[] { Items.BOOK, new ItemStack(Items.INK_SACK, 1, 0), Items.FEATHER}); - this.registerShapedRecipe(new ItemStack(Blocks.FENCE, 2), new Object[] { "###", "###", Character.valueOf('#'), Items.STICK}); + this.registerShapedRecipe(new ItemStack(Blocks.FENCE, 3), new Object[] { "#S#", "#S#", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 0), Character.valueOf('S'), Items.STICK }); // PaperSpigot - Use 1.8 recipe this.registerShapedRecipe(new ItemStack(Blocks.COBBLE_WALL, 6, 0), new Object[] { "###", "###", Character.valueOf('#'), Blocks.COBBLESTONE}); this.registerShapedRecipe(new ItemStack(Blocks.COBBLE_WALL, 6, 1), new Object[] { "###", "###", Character.valueOf('#'), Blocks.MOSSY_COBBLESTONE}); this.registerShapedRecipe(new ItemStack(Blocks.NETHER_FENCE, 6), new Object[] { "###", "###", Character.valueOf('#'), Blocks.NETHER_BRICK}); - this.registerShapedRecipe(new ItemStack(Blocks.FENCE_GATE, 1), new Object[] { "#W#", "#W#", Character.valueOf('#'), Items.STICK, Character.valueOf('W'), Blocks.WOOD}); + this.registerShapedRecipe(new ItemStack(Blocks.FENCE_GATE, 1), new Object[] { "#W#", "#W#", Character.valueOf('#'), Items.STICK, Character.valueOf('W'), new ItemStack(Blocks.WOOD, 1, 0)}); // PaperSpigot - Add explicit data value this.registerShapedRecipe(new ItemStack(Blocks.JUKEBOX, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Blocks.WOOD, Character.valueOf('X'), Items.DIAMOND}); this.registerShapedRecipe(new ItemStack(Items.LEASH, 2), new Object[] { "~~ ", "~O ", " ~", Character.valueOf('~'), Items.STRING, Character.valueOf('O'), Items.SLIME_BALL}); this.registerShapedRecipe(new ItemStack(Blocks.NOTE_BLOCK, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Blocks.WOOD, Character.valueOf('X'), Items.REDSTONE}); @@ -55,7 +55,7 @@ public class CraftingManager { this.registerShapedRecipe(new ItemStack(Blocks.WOOL, 1), new Object[] { "##", "##", Character.valueOf('#'), Items.STRING}); this.registerShapedRecipe(new ItemStack(Blocks.TNT, 1), new Object[] { "X#X", "#X#", "X#X", Character.valueOf('X'), Items.SULPHUR, Character.valueOf('#'), Blocks.SAND}); this.registerShapedRecipe(new ItemStack(Blocks.STEP, 6, 3), new Object[] { "###", Character.valueOf('#'), Blocks.COBBLESTONE}); - this.registerShapedRecipe(new ItemStack(Blocks.STEP, 6, 0), new Object[] { "###", Character.valueOf('#'), Blocks.STONE}); + this.registerShapedRecipe(new ItemStack(Blocks.STEP, 6, 0), new Object[] { "###", Character.valueOf('#'), new ItemStack(Blocks.STONE, 1, 0)}); // PaperSpigot - Explicit data value this.registerShapedRecipe(new ItemStack(Blocks.STEP, 6, 1), new Object[] { "###", Character.valueOf('#'), Blocks.SANDSTONE}); this.registerShapedRecipe(new ItemStack(Blocks.STEP, 6, 4), new Object[] { "###", Character.valueOf('#'), Blocks.BRICK}); this.registerShapedRecipe(new ItemStack(Blocks.STEP, 6, 5), new Object[] { "###", Character.valueOf('#'), Blocks.SMOOTH_BRICK}); @@ -68,7 +68,7 @@ public class CraftingManager { this.registerShapedRecipe(new ItemStack(Blocks.WOOD_STEP, 6, 4), new Object[] { "###", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 4)}); this.registerShapedRecipe(new ItemStack(Blocks.WOOD_STEP, 6, 5), new Object[] { "###", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 5)}); this.registerShapedRecipe(new ItemStack(Blocks.LADDER, 3), new Object[] { "# #", "###", "# #", Character.valueOf('#'), Items.STICK}); - this.registerShapedRecipe(new ItemStack(Items.WOOD_DOOR, 1), new Object[] { "##", "##", "##", Character.valueOf('#'), Blocks.WOOD}); + this.registerShapedRecipe(new ItemStack(Items.WOOD_DOOR, 3), new Object[] { "##", "##", "##", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 0) }); // PaperSpigot - Add explicit data value and bump to 3 this.registerShapedRecipe(new ItemStack(Blocks.TRAP_DOOR, 2), new Object[] { "###", "###", Character.valueOf('#'), Blocks.WOOD}); this.registerShapedRecipe(new ItemStack(Items.IRON_DOOR, 1), new Object[] { "##", "##", "##", Character.valueOf('#'), Items.IRON_INGOT}); this.registerShapedRecipe(new ItemStack(Items.SIGN, 3), new Object[] { "###", "###", " X ", Character.valueOf('#'), Blocks.WOOD, Character.valueOf('X'), Items.STICK}); @@ -125,14 +125,14 @@ public class CraftingManager { this.registerShapedRecipe(new ItemStack(Blocks.LEVER, 1), new Object[] { "X", "#", Character.valueOf('#'), Blocks.COBBLESTONE, Character.valueOf('X'), Items.STICK}); this.registerShapedRecipe(new ItemStack(Blocks.TRIPWIRE_SOURCE, 2), new Object[] { "I", "S", "#", Character.valueOf('#'), Blocks.WOOD, Character.valueOf('S'), Items.STICK, Character.valueOf('I'), Items.IRON_INGOT}); this.registerShapedRecipe(new ItemStack(Blocks.REDSTONE_TORCH_ON, 1), new Object[] { "X", "#", Character.valueOf('#'), Items.STICK, Character.valueOf('X'), Items.REDSTONE}); - this.registerShapedRecipe(new ItemStack(Items.DIODE, 1), new Object[] { "#X#", "III", Character.valueOf('#'), Blocks.REDSTONE_TORCH_ON, Character.valueOf('X'), Items.REDSTONE, Character.valueOf('I'), Blocks.STONE}); + this.registerShapedRecipe(new ItemStack(Items.DIODE, 1), new Object[] { "#X#", "III", Character.valueOf('#'), Blocks.REDSTONE_TORCH_ON, Character.valueOf('X'), Items.REDSTONE, Character.valueOf('I'), new ItemStack(Blocks.STONE, 1, 0)}); // PaperSpigot - Explicit data value this.registerShapedRecipe(new ItemStack(Items.REDSTONE_COMPARATOR, 1), new Object[] { " # ", "#X#", "III", Character.valueOf('#'), Blocks.REDSTONE_TORCH_ON, Character.valueOf('X'), Items.QUARTZ, Character.valueOf('I'), Blocks.STONE}); this.registerShapedRecipe(new ItemStack(Items.WATCH, 1), new Object[] { " # ", "#X#", " # ", Character.valueOf('#'), Items.GOLD_INGOT, Character.valueOf('X'), Items.REDSTONE}); this.registerShapedRecipe(new ItemStack(Items.COMPASS, 1), new Object[] { " # ", "#X#", " # ", Character.valueOf('#'), Items.IRON_INGOT, Character.valueOf('X'), Items.REDSTONE}); this.registerShapedRecipe(new ItemStack(Items.MAP_EMPTY, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Items.PAPER, Character.valueOf('X'), Items.COMPASS}); - this.registerShapedRecipe(new ItemStack(Blocks.STONE_BUTTON, 1), new Object[] { "#", Character.valueOf('#'), Blocks.STONE}); + this.registerShapedRecipe(new ItemStack(Blocks.STONE_BUTTON, 1), new Object[] { "#", Character.valueOf('#'), new ItemStack(Blocks.STONE, 1, 0)}); // PaperSpigot - Explicit data value this.registerShapedRecipe(new ItemStack(Blocks.WOOD_BUTTON, 1), new Object[] { "#", Character.valueOf('#'), Blocks.WOOD}); - this.registerShapedRecipe(new ItemStack(Blocks.STONE_PLATE, 1), new Object[] { "##", Character.valueOf('#'), Blocks.STONE}); + this.registerShapedRecipe(new ItemStack(Blocks.STONE_PLATE, 1), new Object[] { "##", Character.valueOf('#'), new ItemStack(Blocks.STONE, 1, 0)}); // PaperSpigot - Explicit data value this.registerShapedRecipe(new ItemStack(Blocks.WOOD_PLATE, 1), new Object[] { "##", Character.valueOf('#'), Blocks.WOOD}); this.registerShapedRecipe(new ItemStack(Blocks.IRON_PLATE, 1), new Object[] { "##", Character.valueOf('#'), Items.IRON_INGOT}); this.registerShapedRecipe(new ItemStack(Blocks.GOLD_PLATE, 1), new Object[] { "##", Character.valueOf('#'), Items.GOLD_INGOT}); @@ -152,6 +152,30 @@ public class CraftingManager { this.registerShapelessRecipe(new ItemStack(Blocks.MOSSY_COBBLESTONE), new Object[] { Blocks.VINE, Blocks.COBBLESTONE}); this.registerShapelessRecipe(new ItemStack(Blocks.SMOOTH_BRICK, 1, 1), new Object[] { Blocks.VINE, Blocks.SMOOTH_BRICK}); this.registerShapelessRecipe(new ItemStack(Blocks.SMOOTH_BRICK, 1, 3), new Object[] { new ItemStack(Blocks.STEP, 1, 5), new ItemStack(Blocks.STEP, 1, 5)}); + // Register 1.8 stone variant recipes + this.registerShapelessRecipe(new ItemStack(Blocks.STONE, 1, 1), new Object[] { new ItemStack(Blocks.STONE, 1, 3), Items.QUARTZ }); // Granite + this.registerShapedRecipe(new ItemStack(Blocks.STONE, 4, 2), new Object[] { "##", "##", Character.valueOf('#'), new ItemStack(Blocks.STONE, 1, 1) }); // Polished Granite + this.registerShapedRecipe(new ItemStack(Blocks.STONE, 2, 3), new Object[] { "CQ", "QC", Character.valueOf('C'), Blocks.COBBLESTONE, Character.valueOf('Q'), Items.QUARTZ }); // Diorite + this.registerShapedRecipe(new ItemStack(Blocks.STONE, 4, 4), new Object[] { "##", "##", Character.valueOf('#'), new ItemStack(Blocks.STONE, 1, 3) }); // Polished Diorite + this.registerShapelessRecipe(new ItemStack(Blocks.STONE, 2, 5), new Object[] { new ItemStack(Blocks.STONE, 1, 3), Blocks.COBBLESTONE }); // Andesite + this.registerShapedRecipe(new ItemStack(Blocks.STONE, 4, 6), new Object[] { "##", "##", Character.valueOf('#'), new ItemStack(Blocks.STONE, 1, 5) }); // Polished Andesite + this.registerShapedRecipe(new ItemStack(Blocks.SLIME), new Object[] { "###", "###", "###", Character.valueOf('#'), Items.SLIME_BALL }); // Slime Ball -> Slime Block + this.registerShapedRecipe(new ItemStack(Items.SLIME_BALL, 9), new Object[] { "#", Character.valueOf('#'), new ItemStack(Blocks.SLIME, 1) }); // Slime Block -> Slime Ball + this.registerShapedRecipe(new ItemStack(Blocks.SPRUCE_FENCE, 3), new Object[] { "#S#", "#S#", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 1), Character.valueOf('S'), Items.STICK }); // Spruce fence + this.registerShapedRecipe(new ItemStack(Blocks.BIRCH_FENCE, 3), new Object[] { "#S#", "#S#", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 2), Character.valueOf('S'), Items.STICK }); // Birch fence + this.registerShapedRecipe(new ItemStack(Blocks.JUNGLE_FENCE, 3), new Object[] { "#S#", "#S#", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 3), Character.valueOf('S'), Items.STICK }); // Jungle fence + this.registerShapedRecipe(new ItemStack(Blocks.ACACIA_FENCE, 3), new Object[] { "#S#", "#S#", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 4), Character.valueOf('S'), Items.STICK }); // Acacia fence + this.registerShapedRecipe(new ItemStack(Blocks.DARK_OAK_FENCE, 3), new Object[] { "#S#", "#S#", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 5), Character.valueOf('S'), Items.STICK }); // Dark Oak fence + this.registerShapedRecipe(new ItemStack(Blocks.SPRUCE_FENCE_GATE, 1), new Object[] { "#W#", "#W#", Character.valueOf('#'), Items.STICK, Character.valueOf('W'), new ItemStack(Blocks.WOOD, 1, 1) }); // Spruce fence gate + this.registerShapedRecipe(new ItemStack(Blocks.BIRCH_FENCE_GATE, 1), new Object[] { "#W#", "#W#", Character.valueOf('#'), Items.STICK, Character.valueOf('W'), new ItemStack(Blocks.WOOD, 1, 2) }); // Birch fence gate + this.registerShapedRecipe(new ItemStack(Blocks.JUNGLE_FENCE_GATE, 1), new Object[] { "#W#", "#W#", Character.valueOf('#'), Items.STICK, Character.valueOf('W'), new ItemStack(Blocks.WOOD, 1, 3) }); // Jungle fence gate + this.registerShapedRecipe(new ItemStack(Blocks.ACACIA_FENCE_GATE, 1), new Object[] { "#W#", "#W#", Character.valueOf('#'), Items.STICK, Character.valueOf('W'), new ItemStack(Blocks.WOOD, 1, 4) }); // Acacia fence gate + this.registerShapedRecipe(new ItemStack(Blocks.DARK_OAK_FENCE_GATE, 1), new Object[] { "#W#", "#W#", Character.valueOf('#'), Items.STICK, Character.valueOf('W'), new ItemStack(Blocks.WOOD, 1, 5) }); // Dark Oak fence gate + this.registerShapedRecipe(new ItemStack(Items.SPRUCE_DOOR, 3), new Object[] { "##", "##", "##", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 1) }); // Spruce door + this.registerShapedRecipe(new ItemStack(Items.BIRCH_DOOR, 3), new Object[] { "##", "##", "##", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 2) }); // Birch door + this.registerShapedRecipe(new ItemStack(Items.JUNGLE_DOOR, 3), new Object[] { "##", "##", "##", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 3) }); // Jungle door + this.registerShapedRecipe(new ItemStack(Items.ACACIA_DOOR, 3), new Object[] { "##", "##", "##", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 4) }); // Acacia door + this.registerShapedRecipe(new ItemStack(Items.DARK_OAK_DOOR, 3), new Object[] { "##", "##", "##", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 5) }); // Dark Oak door // PaperSpigot end // Collections.sort(this.recipes, new RecipeSorter(this)); // CraftBukkit - moved below this.sort(); // CraftBukkit - call new sort method diff --git a/src/main/java/net/minecraft/server/EntitySheep.java b/src/main/java/net/minecraft/server/EntitySheep.java index 381ae78..e72e4e1 100644 --- a/src/main/java/net/minecraft/server/EntitySheep.java +++ b/src/main/java/net/minecraft/server/EntitySheep.java @@ -64,6 +64,18 @@ public class EntitySheep extends EntityAnimal { if (!this.isSheared()) { this.a(new ItemStack(Item.getItemOf(Blocks.WOOL), 1, this.getColor()), 0.0F); } + + // PaperSpigot start - 1.8 mutton drops! + int j = this.random.nextInt(2) + 1 + this.random.nextInt(1 + i); + + for (int k = 0; k < j; ++k) { + if (this.isBurning()) { + this.a(Items.COOKED_MUTTON, 1); + } else { + this.a(Items.MUTTON, 1); + } + } + // PaperSpigot end } protected Item getLoot() { diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java index e0a1708..49568ea 100644 --- a/src/main/java/net/minecraft/server/HandshakeListener.java +++ b/src/main/java/net/minecraft/server/HandshakeListener.java @@ -72,7 +72,13 @@ public class HandshakeListener implements PacketHandshakingInListener { } // CraftBukkit end - if (packethandshakinginsetprotocol.d() > 5 && packethandshakinginsetprotocol.d() != 47) { // Spigot + // PaperSpigot start - DC non-1.8 clients + if (packethandshakinginsetprotocol.d() != 47) { + chatcomponenttext = new ChatComponentText( "You must join using a 1.8 client!" ); + this.b.handle(new PacketLoginOutDisconnect(chatcomponenttext), new GenericFutureListener[0]); + this.b.close(chatcomponenttext); + } else if (packethandshakinginsetprotocol.d() > 5 && packethandshakinginsetprotocol.d() != 47) { // Spigot + // PaperSpigot end chatcomponenttext = new ChatComponentText( org.spigotmc.SpigotConfig.outdatedServerMessage ); // Spigot this.b.handle(new PacketLoginOutDisconnect(chatcomponenttext), new GenericFutureListener[0]); this.b.close(chatcomponenttext); diff --git a/src/main/java/net/minecraft/server/Item.java b/src/main/java/net/minecraft/server/Item.java index 4382f1a..7493e42 100644 --- a/src/main/java/net/minecraft/server/Item.java +++ b/src/main/java/net/minecraft/server/Item.java @@ -200,6 +200,16 @@ public class Item { REGISTRY.a(420, "lead", (new ItemLeash()).c("leash").f("lead")); REGISTRY.a(421, "name_tag", (new ItemNameTag()).c("nameTag").f("name_tag")); REGISTRY.a(422, "command_block_minecart", (new ItemMinecart(6)).c("minecartCommandBlock").f("minecart_command_block").a((CreativeModeTab) null)); + // PaperSpigot start - Add new item types + REGISTRY.a(423, "mutton", (new ItemFood(2, 0.3F, true)).c("muttonRaw")); + REGISTRY.a(424, "cooked_mutton", (new ItemFood(6, 0.8F, true)).c("muttonCooked")); + //REGISTRY.a(425, "banner", (); // TODO: Needs backporting - wait for deobf + REGISTRY.a(427, "spruce_door", (new ItemDoorSpruce(Material.WOOD)).c("doorSpruce").f("spruce_door")); + REGISTRY.a(428, "birch_door", (new ItemDoorBirch(Material.WOOD)).c("doorBirch").f("birch_door")); + REGISTRY.a(429, "jungle_door", (new ItemDoorJungle(Material.WOOD)).c("doorJungle").f("jungle_door")); + REGISTRY.a(430, "acacia_door", (new ItemDoorAcacia(Material.WOOD)).c("doorAcacia").f("acacia_door")); + REGISTRY.a(431, "dark_oak_door", (new ItemDoorDarkOak(Material.WOOD)).c("doorDarkOak").f("dark_oak_door")); + // PaperSpigot end REGISTRY.a(2256, "record_13", (new ItemRecord("13")).c("record").f("record_13")); REGISTRY.a(2257, "record_cat", (new ItemRecord("cat")).c("record").f("record_cat")); REGISTRY.a(2258, "record_blocks", (new ItemRecord("blocks")).c("record").f("record_blocks")); @@ -212,7 +222,8 @@ public class Item { REGISTRY.a(2265, "record_ward", (new ItemRecord("ward")).c("record").f("record_ward")); REGISTRY.a(2266, "record_11", (new ItemRecord("11")).c("record").f("record_11")); REGISTRY.a(2267, "record_wait", (new ItemRecord("wait")).c("record").f("record_wait")); - HashSet hashset = Sets.newHashSet(new Block[] { Blocks.AIR, Blocks.BREWING_STAND, Blocks.BED, Blocks.NETHER_WART, Blocks.CAULDRON, Blocks.FLOWER_POT, Blocks.CROPS, Blocks.SUGAR_CANE_BLOCK, Blocks.CAKE_BLOCK, Blocks.SKULL, Blocks.PISTON_EXTENSION, Blocks.PISTON_MOVING, Blocks.GLOWING_REDSTONE_ORE, Blocks.DIODE_ON, Blocks.PUMPKIN_STEM, Blocks.SIGN_POST, Blocks.REDSTONE_COMPARATOR_ON, Blocks.TRIPWIRE, Blocks.REDSTONE_LAMP_ON, Blocks.MELON_STEM, Blocks.REDSTONE_TORCH_OFF, Blocks.REDSTONE_COMPARATOR_OFF, Blocks.REDSTONE_WIRE, Blocks.WALL_SIGN, Blocks.DIODE_OFF, Blocks.IRON_DOOR_BLOCK, Blocks.WOODEN_DOOR}); + // PaperSpigot - Add new doors + HashSet hashset = Sets.newHashSet(new Block[] { Blocks.AIR, Blocks.BREWING_STAND, Blocks.BED, Blocks.NETHER_WART, Blocks.CAULDRON, Blocks.FLOWER_POT, Blocks.CROPS, Blocks.SUGAR_CANE_BLOCK, Blocks.CAKE_BLOCK, Blocks.SKULL, Blocks.PISTON_EXTENSION, Blocks.PISTON_MOVING, Blocks.GLOWING_REDSTONE_ORE, Blocks.DIODE_ON, Blocks.PUMPKIN_STEM, Blocks.SIGN_POST, Blocks.REDSTONE_COMPARATOR_ON, Blocks.TRIPWIRE, Blocks.REDSTONE_LAMP_ON, Blocks.MELON_STEM, Blocks.REDSTONE_TORCH_OFF, Blocks.REDSTONE_COMPARATOR_OFF, Blocks.REDSTONE_WIRE, Blocks.WALL_SIGN, Blocks.DIODE_OFF, Blocks.IRON_DOOR_BLOCK, Blocks.WOODEN_DOOR, Blocks.SPRUCE_DOOR_BLOCK, Blocks.BIRCH_DOOR_BLOCK, Blocks.ACACIA_DOOR_BLOCK, Blocks.DARK_OAK_DOOR_BLOCK}); Iterator iterator = Block.REGISTRY.keySet().iterator(); while (iterator.hasNext()) { @@ -288,6 +299,13 @@ public class Item { } else if (block == Blocks.MOB_SPAWNER || block == Blocks.BIG_MUSHROOM_1 || block == Blocks.BIG_MUSHROOM_2) { object = new ItemWithAuxData(block, true); // CraftBukkit end + // PaperSpigot start - Stone and Prismarine variants + } else if (block == Blocks.STONE) { + object = (new ItemMultiTexture(Blocks.STONE, Blocks.STONE, BlockStone.a)).b("stone"); + } else if (block == Blocks.PRISMARINE) { + object = (new ItemMultiTexture(Blocks.PRISMARINE, Blocks.PRISMARINE, BlockPrismarine.a)).b("prismarine"); + } else if (block == Blocks.RED_SANDSTONE) { + object = (new ItemMultiTexture(Blocks.RED_SANDSTONE, Blocks.RED_SANDSTONE, BlockRedSandStone.a)).b("red_sandstone"); } else { if (hashset.contains(block)) { continue; diff --git a/src/main/java/net/minecraft/server/ItemDoor.java b/src/main/java/net/minecraft/server/ItemDoor.java index ee8568b..0875b76 100644 --- a/src/main/java/net/minecraft/server/ItemDoor.java +++ b/src/main/java/net/minecraft/server/ItemDoor.java @@ -6,7 +6,7 @@ public class ItemDoor extends Item { public ItemDoor(Material material) { this.a = material; - this.maxStackSize = 1; + this.maxStackSize = 64; // PaperSpigot - Bump to 1.8 max stack size this.a(CreativeModeTab.d); } diff --git a/src/main/java/net/minecraft/server/ItemDoorAcacia.java b/src/main/java/net/minecraft/server/ItemDoorAcacia.java new file mode 100644 index 0000000..b9c7ec8 --- /dev/null +++ b/src/main/java/net/minecraft/server/ItemDoorAcacia.java @@ -0,0 +1,81 @@ +package net.minecraft.server; + +public class ItemDoorAcacia extends Item { + + // PaperSpigot - Added for compatibility reasons + + private Material a; + + public ItemDoorAcacia(Material material) { + this.a = material; + this.maxStackSize = 64; // PaperSpigot - Bump to 1.8 max stack size + this.a(CreativeModeTab.d); + } + + public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + if (l != 1) { + return false; + } else { + ++j; + Block block; + + if (this.a == Material.WOOD) { + block = Blocks.ACACIA_DOOR_BLOCK; + } else { + block = Blocks.IRON_DOOR_BLOCK; + } + + if (entityhuman.a(i, j, k, l, itemstack) && entityhuman.a(i, j + 1, k, l, itemstack)) { + if (!block.canPlace(world, i, j, k)) { + return false; + } else { + int i1 = MathHelper.floor((double) ((entityhuman.yaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3; + + place(world, i, j, k, i1, block); + --itemstack.count; + return true; + } + } else { + return false; + } + } + } + + public static void place(World world, int i, int j, int k, int l, Block block) { + byte b0 = 0; + byte b1 = 0; + + if (l == 0) { + b1 = 1; + } + + if (l == 1) { + b0 = -1; + } + + if (l == 2) { + b1 = -1; + } + + if (l == 3) { + b0 = 1; + } + + int i1 = (world.getType(i - b0, j, k - b1).r() ? 1 : 0) + (world.getType(i - b0, j + 1, k - b1).r() ? 1 : 0); + int j1 = (world.getType(i + b0, j, k + b1).r() ? 1 : 0) + (world.getType(i + b0, j + 1, k + b1).r() ? 1 : 0); + boolean flag = world.getType(i - b0, j, k - b1) == block || world.getType(i - b0, j + 1, k - b1) == block; + boolean flag1 = world.getType(i + b0, j, k + b1) == block || world.getType(i + b0, j + 1, k + b1) == block; + boolean flag2 = false; + + if (flag && !flag1) { + flag2 = true; + } else if (j1 > i1) { + flag2 = true; + } + + world.setTypeAndData(i, j, k, block, l, 2); + world.setTypeAndData(i, j + 1, k, block, 8 | (flag2 ? 1 : 0), 2); + world.applyPhysics(i, j, k, block); + world.applyPhysics(i, j + 1, k, block); + } +} diff --git a/src/main/java/net/minecraft/server/ItemDoorBirch.java b/src/main/java/net/minecraft/server/ItemDoorBirch.java new file mode 100644 index 0000000..69e8590 --- /dev/null +++ b/src/main/java/net/minecraft/server/ItemDoorBirch.java @@ -0,0 +1,81 @@ +package net.minecraft.server; + +public class ItemDoorBirch extends Item { + + // PaperSpigot - Added for compatibility reasons + + private Material a; + + public ItemDoorBirch(Material material) { + this.a = material; + this.maxStackSize = 64; // PaperSpigot - Bump to 1.8 max stack size + this.a(CreativeModeTab.d); + } + + public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + if (l != 1) { + return false; + } else { + ++j; + Block block; + + if (this.a == Material.WOOD) { + block = Blocks.BIRCH_DOOR_BLOCK; + } else { + block = Blocks.IRON_DOOR_BLOCK; + } + + if (entityhuman.a(i, j, k, l, itemstack) && entityhuman.a(i, j + 1, k, l, itemstack)) { + if (!block.canPlace(world, i, j, k)) { + return false; + } else { + int i1 = MathHelper.floor((double) ((entityhuman.yaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3; + + place(world, i, j, k, i1, block); + --itemstack.count; + return true; + } + } else { + return false; + } + } + } + + public static void place(World world, int i, int j, int k, int l, Block block) { + byte b0 = 0; + byte b1 = 0; + + if (l == 0) { + b1 = 1; + } + + if (l == 1) { + b0 = -1; + } + + if (l == 2) { + b1 = -1; + } + + if (l == 3) { + b0 = 1; + } + + int i1 = (world.getType(i - b0, j, k - b1).r() ? 1 : 0) + (world.getType(i - b0, j + 1, k - b1).r() ? 1 : 0); + int j1 = (world.getType(i + b0, j, k + b1).r() ? 1 : 0) + (world.getType(i + b0, j + 1, k + b1).r() ? 1 : 0); + boolean flag = world.getType(i - b0, j, k - b1) == block || world.getType(i - b0, j + 1, k - b1) == block; + boolean flag1 = world.getType(i + b0, j, k + b1) == block || world.getType(i + b0, j + 1, k + b1) == block; + boolean flag2 = false; + + if (flag && !flag1) { + flag2 = true; + } else if (j1 > i1) { + flag2 = true; + } + + world.setTypeAndData(i, j, k, block, l, 2); + world.setTypeAndData(i, j + 1, k, block, 8 | (flag2 ? 1 : 0), 2); + world.applyPhysics(i, j, k, block); + world.applyPhysics(i, j + 1, k, block); + } +} diff --git a/src/main/java/net/minecraft/server/ItemDoorDarkOak.java b/src/main/java/net/minecraft/server/ItemDoorDarkOak.java new file mode 100644 index 0000000..9dfe5a1 --- /dev/null +++ b/src/main/java/net/minecraft/server/ItemDoorDarkOak.java @@ -0,0 +1,81 @@ +package net.minecraft.server; + +public class ItemDoorDarkOak extends Item { + + // PaperSpigot - Added for compatibility reasons + + private Material a; + + public ItemDoorDarkOak(Material material) { + this.a = material; + this.maxStackSize = 64; // PaperSpigot - Bump to 1.8 max stack size + this.a(CreativeModeTab.d); + } + + public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + if (l != 1) { + return false; + } else { + ++j; + Block block; + + if (this.a == Material.WOOD) { + block = Blocks.DARK_OAK_DOOR_BLOCK; + } else { + block = Blocks.IRON_DOOR_BLOCK; + } + + if (entityhuman.a(i, j, k, l, itemstack) && entityhuman.a(i, j + 1, k, l, itemstack)) { + if (!block.canPlace(world, i, j, k)) { + return false; + } else { + int i1 = MathHelper.floor((double) ((entityhuman.yaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3; + + place(world, i, j, k, i1, block); + --itemstack.count; + return true; + } + } else { + return false; + } + } + } + + public static void place(World world, int i, int j, int k, int l, Block block) { + byte b0 = 0; + byte b1 = 0; + + if (l == 0) { + b1 = 1; + } + + if (l == 1) { + b0 = -1; + } + + if (l == 2) { + b1 = -1; + } + + if (l == 3) { + b0 = 1; + } + + int i1 = (world.getType(i - b0, j, k - b1).r() ? 1 : 0) + (world.getType(i - b0, j + 1, k - b1).r() ? 1 : 0); + int j1 = (world.getType(i + b0, j, k + b1).r() ? 1 : 0) + (world.getType(i + b0, j + 1, k + b1).r() ? 1 : 0); + boolean flag = world.getType(i - b0, j, k - b1) == block || world.getType(i - b0, j + 1, k - b1) == block; + boolean flag1 = world.getType(i + b0, j, k + b1) == block || world.getType(i + b0, j + 1, k + b1) == block; + boolean flag2 = false; + + if (flag && !flag1) { + flag2 = true; + } else if (j1 > i1) { + flag2 = true; + } + + world.setTypeAndData(i, j, k, block, l, 2); + world.setTypeAndData(i, j + 1, k, block, 8 | (flag2 ? 1 : 0), 2); + world.applyPhysics(i, j, k, block); + world.applyPhysics(i, j + 1, k, block); + } +} diff --git a/src/main/java/net/minecraft/server/ItemDoorJungle.java b/src/main/java/net/minecraft/server/ItemDoorJungle.java new file mode 100644 index 0000000..b23b82d --- /dev/null +++ b/src/main/java/net/minecraft/server/ItemDoorJungle.java @@ -0,0 +1,81 @@ +package net.minecraft.server; + +public class ItemDoorJungle extends Item { + + // PaperSpigot - Added for compatibility reasons + + private Material a; + + public ItemDoorJungle(Material material) { + this.a = material; + this.maxStackSize = 64; // PaperSpigot - Bump to 1.8 max stack size + this.a(CreativeModeTab.d); + } + + public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + if (l != 1) { + return false; + } else { + ++j; + Block block; + + if (this.a == Material.WOOD) { + block = Blocks.JUNGLE_DOOR_BLOCK; + } else { + block = Blocks.IRON_DOOR_BLOCK; + } + + if (entityhuman.a(i, j, k, l, itemstack) && entityhuman.a(i, j + 1, k, l, itemstack)) { + if (!block.canPlace(world, i, j, k)) { + return false; + } else { + int i1 = MathHelper.floor((double) ((entityhuman.yaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3; + + place(world, i, j, k, i1, block); + --itemstack.count; + return true; + } + } else { + return false; + } + } + } + + public static void place(World world, int i, int j, int k, int l, Block block) { + byte b0 = 0; + byte b1 = 0; + + if (l == 0) { + b1 = 1; + } + + if (l == 1) { + b0 = -1; + } + + if (l == 2) { + b1 = -1; + } + + if (l == 3) { + b0 = 1; + } + + int i1 = (world.getType(i - b0, j, k - b1).r() ? 1 : 0) + (world.getType(i - b0, j + 1, k - b1).r() ? 1 : 0); + int j1 = (world.getType(i + b0, j, k + b1).r() ? 1 : 0) + (world.getType(i + b0, j + 1, k + b1).r() ? 1 : 0); + boolean flag = world.getType(i - b0, j, k - b1) == block || world.getType(i - b0, j + 1, k - b1) == block; + boolean flag1 = world.getType(i + b0, j, k + b1) == block || world.getType(i + b0, j + 1, k + b1) == block; + boolean flag2 = false; + + if (flag && !flag1) { + flag2 = true; + } else if (j1 > i1) { + flag2 = true; + } + + world.setTypeAndData(i, j, k, block, l, 2); + world.setTypeAndData(i, j + 1, k, block, 8 | (flag2 ? 1 : 0), 2); + world.applyPhysics(i, j, k, block); + world.applyPhysics(i, j + 1, k, block); + } +} diff --git a/src/main/java/net/minecraft/server/ItemDoorSpruce.java b/src/main/java/net/minecraft/server/ItemDoorSpruce.java new file mode 100644 index 0000000..15eb16a --- /dev/null +++ b/src/main/java/net/minecraft/server/ItemDoorSpruce.java @@ -0,0 +1,81 @@ +package net.minecraft.server; + +public class ItemDoorSpruce extends Item { + + // PaperSpigot - Added for compatibility reasons + + private Material a; + + public ItemDoorSpruce(Material material) { + this.a = material; + this.maxStackSize = 64; // PaperSpigot - Bump to 1.8 max stack size + this.a(CreativeModeTab.d); + } + + public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + if (l != 1) { + return false; + } else { + ++j; + Block block; + + if (this.a == Material.WOOD) { + block = Blocks.SPRUCE_DOOR_BLOCK; + } else { + block = Blocks.IRON_DOOR_BLOCK; + } + + if (entityhuman.a(i, j, k, l, itemstack) && entityhuman.a(i, j + 1, k, l, itemstack)) { + if (!block.canPlace(world, i, j, k)) { + return false; + } else { + int i1 = MathHelper.floor((double) ((entityhuman.yaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3; + + place(world, i, j, k, i1, block); + --itemstack.count; + return true; + } + } else { + return false; + } + } + } + + public static void place(World world, int i, int j, int k, int l, Block block) { + byte b0 = 0; + byte b1 = 0; + + if (l == 0) { + b1 = 1; + } + + if (l == 1) { + b0 = -1; + } + + if (l == 2) { + b1 = -1; + } + + if (l == 3) { + b0 = 1; + } + + int i1 = (world.getType(i - b0, j, k - b1).r() ? 1 : 0) + (world.getType(i - b0, j + 1, k - b1).r() ? 1 : 0); + int j1 = (world.getType(i + b0, j, k + b1).r() ? 1 : 0) + (world.getType(i + b0, j + 1, k + b1).r() ? 1 : 0); + boolean flag = world.getType(i - b0, j, k - b1) == block || world.getType(i - b0, j + 1, k - b1) == block; + boolean flag1 = world.getType(i + b0, j, k + b1) == block || world.getType(i + b0, j + 1, k + b1) == block; + boolean flag2 = false; + + if (flag && !flag1) { + flag2 = true; + } else if (j1 > i1) { + flag2 = true; + } + + world.setTypeAndData(i, j, k, block, l, 2); + world.setTypeAndData(i, j + 1, k, block, 8 | (flag2 ? 1 : 0), 2); + world.applyPhysics(i, j, k, block); + world.applyPhysics(i, j + 1, k, block); + } +} diff --git a/src/main/java/net/minecraft/server/Items.java b/src/main/java/net/minecraft/server/Items.java index 6834e67..3876847 100644 --- a/src/main/java/net/minecraft/server/Items.java +++ b/src/main/java/net/minecraft/server/Items.java @@ -173,5 +173,14 @@ public class Items { public static final Item RECORD_10 = (Item) Item.REGISTRY.get("record_ward"); public static final Item RECORD_11 = (Item) Item.REGISTRY.get("record_11"); public static final Item RECORD_12 = (Item) Item.REGISTRY.get("record_wait"); + // PaperSpigot start - Add new items + public static final Item SPRUCE_DOOR = (Item) Item.REGISTRY.get("spruce_door"); + public static final Item BIRCH_DOOR = (Item) Item.REGISTRY.get("birch_door"); + public static final Item JUNGLE_DOOR = (Item) Item.REGISTRY.a(429); // Jungle door ID, no idea why it does this will investigate more later + public static final Item ACACIA_DOOR = (Item) Item.REGISTRY.get("acacia_door"); + public static final Item DARK_OAK_DOOR = (Item) Item.REGISTRY.get("dark_oak_door"); + public static final Item MUTTON = (Item) Item.REGISTRY.get("mutton"); + public static final Item COOKED_MUTTON = (Item) Item.REGISTRY.get("cooked_mutton"); + // PaperSpigot end } diff --git a/src/main/java/net/minecraft/server/RecipesCrafting.java b/src/main/java/net/minecraft/server/RecipesCrafting.java index 0abda55..c34e71b 100644 --- a/src/main/java/net/minecraft/server/RecipesCrafting.java +++ b/src/main/java/net/minecraft/server/RecipesCrafting.java @@ -15,7 +15,7 @@ public class RecipesCrafting { craftingmanager.registerShapedRecipe(new ItemStack(Blocks.SANDSTONE, 1, 1), new Object[] { "#", "#", Character.valueOf('#'), new ItemStack(Blocks.STEP, 1, 1)}); craftingmanager.registerShapedRecipe(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 1), new Object[] { "#", "#", Character.valueOf('#'), new ItemStack(Blocks.STEP, 1, 7)}); craftingmanager.registerShapedRecipe(new ItemStack(Blocks.QUARTZ_BLOCK, 2, 2), new Object[] { "#", "#", Character.valueOf('#'), new ItemStack(Blocks.QUARTZ_BLOCK, 1, 0)}); - craftingmanager.registerShapedRecipe(new ItemStack(Blocks.SMOOTH_BRICK, 4), new Object[] { "##", "##", Character.valueOf('#'), Blocks.STONE}); + craftingmanager.registerShapedRecipe(new ItemStack(Blocks.SMOOTH_BRICK, 4), new Object[] { "##", "##", Character.valueOf('#'), new ItemStack(Blocks.STONE, 1, 0)}); // PaperSpigot - Explicit data value craftingmanager.registerShapedRecipe(new ItemStack(Blocks.IRON_FENCE, 16), new Object[] { "###", "###", Character.valueOf('#'), Items.IRON_INGOT}); craftingmanager.registerShapedRecipe(new ItemStack(Blocks.THIN_GLASS, 16), new Object[] { "###", "###", Character.valueOf('#'), Blocks.GLASS}); craftingmanager.registerShapedRecipe(new ItemStack(Blocks.REDSTONE_LAMP_OFF, 1), new Object[] { " R ", "RGR", " R ", Character.valueOf('R'), Items.REDSTONE, Character.valueOf('G'), Blocks.GLOWSTONE}); diff --git a/src/main/java/net/minecraft/server/RecipesFurnace.java b/src/main/java/net/minecraft/server/RecipesFurnace.java index 23a1446..db4d7d3 100644 --- a/src/main/java/net/minecraft/server/RecipesFurnace.java +++ b/src/main/java/net/minecraft/server/RecipesFurnace.java @@ -34,6 +34,7 @@ public class RecipesFurnace { this.a(Items.POTATO, new ItemStack(Items.POTATO_BAKED), 0.35F); this.registerRecipe(Blocks.NETHERRACK, new ItemStack(Items.NETHER_BRICK), 0.1F); this.registerRecipe(Blocks.SMOOTH_BRICK, new ItemStack(Blocks.SMOOTH_BRICK, 1, 2), 0.5F); // PaperSpigot - Register cracked stone brick recipe + this.a(Items.MUTTON, new ItemStack(Items.COOKED_MUTTON), 0.35F); // PaperSpigot - Register mutton recipe EnumFish[] aenumfish = EnumFish.values(); int i = aenumfish.length; -- 1.9.1