summaryrefslogtreecommitdiffstats
path: root/nms-patches/Block.patch
blob: 87c30356a1cfd2f27512813284296d8c812e3af2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
--- a/net/minecraft/server/Block.java
+++ b/net/minecraft/server/Block.java
@@ -32,7 +32,7 @@
     @Nullable
     private String name;
     private static final ThreadLocal<Object2ByteLinkedOpenHashMap<Block.a>> q = ThreadLocal.withInitial(() -> {
-        Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap = new Object2ByteLinkedOpenHashMap(200) {
+        Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap = new Object2ByteLinkedOpenHashMap<Block.a>(200) { // CraftBukkit - decompile error
             protected void rehash(int i) {}
         };
 
@@ -194,7 +194,7 @@
     }
 
     public Block(Block.Info block_info) {
-        BlockStateList.a blockstatelist_a = new BlockStateList.a(this);
+        BlockStateList.a<Block, IBlockData> blockstatelist_a = new BlockStateList.a(this); // CraftBukkit - decompile error
 
         this.a(blockstatelist_a);
         this.blockStateList = blockstatelist_a.a(BlockData::new);
@@ -409,7 +409,8 @@
             int j = this.getDropCount(iblockdata, i, world, blockposition, world.random);
 
             for (int k = 0; k < j; ++k) {
-                if (f >= 1.0F || world.random.nextFloat() <= f) {
+                // CraftBukkit - <= to < to allow for plugins to completely disable block drops from explosions
+                if (f >= 1.0F || world.random.nextFloat() < f) {
                     Item item = this.getDropType(iblockdata, world, blockposition, i).getItem();
 
                     if (item != Items.AIR) {
@@ -430,7 +431,13 @@
             EntityItem entityitem = new EntityItem(world, (double) blockposition.getX() + d0, (double) blockposition.getY() + d1, (double) blockposition.getZ() + d2, itemstack);
 
             entityitem.n();
-            world.addEntity(entityitem);
+            // CraftBukkit start
+            if (world.captureDrops != null) {
+                world.captureDrops.add(entityitem);
+            } else {
+                world.addEntity(entityitem);
+            }
+            // CraftBukkit end
         }
     }
 
@@ -649,7 +656,7 @@
     }
 
     public String toString() {
-        return "Block{" + IRegistry.BLOCK.getKey(this) + "}";
+        return IRegistry.BLOCK.getKey(this).toString(); // CraftBukkit - cheap hack
     }
 
     public static boolean c(Block block) {
@@ -1398,8 +1405,14 @@
 
     }
 
+    // CraftBukkit start
+    public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) {
+        return 0;
+    }
+    // CraftBukkit end
+
     private static void a(MinecraftKey minecraftkey, Block block) {
-        IRegistry.BLOCK.a(minecraftkey, (Object) block);
+        IRegistry.BLOCK.a(minecraftkey, block); // CraftBukkit - decompile error
     }
 
     private static void a(String s, Block block) {