aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/level/block/ComposterBlock.java.patch
blob: f5b32cecc27510db3545ee02c6c893b38d420918 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
--- a/net/minecraft/world/level/block/ComposterBlock.java
+++ b/net/minecraft/world/level/block/ComposterBlock.java
@@ -13,7 +13,7 @@
 import net.minecraft.sounds.SoundSource;
 import net.minecraft.stats.Stats;
 import net.minecraft.util.RandomSource;
-import net.minecraft.world.InteractionHand;
+import net.minecraft.world.EnumHand;
 import net.minecraft.world.InteractionResult;
 import net.minecraft.world.SimpleContainer;
 import net.minecraft.world.WorldlyContainer;
@@ -24,52 +24,58 @@
 import net.minecraft.world.item.ItemStack;
 import net.minecraft.world.item.Items;
 import net.minecraft.world.level.BlockGetter;
-import net.minecraft.world.level.ItemLike;
+import net.minecraft.world.level.IMaterial;
 import net.minecraft.world.level.Level;
 import net.minecraft.world.level.LevelAccessor;
 import net.minecraft.world.level.block.state.BlockBehaviour;
-import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.block.state.IBlockData;
 import net.minecraft.world.level.block.state.StateDefinition;
 import net.minecraft.world.level.block.state.properties.BlockStateProperties;
 import net.minecraft.world.level.block.state.properties.IntegerProperty;
 import net.minecraft.world.level.gameevent.GameEvent;
-import net.minecraft.world.level.pathfinder.PathComputationType;
+import net.minecraft.world.level.pathfinder.PathMode;
 import net.minecraft.world.phys.BlockHitResult;
 import net.minecraft.world.phys.Vec3;
 import net.minecraft.world.phys.shapes.BooleanOp;
 import net.minecraft.world.phys.shapes.CollisionContext;
 import net.minecraft.world.phys.shapes.Shapes;
 import net.minecraft.world.phys.shapes.VoxelShape;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftBlockInventoryHolder;
