@@ -3,31 +3,32 @@ package org.bukkit.craftbukkit;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.world.entity.decoration.Paintings;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.entity.decoration.PaintingVariant;
|
||||
import org.bukkit.Art;
|
||||
|
||||
public class CraftArt {
|
||||
private static final BiMap<Paintings, Art> artwork;
|
||||
private static final BiMap<Holder<PaintingVariant>, Art> artwork;
|
||||
|
||||
static {
|
||||
ImmutableBiMap.Builder<Paintings, Art> artworkBuilder = ImmutableBiMap.builder();
|
||||
for (MinecraftKey key : IRegistry.MOTIVE.keySet()) {
|
||||
artworkBuilder.put(IRegistry.MOTIVE.get(key), Art.getByName(key.getPath()));
|
||||
ImmutableBiMap.Builder<Holder<PaintingVariant>, Art> artworkBuilder = ImmutableBiMap.builder();
|
||||
for (ResourceKey<PaintingVariant> key : IRegistry.PAINTING_VARIANT.registryKeySet()) {
|
||||
artworkBuilder.put(IRegistry.PAINTING_VARIANT.getHolderOrThrow(key), Art.getByName(key.location().getPath()));
|
||||
}
|
||||
|
||||
artwork = artworkBuilder.build();
|
||||
}
|
||||
|
||||
public static Art NotchToBukkit(Paintings art) {
|
||||
public static Art NotchToBukkit(Holder<PaintingVariant> art) {
|
||||
Art bukkit = artwork.get(art);
|
||||
Preconditions.checkArgument(bukkit != null);
|
||||
return bukkit;
|
||||
}
|
||||
|
||||
public static Paintings BukkitToNotch(Art art) {
|
||||
Paintings nms = artwork.inverse().get(art);
|
||||
public static Holder<PaintingVariant> BukkitToNotch(Art art) {
|
||||
Holder<PaintingVariant> nms = artwork.inverse().get(art);
|
||||
Preconditions.checkArgument(nms != null);
|
||||
return nms;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.DataPaletteBlock;
|
||||
import net.minecraft.world.level.chunk.IChunkAccess;
|
||||
import net.minecraft.world.level.chunk.NibbleArray;
|
||||
import net.minecraft.world.level.chunk.PalettedContainerRO;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkRegionLoader;
|
||||
import net.minecraft.world.level.chunk.storage.EntityStorage;
|
||||
import net.minecraft.world.level.entity.PersistentEntitySectionManager;
|
||||
@@ -52,7 +53,7 @@ public class CraftChunk implements Chunk {
|
||||
private final WorldServer worldServer;
|
||||
private final int x;
|
||||
private final int z;
|
||||
private static final DataPaletteBlock<IBlockData> emptyBlockIDs = new DataPaletteBlock<>(net.minecraft.world.level.block.Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.e.SECTION_STATES);
|
||||
private static final DataPaletteBlock<IBlockData> emptyBlockIDs = new DataPaletteBlock<>(net.minecraft.world.level.block.Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.d.SECTION_STATES);
|
||||
private static final byte[] emptyLight = new byte[2048];
|
||||
|
||||
public CraftChunk(net.minecraft.world.level.chunk.Chunk chunk) {
|
||||
@@ -293,10 +294,10 @@ public class CraftChunk implements Chunk {
|
||||
byte[][] sectionSkyLights = new byte[cs.length][];
|
||||
byte[][] sectionEmitLights = new byte[cs.length][];
|
||||
boolean[] sectionEmpty = new boolean[cs.length];
|
||||
DataPaletteBlock<Holder<BiomeBase>>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[cs.length] : null;
|
||||
PalettedContainerRO<Holder<BiomeBase>>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[cs.length] : null;
|
||||
|
||||
IRegistry<BiomeBase> iregistry = worldServer.registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY);
|
||||
Codec<DataPaletteBlock<Holder<BiomeBase>>> biomeCodec = DataPaletteBlock.codec(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.e.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS));
|
||||
Codec<PalettedContainerRO<Holder<BiomeBase>>> biomeCodec = DataPaletteBlock.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS));
|
||||
|
||||
for (int i = 0; i < cs.length; i++) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
@@ -361,7 +362,7 @@ public class CraftChunk implements Chunk {
|
||||
empty[i] = true;
|
||||
|
||||
if (biome != null) {
|
||||
biome[i] = new DataPaletteBlock<>(iregistry.asHolderIdMap(), iregistry.getHolderOrThrow(Biomes.PLAINS), DataPaletteBlock.e.SECTION_BIOMES);
|
||||
biome[i] = new DataPaletteBlock<>(iregistry.asHolderIdMap(), iregistry.getHolderOrThrow(Biomes.PLAINS), DataPaletteBlock.d.SECTION_BIOMES);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.level.chunk.DataPaletteBlock;
|
||||
import net.minecraft.world.level.chunk.PalettedContainerRO;
|
||||
import net.minecraft.world.level.levelgen.HeightMap;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Material;
|
||||
@@ -33,9 +34,9 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
|
||||
private final HeightMap hmap; // Height map
|
||||
private final long captureFulltime;
|
||||
private final IRegistry<BiomeBase> biomeRegistry;
|
||||
private final DataPaletteBlock<Holder<BiomeBase>>[] biome;
|
||||
private final PalettedContainerRO<Holder<BiomeBase>>[] biome;
|
||||
|
||||
CraftChunkSnapshot(int x, int z, int minHeight, int maxHeight, String wname, long wtime, DataPaletteBlock<IBlockData>[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, HeightMap hmap, IRegistry<BiomeBase> biomeRegistry, DataPaletteBlock<Holder<BiomeBase>>[] biome) {
|
||||
CraftChunkSnapshot(int x, int z, int minHeight, int maxHeight, String wname, long wtime, DataPaletteBlock<IBlockData>[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, HeightMap hmap, IRegistry<BiomeBase> biomeRegistry, PalettedContainerRO<Holder<BiomeBase>>[] biome) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.minHeight = minHeight;
|
||||
@@ -135,7 +136,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
|
||||
Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true");
|
||||
validateChunkCoordinates(x, y, z);
|
||||
|
||||
DataPaletteBlock<Holder<BiomeBase>> biome = this.biome[getSectionIndex(y >> 2)];
|
||||
PalettedContainerRO<Holder<BiomeBase>> biome = this.biome[getSectionIndex(y >> 2)];
|
||||
return CraftBlock.biomeBaseToBiome(biomeRegistry, biome.get(x >> 2, (y & 0xF) >> 2, z >> 2));
|
||||
}
|
||||
|
||||
@@ -149,7 +150,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
|
||||
Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true");
|
||||
validateChunkCoordinates(x, y, z);
|
||||
|
||||
DataPaletteBlock<Holder<BiomeBase>> biome = this.biome[getSectionIndex(y >> 2)];
|
||||
PalettedContainerRO<Holder<BiomeBase>> biome = this.biome[getSectionIndex(y >> 2)];
|
||||
return biome.get(x >> 2, (y & 0xF) >> 2, z >> 2).value().getTemperature(new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z));
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.util.RandomSourceWrapper;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.loot.LootContext;
|
||||
@@ -76,7 +77,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
|
||||
|
||||
LootTableInfo.Builder builder = new LootTableInfo.Builder(handle);
|
||||
if (random != null) {
|
||||
builder = builder.withRandom(random);
|
||||
builder = builder.withRandom(new RandomSourceWrapper(random));
|
||||
}
|
||||
setMaybe(builder, LootContextParameters.ORIGIN, new Vec3D(loc.getX(), loc.getY(), loc.getZ()));
|
||||
if (getHandle() != LootTable.EMPTY) {
|
||||
|
||||
@@ -14,18 +14,21 @@ import net.minecraft.core.particles.ParticleParamBlock;
|
||||
import net.minecraft.core.particles.ParticleParamItem;
|
||||
import net.minecraft.core.particles.ParticleParamRedstone;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.core.particles.SculkChargeParticleOptions;
|
||||
import net.minecraft.core.particles.ShriekParticleOption;
|
||||
import net.minecraft.core.particles.VibrationParticleOption;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.gameevent.BlockPositionSource;
|
||||
import net.minecraft.world.level.gameevent.EntityPositionSource;
|
||||
import net.minecraft.world.level.gameevent.PositionSource;
|
||||
import net.minecraft.world.level.gameevent.vibrations.VibrationPath;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Vibration;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -124,6 +127,11 @@ public enum CraftParticle {
|
||||
ELECTRIC_SPARK("electric_spark"),
|
||||
SCRAPE("scrape"),
|
||||
BLOCK_MARKER("block_marker"),
|
||||
SONIC_BOOM("sonic_boom"),
|
||||
SCULK_SOUL("sculk_soul"),
|
||||
SCULK_CHARGE("sculk_charge"),
|
||||
SCULK_CHARGE_POP("sculk_charge_pop"),
|
||||
SHRIEK("shriek"),
|
||||
// ----- Legacy Separator -----
|
||||
LEGACY_BLOCK_CRACK("block"),
|
||||
LEGACY_BLOCK_DUST("block"),
|
||||
@@ -202,13 +210,19 @@ public enum CraftParticle {
|
||||
Location destination = ((Vibration.Destination.BlockDestination) vibration.getDestination()).getLocation();
|
||||
source = new BlockPositionSource(new BlockPosition(destination.getBlockX(), destination.getBlockY(), destination.getBlockZ()));
|
||||
} else if (vibration.getDestination() instanceof Vibration.Destination.EntityDestination) {
|
||||
source = new EntityPositionSource(((Vibration.Destination.EntityDestination) vibration.getDestination()).getEntity().getEntityId());
|
||||
Entity destination = ((CraftEntity) ((Vibration.Destination.EntityDestination) vibration.getDestination()).getEntity()).getHandle();
|
||||
source = new EntityPositionSource(destination, destination.getEyeHeight());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown vibration destination " + vibration.getDestination());
|
||||
}
|
||||
|
||||
VibrationPath path = new VibrationPath(new BlockPosition(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ()), source, vibration.getArrivalTime());
|
||||
return new VibrationParticleOption(path);
|
||||
return new VibrationParticleOption(source, vibration.getArrivalTime());
|
||||
}
|
||||
if (particle.getDataType() == Float.class) {
|
||||
return new SculkChargeParticleOptions((Float) obj);
|
||||
}
|
||||
if (particle.getDataType() == Integer.class) {
|
||||
return new ShriekParticleOption((Integer) obj);
|
||||
}
|
||||
throw new IllegalArgumentException(particle.getDataType().toString());
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.core.EnumDirection;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.data.worldgen.features.TreeFeatures;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.EntityAreaEffectCloud;
|
||||
import net.minecraft.world.entity.EntityExperienceOrb;
|
||||
import net.minecraft.world.entity.EntityInsentient;
|
||||
@@ -34,7 +35,6 @@ import net.minecraft.world.entity.projectile.EntityFireworks;
|
||||
import net.minecraft.world.entity.projectile.EntityPotion;
|
||||
import net.minecraft.world.entity.projectile.EntitySnowball;
|
||||
import net.minecraft.world.entity.projectile.EntityTippedArrow;
|
||||
import net.minecraft.world.entity.vehicle.EntityBoat;
|
||||
import net.minecraft.world.entity.vehicle.EntityMinecartChest;
|
||||
import net.minecraft.world.entity.vehicle.EntityMinecartCommandBlock;
|
||||
import net.minecraft.world.entity.vehicle.EntityMinecartFurnace;
|
||||
@@ -65,10 +65,12 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.potion.CraftPotionUtil;
|
||||
import org.bukkit.craftbukkit.util.BlockStateListPopulator;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.util.RandomSourceWrapper;
|
||||
import org.bukkit.entity.AbstractArrow;
|
||||
import org.bukkit.entity.AbstractHorse;
|
||||
import org.bukkit.entity.AbstractSkeleton;
|
||||
import org.bukkit.entity.AbstractVillager;
|
||||
import org.bukkit.entity.Allay;
|
||||
import org.bukkit.entity.Ambient;
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
@@ -79,6 +81,7 @@ import org.bukkit.entity.Blaze;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Cat;
|
||||
import org.bukkit.entity.CaveSpider;
|
||||
import org.bukkit.entity.ChestBoat;
|
||||
import org.bukkit.entity.ChestedHorse;
|
||||
import org.bukkit.entity.Chicken;
|
||||
import org.bukkit.entity.Cod;
|
||||
@@ -107,6 +110,7 @@ import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.entity.Fish;
|
||||
import org.bukkit.entity.Fox;
|
||||
import org.bukkit.entity.Frog;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.Giant;
|
||||
import org.bukkit.entity.GlowItemFrame;
|
||||
@@ -166,6 +170,7 @@ import org.bukkit.entity.Squid;
|
||||
import org.bukkit.entity.Stray;
|
||||
import org.bukkit.entity.Strider;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Tadpole;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.ThrownExpBottle;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
@@ -178,6 +183,7 @@ import org.bukkit.entity.Vex;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.Vindicator;
|
||||
import org.bukkit.entity.WanderingTrader;
|
||||
import org.bukkit.entity.Warden;
|
||||
import org.bukkit.entity.Witch;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.entity.WitherSkeleton;
|
||||
@@ -293,7 +299,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
@Override
|
||||
public boolean generateTree(Location location, Random random, TreeType treeType) {
|
||||
BlockPosition pos = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
return generateTree(getHandle(), getHandle().getMinecraftWorld().getChunkSource().getGenerator(), pos, random, treeType);
|
||||
return generateTree(getHandle(), getHandle().getMinecraftWorld().getChunkSource().getGenerator(), pos, new RandomSourceWrapper(random), treeType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -308,7 +314,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
public boolean generateTree(Location location, Random random, TreeType treeType, Predicate<BlockState> predicate) {
|
||||
BlockPosition pos = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
BlockStateListPopulator populator = new BlockStateListPopulator(getHandle());
|
||||
boolean result = generateTree(populator, getHandle().getMinecraftWorld().getChunkSource().getGenerator(), pos, random, treeType);
|
||||
boolean result = generateTree(populator, getHandle().getMinecraftWorld().getChunkSource().getGenerator(), pos, new RandomSourceWrapper(random), treeType);
|
||||
populator.refreshTiles();
|
||||
|
||||
for (BlockState blockState : populator.getList()) {
|
||||
@@ -320,7 +326,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean generateTree(GeneratorAccessSeed access, ChunkGenerator chunkGenerator, BlockPosition pos, Random random, TreeType treeType) {
|
||||
public boolean generateTree(GeneratorAccessSeed access, ChunkGenerator chunkGenerator, BlockPosition pos, RandomSource random, TreeType treeType) {
|
||||
Holder<?> gen;
|
||||
switch (treeType) {
|
||||
case BIG_TREE:
|
||||
@@ -380,6 +386,12 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
case AZALEA:
|
||||
gen = TreeFeatures.AZALEA_TREE;
|
||||
break;
|
||||
case MANGROVE:
|
||||
gen = TreeFeatures.MANGROVE;
|
||||
break;
|
||||
case TALL_MANGROVE:
|
||||
gen = TreeFeatures.TALL_MANGROVE;
|
||||
break;
|
||||
case TREE:
|
||||
default:
|
||||
gen = TreeFeatures.OAK;
|
||||
@@ -555,7 +567,11 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
|
||||
// order is important for some of these
|
||||
if (Boat.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityBoat(world, x, y, z);
|
||||
if (ChestBoat.class.isAssignableFrom(clazz)) {
|
||||
entity = EntityTypes.CHEST_BOAT.create(world);
|
||||
} else {
|
||||
entity = EntityTypes.BOAT.create(world);
|
||||
}
|
||||
entity.moveTo(x, y, z, yaw, pitch);
|
||||
} else if (FallingBlock.class.isAssignableFrom(clazz)) {
|
||||
BlockPosition pos = new BlockPosition(x, y, z);
|
||||
@@ -798,6 +814,8 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
entity = EntityTypes.SALMON.create(world);
|
||||
} else if (TropicalFish.class.isAssignableFrom(clazz)) {
|
||||
entity = EntityTypes.TROPICAL_FISH.create(world);
|
||||
} else if (Tadpole.class.isAssignableFrom(clazz)) {
|
||||
entity = EntityTypes.TADPOLE.create(world);
|
||||
}
|
||||
} else if (Dolphin.class.isAssignableFrom(clazz)) {
|
||||
entity = EntityTypes.DOLPHIN.create(world);
|
||||
@@ -825,6 +843,12 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
entity = EntityTypes.AXOLOTL.create(world);
|
||||
} else if (Goat.class.isAssignableFrom(clazz)) {
|
||||
entity = EntityTypes.GOAT.create(world);
|
||||
} else if (Allay.class.isAssignableFrom(clazz)) {
|
||||
entity = EntityTypes.ALLAY.create(world);
|
||||
} else if (Frog.class.isAssignableFrom(clazz)) {
|
||||
entity = EntityTypes.FROG.create(world);
|
||||
} else if (Warden.class.isAssignableFrom(clazz)) {
|
||||
entity = EntityTypes.WARDEN.create(world);
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
@@ -881,7 +905,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
EnumDirection dir = CraftBlock.blockFaceToNotch(face).getOpposite();
|
||||
if (Painting.class.isAssignableFrom(clazz)) {
|
||||
if (isNormalWorld() && randomizeData) {
|
||||
entity = new EntityPainting(getHandle().getMinecraftWorld(), new BlockPosition(x, y, z), dir);
|
||||
entity = EntityPainting.create(world, pos, dir).orElse(null);
|
||||
} else {
|
||||
entity = new EntityPainting(EntityTypes.PAINTING, getHandle().getMinecraftWorld());
|
||||
entity.absMoveTo(x, y, z, yaw, pitch);
|
||||
|
||||
@@ -37,7 +37,6 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
@@ -51,10 +50,10 @@ import net.minecraft.commands.CommandDispatcher;
|
||||
import net.minecraft.commands.CommandListenerWrapper;
|
||||
import net.minecraft.commands.arguments.ArgumentEntity;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerCommand;
|
||||
import net.minecraft.server.bossevents.BossBattleCustom;
|
||||
import net.minecraft.server.commands.CommandReload;
|
||||
@@ -96,11 +95,8 @@ import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.MobSpawner;
|
||||
import net.minecraft.world.level.WorldSettings;
|
||||
import net.minecraft.world.level.biome.BiomeManager;
|
||||
import net.minecraft.world.level.biome.WorldChunkManager;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.dimension.DimensionManager;
|
||||
import net.minecraft.world.level.dimension.WorldDimension;
|
||||
import net.minecraft.world.level.levelgen.ChunkGeneratorAbstract;
|
||||
import net.minecraft.world.level.levelgen.GeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.MobSpawnerPatrol;
|
||||
import net.minecraft.world.level.levelgen.MobSpawnerPhantom;
|
||||
@@ -154,7 +150,6 @@ import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.craftbukkit.generator.CraftWorldInfo;
|
||||
import org.bukkit.craftbukkit.generator.CustomWorldChunkManager;
|
||||
import org.bukkit.craftbukkit.generator.OldCraftChunkData;
|
||||
import org.bukkit.craftbukkit.help.SimpleHelpMap;
|
||||
import org.bukkit.craftbukkit.inventory.CraftBlastingRecipe;
|
||||
@@ -637,7 +632,7 @@ public final class CraftServer implements Server {
|
||||
|
||||
@Override
|
||||
public boolean getGenerateStructures() {
|
||||
return this.getProperties().getWorldGenSettings(this.getServer().registryAccess()).generateFeatures();
|
||||
return this.getProperties().getWorldGenSettings(this.getServer().registryAccess()).generateStructures();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -665,17 +660,17 @@ public final class CraftServer implements Server {
|
||||
|
||||
@Override
|
||||
public String getResourcePack() {
|
||||
return this.getServer().getResourcePack();
|
||||
return this.getServer().getServerResourcePack().map(MinecraftServer.ServerResourcePackInfo::url).orElse("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResourcePackHash() {
|
||||
return this.getServer().getResourcePackHash().toUpperCase(Locale.ROOT);
|
||||
return this.getServer().getServerResourcePack().map(MinecraftServer.ServerResourcePackInfo::hash).orElse("").toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResourcePackPrompt() {
|
||||
return CraftChatMessage.fromComponent(this.getServer().getResourcePackPrompt());
|
||||
return this.getServer().getServerResourcePack().map(MinecraftServer.ServerResourcePackInfo::prompt).map(CraftChatMessage::fromComponent).orElse("");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1037,7 +1032,7 @@ public final class CraftServer implements Server {
|
||||
if (worlddata == null) {
|
||||
DedicatedServerProperties.a properties = new DedicatedServerProperties.a(Objects.toString(creator.seed()), ChatDeserializer.parse((creator.generatorSettings().isEmpty()) ? "{}" : creator.generatorSettings()), creator.generateStructures(), creator.type().name().toLowerCase(Locale.ROOT));
|
||||
|
||||
GeneratorSettings generatorsettings = GeneratorSettings.create(console.registryAccess(), properties);
|
||||
GeneratorSettings generatorsettings = properties.create(console.registryAccess());
|
||||
worldSettings = new WorldSettings(name, EnumGamemode.byId(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration);
|
||||
worlddata = new WorldDataServer(worldSettings, generatorsettings, Lifecycle.stable());
|
||||
}
|
||||
@@ -1054,29 +1049,12 @@ public final class CraftServer implements Server {
|
||||
List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(worlddata));
|
||||
IRegistry<WorldDimension> iregistry = worlddata.worldGenSettings().dimensions();
|
||||
WorldDimension worlddimension = (WorldDimension) iregistry.get(actualDimension);
|
||||
Holder<DimensionManager> holder;
|
||||
net.minecraft.world.level.chunk.ChunkGenerator chunkgenerator;
|
||||
|
||||
if (worlddimension == null) {
|
||||
holder = console.registryHolder.registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrCreateHolder(DimensionManager.OVERWORLD_LOCATION);
|
||||
chunkgenerator = GeneratorSettings.makeDefaultOverworld(console.registryHolder, (new Random()).nextLong());
|
||||
} else {
|
||||
holder = worlddimension.typeHolder();
|
||||
chunkgenerator = worlddimension.generator();
|
||||
}
|
||||
|
||||
WorldInfo worldInfo = new CraftWorldInfo(worlddata, worldSession, creator.environment(), holder.value());
|
||||
WorldInfo worldInfo = new CraftWorldInfo(worlddata, worldSession, creator.environment(), worlddimension.typeHolder().value());
|
||||
if (biomeProvider == null && generator != null) {
|
||||
biomeProvider = generator.getDefaultBiomeProvider(worldInfo);
|
||||
}
|
||||
|
||||
if (biomeProvider != null) {
|
||||
WorldChunkManager worldChunkManager = new CustomWorldChunkManager(worldInfo, biomeProvider, console.registryHolder.ownedRegistryOrThrow(IRegistry.BIOME_REGISTRY));
|
||||
if (chunkgenerator instanceof ChunkGeneratorAbstract cga) {
|
||||
chunkgenerator = new ChunkGeneratorAbstract(cga.structureSets, cga.noises, worldChunkManager, cga.ringPlacementSeed, cga.settings);
|
||||
}
|
||||
}
|
||||
|
||||
ResourceKey<net.minecraft.world.level.World> worldKey;
|
||||
String levelName = this.getServer().getProperties().levelName;
|
||||
if (name.equals(levelName + "_nether")) {
|
||||
@@ -1087,8 +1065,8 @@ public final class CraftServer implements Server {
|
||||
worldKey = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH)));
|
||||
}
|
||||
|
||||
WorldServer internal = (WorldServer) new WorldServer(console, console.executor, worldSession, worlddata, worldKey, holder, getServer().progressListenerFactory.create(11),
|
||||
chunkgenerator, worlddata.worldGenSettings().isDebug(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider);
|
||||
WorldServer internal = (WorldServer) new WorldServer(console, console.executor, worldSession, worlddata, worldKey, worlddimension, getServer().progressListenerFactory.create(11),
|
||||
worlddata.worldGenSettings().isDebug(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider);
|
||||
|
||||
if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) {
|
||||
return null;
|
||||
@@ -1287,6 +1265,11 @@ public final class CraftServer implements Server {
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.item.ItemStack quickMoveStack(EntityHuman entityhuman, int i) {
|
||||
return net.minecraft.world.item.ItemStack.EMPTY;
|
||||
}
|
||||
};
|
||||
InventoryCrafting inventoryCrafting = new InventoryCrafting(container, 3, 3);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
@@ -224,8 +225,8 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
@Override
|
||||
public boolean isChunkGenerated(int x, int z) {
|
||||
try {
|
||||
return isChunkLoaded(x, z) || world.getChunkSource().chunkMap.read(new ChunkCoordIntPair(x, z)) != null;
|
||||
} catch (IOException ex) {
|
||||
return isChunkLoaded(x, z) || world.getChunkSource().chunkMap.read(new ChunkCoordIntPair(x, z)).get().isPresent();
|
||||
} catch (InterruptedException | ExecutionException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
@@ -1314,7 +1315,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public boolean canGenerateStructures() {
|
||||
return world.serverLevelData.worldGenSettings().generateFeatures();
|
||||
return world.serverLevelData.worldGenSettings().generateStructures();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1556,7 +1557,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
double y = loc.getY();
|
||||
double z = loc.getZ();
|
||||
|
||||
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), SoundCategory.valueOf(category.name()), new Vec3D(x, y, z), volume, pitch);
|
||||
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), SoundCategory.valueOf(category.name()), new Vec3D(x, y, z), volume, pitch, getHandle().getRandom().nextLong());
|
||||
world.getServer().getPlayerList().broadcast(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension(), packet);
|
||||
}
|
||||
|
||||
@@ -1569,7 +1570,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
public void playSound(Entity entity, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
|
||||
if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return;
|
||||
|
||||
PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch);
|
||||
PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, getHandle().getRandom().nextLong());
|
||||
PlayerChunkMap.EntityTracker entityTracker = getHandle().getChunkSource().chunkMap.entityMap.get(entity.getEntityId());
|
||||
if (entityTracker != null) {
|
||||
entityTracker.broadcastAndSend(packet);
|
||||
@@ -1778,7 +1779,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
@Override
|
||||
public Location locateNearestStructure(Location origin, StructureType structureType, int radius, boolean findUnexplored) {
|
||||
BlockPosition originPos = new BlockPosition(origin.getX(), origin.getY(), origin.getZ());
|
||||
BlockPosition nearest = getHandle().findNearestMapFeature(TagKey.create(IRegistry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY, CraftNamespacedKey.toMinecraft(structureType.getKey())), originPos, radius, findUnexplored);
|
||||
BlockPosition nearest = getHandle().findNearestMapStructure(TagKey.create(IRegistry.STRUCTURE_REGISTRY, CraftNamespacedKey.toMinecraft(structureType.getKey())), originPos, radius, findUnexplored);
|
||||
return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ());
|
||||
}
|
||||
|
||||
|
||||
@@ -181,11 +181,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 ***");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.entity.animal.EntityBee;
|
||||
import net.minecraft.world.level.GeneratorAccessSeed;
|
||||
@@ -29,7 +29,7 @@ public final class CapturedBlockState extends CraftBlockState {
|
||||
if (this.treeBlock && getType() == Material.BEE_NEST) {
|
||||
GeneratorAccessSeed generatoraccessseed = this.world.getHandle();
|
||||
BlockPosition blockposition1 = this.getPosition();
|
||||
Random random = generatoraccessseed.getRandom();
|
||||
RandomSource random = generatoraccessseed.getRandom();
|
||||
|
||||
// Begin copied block from WorldGenFeatureTreeBeehive
|
||||
TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition1);
|
||||
|
||||
@@ -11,7 +11,9 @@ 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.SculkCatalystBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SculkSensorBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SculkShriekerBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntityBanner;
|
||||
import net.minecraft.world.level.block.entity.TileEntityBarrel;
|
||||
@@ -130,6 +132,8 @@ public final class CraftBlockStates {
|
||||
Material.DARK_OAK_WALL_SIGN,
|
||||
Material.JUNGLE_SIGN,
|
||||
Material.JUNGLE_WALL_SIGN,
|
||||
Material.MANGROVE_SIGN,
|
||||
Material.MANGROVE_WALL_SIGN,
|
||||
Material.OAK_SIGN,
|
||||
Material.OAK_WALL_SIGN,
|
||||
Material.SPRUCE_SIGN,
|
||||
@@ -279,7 +283,9 @@ public final class CraftBlockStates {
|
||||
register(Material.JUKEBOX, CraftJukebox.class, CraftJukebox::new, TileEntityJukeBox::new);
|
||||
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.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);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.world.level.block.entity.SculkCatalystBlockEntity;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.SculkCatalyst;
|
||||
|
||||
public class CraftSculkCatalyst extends CraftBlockEntityState<SculkCatalystBlockEntity> implements SculkCatalyst {
|
||||
|
||||
public CraftSculkCatalyst(World world, SculkCatalystBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.world.level.block.entity.SculkShriekerBlockEntity;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.SculkShrieker;
|
||||
|
||||
public class CraftSculkShrieker extends CraftBlockEntityState<SculkShriekerBlockEntity> implements SculkShrieker {
|
||||
|
||||
public CraftSculkShrieker(World world, SculkShriekerBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarningLevel() {
|
||||
return getSnapshot().warningLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWarningLevel(int level) {
|
||||
getSnapshot().warningLevel = level;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.network.chat.ChatComponentText;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.world.item.EnumColor;
|
||||
import net.minecraft.world.level.block.entity.TileEntitySign;
|
||||
import org.bukkit.DyeColor;
|
||||
@@ -109,7 +107,7 @@ public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements
|
||||
if (i < lines.length && lines[i] != null) {
|
||||
components[i] = CraftChatMessage.fromString(lines[i])[0];
|
||||
} else {
|
||||
components[i] = new ChatComponentText("");
|
||||
components[i] = IChatBaseComponent.empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -477,9 +477,15 @@ public class CraftBlockData implements BlockData {
|
||||
register(net.minecraft.world.level.block.LayeredCauldronBlock.class, org.bukkit.craftbukkit.block.impl.CraftLayeredCauldron::new);
|
||||
register(net.minecraft.world.level.block.LightBlock.class, org.bukkit.craftbukkit.block.impl.CraftLight::new);
|
||||
register(net.minecraft.world.level.block.LightningRodBlock.class, org.bukkit.craftbukkit.block.impl.CraftLightningRod::new);
|
||||
register(net.minecraft.world.level.block.MangroveLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangroveLeaves::new);
|
||||
register(net.minecraft.world.level.block.MangrovePropaguleBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangrovePropagule::new);
|
||||
register(net.minecraft.world.level.block.MangroveRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangroveRoots::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);
|
||||
register(net.minecraft.world.level.block.SculkSensorBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkSensor::new);
|
||||
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.TallSeagrassBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallSeagrass::new);
|
||||
register(net.minecraft.world.level.block.WeatheringCopperSlabBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperSlab::new);
|
||||
@@ -510,11 +516,11 @@ public class CraftBlockData implements BlockData {
|
||||
}
|
||||
|
||||
StringReader reader = new StringReader(data);
|
||||
ArgumentBlock arg = new ArgumentBlock(reader, false).parse(false);
|
||||
ArgumentBlock.a arg = ArgumentBlock.parseForBlock(IRegistry.BLOCK, reader, false);
|
||||
Preconditions.checkArgument(!reader.canRead(), "Spurious trailing data: " + data);
|
||||
|
||||
blockData = arg.getState();
|
||||
parsed = arg.getProperties();
|
||||
blockData = arg.blockState();
|
||||
parsed = arg.properties();
|
||||
} catch (CommandSyntaxException ex) {
|
||||
throw new IllegalArgumentException("Could not parse data: " + data, ex);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.SculkCatalyst;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftSculkCatalyst extends CraftBlockData implements SculkCatalyst {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean BLOOM = getBoolean("bloom");
|
||||
|
||||
@Override
|
||||
public boolean isBloom() {
|
||||
return get(BLOOM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBloom(boolean bloom) {
|
||||
set(BLOOM, bloom);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.SculkShrieker;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftSculkShrieker extends CraftBlockData implements SculkShrieker {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean CAN_SUMMON = getBoolean("can_summon");
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean SHRIEKING = getBoolean("shrieking");
|
||||
|
||||
@Override
|
||||
public boolean isCanSummon() {
|
||||
return get(CAN_SUMMON);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanSummon(boolean can_summon) {
|
||||
set(CAN_SUMMON, can_summon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShrieking() {
|
||||
return get(SHRIEKING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShrieking(boolean shrieking) {
|
||||
set(SHRIEKING, shrieking);
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
*/
|
||||
package org.bukkit.craftbukkit.block.impl;
|
||||
|
||||
import org.bukkit.block.data.type.BigDripleaf.Tilt;
|
||||
|
||||
public final class CraftBigDripleaf extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.BigDripleaf, org.bukkit.block.data.type.Dripleaf, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged {
|
||||
|
||||
public CraftBigDripleaf() {
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/**
|
||||
* Automatically generated file, changes will be lost.
|
||||
*/
|
||||
package org.bukkit.craftbukkit.block.impl;
|
||||
|
||||
public final class CraftCauldron extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Levelled {
|
||||
|
||||
public CraftCauldron() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CraftCauldron(net.minecraft.world.level.block.state.IBlockData state) {
|
||||
super(state);
|
||||
}
|
||||
|
||||
// org.bukkit.craftbukkit.block.data.CraftLevelled
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger LEVEL = getInteger(net.minecraft.world.level.block.BlockCauldron.class, "level");
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return get(LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLevel(int level) {
|
||||
set(LEVEL, level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumLevel() {
|
||||
return getMax(LEVEL);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
package org.bukkit.craftbukkit.block.impl;
|
||||
|
||||
public final class CraftLantern extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Lantern, org.bukkit.block.data.Waterlogged {
|
||||
public final class CraftLantern extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Lantern, org.bukkit.block.data.Hangable, org.bukkit.block.data.Waterlogged {
|
||||
|
||||
public CraftLantern() {
|
||||
super();
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Automatically generated file, changes will be lost.
|
||||
*/
|
||||
package org.bukkit.craftbukkit.block.impl;
|
||||
|
||||
public final class CraftMangroveLeaves extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Leaves {
|
||||
|
||||
public CraftMangroveLeaves() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CraftMangroveLeaves(net.minecraft.world.level.block.state.IBlockData state) {
|
||||
super(state);
|
||||
}
|
||||
|
||||
// org.bukkit.craftbukkit.block.data.type.CraftLeaves
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger DISTANCE = getInteger(net.minecraft.world.level.block.MangroveLeavesBlock.class, "distance");
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean PERSISTENT = getBoolean(net.minecraft.world.level.block.MangroveLeavesBlock.class, "persistent");
|
||||
|
||||
@Override
|
||||
public boolean isPersistent() {
|
||||
return get(PERSISTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPersistent(boolean persistent) {
|
||||
set(PERSISTENT, persistent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistance() {
|
||||
return get(DISTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDistance(int distance) {
|
||||
set(DISTANCE, distance);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Automatically generated file, changes will be lost.
|
||||
*/
|
||||
package org.bukkit.craftbukkit.block.impl;
|
||||
|
||||
public final class CraftMangrovePropagule extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.MangrovePropagule, org.bukkit.block.data.Ageable, org.bukkit.block.data.type.Sapling, org.bukkit.block.data.Waterlogged {
|
||||
|
||||
public CraftMangrovePropagule() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CraftMangrovePropagule(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.MangrovePropaguleBlock.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.type.CraftSapling
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger STAGE = getInteger(net.minecraft.world.level.block.MangrovePropaguleBlock.class, "stage");
|
||||
|
||||
@Override
|
||||
public int getStage() {
|
||||
return get(STAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStage(int stage) {
|
||||
set(STAGE, stage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumStage() {
|
||||
return getMax(STAGE);
|
||||
}
|
||||
|
||||
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.MangrovePropaguleBlock.class, "waterlogged");
|
||||
|
||||
@Override
|
||||
public boolean isWaterlogged() {
|
||||
return get(WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWaterlogged(boolean waterlogged) {
|
||||
set(WATERLOGGED, waterlogged);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Automatically generated file, changes will be lost.
|
||||
*/
|
||||
package org.bukkit.craftbukkit.block.impl;
|
||||
|
||||
public final class CraftMangroveRoots extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Waterlogged {
|
||||
|
||||
public CraftMangroveRoots() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CraftMangroveRoots(net.minecraft.world.level.block.state.IBlockData state) {
|
||||
super(state);
|
||||
}
|
||||
|
||||
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.MangroveRootsBlock.class, "waterlogged");
|
||||
|
||||
@Override
|
||||
public boolean isWaterlogged() {
|
||||
return get(WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWaterlogged(boolean waterlogged) {
|
||||
set(WATERLOGGED, waterlogged);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Automatically generated file, changes will be lost.
|
||||
*/
|
||||
package org.bukkit.craftbukkit.block.impl;
|
||||
|
||||
public final class CraftSculkCatalyst extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.SculkCatalyst {
|
||||
|
||||
public CraftSculkCatalyst() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CraftSculkCatalyst(net.minecraft.world.level.block.state.IBlockData state) {
|
||||
super(state);
|
||||
}
|
||||
|
||||
// org.bukkit.craftbukkit.block.data.type.CraftSculkCatalyst
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean BLOOM = getBoolean(net.minecraft.world.level.block.SculkCatalystBlock.class, "bloom");
|
||||
|
||||
@Override
|
||||
public boolean isBloom() {
|
||||
return get(BLOOM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBloom(boolean bloom) {
|
||||
set(BLOOM, bloom);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Automatically generated file, changes will be lost.
|
||||
*/
|
||||
package org.bukkit.craftbukkit.block.impl;
|
||||
|
||||
public final class CraftSculkShrieker extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.SculkShrieker, org.bukkit.block.data.Waterlogged {
|
||||
|
||||
public CraftSculkShrieker() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CraftSculkShrieker(net.minecraft.world.level.block.state.IBlockData state) {
|
||||
super(state);
|
||||
}
|
||||
|
||||
// org.bukkit.craftbukkit.block.data.type.CraftSculkShrieker
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean CAN_SUMMON = getBoolean(net.minecraft.world.level.block.SculkShriekerBlock.class, "can_summon");
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean SHRIEKING = getBoolean(net.minecraft.world.level.block.SculkShriekerBlock.class, "shrieking");
|
||||
|
||||
@Override
|
||||
public boolean isCanSummon() {
|
||||
return get(CAN_SUMMON);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanSummon(boolean can_summon) {
|
||||
set(CAN_SUMMON, can_summon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShrieking() {
|
||||
return get(SHRIEKING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShrieking(boolean shrieking) {
|
||||
set(SHRIEKING, shrieking);
|
||||
}
|
||||
|
||||
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.SculkShriekerBlock.class, "waterlogged");
|
||||
|
||||
@Override
|
||||
public boolean isWaterlogged() {
|
||||
return get(WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWaterlogged(boolean waterlogged) {
|
||||
set(WATERLOGGED, waterlogged);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Automatically generated file, changes will be lost.
|
||||
*/
|
||||
package org.bukkit.craftbukkit.block.impl;
|
||||
|
||||
public final class CraftSculkVein extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Waterlogged {
|
||||
|
||||
public CraftSculkVein() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CraftSculkVein(net.minecraft.world.level.block.state.IBlockData state) {
|
||||
super(state);
|
||||
}
|
||||
|
||||
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.SculkVeinBlock.class, "waterlogged");
|
||||
|
||||
@Override
|
||||
public boolean isWaterlogged() {
|
||||
return get(WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWaterlogged(boolean waterlogged) {
|
||||
set(WATERLOGGED, waterlogged);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.bukkit.craftbukkit.command;
|
||||
|
||||
import net.minecraft.SystemUtils;
|
||||
import net.minecraft.commands.CommandListenerWrapper;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
@@ -30,7 +29,7 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
for (IChatBaseComponent component : CraftChatMessage.fromString(message)) {
|
||||
block.source.sendMessage(component, SystemUtils.NIL_UUID);
|
||||
block.source.sendSystemMessage(component);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.bukkit.craftbukkit.command;
|
||||
|
||||
import net.minecraft.SystemUtils;
|
||||
import net.minecraft.network.chat.ChatComponentText;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.server.rcon.RemoteControlCommandListener;
|
||||
import org.bukkit.command.RemoteConsoleCommandSender;
|
||||
|
||||
@@ -15,7 +14,7 @@ public class CraftRemoteConsoleCommandSender extends ServerCommandSender impleme
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
listener.sendMessage(new ChatComponentText(message + "\n"), SystemUtils.NIL_UUID); // Send a newline after each message, to preserve formatting.
|
||||
listener.sendSystemMessage(IChatBaseComponent.literal(message + "\n")); // Send a newline after each message, to preserve formatting.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,7 +42,7 @@ public final class VanillaCommandWrapper extends BukkitCommand {
|
||||
if (!testPermission(sender)) return true;
|
||||
|
||||
CommandListenerWrapper icommandlistener = getListener(sender);
|
||||
dispatcher.performCommand(icommandlistener, toDispatcher(args, getName()), toDispatcher(args, commandLabel), true);
|
||||
dispatcher.performPrefixedCommand(icommandlistener, toDispatcher(args, getName()), toDispatcher(args, commandLabel));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -159,6 +159,8 @@ public class CraftEnchantment extends Enchantment {
|
||||
return "MENDING";
|
||||
case 37:
|
||||
return "VANISHING_CURSE";
|
||||
case 38:
|
||||
return "SWIFT_SNEAK";
|
||||
default:
|
||||
return "UNKNOWN_ENCHANT_" + IRegistry.ENCHANTMENT.getId(target);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.world.entity.animal.allay.Allay;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftAllay extends CraftCreature implements org.bukkit.entity.Allay {
|
||||
|
||||
public CraftAllay(CraftServer server, Allay entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Allay getHandle() {
|
||||
return (Allay) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftAllay";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.ALLAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return new CraftInventory(getHandle().getInventory());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.world.entity.animal.CatVariant;
|
||||
import net.minecraft.world.entity.animal.EntityCat;
|
||||
import net.minecraft.world.item.EnumColor;
|
||||
import org.bukkit.DyeColor;
|
||||
@@ -32,14 +34,14 @@ public class CraftCat extends CraftTameableAnimal implements Cat {
|
||||
|
||||
@Override
|
||||
public Type getCatType() {
|
||||
return Type.values()[getHandle().getCatType()];
|
||||
return Type.values()[IRegistry.CAT_VARIANT.getId(getHandle().getCatVariant())];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCatType(Type type) {
|
||||
Preconditions.checkArgument(type != null, "Cannot have null Type");
|
||||
|
||||
getHandle().setCatType(type.ordinal());
|
||||
getHandle().setCatVariant(IRegistry.CAT_VARIANT.byId(type.ordinal()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.world.entity.vehicle.ChestBoat;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.loot.LootTable;
|
||||
|
||||
public class CraftChestBoat extends CraftBoat implements org.bukkit.entity.ChestBoat {
|
||||
|
||||
private final Inventory inventory;
|
||||
|
||||
public CraftChestBoat(CraftServer server, ChestBoat entity) {
|
||||
super(server, entity);
|
||||
inventory = new CraftInventory(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChestBoat getHandle() {
|
||||
return (ChestBoat) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftChestBoat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.CHEST_BOAT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLootTable(LootTable table) {
|
||||
setLootTable(table, getSeed());
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTable getLootTable() {
|
||||
MinecraftKey nmsTable = getHandle().getLootTable();
|
||||
if (nmsTable == null) {
|
||||
return null; // return empty loot table?
|
||||
}
|
||||
|
||||
NamespacedKey key = CraftNamespacedKey.fromMinecraft(nmsTable);
|
||||
return Bukkit.getLootTable(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSeed(long seed) {
|
||||
setLootTable(getLootTable(), seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSeed() {
|
||||
return getHandle().getLootTableSeed();
|
||||
}
|
||||
|
||||
private void setLootTable(LootTable table, long seed) {
|
||||
MinecraftKey newKey = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey());
|
||||
getHandle().setLootTable(newKey);
|
||||
getHandle().setLootTableSeed(seed);
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,10 @@ import net.minecraft.world.entity.animal.EntityTropicalFish;
|
||||
import net.minecraft.world.entity.animal.EntityTurtle;
|
||||
import net.minecraft.world.entity.animal.EntityWaterAnimal;
|
||||
import net.minecraft.world.entity.animal.EntityWolf;
|
||||
import net.minecraft.world.entity.animal.allay.Allay;
|
||||
import net.minecraft.world.entity.animal.axolotl.Axolotl;
|
||||
import net.minecraft.world.entity.animal.frog.Frog;
|
||||
import net.minecraft.world.entity.animal.frog.Tadpole;
|
||||
import net.minecraft.world.entity.animal.goat.Goat;
|
||||
import net.minecraft.world.entity.animal.horse.EntityHorse;
|
||||
import net.minecraft.world.entity.animal.horse.EntityHorseAbstract;
|
||||
@@ -118,6 +121,7 @@ import net.minecraft.world.entity.monster.hoglin.EntityHoglin;
|
||||
import net.minecraft.world.entity.monster.piglin.EntityPiglin;
|
||||
import net.minecraft.world.entity.monster.piglin.EntityPiglinAbstract;
|
||||
import net.minecraft.world.entity.monster.piglin.EntityPiglinBrute;
|
||||
import net.minecraft.world.entity.monster.warden.Warden;
|
||||
import net.minecraft.world.entity.npc.EntityVillager;
|
||||
import net.minecraft.world.entity.npc.EntityVillagerAbstract;
|
||||
import net.minecraft.world.entity.npc.EntityVillagerTrader;
|
||||
@@ -143,6 +147,7 @@ import net.minecraft.world.entity.projectile.EntityThrownExpBottle;
|
||||
import net.minecraft.world.entity.projectile.EntityThrownTrident;
|
||||
import net.minecraft.world.entity.projectile.EntityTippedArrow;
|
||||
import net.minecraft.world.entity.projectile.EntityWitherSkull;
|
||||
import net.minecraft.world.entity.vehicle.ChestBoat;
|
||||
import net.minecraft.world.entity.vehicle.EntityBoat;
|
||||
import net.minecraft.world.entity.vehicle.EntityMinecartAbstract;
|
||||
import net.minecraft.world.entity.vehicle.EntityMinecartChest;
|
||||
@@ -218,6 +223,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else if (entity instanceof EntityPufferFish) { return new CraftPufferFish(server, (EntityPufferFish) entity); }
|
||||
else if (entity instanceof EntitySalmon) { return new CraftSalmon(server, (EntitySalmon) entity); }
|
||||
else if (entity instanceof EntityTropicalFish) { return new CraftTropicalFish(server, (EntityTropicalFish) entity); }
|
||||
else if (entity instanceof Tadpole) { return new CraftTadpole(server, (Tadpole) entity); }
|
||||
else { return new CraftFish(server, (EntityFish) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityDolphin) { return new CraftDolphin(server, (EntityDolphin) entity); }
|
||||
@@ -259,6 +265,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else if (entity instanceof EntityStrider) { return new CraftStrider(server, (EntityStrider) entity); }
|
||||
else if (entity instanceof Axolotl) { return new CraftAxolotl(server, (Axolotl) entity); }
|
||||
else if (entity instanceof Goat) { return new CraftGoat(server, (Goat) entity); }
|
||||
else if (entity instanceof Frog) { return new CraftFrog(server, (Frog) entity); }
|
||||
else { return new CraftAnimals(server, (EntityAnimal) entity); }
|
||||
}
|
||||
// Monsters
|
||||
@@ -309,6 +316,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else { return new CraftPiglinAbstract(server, (EntityPiglinAbstract) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityZoglin) { return new CraftZoglin(server, (EntityZoglin) entity); }
|
||||
else if (entity instanceof Warden) { return new CraftWarden(server, (Warden) entity); }
|
||||
|
||||
else { return new CraftMonster(server, (EntityMonster) entity); }
|
||||
}
|
||||
@@ -322,6 +330,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else if (entity instanceof EntityVillagerTrader) { return new CraftWanderingTrader(server, (EntityVillagerTrader) entity); }
|
||||
else { return new CraftAbstractVillager(server, (EntityVillagerAbstract) entity); }
|
||||
}
|
||||
else if (entity instanceof Allay) { return new CraftAllay(server, (Allay) entity); }
|
||||
else { return new CraftCreature(server, (EntityCreature) entity); }
|
||||
}
|
||||
// Slimes are a special (and broken) case
|
||||
@@ -358,7 +367,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
if (entity instanceof EntityThrownTrident) { return new CraftTrident(server, (EntityThrownTrident) entity); }
|
||||
else { return new CraftArrow(server, (EntityArrow) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityBoat) { return new CraftBoat(server, (EntityBoat) entity); }
|
||||
else if (entity instanceof EntityBoat) {
|
||||
if (entity instanceof ChestBoat) { return new CraftChestBoat(server, (ChestBoat) entity); }
|
||||
else { return new CraftBoat(server, (EntityBoat) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityProjectile) {
|
||||
if (entity instanceof EntityEgg) { return new CraftEgg(server, (EntityEgg) entity); }
|
||||
else if (entity instanceof EntitySnowball) { return new CraftSnowball(server, (EntitySnowball) entity); }
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.world.entity.animal.frog.Frog;
|
||||
import org.bukkit.Registry;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class CraftFrog extends CraftAnimals implements org.bukkit.entity.Frog {
|
||||
|
||||
public CraftFrog(CraftServer server, Frog entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Frog getHandle() {
|
||||
return (Frog) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftFrog";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.FROG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getTongueTarget() {
|
||||
return getHandle().getTongueTarget().map(net.minecraft.world.entity.Entity::getBukkitEntity).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTongueTarget(Entity target) {
|
||||
if (target == null) {
|
||||
getHandle().eraseTongueTarget();
|
||||
} else {
|
||||
getHandle().setTongueTarget(((CraftEntity) target).getHandle());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Variant getVariant() {
|
||||
return Registry.FROG_VARIANT.get(CraftNamespacedKey.fromMinecraft(IRegistry.FROG_VARIANT.getKey(getHandle().getVariant())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVariant(Variant variant) {
|
||||
Preconditions.checkArgument(variant != null, "variant");
|
||||
|
||||
getHandle().setVariant(IRegistry.FROG_VARIANT.get(CraftNamespacedKey.toMinecraft(variant.getKey())));
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,26 @@ public class CraftGoat extends CraftAnimals implements Goat {
|
||||
return "CraftGoat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLeftHorn() {
|
||||
return getHandle().hasLeftHorn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeftHorn(boolean hasHorn) {
|
||||
getHandle().getEntityData().set(net.minecraft.world.entity.animal.goat.Goat.DATA_HAS_LEFT_HORN, hasHorn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRightHorn() {
|
||||
return getHandle().hasRightHorn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRightHorn(boolean hasHorn) {
|
||||
getHandle().getEntityData().set(net.minecraft.world.entity.animal.goat.Goat.DATA_HAS_RIGHT_HORN, hasHorn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScreaming() {
|
||||
return getHandle().isScreamingGoat();
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.world.entity.decoration.EntityPainting;
|
||||
import net.minecraft.world.entity.decoration.Paintings;
|
||||
import net.minecraft.world.entity.decoration.PaintingVariant;
|
||||
import org.bukkit.Art;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.CraftArt;
|
||||
@@ -17,7 +18,7 @@ public class CraftPainting extends CraftHanging implements Painting {
|
||||
|
||||
@Override
|
||||
public Art getArt() {
|
||||
Paintings art = getHandle().motive;
|
||||
Holder<PaintingVariant> art = getHandle().getVariant();
|
||||
return CraftArt.NotchToBukkit(art);
|
||||
}
|
||||
|
||||
@@ -29,12 +30,12 @@ public class CraftPainting extends CraftHanging implements Painting {
|
||||
@Override
|
||||
public boolean setArt(Art art, boolean force) {
|
||||
EntityPainting painting = this.getHandle();
|
||||
Paintings oldArt = painting.motive;
|
||||
painting.motive = CraftArt.BukkitToNotch(art);
|
||||
Holder<PaintingVariant> oldArt = painting.getVariant();
|
||||
painting.setVariant(CraftArt.BukkitToNotch(art));
|
||||
painting.setDirection(painting.getDirection());
|
||||
if (!force && !getHandle().generation && !painting.survives()) {
|
||||
// Revert painting since it doesn't fit
|
||||
painting.motive = oldArt;
|
||||
painting.setVariant(oldArt);
|
||||
painting.setDirection(painting.getDirection());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -26,14 +26,14 @@ import java.util.WeakHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.SystemUtils;
|
||||
import net.minecraft.advancements.AdvancementProgress;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketDataSerializer;
|
||||
import net.minecraft.network.chat.ChatComponentText;
|
||||
import net.minecraft.network.chat.ChatMessageType;
|
||||
import net.minecraft.network.chat.ChatSender;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.network.chat.PlayerChatMessage;
|
||||
import net.minecraft.network.protocol.game.ClientboundClearTitlesPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetBorderCenterPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetBorderLerpSizePacket;
|
||||
@@ -45,7 +45,6 @@ import net.minecraft.network.protocol.game.ClientboundSetTitleTextPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetTitlesAnimationPacket;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutBlockBreakAnimation;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutBlockChange;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutChat;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutCustomPayload;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutCustomSoundEffect;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment;
|
||||
@@ -85,7 +84,6 @@ import net.minecraft.world.level.border.IWorldBorderListener;
|
||||
import net.minecraft.world.level.saveddata.maps.MapIcon;
|
||||
import net.minecraft.world.level.saveddata.maps.WorldMap;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.BanList;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -231,7 +229,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
if (getHandle().connection == null) return;
|
||||
|
||||
for (IChatBaseComponent component : CraftChatMessage.fromString(message)) {
|
||||
getHandle().connection.send(new PacketPlayOutChat(component, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID));
|
||||
getHandle().sendSystemMessage(component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +238,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
if (getHandle().connection == null) return;
|
||||
|
||||
for (IChatBaseComponent component : CraftChatMessage.fromString(message)) {
|
||||
getHandle().connection.send(new PacketPlayOutChat(component, ChatMessageType.CHAT, (sender == null) ? SystemUtils.NIL_UUID : sender));
|
||||
getHandle().sendSystemMessage(component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +333,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
private void updatePlayerListHeaderFooter() {
|
||||
if (getHandle().connection == null) return;
|
||||
|
||||
PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter((this.playerListHeader == null) ? new ChatComponentText("") : this.playerListHeader, (this.playerListFooter == null) ? new ChatComponentText("") : this.playerListFooter);
|
||||
PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter((this.playerListHeader == null) ? IChatBaseComponent.empty() : this.playerListHeader, (this.playerListFooter == null) ? IChatBaseComponent.empty() : this.playerListFooter);
|
||||
getHandle().connection.send(packet);
|
||||
}
|
||||
|
||||
@@ -430,7 +428,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
|
||||
float f = (float) Math.pow(2.0D, (note - 12.0D) / 12.0D);
|
||||
getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
|
||||
getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, getHandle().getRandom().nextLong()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -492,7 +490,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
break;
|
||||
}
|
||||
float f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D);
|
||||
getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
|
||||
getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, getHandle().getRandom().nextLong()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -509,7 +507,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
|
||||
if (loc == null || sound == null || category == null || getHandle().connection == null) return;
|
||||
|
||||
PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch);
|
||||
PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch, getHandle().getRandom().nextLong());
|
||||
getHandle().connection.send(packet);
|
||||
}
|
||||
|
||||
@@ -517,7 +515,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch) {
|
||||
if (loc == null || sound == null || category == null || getHandle().connection == null) return;
|
||||
|
||||
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), new Vec3D(loc.getX(), loc.getY(), loc.getZ()), volume, pitch);
|
||||
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), new Vec3D(loc.getX(), loc.getY(), loc.getZ()), volume, pitch, getHandle().getRandom().nextLong());
|
||||
getHandle().connection.send(packet);
|
||||
}
|
||||
|
||||
@@ -530,7 +528,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void playSound(org.bukkit.entity.Entity entity, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
|
||||
if (!(entity instanceof CraftEntity craftEntity) || sound == null || category == null || getHandle().connection == null) return;
|
||||
|
||||
PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch);
|
||||
PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, getHandle().getRandom().nextLong());
|
||||
getHandle().connection.send(packet);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.world.entity.animal.frog.Tadpole;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class CraftTadpole extends CraftFish implements org.bukkit.entity.Tadpole {
|
||||
|
||||
public CraftTadpole(CraftServer server, Tadpole entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tadpole getHandle() {
|
||||
return (Tadpole) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftTadpole";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.TADPOLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAge() {
|
||||
return getHandle().age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAge(int age) {
|
||||
getHandle().age = age;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.world.entity.monster.warden.Warden;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class CraftWarden extends CraftMonster implements org.bukkit.entity.Warden {
|
||||
|
||||
public CraftWarden(CraftServer server, Warden entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Warden getHandle() {
|
||||
return (Warden) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftWarden";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.WARDEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAnger(Entity entity) {
|
||||
Preconditions.checkArgument(entity != null, "Entity cannot be null");
|
||||
|
||||
return getHandle().getAngerManagement().getActiveAnger(((CraftEntity) entity).getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void increaseAnger(Entity entity, int increase) {
|
||||
Preconditions.checkArgument(entity != null, "Entity cannot be null");
|
||||
|
||||
getHandle().getAngerManagement().increaseAnger(((CraftEntity) entity).getHandle(), increase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnger(Entity entity, int anger) {
|
||||
Preconditions.checkArgument(entity != null, "Entity cannot be null");
|
||||
|
||||
getHandle().clearAnger(((CraftEntity) entity).getHandle());
|
||||
getHandle().getAngerManagement().increaseAnger(((CraftEntity) entity).getHandle(), anger);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public class CraftWorldInfo implements WorldInfo {
|
||||
|
||||
public CraftWorldInfo(IWorldDataServer worldDataServer, Convertable.ConversionSession session, World.Environment environment, DimensionManager dimensionManager) {
|
||||
this.name = worldDataServer.getLevelName();
|
||||
this.uuid = WorldUUID.getUUID(session.levelPath.toFile());
|
||||
this.uuid = WorldUUID.getUUID(session.levelDirectory.path().toFile());
|
||||
this.environment = environment;
|
||||
this.seed = ((WorldDataServer) worldDataServer).worldGenSettings().seed();
|
||||
this.minHeight = dimensionManager.minY();
|
||||
|
||||
@@ -8,21 +8,18 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.core.IRegistryCustom;
|
||||
import net.minecraft.server.level.RegionLimitedWorldAccess;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.util.random.WeightedRandomList;
|
||||
import net.minecraft.world.entity.EnumCreatureType;
|
||||
import net.minecraft.world.level.BlockColumn;
|
||||
import net.minecraft.world.level.ChunkCoordIntPair;
|
||||
import net.minecraft.world.level.GeneratorAccessSeed;
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
import net.minecraft.world.level.StructureManager;
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
import net.minecraft.world.level.biome.BiomeManager;
|
||||
import net.minecraft.world.level.biome.BiomeSettingsMobs;
|
||||
import net.minecraft.world.level.biome.Climate;
|
||||
import net.minecraft.world.level.biome.WorldChunkManager;
|
||||
import net.minecraft.world.level.block.ITileEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
@@ -32,13 +29,15 @@ import net.minecraft.world.level.chunk.IChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.levelgen.HeightMap;
|
||||
import net.minecraft.world.level.levelgen.LegacyRandomSource;
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
import net.minecraft.world.level.levelgen.SeededRandom;
|
||||
import net.minecraft.world.level.levelgen.WorldGenStage;
|
||||
import net.minecraft.world.level.levelgen.blending.Blender;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.DefinedStructureManager;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.craftbukkit.CraftHeightMap;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.util.RandomSourceWrapper;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||
@@ -97,11 +96,6 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
return new SeededRandom(new LegacyRandomSource(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.level.chunk.ChunkGenerator withSeed(long i) {
|
||||
return new CustomChunkGenerator(this.world, delegate.withSeed(i), this.generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldChunkManager getBiomeSource() {
|
||||
return delegate.getBiomeSource();
|
||||
@@ -118,16 +112,16 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createStructures(IRegistryCustom iregistrycustom, StructureManager structuremanager, IChunkAccess ichunkaccess, DefinedStructureManager definedstructuremanager, long i) {
|
||||
public void createStructures(IRegistryCustom iregistrycustom, RandomState randomstate, StructureManager structuremanager, IChunkAccess ichunkaccess, StructureTemplateManager structuretemplatemanager, long i) {
|
||||
if (generator.shouldGenerateStructures()) {
|
||||
super.createStructures(iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i);
|
||||
super.createStructures(iregistrycustom, randomstate, structuremanager, ichunkaccess, structuretemplatemanager, i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildSurface(RegionLimitedWorldAccess regionlimitedworldaccess, StructureManager structuremanager, IChunkAccess ichunkaccess) {
|
||||
public void buildSurface(RegionLimitedWorldAccess regionlimitedworldaccess, StructureManager structuremanager, RandomState randomstate, IChunkAccess ichunkaccess) {
|
||||
if (generator.shouldGenerateSurface()) {
|
||||
delegate.buildSurface(regionlimitedworldaccess, structuremanager, ichunkaccess);
|
||||
delegate.buildSurface(regionlimitedworldaccess, structuremanager, randomstate, ichunkaccess);
|
||||
}
|
||||
|
||||
CraftChunkData chunkData = new CraftChunkData(this.world.getWorld(), ichunkaccess);
|
||||
@@ -135,7 +129,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
int x = ichunkaccess.getPos().x;
|
||||
int z = ichunkaccess.getPos().z;
|
||||
random.setSeed((long) x * 341873128712L + (long) z * 132897987541L);
|
||||
generator.generateSurface(this.world.getWorld(), random, x, z, chunkData);
|
||||
generator.generateSurface(this.world.getWorld(), new RandomSourceWrapper.RandomWrapper(random), x, z, chunkData);
|
||||
|
||||
if (generator.shouldGenerateBedrock()) {
|
||||
random = getSeededRandom();
|
||||
@@ -145,7 +139,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
|
||||
random = getSeededRandom();
|
||||
random.setSeed((long) x * 341873128712L + (long) z * 132897987541L);
|
||||
generator.generateBedrock(this.world.getWorld(), random, x, z, chunkData);
|
||||
generator.generateBedrock(this.world.getWorld(), new RandomSourceWrapper.RandomWrapper(random), x, z, chunkData);
|
||||
chunkData.breakLink();
|
||||
|
||||
// return if new api is used
|
||||
@@ -223,9 +217,9 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyCarvers(RegionLimitedWorldAccess regionlimitedworldaccess, long seed, BiomeManager biomemanager, StructureManager structuremanager, IChunkAccess ichunkaccess, WorldGenStage.Features worldgenstage_features) {
|
||||
public void applyCarvers(RegionLimitedWorldAccess regionlimitedworldaccess, long seed, RandomState randomstate, BiomeManager biomemanager, StructureManager structuremanager, IChunkAccess ichunkaccess, WorldGenStage.Features worldgenstage_features) {
|
||||
if (generator.shouldGenerateCaves()) {
|
||||
delegate.applyCarvers(regionlimitedworldaccess, seed, biomemanager, structuremanager, ichunkaccess, worldgenstage_features);
|
||||
delegate.applyCarvers(regionlimitedworldaccess, seed, randomstate, biomemanager, structuremanager, ichunkaccess, worldgenstage_features);
|
||||
}
|
||||
|
||||
if (worldgenstage_features == WorldGenStage.Features.LIQUID) { // stage check ensures that the method is only called once
|
||||
@@ -235,16 +229,16 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
int z = ichunkaccess.getPos().z;
|
||||
random.setDecorationSeed(seed, 0, 0);
|
||||
|
||||
generator.generateCaves(this.world.getWorld(), random, x, z, chunkData);
|
||||
generator.generateCaves(this.world.getWorld(), new RandomSourceWrapper.RandomWrapper(random), x, z, chunkData);
|
||||
chunkData.breakLink();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<IChunkAccess> fillFromNoise(Executor executor, Blender blender, StructureManager structuremanager, IChunkAccess ichunkaccess) {
|
||||
public CompletableFuture<IChunkAccess> fillFromNoise(Executor executor, Blender blender, RandomState randomstate, StructureManager structuremanager, IChunkAccess ichunkaccess) {
|
||||
CompletableFuture<IChunkAccess> future = null;
|
||||
if (generator.shouldGenerateNoise()) {
|
||||
future = delegate.fillFromNoise(executor, blender, structuremanager, ichunkaccess);
|
||||
future = delegate.fillFromNoise(executor, blender, randomstate, structuremanager, ichunkaccess);
|
||||
}
|
||||
|
||||
java.util.function.Function<IChunkAccess, IChunkAccess> function = (ichunkaccess1) -> {
|
||||
@@ -254,7 +248,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
int z = ichunkaccess1.getPos().z;
|
||||
random.setSeed((long) x * 341873128712L + (long) z * 132897987541L);
|
||||
|
||||
generator.generateNoise(this.world.getWorld(), random, x, z, chunkData);
|
||||
generator.generateNoise(this.world.getWorld(), new RandomSourceWrapper.RandomWrapper(random), x, z, chunkData);
|
||||
chunkData.breakLink();
|
||||
return ichunkaccess1;
|
||||
};
|
||||
@@ -263,7 +257,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBaseHeight(int i, int j, HeightMap.Type heightmap_type, LevelHeightAccessor levelheightaccessor) {
|
||||
public int getBaseHeight(int i, int j, HeightMap.Type heightmap_type, LevelHeightAccessor levelheightaccessor, RandomState randomstate) {
|
||||
if (implementBaseHeight) {
|
||||
try {
|
||||
SeededRandom random = getSeededRandom();
|
||||
@@ -271,13 +265,13 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
int zChunk = j >> 4;
|
||||
random.setSeed((long) xChunk * 341873128712L + (long) zChunk * 132897987541L);
|
||||
|
||||
return generator.getBaseHeight(this.world.getWorld(), random, i, j, CraftHeightMap.fromNMS(heightmap_type));
|
||||
return generator.getBaseHeight(this.world.getWorld(), new RandomSourceWrapper.RandomWrapper(random), i, j, CraftHeightMap.fromNMS(heightmap_type));
|
||||
} catch (UnsupportedOperationException exception) {
|
||||
implementBaseHeight = false;
|
||||
}
|
||||
}
|
||||
|
||||
return delegate.getBaseHeight(i, j, heightmap_type, levelheightaccessor);
|
||||
return delegate.getBaseHeight(i, j, heightmap_type, levelheightaccessor, randomstate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -291,8 +285,8 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDebugScreenInfo(List<String> list, BlockPosition blockposition) {
|
||||
delegate.addDebugScreenInfo(list, blockposition);
|
||||
public void addDebugScreenInfo(List<String> list, RandomState randomstate, BlockPosition blockposition) {
|
||||
delegate.addDebugScreenInfo(list, randomstate, blockposition);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -313,13 +307,8 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockColumn getBaseColumn(int i, int j, LevelHeightAccessor levelheightaccessor) {
|
||||
return delegate.getBaseColumn(i, j, levelheightaccessor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Climate.Sampler climateSampler() {
|
||||
return delegate.climateSampler();
|
||||
public BlockColumn getBaseColumn(int i, int j, LevelHeightAccessor levelheightaccessor, RandomState randomstate) {
|
||||
return delegate.getBaseColumn(i, j, levelheightaccessor, randomstate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -44,12 +44,6 @@ public class CustomWorldChunkManager extends WorldChunkManager {
|
||||
throw new UnsupportedOperationException("Cannot serialize CustomWorldChunkManager");
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldChunkManager withSeed(long l) {
|
||||
// TODO check method further
|
||||
throw new UnsupportedOperationException("Cannot copy CustomWorldChunkManager");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Holder<BiomeBase> getNoiseBiome(int x, int y, int z, Climate.Sampler sampler) {
|
||||
Biome biome = biomeProvider.getBiome(worldInfo, x << 2, y << 2, z << 2);
|
||||
|
||||
@@ -285,7 +285,7 @@ public class CraftContainer extends Container {
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(EntityHuman entityhuman, int i) {
|
||||
return (delegate != null) ? delegate.quickMoveStack(entityhuman, i) : super.quickMoveStack(entityhuman, i);
|
||||
return (delegate != null) ? delegate.quickMoveStack(entityhuman, i) : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.bukkit.craftbukkit.inventory;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.commands.arguments.item.ArgumentParserItemStack;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.item.Item;
|
||||
import org.apache.commons.lang.Validate;
|
||||
@@ -215,6 +217,8 @@ public final class CraftItemFactory implements ItemFactory {
|
||||
case DARK_OAK_WALL_SIGN:
|
||||
case JUNGLE_SIGN:
|
||||
case JUNGLE_WALL_SIGN:
|
||||
case MANGROVE_SIGN:
|
||||
case MANGROVE_WALL_SIGN:
|
||||
case OAK_SIGN:
|
||||
case OAK_WALL_SIGN:
|
||||
case SPRUCE_SIGN:
|
||||
@@ -261,6 +265,8 @@ public final class CraftItemFactory implements ItemFactory {
|
||||
case SMOKER:
|
||||
case BEEHIVE:
|
||||
case BEE_NEST:
|
||||
case SCULK_CATALYST:
|
||||
case SCULK_SHRIEKER:
|
||||
case SCULK_SENSOR:
|
||||
return new CraftMetaBlockState(meta, material);
|
||||
case TROPICAL_FISH_BUCKET:
|
||||
@@ -348,12 +354,12 @@ public final class CraftItemFactory implements ItemFactory {
|
||||
@Override
|
||||
public ItemStack createItemStack(String input) throws IllegalArgumentException {
|
||||
try {
|
||||
ArgumentParserItemStack arg = new ArgumentParserItemStack(new StringReader(input), false).parse(); // false = no tags
|
||||
ArgumentParserItemStack.a arg = ArgumentParserItemStack.parseForItem(HolderLookup.forRegistry(IRegistry.ITEM), new StringReader(input));
|
||||
|
||||
Item item = arg.getItem();
|
||||
Item item = arg.item().value();
|
||||
net.minecraft.world.item.ItemStack nmsItemStack = new net.minecraft.world.item.ItemStack(item);
|
||||
|
||||
NBTTagCompound nbt = arg.getNbt();
|
||||
NBTTagCompound nbt = arg.nbt();
|
||||
if (nbt != null) {
|
||||
nmsItemStack.setTag(nbt);
|
||||
}
|
||||
|
||||
@@ -480,6 +480,8 @@ public final class CraftItemStack extends ItemStack {
|
||||
case DARK_OAK_WALL_SIGN:
|
||||
case JUNGLE_SIGN:
|
||||
case JUNGLE_WALL_SIGN:
|
||||
case MANGROVE_SIGN:
|
||||
case MANGROVE_WALL_SIGN:
|
||||
case OAK_SIGN:
|
||||
case OAK_WALL_SIGN:
|
||||
case SPRUCE_SIGN:
|
||||
@@ -526,6 +528,8 @@ public final class CraftItemStack extends ItemStack {
|
||||
case SMOKER:
|
||||
case BEEHIVE:
|
||||
case BEE_NEST:
|
||||
case SCULK_CATALYST:
|
||||
case SCULK_SHRIEKER:
|
||||
case SCULK_SENSOR:
|
||||
return new CraftMetaBlockState(item.getTag(), CraftMagicNumbers.getMaterial(item.getItem()));
|
||||
case TROPICAL_FISH_BUCKET:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import net.minecraft.network.chat.ChatComponentText;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.sounds.SoundEffect;
|
||||
import net.minecraft.sounds.SoundEffects;
|
||||
@@ -39,7 +38,7 @@ public class CraftMerchantCustom extends CraftMerchant {
|
||||
|
||||
public MinecraftMerchant(String title) {
|
||||
Validate.notNull(title, "Title cannot be null");
|
||||
this.title = new ChatComponentText(title);
|
||||
this.title = IChatBaseComponent.literal(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -146,6 +146,8 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
||||
case DARK_OAK_WALL_SIGN:
|
||||
case JUNGLE_SIGN:
|
||||
case JUNGLE_WALL_SIGN:
|
||||
case MANGROVE_SIGN:
|
||||
case MANGROVE_WALL_SIGN:
|
||||
case OAK_SIGN:
|
||||
case OAK_WALL_SIGN:
|
||||
case SPRUCE_SIGN:
|
||||
@@ -192,6 +194,8 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
||||
case SMOKER:
|
||||
case BEEHIVE:
|
||||
case BEE_NEST:
|
||||
case SCULK_CATALYST:
|
||||
case SCULK_SHRIEKER:
|
||||
case SCULK_SENSOR:
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ import net.minecraft.nbt.NBTCompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.network.chat.ChatComponentText;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.world.entity.EnumItemSlot;
|
||||
import net.minecraft.world.item.ItemBlock;
|
||||
import org.apache.commons.lang.Validate;
|
||||
@@ -1329,7 +1329,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
throw new IllegalArgumentException(addFrom + " cannot contain non-string " + object.getClass().getName());
|
||||
}
|
||||
|
||||
addTo.add(CraftChatMessage.toJSON(new ChatComponentText("")));
|
||||
addTo.add(CraftChatMessage.toJSON(IChatBaseComponent.empty()));
|
||||
} else {
|
||||
String entry = object.toString();
|
||||
|
||||
|
||||
@@ -88,6 +88,8 @@ public class CraftPotionEffectType extends PotionEffectType {
|
||||
return "BAD_OMEN";
|
||||
case 32:
|
||||
return "HERO_OF_THE_VILLAGE";
|
||||
case 33:
|
||||
return "DARKNESS";
|
||||
default:
|
||||
return "UNKNOWN_EFFECT_TYPE_" + getId();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package org.bukkit.craftbukkit.projectiles;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.core.EnumDirection;
|
||||
import net.minecraft.core.IPosition;
|
||||
import net.minecraft.core.SourceBlock;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.entity.projectile.EntityArrow;
|
||||
import net.minecraft.world.entity.projectile.EntityEgg;
|
||||
@@ -105,7 +104,7 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
|
||||
double d0 = iposition.x() + (double) ((float) enumdirection.getStepX() * 0.3F);
|
||||
double d1 = iposition.y() + (double) ((float) enumdirection.getStepY() * 0.3F);
|
||||
double d2 = iposition.z() + (double) ((float) enumdirection.getStepZ() * 0.3F);
|
||||
Random random = world.random;
|
||||
RandomSource random = world.random;
|
||||
double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepX();
|
||||
double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepY();
|
||||
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepZ();
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.EnumBlockMirror;
|
||||
@@ -22,6 +23,7 @@ import org.bukkit.block.structure.Mirror;
|
||||
import org.bukkit.block.structure.StructureRotation;
|
||||
import org.bukkit.craftbukkit.CraftRegionAccessor;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.util.RandomSourceWrapper;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.structure.Palette;
|
||||
@@ -55,16 +57,17 @@ public class CraftStructure implements Structure {
|
||||
throw new IllegalArgumentException("Integrity must be between 0 and 1 inclusive. Was \"" + integrity + "\"");
|
||||
}
|
||||
|
||||
RandomSource randomSource = new RandomSourceWrapper(random);
|
||||
DefinedStructureInfo definedstructureinfo = new DefinedStructureInfo()
|
||||
.setMirror(EnumBlockMirror.valueOf(mirror.name()))
|
||||
.setRotation(EnumBlockRotation.valueOf(structureRotation.name()))
|
||||
.setIgnoreEntities(!includeEntities)
|
||||
.addProcessor(new DefinedStructureProcessorRotation(integrity))
|
||||
.setRandom(random);
|
||||
.setRandom(randomSource);
|
||||
definedstructureinfo.palette = palette;
|
||||
|
||||
BlockPosition blockPosition = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
structure.placeInWorld(((CraftRegionAccessor) regionAccessor).getHandle(), blockPosition, blockPosition, definedstructureinfo, random, 2);
|
||||
structure.placeInWorld(((CraftRegionAccessor) regionAccessor).getHandle(), blockPosition, blockPosition, definedstructureinfo, randomSource, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,7 @@ import net.minecraft.nbt.NBTCompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.DefinedStructure;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.DefinedStructureManager;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
@@ -25,9 +25,9 @@ import org.bukkit.structure.StructureManager;
|
||||
|
||||
public class CraftStructureManager implements StructureManager {
|
||||
|
||||
private final DefinedStructureManager structureManager;
|
||||
private final StructureTemplateManager structureManager;
|
||||
|
||||
public CraftStructureManager(DefinedStructureManager structureManager) {
|
||||
public CraftStructureManager(StructureTemplateManager structureManager) {
|
||||
this.structureManager = structureManager;
|
||||
}
|
||||
|
||||
@@ -120,14 +120,14 @@ public class CraftStructureManager implements StructureManager {
|
||||
if (unregister) {
|
||||
structureManager.structureRepository.remove(key);
|
||||
}
|
||||
Path path = structureManager.createAndValidatePathToStructure(key, ".nbt");
|
||||
Path path = structureManager.getPathToGeneratedStructure(key, ".nbt");
|
||||
Files.deleteIfExists(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getStructureFile(NamespacedKey structureKey) {
|
||||
MinecraftKey minecraftKey = createAndValidateMinecraftStructureKey(structureKey);
|
||||
return structureManager.createAndValidatePathToStructure(minecraftKey, ".nbt").toFile();
|
||||
return structureManager.getPathToGeneratedStructure(minecraftKey, ".nbt").toFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,12 +12,13 @@ import java.util.regex.Pattern;
|
||||
import net.minecraft.EnumChatFormat;
|
||||
import net.minecraft.network.chat.ChatClickable;
|
||||
import net.minecraft.network.chat.ChatClickable.EnumClickAction;
|
||||
import net.minecraft.network.chat.ChatComponentText;
|
||||
import net.minecraft.network.chat.ChatHexColor;
|
||||
import net.minecraft.network.chat.ChatMessage;
|
||||
import net.minecraft.network.chat.ChatModifier;
|
||||
import net.minecraft.network.chat.ComponentContents;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.network.chat.IChatMutableComponent;
|
||||
import net.minecraft.network.chat.contents.LiteralContents;
|
||||
import net.minecraft.network.chat.contents.TranslatableContents;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public final class CraftChatMessage {
|
||||
@@ -49,7 +50,7 @@ public final class CraftChatMessage {
|
||||
private static final ChatModifier RESET = ChatModifier.EMPTY.withBold(false).withItalic(false).withUnderlined(false).withStrikethrough(false).withObfuscated(false);
|
||||
|
||||
private final List<IChatBaseComponent> list = new ArrayList<IChatBaseComponent>();
|
||||
private IChatMutableComponent currentChatComponent = new ChatComponentText("");
|
||||
private IChatMutableComponent currentChatComponent = IChatBaseComponent.empty();
|
||||
private ChatModifier modifier = ChatModifier.EMPTY;
|
||||
private final IChatBaseComponent[] output;
|
||||
private int currentIndex;
|
||||
@@ -146,10 +147,10 @@ public final class CraftChatMessage {
|
||||
}
|
||||
|
||||
private void appendNewComponent(int index) {
|
||||
IChatBaseComponent addition = new ChatComponentText(message.substring(currentIndex, index)).setStyle(modifier);
|
||||
IChatBaseComponent addition = IChatBaseComponent.literal(message.substring(currentIndex, index)).setStyle(modifier);
|
||||
currentIndex = index;
|
||||
if (currentChatComponent == null) {
|
||||
currentChatComponent = new ChatComponentText("");
|
||||
currentChatComponent = IChatBaseComponent.empty();
|
||||
list.add(currentChatComponent);
|
||||
}
|
||||
currentChatComponent.append(addition);
|
||||
@@ -296,7 +297,7 @@ public final class CraftChatMessage {
|
||||
for (IChatBaseComponent c : component) {
|
||||
ChatModifier modi = c.getStyle();
|
||||
ChatHexColor color = modi.getColor();
|
||||
if (!c.getContents().isEmpty() || color != null) {
|
||||
if (c.getContents() != ComponentContents.EMPTY || color != null) {
|
||||
if (color != null) {
|
||||
if (color.format != null) {
|
||||
out.append(color.format);
|
||||
@@ -332,7 +333,7 @@ public final class CraftChatMessage {
|
||||
out.append(EnumChatFormat.OBFUSCATED);
|
||||
hadFormat = true;
|
||||
}
|
||||
c.visitSelf((x) -> {
|
||||
c.getContents().visit((x) -> {
|
||||
out.append(x);
|
||||
return Optional.empty();
|
||||
});
|
||||
@@ -340,22 +341,22 @@ public final class CraftChatMessage {
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static IChatBaseComponent fixComponent(IChatBaseComponent component) {
|
||||
public static IChatBaseComponent fixComponent(IChatMutableComponent component) {
|
||||
Matcher matcher = LINK_PATTERN.matcher("");
|
||||
return fixComponent(component, matcher);
|
||||
}
|
||||
|
||||
private static IChatBaseComponent fixComponent(IChatBaseComponent component, Matcher matcher) {
|
||||
if (component instanceof ChatComponentText) {
|
||||
ChatComponentText text = ((ChatComponentText) component);
|
||||
String msg = text.getContents();
|
||||
private static IChatBaseComponent fixComponent(IChatMutableComponent component, Matcher matcher) {
|
||||
if (component.getContents() instanceof LiteralContents) {
|
||||
LiteralContents text = ((LiteralContents) component.getContents());
|
||||
String msg = text.text();
|
||||
if (matcher.reset(msg).find()) {
|
||||
matcher.reset();
|
||||
|
||||
ChatModifier modifier = text.getStyle();
|
||||
ChatModifier modifier = component.getStyle();
|
||||
List<IChatBaseComponent> extras = new ArrayList<IChatBaseComponent>();
|
||||
List<IChatBaseComponent> extrasOld = new ArrayList<IChatBaseComponent>(text.getSiblings());
|
||||
component = text = new ChatComponentText("");
|
||||
List<IChatBaseComponent> extrasOld = new ArrayList<IChatBaseComponent>(component.getSiblings());
|
||||
component = IChatBaseComponent.empty();
|
||||
|
||||
int pos = 0;
|
||||
while (matcher.find()) {
|
||||
@@ -365,11 +366,11 @@ public final class CraftChatMessage {
|
||||
match = "http://" + match;
|
||||
}
|
||||
|
||||
ChatComponentText prev = new ChatComponentText(msg.substring(pos, matcher.start()));
|
||||
IChatMutableComponent prev = IChatBaseComponent.literal(msg.substring(pos, matcher.start()));
|
||||
prev.setStyle(modifier);
|
||||
extras.add(prev);
|
||||
|
||||
ChatComponentText link = new ChatComponentText(matcher.group());
|
||||
IChatMutableComponent link = IChatBaseComponent.literal(matcher.group());
|
||||
ChatModifier linkModi = modifier.withClickEvent(new ChatClickable(EnumClickAction.OPEN_URL, match));
|
||||
link.setStyle(linkModi);
|
||||
extras.add(link);
|
||||
@@ -377,13 +378,13 @@ public final class CraftChatMessage {
|
||||
pos = matcher.end();
|
||||
}
|
||||
|
||||
ChatComponentText prev = new ChatComponentText(msg.substring(pos));
|
||||
IChatMutableComponent prev = IChatBaseComponent.literal(msg.substring(pos));
|
||||
prev.setStyle(modifier);
|
||||
extras.add(prev);
|
||||
extras.addAll(extrasOld);
|
||||
|
||||
for (IChatBaseComponent c : extras) {
|
||||
text.append(c);
|
||||
component.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -392,21 +393,21 @@ public final class CraftChatMessage {
|
||||
for (int i = 0; i < extras.size(); i++) {
|
||||
IChatBaseComponent comp = extras.get(i);
|
||||
if (comp.getStyle() != null && comp.getStyle().getClickEvent() == null) {
|
||||
extras.set(i, fixComponent(comp, matcher));
|
||||
extras.set(i, fixComponent(comp.copy(), matcher));
|
||||
}
|
||||
}
|
||||
|
||||
if (component instanceof ChatMessage) {
|
||||
Object[] subs = ((ChatMessage) component).getArgs();
|
||||
if (component.getContents() instanceof TranslatableContents) {
|
||||
Object[] subs = ((TranslatableContents) component.getContents()).getArgs();
|
||||
for (int i = 0; i < subs.length; i++) {
|
||||
Object comp = subs[i];
|
||||
if (comp instanceof IChatBaseComponent) {
|
||||
IChatBaseComponent c = (IChatBaseComponent) comp;
|
||||
if (c.getStyle() != null && c.getStyle().getClickEvent() == null) {
|
||||
subs[i] = fixComponent(c, matcher);
|
||||
subs[i] = fixComponent(c.copy(), matcher);
|
||||
}
|
||||
} else if (comp instanceof String && matcher.reset((String) comp).find()) {
|
||||
subs[i] = fixComponent(new ChatComponentText((String) comp), matcher);
|
||||
subs[i] = fixComponent(IChatBaseComponent.literal((String) comp), matcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
* @return string
|
||||
*/
|
||||
public String getMappingsVersion() {
|
||||
return "eaeedbff51b16ead3170906872fda334";
|
||||
return "7b9de0da1357e5b251eddde9aa762916";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -303,7 +303,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");
|
||||
private static final List<String> SUPPORTED_API = Arrays.asList("1.13", "1.14", "1.15", "1.16", "1.17", "1.18", "1.19");
|
||||
|
||||
@Override
|
||||
public void checkSupported(PluginDescriptionFile pdf) throws InvalidPluginException {
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.sounds.SoundCategory;
|
||||
import net.minecraft.sounds.SoundEffect;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.DifficultyDamageScaler;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
@@ -36,6 +37,8 @@ import net.minecraft.world.level.material.FluidType;
|
||||
import net.minecraft.world.level.material.FluidTypes;
|
||||
import net.minecraft.world.level.storage.WorldData;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraft.world.ticks.LevelTickAccess;
|
||||
import net.minecraft.world.ticks.TickListEmpty;
|
||||
|
||||
@@ -97,7 +100,7 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Random getRandom() {
|
||||
public RandomSource getRandom() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@@ -117,7 +120,7 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gameEvent(Entity entity, GameEvent gameevent, BlockPosition blockposition) {
|
||||
public void gameEvent(GameEvent gameevent, Vec3D vec3d, GameEvent.a gameevent_a) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.levelgen.PositionalRandomFactory;
|
||||
|
||||
public final class RandomSourceWrapper implements RandomSource {
|
||||
|
||||
private final Random random;
|
||||
|
||||
public RandomSourceWrapper(Random random) {
|
||||
this.random = random;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RandomSource fork() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionalRandomFactory forkPositional() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setSeed(long seed) {
|
||||
random.setSeed(seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt() {
|
||||
return random.nextInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt(int bound) {
|
||||
return random.nextInt(bound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long nextLong() {
|
||||
return random.nextLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextBoolean() {
|
||||
return random.nextBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float nextFloat() {
|
||||
return random.nextFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double nextDouble() {
|
||||
return random.nextDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized double nextGaussian() {
|
||||
return random.nextGaussian();
|
||||
}
|
||||
|
||||
public static final class RandomWrapper extends Random {
|
||||
|
||||
private final RandomSource random;
|
||||
|
||||
public RandomWrapper(RandomSource random) {
|
||||
this.random = random;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSeed(long l) {
|
||||
random.setSeed(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt() {
|
||||
return random.nextInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt(int i) {
|
||||
return random.nextInt(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long nextLong() {
|
||||
return random.nextLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextBoolean() {
|
||||
return random.nextBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float nextFloat() {
|
||||
return random.nextFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double nextDouble() {
|
||||
return random.nextDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double nextGaussian() {
|
||||
return random.nextGaussian();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt(int var0, int var1) {
|
||||
return random.nextInt(var0, var1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user