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

@@ -36,7 +36,7 @@ import net.minecraft.world.level.chunk.storage.EntityStorage;
import net.minecraft.world.level.entity.PersistentEntitySectionManager;
import net.minecraft.world.level.levelgen.HeightMap;
import net.minecraft.world.level.levelgen.SeededRandom;
import net.minecraft.world.level.lighting.LightEngine;
import net.minecraft.world.level.lighting.LevelLightEngine;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.World;
@@ -314,7 +314,7 @@ public class CraftChunk implements Chunk {
data.put("block_states", ChunkRegionLoader.BLOCK_STATE_CODEC.encodeStart(DynamicOpsNBT.INSTANCE, cs[i].getStates()).get().left().get());
sectionBlockIDs[i] = ChunkRegionLoader.BLOCK_STATE_CODEC.parse(DynamicOpsNBT.INSTANCE, data.getCompound("block_states")).get().left().get();
LightEngine lightengine = worldServer.getLightEngine();
LevelLightEngine lightengine = worldServer.getLightEngine();
NibbleArray skyLightArray = lightengine.getLayerListener(EnumSkyBlock.SKY).getDataLayerData(SectionPosition.of(x, i, z));
if (skyLightArray == null) {
sectionSkyLights[i] = emptyLight;

View File

@@ -10,10 +10,12 @@ import net.minecraft.world.IInventory;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.level.storage.loot.LootParams;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.LootTableInfo;
import net.minecraft.world.level.storage.loot.parameters.LootContextParameter;
import net.minecraft.world.level.storage.loot.parameters.LootContextParameterSet;
import net.minecraft.world.level.storage.loot.parameters.LootContextParameterSets;
import net.minecraft.world.level.storage.loot.parameters.LootContextParameters;
import net.minecraft.world.phys.Vec3D;
import org.bukkit.Location;
@@ -45,7 +47,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
@Override
public Collection<ItemStack> populateLoot(Random random, LootContext context) {
Preconditions.checkArgument(context != null, "LootContext cannot be null");
LootTableInfo nmsContext = convertContext(context, random);
LootParams nmsContext = convertContext(context, random);
List<net.minecraft.world.item.ItemStack> nmsItems = handle.getRandomItems(nmsContext);
Collection<ItemStack> bukkit = new ArrayList<>(nmsItems.size());
@@ -63,12 +65,12 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
public void fillInventory(Inventory inventory, Random random, LootContext context) {
Preconditions.checkArgument(inventory != null, "Inventory cannot be null");
Preconditions.checkArgument(context != null, "LootContext cannot be null");
LootTableInfo nmsContext = convertContext(context, random);
LootParams nmsContext = convertContext(context, random);
CraftInventory craftInventory = (CraftInventory) inventory;
IInventory handle = craftInventory.getInventory();
// TODO: When events are added, call event here w/ custom reason?
getHandle().fillInventory(handle, nmsContext, true);
getHandle().fillInventory(handle, nmsContext, random.nextLong(), true);
}
@Override
@@ -76,15 +78,15 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
return key;
}
private LootTableInfo convertContext(LootContext context, Random random) {
private LootParams convertContext(LootContext context, Random random) {
Preconditions.checkArgument(context != null, "LootContext cannot be null");
Location loc = context.getLocation();
Preconditions.checkArgument(loc.getWorld() != null, "LootContext.getLocation#getWorld cannot be null");
WorldServer handle = ((CraftWorld) loc.getWorld()).getHandle();
LootTableInfo.Builder builder = new LootTableInfo.Builder(handle);
LootParams.a builder = new LootParams.a(handle);
if (random != null) {
builder = builder.withRandom(new RandomSourceWrapper(random));
// builder = builder.withRandom(new RandomSourceWrapper(random));
}
setMaybe(builder, LootContextParameters.ORIGIN, CraftLocation.toVec3D(loc));
if (getHandle() != LootTable.EMPTY) {
@@ -124,10 +126,10 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
}
nmsBuilder.optional(LootContextParameters.LOOTING_MOD);
return builder.create(nmsBuilder.build());
return builder.create(getHandle().getParamSet());
}
private <T> void setMaybe(LootTableInfo.Builder builder, LootContextParameter<T> param, T value) {
private <T> void setMaybe(LootParams.a builder, LootContextParameter<T> param, T value) {
if (getHandle().getParamSet().getRequired().contains(param) || getHandle().getParamSet().getAllowed().contains(param)) {
builder.withParameter(param, value);
}

View File

@@ -133,9 +133,8 @@ public enum CraftParticle {
SCULK_CHARGE("sculk_charge"),
SCULK_CHARGE_POP("sculk_charge_pop"),
SHRIEK("shriek"),
DRIPPING_CHERRY_LEAVES("dripping_cherry_leaves"),
FALLING_CHERRY_LEAVES("falling_cherry_leaves"),
LANDING_CHERRY_LEAVES("landing_cherry_leaves"),
CHERRY_LEAVES("cherry_leaves"),
EGG_CRACK("egg_crack"),
// ----- Legacy Separator -----
LEGACY_BLOCK_CRACK("block"),
LEGACY_BLOCK_DUST("block"),

View File

@@ -912,7 +912,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
final BlockPosition pos = BlockPosition.containing(x, y, z);
for (BlockFace dir : faces) {
IBlockData nmsBlock = getHandle().getBlockState(pos.relative(CraftBlock.blockFaceToNotch(dir)));
if (nmsBlock.getMaterial().isSolid() || BlockDiodeAbstract.isDiode(nmsBlock)) {
if (nmsBlock.isSolid() || BlockDiodeAbstract.isDiode(nmsBlock)) {
boolean taken = false;
AxisAlignedBB bb = (ItemFrame.class.isAssignableFrom(clazz))
? EntityItemFrame.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).getOpposite(), width, height)

View File

@@ -88,6 +88,7 @@ import net.minecraft.world.inventory.Container;
import net.minecraft.world.inventory.ContainerWorkbench;
import net.minecraft.world.inventory.InventoryCraftResult;
import net.minecraft.world.inventory.InventoryCrafting;
import net.minecraft.world.inventory.TransientCraftingContainer;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemWorldMap;
import net.minecraft.world.item.crafting.IRecipe;
@@ -113,7 +114,8 @@ import net.minecraft.world.level.storage.Convertable;
import net.minecraft.world.level.storage.SaveData;
import net.minecraft.world.level.storage.WorldDataServer;
import net.minecraft.world.level.storage.WorldNBTStorage;
import net.minecraft.world.level.storage.loot.LootTableRegistry;
import net.minecraft.world.level.storage.loot.LootDataManager;
import net.minecraft.world.level.validation.ContentValidationException;
import net.minecraft.world.phys.Vec3D;
import org.apache.commons.lang.Validate;
import org.bukkit.BanList;
@@ -169,7 +171,6 @@ import org.bukkit.craftbukkit.inventory.CraftMerchantCustom;
import org.bukkit.craftbukkit.inventory.CraftRecipe;
import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe;
import org.bukkit.craftbukkit.inventory.CraftSmithingRecipe;
import org.bukkit.craftbukkit.inventory.CraftSmithingTransformRecipe;
import org.bukkit.craftbukkit.inventory.CraftSmithingTrimRecipe;
import org.bukkit.craftbukkit.inventory.CraftSmokingRecipe;
@@ -227,7 +228,6 @@ import org.bukkit.inventory.Merchant;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.SmithingRecipe;
import org.bukkit.inventory.SmithingTransformRecipe;
import org.bukkit.inventory.SmithingTrimRecipe;
import org.bukkit.inventory.SmokingRecipe;
@@ -1061,8 +1061,8 @@ public final class CraftServer implements Server {
Convertable.ConversionSession worldSession;
try {
worldSession = Convertable.createDefault(getWorldContainer().toPath()).createAccess(name, actualDimension);
} catch (IOException ex) {
worldSession = Convertable.createDefault(getWorldContainer().toPath()).validateAndCreateAccess(name, actualDimension);
} catch (IOException | ContentValidationException ex) {
throw new RuntimeException(ex);
}
@@ -1123,7 +1123,7 @@ public final class CraftServer implements Server {
}
WorldServer internal = (WorldServer) new WorldServer(console, console.executor, worldSession, worlddata, worldKey, worlddimension, getServer().progressListenerFactory.create(11),
worlddata.isDebugWorld(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider);
worlddata.isDebugWorld(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, console.overworld().getRandomSequences(), creator.environment(), generator, biomeProvider);
if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) {
return null;
@@ -1271,8 +1271,6 @@ public final class CraftServer implements Server {
toAdd = CraftSmokingRecipe.fromBukkitRecipe((SmokingRecipe) recipe);
} else if (recipe instanceof StonecuttingRecipe) {
toAdd = CraftStonecuttingRecipe.fromBukkitRecipe((StonecuttingRecipe) recipe);
} else if (recipe instanceof SmithingRecipe) {
toAdd = CraftSmithingRecipe.fromBukkitRecipe((SmithingRecipe) recipe);
} else if (recipe instanceof SmithingTransformRecipe) {
toAdd = CraftSmithingTransformRecipe.fromBukkitRecipe((SmithingTransformRecipe) recipe);
} else if (recipe instanceof SmithingTrimRecipe) {
@@ -1332,7 +1330,7 @@ public final class CraftServer implements Server {
return net.minecraft.world.item.ItemStack.EMPTY;
}
};
InventoryCrafting inventoryCrafting = new InventoryCrafting(container, 3, 3);
InventoryCrafting inventoryCrafting = new TransientCraftingContainer(container, 3, 3);
return getNMSRecipe(craftingMatrix, inventoryCrafting, (CraftWorld) world).map(IRecipe::toBukkitRecipe).orElse(null);
}
@@ -2290,8 +2288,8 @@ public final class CraftServer implements Server {
public LootTable getLootTable(NamespacedKey key) {
Validate.notNull(key, "NamespacedKey cannot be null");
LootTableRegistry registry = getServer().getLootTables();
return new CraftLootTable(key, registry.get(CraftNamespacedKey.toMinecraft(key)));
LootDataManager registry = getServer().getLootData();
return new CraftLootTable(key, registry.getLootTable(CraftNamespacedKey.toMinecraft(key)));
}
@Override

View File

@@ -329,7 +329,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
List<EntityPlayer> playersInRange = playerChunk.playerProvider.getPlayers(playerChunk.getPos(), false);
if (playersInRange.isEmpty()) return;
ClientboundLevelChunkWithLightPacket refreshPacket = new ClientboundLevelChunkWithLightPacket(chunk, world.getLightEngine(), null, null, true);
ClientboundLevelChunkWithLightPacket refreshPacket = new ClientboundLevelChunkWithLightPacket(chunk, world.getLightEngine(), null, null);
for (EntityPlayer player : playersInRange) {
if (player.connection == null) continue;
@@ -643,7 +643,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
CraftPlayer cp = (CraftPlayer) p;
if (cp.getHandle().connection == null) continue;
cp.getHandle().connection.send(new PacketPlayOutUpdateTime(cp.getHandle().level.getGameTime(), cp.getHandle().getPlayerTime(), cp.getHandle().level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)));
cp.getHandle().connection.send(new PacketPlayOutUpdateTime(cp.getHandle().level().getGameTime(), cp.getHandle().getPlayerTime(), cp.getHandle().level().getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)));
}
}
@@ -1894,7 +1894,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public DragonBattle getEnderDragonBattle() {
return (getHandle().dragonFight() == null) ? null : new CraftDragonBattle(getHandle().dragonFight());
return (getHandle().getDragonFight() == null) ? null : new CraftDragonBattle(getHandle().getDragonFight());
}
@Override

View File

@@ -200,11 +200,11 @@ public class Main {
useConsole = false;
}
if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L);
Calendar deadline = Calendar.getInstance();
deadline.add(Calendar.DAY_OF_YEAR, -21);
deadline.add(Calendar.DAY_OF_YEAR, -3);
if (buildDate.before(deadline.getTime())) {
System.err.println("*** Error, this build is outdated ***");
System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***");

View File

@@ -460,7 +460,7 @@ public class CraftBlock implements Block {
@Override
public boolean isLiquid() {
return getNMS().getMaterial().isLiquid();
return getNMS().liquid();
}
@Override

View File

@@ -11,13 +11,14 @@ import javax.annotation.Nullable;
import net.minecraft.core.BlockPosition;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.level.GeneratorAccess;
import net.minecraft.world.level.block.entity.BrushableBlockEntity;
import net.minecraft.world.level.block.entity.CalibratedSculkSensorBlockEntity;
import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity;
import net.minecraft.world.level.block.entity.DecoratedPotBlockEntity;
import net.minecraft.world.level.block.entity.HangingSignBlockEntity;
import net.minecraft.world.level.block.entity.SculkCatalystBlockEntity;
import net.minecraft.world.level.block.entity.SculkSensorBlockEntity;
import net.minecraft.world.level.block.entity.SculkShriekerBlockEntity;
import net.minecraft.world.level.block.entity.SuspiciousSandBlockEntity;
import net.minecraft.world.level.block.entity.TileEntity;
import net.minecraft.world.level.block.entity.TileEntityBanner;
import net.minecraft.world.level.block.entity.TileEntityBarrel;
@@ -323,12 +324,14 @@ public final class CraftBlockStates {
register(Material.LECTERN, CraftLectern.class, CraftLectern::new, TileEntityLectern::new);
register(Material.MOVING_PISTON, CraftMovingPiston.class, CraftMovingPiston::new, TileEntityPiston::new);
register(Material.SCULK_CATALYST, CraftSculkCatalyst.class, CraftSculkCatalyst::new, SculkCatalystBlockEntity::new);
register(Material.CALIBRATED_SCULK_SENSOR, CraftCalibratedSculkSensor.class, CraftCalibratedSculkSensor::new, CalibratedSculkSensorBlockEntity::new);
register(Material.SCULK_SENSOR, CraftSculkSensor.class, CraftSculkSensor::new, SculkSensorBlockEntity::new);
register(Material.SCULK_SHRIEKER, CraftSculkShrieker.class, CraftSculkShrieker::new, SculkShriekerBlockEntity::new);
register(Material.SMOKER, CraftSmoker.class, CraftSmoker::new, TileEntitySmoker::new);
register(Material.SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new, TileEntityMobSpawner::new);
register(Material.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new, TileEntityStructure::new);
register(Material.SUSPICIOUS_SAND, CraftSuspiciousSand.class, CraftSuspiciousSand::new, SuspiciousSandBlockEntity::new);
register(Material.SUSPICIOUS_SAND, CraftSuspiciousSand.class, CraftSuspiciousSand::new, BrushableBlockEntity::new);
register(Material.SUSPICIOUS_GRAVEL, CraftBrushableBlock.class, CraftBrushableBlock::new, BrushableBlockEntity::new);
register(Material.TRAPPED_CHEST, CraftChest.class, CraftChest::new, TileEntityChestTrapped::new);
}

View File

@@ -0,0 +1,67 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.world.level.block.entity.BrushableBlockEntity;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.BrushableBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.loot.LootTable;
public class CraftBrushableBlock extends CraftBlockEntityState<BrushableBlockEntity> implements BrushableBlock {
public CraftBrushableBlock(World world, BrushableBlockEntity tileEntity) {
super(world, tileEntity);
}
@Override
public ItemStack getItem() {
return CraftItemStack.asBukkitCopy(getSnapshot().getItem());
}
@Override
public void setItem(ItemStack item) {
getSnapshot().item = CraftItemStack.asNMSCopy(item);
}
@Override
public void applyTo(BrushableBlockEntity lootable) {
super.applyTo(lootable);
if (this.getSnapshot().lootTable == null) {
lootable.setLootTable((MinecraftKey) null, 0L);
}
}
@Override
public LootTable getLootTable() {
if (getSnapshot().lootTable == null) {
return null;
}
MinecraftKey key = getSnapshot().lootTable;
return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key));
}
@Override
public void setLootTable(LootTable table) {
setLootTable(table, getSeed());
}
@Override
public long getSeed() {
return getSnapshot().lootTableSeed;
}
@Override
public void setSeed(long seed) {
setLootTable(getLootTable(), seed);
}
private void setLootTable(LootTable table, long seed) {
MinecraftKey key = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey());
getSnapshot().setLootTable(key, seed);
}
}

View File

@@ -0,0 +1,12 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.CalibratedSculkSensorBlockEntity;
import org.bukkit.World;
import org.bukkit.block.CalibratedSculkSensor;
public class CraftCalibratedSculkSensor extends CraftSculkSensor<CalibratedSculkSensorBlockEntity> implements CalibratedSculkSensor {
public CraftCalibratedSculkSensor(World world, CalibratedSculkSensorBlockEntity tileEntity) {
super(world, tileEntity);
}
}

View File

@@ -1,6 +1,5 @@
package org.bukkit.craftbukkit.block;
import com.google.common.base.Preconditions;
import java.util.List;
import java.util.stream.Collectors;
import net.minecraft.world.level.block.entity.DecoratedPotBlockEntity;
@@ -17,22 +16,6 @@ public class CraftDecoratedPot extends CraftBlockEntityState<DecoratedPotBlockEn
@Override
public List<Material> getShards() {
return getSnapshot().getShards().stream().map(CraftMagicNumbers::getMaterial).collect(Collectors.toUnmodifiableList());
}
@Override
public void addShard(Material material) {
Preconditions.checkArgument(material != null && material.isItem(), "Material must be an item");
getSnapshot().getShards().add(CraftMagicNumbers.getItem(material));
}
@Override
public void setShards(List<Material> shard) {
getSnapshot().getShards().clear();
for (Material material : shard) {
addShard(material);
}
return getSnapshot().getDecorations().sorted().map(CraftMagicNumbers::getMaterial).collect(Collectors.toUnmodifiableList());
}
}

View File

@@ -5,9 +5,9 @@ import net.minecraft.world.level.block.entity.SculkSensorBlockEntity;
import org.bukkit.World;
import org.bukkit.block.SculkSensor;
public class CraftSculkSensor extends CraftBlockEntityState<SculkSensorBlockEntity> implements SculkSensor {
public class CraftSculkSensor<T extends SculkSensorBlockEntity> extends CraftBlockEntityState<T> implements SculkSensor {
public CraftSculkSensor(World world, SculkSensorBlockEntity tileEntity) {
public CraftSculkSensor(World world, T tileEntity) {
super(world, tileEntity);
}

View File

@@ -17,10 +17,12 @@ import org.jetbrains.annotations.NotNull;
public class CraftSign<T extends TileEntitySign> extends CraftBlockEntityState<T> implements Sign {
private final CraftSignSide front;
private final CraftSignSide back;
public CraftSign(World world, T tileEntity) {
super(world, tileEntity);
this.front = new CraftSignSide(this.getSnapshot());
this.front = new CraftSignSide(this.getSnapshot().getFrontText());
this.back = new CraftSignSide(this.getSnapshot().getBackText());
}
@Override
@@ -40,12 +42,12 @@ public class CraftSign<T extends TileEntitySign> extends CraftBlockEntityState<T
@Override
public boolean isEditable() {
return getSnapshot().isEditable;
return !getSnapshot().isWaxed() && getSnapshot().playerWhoMayEdit != null;
}
@Override
public void setEditable(boolean editable) {
getSnapshot().isEditable = editable;
getSnapshot().setWaxed(!editable);
}
@Override
@@ -63,7 +65,14 @@ public class CraftSign<T extends TileEntitySign> extends CraftBlockEntityState<T
public SignSide getSide(Side side) {
Preconditions.checkArgument(side != null, "side == null");
return front;
switch (side) {
case FRONT:
return front;
case BACK:
return back;
default:
throw new IllegalArgumentException();
}
}
@Override
@@ -79,6 +88,7 @@ public class CraftSign<T extends TileEntitySign> extends CraftBlockEntityState<T
@Override
public void applyTo(T sign) {
front.applyLegacyStringToSignSide();
back.applyLegacyStringToSignSide();
super.applyTo(sign);
}
@@ -89,9 +99,8 @@ public class CraftSign<T extends TileEntitySign> extends CraftBlockEntityState<T
Preconditions.checkArgument(sign.getWorld() == player.getWorld(), "Sign must be in same world as Player");
TileEntitySign handle = ((CraftSign<?>) sign).getTileEntity();
handle.isEditable = true;
((CraftPlayer) player).getHandle().openTextEdit(handle);
((CraftPlayer) player).getHandle().openTextEdit(handle, true);
}
public static IChatBaseComponent[] sanitizeLines(String[] lines) {

View File

@@ -1,67 +1,12 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.world.level.block.entity.SuspiciousSandBlockEntity;
import org.bukkit.Bukkit;
import net.minecraft.world.level.block.entity.BrushableBlockEntity;
import org.bukkit.World;
import org.bukkit.block.SuspiciousSand;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.loot.LootTable;
public class CraftSuspiciousSand extends CraftBlockEntityState<SuspiciousSandBlockEntity> implements SuspiciousSand {
public class CraftSuspiciousSand extends CraftBrushableBlock implements SuspiciousSand {
public CraftSuspiciousSand(World world, SuspiciousSandBlockEntity tileEntity) {
public CraftSuspiciousSand(World world, BrushableBlockEntity tileEntity) {
super(world, tileEntity);
}
@Override
public ItemStack getItem() {
return CraftItemStack.asBukkitCopy(getSnapshot().getItem());
}
@Override
public void setItem(ItemStack item) {
getSnapshot().item = CraftItemStack.asNMSCopy(item);
}
@Override
public void applyTo(SuspiciousSandBlockEntity lootable) {
super.applyTo(lootable);
if (this.getSnapshot().lootTable == null) {
lootable.setLootTable((MinecraftKey) null, 0L);
}
}
@Override
public LootTable getLootTable() {
if (getSnapshot().lootTable == null) {
return null;
}
MinecraftKey key = getSnapshot().lootTable;
return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key));
}
@Override
public void setLootTable(LootTable table) {
setLootTable(table, getSeed());
}
@Override
public long getSeed() {
return getSnapshot().lootTableSeed;
}
@Override
public void setSeed(long seed) {
setLootTable(getLootTable(), seed);
}
private void setLootTable(LootTable table, long seed) {
MinecraftKey key = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey());
getSnapshot().setLootTable(key, seed);
}
}

View File

@@ -480,6 +480,8 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.world.level.block.BlockWeepingVines.class, org.bukkit.craftbukkit.block.impl.CraftWeepingVines::new);
register(net.minecraft.world.level.block.BlockWitherSkull.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkull::new);
register(net.minecraft.world.level.block.BlockWitherSkullWall.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkullWall::new);
register(net.minecraft.world.level.block.BrushableBlock.class, org.bukkit.craftbukkit.block.impl.CraftBrushable::new);
register(net.minecraft.world.level.block.CalibratedSculkSensorBlock.class, org.bukkit.craftbukkit.block.impl.CraftCalibratedSculkSensor::new);
register(net.minecraft.world.level.block.CandleBlock.class, org.bukkit.craftbukkit.block.impl.CraftCandle::new);
register(net.minecraft.world.level.block.CandleCakeBlock.class, org.bukkit.craftbukkit.block.impl.CraftCandleCake::new);
register(net.minecraft.world.level.block.CaveVinesBlock.class, org.bukkit.craftbukkit.block.impl.CraftCaveVines::new);
@@ -488,6 +490,7 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.world.level.block.CherryLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftCherryLeaves::new);
register(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, org.bukkit.craftbukkit.block.impl.CraftChiseledBookShelf::new);
register(net.minecraft.world.level.block.DecoratedPotBlock.class, org.bukkit.craftbukkit.block.impl.CraftDecoratedPot::new);
register(net.minecraft.world.level.block.EquipableCarvedPumpkinBlock.class, org.bukkit.craftbukkit.block.impl.CraftEquipableCarvedPumpkin::new);
register(net.minecraft.world.level.block.GlowLichenBlock.class, org.bukkit.craftbukkit.block.impl.CraftGlowLichen::new);
register(net.minecraft.world.level.block.HangingRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftHangingRoots::new);
register(net.minecraft.world.level.block.InfestedRotatedPillarBlock.class, org.bukkit.craftbukkit.block.impl.CraftInfestedRotatedPillar::new);
@@ -499,6 +502,7 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.world.level.block.MangroveRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangroveRoots::new);
register(net.minecraft.world.level.block.PiglinWallSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftPiglinWallSkull::new);
register(net.minecraft.world.level.block.PinkPetalsBlock.class, org.bukkit.craftbukkit.block.impl.CraftPinkPetals::new);
register(net.minecraft.world.level.block.PitcherCropBlock.class, org.bukkit.craftbukkit.block.impl.CraftPitcherCrop::new);
register(net.minecraft.world.level.block.PointedDripstoneBlock.class, org.bukkit.craftbukkit.block.impl.CraftPointedDripstone::new);
register(net.minecraft.world.level.block.PowderSnowCauldronBlock.class, org.bukkit.craftbukkit.block.impl.CraftPowderSnowCauldron::new);
register(net.minecraft.world.level.block.SculkCatalystBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkCatalyst::new);
@@ -506,7 +510,7 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.world.level.block.SculkShriekerBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkShrieker::new);
register(net.minecraft.world.level.block.SculkVeinBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkVein::new);
register(net.minecraft.world.level.block.SmallDripleafBlock.class, org.bukkit.craftbukkit.block.impl.CraftSmallDripleaf::new);
register(net.minecraft.world.level.block.SuspiciousSandBlock.class, org.bukkit.craftbukkit.block.impl.CraftSuspiciousSand::new);
register(net.minecraft.world.level.block.SnifferEggBlock.class, org.bukkit.craftbukkit.block.impl.CraftSnifferEgg::new);
register(net.minecraft.world.level.block.TallSeagrassBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallSeagrass::new);
register(net.minecraft.world.level.block.TorchflowerCropBlock.class, org.bukkit.craftbukkit.block.impl.CraftTorchflowerCrop::new);
register(net.minecraft.world.level.block.WallHangingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallHangingSign::new);

View File

@@ -0,0 +1,23 @@
package org.bukkit.craftbukkit.block.data;
import org.bukkit.block.data.Brushable;
public abstract class CraftBrushable extends CraftBlockData implements Brushable {
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger DUSTED = getInteger("dusted");
@Override
public int getDusted() {
return get(DUSTED);
}
@Override
public void setDusted(int dusted) {
set(DUSTED, dusted);
}
@Override
public int getMaximumDusted() {
return getMax(DUSTED);
}
}

View File

@@ -0,0 +1,23 @@
package org.bukkit.craftbukkit.block.data;
import org.bukkit.block.data.Hatchable;
public abstract class CraftHatchable extends CraftBlockData implements Hatchable {
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger HATCH = getInteger("hatch");
@Override
public int getHatch() {
return get(HATCH);
}
@Override
public void setHatch(int hatch) {
set(HATCH, hatch);
}
@Override
public int getMaximumHatch() {
return getMax(HATCH);
}
}

View File

@@ -1,9 +1,9 @@
package org.bukkit.craftbukkit.block.data.type;
import org.bukkit.block.data.type.SuspiciousSand;
import org.bukkit.block.data.Brushable;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftSuspiciousSand extends CraftBlockData implements SuspiciousSand {
public abstract class CraftBrushable extends CraftBlockData implements Brushable {
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger DUSTED = getInteger("dusted");

View File

@@ -6,7 +6,6 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftTurtleEgg extends CraftBlockData implements TurtleEgg {
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger EGGS = getInteger("eggs");
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger HATCH = getInteger("hatch");
@Override
public int getEggs() {
@@ -27,19 +26,4 @@ public abstract class CraftTurtleEgg extends CraftBlockData implements TurtleEgg
public int getMaximumEggs() {
return getMax(EGGS);
}
@Override
public int getHatch() {
return get(HATCH);
}
@Override
public void setHatch(int hatch) {
set(HATCH, hatch);
}
@Override
public int getMaximumHatch() {
return getMax(HATCH);
}
}

View File

@@ -3,19 +3,19 @@
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftSuspiciousSand extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.SuspiciousSand {
public final class CraftBrushable extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Brushable {
public CraftSuspiciousSand() {
public CraftBrushable() {
super();
}
public CraftSuspiciousSand(net.minecraft.world.level.block.state.IBlockData state) {
public CraftBrushable(net.minecraft.world.level.block.state.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftSuspiciousSand
// org.bukkit.craftbukkit.block.data.CraftBrushable
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger DUSTED = getInteger(net.minecraft.world.level.block.SuspiciousSandBlock.class, "dusted");
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger DUSTED = getInteger(net.minecraft.world.level.block.BrushableBlock.class, "dusted");
@Override
public int getDusted() {

View File

@@ -0,0 +1,81 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftCalibratedSculkSensor extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.CalibratedSculkSensor, org.bukkit.block.data.Directional, org.bukkit.block.data.type.SculkSensor, org.bukkit.block.data.AnaloguePowerable, org.bukkit.block.data.Waterlogged {
public CraftCalibratedSculkSensor() {
super();
}
public CraftCalibratedSculkSensor(net.minecraft.world.level.block.state.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> FACING = getEnum(net.minecraft.world.level.block.CalibratedSculkSensorBlock.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
// org.bukkit.craftbukkit.block.data.type.CraftSculkSensor
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> PHASE = getEnum(net.minecraft.world.level.block.CalibratedSculkSensorBlock.class, "sculk_sensor_phase");
@Override
public org.bukkit.block.data.type.SculkSensor.Phase getPhase() {
return get(PHASE, org.bukkit.block.data.type.SculkSensor.Phase.class);
}
@Override
public void setPhase(org.bukkit.block.data.type.SculkSensor.Phase phase) {
set(PHASE, phase);
}
// org.bukkit.craftbukkit.block.data.CraftAnaloguePowerable
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger POWER = getInteger(net.minecraft.world.level.block.CalibratedSculkSensorBlock.class, "power");
@Override
public int getPower() {
return get(POWER);
}
@Override
public void setPower(int power) {
set(POWER, power);
}
@Override
public int getMaximumPower() {
return getMax(POWER);
}
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.CalibratedSculkSensorBlock.class, "waterlogged");
@Override
public boolean isWaterlogged() {
return get(WATERLOGGED);
}
@Override
public void setWaterlogged(boolean waterlogged) {
set(WATERLOGGED, waterlogged);
}
}

View File

@@ -0,0 +1,34 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftEquipableCarvedPumpkin extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional {
public CraftEquipableCarvedPumpkin() {
super();
}
public CraftEquipableCarvedPumpkin(net.minecraft.world.level.block.state.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> FACING = getEnum(net.minecraft.world.level.block.EquipableCarvedPumpkinBlock.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
}

View File

@@ -0,0 +1,48 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftPitcherCrop extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.PitcherCrop, org.bukkit.block.data.Ageable, org.bukkit.block.data.Bisected {
public CraftPitcherCrop() {
super();
}
public CraftPitcherCrop(net.minecraft.world.level.block.state.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftAgeable
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger AGE = getInteger(net.minecraft.world.level.block.PitcherCropBlock.class, "age");
@Override
public int getAge() {
return get(AGE);
}
@Override
public void setAge(int age) {
set(AGE, age);
}
@Override
public int getMaximumAge() {
return getMax(AGE);
}
// org.bukkit.craftbukkit.block.data.CraftBisected
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> HALF = getEnum(net.minecraft.world.level.block.PitcherCropBlock.class, "half");
@Override
public org.bukkit.block.data.Bisected.Half getHalf() {
return get(HALF, org.bukkit.block.data.Bisected.Half.class);
}
@Override
public void setHalf(org.bukkit.block.data.Bisected.Half half) {
set(HALF, half);
}
}

View File

@@ -0,0 +1,34 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftSnifferEgg extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Hatchable {
public CraftSnifferEgg() {
super();
}
public CraftSnifferEgg(net.minecraft.world.level.block.state.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftHatchable
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger HATCH = getInteger(net.minecraft.world.level.block.SnifferEggBlock.class, "hatch");
@Override
public int getHatch() {
return get(HATCH);
}
@Override
public void setHatch(int hatch) {
set(HATCH, hatch);
}
@Override
public int getMaximumHatch() {
return getMax(HATCH);
}
}

View File

@@ -3,7 +3,7 @@
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftTurtleEgg extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.TurtleEgg {
public final class CraftTurtleEgg extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.TurtleEgg, org.bukkit.block.data.Hatchable {
public CraftTurtleEgg() {
super();
@@ -16,7 +16,6 @@ public final class CraftTurtleEgg extends org.bukkit.craftbukkit.block.data.Craf
// org.bukkit.craftbukkit.block.data.type.CraftTurtleEgg
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger EGGS = getInteger(net.minecraft.world.level.block.BlockTurtleEgg.class, "eggs");
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger HATCH = getInteger(net.minecraft.world.level.block.BlockTurtleEgg.class, "hatch");
@Override
public int getEggs() {
@@ -38,6 +37,10 @@ public final class CraftTurtleEgg extends org.bukkit.craftbukkit.block.data.Craf
return getMax(EGGS);
}
// org.bukkit.craftbukkit.block.data.CraftHatchable
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger HATCH = getInteger(net.minecraft.world.level.block.BlockTurtleEgg.class, "hatch");
@Override
public int getHatch() {
return get(HATCH);

View File

@@ -1,7 +1,8 @@
package org.bukkit.craftbukkit.block.sign;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.world.item.EnumColor;
import net.minecraft.world.level.block.entity.TileEntitySign;
import net.minecraft.world.level.block.entity.SignText;
import org.bukkit.DyeColor;
import org.bukkit.block.sign.SignSide;
import org.bukkit.craftbukkit.block.CraftSign;
@@ -14,9 +15,9 @@ public class CraftSignSide implements SignSide {
// Lazily initialized only if requested:
private String[] originalLines = null;
private String[] lines = null;
private final TileEntitySign signText;
private final SignText signText;
public CraftSignSide(TileEntitySign signText) {
public CraftSignSide(SignText signText) {
this.signText = signText;
}
@@ -25,8 +26,9 @@ public class CraftSignSide implements SignSide {
public String[] getLines() {
if (lines == null) {
// Lazy initialization:
lines = new String[signText.messages.length];
System.arraycopy(CraftSign.revertComponents(signText.messages), 0, lines, 0, lines.length);
IChatBaseComponent[] messages = signText.getMessages(false);
lines = new String[messages.length];
System.arraycopy(CraftSign.revertComponents(messages), 0, lines, 0, lines.length);
originalLines = new String[lines.length];
System.arraycopy(lines, 0, originalLines, 0, originalLines.length);
}

View File

@@ -489,7 +489,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
if (entity instanceof EntityArrow) {
return ((EntityArrow) entity).inGround;
}
return entity.isOnGround();
return entity.onGround();
}
@Override
@@ -499,7 +499,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@Override
public World getWorld() {
return entity.level.getWorld();
return entity.level().getWorld();
}
@Override
@@ -564,7 +564,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z) {
Preconditions.checkState(!entity.generation, "Cannot get nearby entities during world generation");
List<Entity> notchEntityList = entity.level.getEntities(entity, entity.getBoundingBox().inflate(x, y, z), Predicates.alwaysTrue());
List<Entity> notchEntityList = entity.level().getEntities(entity, entity.getBoundingBox().inflate(x, y, z), Predicates.alwaysTrue());
List<org.bukkit.entity.Entity> bukkitEntityList = new java.util.ArrayList<org.bukkit.entity.Entity>(notchEntityList.size());
for (Entity e : notchEntityList) {
@@ -768,7 +768,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
Preconditions.checkState(!entity.generation, "Cannot play effect during world generation");
if (type.getApplicable().isInstance(this)) {
this.getHandle().level.broadcastEntityEvent(getHandle(), type.getData());
this.getHandle().level().broadcastEntityEvent(getHandle(), type.getData());
}
}

View File

@@ -156,7 +156,7 @@ public class CraftFishHook extends CraftProjectile implements FishHook {
EntityFishingHook hook = getHandle();
if (this.biteChance == -1) {
if (hook.level.isRainingAt(BlockPosition.containing(hook.position()).offset(0, 1, 0))) {
if (hook.level().isRainingAt(BlockPosition.containing(hook.position()).offset(0, 1, 0))) {
return 1 / 300.0;
}
return 1 / 500.0;

View File

@@ -138,7 +138,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
Preconditions.checkArgument(location.getWorld().equals(getWorld()), "Cannot sleep across worlds");
BlockPosition blockposition = CraftLocation.toBlockPosition(location);
IBlockData iblockdata = getHandle().level.getBlockState(blockposition);
IBlockData iblockdata = getHandle().level().getBlockState(blockposition);
if (!(iblockdata.getBlock() instanceof BlockBed)) {
return false;
}
@@ -149,7 +149,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
// From BlockBed
iblockdata = iblockdata.setValue(BlockBed.OCCUPIED, true);
getHandle().level.setBlock(blockposition, iblockdata, 4);
getHandle().level().setBlock(blockposition, iblockdata, 4);
return true;
}
@@ -296,7 +296,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
if (iinventory instanceof TileEntity) {
TileEntity te = (TileEntity) iinventory;
if (!te.hasLevel()) {
te.setLevel(getHandle().level);
te.setLevel(getHandle().level());
}
}
}
@@ -341,7 +341,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
return null;
}
}
getHandle().openMenu(((BlockWorkbench) Blocks.CRAFTING_TABLE).getMenuProvider(null, getHandle().level, CraftLocation.toBlockPosition(location)));
getHandle().openMenu(((BlockWorkbench) Blocks.CRAFTING_TABLE).getMenuProvider(null, getHandle().level(), CraftLocation.toBlockPosition(location)));
if (force) {
getHandle().containerMenu.checkReachable = false;
}
@@ -362,7 +362,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
// If there isn't an enchant table we can force create one, won't be very useful though.
BlockPosition pos = CraftLocation.toBlockPosition(location);
getHandle().openMenu(((BlockEnchantmentTable) Blocks.ENCHANTING_TABLE).getMenuProvider(null, getHandle().level, pos));
getHandle().openMenu(((BlockEnchantmentTable) Blocks.ENCHANTING_TABLE).getMenuProvider(null, getHandle().level(), pos));
if (force) {
getHandle().containerMenu.checkReachable = false;
@@ -544,7 +544,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
private Collection<IRecipe<?>> bukkitKeysToMinecraftRecipes(Collection<NamespacedKey> recipeKeys) {
Collection<IRecipe<?>> recipes = new ArrayList<>();
CraftingManager manager = getHandle().level.getServer().getRecipeManager();
CraftingManager manager = getHandle().level().getServer().getRecipeManager();
for (NamespacedKey recipeKey : recipeKeys) {
Optional<? extends IRecipe<?>> recipe = manager.byKey(CraftNamespacedKey.toMinecraft(recipeKey));
@@ -561,7 +561,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override
public org.bukkit.entity.Entity getShoulderEntityLeft() {
if (!getHandle().getShoulderEntityLeft().isEmpty()) {
Optional<Entity> shoulder = EntityTypes.create(getHandle().getShoulderEntityLeft(), getHandle().level);
Optional<Entity> shoulder = EntityTypes.create(getHandle().getShoulderEntityLeft(), getHandle().level());
return (!shoulder.isPresent()) ? null : shoulder.get().getBukkitEntity();
}
@@ -580,7 +580,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override
public org.bukkit.entity.Entity getShoulderEntityRight() {
if (!getHandle().getShoulderEntityRight().isEmpty()) {
Optional<Entity> shoulder = EntityTypes.create(getHandle().getShoulderEntityRight(), getHandle().level);
Optional<Entity> shoulder = EntityTypes.create(getHandle().getShoulderEntityRight(), getHandle().level());
return (!shoulder.isPresent()) ? null : shoulder.get().getBukkitEntity();
}
@@ -681,8 +681,8 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
Preconditions.checkArgument(fireworkItemStack != null, "fireworkItemStack must not be null");
Preconditions.checkArgument(fireworkItemStack.getType() == Material.FIREWORK_ROCKET, "fireworkItemStack must be of type %s", Material.FIREWORK_ROCKET);
EntityFireworks fireworks = new EntityFireworks(getHandle().level, CraftItemStack.asNMSCopy(fireworkItemStack), getHandle());
boolean success = getHandle().level.addFreshEntity(fireworks, SpawnReason.CUSTOM);
EntityFireworks fireworks = new EntityFireworks(getHandle().level(), CraftItemStack.asNMSCopy(fireworkItemStack), getHandle());
boolean success = getHandle().level().addFreshEntity(fireworks, SpawnReason.CUSTOM);
return success ? (Firework) fireworks.getBukkitEntity() : null;
}
}

View File

@@ -48,7 +48,7 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame {
// update redstone
if (!getHandle().generation) {
getHandle().getLevel().updateNeighbourForOutputSignal(getHandle().pos, Blocks.AIR);
getHandle().level().updateNeighbourForOutputSignal(getHandle().pos, Blocks.AIR);
}
}

View File

@@ -85,6 +85,7 @@ import net.minecraft.world.inventory.Container;
import net.minecraft.world.item.EnumColor;
import net.minecraft.world.level.EnumGamemode;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.SignText;
import net.minecraft.world.level.block.entity.TileEntitySign;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.border.IWorldBorderListener;
@@ -148,7 +149,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerExpCooldownChangeEvent;
import org.bukkit.event.player.PlayerHideEntityEvent;
import org.bukkit.event.player.PlayerRegisterChannelEvent;
import org.bukkit.event.player.PlayerRespawnEvent.RespawnReason;
import org.bukkit.event.player.PlayerShowEntityEvent;
import org.bukkit.event.player.PlayerSpawnChangeEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
@@ -644,7 +644,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
@Override
public void sendBlockChanges(Collection<BlockState> blocks, boolean suppressLightUpdates) {
public void sendBlockChanges(Collection<BlockState> blocks) {
Preconditions.checkArgument(blocks != null, "blocks must not be null");
if (getHandle().connection == null || blocks.isEmpty()) {
@@ -669,11 +669,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// Construct the packets using the data allocated above and send then to the players
for (Map.Entry<SectionPosition, ChunkSectionChanges> entry : changes.entrySet()) {
ChunkSectionChanges chunkChanges = entry.getValue();
PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange(entry.getKey(), chunkChanges.positions(), chunkChanges.blockData().toArray(IBlockData[]::new), suppressLightUpdates);
PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange(entry.getKey(), chunkChanges.positions(), chunkChanges.blockData().toArray(IBlockData[]::new));
getHandle().connection.send(packet);
}
}
@Override
public void sendBlockChanges(Collection<BlockState> blocks, boolean suppressLightUpdates) {
this.sendBlockChanges(blocks);
}
private record ChunkSectionChanges(ShortSet positions, List<IBlockData> blockData) {
public ChunkSectionChanges() {
@@ -736,10 +741,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
IChatBaseComponent[] components = CraftSign.sanitizeLines(lines);
TileEntitySign sign = new TileEntitySign(CraftLocation.toBlockPosition(loc), Blocks.OAK_SIGN.defaultBlockState());
sign.setColor(EnumColor.byId(dyeColor.getWoolData()));
sign.setHasGlowingText(hasGlowingText);
SignText text = sign.getFrontText();
text.setColor(EnumColor.byId(dyeColor.getWoolData()));
text.setHasGlowingText(hasGlowingText);
for (int i = 0; i < components.length; i++) {
sign.setMessage(i, components[i]);
text.setMessage(i, components[i]);
}
getHandle().connection.send(sign.getUpdatePacket());
@@ -1368,7 +1374,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
private void untrackAndHideEntity(org.bukkit.entity.Entity entity) {
// Remove this entity from the hidden player's EntityTrackerEntry
PlayerChunkMap tracker = ((WorldServer) getHandle().level).getChunkSource().chunkMap;
PlayerChunkMap tracker = ((WorldServer) getHandle().level()).getChunkSource().chunkMap;
Entity other = ((CraftEntity) entity).getHandle();
PlayerChunkMap.EntityTracker entry = tracker.entityMap.get(other.getId());
if (entry != null) {
@@ -1448,7 +1454,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
private void trackAndShowEntity(org.bukkit.entity.Entity entity) {
PlayerChunkMap tracker = ((WorldServer) getHandle().level).getChunkSource().chunkMap;
PlayerChunkMap tracker = ((WorldServer) getHandle().level()).getChunkSource().chunkMap;
Entity other = ((CraftEntity) entity).getHandle();
if (other instanceof EntityPlayer) {

View File

@@ -1,7 +1,6 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.core.BlockPosition;
import net.minecraft.world.entity.raid.EntityRaider;
import org.bukkit.Sound;
import org.bukkit.block.Block;
@@ -28,7 +27,7 @@ public abstract class CraftRaider extends CraftMonster implements Raider {
@Override
public Block getPatrolTarget() {
return getHandle().getPatrolTarget() == null ? null : CraftBlock.at(getHandle().level, getHandle().getPatrolTarget());
return getHandle().getPatrolTarget() == null ? null : CraftBlock.at(getHandle().level(), getHandle().getPatrolTarget());
}
@Override

View File

@@ -34,7 +34,7 @@ public class CraftSniffer extends CraftAnimals implements Sniffer {
@Override
public Collection<Location> getExploredLocations() {
return this.getHandle().getExploredPositions().map(blockPosition -> CraftLocation.toBukkit(blockPosition, this.getLocation().getWorld())).collect(Collectors.toList());
return this.getHandle().getExploredPositions().map(blockPosition -> CraftLocation.toBukkit(blockPosition.pos(), this.server.getServer().getLevel(blockPosition.dimension()))).collect(Collectors.toList());
}
@Override
@@ -79,19 +79,19 @@ public class CraftSniffer extends CraftAnimals implements Sniffer {
return this.getHandle().canDig();
}
private net.minecraft.world.entity.animal.sniffer.Sniffer.a stateToNMS(Sniffer.State state) {
private net.minecraft.world.entity.animal.sniffer.Sniffer.State stateToNMS(Sniffer.State state) {
return switch (state) {
case IDLING -> net.minecraft.world.entity.animal.sniffer.Sniffer.a.IDLING;
case FEELING_HAPPY -> net.minecraft.world.entity.animal.sniffer.Sniffer.a.FEELING_HAPPY;
case SCENTING -> net.minecraft.world.entity.animal.sniffer.Sniffer.a.SCENTING;
case SNIFFING -> net.minecraft.world.entity.animal.sniffer.Sniffer.a.SNIFFING;
case SEARCHING -> net.minecraft.world.entity.animal.sniffer.Sniffer.a.SEARCHING;
case DIGGING -> net.minecraft.world.entity.animal.sniffer.Sniffer.a.DIGGING;
case RISING -> net.minecraft.world.entity.animal.sniffer.Sniffer.a.RISING;
case IDLING -> net.minecraft.world.entity.animal.sniffer.Sniffer.State.IDLING;
case FEELING_HAPPY -> net.minecraft.world.entity.animal.sniffer.Sniffer.State.FEELING_HAPPY;
case SCENTING -> net.minecraft.world.entity.animal.sniffer.Sniffer.State.SCENTING;
case SNIFFING -> net.minecraft.world.entity.animal.sniffer.Sniffer.State.SNIFFING;
case SEARCHING -> net.minecraft.world.entity.animal.sniffer.Sniffer.State.SEARCHING;
case DIGGING -> net.minecraft.world.entity.animal.sniffer.Sniffer.State.DIGGING;
case RISING -> net.minecraft.world.entity.animal.sniffer.Sniffer.State.RISING;
};
}
private Sniffer.State stateToBukkit(net.minecraft.world.entity.animal.sniffer.Sniffer.a state) {
private Sniffer.State stateToBukkit(net.minecraft.world.entity.animal.sniffer.Sniffer.State state) {
return switch (state) {
case IDLING -> Sniffer.State.IDLING;
case FEELING_HAPPY -> Sniffer.State.FEELING_HAPPY;

View File

@@ -102,7 +102,7 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
Preconditions.checkState(!getHandle().generation, "Cannot sleep during world generation");
BlockPosition position = CraftLocation.toBlockPosition(location);
IBlockData iblockdata = getHandle().level.getBlockState(position);
IBlockData iblockdata = getHandle().level().getBlockState(position);
if (!(iblockdata.getBlock() instanceof BlockBed)) {
return false;
}
@@ -126,7 +126,7 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
@Override
public ZombieVillager zombify() {
EntityZombieVillager entityzombievillager = EntityZombie.zombifyVillager(getHandle().level.getMinecraftWorld(), getHandle(), getHandle().blockPosition(), isSilent(), CreatureSpawnEvent.SpawnReason.CUSTOM);
EntityZombieVillager entityzombievillager = EntityZombie.zombifyVillager(getHandle().level().getMinecraftWorld(), getHandle(), getHandle().blockPosition(), isSilent(), CreatureSpawnEvent.SpawnReason.CUSTOM);
return (entityzombievillager != null) ? (ZombieVillager) entityzombievillager.getBukkitEntity() : null;
}

View File

@@ -58,7 +58,7 @@ public class CraftWither extends CraftMonster implements Wither {
if (entityId == 0) {
return null;
}
Entity target = getHandle().getLevel().getEntity(entityId);
Entity target = getHandle().level().getEntity(entityId);
return (target != null) ? (LivingEntity) target.getBukkitEntity() : null;
}

View File

@@ -284,7 +284,7 @@ public class CraftEventFactory {
}
}, t -> BedEnterResult.OK).map(java.util.function.Function.identity(), java.util.function.Function.identity());
PlayerBedEnterEvent event = new PlayerBedEnterEvent((Player) player.getBukkitEntity(), CraftBlock.at(player.level, bed), bedEnterResult);
PlayerBedEnterEvent event = new PlayerBedEnterEvent((Player) player.getBukkitEntity(), CraftBlock.at(player.level(), bed), bedEnterResult);
Bukkit.getServer().getPluginManager().callEvent(event);
Result result = event.useBed();
@@ -422,7 +422,7 @@ public class CraftEventFactory {
if (!event.isCancelled()) {
for (EntityItem item : items) {
item.level.addFreshEntity(item);
item.level().addFreshEntity(item);
}
}
}
@@ -437,7 +437,7 @@ public class CraftEventFactory {
org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(clickedFace);
EntityPlaceEvent event = new EntityPlaceEvent(entity.getBukkitEntity(), who, blockClicked, blockFace, CraftEquipmentSlot.getHand(enumhand));
entity.level.getCraftServer().getPluginManager().callEvent(event);
entity.level().getCraftServer().getPluginManager().callEvent(event);
return event;
}
@@ -587,7 +587,7 @@ public class CraftEventFactory {
Player player = who.getBukkitEntity();
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
Block blockClicked = CraftBlock.at(who.getLevel(), pos);
Block blockClicked = CraftBlock.at(who.level(), pos);
BlockDamageEvent event = new BlockDamageEvent(player, blockClicked, itemInHand, instaBreak);
player.getServer().getPluginManager().callEvent(event);
@@ -599,7 +599,7 @@ public class CraftEventFactory {
Player player = who.getBukkitEntity();
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
Block blockClicked = CraftBlock.at(who.getLevel(), pos);
Block blockClicked = CraftBlock.at(who.level(), pos);
BlockDamageAbortEvent event = new BlockDamageAbortEvent(player, blockClicked, itemInHand);
player.getServer().getPluginManager().callEvent(event);
@@ -917,7 +917,7 @@ public class CraftEventFactory {
}
return callEntityDamageEvent(damager, entity, cause, modifiers, modifierFunctions, cancelled);
} else if (source.is(DamageTypes.OUT_OF_WORLD)) {
} else if (source.is(DamageTypes.FELL_OUT_OF_WORLD)) {
EntityDamageEvent event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.VOID, modifiers, modifierFunctions);
event.setCancelled(cancelled);
callEvent(event);
@@ -1194,7 +1194,7 @@ public class CraftEventFactory {
}
public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, BlockPosition position, IBlockData newBlock, boolean cancelled) {
Block block = entity.level.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
Block block = entity.level().getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
EntityChangeBlockEvent event = new EntityChangeBlockEvent(entity.getBukkitEntity(), block, CraftBlockData.fromData(newBlock));
event.setCancelled(cancelled);
@@ -1222,7 +1222,7 @@ public class CraftEventFactory {
public static EntityBreakDoorEvent callEntityBreakDoorEvent(Entity entity, BlockPosition pos) {
org.bukkit.entity.Entity entity1 = entity.getBukkitEntity();
Block block = CraftBlock.at(entity.level, pos);
Block block = CraftBlock.at(entity.level(), pos);
EntityBreakDoorEvent event = new EntityBreakDoorEvent((LivingEntity) entity1, block);
entity1.getServer().getPluginManager().callEvent(event);
@@ -1239,7 +1239,7 @@ public class CraftEventFactory {
player.connection.handleContainerClose(new PacketPlayInCloseWindow(player.containerMenu.containerId));
}
CraftServer server = player.level.getCraftServer();
CraftServer server = player.level().getCraftServer();
CraftPlayer craftPlayer = player.getBukkitEntity();
player.containerMenu.transferTo(container, craftPlayer);
@@ -1283,7 +1283,7 @@ public class CraftEventFactory {
BlockFace hitFace = null;
if (position.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
MovingObjectPositionBlock positionBlock = (MovingObjectPositionBlock) position;
hitBlock = CraftBlock.at(entity.level, positionBlock.getBlockPos());
hitBlock = CraftBlock.at(entity.level(), positionBlock.getBlockPos());
hitFace = CraftBlock.notchToBlockFace(positionBlock.getDirection());
}
@@ -1293,7 +1293,7 @@ public class CraftEventFactory {
}
ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), hitEntity, hitBlock, hitFace);
entity.level.getCraftServer().getPluginManager().callEvent(event);
entity.level().getCraftServer().getPluginManager().callEvent(event);
return event;
}
@@ -1394,13 +1394,13 @@ public class CraftEventFactory {
public static void handleInventoryCloseEvent(EntityHuman human) {
InventoryCloseEvent event = new InventoryCloseEvent(human.containerMenu.getBukkitView());
human.level.getCraftServer().getPluginManager().callEvent(event);
human.level().getCraftServer().getPluginManager().callEvent(event);
human.containerMenu.transferTo(human.inventoryMenu, human.getBukkitEntity());
}
public static ItemStack handleEditBookEvent(EntityPlayer player, int itemInHandIndex, ItemStack itemInHand, ItemStack newBookItem) {
PlayerEditBookEvent editBookEvent = new PlayerEditBookEvent(player.getBukkitEntity(), (itemInHandIndex >= 0 && itemInHandIndex <= 8) ? itemInHandIndex : -1, (BookMeta) CraftItemStack.getItemMeta(itemInHand), (BookMeta) CraftItemStack.getItemMeta(newBookItem), newBookItem.getItem() == Items.WRITTEN_BOOK);
player.level.getCraftServer().getPluginManager().callEvent(editBookEvent);
player.level().getCraftServer().getPluginManager().callEvent(editBookEvent);
// If they've got the same item in their hand, it'll need to be updated.
if (itemInHand != null && itemInHand.getItem() == Items.WRITABLE_BOOK) {
@@ -1418,13 +1418,13 @@ public class CraftEventFactory {
public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(EntityInsentient entity, EntityHuman player, EnumHand enumhand) {
PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand));
entity.level.getCraftServer().getPluginManager().callEvent(event);
entity.level().getCraftServer().getPluginManager().callEvent(event);
return event;
}
public static PlayerLeashEntityEvent callPlayerLeashEntityEvent(EntityInsentient entity, Entity leashHolder, EntityHuman player, EnumHand enumhand) {
PlayerLeashEntityEvent event = new PlayerLeashEntityEvent(entity.getBukkitEntity(), leashHolder.getBukkitEntity(), (Player) player.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand));
entity.level.getCraftServer().getPluginManager().callEvent(event);
entity.level().getCraftServer().getPluginManager().callEvent(event);
return event;
}
@@ -1488,13 +1488,13 @@ public class CraftEventFactory {
event = new PlayerStatisticIncrementEvent(player, stat, current, newValue, material);
}
}
entityHuman.level.getCraftServer().getPluginManager().callEvent(event);
entityHuman.level().getCraftServer().getPluginManager().callEvent(event);
return (Cancellable) event;
}
public static FireworkExplodeEvent callFireworkExplodeEvent(EntityFireworks firework) {
FireworkExplodeEvent event = new FireworkExplodeEvent((Firework) firework.getBukkitEntity());
firework.level.getCraftServer().getPluginManager().callEvent(event);
firework.level().getCraftServer().getPluginManager().callEvent(event);
return event;
}
@@ -1521,19 +1521,19 @@ public class CraftEventFactory {
public static EntityToggleGlideEvent callToggleGlideEvent(EntityLiving entity, boolean gliding) {
EntityToggleGlideEvent event = new EntityToggleGlideEvent((LivingEntity) entity.getBukkitEntity(), gliding);
entity.level.getCraftServer().getPluginManager().callEvent(event);
entity.level().getCraftServer().getPluginManager().callEvent(event);
return event;
}
public static EntityToggleSwimEvent callToggleSwimEvent(EntityLiving entity, boolean swimming) {
EntityToggleSwimEvent event = new EntityToggleSwimEvent((LivingEntity) entity.getBukkitEntity(), swimming);
entity.level.getCraftServer().getPluginManager().callEvent(event);
entity.level().getCraftServer().getPluginManager().callEvent(event);
return event;
}
public static AreaEffectCloudApplyEvent callAreaEffectCloudApplyEvent(EntityAreaEffectCloud cloud, List<LivingEntity> entities) {
AreaEffectCloudApplyEvent event = new AreaEffectCloudApplyEvent((AreaEffectCloud) cloud.getBukkitEntity(), entities);
cloud.level.getCraftServer().getPluginManager().callEvent(event);
cloud.level().getCraftServer().getPluginManager().callEvent(event);
return event;
}
@@ -1549,7 +1549,7 @@ public class CraftEventFactory {
CraftItemStack bredWithStack = bredWith == null ? null : CraftItemStack.asCraftMirror(bredWith).clone();
EntityBreedEvent event = new EntityBreedEvent((LivingEntity) child.getBukkitEntity(), (LivingEntity) mother.getBukkitEntity(), (LivingEntity) father.getBukkitEntity(), breederEntity, bredWithStack, experience);
child.level.getCraftServer().getPluginManager().callEvent(event);
child.level().getCraftServer().getPluginManager().callEvent(event);
return event;
}
@@ -1679,7 +1679,7 @@ public class CraftEventFactory {
public static LootGenerateEvent callLootGenerateEvent(IInventory inventory, LootTable lootTable, LootTableInfo lootInfo, List<ItemStack> loot, boolean plugin) {
CraftWorld world = lootInfo.getLevel().getWorld();
Entity entity = lootInfo.getParamOrNull(LootContextParameters.THIS_ENTITY);
NamespacedKey key = CraftNamespacedKey.fromMinecraft(world.getHandle().getServer().getLootTables().lootTableToKey.get(lootTable));
NamespacedKey key = CraftNamespacedKey.fromMinecraft(world.getHandle().getServer().getLootData().lootTableToKey.get(lootTable));
CraftLootTable craftLootTable = new CraftLootTable(key, lootTable);
List<org.bukkit.inventory.ItemStack> bukkitLoot = loot.stream().map(CraftItemStack::asCraftMirror).collect(Collectors.toCollection(ArrayList::new));

View File

@@ -223,11 +223,6 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
}
}
}
// Apply captured light blocks
for (BlockPosition lightPosition : craftData.getLights()) {
((ProtoChunk) ichunkaccess).addLight(new BlockPosition((x << 4) + lightPosition.getX(), lightPosition.getY(), (z << 4) + lightPosition.getZ()));
}
}
@Override

View File

@@ -177,7 +177,7 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData {
int offset = (y - minHeight) >> 4;
ChunkSection section = sections[offset];
if (create && section == null) {
sections[offset] = section = new ChunkSection(offset + (minHeight >> 4), biomes);
sections[offset] = section = new ChunkSection(biomes);
}
return section;
}

View File

@@ -134,8 +134,6 @@ public class CraftContainer extends Container {
return Containers.BEACON;
case ANVIL:
return Containers.ANVIL;
case SMITHING:
return Containers.LEGACY_SMITHING;
case HOPPER:
return Containers.HOPPER;
case DROPPER:

View File

@@ -329,9 +329,11 @@ public final class CraftItemFactory implements ItemFactory {
case SCULK_CATALYST:
case SCULK_SHRIEKER:
case SCULK_SENSOR:
case CALIBRATED_SCULK_SENSOR:
case CHISELED_BOOKSHELF:
case DECORATED_POT:
case SUSPICIOUS_SAND:
case SUSPICIOUS_GRAVEL:
return new CraftMetaBlockState(meta, material);
case TROPICAL_FISH_BUCKET:
return meta instanceof CraftMetaTropicalFishBucket ? meta : new CraftMetaTropicalFishBucket(meta);

View File

@@ -592,9 +592,11 @@ public final class CraftItemStack extends ItemStack {
case SCULK_CATALYST:
case SCULK_SHRIEKER:
case SCULK_SENSOR:
case CALIBRATED_SCULK_SENSOR:
case CHISELED_BOOKSHELF:
case DECORATED_POT:
case SUSPICIOUS_SAND:
case SUSPICIOUS_GRAVEL:
return new CraftMetaBlockState(item.getTag(), CraftMagicNumbers.getMaterial(item.getItem()));
case TROPICAL_FISH_BUCKET:
return new CraftMetaTropicalFishBucket(item.getTag());

View File

@@ -116,10 +116,12 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
Material.BEE_NEST,
Material.SCULK_CATALYST,
Material.SCULK_SHRIEKER,
Material.CALIBRATED_SCULK_SENSOR,
Material.SCULK_SENSOR,
Material.CHISELED_BOOKSHELF,
Material.DECORATED_POT,
Material.SUSPICIOUS_SAND
Material.SUSPICIOUS_SAND,
Material.SUSPICIOUS_GRAVEL
);
static {

View File

@@ -1,29 +0,0 @@
package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.MinecraftServer;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.SmithingRecipe;
public class CraftSmithingRecipe extends SmithingRecipe implements CraftRecipe {
public CraftSmithingRecipe(NamespacedKey key, ItemStack result, RecipeChoice base, RecipeChoice addition) {
super(key, result, base, addition);
}
public static CraftSmithingRecipe fromBukkitRecipe(SmithingRecipe recipe) {
if (recipe instanceof CraftSmithingRecipe) {
return (CraftSmithingRecipe) recipe;
}
CraftSmithingRecipe ret = new CraftSmithingRecipe(recipe.getKey(), recipe.getResult(), recipe.getBase(), recipe.getAddition());
return ret;
}
@Override
public void addToCraftingManager() {
ItemStack result = this.getResult();
MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.LegacyUpgradeRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result)));
}
}

View File

@@ -7,18 +7,17 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService;
import com.mojang.authlib.yggdrasil.ServicesKeySet;
import com.mojang.authlib.yggdrasil.ServicesKeyType;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import java.net.Proxy;
import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.commons.io.IOUtils;
import org.bukkit.craftbukkit.configuration.ConfigSerializationUtil;
final class CraftProfileProperty {
@@ -44,19 +43,18 @@ final class CraftProfileProperty {
public String format(JsonElement jsonElement);
}
private static final PublicKey PUBLIC_KEY;
private static final ServicesKeySet PUBLIC_KEYS;
static {
try {
X509EncodedKeySpec spec = new X509EncodedKeySpec(IOUtils.toByteArray(YggdrasilMinecraftSessionService.class.getResourceAsStream("/yggdrasil_session_pubkey.der")));
PUBLIC_KEY = KeyFactory.getInstance("RSA").generatePublic(spec);
PUBLIC_KEYS = new YggdrasilAuthenticationService(Proxy.NO_PROXY).getServicesKeySet();
} catch (Exception e) {
throw new Error("Could not find yggdrasil_session_pubkey.der! This indicates a bug.");
throw new Error("Could not load yggdrasil_session_pubkey.der! This indicates a bug.");
}
}
public static boolean hasValidSignature(@Nonnull Property property) {
return property.hasSignature() && property.isSignatureValid(PUBLIC_KEY);
return property.hasSignature() && PUBLIC_KEYS.keys(ServicesKeyType.PROFILE_PROPERTY).stream().anyMatch((key) -> key.validateProperty(property));
}
@Nullable

View File

@@ -19,7 +19,7 @@ public class CraftPalette implements Palette {
public List<BlockState> getBlocks() {
List<BlockState> blocks = new ArrayList<>();
for (DefinedStructure.BlockInfo blockInfo : palette.blocks()) {
blocks.add(CraftBlockStates.getBlockState(blockInfo.pos, blockInfo.state, blockInfo.nbt));
blocks.add(CraftBlockStates.getBlockState(blockInfo.pos(), blockInfo.state(), blockInfo.nbt()));
}
return blocks;
}

View File

@@ -24,9 +24,11 @@ public final class CraftLocation {
}
public static Location toBukkit(BlockPosition blockPosition) {
return toBukkit(blockPosition, null);
return toBukkit(blockPosition, (World) null);
}
public static Location toBukkit(BlockPosition blockPosition, net.minecraft.world.level.World world) {
return toBukkit(blockPosition, world.getWorld(), 0.0F, 0.0F);
}
public static Location toBukkit(BlockPosition blockPosition, World world) {
return toBukkit(blockPosition, world, 0.0F, 0.0F);
}

View File

@@ -239,7 +239,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
* @return string
*/
public String getMappingsVersion() {
return "3009edc0fff87fa34680686663bd59df";
return "34f399b4f2033891290b7f0700e9e47b";
}
@Override
@@ -275,7 +275,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
JsonElement jsonelement = AdvancementDataWorld.GSON.fromJson(advancement, JsonElement.class);
JsonObject jsonobject = ChatDeserializer.convertToJsonObject(jsonelement, "advancement");
net.minecraft.advancements.Advancement.SerializedAdvancement nms = net.minecraft.advancements.Advancement.SerializedAdvancement.fromJson(jsonobject, new LootDeserializationContext(minecraftkey, MinecraftServer.getServer().getPredicateManager()));
net.minecraft.advancements.Advancement.SerializedAdvancement nms = net.minecraft.advancements.Advancement.SerializedAdvancement.fromJson(jsonobject, new LootDeserializationContext(minecraftkey, MinecraftServer.getServer().getLootData()));
if (nms != null) {
MinecraftServer.getServer().getAdvancements().advancements.add(Maps.newHashMap(Collections.singletonMap(minecraftkey, nms)));
Advancement bukkit = Bukkit.getAdvancement(key);
@@ -305,7 +305,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
return file.delete();
}
private static final List<String> SUPPORTED_API = Arrays.asList("1.13", "1.14", "1.15", "1.16", "1.17", "1.18", "1.19");
private static final List<String> SUPPORTED_API = Arrays.asList("1.13", "1.14", "1.15", "1.16", "1.17", "1.18", "1.19", "1.20");
@Override
public void checkSupported(PluginDescriptionFile pdf) throws InvalidPluginException {

View File

@@ -31,7 +31,7 @@ import net.minecraft.world.level.dimension.DimensionManager;
import net.minecraft.world.level.entity.EntityTypeTest;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.levelgen.HeightMap;
import net.minecraft.world.level.lighting.LightEngine;
import net.minecraft.world.level.lighting.LevelLightEngine;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidType;
import net.minecraft.world.level.material.FluidTypes;
@@ -194,7 +194,7 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed {
}
@Override
public LightEngine getLightEngine() {
public LevelLightEngine getLightEngine() {
throw new UnsupportedOperationException("Not supported yet.");
}