Update to Minecraft 1.20

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2023-06-08 01:30:00 +10:00
parent bac55e67d6
commit 9d740b84b0
269 changed files with 2605 additions and 2568 deletions

View File

@@ -155,12 +155,12 @@
BlockPosition blockposition1 = blockposition.immutable();
@@ -281,8 +383,8 @@
TileEntity tileentity = iblockdata.hasBlockEntity() ? this.level.getBlockEntity(blockposition) : null;
LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder(worldserver)).withRandom(this.level.random).withParameter(LootContextParameters.ORIGIN, Vec3D.atCenterOf(blockposition)).withParameter(LootContextParameters.TOOL, ItemStack.EMPTY).withOptionalParameter(LootContextParameters.BLOCK_ENTITY, tileentity).withOptionalParameter(LootContextParameters.THIS_ENTITY, this.source);
LootParams.a lootparams_a = (new LootParams.a(worldserver)).withParameter(LootContextParameters.ORIGIN, Vec3D.atCenterOf(blockposition)).withParameter(LootContextParameters.TOOL, ItemStack.EMPTY).withOptionalParameter(LootContextParameters.BLOCK_ENTITY, tileentity).withOptionalParameter(LootContextParameters.THIS_ENTITY, this.source);
- if (this.blockInteraction == Explosion.Effect.DESTROY_WITH_DECAY) {
- loottableinfo_builder.withParameter(LootContextParameters.EXPLOSION_RADIUS, this.radius);
- lootparams_a.withParameter(LootContextParameters.EXPLOSION_RADIUS, this.radius);
+ if (yield < 1.0F) { // CraftBukkit - add yield
+ loottableinfo_builder.withParameter(LootContextParameters.EXPLOSION_RADIUS, 1.0F / yield); // CraftBukkit - add yield
+ lootparams_a.withParameter(LootContextParameters.EXPLOSION_RADIUS, 1.0F / yield); // CraftBukkit - add yield
}
iblockdata.spawnAfterBreak(worldserver, blockposition, ItemStack.EMPTY, flag2);

View File

@@ -32,7 +32,7 @@
public abstract class World implements GeneratorAccess, AutoCloseable {
public static final Codec<ResourceKey<World>> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION);
@@ -115,7 +140,43 @@
@@ -114,7 +139,43 @@
private final DamageSources damageSources;
private long subTickCount;
@@ -77,7 +77,7 @@
this.profiler = supplier;
this.levelData = worlddatamutable;
this.dimensionTypeRegistration = holder;
@@ -130,12 +191,12 @@
@@ -129,12 +190,12 @@
this.worldBorder = new WorldBorder() {
@Override
public double getCenterX() {
@@ -92,7 +92,7 @@
}
};
} else {
@@ -148,6 +209,42 @@
@@ -147,6 +208,42 @@
this.neighborUpdater = new CollectingNeighborUpdater(this, j);
this.registryAccess = iregistrycustom;
this.damageSources = new DamageSources(iregistrycustom);
@@ -135,7 +135,7 @@
}
@Override
@@ -205,6 +302,17 @@
@@ -204,6 +301,17 @@
@Override
public boolean setBlock(BlockPosition blockposition, IBlockData iblockdata, int i, int j) {
@@ -153,7 +153,7 @@
if (this.isOutsideBuildHeight(blockposition)) {
return false;
} else if (!this.isClientSide && this.isDebug()) {
@@ -212,9 +320,24 @@
@@ -211,13 +319,29 @@
} else {
Chunk chunk = this.getChunkAt(blockposition);
Block block = iblockdata.getBlock();
@@ -179,15 +179,12 @@
return false;
} else {
IBlockData iblockdata2 = this.getBlockState(blockposition);
@@ -225,6 +348,7 @@
this.getProfiler().pop();
}
+ /*
if (iblockdata2 == iblockdata) {
if (iblockdata1 != iblockdata2) {
this.setBlocksDirty(blockposition, iblockdata1, iblockdata2);
@@ -251,12 +375,69 @@
@@ -244,12 +368,69 @@
this.onBlockStateChange(blockposition, iblockdata1, iblockdata2);
}
@@ -215,7 +212,7 @@
+ this.setBlocksDirty(blockposition, iblockdata1, iblockdata2);
+ }
+
+ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (this.isClientSide || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(PlayerChunk.State.TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement
+ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (this.isClientSide || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement
+ this.sendBlockUpdated(blockposition, iblockdata1, iblockdata, i);
+ }
+
@@ -257,7 +254,7 @@
public void onBlockStateChange(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {}
@Override
@@ -342,6 +523,14 @@
@@ -335,6 +516,14 @@
@Override
public IBlockData getBlockState(BlockPosition blockposition) {
@@ -272,7 +269,7 @@
if (this.isOutsideBuildHeight(blockposition)) {
return Blocks.VOID_AIR.defaultBlockState();
} else {
@@ -533,6 +722,16 @@
@@ -526,6 +715,16 @@
@Nullable
@Override
public TileEntity getBlockEntity(BlockPosition blockposition) {
@@ -289,7 +286,7 @@
return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, Chunk.EnumTileEntityState.IMMEDIATE));
}
@@ -540,6 +739,12 @@
@@ -533,6 +732,12 @@
BlockPosition blockposition = tileentity.getBlockPos();
if (!this.isOutsideBuildHeight(blockposition)) {
@@ -302,7 +299,7 @@
this.getChunkAt(blockposition).addAndRegisterBlockEntity(tileentity);
}
}
@@ -670,7 +875,7 @@
@@ -663,7 +868,7 @@
for (int k = 0; k < j; ++k) {
EntityComplexPart entitycomplexpart = aentitycomplexpart[k];

View File

@@ -56,7 +56,7 @@
resetTilt(iblockdata, worldserver, blockposition);
}
@@ -210,8 +228,10 @@
return entity.isOnGround() && entity.position().y > (double) ((float) blockposition.getY() + 0.6875F);
return entity.onGround() && entity.position().y > (double) ((float) blockposition.getY() + 0.6875F);
}
- private void setTiltAndScheduleTick(IBlockData iblockdata, World world, BlockPosition blockposition, Tilt tilt, @Nullable SoundEffect soundeffect) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/Block.java
+++ b/net/minecraft/world/level/block/Block.java
@@ -354,7 +354,13 @@
@@ -342,7 +342,13 @@
EntityItem entityitem = (EntityItem) supplier.get();
entityitem.setDefaultPickUpDelay();
@@ -15,7 +15,7 @@
}
}
@@ -380,7 +386,7 @@
@@ -368,7 +374,7 @@
public void playerDestroy(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, @Nullable TileEntity tileentity, ItemStack itemstack) {
entityhuman.awardStat(StatisticList.BLOCK_MINED.get(this));
@@ -24,7 +24,7 @@
dropResources(iblockdata, world, blockposition, tileentity, entityhuman, itemstack);
}
@@ -516,16 +522,24 @@
@@ -504,16 +510,24 @@
return this.builtInRegistryHolder;
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockBed.java
+++ b/net/minecraft/world/level/block/BlockBed.java
@@ -85,7 +85,8 @@
@@ -84,7 +84,8 @@
}
}
@@ -10,7 +10,7 @@
world.removeBlock(blockposition, false);
BlockPosition blockposition1 = blockposition.relative(((EnumDirection) iblockdata.getValue(BlockBed.FACING)).getOpposite());
@@ -104,7 +105,16 @@
@@ -103,7 +104,16 @@
return EnumInteractionResult.SUCCESS;
} else {
@@ -27,7 +27,7 @@
if (entityhuman_enumbedresult.getMessage() != null) {
entityhuman.displayClientMessage(entityhuman_enumbedresult.getMessage(), true);
}
@@ -115,8 +125,29 @@
@@ -114,8 +124,29 @@
}
}
@@ -58,7 +58,7 @@
}
private boolean kickVillagerOutOfBed(World world, BlockPosition blockposition) {
@@ -320,6 +351,11 @@
@@ -314,6 +345,11 @@
BlockPosition blockposition1 = blockposition.relative((EnumDirection) iblockdata.getValue(BlockBed.FACING));
world.setBlock(blockposition1, (IBlockData) iblockdata.setValue(BlockBed.PART, BlockPropertyBedPart.HEAD), 3);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockBell.java
+++ b/net/minecraft/world/level/block/BlockBell.java
@@ -137,6 +137,11 @@
@@ -136,6 +136,11 @@
if (enumdirection == null) {
enumdirection = (EnumDirection) world.getBlockState(blockposition).getValue(BlockBell.FACING);
}
@@ -12,7 +12,7 @@
((TileEntityBell) tileentity).onHit(enumdirection);
world.playSound((EntityHuman) null, blockposition, SoundEffects.BELL_BLOCK, SoundCategory.BLOCKS, 2.0F, 1.0F);
@@ -268,4 +273,16 @@
@@ -262,4 +267,16 @@
public boolean isPathfindable(IBlockData iblockdata, IBlockAccess iblockaccess, BlockPosition blockposition, PathMode pathmode) {
return false;
}

View File

@@ -18,7 +18,7 @@
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockCactus.AGE, 0);
worldserver.setBlock(blockposition, iblockdata1, 4);
@@ -114,7 +116,9 @@
@@ -112,7 +114,9 @@
@Override
public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {

View File

@@ -13,7 +13,7 @@
public class BlockComposter extends Block implements IInventoryHolder {
public static final int READY = 8;
@@ -246,7 +252,14 @@
@@ -248,7 +254,14 @@
int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL);
if (i < 7 && BlockComposter.COMPOSTABLES.containsKey(itemstack.getItem())) {
@@ -29,7 +29,7 @@
itemstack.shrink(1);
return iblockdata1;
@@ -256,6 +269,14 @@
@@ -258,6 +271,14 @@
}
public static IBlockData extractProduce(Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) {
@@ -44,7 +44,7 @@
if (!world.isClientSide) {
Vec3D vec3d = Vec3D.atLowerCornerWithOffset(blockposition, 0.5D, 1.01D, 0.5D).offsetRandom(world.random, 0.7F);
EntityItem entityitem = new EntityItem(world, vec3d.x(), vec3d.y(), vec3d.z(), new ItemStack(Items.BONE_MEAL));
@@ -279,10 +300,16 @@
@@ -281,10 +302,16 @@
}
static IBlockData addItem(@Nullable Entity entity, IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) {
@@ -62,7 +62,7 @@
return iblockdata;
} else {
int j = i + 1;
@@ -331,7 +358,8 @@
@@ -333,7 +360,8 @@
public IWorldInventory getContainer(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL);
@@ -72,7 +72,7 @@
}
public static class ContainerOutput extends InventorySubcontainer implements IWorldInventory {
@@ -346,6 +374,7 @@
@@ -348,6 +376,7 @@
this.state = iblockdata;
this.level = generatoraccess;
this.pos = blockposition;
@@ -80,7 +80,7 @@
}
@Override
@@ -370,8 +399,15 @@
@@ -372,8 +401,15 @@
@Override
public void setChanged() {
@@ -98,7 +98,7 @@
}
}
@@ -384,6 +420,7 @@
@@ -386,6 +422,7 @@
public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
super(1);
@@ -106,7 +106,7 @@
this.state = iblockdata;
this.level = generatoraccess;
this.pos = blockposition;
@@ -426,8 +463,9 @@
@@ -428,8 +465,9 @@
public static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockDiodeAbstract.java
+++ b/net/minecraft/world/level/block/BlockDiodeAbstract.java
@@ -19,6 +19,8 @@
@@ -20,6 +20,8 @@
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import net.minecraft.world.ticks.TickListPriority;
@@ -9,7 +9,7 @@
public abstract class BlockDiodeAbstract extends BlockFacingHorizontal {
protected static final VoxelShape SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D);
@@ -45,8 +47,18 @@
@@ -46,8 +48,18 @@
boolean flag1 = this.shouldTurnOn(worldserver, blockposition, iblockdata);
if (flag && !flag1) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockDispenser.java
+++ b/net/minecraft/world/level/block/BlockDispenser.java
@@ -47,6 +47,7 @@
@@ -46,6 +46,7 @@
object2objectopenhashmap.defaultReturnValue(new DispenseBehaviorItem());
});
private static final int TRIGGER_DURATION = 4;
@@ -8,7 +8,7 @@
public static void registerBehavior(IMaterial imaterial, IDispenseBehavior idispensebehavior) {
BlockDispenser.DISPENSER_REGISTRY.put(imaterial.asItem(), idispensebehavior);
@@ -90,6 +91,7 @@
@@ -89,6 +90,7 @@
IDispenseBehavior idispensebehavior = this.getDispenseMethod(itemstack);
if (idispensebehavior != IDispenseBehavior.NOOP) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockDoor.java
+++ b/net/minecraft/world/level/block/BlockDoor.java
@@ -35,6 +35,8 @@
@@ -33,6 +33,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -9,7 +9,7 @@
public class BlockDoor extends Block {
public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
@@ -187,9 +189,24 @@
@@ -189,9 +191,24 @@
@Override
public void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockIce.java
+++ b/net/minecraft/world/level/block/BlockIce.java
@@ -49,6 +49,11 @@
@@ -51,6 +51,11 @@
}
protected void melt(IBlockData iblockdata, World world, BlockPosition blockposition) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockLeaves.java
+++ b/net/minecraft/world/level/block/BlockLeaves.java
@@ -23,6 +23,8 @@
@@ -24,6 +24,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapes;
@@ -9,7 +9,7 @@
public class BlockLeaves extends Block implements IBlockWaterlogged {
public static final int DECAY_DISTANCE = 7;
@@ -49,6 +51,14 @@
@@ -50,6 +52,14 @@
@Override
public void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) {
if (this.decaying(iblockdata)) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockMagma.java
+++ b/net/minecraft/world/level/block/BlockMagma.java
@@ -28,7 +28,9 @@
@@ -23,7 +23,9 @@
@Override
public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
if (!entity.isSteppingCarefully() && entity instanceof EntityLiving && !EnchantmentManager.hasFrostWalker((EntityLiving) entity)) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockNote.java
+++ b/net/minecraft/world/level/block/BlockNote.java
@@ -79,6 +79,7 @@
@@ -75,6 +75,7 @@
if (flag1 != (Boolean) iblockdata.getValue(BlockNote.POWERED)) {
if (flag1) {
this.playNote((Entity) null, iblockdata, world, blockposition);
@@ -8,10 +8,10 @@
}
world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockNote.POWERED, flag1), 3);
@@ -88,6 +89,12 @@
@@ -84,6 +85,12 @@
private void playNote(@Nullable Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) {
if (!((BlockPropertyInstrument) iblockdata.getValue(BlockNote.INSTRUMENT)).requiresAirAbove() || world.getBlockState(blockposition.above()).isAir()) {
if (((BlockPropertyInstrument) iblockdata.getValue(BlockNote.INSTRUMENT)).worksAboveNoteBlock() || world.getBlockState(blockposition.above()).isAir()) {
+ // CraftBukkit start
+ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, blockposition, iblockdata.getValue(BlockNote.INSTRUMENT), iblockdata.getValue(BlockNote.NOTE));
+ if (event.isCancelled()) {

View File

@@ -29,3 +29,20 @@
if (i != j) {
IBlockData iblockdata1 = this.setSignalForState(iblockdata, j);
@@ -140,9 +155,15 @@
}
protected static int getEntityCount(World world, AxisAlignedBB axisalignedbb, Class<? extends Entity> oclass) {
+ // CraftBukkit start
+ return getEntities(world, axisalignedbb, oclass).size();
+ }
+
+ protected static <T extends Entity> java.util.List<T> getEntities(World world, AxisAlignedBB axisalignedbb, Class<T> oclass) {
+ // CraftBukkit end
return world.getEntitiesOfClass(oclass, axisalignedbb, IEntitySelector.NO_SPECTATORS.and((entity) -> {
return !entity.isIgnoringBlockTriggers();
- })).size();
+ })); // CraftBukkit
}
protected abstract int getSignalStrength(World world, BlockPosition blockposition);

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/level/block/BlockPressurePlateBinary.java
+++ b/net/minecraft/world/level/block/BlockPressurePlateBinary.java
@@ -14,6 +14,11 @@
@@ -11,6 +11,11 @@
import net.minecraft.world.level.block.state.properties.BlockSetType;
import net.minecraft.world.level.block.state.properties.BlockStateBoolean;
import net.minecraft.world.phys.AxisAlignedBB;
+// CraftBukkit start
+import net.minecraft.world.entity.player.EntityHuman;
@@ -12,30 +12,45 @@
public class BlockPressurePlateBinary extends BlockPressurePlateAbstract {
public static final BlockStateBoolean POWERED = BlockProperties.POWERED;
@@ -57,6 +62,26 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@@ -34,7 +39,7 @@
+ // CraftBukkit start - Call interact event when turning on a pressure plate
+ if (this.getSignalForState(world.getBlockState(blockposition)) == 0) {
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.plugin.PluginManager manager = world.getCraftServer().getPluginManager();
+ org.bukkit.event.Cancellable cancellable;
@Override
protected int getSignalStrength(World world, BlockPosition blockposition) {
- Class oclass;
+ Class<? extends Entity> oclass; // CraftBukkit
switch (this.sensitivity) {
case EVERYTHING:
@@ -49,7 +54,31 @@
Class oclass1 = oclass;
- return getEntityCount(world, BlockPressurePlateBinary.TOUCH_AABB.move(blockposition), oclass1) > 0 ? 15 : 0;
+ // CraftBukkit start - Call interact event when turning on a pressure plate
+ for (Entity entity : getEntities(world, BlockPressurePlateBinary.TOUCH_AABB.move(blockposition), oclass)) {
+ if (this.getSignalForState(world.getBlockState(blockposition)) == 0) {
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.plugin.PluginManager manager = world.getCraftServer().getPluginManager();
+ org.bukkit.event.Cancellable cancellable;
+
+ if (entity instanceof EntityHuman) {
+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
+ } else {
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ manager.callEvent((EntityInteractEvent) cancellable);
+ }
+
+ // We only want to block turning the plate on if all events are cancelled
+ if (cancellable.isCancelled()) {
+ continue;
+ }
+ if (entity instanceof EntityHuman) {
+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
+ } else {
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ manager.callEvent((EntityInteractEvent) cancellable);
+ }
+ // CraftBukkit end
+
if (!entity.isIgnoringBlockTriggers()) {
return 15;
}
+ // We only want to block turning the plate on if all events are cancelled
+ if (cancellable.isCancelled()) {
+ continue;
+ }
+ }
+
+ return 15;
+ }
+
+ return 0;
+ // CraftBukkit end
}
@Override

View File

@@ -12,19 +12,15 @@
public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
public static final BlockStateInteger POWER = BlockProperties.POWER;
@@ -24,7 +29,31 @@
@@ -24,7 +29,27 @@
@Override
protected int getSignalStrength(World world, BlockPosition blockposition) {
- int i = Math.min(world.getEntitiesOfClass(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition)).size(), this.maxWeight);
- int i = Math.min(getEntityCount(world, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition), Entity.class), this.maxWeight);
+ // CraftBukkit start
+ // int i = Math.min(world.getEntitiesOfClass(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition)).size(), this.maxWeight);
+ // int i = Math.min(getEntityCount(world, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition), Entity.class), this.maxWeight);
+ int i = 0;
+ java.util.Iterator iterator = world.getEntitiesOfClass(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition)).iterator();
+
+ while (iterator.hasNext()) {
+ Entity entity = (Entity) iterator.next();
+
+ for (Entity entity : getEntities(world, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition), Entity.class)) {
+ org.bukkit.event.Cancellable cancellable;
+
+ if (entity instanceof EntityHuman) {

View File

@@ -1,17 +1,17 @@
--- a/net/minecraft/world/level/block/BlockPumpkinCarved.java
+++ b/net/minecraft/world/level/block/BlockPumpkinCarved.java
@@ -27,6 +27,10 @@
@@ -23,6 +23,10 @@
import net.minecraft.world.level.block.state.predicate.BlockStatePredicate;
import net.minecraft.world.level.block.state.properties.BlockStateDirection;
import net.minecraft.world.level.material.Material;
+// CraftBukkit start
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+// CraftBukkit end
+
public class BlockPumpkinCarved extends BlockFacingHorizontal implements Equipable {
public class BlockPumpkinCarved extends BlockFacingHorizontal {
public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
@@ -83,9 +87,14 @@
@@ -79,9 +83,14 @@
}
private static void spawnGolemInWorld(World world, ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection, Entity entity, BlockPosition blockposition) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockSoil.java
+++ b/net/minecraft/world/level/block/BlockSoil.java
@@ -27,6 +27,11 @@
@@ -28,6 +28,11 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -12,13 +12,13 @@
public class BlockSoil extends Block {
public static final BlockStateInteger MOISTURE = BlockProperties.MOISTURE;
@@ -83,26 +88,49 @@
@@ -84,26 +89,49 @@
if (!isNearWater(worldserver, blockposition) && !worldserver.isRainingAt(blockposition.above())) {
if (i > 0) {
- worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockSoil.MOISTURE, i - 1), 2);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.setValue(BlockSoil.MOISTURE, i - 1), 2); // CraftBukkit
} else if (!isUnderCrops(worldserver, blockposition)) {
} else if (!shouldMaintainFarmland(worldserver, blockposition)) {
turnToDirt((Entity) null, iblockdata, worldserver, blockposition);
}
} else if (i < 7) {

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/level/block/BlockSponge.java
+++ b/net/minecraft/world/level/block/BlockSponge.java
@@ -13,6 +13,13 @@
@@ -9,6 +9,13 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.Material;
+// CraftBukkit start
+import java.util.List;
@@ -14,57 +14,63 @@
public class BlockSponge extends Block {
public static final int MAX_DEPTH = 6;
@@ -48,6 +55,7 @@
@@ -41,7 +48,8 @@
}
queue.add(new Tuple<>(blockposition, 0));
int i = 0;
private boolean removeWaterBreadthFirstSearch(World world, BlockPosition blockposition) {
- return BlockPosition.breadthFirstTraversal(blockposition, 6, 65, (blockposition1, consumer) -> {
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator
+ BlockPosition.breadthFirstTraversal(blockposition, 6, 65, (blockposition1, consumer) -> {
EnumDirection[] aenumdirection = BlockSponge.ALL_DIRECTIONS;
int i = aenumdirection.length;
while (!queue.isEmpty()) {
Tuple<BlockPosition, Integer> tuple = (Tuple) queue.poll();
@@ -59,27 +67,31 @@
for (int l = 0; l < k; ++l) {
EnumDirection enumdirection = aenumdirection[l];
BlockPosition blockposition2 = blockposition1.relative(enumdirection);
- IBlockData iblockdata = world.getBlockState(blockposition2);
- Fluid fluid = world.getFluidState(blockposition2);
@@ -55,8 +63,10 @@
if (blockposition1.equals(blockposition)) {
return true;
} else {
- IBlockData iblockdata = world.getBlockState(blockposition1);
- Fluid fluid = world.getFluidState(blockposition1);
+ // CraftBukkit start
+ IBlockData iblockdata = blockList.getBlockState(blockposition2);
+ Fluid fluid = blockList.getFluidState(blockposition2);
+ IBlockData iblockdata = blockList.getBlockState(blockposition1);
+ Fluid fluid = blockList.getFluidState(blockposition1);
+ // CraftBukkit end
Material material = iblockdata.getMaterial();
if (fluid.is(TagsFluid.WATER)) {
- if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).pickupBlock(world, blockposition2, iblockdata).isEmpty()) {
+ if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).pickupBlock(blockList, blockposition2, iblockdata).isEmpty()) { // CraftBukkit
++i;
if (j < 6) {
queue.add(new Tuple<>(blockposition2, j + 1));
if (!fluid.is(TagsFluid.WATER)) {
return false;
@@ -66,27 +76,64 @@
if (block instanceof IFluidSource) {
IFluidSource ifluidsource = (IFluidSource) block;
- if (!ifluidsource.pickupBlock(world, blockposition1, iblockdata).isEmpty()) {
+ if (!ifluidsource.pickupBlock(blockList, blockposition1, iblockdata).isEmpty()) { // CraftBukkit
return true;
}
} else if (iblockdata.getBlock() instanceof BlockFluids) {
- world.setBlock(blockposition2, Blocks.AIR.defaultBlockState(), 3);
+ blockList.setBlock(blockposition2, Blocks.AIR.defaultBlockState(), 3); // CraftBukkit
++i;
if (j < 6) {
queue.add(new Tuple<>(blockposition2, j + 1));
}
if (iblockdata.getBlock() instanceof BlockFluids) {
- world.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3);
+ blockList.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3); // CraftBukkit
} else {
if (!iblockdata.is(Blocks.KELP) && !iblockdata.is(Blocks.KELP_PLANT) && !iblockdata.is(Blocks.SEAGRASS) && !iblockdata.is(Blocks.TALL_SEAGRASS)) {
return false;
}
} else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
- TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition2) : null;
- TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition1) : null;
+ // CraftBukkit start
+ // TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition2) : null;
+ // TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition1) : null;
- dropResources(iblockdata, world, blockposition2, tileentity);
- world.setBlock(blockposition2, Blocks.AIR.defaultBlockState(), 3);
+ // dropResources(iblockdata, world, blockposition2, tileentity);
+ blockList.setBlock(blockposition2, Blocks.AIR.defaultBlockState(), 3);
- dropResources(iblockdata, world, blockposition1, tileentity);
- world.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3);
+ // dropResources(iblockdata, world, blockposition1, tileentity);
+ blockList.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3);
+ // CraftBukkit end
++i;
if (j < 6) {
queue.add(new Tuple<>(blockposition2, j + 1));
@@ -92,6 +104,39 @@
break;
}
return true;
}
}
}
- }) > 1;
+ });
+ // CraftBukkit start
+ List<CraftBlockState> blocks = blockList.getList(); // Is a clone
+ if (!blocks.isEmpty()) {
@@ -78,26 +84,27 @@
+ }
+
+ for (CraftBlockState block : blocks) {
+ BlockPosition blockposition2 = block.getPosition();
+ IBlockData iblockdata = world.getBlockState(blockposition2);
+ Fluid fluid = world.getFluidState(blockposition2);
+ Material material = iblockdata.getMaterial();
+ BlockPosition blockposition1 = block.getPosition();
+ IBlockData iblockdata = world.getBlockState(blockposition1);
+ Fluid fluid = world.getFluidState(blockposition1);
+
+ if (fluid.is(TagsFluid.WATER)) {
+ if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).pickupBlock(blockList, blockposition2, iblockdata).isEmpty()) {
+ if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).pickupBlock(blockList, blockposition1, iblockdata).isEmpty()) {
+ // NOP
+ } else if (iblockdata.getBlock() instanceof BlockFluids) {
+ // NOP
+ } else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
+ TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition2) : null;
+ } else if (iblockdata.is(Blocks.KELP) || iblockdata.is(Blocks.KELP_PLANT) || iblockdata.is(Blocks.SEAGRASS) || iblockdata.is(Blocks.TALL_SEAGRASS)) {
+ TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition1) : null;
+
+ dropResources(iblockdata, world, blockposition2, tileentity);
+ dropResources(iblockdata, world, blockposition1, tileentity);
+ }
+ }
+ world.setBlock(blockposition2, block.getHandle(), block.getFlag());
+ world.setBlock(blockposition1, block.getHandle(), block.getFlag());
+ }
+
+ return true;
+ }
+ return false;
+ // CraftBukkit end
return i > 0;
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockTrapdoor.java
+++ b/net/minecraft/world/level/block/BlockTrapdoor.java
@@ -30,6 +30,8 @@
@@ -29,6 +29,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -9,7 +9,7 @@
public class BlockTrapdoor extends BlockFacingHorizontal implements IBlockWaterlogged {
public static final BlockStateBoolean OPEN = BlockProperties.OPEN;
@@ -111,6 +113,19 @@
@@ -110,6 +112,19 @@
boolean flag1 = world.hasNeighborSignal(blockposition);
if (flag1 != (Boolean) iblockdata.getValue(BlockTrapdoor.POWERED)) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockWaterLily.java
+++ b/net/minecraft/world/level/block/BlockWaterLily.java
@@ -25,7 +25,7 @@
@@ -24,7 +24,7 @@
@Override
public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
super.entityInside(iblockdata, world, blockposition, entity);

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/level/block/BlockWitherSkull.java
+++ b/net/minecraft/world/level/block/BlockWitherSkull.java
@@ -26,6 +26,10 @@
import net.minecraft.world.level.block.state.predicate.MaterialPredicate;
import net.minecraft.world.level.material.Material;
@@ -24,6 +24,10 @@
import net.minecraft.world.level.block.state.pattern.ShapeDetectorBuilder;
import net.minecraft.world.level.block.state.predicate.BlockStatePredicate;
+// CraftBukkit start
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
@@ -11,7 +11,7 @@
public class BlockWitherSkull extends BlockSkull {
@Nullable
@@ -49,6 +53,7 @@
@@ -47,6 +51,7 @@
}
public static void checkSpawn(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) {
@@ -19,7 +19,7 @@
if (!world.isClientSide) {
IBlockData iblockdata = tileentityskull.getBlockState();
boolean flag = iblockdata.is(Blocks.WITHER_SKELETON_SKULL) || iblockdata.is(Blocks.WITHER_SKELETON_WALL_SKULL);
@@ -60,12 +65,18 @@
@@ -58,12 +63,18 @@
EntityWither entitywither = (EntityWither) EntityTypes.WITHER.create(world);
if (entitywither != null) {
@@ -39,7 +39,7 @@
Iterator iterator = world.getEntitiesOfClass(EntityPlayer.class, entitywither.getBoundingBox().inflate(50.0D)).iterator();
while (iterator.hasNext()) {
@@ -74,7 +85,7 @@
@@ -72,7 +83,7 @@
CriterionTriggers.SUMMONED_ENTITY.trigger(entityplayer, (Entity) entitywither);
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BuddingAmethystBlock.java
+++ b/net/minecraft/world/level/block/BuddingAmethystBlock.java
@@ -44,7 +44,7 @@
@@ -38,7 +38,7 @@
if (block != null) {
IBlockData iblockdata2 = (IBlockData) ((IBlockData) block.defaultBlockState().setValue(AmethystClusterBlock.FACING, enumdirection)).setValue(AmethystClusterBlock.WATERLOGGED, iblockdata1.getFluidState().getType() == FluidTypes.WATER);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/PointedDripstoneBlock.java
+++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java
@@ -44,6 +44,11 @@
@@ -42,6 +42,11 @@
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import net.minecraft.world.phys.shapes.VoxelShapes;
@@ -12,7 +12,7 @@
public class PointedDripstoneBlock extends Block implements Fallable, IBlockWaterlogged {
public static final BlockStateDirection TIP_DIRECTION = BlockProperties.VERTICAL_DIRECTION;
@@ -126,6 +131,11 @@
@@ -124,6 +129,11 @@
BlockPosition blockposition = movingobjectpositionblock.getBlockPos();
if (!world.isClientSide && iprojectile.mayInteract(world, blockposition) && iprojectile instanceof EntityThrownTrident && iprojectile.getDeltaMovement().length() > 0.6D) {
@@ -24,7 +24,7 @@
world.destroyBlock(blockposition, true);
}
@@ -134,7 +144,9 @@
@@ -132,7 +142,9 @@
@Override
public void fallOn(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, float f) {
if (iblockdata.getValue(PointedDripstoneBlock.TIP_DIRECTION) == EnumDirection.UP && iblockdata.getValue(PointedDripstoneBlock.THICKNESS) == DripstoneThickness.TIP) {
@@ -34,7 +34,7 @@
} else {
super.fallOn(world, iblockdata, blockposition, entity, f);
}
@@ -389,15 +401,15 @@
@@ -377,15 +389,15 @@
if (isUnmergedTipWithDirection(iblockdata, enumdirection.getOpposite())) {
createMergedTips(iblockdata, worldserver, blockposition1);
} else if (iblockdata.isAir() || iblockdata.is(Blocks.WATER)) {
@@ -53,7 +53,7 @@
}
private static void createMergedTips(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
@@ -412,8 +424,8 @@
@@ -400,8 +412,8 @@
blockposition1 = blockposition.below();
}
@@ -64,7 +64,7 @@
}
public static void spawnDripParticle(World world, BlockPosition blockposition, IBlockData iblockdata) {
@@ -446,7 +458,7 @@
@@ -434,7 +446,7 @@
return (BlockPosition) findBlockVertical(generatoraccess, blockposition, enumdirection.getAxisDirection(), bipredicate, (iblockdata1) -> {
return isTip(iblockdata1, flag);
@@ -73,7 +73,7 @@
}
}
@@ -562,7 +574,7 @@
@@ -550,7 +562,7 @@
return canDripThrough(world, blockposition1, iblockdata);
};
@@ -82,7 +82,7 @@
}
@Nullable
@@ -571,7 +583,7 @@
@@ -559,7 +571,7 @@
return canDripThrough(world, blockposition1, iblockdata);
};

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/SculkCatalystBlock.java
+++ b/net/minecraft/world/level/block/SculkCatalystBlock.java
@@ -86,9 +86,16 @@
@@ -61,9 +61,16 @@
@Override
public void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) {
super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack, flag);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/SculkSensorBlock.java
+++ b/net/minecraft/world/level/block/SculkSensorBlock.java
@@ -38,6 +38,11 @@
@@ -41,6 +41,11 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -11,8 +11,8 @@
+
public class SculkSensorBlock extends BlockTileEntity implements IBlockWaterlogged {
public static final int ACTIVE_TICKS = 40;
@@ -87,6 +92,18 @@
public static final int ACTIVE_TICKS = 30;
@@ -95,6 +100,18 @@
@Override
public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
if (!world.isClientSide() && canActivate(iblockdata) && entity.getType() != EntityTypes.WARDEN) {
@@ -31,7 +31,7 @@
TileEntity tileentity = world.getBlockEntity(blockposition);
if (tileentity instanceof SculkSensorBlockEntity) {
@@ -188,6 +205,15 @@
@@ -198,6 +215,15 @@
}
public static void deactivate(World world, BlockPosition blockposition, IBlockData iblockdata) {
@@ -45,12 +45,12 @@
+ }
+ // CraftBukkit end
world.setBlock(blockposition, (IBlockData) ((IBlockData) iblockdata.setValue(SculkSensorBlock.PHASE, SculkSensorPhase.COOLDOWN)).setValue(SculkSensorBlock.POWER, 0), 3);
world.scheduleTick(blockposition, iblockdata.getBlock(), 1);
if (!(Boolean) iblockdata.getValue(SculkSensorBlock.WATERLOGGED)) {
@@ -198,6 +224,15 @@
world.scheduleTick(blockposition, iblockdata.getBlock(), 10);
updateNeighbours(world, blockposition, iblockdata);
@@ -209,6 +235,15 @@
}
public static void activate(@Nullable Entity entity, World world, BlockPosition blockposition, IBlockData iblockdata, int i) {
public void activate(@Nullable Entity entity, World world, BlockPosition blockposition, IBlockData iblockdata, int i, int j) {
+ // CraftBukkit start
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(world, blockposition), iblockdata.getValue(SculkSensorBlock.POWER), i);
+ world.getCraftServer().getPluginManager().callEvent(eventRedstone);
@@ -61,9 +61,9 @@
+ i = eventRedstone.getNewCurrent();
+ // CraftBukkit end
world.setBlock(blockposition, (IBlockData) ((IBlockData) iblockdata.setValue(SculkSensorBlock.PHASE, SculkSensorPhase.ACTIVE)).setValue(SculkSensorBlock.POWER, i), 3);
world.scheduleTick(blockposition, iblockdata.getBlock(), 40);
updateNeighbours(world, blockposition);
@@ -260,9 +295,16 @@
world.scheduleTick(blockposition, iblockdata.getBlock(), this.getActiveTicks());
updateNeighbours(world, blockposition, iblockdata);
@@ -291,9 +326,16 @@
@Override
public void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) {
super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack, flag);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/SculkVeinBlock.java
+++ b/net/minecraft/world/level/block/SculkVeinBlock.java
@@ -103,10 +103,11 @@
@@ -101,10 +101,11 @@
@Override
public int attemptUseCharge(SculkSpreader.a sculkspreader_a, GeneratorAccess generatoraccess, BlockPosition blockposition, RandomSource randomsource, SculkSpreader sculkspreader, boolean flag) {
@@ -14,7 +14,7 @@
IBlockData iblockdata = generatoraccess.getBlockState(blockposition);
TagKey<Block> tagkey = sculkspreader.replaceableBlocks();
Iterator iterator = EnumDirection.allShuffled(randomsource).iterator();
@@ -121,7 +122,11 @@
@@ -119,7 +120,11 @@
if (iblockdata1.is(tagkey)) {
IBlockData iblockdata2 = Blocks.SCULK.defaultBlockState();

View File

@@ -55,7 +55,7 @@
public ChiseledBookShelfBlockEntity(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.CHISELED_BOOKSHELF, blockposition, iblockdata);
@@ -113,7 +155,7 @@
@@ -120,7 +162,7 @@
@Override
public int getMaxStackSize() {

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
@@ -86,7 +86,9 @@
@@ -35,7 +35,9 @@
}
public static void serverTick(World world, BlockPosition blockposition, IBlockData iblockdata, SculkCatalystBlockEntity sculkcatalystblockentity) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.sourceBlockOverride = sculkcatalystblockentity.getBlockPos(); // CraftBukkit - SPIGOT-7068: Add source block override, not the most elegant way but better than passing down a BlockPosition up to five methods deep.
sculkcatalystblockentity.sculkSpreader.updateCursors(world, blockposition, world.getRandom(), true);
sculkcatalystblockentity.catalystListener.getSculkSpreader().updateCursors(world, blockposition, world.getRandom(), true);
+ org.bukkit.craftbukkit.event.CraftEventFactory.sourceBlockOverride = null; // CraftBukkit
}

View File

@@ -1,16 +1,5 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBell.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBell.java
@@ -35,8 +35,8 @@
public boolean shaking;
public EnumDirection clickDirection;
private List<EntityLiving> nearbyEntities;
- private boolean resonating;
- private int resonationTicks;
+ public boolean resonating;
+ public int resonationTicks;
public TileEntityBell(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.BELL, blockposition, iblockdata);
@@ -120,7 +120,7 @@
EntityLiving entityliving = (EntityLiving) iterator.next();

View File

@@ -183,17 +183,18 @@
}
public static boolean isFuel(ItemStack itemstack) {
@@ -493,14 +591,20 @@
@@ -493,8 +591,8 @@
@Override
public void awardUsedRecipes(EntityHuman entityhuman) {}
public void awardUsedRecipes(EntityHuman entityhuman, List<ItemStack> list) {}
- public void awardUsedRecipesAndPopExperience(EntityPlayer entityplayer) {
- List<IRecipe<?>> list = this.getRecipesToAwardAndPopExperience(entityplayer.getLevel(), entityplayer.position());
- List<IRecipe<?>> list = this.getRecipesToAwardAndPopExperience(entityplayer.serverLevel(), entityplayer.position());
+ public void awardUsedRecipesAndPopExperience(EntityPlayer entityplayer, ItemStack itemstack, int amount) { // CraftBukkit
+ List<IRecipe<?>> list = this.getRecipesToAwardAndPopExperience(entityplayer.getLevel(), entityplayer.position(), this.worldPosition, entityplayer, itemstack, amount); // CraftBukkit
+ List<IRecipe<?>> list = this.getRecipesToAwardAndPopExperience(entityplayer.serverLevel(), entityplayer.position(), this.worldPosition, entityplayer, itemstack, amount); // CraftBukkit
entityplayer.awardRecipes(list);
this.recipesUsed.clear();
Iterator iterator = list.iterator();
@@ -511,6 +609,12 @@
}
public List<IRecipe<?>> getRecipesToAwardAndPopExperience(WorldServer worldserver, Vec3D vec3d) {
@@ -206,7 +207,7 @@
List<IRecipe<?>> list = Lists.newArrayList();
ObjectIterator objectiterator = this.recipesUsed.object2IntEntrySet().iterator();
@@ -509,14 +613,14 @@
@@ -519,14 +623,14 @@
worldserver.getRecipeManager().byKey((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> {
list.add(irecipe);
@@ -223,7 +224,7 @@
int j = MathHelper.floor((float) i * f);
float f1 = MathHelper.frac((float) i * f);
@@ -524,6 +628,17 @@
@@ -534,6 +638,17 @@
++j;
}

View File

@@ -151,7 +151,7 @@
boolean flag = false;
+ // CraftBukkit start
+ InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
+ entityitem.level.getCraftServer().getPluginManager().callEvent(event);
+ entityitem.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return false;
+ }

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityJukeBox.java
+++ b/net/minecraft/world/level/block/entity/TileEntityJukeBox.java
@@ -24,14 +24,57 @@
@@ -24,6 +24,13 @@
import net.minecraft.world.phys.Vec3D;
import net.minecraft.world.ticks.ContainerSingleItem;
@@ -14,14 +14,10 @@
public class TileEntityJukeBox extends TileEntity implements Clearable, ContainerSingleItem {
private static final int SONG_END_PADDING = 20;
private final NonNullList<ItemStack> items;
private int ticksSinceLastEvent;
- private long tickCount;
- private long recordStartedTick;
- private boolean isPlaying;
+ public long tickCount;
+ public long recordStartedTick;
+ public boolean isPlaying;
@@ -32,6 +39,42 @@
public long tickCount;
public long recordStartedTick;
public boolean isPlaying;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;

View File

@@ -1,67 +1,81 @@
--- a/net/minecraft/world/level/block/entity/TileEntitySign.java
+++ b/net/minecraft/world/level/block/entity/TileEntitySign.java
@@ -25,7 +25,7 @@
import net.minecraft.world.phys.Vec2F;
@@ -31,7 +31,17 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
-public class TileEntitySign extends TileEntity {
+// CraftBukkit start
+import net.minecraft.EnumChatFormat;
+import net.minecraft.nbt.NBTBase;
+import net.minecraft.server.level.EntityPlayer;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.util.CraftChatMessage;
+import org.bukkit.entity.Player;
+import org.bukkit.event.block.SignChangeEvent;
+// CraftBukkit end
+
+public class TileEntitySign extends TileEntity implements ICommandListener { // CraftBukkit - implements
public static final int LINES = 4;
private static final Logger LOGGER = LogUtils.getLogger();
private static final int MAX_TEXT_LINE_WIDTH = 90;
@@ -83,6 +83,12 @@
}
}
@@ -100,7 +110,7 @@
@Override
protected void saveAdditional(NBTTagCompound nbttagcompound) {
super.saveAdditional(nbttagcompound);
- DataResult dataresult = SignText.DIRECT_CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.frontText);
+ DataResult<NBTBase> dataresult = SignText.DIRECT_CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.frontText); // CraftBukkit - decompile error
Logger logger = TileEntitySign.LOGGER;
+ // CraftBukkit start
+ if (Boolean.getBoolean("convertLegacySigns")) {
+ nbttagcompound.putBoolean("Bukkit.isConverted", true);
+ }
+ // CraftBukkit end
+
nbttagcompound.putString("Color", this.color.getName());
nbttagcompound.putBoolean("GlowingText", this.hasGlowingText);
}
@@ -93,8 +99,24 @@
Objects.requireNonNull(logger);
@@ -119,7 +129,7 @@
@Override
public void load(NBTTagCompound nbttagcompound) {
super.load(nbttagcompound);
this.color = EnumColor.byName(nbttagcompound.getString("Color"), EnumColor.BLACK);
- DataResult dataresult;
+ DataResult<SignText> dataresult; // CraftBukkit - decompile error
Logger logger;
+ // CraftBukkit start - Add an option to convert signs correctly
+ // This is done with a flag instead of all the time because
+ // we have no way to tell whether a sign is from 1.7.10 or 1.8
+ boolean oldSign = Boolean.getBoolean("convertLegacySigns") && !nbttagcompound.getBoolean("Bukkit.isConverted");
+ // CraftBukkit end
+
for (int i = 0; i < 4; ++i) {
String s = nbttagcompound.getString(TileEntitySign.RAW_TEXT_FIELD_NAMES[i]);
+ // CraftBukkit start
+ if (s != null && s.length() > 2048) {
+ s = "\"\"";
+ }
+
+ if (oldSign) {
+ messages[i] = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(s)[0];
+ continue;
+ }
+ // CraftBukkit end
IChatBaseComponent ichatbasecomponent = this.loadLine(s);
this.messages[i] = ichatbasecomponent;
@@ -132,6 +154,10 @@
if (ichatmutablecomponent != null) {
return ichatmutablecomponent;
}
+ // CraftBukkit start
+ } catch (com.google.gson.JsonParseException jsonparseexception) {
+ return IChatBaseComponent.empty();
+ // CraftBukkit end
} catch (Exception exception) {
;
if (nbttagcompound.contains("front_text")) {
@@ -179,6 +189,7 @@
this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3);
} else {
TileEntitySign.LOGGER.warn("Player {} just tried to change non-editable sign", entityhuman.getName().getString());
+ ((EntityPlayer) entityhuman).connection.send(this.getUpdatePacket()); // CraftBukkit
}
@@ -240,11 +266,37 @@
return true;
}
@@ -198,6 +209,25 @@
} else {
signtext = signtext.setMessage(i, IChatBaseComponent.literal(filteredtext.raw()).setStyle(chatmodifier), IChatBaseComponent.literal(filteredtext.filteredOrEmpty()).setStyle(chatmodifier));
}
+
+ // CraftBukkit start
+ Player player = ((EntityPlayer) entityhuman).getBukkitEntity();
+ String[] lines = new String[4];
+
+ for (int j = 0; j < list.size(); ++j) {
+ lines[j] = CraftChatMessage.fromComponent(signtext.getMessage(j, entityhuman.isTextFilteringEnabled()));
+ }
+
+ SignChangeEvent event = new SignChangeEvent(CraftBlock.at(this.level, this.worldPosition), player, lines);
+ entityhuman.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ IChatBaseComponent[] components = org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines());
+ for (int j = 0; j < components.length; j++) {
+ signtext = signtext.setMessage(j, components[j]);
+ }
+ }
+ // CraftBukkit end
}
return signtext;
@@ -250,11 +280,37 @@
return flag1;
}
- private static CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition) {
+ // CraftBukkit start
+ @Override
+ public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) {}
@@ -85,23 +99,24 @@
+ public boolean shouldInformAdmins() {
+ return false;
+ }
+ // CraftBukkit end
+
public CommandListenerWrapper createCommandSourceStack(@Nullable EntityPlayer entityplayer) {
String s = entityplayer == null ? "Sign" : entityplayer.getName().getString();
Object object = entityplayer == null ? IChatBaseComponent.literal("Sign") : entityplayer.getDisplayName();
+ private CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition) {
+ // CraftBukkit end
String s = entityhuman == null ? "Sign" : entityhuman.getName().getString();
Object object = entityhuman == null ? IChatBaseComponent.literal("Sign") : entityhuman.getDisplayName();
- return new CommandListenerWrapper(ICommandListener.NULL, Vec3D.atCenterOf(this.worldPosition), Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getServer(), entityplayer);
- return new CommandListenerWrapper(ICommandListener.NULL, Vec3D.atCenterOf(blockposition), Vec2F.ZERO, (WorldServer) world, 2, s, (IChatBaseComponent) object, world.getServer(), entityhuman);
+ // CraftBukkit - this
+ return new CommandListenerWrapper(this, Vec3D.atCenterOf(this.worldPosition), Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getServer(), entityplayer);
+ return new CommandListenerWrapper(this, Vec3D.atCenterOf(blockposition), Vec2F.ZERO, (WorldServer) world, 2, s, (IChatBaseComponent) object, world.getServer(), entityhuman);
}
public EnumColor getColor() {
@@ -277,6 +329,6 @@
@Override
@@ -283,7 +339,7 @@
private void markUpdated() {
this.setChanged();
- this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3);
+ if (this.level != null) this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3); // CraftBukkit - skip notify if world is null (SPIGOT-5122)
}
}
public boolean isWaxed() {

View File

@@ -34,7 +34,7 @@
world.blockEvent(blockposition, this, b0, enumdirection.get3DDataValue());
}
@@ -316,6 +336,48 @@
@@ -317,6 +337,48 @@
IBlockData[] aiblockdata = new IBlockData[list.size() + list2.size()];
EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.getOpposite();
int j = 0;

View File

@@ -1,24 +1,24 @@
--- a/net/minecraft/world/level/chunk/Chunk.java
+++ b/net/minecraft/world/level/chunk/Chunk.java
@@ -77,7 +77,7 @@
@@ -75,7 +75,7 @@
};
private final Map<BlockPosition, Chunk.d> tickersInLevel;
public boolean loaded;
private boolean clientLightReady;
- public final World level;
+ public final WorldServer level; // CraftBukkit - type
@Nullable
private Supplier<PlayerChunk.State> fullStatus;
private Supplier<FullChunkStatus> fullStatus;
@Nullable
@@ -94,7 +94,7 @@
@@ -91,7 +91,7 @@
public Chunk(World world, ChunkCoordIntPair chunkcoordintpair, ChunkConverter chunkconverter, LevelChunkTicks<Block> levelchunkticks, LevelChunkTicks<FluidType> levelchunkticks1, long i, @Nullable ChunkSection[] achunksection, @Nullable Chunk.c chunk_c, @Nullable BlendingData blendingdata) {
super(chunkcoordintpair, chunkconverter, world, world.registryAccess().registryOrThrow(Registries.BIOME), i, achunksection, blendingdata);
this.tickersInLevel = Maps.newHashMap();
this.clientLightReady = false;
- this.level = world;
+ this.level = (WorldServer) world; // CraftBukkit - type
this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap();
HeightMap.Type[] aheightmap_type = HeightMap.Type.values();
int j = aheightmap_type.length;
@@ -112,6 +112,11 @@
@@ -109,6 +109,11 @@
this.fluidTicks = levelchunkticks1;
}
@@ -30,8 +30,8 @@
public Chunk(WorldServer worldserver, ProtoChunk protochunk, @Nullable Chunk.c chunk_c) {
this(worldserver, protochunk.getPos(), protochunk.getUpgradeData(), protochunk.unpackBlockTicks(), protochunk.unpackFluidTicks(), protochunk.getInhabitedTime(), protochunk.getSections(), chunk_c, protochunk.getBlendingData());
Iterator iterator = protochunk.getBlockEntities().values().iterator();
@@ -142,6 +147,10 @@
@@ -140,6 +145,10 @@
this.skyLightSources = protochunk.skyLightSources;
this.setLightCorrect(protochunk.isLightCorrect());
this.unsaved = true;
+ this.needsDecoration = true; // CraftBukkit
@@ -41,7 +41,7 @@
}
@Override
@@ -246,9 +255,16 @@
@@ -244,9 +253,16 @@
}
}
@@ -58,7 +58,7 @@
int i = blockposition.getY();
ChunkSection chunksection = this.getSection(this.getSectionIndex(i));
boolean flag1 = chunksection.hasOnlyAir();
@@ -287,7 +303,8 @@
@@ -295,7 +311,8 @@
if (!chunksection.getBlockState(j, k, l).is(block)) {
return null;
} else {
@@ -68,7 +68,7 @@
iblockdata.onPlace(this.level, blockposition, iblockdata1, flag);
}
@@ -332,7 +349,12 @@
@@ -340,7 +357,12 @@
@Nullable
public TileEntity getBlockEntity(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) {
@@ -82,7 +82,7 @@
if (tileentity == null) {
NBTTagCompound nbttagcompound = (NBTTagCompound) this.pendingBlockEntities.remove(blockposition);
@@ -410,6 +432,13 @@
@@ -418,6 +440,13 @@
tileentity1.setRemoved();
}
@@ -96,7 +96,7 @@
}
}
@@ -439,6 +468,12 @@
@@ -447,6 +476,12 @@
if (this.isInLevel()) {
TileEntity tileentity = (TileEntity) this.blockEntities.remove(blockposition);
@@ -109,7 +109,7 @@
if (tileentity != null) {
World world = this.level;
@@ -491,6 +526,57 @@
@@ -500,6 +535,57 @@
}
@@ -167,7 +167,7 @@
public boolean isEmpty() {
return false;
}
@@ -694,7 +780,7 @@
@@ -697,7 +783,7 @@
private <T extends TileEntity> void updateBlockEntityTicker(T t0) {
IBlockData iblockdata = t0.getBlockState();
@@ -176,7 +176,7 @@
if (blockentityticker == null) {
this.removeBlockEntityTicker(t0.getBlockPos());
@@ -787,7 +873,7 @@
@@ -782,7 +868,7 @@
private boolean loggedInvalidBlockState;
a(TileEntity tileentity, BlockEntityTicker blockentityticker) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/chunk/ChunkSection.java
+++ b/net/minecraft/world/level/chunk/ChunkSection.java
@@ -25,9 +25,11 @@
@@ -23,9 +23,11 @@
private short tickingBlockCount;
private short tickingFluidCount;
private final DataPaletteBlock<IBlockData> states;
@@ -8,13 +8,13 @@
+ // CraftBukkit start - read/write
+ private DataPaletteBlock<Holder<BiomeBase>> biomes;
- public ChunkSection(int i, DataPaletteBlock<IBlockData> datapaletteblock, PalettedContainerRO<Holder<BiomeBase>> palettedcontainerro) {
+ public ChunkSection(int i, DataPaletteBlock<IBlockData> datapaletteblock, DataPaletteBlock<Holder<BiomeBase>> palettedcontainerro) {
- public ChunkSection(DataPaletteBlock<IBlockData> datapaletteblock, PalettedContainerRO<Holder<BiomeBase>> palettedcontainerro) {
+ public ChunkSection(DataPaletteBlock<IBlockData> datapaletteblock, DataPaletteBlock<Holder<BiomeBase>> palettedcontainerro) {
+ // CraftBukkit end
this.bottomBlockY = getBottomBlockY(i);
this.states = datapaletteblock;
this.biomes = palettedcontainerro;
@@ -200,6 +202,12 @@
this.recalcBlockCounts();
@@ -188,6 +190,12 @@
return (Holder) this.biomes.get(i, j, k);
}
@@ -24,6 +24,6 @@
+ }
+ // CraftBukkit end
+
public void fillBiomesFromNoise(BiomeResolver biomeresolver, Climate.Sampler climate_sampler, int i, int j) {
public void fillBiomesFromNoise(BiomeResolver biomeresolver, Climate.Sampler climate_sampler, int i, int j, int k) {
DataPaletteBlock<Holder<BiomeBase>> datapaletteblock = this.biomes.recreate();
int k = QuartPos.fromBlock(this.bottomBlockY());
boolean flag = true;

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/level/chunk/ChunkStatus.java
+++ b/net/minecraft/world/level/chunk/ChunkStatus.java
@@ -48,7 +48,7 @@
@@ -39,7 +39,7 @@
public static final ChunkStatus EMPTY = registerSimple("empty", (ChunkStatus) null, -1, ChunkStatus.PRE_FEATURES, ChunkStatus.Type.PROTOCHUNK, (chunkstatus, worldserver, chunkgenerator, list, ichunkaccess) -> {
});
public static final ChunkStatus STRUCTURE_STARTS = register("structure_starts", ChunkStatus.EMPTY, 0, ChunkStatus.PRE_FEATURES, ChunkStatus.Type.PROTOCHUNK, (chunkstatus, executor, worldserver, chunkgenerator, structuretemplatemanager, lightenginethreaded, function, list, ichunkaccess, flag) -> {
if (!ichunkaccess.getStatus().isOrAfter(chunkstatus)) {
- if (worldserver.getServer().getWorldData().worldGenOptions().generateStructures()) {
+ if (worldserver.serverLevelData.worldGenOptions().generateStructures()) { // CraftBukkit
chunkgenerator.createStructures(worldserver.registryAccess(), worldserver.getChunkSource().getGeneratorState(), worldserver.structureManager(), ichunkaccess, structuretemplatemanager);
}
public static final ChunkStatus STRUCTURE_STARTS = register("structure_starts", ChunkStatus.EMPTY, 0, false, ChunkStatus.PRE_FEATURES, ChunkStatus.Type.PROTOCHUNK, (chunkstatus, executor, worldserver, chunkgenerator, structuretemplatemanager, lightenginethreaded, function, list, ichunkaccess) -> {
- if (worldserver.getServer().getWorldData().worldGenOptions().generateStructures()) {
+ if (worldserver.serverLevelData.worldGenOptions().generateStructures()) { // CraftBukkit
chunkgenerator.createStructures(worldserver.registryAccess(), worldserver.getChunkSource().getGeneratorState(), worldserver.structureManager(), ichunkaccess, structuretemplatemanager);
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/chunk/IChunkAccess.java
+++ b/net/minecraft/world/level/chunk/IChunkAccess.java
@@ -77,6 +77,11 @@
@@ -82,6 +82,11 @@
protected final LevelHeightAccessor levelHeightAccessor;
protected final ChunkSection[] sections;
@@ -12,19 +12,19 @@
public IChunkAccess(ChunkCoordIntPair chunkcoordintpair, ChunkConverter chunkconverter, LevelHeightAccessor levelheightaccessor, IRegistry<BiomeBase> iregistry, long i, @Nullable ChunkSection[] achunksection, @Nullable BlendingData blendingdata) {
this.chunkPos = chunkcoordintpair;
this.upgradeData = chunkconverter;
@@ -94,7 +99,11 @@
@@ -100,7 +105,11 @@
}
replaceMissingSections(levelheightaccessor, iregistry, this.sections);
replaceMissingSections(iregistry, this.sections);
+ // CraftBukkit start
+ this.biomeRegistry = iregistry;
}
+ public final IRegistry<BiomeBase> biomeRegistry;
+ // CraftBukkit end
private static void replaceMissingSections(LevelHeightAccessor levelheightaccessor, IRegistry<BiomeBase> iregistry, ChunkSection[] achunksection) {
private static void replaceMissingSections(IRegistry<BiomeBase> iregistry, ChunkSection[] achunksection) {
for (int i = 0; i < achunksection.length; ++i) {
@@ -256,10 +265,11 @@
@@ -263,10 +272,11 @@
public void setUnsaved(boolean flag) {
this.unsaved = flag;
@@ -37,7 +37,7 @@
}
public abstract ChunkStatus getStatus();
@@ -392,6 +402,27 @@
@@ -442,6 +452,27 @@
}
}

View File

@@ -4,4 +4,4 @@
+// mc-dev import
package net.minecraft.world.level.chunk;
import javax.annotation.Nullable;
import java.util.Arrays;

View File

@@ -2,7 +2,7 @@
+++ b/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java
@@ -102,7 +102,7 @@
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
LightEngine lightengine = chunkproviderserver.getLightEngine();
LevelLightEngine levellightengine = chunkproviderserver.getLightEngine();
IRegistry<BiomeBase> iregistry = worldserver.registryAccess().registryOrThrow(Registries.BIOME);
- Codec<PalettedContainerRO<Holder<BiomeBase>>> codec = makeBiomeCodec(iregistry);
+ Codec<DataPaletteBlock<Holder<BiomeBase>>> codec = makeBiomeCodecRW(iregistry); // CraftBukkit - read/write
@@ -34,12 +34,12 @@
object = new DataPaletteBlock<>(iregistry.asHolderIdMap(), iregistry.getHolderOrThrow(Biomes.PLAINS), DataPaletteBlock.d.SECTION_BIOMES);
}
- ChunkSection chunksection = new ChunkSection(b0, datapaletteblock, (PalettedContainerRO) object);
+ ChunkSection chunksection = new ChunkSection(b0, datapaletteblock, (DataPaletteBlock) object); // CraftBukkit - read/write
- ChunkSection chunksection = new ChunkSection(datapaletteblock, (PalettedContainerRO) object);
+ ChunkSection chunksection = new ChunkSection(datapaletteblock, (DataPaletteBlock) object); // CraftBukkit - read/write
achunksection[k] = chunksection;
villageplace.checkConsistencyWithBlocks(chunkcoordintpair, chunksection);
@@ -174,7 +174,7 @@
SectionPosition sectionposition = SectionPosition.of(chunkcoordintpair, b0);
@@ -176,7 +176,7 @@
dataresult = BlendingData.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("blending_data")));
logger1 = ChunkRegionLoader.LOGGER;
Objects.requireNonNull(logger1);
@@ -48,7 +48,7 @@
} else {
blendingdata = null;
}
@@ -205,7 +205,7 @@
@@ -207,7 +207,7 @@
dataresult = BelowZeroRetrogen.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("below_zero_retrogen")));
logger1 = ChunkRegionLoader.LOGGER;
Objects.requireNonNull(logger1);
@@ -57,7 +57,7 @@
Objects.requireNonNull(protochunk);
optional.ifPresent(protochunk::setBelowZeroRetrogen);
@@ -234,6 +234,13 @@
@@ -221,6 +221,13 @@
}
}
@@ -71,7 +71,7 @@
((IChunkAccess) object1).setLightCorrect(flag);
NBTTagCompound nbttagcompound2 = nbttagcompound.getCompound("Heightmaps");
EnumSet<HeightMap.Type> enumset = EnumSet.noneOf(HeightMap.Type.class);
@@ -328,6 +335,12 @@
@@ -300,6 +307,12 @@
return DataPaletteBlock.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS));
}
@@ -84,16 +84,16 @@
public static NBTTagCompound write(WorldServer worldserver, IChunkAccess ichunkaccess) {
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
NBTTagCompound nbttagcompound = GameProfileSerializer.addCurrentDataVersion(new NBTTagCompound());
@@ -339,7 +352,7 @@
@@ -311,7 +324,7 @@
nbttagcompound.putLong("InhabitedTime", ichunkaccess.getInhabitedTime());
nbttagcompound.putString("Status", ichunkaccess.getStatus().getName());
nbttagcompound.putString("Status", BuiltInRegistries.CHUNK_STATUS.getKey(ichunkaccess.getStatus()).toString());
BlendingData blendingdata = ichunkaccess.getBlendingData();
- DataResult dataresult;
+ DataResult<NBTBase> dataresult; // CraftBukkit - decompile error
Logger logger;
if (blendingdata != null) {
@@ -386,7 +399,7 @@
@@ -358,7 +371,7 @@
if (flag1) {
ChunkSection chunksection = achunksection[j];
@@ -102,7 +102,7 @@
Logger logger1 = ChunkRegionLoader.LOGGER;
Objects.requireNonNull(logger1);
@@ -470,6 +483,11 @@
@@ -441,6 +454,11 @@
nbttagcompound.put("Heightmaps", nbttagcompound3);
nbttagcompound.put("structures", packStructureData(StructurePieceSerializationContext.fromLevel(worldserver), chunkcoordintpair, ichunkaccess.getAllStarts(), ichunkaccess.getAllReferences()));

View File

@@ -1,51 +0,0 @@
--- a/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java
+++ b/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java
@@ -29,6 +29,13 @@
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import net.minecraft.core.registries.BuiltInRegistries;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
+import org.bukkit.event.block.BlockReceiveGameEvent;
+// CraftBukkit end
+
public class VibrationListener implements GameEventListener {
@VisibleForTesting
@@ -98,7 +105,7 @@
}), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("event_delay").orElse(0).forGetter((vibrationlistener) -> {
return vibrationlistener.travelTimeInTicks;
})).apply(instance, (positionsource, integer, optional, vibrationselector, integer1) -> {
- return new VibrationListener(positionsource, integer, vibrationlistener_a, (VibrationInfo) optional.orElse((Object) null), vibrationselector, integer1);
+ return new VibrationListener(positionsource, integer, vibrationlistener_a, (VibrationInfo) optional.orElse(null), vibrationselector, integer1); // CraftBukkit - decompile error
});
});
}
@@ -140,7 +147,8 @@
--this.travelTimeInTicks;
if (this.travelTimeInTicks <= 0) {
this.travelTimeInTicks = 0;
- this.config.onSignalReceive(worldserver, this, BlockPosition.containing(this.currentVibration.pos()), this.currentVibration.gameEvent(), (Entity) this.currentVibration.getEntity(worldserver).orElse((Object) null), (Entity) this.currentVibration.getProjectileOwner(worldserver).orElse((Object) null), this.currentVibration.distance());
+ // CraftBukkit - decompile error
+ this.config.onSignalReceive(worldserver, this, BlockPosition.containing(this.currentVibration.pos()), this.currentVibration.gameEvent(), (Entity) this.currentVibration.getEntity(worldserver).orElse(null), (Entity) this.currentVibration.getProjectileOwner(worldserver).orElse(null), this.currentVibration.distance());
this.currentVibration = null;
}
}
@@ -172,7 +180,14 @@
} else {
Vec3D vec3d1 = (Vec3D) optional.get();
- if (!this.config.shouldListen(worldserver, this, BlockPosition.containing(vec3d), gameevent, gameevent_a)) {
+ // CraftBukkit start
+ boolean defaultCancel = !this.config.shouldListen(worldserver, this, BlockPosition.containing(vec3d), gameevent, gameevent_a);
+ Entity entity = gameevent_a.sourceEntity();
+ BlockReceiveGameEvent event = new BlockReceiveGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(gameevent))), CraftBlock.at(worldserver, BlockPosition.containing(vec3d1)), (entity == null) ? null : entity.getBukkitEntity());
+ event.setCancelled(defaultCancel);
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ // CraftBukkit end
return false;
} else if (isOccluded(worldserver, vec3d, vec3d1)) {
return false;

View File

@@ -0,0 +1,52 @@
--- a/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java
+++ b/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java
@@ -29,6 +29,13 @@
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import net.minecraft.core.registries.BuiltInRegistries;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
+import org.bukkit.event.block.BlockReceiveGameEvent;
+// CraftBukkit end
+
public interface VibrationSystem {
GameEvent[] RESONANCE_EVENTS = new GameEvent[]{GameEvent.RESONATE_1, GameEvent.RESONATE_2, GameEvent.RESONATE_3, GameEvent.RESONATE_4, GameEvent.RESONATE_5, GameEvent.RESONATE_6, GameEvent.RESONATE_7, GameEvent.RESONATE_8, GameEvent.RESONATE_9, GameEvent.RESONATE_10, GameEvent.RESONATE_11, GameEvent.RESONATE_12, GameEvent.RESONATE_13, GameEvent.RESONATE_14, GameEvent.RESONATE_15};
@@ -228,7 +235,8 @@
if (vibrationsystem_d.requiresAdjacentChunksToBeTicking() && !areAdjacentChunksTicking(worldserver, blockposition1)) {
return false;
} else {
- vibrationsystem_d.onReceiveVibration(worldserver, blockposition, vibrationinfo.gameEvent(), (Entity) vibrationinfo.getEntity(worldserver).orElse((Object) null), (Entity) vibrationinfo.getProjectileOwner(worldserver).orElse((Object) null), VibrationSystem.b.distanceBetweenInBlocks(blockposition, blockposition1));
+ // CraftBukkit - decompile error
+ vibrationsystem_d.onReceiveVibration(worldserver, blockposition, vibrationinfo.gameEvent(), (Entity) vibrationinfo.getEntity(worldserver).orElse(null), (Entity) vibrationinfo.getProjectileOwner(worldserver).orElse(null), VibrationSystem.b.distanceBetweenInBlocks(blockposition, blockposition1));
vibrationsystem_a.setCurrentVibration((VibrationInfo) null);
return true;
}
@@ -285,8 +293,14 @@
return false;
} else {
Vec3D vec3d1 = (Vec3D) optional.get();
-
- if (!vibrationsystem_d.canReceiveVibration(worldserver, BlockPosition.containing(vec3d), gameevent, gameevent_a)) {
+ // CraftBukkit start
+ boolean defaultCancel = !vibrationsystem_d.canReceiveVibration(worldserver, BlockPosition.containing(vec3d), gameevent, gameevent_a);
+ Entity entity = gameevent_a.sourceEntity();
+ BlockReceiveGameEvent event = new BlockReceiveGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(gameevent))), CraftBlock.at(worldserver, BlockPosition.containing(vec3d1)), (entity == null) ? null : entity.getBukkitEntity());
+ event.setCancelled(defaultCancel);
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ // CraftBukkit end
return false;
} else if (isOccluded(worldserver, vec3d, vec3d1)) {
return false;
@@ -339,7 +353,7 @@
return instance.group(VibrationInfo.CODEC.optionalFieldOf("event").forGetter((vibrationsystem_a) -> {
return Optional.ofNullable(vibrationsystem_a.currentVibration);
}), VibrationSelector.CODEC.fieldOf("selector").forGetter(VibrationSystem.a::getSelectionStrategy), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("event_delay").orElse(0).forGetter(VibrationSystem.a::getTravelTimeInTicks)).apply(instance, (optional, vibrationselector, integer) -> {
- return new VibrationSystem.a((VibrationInfo) optional.orElse((Object) null), vibrationselector, integer, true);
+ return new VibrationSystem.a((VibrationInfo) optional.orElse(null), vibrationselector, integer, true); // CraftBukkit - decompile error
});
});
public static final String NBT_TAG_KEY = "listener";

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java
+++ b/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java
@@ -76,7 +76,7 @@
@@ -75,7 +75,7 @@
if (entityphantom != null) {
entityphantom.moveTo(blockposition1, 0.0F, 0.0F);
groupdataentity = entityphantom.finalizeSpawn(worldserver, difficultydamagescaler, EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java
+++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java
@@ -51,6 +51,12 @@
@@ -52,6 +52,12 @@
import net.minecraft.world.phys.shapes.VoxelShapeBitSet;
import net.minecraft.world.phys.shapes.VoxelShapeDiscrete;
@@ -13,7 +13,7 @@
public class DefinedStructure {
public static final String PALETTE_TAG = "palette";
@@ -69,6 +75,11 @@
@@ -70,6 +76,11 @@
private BaseBlockPosition size;
private String author;
@@ -25,7 +25,7 @@
public DefinedStructure() {
this.size = BaseBlockPosition.ZERO;
this.author = "?";
@@ -142,7 +153,7 @@
@@ -143,7 +154,7 @@
}
private static List<DefinedStructure.BlockInfo> buildInfoList(List<DefinedStructure.BlockInfo> list, List<DefinedStructure.BlockInfo> list1, List<DefinedStructure.BlockInfo> list2) {
@@ -34,7 +34,7 @@
return definedstructure_blockinfo.pos.getY();
}).thenComparingInt((definedstructure_blockinfo) -> {
return definedstructure_blockinfo.pos.getX();
@@ -471,11 +482,13 @@
@@ -472,11 +483,13 @@
}
private static Optional<Entity> createEntityIgnoreException(WorldAccess worldaccess, NBTTagCompound nbttagcompound) {
@@ -52,7 +52,7 @@
}
public BaseBlockPosition getSize(EnumBlockRotation enumblockrotation) {
@@ -689,6 +702,11 @@
@@ -690,6 +703,11 @@
nbttagcompound.put("entities", nbttaglist3);
nbttagcompound.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ()));
@@ -64,7 +64,7 @@
return GameProfileSerializer.addCurrentDataVersion(nbttagcompound);
}
@@ -728,6 +746,12 @@
@@ -729,6 +747,12 @@
}
}
@@ -77,7 +77,7 @@
}
private void loadPalette(HolderGetter<Block> holdergetter, NBTTagList nbttaglist, NBTTagList nbttaglist1) {
@@ -867,7 +891,7 @@
@@ -858,7 +882,7 @@
public IBlockData stateFor(int i) {
IBlockData iblockdata = (IBlockData) this.ids.byId(i);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/material/FluidTypeFlowing.java
+++ b/net/minecraft/world/level/material/FluidTypeFlowing.java
@@ -30,6 +30,15 @@
@@ -31,6 +31,15 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapes;
@@ -16,7 +16,7 @@
public abstract class FluidTypeFlowing extends FluidType {
public static final BlockStateBoolean FALLING = BlockProperties.FALLING;
@@ -130,6 +139,15 @@
@@ -131,6 +140,15 @@
Fluid fluid1 = this.getNewLiquid(world, blockposition1, iblockdata1);
if (this.canSpreadTo(world, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) {
@@ -32,7 +32,7 @@
this.spreadTo(world, blockposition1, iblockdata1, EnumDirection.DOWN, fluid1);
if (this.sourceNeighborCount(world, blockposition) >= 3) {
this.spreadToSides(world, blockposition, fluid, iblockdata);
@@ -160,6 +178,15 @@
@@ -161,6 +179,15 @@
IBlockData iblockdata1 = world.getBlockState(blockposition1);
if (this.canSpreadTo(world, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) {
@@ -48,7 +48,7 @@
this.spreadTo(world, blockposition1, iblockdata1, enumdirection, fluid1);
}
}
@@ -438,12 +465,23 @@
@@ -431,12 +458,23 @@
if (fluid1.isEmpty()) {
fluid = fluid1;

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/level/storage/Convertable.java
+++ b/net/minecraft/world/level/storage/Convertable.java
@@ -68,6 +68,10 @@
import net.minecraft.world.level.levelgen.WorldDimensions;
@@ -74,6 +74,10 @@
import net.minecraft.world.level.validation.PathAllowList;
import org.slf4j.Logger;
+// CraftBukkit start
@@ -11,7 +11,7 @@
public class Convertable {
static final Logger LOGGER = LogUtils.getLogger();
@@ -114,7 +118,7 @@
@@ -160,7 +164,7 @@
}
private static WorldDataConfiguration readDataConfig(Dynamic<?> dynamic) {
@@ -20,7 +20,16 @@
Logger logger = Convertable.LOGGER;
Objects.requireNonNull(logger);
@@ -252,6 +256,7 @@
@@ -176,7 +180,7 @@
throw new LevelStorageException(IChatBaseComponent.translatable("selectWorld.load_folder_access"));
} else {
try {
- Stream stream = Files.list(this.baseDir);
+ Stream<Path> stream = Files.list(this.baseDir); // CraftBukkit - decompile error
Convertable.a convertable_a;
@@ -320,6 +324,7 @@
WorldDimensions.b worlddimensions_b = generatorsettings.dimensions().bake(iregistry);
Lifecycle lifecycle1 = worlddimensions_b.lifecycle().add(lifecycle);
WorldDataServer worlddataserver = WorldDataServer.parse(dynamic, datafixer, i, nbttagcompound2, worldsettings, levelversion, worlddimensions_b.specialWorldProperty(), generatorsettings.options(), lifecycle1);
@@ -28,17 +37,36 @@
return Pair.of(worlddataserver, worlddimensions_b);
};
@@ -333,9 +338,23 @@
@@ -415,27 +420,41 @@
return this.backupDir;
}
- public Convertable.ConversionSession validateAndCreateAccess(String s) throws IOException, ContentValidationException {
+ public Convertable.ConversionSession validateAndCreateAccess(String s, ResourceKey<WorldDimension> dimensionType) throws IOException, ContentValidationException { // CraftBukkit
Path path = this.getLevelPath(s);
List<ForbiddenSymlinkInfo> list = this.worldDirValidator.validateSave(path, true);
if (!list.isEmpty()) {
throw new ContentValidationException(path, list);
} else {
- return new Convertable.ConversionSession(s, path);
+ return new Convertable.ConversionSession(s, path, dimensionType); // CraftBukkit
}
}
- public Convertable.ConversionSession createAccess(String s) throws IOException {
- return new Convertable.ConversionSession(s);
+ public Convertable.ConversionSession createAccess(String s, ResourceKey<WorldDimension> dimensionType) throws IOException { // CraftBukkit
Path path = this.getLevelPath(s);
- return new Convertable.ConversionSession(s, path);
+ return new Convertable.ConversionSession(s, path, dimensionType); // CraftBukkit
}
public DirectoryValidator getWorldDirValidator() {
return this.worldDirValidator;
}
+ // CraftBukkit start
+ public Convertable.ConversionSession createAccess(String s, ResourceKey<WorldDimension> dimensionType) throws IOException {
+ return new Convertable.ConversionSession(s, dimensionType);
+ }
+
+ public static Path getStorageFolder(Path path, ResourceKey<WorldDimension> dimensionType) {
+ if (dimensionType == WorldDimension.OVERWORLD) {
+ return path;
@@ -49,26 +77,27 @@
+ } else {
+ return path.resolve("dimensions").resolve(dimensionType.location().getNamespace()).resolve(dimensionType.location().getPath());
+ }
}
+ }
+ // CraftBukkit end
+
public static record a(List<Convertable.b> levels) implements Iterable<Convertable.b> {
@@ -388,8 +407,12 @@
public boolean isEmpty() {
@@ -487,8 +506,12 @@
public final Convertable.b levelDirectory;
private final String levelId;
private final Map<SavedFile, Path> resources = Maps.newHashMap();
+ // CraftBukkit start
+ public final ResourceKey<WorldDimension> dimensionType;
- public ConversionSession(String s) throws IOException {
+ public ConversionSession(String s, ResourceKey<WorldDimension> dimensionType) throws IOException {
- ConversionSession(String s, Path path) throws IOException {
+ ConversionSession(String s, Path path, ResourceKey<WorldDimension> dimensionType) throws IOException {
+ this.dimensionType = dimensionType;
+ // CraftBukkit end
this.levelId = s;
this.levelDirectory = new Convertable.b(Convertable.this.baseDir.resolve(s));
this.lock = SessionLock.create(this.levelDirectory.path());
@@ -400,7 +423,7 @@
this.levelDirectory = new Convertable.b(path);
this.lock = SessionLock.create(path);
@@ -499,7 +522,7 @@
}
public Path getLevelPath(SavedFile savedfile) {
@@ -77,7 +106,7 @@
Convertable.b convertable_b = this.levelDirectory;
Objects.requireNonNull(this.levelDirectory);
@@ -408,7 +431,7 @@
@@ -507,7 +530,7 @@
}
public Path getDimensionPath(ResourceKey<World> resourcekey) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/storage/WorldDataServer.java
+++ b/net/minecraft/world/level/storage/WorldDataServer.java
@@ -43,6 +43,19 @@
@@ -45,6 +45,19 @@
import net.minecraft.world.level.timers.CustomFunctionCallbackTimers;
import org.slf4j.Logger;
@@ -20,9 +20,9 @@
public class WorldDataServer implements IWorldDataServer, SaveData {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -83,6 +96,20 @@
private final Set<String> knownServerBrands;
@@ -86,6 +99,20 @@
private boolean wasModded;
private final Set<String> removedFeatureFlags;
private final CustomFunctionCallbackTimerQueue<MinecraftServer> scheduledEvents;
+ // CraftBukkit start - Add world and pdc
+ public IRegistry<WorldDimension> customDimensions;
@@ -39,28 +39,27 @@
+ }
+ // CraftBukkit end
private WorldDataServer(@Nullable DataFixer datafixer, int i, @Nullable NBTTagCompound nbttagcompound, boolean flag, int j, int k, int l, float f, long i1, long j1, int k1, int l1, int i2, boolean flag1, int j2, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int k2, int l2, @Nullable UUID uuid, Set<String> set, CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, NBTTagCompound nbttagcompound2, WorldSettings worldsettings, WorldOptions worldoptions, WorldDataServer.a worlddataserver_a, Lifecycle lifecycle) {
private WorldDataServer(@Nullable DataFixer datafixer, int i, @Nullable NBTTagCompound nbttagcompound, boolean flag, int j, int k, int l, float f, long i1, long j1, int k1, int l1, int i2, boolean flag1, int j2, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int k2, int l2, @Nullable UUID uuid, Set<String> set, Set<String> set1, CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, EnderDragonBattle.a enderdragonbattle_a, WorldSettings worldsettings, WorldOptions worldoptions, WorldDataServer.a worlddataserver_a, Lifecycle lifecycle) {
this.fixerUpper = datafixer;
@@ -127,7 +154,8 @@
return dynamic.get("DimensionData").get("1").get("DragonFight").orElseEmptyMap();
})).convert(DynamicOpsNBT.INSTANCE).getValue();
- return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), dynamic.get("SpawnAngle").asFloat(0.0F), j, dynamic.get("DayTime").asLong(j), levelversion.levelDataVersion(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.read(dynamic, WorldBorder.DEFAULT_SETTINGS), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(UUIDUtil.CODEC).result().orElse((Object) null), (Set) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> {
+ // CraftBukkit - decompile error
+ return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), dynamic.get("SpawnAngle").asFloat(0.0F), j, dynamic.get("DayTime").asLong(j), levelversion.levelDataVersion(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.read(dynamic, WorldBorder.DEFAULT_SETTINGS), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(UUIDUtil.CODEC).result().orElse(null), (Set) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> {
@@ -144,7 +171,7 @@
WorldBorder.c worldborder_c = WorldBorder.c.read(dynamic, WorldBorder.DEFAULT_SETTINGS);
int k2 = dynamic.get("WanderingTraderSpawnDelay").asInt(0);
int l2 = dynamic.get("WanderingTraderSpawnChance").asInt(0);
- UUID uuid = (UUID) dynamic.get("WanderingTraderId").read(UUIDUtil.CODEC).result().orElse((Object) null);
+ UUID uuid = (UUID) dynamic.get("WanderingTraderId").read(UUIDUtil.CODEC).result().orElse(null); // CraftBukkit - decompile error
Set set = (Set) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> {
return dynamic1.asString().result().stream();
}).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new CustomFunctionCallbackTimerQueue<>(CustomFunctionCallbackTimers.SERVER_CALLBACKS, dynamic.get("ScheduledEvents").asStream()), (NBTTagCompound) dynamic.get("CustomBossEvents").orElseEmptyMap().getValue(), nbttagcompound1, worldsettings, worldoptions, worlddataserver_a, lifecycle);
}
@@ -147,7 +175,7 @@
}).collect(Collectors.toCollection(Sets::newLinkedHashSet));
@@ -153,7 +180,7 @@
}).collect(Collectors.toSet());
CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue = new CustomFunctionCallbackTimerQueue<>(CustomFunctionCallbackTimers.SERVER_CALLBACKS, dynamic.get("ScheduledEvents").asStream());
NBTTagCompound nbttagcompound1 = (NBTTagCompound) dynamic.get("CustomBossEvents").orElseEmptyMap().getValue();
- DataResult dataresult = dynamic.get("DragonFight").read(EnderDragonBattle.a.CODEC);
+ DataResult<EnderDragonBattle.a> dataresult = dynamic.get("DragonFight").read(EnderDragonBattle.a.CODEC); // CraftBukkit - decompile error
Logger logger = WorldDataServer.LOGGER;
private void setTagData(IRegistryCustom iregistrycustom, NBTTagCompound nbttagcompound, @Nullable NBTTagCompound nbttagcompound1) {
NBTTagList nbttaglist = new NBTTagList();
- Stream stream = this.knownServerBrands.stream().map(NBTTagString::valueOf);
+ Stream<NBTTagString> stream = this.knownServerBrands.stream().map(NBTTagString::valueOf); // CraftBukkit - decompile error
Objects.requireNonNull(nbttaglist);
stream.forEach(nbttaglist::add);
@@ -162,7 +190,7 @@
Objects.requireNonNull(logger);
@@ -189,7 +216,7 @@
nbttagcompound.put("Version", nbttagcompound2);
GameProfileSerializer.addCurrentDataVersion(nbttagcompound);
DynamicOps<NBTBase> dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) iregistrycustom);
@@ -69,7 +68,7 @@
Logger logger = WorldDataServer.LOGGER;
Objects.requireNonNull(logger);
@@ -214,6 +242,8 @@
@@ -241,11 +268,13 @@
nbttagcompound.putUUID("WanderingTraderId", this.wanderingTraderId);
}
@@ -77,8 +76,14 @@
+ world.getWorld().storeBukkitValues(nbttagcompound); // CraftBukkit - add pdc
}
@Override
@@ -331,6 +361,20 @@
private static NBTTagList stringCollectionToTag(Set<String> set) {
NBTTagList nbttaglist = new NBTTagList();
- Stream stream = set.stream().map(NBTTagString::valueOf);
+ Stream<NBTTagString> stream = set.stream().map(NBTTagString::valueOf); // CraftBukkit - decompile error
Objects.requireNonNull(nbttaglist);
stream.forEach(nbttaglist::add);
@@ -367,6 +396,20 @@
@Override
public void setThundering(boolean flag) {
@@ -99,7 +104,7 @@
this.thundering = flag;
}
@@ -351,6 +395,20 @@
@@ -387,6 +430,20 @@
@Override
public void setRaining(boolean flag) {
@@ -120,7 +125,7 @@
this.raining = flag;
}
@@ -417,6 +475,12 @@
@@ -453,6 +510,12 @@
@Override
public void setDifficulty(EnumDifficulty enumdifficulty) {
this.settings = this.settings.withDifficulty(enumdifficulty);
@@ -133,7 +138,7 @@
}
@Override
@@ -548,6 +612,14 @@
@@ -589,6 +652,14 @@
return this.settings.copy();
}

View File

@@ -0,0 +1,43 @@
--- a/net/minecraft/world/level/storage/loot/LootDataManager.java
+++ b/net/minecraft/world/level/storage/loot/LootDataManager.java
@@ -36,6 +36,7 @@
public static final LootDataId<LootTable> EMPTY_LOOT_TABLE_KEY = new LootDataId<>(LootDataType.TABLE, LootTables.EMPTY);
private Map<LootDataId<?>, ?> elements = Map.of();
private Multimap<LootDataType<?>, MinecraftKey> typeKeys = ImmutableMultimap.of();
+ public Map<?, MinecraftKey> lootTableToKey = ImmutableMap.of(); // CraftBukkit
public LootDataManager() {}
@@ -93,7 +94,7 @@
@Nullable
@Override
public <T> T getElement(LootDataId<T> lootdataid) {
- return map1.get(lootdataid);
+ return (T) map1.get(lootdataid); // CraftBukkit - decompile error
}
});
@@ -105,16 +106,21 @@
});
this.elements = map1;
this.typeKeys = com_google_common_collect_immutablemultimap_builder.build();
+ // CraftBukkit start - build a reversed registry map
+ ImmutableMap.Builder<Object, MinecraftKey> lootTableToKeyBuilder = ImmutableMap.builder();
+ this.elements.forEach((key, lootTable) -> lootTableToKeyBuilder.put((Object) lootTable, key.location()));
+ this.lootTableToKey = lootTableToKeyBuilder.build();
+ // CraftBukkit end
}
private static <T> void castAndValidate(LootCollector lootcollector, LootDataId<T> lootdataid, Object object) {
- lootdataid.type().runValidation(lootcollector, lootdataid, object);
+ lootdataid.type().runValidation(lootcollector, lootdataid, (T) object); // CraftBukkit - decompile error
}
@Nullable
@Override
public <T> T getElement(LootDataId<T> lootdataid) {
- return this.elements.get(lootdataid);
+ return (T) this.elements.get(lootdataid); // CraftBukkit - decompile error
}
public Collection<MinecraftKey> getKeys(LootDataType<?> lootdatatype) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/storage/loot/LootTable.java
+++ b/net/minecraft/world/level/storage/loot/LootTable.java
@@ -32,6 +32,13 @@
@@ -34,6 +34,13 @@
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
@@ -14,16 +14,17 @@
public class LootTable {
static final Logger LOGGER = LogUtils.getLogger();
@@ -119,8 +126,21 @@
@@ -145,9 +152,22 @@
}
public void fill(IInventory iinventory, LootTableInfo loottableinfo) {
public void fill(IInventory iinventory, LootParams lootparams, long i) {
+ // CraftBukkit start
+ this.fillInventory(iinventory, loottableinfo, false);
+ this.fillInventory(iinventory, lootparams, i, false);
+ }
+
+ public void fillInventory(IInventory iinventory, LootTableInfo loottableinfo, boolean plugin) {
+ public void fillInventory(IInventory iinventory, LootParams lootparams, long i, boolean plugin) {
+ // CraftBukkit end
LootTableInfo loottableinfo = (new LootTableInfo.Builder(lootparams)).withOptionalRandomSeed(i).create(this.randomSequence);
ObjectArrayList<ItemStack> objectarraylist = this.getRandomItems(loottableinfo);
RandomSource randomsource = loottableinfo.getRandom();
+ // CraftBukkit start

View File

@@ -1,31 +0,0 @@
--- a/net/minecraft/world/level/storage/loot/LootTableRegistry.java
+++ b/net/minecraft/world/level/storage/loot/LootTableRegistry.java
@@ -22,6 +22,7 @@
private static final Logger LOGGER = LogUtils.getLogger();
private static final Gson GSON = LootSerialization.createLootTableSerializer().create();
private Map<MinecraftKey, LootTable> tables = ImmutableMap.of();
+ public Map<LootTable, MinecraftKey> lootTableToKey = ImmutableMap.of(); // CraftBukkit
private final LootPredicateManager predicateManager;
public LootTableRegistry(LootPredicateManager lootpredicatemanager) {
@@ -57,7 +58,7 @@
LootPredicateManager lootpredicatemanager = this.predicateManager;
Objects.requireNonNull(this.predicateManager);
- Function function = lootpredicatemanager::get;
+ Function<MinecraftKey, net.minecraft.world.level.storage.loot.predicates.LootItemCondition> function = lootpredicatemanager::get; // CraftBukkit - decompile error
Objects.requireNonNull(immutablemap);
LootCollector lootcollector = new LootCollector(lootcontextparameterset, function, immutablemap::get);
@@ -69,6 +70,11 @@
LootTableRegistry.LOGGER.warn("Found validation problem in {}: {}", s, s1);
});
this.tables = immutablemap;
+ // CraftBukkit start - build a reversed registry map
+ ImmutableMap.Builder<LootTable, MinecraftKey> lootTableToKeyBuilder = ImmutableMap.builder();
+ this.tables.forEach((lootTable, key) -> lootTableToKeyBuilder.put(key, lootTable));
+ this.lootTableToKey = lootTableToKeyBuilder.build();
+ // CraftBukkit end
}
public static void validate(LootCollector lootcollector, MinecraftKey minecraftkey, LootTable loottable) {