mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 04:32:11 -07:00
Start working on 1.19.4
This commit is contained in:
@@ -1,94 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Noah van der Aa <ndvdaa@gmail.com>
|
||||
Date: Sun, 8 Aug 2021 19:56:02 +0200
|
||||
Subject: [PATCH] Add CompostItemEvent and EntityCompostItemEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
||||
@@ -0,0 +0,0 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
||||
if (state != dummyBlockState && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, dummyBlockState).isCancelled()) { // if block state will change and event cancelled
|
||||
return InteractionResult.sidedSuccess(world.isClientSide);
|
||||
}
|
||||
- BlockState iblockdata1 = ComposterBlock.addItem(state, world, pos, itemstack, rand);
|
||||
+ BlockState iblockdata1 = ComposterBlock.addItem(state, world, pos, itemstack, player);
|
||||
+ if (iblockdata1 == null) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
world.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0);
|
||||
@@ -0,0 +0,0 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
||||
if (i < 7 && ComposterBlock.COMPOSTABLES.containsKey(itemstack.getItem())) {
|
||||
// CraftBukkit start
|
||||
double rand = worldserver.getRandom().nextDouble();
|
||||
- BlockState iblockdata1 = ComposterBlock.addItem(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand);
|
||||
+ BlockState iblockdata1 = ComposterBlock.addItem(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand, entity); // Paper
|
||||
if (iblockdata == iblockdata1 || org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) {
|
||||
return iblockdata;
|
||||
}
|
||||
- iblockdata1 = ComposterBlock.addItem(iblockdata, (LevelAccessor) worldserver, blockposition, itemstack, rand);
|
||||
+ // Paper start
|
||||
+ iblockdata1 = ComposterBlock.addItem(iblockdata, (LevelAccessor) worldserver, blockposition, itemstack, rand, entity);
|
||||
+ if (iblockdata1 == null) {
|
||||
+ return iblockdata;
|
||||
+ }
|
||||
+ // Paper end
|
||||
// CraftBukkit end
|
||||
|
||||
itemstack.shrink(1);
|
||||
@@ -0,0 +0,0 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
||||
// CraftBukkit start
|
||||
return ComposterBlock.addItem(state, world, pos, item, world.getRandom().nextDouble());
|
||||
}
|
||||
+ // Paper start
|
||||
+ static BlockState addItem(BlockState state, LevelAccessor world, BlockPos pos, ItemStack item, @Nullable Entity entity) {
|
||||
+ return ComposterBlock.addItem(state, world, pos, item, world.getRandom().nextDouble(), entity);
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
static BlockState addItem(BlockState iblockdata, LevelAccessor generatoraccess, BlockPos blockposition, ItemStack itemstack, double rand) {
|
||||
+ // Paper start
|
||||
+ return ComposterBlock.addItem(iblockdata, generatoraccess, blockposition, itemstack, rand, null);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ static BlockState addItem(BlockState iblockdata, LevelAccessor generatoraccess, BlockPos blockposition, ItemStack itemstack, double rand, @Nullable Entity entity) {
|
||||
+ // Paper end
|
||||
// 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) {
|
||||
+ // Paper start
|
||||
+ io.papermc.paper.event.block.CompostItemEvent event;
|
||||
+ boolean willRaiseLevel = !((i != 0 || f <= 0.0F) && rand >= (double) f);
|
||||
+ if (entity == null) {
|
||||
+ event = new io.papermc.paper.event.block.CompostItemEvent(org.bukkit.craftbukkit.block.CraftBlock.at(generatoraccess, blockposition), itemstack.getBukkitStack(), willRaiseLevel);
|
||||
+ } else {
|
||||
+ event = new io.papermc.paper.event.entity.EntityCompostItemEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(generatoraccess, blockposition), itemstack.getBukkitStack(), willRaiseLevel);
|
||||
+ }
|
||||
+
|
||||
+ if (!event.callEvent()) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.willRaiseLevel()) {
|
||||
+ // Paper end
|
||||
return iblockdata;
|
||||
} else {
|
||||
int j = i + 1;
|
||||
@@ -0,0 +0,0 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
||||
this.changed = true;
|
||||
BlockState iblockdata = ComposterBlock.addItem(this.state, this.level, this.pos, itemstack);
|
||||
|
||||
+ // Paper start
|
||||
+ if (iblockdata == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.level.levelEvent(1500, this.pos, iblockdata != this.state ? 1 : 0);
|
||||
this.removeItemNoUpdate(0);
|
||||
}
|
Reference in New Issue
Block a user