+import org.bukkit.craftbukkit.util.DummyGeneratorAccess;
+// CraftBukkit end
 
 public class ComposterBlock extends Block implements WorldlyContainerHolder {
+
     public static final MapCodec<ComposterBlock> CODEC = simpleCodec(ComposterBlock::new);
     public static final int READY = 8;
     public static final int MIN_LEVEL = 0;
     public static final int MAX_LEVEL = 7;
     public static final IntegerProperty LEVEL = BlockStateProperties.LEVEL_COMPOSTER;
-    public static final Object2FloatMap<ItemLike> COMPOSTABLES = new Object2FloatOpenHashMap<>();
+    public static final Object2FloatMap<IMaterial> COMPOSTABLES = new Object2FloatOpenHashMap();
     private static final int AABB_SIDE_THICKNESS = 2;
     private static final VoxelShape OUTER_SHAPE = Shapes.block();
-    private static final VoxelShape[] SHAPES = Util.make(new VoxelShape[9], shapes -> {
-        for (int i = 0; i < 8; i++) {
-            shapes[i] = Shapes.join(OUTER_SHAPE, Block.box(2.0, (double)Math.max(2, 1 + i * 2), 2.0, 14.0, 16.0, 14.0), BooleanOp.ONLY_FIRST);
+    private static final VoxelShape[] SHAPES = (VoxelShape[]) Util.make(new VoxelShape[9], (avoxelshape) -> {
+        for (int i = 0; i < 8; ++i) {
+            avoxelshape[i] = Shapes.join(ComposterBlock.OUTER_SHAPE, Block.box(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), BooleanOp.ONLY_FIRST);
         }
 
-        shapes[8] = shapes[7];
+        avoxelshape[8] = avoxelshape[7];
     });
 
     @Override
     public MapCodec<ComposterBlock> codec() {
-        return CODEC;
+        return ComposterBlock.CODEC;
     }
 
     public static void bootStrap() {
-        COMPOSTABLES.defaultReturnValue(-1.0F);
+        ComposterBlock.COMPOSTABLES.defaultReturnValue(-1.0F);
         float f = 0.3F;
         float f1 = 0.5F;
         float f2 = 0.65F;
         float f3 = 0.85F;
         float f4 = 1.0F;
+
         add(0.3F, Items.JUNGLE_LEAVES);
         add(0.3F, Items.OAK_LEAVES);
         add(0.3F, Items.SPRUCE_LEAVES);
@@ -173,72 +179,70 @@
         add(1.0F, Items.PUMPKIN_PIE);
     }
 
-    private static void add(float chance, ItemLike item) {
-        COMPOSTABLES.put(item.asItem(), chance);
+    private static void add(float chance, IMaterial item) {
+        ComposterBlock.COMPOSTABLES.put(item.asItem(), chance);
     }
 
     public ComposterBlock(BlockBehaviour.Properties properties) {
         super(properties);
-        this.registerDefaultState(this.stateDefinition.any().setValue(LEVEL, Integer.valueOf(0)));
+        this.registerDefaultState((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(ComposterBlock.LEVEL, 0));
     }
 
     public static void handleFill(Level level, BlockPos pos, boolean success) {
-        BlockState blockState = level.getBlockState(pos);
+        IBlockData iblockdata = level.getBlockState(pos);
+
         level.playLocalSound(pos, success ? SoundEvents.COMPOSTER_FILL_SUCCESS : SoundEvents.COMPOSTER_FILL, SoundSource.BLOCKS, 1.0F, 1.0F, false);
-        double d = blockState.getShape(level, pos).max(Direction.Axis.Y, 0.5, 0.5) + 0.03125;
-        double d1 = 0.13125F;
-        double d2 = 0.7375F;
-        RandomSource random = level.getRandom();
+        double d0 = iblockdata.getShape(level, pos).max(Direction.Axis.Y, 0.5D, 0.5D) + 0.03125D;
+        double d1 = 0.13124999403953552D;
+        double d2 = 0.737500011920929D;
+        RandomSource randomsource = level.getRandom();
 
-        for (int i = 0; i < 10; i++) {
-            double d3 = random.nextGaussian() * 0.02;
-            double d4 = random.nextGaussian() * 0.02;
-            double d5 = random.nextGaussian() * 0.02;
-            level.addParticle(
-                ParticleTypes.COMPOSTER,
-                (double)pos.getX() + 0.13125F + 0.7375F * (double)random.nextFloat(),
-                (double)pos.getY() + d + (double)random.nextFloat() * (1.0 - d),
-                (double)pos.getZ() + 0.13125F + 0.7375F * (double)random.nextFloat(),
-                d3,
-                d4,
-                d5
-            );
+        for (int i = 0; i < 10; ++i) {
+            double d3 = randomsource.nextGaussian() * 0.02D;
+            double d4 = randomsource.nextGaussian() * 0.02D;
+            double d5 = randomsource.nextGaussian() * 0.02D;
+
+            level.addParticle(ParticleTypes.COMPOSTER, (double) pos.getX() + 0.13124999403953552D + 0.737500011920929D * (double) randomsource.nextFloat(), (double) pos.getY() + d0 + (double) randomsource.nextFloat() * (1.0D - d0), (double) pos.getZ() + 0.13124999403953552D + 0.737500011920929D * (double) randomsource.nextFloat(), d3, d4, d5);
         }
+
     }
 
     @Override
-    public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
-        return SHAPES[state.getValue(LEVEL)];
+    public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) {
+        return ComposterBlock.SHAPES[(Integer) state.getValue(ComposterBlock.LEVEL)];
     }
 
     @Override
-    public VoxelShape getInteractionShape(BlockState state, BlockGetter level, BlockPos pos) {
-        return OUTER_SHAPE;
+    public VoxelShape getInteractionShape(IBlockData state, BlockGetter level, BlockPos pos) {
+        return ComposterBlock.OUTER_SHAPE;
     }
 
     @Override
-    public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
-        return SHAPES[0];
+    public VoxelShape getCollisionShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) {
+        return ComposterBlock.SHAPES[0];
     }
 
     @Override
-    public void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) {
-        if (state.getValue(LEVEL) == 7) {
+    public void onPlace(IBlockData state, Level level, BlockPos pos, IBlockData oldState, boolean isMoving) {
+        if ((Integer) state.getValue(ComposterBlock.LEVEL) == 7) {
             level.scheduleTick(pos, state.getBlock(), 20);
         }
+
     }
 
     @Override
-    public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
-        int i = state.getValue(LEVEL);
-        ItemStack itemInHand = player.getItemInHand(hand);
-        if (i < 8 && COMPOSTABLES.containsKey(itemInHand.getItem())) {
+    public InteractionResult use(IBlockData state, Level level, BlockPos pos, Player player, EnumHand hand, BlockHitResult hit) {
+        int i = (Integer) state.getValue(ComposterBlock.LEVEL);
+        ItemStack itemstack = player.getItemInHand(hand);
+
+        if (i < 8 && ComposterBlock.COMPOSTABLES.containsKey(itemstack.getItem())) {
             if (i < 7 && !level.isClientSide) {
-                BlockState blockState = addItem(player, state, level, pos, itemInHand);
-                level.levelEvent(1500, pos, state != blockState ? 1 : 0);
-                player.awardStat(Stats.ITEM_USED.get(itemInHand.getItem()));
+                IBlockData iblockdata1 = addItem(player, state, level, pos, itemstack);
+
+                level.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0);
+                player.awardStat(Stats.ITEM_USED.get(itemstack.getItem()));
                 if (!player.getAbilities().instabuild) {
-                    itemInHand.shrink(1);
+                    itemstack.shrink(1);
                 }
             }
 
@@ -251,101 +255,143 @@
         }
     }
 
-    public static BlockState insertItem(Entity entity, BlockState state, ServerLevel level, ItemStack stack, BlockPos pos) {
-        int i = state.getValue(LEVEL);
-        if (i < 7 && COMPOSTABLES.containsKey(stack.getItem())) {
-            BlockState blockState = addItem(entity, state, level, pos, stack);
+    public static IBlockData insertItem(Entity entity, IBlockData state, ServerLevel level, ItemStack stack, BlockPos pos) {
+        int i = (Integer) state.getValue(ComposterBlock.LEVEL);
+
+        if (i < 7 && ComposterBlock.COMPOSTABLES.containsKey(stack.getItem())) {
+            // CraftBukkit start
+            double rand = level.getRandom().nextDouble();
+            IBlockData iblockdata1 = addItem(entity, state, DummyGeneratorAccess.INSTANCE, pos, stack, rand);
+            if (state == iblockdata1 || !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, iblockdata1)) {
+                return state;
+            }
+            iblockdata1 = addItem(entity, state, level, pos, stack, rand);
+            // CraftBukkit end
+
             stack.shrink(1);
-            return blockState;
+            return iblockdata1;
         } else {
             return state;
         }
     }
 
-    public static BlockState extractProduce(Entity entity, BlockState state, Level level, BlockPos pos) {
+    public static IBlockData extractProduce(Entity entity, IBlockData state, Level level, BlockPos pos) {
+        // CraftBukkit start
+        if (entity != null && !(entity instanceof Player)) {
+            IBlockData iblockdata1 = empty(entity, state, DummyGeneratorAccess.INSTANCE, pos);
+            if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, iblockdata1)) {
+                return state;
+            }
+        }
+        // CraftBukkit end
         if (!level.isClientSide) {
-            Vec3 vec3 = Vec3.atLowerCornerWithOffset(pos, 0.5, 1.01, 0.5).offsetRandom(level.random, 0.7F);
-            ItemEntity itemEntity = new ItemEntity(level, vec3.x(), vec3.y(), vec3.z(), new ItemStack(Items.BONE_MEAL));
-            itemEntity.setDefaultPickUpDelay();
-            level.addFreshEntity(itemEntity);
+            Vec3 vec3d = Vec3.atLowerCornerWithOffset(pos, 0.5D, 1.01D, 0.5D).offsetRandom(level.random, 0.7F);
+            ItemEntity entityitem = new ItemEntity(level, vec3d.x(), vec3d.y(), vec3d.z(), new ItemStack(Items.BONE_MEAL));
+
+            entityitem.setDefaultPickUpDelay();
+            level.addFreshEntity(entityitem);
         }
 
-        BlockState blockState = empty(entity, state, level, pos);
-        level.playSound(null, pos, SoundEvents.COMPOSTER_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F);
-        return blockState;
+        IBlockData iblockdata1 = empty(entity, state, level, pos);
+
+        level.playSound((Player) null, pos, SoundEvents.COMPOSTER_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F);
+        return iblockdata1;
     }
 
-    static BlockState empty(@Nullable Entity entity, BlockState state, LevelAccessor level, BlockPos pos) {
-        BlockState blockState = state.setValue(LEVEL, Integer.valueOf(0));
-        level.setBlock(pos, blockState, 3);
-        level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(entity, blockState));
-        return blockState;
+    static IBlockData empty(@Nullable Entity entity, IBlockData state, LevelAccessor level, BlockPos pos) {
+        IBlockData iblockdata1 = (IBlockData) state.setValue(ComposterBlock.LEVEL, 0);
+
+        level.setBlock(pos, iblockdata1, 3);
+        level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(entity, iblockdata1));
+        return iblockdata1;
     }
 
-    static BlockState addItem(@Nullable Entity entity, BlockState state, LevelAccessor level, BlockPos pos, ItemStack stack) {
-        int i = state.getValue(LEVEL);
-        float _float = COMPOSTABLES.getFloat(stack.getItem());
-        if ((i != 0 || !(_float > 0.0F)) && !(level.getRandom().nextDouble() < (double)_float)) {
-            return state;
+    static IBlockData addItem(@Nullable Entity entity, IBlockData state, LevelAccessor level, BlockPos pos, ItemStack stack) {
+        // CraftBukkit start
+        return addItem(entity, state, level, pos, stack, level.getRandom().nextDouble());
+    }
+
+    static IBlockData addItem(@Nullable Entity entity, IBlockData iblockdata, LevelAccessor generatoraccess, BlockPos blockposition, ItemStack itemstack, double rand) {
+        // CraftBukkit end
+        int i = (Integer) iblockdata.getValue(ComposterBlock.LEVEL);
+        float f = ComposterBlock.COMPOSTABLES.getFloat(itemstack.getItem());
+
+        if ((i != 0 || f <= 0.0F) && rand >= (double) f) {
+            return iblockdata;
         } else {
-            int i1 = i + 1;
-            BlockState blockState = state.setValue(LEVEL, Integer.valueOf(i1));
-            level.setBlock(pos, blockState, 3);
-            level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(entity, blockState));
-            if (i1 == 7) {
-                level.scheduleTick(pos, state.getBlock(), 20);
+            int j = i + 1;
+            IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(ComposterBlock.LEVEL, j);
+
+            generatoraccess.setBlock(blockposition, iblockdata1, 3);
+            generatoraccess.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(entity, iblockdata1));
+            if (j == 7) {
+                generatoraccess.scheduleTick(blockposition, iblockdata.getBlock(), 20);
             }
 
-            return blockState;
+            return iblockdata1;
         }
     }
 
     @Override
-    public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
-        if (state.getValue(LEVEL) == 7) {
-            level.setBlock(pos, state.cycle(LEVEL), 3);
-            level.playSound(null, pos, SoundEvents.COMPOSTER_READY, SoundSource.BLOCKS, 1.0F, 1.0F);
+    public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) {
+        if ((Integer) state.getValue(ComposterBlock.LEVEL) == 7) {
+            level.setBlock(pos, (IBlockData) state.cycle(ComposterBlock.LEVEL), 3);
+            level.playSound((Player) null, pos, SoundEvents.COMPOSTER_READY, SoundSource.BLOCKS, 1.0F, 1.0F);
         }
+
     }
 
     @Override
-    public boolean hasAnalogOutputSignal(BlockState state) {
+    public boolean hasAnalogOutputSignal(IBlockData state) {
         return true;
     }
 
     @Override
-    public int getAnalogOutputSignal(BlockState blockState, Level level, BlockPos pos) {
-        return blockState.getValue(LEVEL);
+    public int getAnalogOutputSignal(IBlockData blockState, Level level, BlockPos pos) {
+        return (Integer) blockState.getValue(ComposterBlock.LEVEL);
     }
 
     @Override
-    protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
-        builder.add(LEVEL);
+    protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) {
+        builder.add(ComposterBlock.LEVEL);
     }
 
     @Override
-    public boolean isPathfindable(BlockState state, BlockGetter level, BlockPos pos, PathComputationType type) {
+    public boolean isPathfindable(IBlockData state, BlockGetter level, BlockPos pos, PathMode type) {
         return false;
     }
 
     @Override
-    public WorldlyContainer getContainer(BlockState state, LevelAccessor level, BlockPos pos) {
-        int i = state.getValue(LEVEL);
-        if (i == 8) {
-            return new ComposterBlock.OutputContainer(state, level, pos, new ItemStack(Items.BONE_MEAL));
-        } else {
-            return (WorldlyContainer)(i < 7 ? new ComposterBlock.InputContainer(state, level, pos) : new ComposterBlock.EmptyContainer());
-        }
+    public WorldlyContainer getContainer(IBlockData state, LevelAccessor level, BlockPos pos) {
+        int i = (Integer) state.getValue(ComposterBlock.LEVEL);
+
+        // CraftBukkit - empty generatoraccess, blockposition
+        return (WorldlyContainer) (i == 8 ? new ComposterBlock.OutputContainer(state, level, pos, new ItemStack(Items.BONE_MEAL)) : (i < 7 ? new ComposterBlock.InputContainer(state, level, pos) : new ComposterBlock.EmptyContainer(level, pos)));
     }
 
-    static class EmptyContainer extends SimpleContainer implements WorldlyContainer {
-        public EmptyContainer() {
-            super(0);
+    public static class OutputContainer extends SimpleContainer implements WorldlyContainer {
+
+        private final IBlockData state;
+        private final LevelAccessor level;
+        private final BlockPos pos;
+        private boolean changed;
+
+        public OutputContainer(IBlockData state, LevelAccessor level, BlockPos pos, ItemStack stack) {
+            super(stack);
+            this.state = state;
+            this.level = level;
+            this.pos = pos;
+            this.bukkitOwner = new CraftBlockInventoryHolder(level, pos, this); // CraftBukkit
         }
 
         @Override
+        public int getMaxStackSize() {
+            return 1;
+        }
+
+        @Override
         public int[] getSlotsForFace(Direction side) {
-            return new int[0];
+            return side == Direction.DOWN ? new int[]{0} : new int[0];
         }
 
         @Override
@@ -355,18 +401,33 @@
 
         @Override
         public boolean canTakeItemThroughFace(int index, ItemStack stack, Direction direction) {
-            return false;
+            return !this.changed && direction == Direction.DOWN && stack.is(Items.BONE_MEAL);
         }
+
+        @Override
+        public void setChanged() {
+            // CraftBukkit start - allow putting items back (eg cancelled InventoryMoveItemEvent)
+            if (this.isEmpty()) {
+            ComposterBlock.empty((Entity) null, this.state, this.level, this.pos);
+            this.changed = true;
+            } else {
+                this.level.setBlock(this.pos, this.state, 3);
+                this.changed = false;
+            }
+            // CraftBukkit end
+        }
     }
 
-    static class InputContainer extends SimpleContainer implements WorldlyContainer {
-        private final BlockState state;
+    public static class InputContainer extends SimpleContainer implements WorldlyContainer {
+
+        private final IBlockData state;
         private final LevelAccessor level;
         private final BlockPos pos;
         private boolean changed;
 
-        public InputContainer(BlockState state, LevelAccessor level, BlockPos pos) {
+        public InputContainer(IBlockData state, LevelAccessor level, BlockPos pos) {
             super(1);
+            this.bukkitOwner = new CraftBlockInventoryHolder(level, pos, this); // CraftBukkit
             this.state = state;
             this.level = level;
             this.pos = pos;
@@ -394,37 +455,29 @@
 
         @Override
         public void setChanged() {
-            ItemStack item = this.getItem(0);
-            if (!item.isEmpty()) {
+            ItemStack itemstack = this.getItem(0);
+
+            if (!itemstack.isEmpty()) {
                 this.changed = true;
-                BlockState blockState = ComposterBlock.addItem(null, this.state, this.level, this.pos, item);
-                this.level.levelEvent(1500, this.pos, blockState != this.state ? 1 : 0);
+                IBlockData iblockdata = ComposterBlock.addItem((Entity) null, this.state, this.level, this.pos, itemstack);
+
+                this.level.levelEvent(1500, this.pos, iblockdata != this.state ? 1 : 0);
                 this.removeItemNoUpdate(0);
             }
+
         }
     }
 
-    static class OutputContainer extends SimpleContainer implements WorldlyContainer {
-        private final BlockState state;
-        private final LevelAccessor level;
-        private final BlockPos pos;
-        private boolean changed;
+    public static class EmptyContainer extends SimpleContainer implements WorldlyContainer {
 
-        public OutputContainer(BlockState state, LevelAccessor level, BlockPos pos, ItemStack stack) {
-            super(stack);
-            this.state = state;
-            this.level = level;
-            this.pos = pos;
+        public EmptyContainer(LevelAccessor generatoraccess, BlockPos blockposition) { // CraftBukkit
+            super(0);
+            this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit
         }
 
         @Override
-        public int getMaxStackSize() {
-            return 1;
-        }
-
-        @Override
         public int[] getSlotsForFace(Direction side) {
-            return side == Direction.DOWN ? new int[]{0} : new int[0];
+            return new int[0];
         }
 
         @Override
@@ -434,13 +487,7 @@
 
         @Override
         public boolean canTakeItemThroughFace(int index, ItemStack stack, Direction direction) {
-            return !this.changed && direction == Direction.DOWN && stack.is(Items.BONE_MEAL);
+            return false;
         }
-
-        @Override
-        public void setChanged() {
-            ComposterBlock.empty(null, this.state, this.level, this.pos);
-            this.changed = true;
-        }
     }
 }