3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-19 04:50:06 +01:00

SPIGOT-5889: Villager using composter should call EntityChangeBlockEvent

Dieser Commit ist enthalten in:
Parker Hawke 2020-06-30 12:18:39 +10:00 committet von md_5
Ursprung 2fe6b4a320
Commit d47c47ee59
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: E8E901AC7C617C11
4 geänderte Dateien mit 80 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,26 @@
--- a/net/minecraft/server/BehaviorWork.java
+++ b/net/minecraft/server/BehaviorWork.java
@@ -27,19 +27,19 @@
protected void a(WorldServer worldserver, EntityVillager entityvillager, long i) {
BehaviorController<EntityVillager> behaviorcontroller = entityvillager.getBehaviorController();
- behaviorcontroller.setMemory(MemoryModuleType.LAST_WORKED_AT_POI, (Object) i);
+ behaviorcontroller.setMemory(MemoryModuleType.LAST_WORKED_AT_POI, i); // CraftBukkit - decompile error
behaviorcontroller.getMemory(MemoryModuleType.JOB_SITE).ifPresent((globalpos) -> {
- behaviorcontroller.setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(globalpos.getBlockPosition())));
+ behaviorcontroller.setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(globalpos.getBlockPosition()))); // CraftBukkit - decompile error
});
entityvillager.fd();
- this.a(worldserver, entityvillager);
+ this.doWork(worldserver, entityvillager); // PAIL
if (entityvillager.fc()) {
entityvillager.fb();
}
}
- protected void a(WorldServer worldserver, EntityVillager entityvillager) {}
+ protected void doWork(WorldServer worldserver, EntityVillager entityvillager) {} // PAIL
protected boolean b(WorldServer worldserver, EntityVillager entityvillager, long i) {
Optional<GlobalPos> optional = entityvillager.getBehaviorController().getMemory(MemoryModuleType.JOB_SITE);

Datei anzeigen

@ -0,0 +1,20 @@
--- a/net/minecraft/server/BehaviorWorkComposter.java
+++ b/net/minecraft/server/BehaviorWorkComposter.java
@@ -11,7 +11,7 @@
public BehaviorWorkComposter() {}
@Override
- protected void a(WorldServer worldserver, EntityVillager entityvillager) {
+ protected void doWork(WorldServer worldserver, EntityVillager entityvillager) { // PAIL
Optional<GlobalPos> optional = entityvillager.getBehaviorController().getMemory(MemoryModuleType.JOB_SITE);
if (optional.isPresent()) {
@@ -52,7 +52,7 @@
i -= k1;
for (int l1 = 0; l1 < k1; ++l1) {
- iblockdata = BlockComposter.a(iblockdata, worldserver, itemstack, globalpos.getBlockPosition());
+ iblockdata = BlockComposter.a(iblockdata, worldserver, itemstack, globalpos.getBlockPosition(), entityvillager); // CraftBukkit
if ((Integer) iblockdata.get(BlockComposter.a) == 7) {
return;
}

Datei anzeigen

@ -1,10 +1,13 @@
--- a/net/minecraft/server/BlockComposter.java
+++ b/net/minecraft/server/BlockComposter.java
@@ -4,13 +4,14 @@
@@ -4,13 +4,17 @@
import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap;
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.inventory.CraftBlockInventoryHolder; // CraftBukkit
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftBlockInventoryHolder;
+import org.bukkit.craftbukkit.util.DummyGeneratorAccess;
+// CraftBukkit end
public class BlockComposter extends Block implements IInventoryHolder {
@ -16,7 +19,27 @@
for (int i = 0; i < 8; ++i) {
avoxelshape[i] = VoxelShapes.a(BlockComposter.c, Block.a(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), OperatorBoolean.ONLY_FIRST);
}
@@ -254,7 +255,8 @@
@@ -163,11 +167,17 @@
}
}
- public static IBlockData a(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition) {
+ public static IBlockData a(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition, EntityVillager entity) { // CraftBukkit
int i = (Integer) iblockdata.get(BlockComposter.a);
if (i < 7 && BlockComposter.b.containsKey(itemstack.getItem())) {
- IBlockData iblockdata1 = b(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack);
+ // CraftBukkit start
+ IBlockData iblockdata1 = b(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack);
+ if (iblockdata == iblockdata1 || org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) {
+ return iblockdata;
+ }
+ iblockdata1 = b(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack);
+ // CraftBukkit end
itemstack.subtract(1);
worldserver.triggerEffect(1500, blockposition, iblockdata != iblockdata1 ? 1 : 0);
@@ -254,7 +264,8 @@
public IWorldInventory a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
int i = (Integer) iblockdata.get(BlockComposter.a);
@ -26,7 +49,7 @@
}
static class ContainerInput extends InventorySubcontainer implements IWorldInventory {
@@ -266,6 +268,7 @@
@@ -266,6 +277,7 @@
public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
super(1);
@ -34,7 +57,7 @@
this.a = iblockdata;
this.b = generatoraccess;
this.c = blockposition;
@@ -318,6 +321,7 @@
@@ -318,6 +330,7 @@
this.blockData = iblockdata;
this.generatorAccess = generatoraccess;
this.blockPosition = blockposition;
@ -42,7 +65,7 @@
}
@Override
@@ -342,15 +346,23 @@
@@ -342,15 +355,23 @@
@Override
public void update() {

Datei anzeigen

@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.util;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import java.util.function.Predicate;
import net.minecraft.server.AxisAlignedBB;
import net.minecraft.server.BiomeBase;
@ -25,6 +26,7 @@ import net.minecraft.server.ParticleParam;
import net.minecraft.server.SoundCategory;
import net.minecraft.server.SoundEffect;
import net.minecraft.server.TickList;
import net.minecraft.server.TickListEmpty;
import net.minecraft.server.TileEntity;
import net.minecraft.server.World;
import net.minecraft.server.WorldBorder;
@ -39,12 +41,12 @@ public class DummyGeneratorAccess implements GeneratorAccess {
@Override
public TickList<Block> getBlockTickList() {
throw new UnsupportedOperationException("Not supported yet.");
return TickListEmpty.b();
}
@Override
public TickList<FluidType> getFluidTickList() {
throw new UnsupportedOperationException("Not supported yet.");
return TickListEmpty.b();
}
@Override
@ -69,7 +71,7 @@ public class DummyGeneratorAccess implements GeneratorAccess {
@Override
public Random getRandom() {
throw new UnsupportedOperationException("Not supported yet.");
return ThreadLocalRandom.current();
}
@Override