@@ -92,7 +92,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
|
||||
if (context.getLootedEntity() != null) {
|
||||
Entity nmsLootedEntity = ((CraftEntity) context.getLootedEntity()).getHandle();
|
||||
setMaybe(builder, LootContextParameters.THIS_ENTITY, nmsLootedEntity);
|
||||
setMaybe(builder, LootContextParameters.DAMAGE_SOURCE, DamageSource.GENERIC);
|
||||
setMaybe(builder, LootContextParameters.DAMAGE_SOURCE, handle.damageSources().generic());
|
||||
setMaybe(builder, LootContextParameters.ORIGIN, nmsLootedEntity.position());
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
|
||||
EntityHuman nmsKiller = ((CraftHumanEntity) context.getKiller()).getHandle();
|
||||
setMaybe(builder, LootContextParameters.KILLER_ENTITY, nmsKiller);
|
||||
// If there is a player killer, damage source should reflect that in case loot tables use that information
|
||||
setMaybe(builder, LootContextParameters.DAMAGE_SOURCE, DamageSource.playerAttack(nmsKiller));
|
||||
setMaybe(builder, LootContextParameters.DAMAGE_SOURCE, handle.damageSources().playerAttack(nmsKiller));
|
||||
setMaybe(builder, LootContextParameters.LAST_DAMAGE_PLAYER, nmsKiller); // SPIGOT-5603 - Set minecraft:killed_by_player
|
||||
setMaybe(builder, LootContextParameters.TOOL, nmsKiller.getUseItem()); // SPIGOT-6925 - Set minecraft:match_tool
|
||||
}
|
||||
|
||||
@@ -132,6 +132,9 @@ public enum CraftParticle {
|
||||
SCULK_CHARGE("sculk_charge"),
|
||||
SCULK_CHARGE_POP("sculk_charge_pop"),
|
||||
SHRIEK("shriek"),
|
||||
DRIPPING_CHERRY_LEAVES("dripping_cherry_leaves"),
|
||||
FALLING_CHERRY_LEAVES("falling_cherry_leaves"),
|
||||
LANDING_CHERRY_LEAVES("landing_cherry_leaves"),
|
||||
// ----- Legacy Separator -----
|
||||
LEGACY_BLOCK_CRACK("block"),
|
||||
LEGACY_BLOCK_DUST("block"),
|
||||
|
||||
@@ -10,8 +10,6 @@ import java.util.function.Predicate;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.core.EnumDirection;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.features.TreeFeatures;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
@@ -81,6 +79,7 @@ import org.bukkit.entity.Axolotl;
|
||||
import org.bukkit.entity.Bat;
|
||||
import org.bukkit.entity.Bee;
|
||||
import org.bukkit.entity.Blaze;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Camel;
|
||||
import org.bukkit.entity.Cat;
|
||||
@@ -92,6 +91,7 @@ import org.bukkit.entity.Cod;
|
||||
import org.bukkit.entity.ComplexLivingEntity;
|
||||
import org.bukkit.entity.Cow;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.Dolphin;
|
||||
import org.bukkit.entity.Donkey;
|
||||
import org.bukkit.entity.DragonFireball;
|
||||
@@ -127,7 +127,9 @@ import org.bukkit.entity.Hoglin;
|
||||
import org.bukkit.entity.Husk;
|
||||
import org.bukkit.entity.Illager;
|
||||
import org.bukkit.entity.Illusioner;
|
||||
import org.bukkit.entity.Interaction;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.ItemDisplay;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.LeashHitch;
|
||||
import org.bukkit.entity.LightningStrike;
|
||||
@@ -165,6 +167,7 @@ import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.SkeletonHorse;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.SmallFireball;
|
||||
import org.bukkit.entity.Sniffer;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.entity.Snowman;
|
||||
import org.bukkit.entity.SpectralArrow;
|
||||
@@ -176,6 +179,7 @@ import org.bukkit.entity.Strider;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Tadpole;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.TextDisplay;
|
||||
import org.bukkit.entity.ThrownExpBottle;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.entity.TippedArrow;
|
||||
@@ -396,6 +400,9 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
case TALL_MANGROVE:
|
||||
gen = TreeFeatures.TALL_MANGROVE;
|
||||
break;
|
||||
case CHERRY:
|
||||
gen = TreeFeatures.CHERRY;
|
||||
break;
|
||||
case TREE:
|
||||
default:
|
||||
gen = TreeFeatures.OAK;
|
||||
@@ -579,7 +586,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
}
|
||||
entity.moveTo(x, y, z, yaw, pitch);
|
||||
} else if (FallingBlock.class.isAssignableFrom(clazz)) {
|
||||
BlockPosition pos = new BlockPosition(x, y, z);
|
||||
BlockPosition pos = BlockPosition.containing(x, y, z);
|
||||
entity = EntityFallingBlock.fall(world, pos, getHandle().getBlockState(pos));
|
||||
} else if (Projectile.class.isAssignableFrom(clazz)) {
|
||||
if (Snowball.class.isAssignableFrom(clazz)) {
|
||||
@@ -856,6 +863,8 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
entity = EntityTypes.FROG.create(world);
|
||||
} else if (Warden.class.isAssignableFrom(clazz)) {
|
||||
entity = EntityTypes.WARDEN.create(world);
|
||||
} else if (Sniffer.class.isAssignableFrom(clazz)) {
|
||||
entity = EntityTypes.SNIFFER.create(world);
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
@@ -865,7 +874,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
} else if (Hanging.class.isAssignableFrom(clazz)) {
|
||||
if (LeashHitch.class.isAssignableFrom(clazz)) {
|
||||
// SPIGOT-5732: LeashHitch has no direction and is always centered at a block
|
||||
entity = new EntityLeash(world, new BlockPosition(x, y, z));
|
||||
entity = new EntityLeash(world, BlockPosition.containing(x, y, z));
|
||||
} else {
|
||||
BlockFace face = BlockFace.SELF;
|
||||
BlockFace[] faces = new BlockFace[]{BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH};
|
||||
@@ -879,7 +888,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
faces = new BlockFace[]{BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH, BlockFace.UP, BlockFace.DOWN};
|
||||
}
|
||||
|
||||
final BlockPosition pos = new BlockPosition(x, y, z);
|
||||
final BlockPosition pos = BlockPosition.containing(x, y, z);
|
||||
for (BlockFace dir : faces) {
|
||||
IBlockData nmsBlock = getHandle().getBlockState(pos.relative(CraftBlock.blockFaceToNotch(dir)));
|
||||
if (nmsBlock.getMaterial().isSolid() || BlockDiodeAbstract.isDiode(nmsBlock)) {
|
||||
@@ -920,9 +929,9 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
}
|
||||
} else if (ItemFrame.class.isAssignableFrom(clazz)) {
|
||||
if (GlowItemFrame.class.isAssignableFrom(clazz)) {
|
||||
entity = new net.minecraft.world.entity.decoration.GlowItemFrame(world, new BlockPosition(x, y, z), dir);
|
||||
entity = new net.minecraft.world.entity.decoration.GlowItemFrame(world, BlockPosition.containing(x, y, z), dir);
|
||||
} else {
|
||||
entity = new EntityItemFrame(world, new BlockPosition(x, y, z), dir);
|
||||
entity = new EntityItemFrame(world, BlockPosition.containing(x, y, z), dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -940,6 +949,21 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
} else if (Marker.class.isAssignableFrom(clazz)) {
|
||||
entity = EntityTypes.MARKER.create(world);
|
||||
entity.setPos(x, y, z);
|
||||
} else if (Interaction.class.isAssignableFrom(clazz)) {
|
||||
entity = EntityTypes.INTERACTION.create(world);
|
||||
entity.setPos(x, y, z);
|
||||
} else if (Display.class.isAssignableFrom(clazz)) {
|
||||
if (BlockDisplay.class.isAssignableFrom(clazz)) {
|
||||
entity = EntityTypes.BLOCK_DISPLAY.create(world);
|
||||
} else if (ItemDisplay.class.isAssignableFrom(clazz)) {
|
||||
entity = EntityTypes.ITEM_DISPLAY.create(world);
|
||||
} else if (TextDisplay.class.isAssignableFrom(clazz)) {
|
||||
entity = EntityTypes.TEXT_DISPLAY.create(world);
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
entity.setPos(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
@@ -16,20 +15,15 @@ import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.DynamicOps;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -39,7 +33,6 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@@ -108,12 +101,10 @@ import net.minecraft.world.level.WorldSettings;
|
||||
import net.minecraft.world.level.biome.BiomeManager;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.dimension.WorldDimension;
|
||||
import net.minecraft.world.level.levelgen.GeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.MobSpawnerPatrol;
|
||||
import net.minecraft.world.level.levelgen.MobSpawnerPhantom;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.WorldOptions;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPresets;
|
||||
import net.minecraft.world.level.material.FluidType;
|
||||
import net.minecraft.world.level.saveddata.maps.MapIcon;
|
||||
import net.minecraft.world.level.saveddata.maps.WorldMap;
|
||||
@@ -232,6 +223,8 @@ import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
import org.bukkit.inventory.SmithingRecipe;
|
||||
import org.bukkit.inventory.SmithingTransformRecipe;
|
||||
import org.bukkit.inventory.SmithingTrimRecipe;
|
||||
import org.bukkit.inventory.SmokingRecipe;
|
||||
import org.bukkit.inventory.StonecuttingRecipe;
|
||||
import org.bukkit.loot.LootTable;
|
||||
@@ -256,6 +249,7 @@ import org.bukkit.scoreboard.Criteria;
|
||||
import org.bukkit.structure.StructureManager;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.bukkit.util.permissions.DefaultPermissions;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
import org.yaml.snakeyaml.error.MarkedYAMLException;
|
||||
@@ -278,7 +272,7 @@ public final class CraftServer implements Server {
|
||||
private final Map<Class<?>, Registry<?>> registries = new HashMap<>();
|
||||
private YamlConfiguration configuration;
|
||||
private YamlConfiguration commandsConfiguration;
|
||||
private final Yaml yaml = new Yaml(new SafeConstructor());
|
||||
private final Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
|
||||
private final Map<UUID, OfflinePlayer> offlinePlayers = new MapMaker().weakValues().makeMap();
|
||||
private final EntityMetadataStore entityMetadata = new EntityMetadataStore();
|
||||
private final PlayerMetadataStore playerMetadata = new PlayerMetadataStore();
|
||||
@@ -1256,6 +1250,10 @@ public final class CraftServer implements Server {
|
||||
toAdd = CraftStonecuttingRecipe.fromBukkitRecipe((StonecuttingRecipe) recipe);
|
||||
} else if (recipe instanceof SmithingRecipe) {
|
||||
toAdd = CraftSmithingRecipe.fromBukkitRecipe((SmithingRecipe) recipe);
|
||||
} else if (recipe instanceof SmithingTransformRecipe) {
|
||||
toAdd = CraftSmithingRecipe.fromBukkitRecipe((SmithingTransformRecipe) recipe);
|
||||
} else if (recipe instanceof SmithingTrimRecipe) {
|
||||
toAdd = CraftSmithingRecipe.fromBukkitRecipe((SmithingTrimRecipe) recipe);
|
||||
} else if (recipe instanceof ComplexRecipe) {
|
||||
throw new UnsupportedOperationException("Cannot add custom complex recipe");
|
||||
} else {
|
||||
@@ -1337,7 +1335,7 @@ public final class CraftServer implements Server {
|
||||
if (recipe.isPresent()) {
|
||||
RecipeCrafting recipeCrafting = recipe.get();
|
||||
if (craftResult.setRecipeUsed(craftWorld.getHandle(), craftPlayer.getHandle(), recipeCrafting)) {
|
||||
itemstack = recipeCrafting.assemble(inventoryCrafting);
|
||||
itemstack = recipeCrafting.assemble(inventoryCrafting, craftWorld.getHandle().registryAccess());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2050,14 +2048,13 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
|
||||
static CraftIconCache loadServerIcon0(BufferedImage image) throws Exception {
|
||||
ByteBuf bytebuf = Unpooled.buffer();
|
||||
|
||||
Validate.isTrue(image.getWidth() == 64, "Must be 64 pixels wide");
|
||||
Validate.isTrue(image.getHeight() == 64, "Must be 64 pixels high");
|
||||
ImageIO.write(image, "PNG", new ByteBufOutputStream(bytebuf));
|
||||
ByteBuffer bytebuffer = Base64.getEncoder().encode(bytebuf.nioBuffer());
|
||||
|
||||
return new CraftIconCache("data:image/png;base64," + StandardCharsets.UTF_8.decode(bytebuffer));
|
||||
ByteArrayOutputStream bytebuf = new ByteArrayOutputStream();
|
||||
ImageIO.write(image, "PNG", bytebuf);
|
||||
|
||||
return new CraftIconCache(bytebuf.toByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -796,7 +796,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public double getHumidity(int x, int y, int z) {
|
||||
return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).value().getDownfall();
|
||||
return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).value().climateSettings.downfall();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1158,7 +1158,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
Validate.notNull(material, "Material cannot be null");
|
||||
Validate.isTrue(material.isBlock(), "Material must be a block");
|
||||
|
||||
EntityFallingBlock entity = EntityFallingBlock.fall(world, new BlockPosition(location.getX(), location.getY(), location.getZ()), CraftMagicNumbers.getBlock(material).defaultBlockState(), SpawnReason.CUSTOM);
|
||||
EntityFallingBlock entity = EntityFallingBlock.fall(world, BlockPosition.containing(location.getX(), location.getY(), location.getZ()), CraftMagicNumbers.getBlock(material).defaultBlockState(), SpawnReason.CUSTOM);
|
||||
return (FallingBlock) entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
@@ -1167,7 +1167,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
Validate.notNull(location, "Location cannot be null");
|
||||
Validate.notNull(data, "BlockData cannot be null");
|
||||
|
||||
EntityFallingBlock entity = EntityFallingBlock.fall(world, new BlockPosition(location.getX(), location.getY(), location.getZ()), ((CraftBlockData) data).getState(), SpawnReason.CUSTOM);
|
||||
EntityFallingBlock entity = EntityFallingBlock.fall(world, BlockPosition.containing(location.getX(), location.getY(), location.getZ()), ((CraftBlockData) data).getState(), SpawnReason.CUSTOM);
|
||||
return (FallingBlock) entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
@@ -1862,7 +1862,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
}
|
||||
|
||||
public StructureSearchResult locateNearestStructure(Location origin, List<Structure> structures, int radius, boolean findUnexplored) {
|
||||
BlockPosition originPos = new BlockPosition(origin.getX(), origin.getY(), origin.getZ());
|
||||
BlockPosition originPos = BlockPosition.containing(origin.getX(), origin.getY(), origin.getZ());
|
||||
List<Holder<net.minecraft.world.level.levelgen.structure.Structure>> holders = new ArrayList<>();
|
||||
|
||||
for (Structure structure : structures) {
|
||||
|
||||
@@ -125,7 +125,7 @@ public class CraftWorldBorder implements WorldBorder {
|
||||
public boolean isInside(Location location) {
|
||||
Preconditions.checkArgument(location != null, "location cannot be null");
|
||||
|
||||
return (world == null || location.getWorld().equals(this.world)) && this.handle.isWithinBounds(new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
return (world == null || location.getWorld().equals(this.world)) && this.handle.isWithinBounds(BlockPosition.containing(location.getX(), location.getY(), location.getZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
import joptsimple.util.PathConverter;
|
||||
import org.fusesource.jansi.AnsiConsole;
|
||||
|
||||
public class Main {
|
||||
@@ -57,6 +58,15 @@ public class Main {
|
||||
.ofType(Integer.class)
|
||||
.describedAs("Port");
|
||||
|
||||
accepts("serverId", "Server ID")
|
||||
.withRequiredArg();
|
||||
|
||||
accepts("jfrProfile", "Enable JFR profiling");
|
||||
|
||||
accepts("pidFile", "pid File")
|
||||
.withRequiredArg()
|
||||
.withValuesConvertedBy(new PathConverter());
|
||||
|
||||
acceptsAll(asList("o", "online-mode"), "Whether to use online authentication")
|
||||
.withRequiredArg()
|
||||
.ofType(Boolean.class)
|
||||
@@ -183,11 +193,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, -28);
|
||||
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 ***");
|
||||
|
||||
@@ -12,10 +12,12 @@ import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.level.GeneratorAccess;
|
||||
import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.DecoratedPotBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.HangingSignBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SculkCatalystBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SculkSensorBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SculkShriekerBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SuspiciousSandBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntityBanner;
|
||||
import net.minecraft.world.level.block.entity.TileEntityBarrel;
|
||||
@@ -130,6 +132,8 @@ public final class CraftBlockStates {
|
||||
Material.BAMBOO_WALL_SIGN,
|
||||
Material.BIRCH_SIGN,
|
||||
Material.BIRCH_WALL_SIGN,
|
||||
Material.CHERRY_SIGN,
|
||||
Material.CHERRY_WALL_SIGN,
|
||||
Material.CRIMSON_SIGN,
|
||||
Material.CRIMSON_WALL_SIGN,
|
||||
Material.DARK_OAK_SIGN,
|
||||
@@ -155,6 +159,8 @@ public final class CraftBlockStates {
|
||||
Material.BAMBOO_WALL_HANGING_SIGN,
|
||||
Material.BIRCH_HANGING_SIGN,
|
||||
Material.BIRCH_WALL_HANGING_SIGN,
|
||||
Material.CHERRY_HANGING_SIGN,
|
||||
Material.CHERRY_WALL_HANGING_SIGN,
|
||||
Material.CRIMSON_HANGING_SIGN,
|
||||
Material.CRIMSON_WALL_HANGING_SIGN,
|
||||
Material.DARK_OAK_HANGING_SIGN,
|
||||
@@ -303,6 +309,7 @@ public final class CraftBlockStates {
|
||||
register(Material.COMPARATOR, CraftComparator.class, CraftComparator::new, TileEntityComparator::new);
|
||||
register(Material.CONDUIT, CraftConduit.class, CraftConduit::new, TileEntityConduit::new);
|
||||
register(Material.DAYLIGHT_DETECTOR, CraftDaylightDetector.class, CraftDaylightDetector::new, TileEntityLightDetector::new);
|
||||
register(Material.DECORATED_POT, CraftDecoratedPot.class, CraftDecoratedPot::new, DecoratedPotBlockEntity::new);
|
||||
register(Material.DISPENSER, CraftDispenser.class, CraftDispenser::new, TileEntityDispenser::new);
|
||||
register(Material.DROPPER, CraftDropper.class, CraftDropper::new, TileEntityDropper::new);
|
||||
register(Material.ENCHANTING_TABLE, CraftEnchantingTable.class, CraftEnchantingTable::new, TileEntityEnchantTable::new);
|
||||
@@ -321,6 +328,7 @@ public final class CraftBlockStates {
|
||||
register(Material.SMOKER, CraftSmoker.class, CraftSmoker::new, TileEntitySmoker::new);
|
||||
register(Material.SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new, TileEntityMobSpawner::new);
|
||||
register(Material.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new, TileEntityStructure::new);
|
||||
register(Material.SUSPICIOUS_SAND, CraftSuspiciousSand.class, CraftSuspiciousSand::new, SuspiciousSandBlockEntity::new);
|
||||
register(Material.TRAPPED_CHEST, CraftChest.class, CraftChest::new, TileEntityChestTrapped::new);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import net.minecraft.world.level.block.entity.DecoratedPotBlockEntity;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.DecoratedPot;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
|
||||
public class CraftDecoratedPot extends CraftBlockEntityState<DecoratedPotBlockEntity> implements DecoratedPot {
|
||||
|
||||
public CraftDecoratedPot(World world, DecoratedPotBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Material> getShards() {
|
||||
return getSnapshot().getShards().stream().map(CraftMagicNumbers::getMaterial).collect(Collectors.toUnmodifiableList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addShard(Material material) {
|
||||
Preconditions.checkArgument(material != null && material.isItem(), "Material must be an item");
|
||||
|
||||
getSnapshot().getShards().add(CraftMagicNumbers.getItem(material));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShards(List<Material> shard) {
|
||||
getSnapshot().getShards().clear();
|
||||
|
||||
for (Material material : shard) {
|
||||
addShard(material);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,14 +54,14 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getRecord() {
|
||||
ItemStack record = this.getSnapshot().getRecord();
|
||||
ItemStack record = this.getSnapshot().getFirstItem();
|
||||
return CraftItemStack.asBukkitCopy(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecord(org.bukkit.inventory.ItemStack record) {
|
||||
ItemStack nms = CraftItemStack.asNMSCopy(record);
|
||||
this.getSnapshot().setRecord(nms);
|
||||
this.getSnapshot().setRecordWithoutPlaying(nms);
|
||||
if (nms.isEmpty()) {
|
||||
this.data = this.data.setValue(BlockJukeBox.HAS_RECORD, false);
|
||||
} else {
|
||||
@@ -87,9 +87,8 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
|
||||
if (!(tileEntity instanceof TileEntityJukeBox)) return false;
|
||||
|
||||
TileEntityJukeBox jukebox = (TileEntityJukeBox) tileEntity;
|
||||
boolean result = !jukebox.getRecord().isEmpty();
|
||||
CraftWorld world = (CraftWorld) this.getWorld();
|
||||
((BlockJukeBox) Blocks.JUKEBOX).dropRecording(world.getHandle(), getPosition());
|
||||
boolean result = !jukebox.getFirstItem().isEmpty();
|
||||
jukebox.popOutRecord();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.world.level.block.entity.SuspiciousSandBlockEntity;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.SuspiciousSand;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.loot.LootTable;
|
||||
|
||||
public class CraftSuspiciousSand extends CraftBlockEntityState<SuspiciousSandBlockEntity> implements SuspiciousSand {
|
||||
|
||||
public CraftSuspiciousSand(World world, SuspiciousSandBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
return CraftItemStack.asBukkitCopy(getSnapshot().getItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(ItemStack item) {
|
||||
getSnapshot().item = CraftItemStack.asNMSCopy(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(SuspiciousSandBlockEntity lootable) {
|
||||
super.applyTo(lootable);
|
||||
|
||||
if (this.getSnapshot().lootTable == null) {
|
||||
lootable.setLootTable((MinecraftKey) null, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTable getLootTable() {
|
||||
if (getSnapshot().lootTable == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
MinecraftKey key = getSnapshot().lootTable;
|
||||
return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLootTable(LootTable table) {
|
||||
setLootTable(table, getSeed());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSeed() {
|
||||
return getSnapshot().lootTableSeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSeed(long seed) {
|
||||
setLootTable(getLootTable(), seed);
|
||||
}
|
||||
|
||||
private void setLootTable(LootTable table, long seed) {
|
||||
MinecraftKey key = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey());
|
||||
getSnapshot().setLootTable(key, seed);
|
||||
}
|
||||
}
|
||||
@@ -480,7 +480,9 @@ public class CraftBlockData implements BlockData {
|
||||
register(net.minecraft.world.level.block.CaveVinesBlock.class, org.bukkit.craftbukkit.block.impl.CraftCaveVines::new);
|
||||
register(net.minecraft.world.level.block.CaveVinesPlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftCaveVinesPlant::new);
|
||||
register(net.minecraft.world.level.block.CeilingHangingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftCeilingHangingSign::new);
|
||||
register(net.minecraft.world.level.block.CherryLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftCherryLeaves::new);
|
||||
register(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, org.bukkit.craftbukkit.block.impl.CraftChiseledBookShelf::new);
|
||||
register(net.minecraft.world.level.block.DecoratedPotBlock.class, org.bukkit.craftbukkit.block.impl.CraftDecoratedPot::new);
|
||||
register(net.minecraft.world.level.block.GlowLichenBlock.class, org.bukkit.craftbukkit.block.impl.CraftGlowLichen::new);
|
||||
register(net.minecraft.world.level.block.HangingRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftHangingRoots::new);
|
||||
register(net.minecraft.world.level.block.InfestedRotatedPillarBlock.class, org.bukkit.craftbukkit.block.impl.CraftInfestedRotatedPillar::new);
|
||||
@@ -491,6 +493,7 @@ public class CraftBlockData implements BlockData {
|
||||
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.PiglinWallSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftPiglinWallSkull::new);
|
||||
register(net.minecraft.world.level.block.PinkPetalsBlock.class, org.bukkit.craftbukkit.block.impl.CraftPinkPetals::new);
|
||||
register(net.minecraft.world.level.block.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);
|
||||
@@ -498,7 +501,9 @@ public class CraftBlockData implements BlockData {
|
||||
register(net.minecraft.world.level.block.SculkShriekerBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkShrieker::new);
|
||||
register(net.minecraft.world.level.block.SculkVeinBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkVein::new);
|
||||
register(net.minecraft.world.level.block.SmallDripleafBlock.class, org.bukkit.craftbukkit.block.impl.CraftSmallDripleaf::new);
|
||||
register(net.minecraft.world.level.block.SuspiciousSandBlock.class, org.bukkit.craftbukkit.block.impl.CraftSuspiciousSand::new);
|
||||
register(net.minecraft.world.level.block.TallSeagrassBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallSeagrass::new);
|
||||
register(net.minecraft.world.level.block.TorchflowerCropBlock.class, org.bukkit.craftbukkit.block.impl.CraftTorchflowerCrop::new);
|
||||
register(net.minecraft.world.level.block.WallHangingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallHangingSign::new);
|
||||
register(net.minecraft.world.level.block.WeatheringCopperSlabBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperSlab::new);
|
||||
register(net.minecraft.world.level.block.WeatheringCopperStairBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperStair::new);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.PinkPetals;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftPinkPetals extends CraftBlockData implements PinkPetals {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger FLOWER_AMOUNT = getInteger("flower_amount");
|
||||
|
||||
@Override
|
||||
public int getFlowerAmount() {
|
||||
return get(FLOWER_AMOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlowerAmount(int flower_amount) {
|
||||
set(FLOWER_AMOUNT, flower_amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumFlowerAmount() {
|
||||
return getMax(FLOWER_AMOUNT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.SuspiciousSand;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftSuspiciousSand extends CraftBlockData implements SuspiciousSand {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger DUSTED = getInteger("dusted");
|
||||
|
||||
@Override
|
||||
public int getDusted() {
|
||||
return get(DUSTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDusted(int dusted) {
|
||||
set(DUSTED, dusted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumDusted() {
|
||||
return getMax(DUSTED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Automatically generated file, changes will be lost.
|
||||
*/
|
||||
package org.bukkit.craftbukkit.block.impl;
|
||||
|
||||
public final class CraftCherryLeaves extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Leaves, org.bukkit.block.data.Waterlogged {
|
||||
|
||||
public CraftCherryLeaves() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CraftCherryLeaves(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.CherryLeavesBlock.class, "distance");
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean PERSISTENT = getBoolean(net.minecraft.world.level.block.CherryLeavesBlock.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);
|
||||
}
|
||||
|
||||
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.CherryLeavesBlock.class, "waterlogged");
|
||||
|
||||
@Override
|
||||
public boolean isWaterlogged() {
|
||||
return get(WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWaterlogged(boolean waterlogged) {
|
||||
set(WATERLOGGED, waterlogged);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Automatically generated file, changes will be lost.
|
||||
*/
|
||||
package org.bukkit.craftbukkit.block.impl;
|
||||
|
||||
public final class CraftDecoratedPot extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.DecoratedPot, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged {
|
||||
|
||||
public CraftDecoratedPot() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CraftDecoratedPot(net.minecraft.world.level.block.state.IBlockData state) {
|
||||
super(state);
|
||||
}
|
||||
|
||||
// org.bukkit.craftbukkit.block.data.CraftDirectional
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> FACING = getEnum(net.minecraft.world.level.block.DecoratedPotBlock.class, "facing");
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.BlockFace getFacing() {
|
||||
return get(FACING, org.bukkit.block.BlockFace.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(org.bukkit.block.BlockFace facing) {
|
||||
set(FACING, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
|
||||
return getValues(FACING, org.bukkit.block.BlockFace.class);
|
||||
}
|
||||
|
||||
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.DecoratedPotBlock.class, "waterlogged");
|
||||
|
||||
@Override
|
||||
public boolean isWaterlogged() {
|
||||
return get(WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWaterlogged(boolean waterlogged) {
|
||||
set(WATERLOGGED, waterlogged);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Automatically generated file, changes will be lost.
|
||||
*/
|
||||
package org.bukkit.craftbukkit.block.impl;
|
||||
|
||||
public final class CraftPinkPetals extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.PinkPetals, org.bukkit.block.data.Directional {
|
||||
|
||||
public CraftPinkPetals() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CraftPinkPetals(net.minecraft.world.level.block.state.IBlockData state) {
|
||||
super(state);
|
||||
}
|
||||
|
||||
// org.bukkit.craftbukkit.block.data.type.CraftPinkPetals
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger FLOWER_AMOUNT = getInteger(net.minecraft.world.level.block.PinkPetalsBlock.class, "flower_amount");
|
||||
|
||||
@Override
|
||||
public int getFlowerAmount() {
|
||||
return get(FLOWER_AMOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlowerAmount(int flower_amount) {
|
||||
set(FLOWER_AMOUNT, flower_amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumFlowerAmount() {
|
||||
return getMax(FLOWER_AMOUNT);
|
||||
}
|
||||
|
||||
// org.bukkit.craftbukkit.block.data.CraftDirectional
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> FACING = getEnum(net.minecraft.world.level.block.PinkPetalsBlock.class, "facing");
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.BlockFace getFacing() {
|
||||
return get(FACING, org.bukkit.block.BlockFace.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(org.bukkit.block.BlockFace facing) {
|
||||
set(FACING, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
|
||||
return getValues(FACING, org.bukkit.block.BlockFace.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Automatically generated file, changes will be lost.
|
||||
*/
|
||||
package org.bukkit.craftbukkit.block.impl;
|
||||
|
||||
public final class CraftSuspiciousSand extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.SuspiciousSand {
|
||||
|
||||
public CraftSuspiciousSand() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CraftSuspiciousSand(net.minecraft.world.level.block.state.IBlockData state) {
|
||||
super(state);
|
||||
}
|
||||
|
||||
// org.bukkit.craftbukkit.block.data.type.CraftSuspiciousSand
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger DUSTED = getInteger(net.minecraft.world.level.block.SuspiciousSandBlock.class, "dusted");
|
||||
|
||||
@Override
|
||||
public int getDusted() {
|
||||
return get(DUSTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDusted(int dusted) {
|
||||
set(DUSTED, dusted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumDusted() {
|
||||
return getMax(DUSTED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Automatically generated file, changes will be lost.
|
||||
*/
|
||||
package org.bukkit.craftbukkit.block.impl;
|
||||
|
||||
public final class CraftTorchflowerCrop extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable {
|
||||
|
||||
public CraftTorchflowerCrop() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CraftTorchflowerCrop(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.TorchflowerCropBlock.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);
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class CraftAllay extends CraftCreature implements org.bukkit.entity.Allay
|
||||
public void startDancing(Location location) {
|
||||
Preconditions.checkArgument(location != null, "Location cannot be null");
|
||||
Preconditions.checkArgument(location.getBlock().getType().equals(Material.JUKEBOX), "The Block in the Location need to be a JukeBox");
|
||||
getHandle().setJukeboxPlaying(new BlockPosition(location.getX(), location.getY(), location.getZ()), true);
|
||||
getHandle().setJukeboxPlaying(BlockPosition.containing(location.getX(), location.getY(), location.getZ()), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class CraftBlockDisplay extends CraftDisplay implements BlockDisplay {
|
||||
|
||||
public CraftBlockDisplay(CraftServer server, net.minecraft.world.entity.Display.BlockDisplay entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.entity.Display.BlockDisplay getHandle() {
|
||||
return (net.minecraft.world.entity.Display.BlockDisplay) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftBlockDisplay";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.BLOCK_DISPLAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlock() {
|
||||
return CraftBlockData.fromData(getHandle().getBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(BlockData block) {
|
||||
Preconditions.checkArgument(block != null, "Block cannot be null");
|
||||
|
||||
getHandle().setBlockState(((CraftBlockData) block).getState());
|
||||
}
|
||||
}
|
||||
@@ -107,6 +107,7 @@ public class CraftBoat extends CraftVehicle implements Boat {
|
||||
case OAK -> Type.OAK;
|
||||
case BIRCH -> Type.BIRCH;
|
||||
case ACACIA -> Type.ACACIA;
|
||||
case CHERRY -> Type.CHERRY;
|
||||
case JUNGLE -> Type.JUNGLE;
|
||||
case SPRUCE -> Type.SPRUCE;
|
||||
case DARK_OAK -> Type.DARK_OAK;
|
||||
@@ -123,6 +124,7 @@ public class CraftBoat extends CraftVehicle implements Boat {
|
||||
case SPRUCE -> EntityBoat.EnumBoatType.SPRUCE;
|
||||
case DARK_OAK -> EntityBoat.EnumBoatType.DARK_OAK;
|
||||
case JUNGLE -> EntityBoat.EnumBoatType.JUNGLE;
|
||||
case CHERRY -> EntityBoat.EnumBoatType.CHERRY;
|
||||
case ACACIA -> EntityBoat.EnumBoatType.ACACIA;
|
||||
case BIRCH -> EntityBoat.EnumBoatType.BIRCH;
|
||||
case OAK -> EntityBoat.EnumBoatType.OAK;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.world.entity.EntityPose;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Camel;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -43,7 +44,7 @@ public class CraftCamel extends CraftAbstractHorse implements Camel {
|
||||
|
||||
@Override
|
||||
public boolean isSitting() {
|
||||
return getHandle().isPoseSitting();
|
||||
return getHandle().getPose() == EntityPose.SITTING;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.util.Transformation;
|
||||
|
||||
public class CraftDisplay extends CraftEntity implements Display {
|
||||
|
||||
public CraftDisplay(CraftServer server, net.minecraft.world.entity.Display entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.entity.Display getHandle() {
|
||||
return (net.minecraft.world.entity.Display) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftDisplay";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transformation getTransformation() {
|
||||
com.mojang.math.Transformation nms = net.minecraft.world.entity.Display.createTransformation(getHandle().getEntityData());
|
||||
|
||||
return new Transformation(nms.getTranslation(), nms.getLeftRotation(), nms.getScale(), nms.getRightRotation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransformation(Transformation transformation) {
|
||||
Preconditions.checkArgument(transformation != null, "Transformation cannot be null");
|
||||
|
||||
getHandle().setTransformation(new com.mojang.math.Transformation(transformation.getTranslation(), transformation.getLeftRotation(), transformation.getScale(), transformation.getRightRotation()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInterpolationDuration() {
|
||||
return getHandle().getInterpolationDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInterpolationDuration(int duration) {
|
||||
getHandle().setInterpolationDuration(duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getViewRange() {
|
||||
return getHandle().getViewRange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViewRange(float range) {
|
||||
getHandle().setViewRange(range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadowRadius() {
|
||||
return getHandle().getShadowRadius();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShadowRadius(float radius) {
|
||||
getHandle().setShadowRadius(radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadowStrength() {
|
||||
return getHandle().getShadowStrength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShadowStrength(float strength) {
|
||||
getHandle().setShadowStrength(strength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDisplayWidth() {
|
||||
return getHandle().getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayWidth(float width) {
|
||||
getHandle().setWidth(width);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDisplayHeight() {
|
||||
return getHandle().getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayHeight(float height) {
|
||||
getHandle().setHeight(height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInterpolationDelay() {
|
||||
return getHandle().getInterpolationDelay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInterpolationDelay(int ticks) {
|
||||
getHandle().setInterpolationDelay(ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Billboard getBillboard() {
|
||||
return Billboard.valueOf(getHandle().getBillboardConstraints().name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBillboard(Billboard billboard) {
|
||||
Preconditions.checkArgument(billboard != null, "Billboard cannot be null");
|
||||
|
||||
getHandle().setBillboardConstraints(net.minecraft.world.entity.Display.BillboardConstraints.valueOf(billboard.name()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getGlowColorOverride() {
|
||||
int color = getHandle().getGlowColorOverride();
|
||||
|
||||
return (color == -1) ? null : Color.fromRGB(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGlowColorOverride(Color color) {
|
||||
if (color == null) {
|
||||
getHandle().setGlowColorOverride(-1);
|
||||
} else {
|
||||
getHandle().setGlowColorOverride(color.asRGB());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Brightness getBrightness() {
|
||||
net.minecraft.util.Brightness nms = getHandle().getBrightnessOverride();
|
||||
|
||||
return (nms != null) ? new Brightness(nms.block(), nms.sky()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBrightness(Brightness brightness) {
|
||||
if (brightness != null) {
|
||||
getHandle().setBrightnessOverride(new net.minecraft.util.Brightness(brightness.getBlockLight(), brightness.getSkyLight()));
|
||||
} else {
|
||||
getHandle().setBrightnessOverride(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal {
|
||||
@Override
|
||||
public void setTargetLocation(Location location) {
|
||||
Preconditions.checkArgument(getWorld().equals(location.getWorld()), "Cannot target EnderSignal across worlds");
|
||||
getHandle().signalTo(new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
getHandle().signalTo(BlockPosition.containing(location.getX(), location.getY(), location.getZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.core.Position;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -15,8 +14,7 @@ import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.level.PlayerChunkMap;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.sounds.SoundEffect;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Display;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityAreaEffectCloud;
|
||||
import net.minecraft.world.entity.EntityCreature;
|
||||
@@ -26,6 +24,7 @@ import net.minecraft.world.entity.EntityLightning;
|
||||
import net.minecraft.world.entity.EntityLiving;
|
||||
import net.minecraft.world.entity.EntityTameableAnimal;
|
||||
import net.minecraft.world.entity.GlowSquid;
|
||||
import net.minecraft.world.entity.Interaction;
|
||||
import net.minecraft.world.entity.Marker;
|
||||
import net.minecraft.world.entity.ambient.EntityAmbient;
|
||||
import net.minecraft.world.entity.ambient.EntityBat;
|
||||
@@ -71,6 +70,7 @@ import net.minecraft.world.entity.animal.horse.EntityHorseSkeleton;
|
||||
import net.minecraft.world.entity.animal.horse.EntityHorseZombie;
|
||||
import net.minecraft.world.entity.animal.horse.EntityLlama;
|
||||
import net.minecraft.world.entity.animal.horse.EntityLlamaTrader;
|
||||
import net.minecraft.world.entity.animal.sniffer.Sniffer;
|
||||
import net.minecraft.world.entity.boss.EntityComplexPart;
|
||||
import net.minecraft.world.entity.boss.enderdragon.EntityEnderCrystal;
|
||||
import net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon;
|
||||
@@ -273,6 +273,7 @@ public abstract class CraftEntity implements org.bukkit.entity.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 if (entity instanceof Sniffer) { return new CraftSniffer(server, (Sniffer) entity); }
|
||||
else { return new CraftAnimals(server, (EntityAnimal) entity); }
|
||||
}
|
||||
// Monsters
|
||||
@@ -422,6 +423,13 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else if (entity instanceof EntityEvokerFangs) { return new CraftEvokerFangs(server, (EntityEvokerFangs) entity); }
|
||||
else if (entity instanceof EntityLlamaSpit) { return new CraftLlamaSpit(server, (EntityLlamaSpit) entity); }
|
||||
else if (entity instanceof Marker) { return new CraftMarker(server, (Marker) entity); }
|
||||
else if (entity instanceof Interaction) { return new CraftInteraction(server, (Interaction) entity); }
|
||||
else if (entity instanceof Display) {
|
||||
if (entity instanceof Display.BlockDisplay) { return new CraftBlockDisplay(server, (Display.BlockDisplay) entity); }
|
||||
else if (entity instanceof Display.ItemDisplay) { return new CraftItemDisplay(server, (Display.ItemDisplay) entity); }
|
||||
else if (entity instanceof Display.TextDisplay) { return new CraftTextDisplay(server, (Display.TextDisplay) entity); }
|
||||
else { return new CraftDisplay(server, (Display) entity); }
|
||||
}
|
||||
// CHECKSTYLE:ON
|
||||
|
||||
throw new AssertionError("Unknown entity " + (entity == null ? null : entity.getClass()));
|
||||
@@ -1012,7 +1020,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable() {
|
||||
return getHandle().isInvulnerableTo(DamageSource.GENERIC);
|
||||
return getHandle().isInvulnerableTo(getHandle().damageSources().generic());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Interaction;
|
||||
|
||||
public class CraftInteraction extends CraftEntity implements Interaction {
|
||||
|
||||
public CraftInteraction(CraftServer server, net.minecraft.world.entity.Interaction entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.entity.Interaction getHandle() {
|
||||
return (net.minecraft.world.entity.Interaction) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftInteraction";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.INTERACTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInteractionWidth() {
|
||||
return getHandle().getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInteractionWidth(float width) {
|
||||
getHandle().setWidth(width);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInteractionHeight() {
|
||||
return getHandle().getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInteractionHeight(float height) {
|
||||
getHandle().setHeight(height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResponsive() {
|
||||
return getHandle().getResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResponsive(boolean response) {
|
||||
getHandle().setResponse(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreviousInteraction getLastAttack() {
|
||||
net.minecraft.world.entity.Interaction.PlayerAction last = getHandle().attack;
|
||||
|
||||
return (last != null) ? new CraftPreviousInteraction(last.player(), last.timestamp()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreviousInteraction getLastInteraction() {
|
||||
net.minecraft.world.entity.Interaction.PlayerAction last = getHandle().interaction;
|
||||
|
||||
return (last != null) ? new CraftPreviousInteraction(last.player(), last.timestamp()) : null;
|
||||
}
|
||||
|
||||
private static class CraftPreviousInteraction implements PreviousInteraction {
|
||||
|
||||
private final UUID uuid;
|
||||
private final long timestamp;
|
||||
|
||||
public CraftPreviousInteraction(UUID uuid, long timestamp) {
|
||||
this.uuid = uuid;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlayer getPlayer() {
|
||||
return Bukkit.getOfflinePlayer(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,12 +68,12 @@ public class CraftItem extends CraftEntity implements Item {
|
||||
|
||||
@Override
|
||||
public void setOwner(UUID uuid) {
|
||||
item.setOwner(uuid);
|
||||
item.setTarget(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getOwner() {
|
||||
return item.getOwner();
|
||||
return item.target;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,7 +83,7 @@ public class CraftItem extends CraftEntity implements Item {
|
||||
|
||||
@Override
|
||||
public UUID getThrower() {
|
||||
return item.getThrower();
|
||||
return item.thrower;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ItemDisplay;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CraftItemDisplay extends CraftDisplay implements ItemDisplay {
|
||||
|
||||
public CraftItemDisplay(CraftServer server, net.minecraft.world.entity.Display.ItemDisplay entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.entity.Display.ItemDisplay getHandle() {
|
||||
return (net.minecraft.world.entity.Display.ItemDisplay) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftItemDisplay";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.ITEM_DISPLAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return CraftItemStack.asBukkitCopy(getHandle().getItemStack());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemStack(ItemStack item) {
|
||||
getHandle().setItemStack(CraftItemStack.asNMSCopy(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemDisplayTransform getItemDisplayTransform() {
|
||||
return ItemDisplayTransform.values()[getHandle().getItemTransform().ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemDisplayTransform(ItemDisplayTransform display) {
|
||||
Preconditions.checkArgument(display != null, "Display cannot be null");
|
||||
|
||||
getHandle().setItemTransform(ItemDisplayContext.BY_ID.apply(display.ordinal()));
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
getHandle().setHealth((float) health);
|
||||
|
||||
if (health == 0) {
|
||||
getHandle().die(DamageSource.GENERIC);
|
||||
getHandle().die(getHandle().damageSources().generic());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,12 +289,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
public void damage(double amount, org.bukkit.entity.Entity source) {
|
||||
Preconditions.checkState(!getHandle().generation, "Cannot damage entity during world generation");
|
||||
|
||||
DamageSource reason = DamageSource.GENERIC;
|
||||
DamageSource reason = getHandle().damageSources().generic();
|
||||
|
||||
if (source instanceof HumanEntity) {
|
||||
reason = DamageSource.playerAttack(((CraftHumanEntity) source).getHandle());
|
||||
reason = getHandle().damageSources().playerAttack(((CraftHumanEntity) source).getHandle());
|
||||
} else if (source instanceof LivingEntity) {
|
||||
reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
|
||||
reason = getHandle().damageSources().mobAttack(((CraftLivingEntity) source).getHandle());
|
||||
}
|
||||
|
||||
entity.hurt(reason, (float) amount);
|
||||
@@ -702,7 +702,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
|
||||
@Override
|
||||
public Sound getHurtSound() {
|
||||
SoundEffect sound = getHandle().getHurtSound0(DamageSource.GENERIC);
|
||||
SoundEffect sound = getHandle().getHurtSound0(getHandle().damageSources().generic());
|
||||
return (sound != null) ? CraftSound.getBukkit(sound) : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class CraftPig extends CraftAnimals implements Pig {
|
||||
|
||||
@Override
|
||||
public int getBoostTicks() {
|
||||
return getHandle().steering.boosting ? getHandle().steering.boostTimeTotal : 0;
|
||||
return getHandle().steering.boosting ? getHandle().steering.boostTimeTotal() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,7 +46,7 @@ public class CraftPig extends CraftAnimals implements Pig {
|
||||
return;
|
||||
}
|
||||
|
||||
int max = getHandle().steering.boostTimeTotal;
|
||||
int max = getHandle().steering.boostTimeTotal();
|
||||
Preconditions.checkArgument(ticks >= 0 && ticks <= max, "boost ticks must not exceed 0 or %d (inclusive)", max);
|
||||
|
||||
this.getHandle().steering.boostTime = ticks;
|
||||
|
||||
@@ -216,7 +216,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public InetSocketAddress getAddress() {
|
||||
if (getHandle().connection == null) return null;
|
||||
|
||||
SocketAddress addr = getHandle().connection.connection.getRemoteAddress();
|
||||
SocketAddress addr = getHandle().connection.getRemoteAddress();
|
||||
if (addr instanceof InetSocketAddress) {
|
||||
return (InetSocketAddress) addr;
|
||||
} else {
|
||||
@@ -842,20 +842,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public void addCustomChatCompletions(Collection<String> completions) {
|
||||
this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.a.ADD);
|
||||
this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.Action.ADD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCustomChatCompletions(Collection<String> completions) {
|
||||
this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.a.REMOVE);
|
||||
this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.Action.REMOVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomChatCompletions(Collection<String> completions) {
|
||||
this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.a.SET);
|
||||
this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.Action.SET);
|
||||
}
|
||||
|
||||
private void sendCustomChatCompletionPacket(Collection<String> completions, ClientboundCustomChatCompletionsPacket.a action) { // PAIL rename Action
|
||||
private void sendCustomChatCompletionPacket(Collection<String> completions, ClientboundCustomChatCompletionsPacket.Action action) {
|
||||
if (getHandle().connection == null) return;
|
||||
|
||||
ClientboundCustomChatCompletionsPacket packet = new ClientboundCustomChatCompletionsPacket(action, new ArrayList<>(completions));
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Sniffer;
|
||||
|
||||
public class CraftSniffer extends CraftAnimals implements Sniffer {
|
||||
|
||||
public CraftSniffer(CraftServer server, net.minecraft.world.entity.animal.sniffer.Sniffer entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.entity.animal.sniffer.Sniffer getHandle() {
|
||||
return (net.minecraft.world.entity.animal.sniffer.Sniffer) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftSniffer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.SNIFFER;
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class CraftStrider extends CraftAnimals implements Strider {
|
||||
|
||||
@Override
|
||||
public int getBoostTicks() {
|
||||
return getHandle().steering.boosting ? getHandle().steering.boostTimeTotal : 0;
|
||||
return getHandle().steering.boosting ? getHandle().steering.boostTimeTotal() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,7 +56,7 @@ public class CraftStrider extends CraftAnimals implements Strider {
|
||||
return;
|
||||
}
|
||||
|
||||
int max = getHandle().steering.boostTimeTotal;
|
||||
int max = getHandle().steering.boostTimeTotal();
|
||||
Preconditions.checkArgument(ticks >= 0 && ticks <= max, "boost ticks must not exceed 0 or %d (inclusive)", max);
|
||||
|
||||
this.getHandle().steering.boostTime = ticks;
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.world.entity.Display;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.TextDisplay;
|
||||
|
||||
public class CraftTextDisplay extends CraftDisplay implements TextDisplay {
|
||||
|
||||
public CraftTextDisplay(CraftServer server, net.minecraft.world.entity.Display.TextDisplay entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.entity.Display.TextDisplay getHandle() {
|
||||
return (net.minecraft.world.entity.Display.TextDisplay) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftTextDisplay";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.TEXT_DISPLAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return CraftChatMessage.fromComponent(getHandle().getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String text) {
|
||||
getHandle().setText(CraftChatMessage.fromString(text, true)[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLineWidth() {
|
||||
return getHandle().getLineWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineWidth(int width) {
|
||||
getHandle().setLineWidth(width);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getBackgroundColor() {
|
||||
int color = getHandle().getBackgroundColor();
|
||||
|
||||
return (color == -1) ? null : Color.fromRGB(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundColor(Color color) {
|
||||
if (color == null) {
|
||||
getHandle().setBackgroundColor(-1);
|
||||
} else {
|
||||
getHandle().setBackgroundColor(color.asRGB());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getTextOpacity() {
|
||||
return getHandle().getTextOpacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextOpacity(byte opacity) {
|
||||
getHandle().setTextOpacity(opacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShadowed() {
|
||||
return getFlag(Display.TextDisplay.FLAG_SHADOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShadowed(boolean shadow) {
|
||||
setFlag(Display.TextDisplay.FLAG_SHADOW, shadow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSeeThrough() {
|
||||
return getFlag(Display.TextDisplay.FLAG_SEE_THROUGH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSeeThrough(boolean seeThrough) {
|
||||
setFlag(Display.TextDisplay.FLAG_SEE_THROUGH, seeThrough);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefaultBackground() {
|
||||
return getFlag(Display.TextDisplay.FLAG_USE_DEFAULT_BACKGROUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultBackground(boolean defaultBackground) {
|
||||
setFlag(Display.TextDisplay.FLAG_USE_DEFAULT_BACKGROUND, defaultBackground);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextAligment getAlignment() {
|
||||
Display.TextDisplay.Align nms = Display.TextDisplay.getAlign(getHandle().getFlags());
|
||||
return TextAligment.valueOf(nms.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlignment(TextAligment alignment) {
|
||||
Preconditions.checkArgument(alignment != null, "Alignment cannot be null");
|
||||
|
||||
switch (alignment) {
|
||||
case LEFT:
|
||||
setFlag(Display.TextDisplay.FLAG_ALIGN_LEFT, true);
|
||||
setFlag(Display.TextDisplay.FLAG_ALIGN_RIGHT, false);
|
||||
break;
|
||||
case RIGHT:
|
||||
setFlag(Display.TextDisplay.FLAG_ALIGN_LEFT, false);
|
||||
setFlag(Display.TextDisplay.FLAG_ALIGN_RIGHT, true);
|
||||
break;
|
||||
case CENTER:
|
||||
setFlag(Display.TextDisplay.FLAG_ALIGN_LEFT, false);
|
||||
setFlag(Display.TextDisplay.FLAG_ALIGN_RIGHT, false);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown alignment " + alignment);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getFlag(int flag) {
|
||||
return (getHandle().getFlags() & flag) != 0;
|
||||
}
|
||||
|
||||
private void setFlag(int flag, boolean set) {
|
||||
byte flagBits = getHandle().getFlags();
|
||||
|
||||
if (set) {
|
||||
flagBits |= flag;
|
||||
} else {
|
||||
flagBits &= ~flag;
|
||||
}
|
||||
|
||||
getHandle().setFlags(flagBits);
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class CraftWarden extends CraftMonster implements org.bukkit.entity.Warde
|
||||
public void setDisturbanceLocation(Location location) {
|
||||
Preconditions.checkArgument(location != null, "Location cannot be null");
|
||||
|
||||
WardenAi.setDisturbanceLocation(getHandle(), new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
WardenAi.setDisturbanceLocation(getHandle(), BlockPosition.containing(location.getX(), location.getY(), location.getZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,6 +51,6 @@ public final class CraftMemoryMapper {
|
||||
}
|
||||
|
||||
public static GlobalPos toNms(Location location) {
|
||||
return GlobalPos.of(((CraftWorld) location.getWorld()).getHandle().dimension(), new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
return GlobalPos.of(((CraftWorld) location.getWorld()).getHandle().dimension(), BlockPosition.containing(location.getX(), location.getY(), location.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,16 @@ import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.core.EnumDirection;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInCloseWindow;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.tags.DamageTypeTags;
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.world.EnumHand;
|
||||
import net.minecraft.world.IInventory;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.damagesource.EntityDamageSource;
|
||||
import net.minecraft.world.damagesource.EntityDamageSourceIndirect;
|
||||
import net.minecraft.world.damagesource.DamageType;
|
||||
import net.minecraft.world.damagesource.DamageTypes;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityAreaEffectCloud;
|
||||
@@ -97,7 +99,6 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.inventory.CraftMetaBook;
|
||||
import org.bukkit.craftbukkit.potion.CraftPotionUtil;
|
||||
import org.bukkit.craftbukkit.util.CraftDamageSource;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.entity.AbstractHorse;
|
||||
@@ -235,8 +236,6 @@ import org.bukkit.inventory.meta.BookMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
public class CraftEventFactory {
|
||||
public static final DamageSource MELTING = CraftDamageSource.copyOf(DamageSource.ON_FIRE);
|
||||
public static final DamageSource POISON = CraftDamageSource.copyOf(DamageSource.MAGIC);
|
||||
public static org.bukkit.block.Block blockDamage; // For use in EntityDamageByBlockEvent
|
||||
public static Entity entityDamage; // For use in EntityDamageByEntityEvent
|
||||
|
||||
@@ -852,7 +851,8 @@ public class CraftEventFactory {
|
||||
}
|
||||
|
||||
private static EntityDamageEvent handleEntityDamageEvent(Entity entity, DamageSource source, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled) {
|
||||
if (source.isExplosion()) {
|
||||
ResourceKey<DamageType> sourceType = source.typeHolder().unwrapKey().get();
|
||||
if (source.is(DamageTypeTags.IS_EXPLOSION)) {
|
||||
DamageCause damageCause;
|
||||
Entity damager = entityDamage;
|
||||
entityDamage = null;
|
||||
@@ -879,25 +879,25 @@ public class CraftEventFactory {
|
||||
entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled
|
||||
}
|
||||
return event;
|
||||
} else if (source instanceof EntityDamageSource) {
|
||||
Entity damager = source.getEntity();
|
||||
} else if (source.getEntity() != null) {
|
||||
Entity damager = source.getDirectEntity();
|
||||
DamageCause cause = (source.isSweep()) ? DamageCause.ENTITY_SWEEP_ATTACK : DamageCause.ENTITY_ATTACK;
|
||||
|
||||
if (source instanceof EntityDamageSourceIndirect) {
|
||||
damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource();
|
||||
if (source.isIndirect()) {
|
||||
damager = source.getEntity();
|
||||
if (damager.getBukkitEntity() instanceof ThrownPotion) {
|
||||
cause = DamageCause.MAGIC;
|
||||
} else if (damager.getBukkitEntity() instanceof Projectile) {
|
||||
cause = DamageCause.PROJECTILE;
|
||||
}
|
||||
} else if ("thorns".equals(source.msgId)) {
|
||||
} else if ("thorns".equals(source.getMsgId())) {
|
||||
cause = DamageCause.THORNS;
|
||||
} else if ("sonic_boom".equals(source.msgId)) {
|
||||
} else if ("sonic_boom".equals(source.getMsgId())) {
|
||||
cause = DamageCause.SONIC_BOOM;
|
||||
}
|
||||
|
||||
return callEntityDamageEvent(damager, entity, cause, modifiers, modifierFunctions, cancelled);
|
||||
} else if (source == DamageSource.OUT_OF_WORLD) {
|
||||
} else if (sourceType == DamageTypes.OUT_OF_WORLD) {
|
||||
EntityDamageEvent event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.VOID, modifiers, modifierFunctions);
|
||||
event.setCancelled(cancelled);
|
||||
callEvent(event);
|
||||
@@ -907,7 +907,7 @@ public class CraftEventFactory {
|
||||
entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled
|
||||
}
|
||||
return event;
|
||||
} else if (source == DamageSource.LAVA) {
|
||||
} else if (sourceType == DamageTypes.LAVA) {
|
||||
EntityDamageEvent event = (new EntityDamageByBlockEvent(blockDamage, entity.getBukkitEntity(), DamageCause.LAVA, modifiers, modifierFunctions));
|
||||
event.setCancelled(cancelled);
|
||||
|
||||
@@ -925,16 +925,16 @@ public class CraftEventFactory {
|
||||
} else if (blockDamage != null) {
|
||||
DamageCause cause = null;
|
||||
Block damager = blockDamage;
|
||||
if (source == DamageSource.CACTUS || source == DamageSource.SWEET_BERRY_BUSH || source == DamageSource.STALAGMITE || "fallingStalactite".equals(source.msgId) || "anvil".equals(source.msgId)) {
|
||||
if (sourceType == DamageTypes.CACTUS || sourceType == DamageTypes.SWEET_BERRY_BUSH || sourceType == DamageTypes.STALAGMITE || "fallingStalactite".equals(source.getMsgId()) || "anvil".equals(source.getMsgId())) {
|
||||
cause = DamageCause.CONTACT;
|
||||
} else if (source == DamageSource.HOT_FLOOR) {
|
||||
} else if (sourceType == DamageTypes.HOT_FLOOR) {
|
||||
cause = DamageCause.HOT_FLOOR;
|
||||
} else if (source == DamageSource.MAGIC) {
|
||||
} else if (sourceType == DamageTypes.MAGIC) {
|
||||
cause = DamageCause.MAGIC;
|
||||
} else if (source == DamageSource.IN_FIRE) {
|
||||
} else if (sourceType == DamageTypes.IN_FIRE) {
|
||||
cause = DamageCause.FIRE;
|
||||
} else {
|
||||
throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager, source.msgId));
|
||||
throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager, source.getMsgId()));
|
||||
}
|
||||
EntityDamageEvent event = new EntityDamageByBlockEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions);
|
||||
event.setCancelled(cancelled);
|
||||
@@ -953,18 +953,18 @@ public class CraftEventFactory {
|
||||
DamageCause cause = null;
|
||||
CraftEntity damager = entityDamage.getBukkitEntity();
|
||||
entityDamage = null;
|
||||
if ("fallingStalactite".equals(source.msgId) || "fallingBlock".equals(source.msgId) || "anvil".equals(source.msgId)) {
|
||||
if ("fallingStalactite".equals(source.getMsgId()) || "fallingBlock".equals(source.getMsgId()) || "anvil".equals(source.getMsgId())) {
|
||||
cause = DamageCause.FALLING_BLOCK;
|
||||
} else if (damager instanceof LightningStrike) {
|
||||
cause = DamageCause.LIGHTNING;
|
||||
} else if (source == DamageSource.FALL) {
|
||||
} else if (sourceType == DamageTypes.FALL) {
|
||||
cause = DamageCause.FALL;
|
||||
} else if (source == DamageSource.DRAGON_BREATH) {
|
||||
} else if (sourceType == DamageTypes.DRAGON_BREATH) {
|
||||
cause = DamageCause.DRAGON_BREATH;
|
||||
} else if (source == DamageSource.MAGIC) {
|
||||
} else if (sourceType == DamageTypes.MAGIC) {
|
||||
cause = DamageCause.MAGIC;
|
||||
} else {
|
||||
throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager.getHandle(), source.msgId));
|
||||
throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager.getHandle(), source.getMsgId()));
|
||||
}
|
||||
EntityDamageEvent event = new EntityDamageByEntityEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions);
|
||||
event.setCancelled(cancelled);
|
||||
@@ -978,35 +978,35 @@ public class CraftEventFactory {
|
||||
}
|
||||
|
||||
DamageCause cause = null;
|
||||
if (source == DamageSource.IN_FIRE) {
|
||||
if (sourceType == DamageTypes.IN_FIRE) {
|
||||
cause = DamageCause.FIRE;
|
||||
} else if (source == DamageSource.STARVE) {
|
||||
} else if (sourceType == DamageTypes.STARVE) {
|
||||
cause = DamageCause.STARVATION;
|
||||
} else if (source == DamageSource.WITHER) {
|
||||
} else if (sourceType == DamageTypes.WITHER) {
|
||||
cause = DamageCause.WITHER;
|
||||
} else if (source == DamageSource.IN_WALL) {
|
||||
} else if (sourceType == DamageTypes.IN_WALL) {
|
||||
cause = DamageCause.SUFFOCATION;
|
||||
} else if (source == DamageSource.DROWN) {
|
||||
} else if (sourceType == DamageTypes.DROWN) {
|
||||
cause = DamageCause.DROWNING;
|
||||
} else if (source == DamageSource.ON_FIRE) {
|
||||
} else if (sourceType == DamageTypes.ON_FIRE) {
|
||||
cause = DamageCause.FIRE_TICK;
|
||||
} else if (source == MELTING) {
|
||||
} else if (source.isMelting()) {
|
||||
cause = DamageCause.MELTING;
|
||||
} else if (source == POISON) {
|
||||
} else if (source.isPoison()) {
|
||||
cause = DamageCause.POISON;
|
||||
} else if (source == DamageSource.MAGIC) {
|
||||
} else if (sourceType == DamageTypes.MAGIC) {
|
||||
cause = DamageCause.MAGIC;
|
||||
} else if (source == DamageSource.FALL) {
|
||||
} else if (sourceType == DamageTypes.FALL) {
|
||||
cause = DamageCause.FALL;
|
||||
} else if (source == DamageSource.FLY_INTO_WALL) {
|
||||
} else if (sourceType == DamageTypes.FLY_INTO_WALL) {
|
||||
cause = DamageCause.FLY_INTO_WALL;
|
||||
} else if (source == DamageSource.CRAMMING) {
|
||||
} else if (sourceType == DamageTypes.CRAMMING) {
|
||||
cause = DamageCause.CRAMMING;
|
||||
} else if (source == DamageSource.DRY_OUT) {
|
||||
} else if (sourceType == DamageTypes.DRY_OUT) {
|
||||
cause = DamageCause.DRYOUT;
|
||||
} else if (source == DamageSource.FREEZE) {
|
||||
} else if (sourceType == DamageTypes.FREEZE) {
|
||||
cause = DamageCause.FREEZE;
|
||||
} else if (source == DamageSource.GENERIC) {
|
||||
} else {
|
||||
cause = DamageCause.CUSTOM;
|
||||
}
|
||||
|
||||
@@ -1014,7 +1014,7 @@ public class CraftEventFactory {
|
||||
return callEntityDamageEvent(null, entity, cause, modifiers, modifierFunctions, cancelled);
|
||||
}
|
||||
|
||||
throw new IllegalStateException(String.format("Unhandled damage of %s from %s", entity, source.msgId));
|
||||
throw new IllegalStateException(String.format("Unhandled damage of %s from %s", entity, source.getMsgId()));
|
||||
}
|
||||
|
||||
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) {
|
||||
@@ -1047,7 +1047,7 @@ public class CraftEventFactory {
|
||||
Map<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class);
|
||||
modifiers.put(DamageModifier.BASE, rawDamage);
|
||||
modifierFunctions.put(DamageModifier.BASE, ZERO);
|
||||
if ("fallingBlock".equals(source.msgId) || "anvil".equals(source.msgId)) {
|
||||
if ("fallingBlock".equals(source.getMsgId()) || "anvil".equals(source.getMsgId())) {
|
||||
modifiers.put(DamageModifier.HARD_HAT, hardHatModifier);
|
||||
modifierFunctions.put(DamageModifier.HARD_HAT, hardHat);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.common.base.Preconditions;
|
||||
import com.mojang.serialization.Codec;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
@@ -32,8 +33,6 @@ public class CustomWorldChunkManager extends WorldChunkManager {
|
||||
}
|
||||
|
||||
public CustomWorldChunkManager(WorldInfo worldInfo, BiomeProvider biomeProvider, IRegistry<BiomeBase> registry) {
|
||||
super(biomeListToBiomeBaseList(biomeProvider.getBiomes(worldInfo), registry));
|
||||
|
||||
this.worldInfo = worldInfo;
|
||||
this.biomeProvider = biomeProvider;
|
||||
this.registry = registry;
|
||||
@@ -51,4 +50,9 @@ public class CustomWorldChunkManager extends WorldChunkManager {
|
||||
|
||||
return CraftBlock.biomeToBiomeBase(registry, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<Holder<BiomeBase>> collectPossibleBiomes() {
|
||||
return biomeListToBiomeBaseList(biomeProvider.getBiomes(worldInfo), registry).stream();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import net.minecraft.core.IRegistryCustom;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.item.crafting.IRecipeComplex;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@@ -17,7 +18,7 @@ public class CraftComplexRecipe implements CraftRecipe, ComplexRecipe {
|
||||
|
||||
@Override
|
||||
public ItemStack getResult() {
|
||||
return CraftItemStack.asCraftMirror(recipe.getResultItem());
|
||||
return CraftItemStack.asCraftMirror(recipe.getResultItem(IRegistryCustom.EMPTY));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -119,7 +119,7 @@ public class CraftContainer extends Container {
|
||||
case ANVIL:
|
||||
return Containers.ANVIL;
|
||||
case SMITHING:
|
||||
return Containers.SMITHING;
|
||||
return Containers.LEGACY_SMITHING;
|
||||
case HOPPER:
|
||||
return Containers.HOPPER;
|
||||
case DROPPER:
|
||||
@@ -140,6 +140,8 @@ public class CraftContainer extends Container {
|
||||
return Containers.GRINDSTONE;
|
||||
case STONECUTTER:
|
||||
return Containers.STONECUTTER;
|
||||
case SMITHING_NEW:
|
||||
return Containers.SMITHING;
|
||||
case CREATIVE:
|
||||
case CRAFTING:
|
||||
case MERCHANT:
|
||||
@@ -215,6 +217,9 @@ public class CraftContainer extends Container {
|
||||
case MERCHANT:
|
||||
delegate = new ContainerMerchant(windowId, bottom);
|
||||
break;
|
||||
case SMITHING_NEW:
|
||||
setupSmithing(top, bottom); // SPIGOT-6783 - manually set up slots so we can use the delegated inventory and not the automatically created one
|
||||
break;
|
||||
}
|
||||
|
||||
if (delegate != null) {
|
||||
@@ -280,6 +285,28 @@ public class CraftContainer extends Container {
|
||||
// End copy from ContainerAnvilAbstract
|
||||
}
|
||||
|
||||
private void setupSmithing(IInventory top, IInventory bottom) {
|
||||
// This code copied from ContainerSmithing
|
||||
this.addSlot(new Slot(top, 0, 8, 48));
|
||||
this.addSlot(new Slot(top, 1, 26, 48));
|
||||
this.addSlot(new Slot(top, 2, 44, 48));
|
||||
this.addSlot(new Slot(top, 3, 98, 48));
|
||||
|
||||
int row;
|
||||
int col;
|
||||
|
||||
for (row = 0; row < 3; ++row) {
|
||||
for (col = 0; col < 9; ++col) {
|
||||
this.addSlot(new Slot(bottom, col + row * 9 + 9, 8 + col * 18, 84 + row * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (row = 0; row < 9; ++row) {
|
||||
this.addSlot(new Slot(bottom, row, 8 + row * 18, 142));
|
||||
}
|
||||
// End copy from ContainerSmithing
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(EntityHuman entityhuman, int i) {
|
||||
return (delegate != null) ? delegate.quickMoveStack(entityhuman, i) : ItemStack.EMPTY;
|
||||
|
||||
@@ -502,6 +502,8 @@ public class CraftInventory implements Inventory {
|
||||
return InventoryType.STONECUTTER;
|
||||
} else if (inventory instanceof BlockComposter.ContainerEmpty || inventory instanceof BlockComposter.ContainerInput || inventory instanceof BlockComposter.ContainerOutput) {
|
||||
return InventoryType.COMPOSTER;
|
||||
} else if (this instanceof CraftInventorySmithingNew) {
|
||||
return InventoryType.SMITHING_NEW;
|
||||
} else {
|
||||
return InventoryType.CHEST;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import net.minecraft.world.IInventory;
|
||||
import net.minecraft.world.inventory.InventoryCraftResult;
|
||||
import net.minecraft.world.item.crafting.IRecipe;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.SmithingInventory;
|
||||
|
||||
public class CraftInventorySmithingNew extends CraftResultInventory implements SmithingInventory {
|
||||
|
||||
private final Location location;
|
||||
|
||||
public CraftInventorySmithingNew(Location location, IInventory inventory, InventoryCraftResult resultInventory) {
|
||||
super(inventory, resultInventory);
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryCraftResult getResultInventory() {
|
||||
return (InventoryCraftResult) super.getResultInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getResult() {
|
||||
return getItem(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResult(ItemStack item) {
|
||||
setItem(3, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Recipe getRecipe() {
|
||||
IRecipe recipe = getResultInventory().getRecipeUsed();
|
||||
return (recipe == null) ? null : recipe.toBukkitRecipe();
|
||||
}
|
||||
}
|
||||
@@ -184,6 +184,7 @@ public final class CraftItemFactory implements ItemFactory {
|
||||
case SKELETON_HORSE_SPAWN_EGG:
|
||||
case SKELETON_SPAWN_EGG:
|
||||
case SLIME_SPAWN_EGG:
|
||||
case SNIFFER_SPAWN_EGG:
|
||||
case SNOW_GOLEM_SPAWN_EGG:
|
||||
case SPIDER_SPAWN_EGG:
|
||||
case SQUID_SPAWN_EGG:
|
||||
@@ -230,6 +231,10 @@ public final class CraftItemFactory implements ItemFactory {
|
||||
case BIRCH_SIGN:
|
||||
case BIRCH_WALL_HANGING_SIGN:
|
||||
case BIRCH_WALL_SIGN:
|
||||
case CHERRY_HANGING_SIGN:
|
||||
case CHERRY_SIGN:
|
||||
case CHERRY_WALL_HANGING_SIGN:
|
||||
case CHERRY_WALL_SIGN:
|
||||
case CRIMSON_HANGING_SIGN:
|
||||
case CRIMSON_SIGN:
|
||||
case CRIMSON_WALL_HANGING_SIGN:
|
||||
@@ -302,6 +307,8 @@ public final class CraftItemFactory implements ItemFactory {
|
||||
case SCULK_SHRIEKER:
|
||||
case SCULK_SENSOR:
|
||||
case CHISELED_BOOKSHELF:
|
||||
case DECORATED_POT:
|
||||
case SUSPICIOUS_SAND:
|
||||
return new CraftMetaBlockState(meta, material);
|
||||
case TROPICAL_FISH_BUCKET:
|
||||
return meta instanceof CraftMetaTropicalFishBucket ? meta : new CraftMetaTropicalFishBucket(meta);
|
||||
|
||||
@@ -447,6 +447,7 @@ public final class CraftItemStack extends ItemStack {
|
||||
case SKELETON_HORSE_SPAWN_EGG:
|
||||
case SKELETON_SPAWN_EGG:
|
||||
case SLIME_SPAWN_EGG:
|
||||
case SNIFFER_SPAWN_EGG:
|
||||
case SNOW_GOLEM_SPAWN_EGG:
|
||||
case SPIDER_SPAWN_EGG:
|
||||
case SQUID_SPAWN_EGG:
|
||||
@@ -493,6 +494,10 @@ public final class CraftItemStack extends ItemStack {
|
||||
case BIRCH_SIGN:
|
||||
case BIRCH_WALL_HANGING_SIGN:
|
||||
case BIRCH_WALL_SIGN:
|
||||
case CHERRY_HANGING_SIGN:
|
||||
case CHERRY_SIGN:
|
||||
case CHERRY_WALL_HANGING_SIGN:
|
||||
case CHERRY_WALL_SIGN:
|
||||
case CRIMSON_HANGING_SIGN:
|
||||
case CRIMSON_SIGN:
|
||||
case CRIMSON_WALL_HANGING_SIGN:
|
||||
@@ -565,6 +570,8 @@ public final class CraftItemStack extends ItemStack {
|
||||
case SCULK_SHRIEKER:
|
||||
case SCULK_SENSOR:
|
||||
case CHISELED_BOOKSHELF:
|
||||
case DECORATED_POT:
|
||||
case SUSPICIOUS_SAND:
|
||||
return new CraftMetaBlockState(item.getTag(), CraftMagicNumbers.getMaterial(item.getItem()));
|
||||
case TROPICAL_FISH_BUCKET:
|
||||
return new CraftMetaTropicalFishBucket(item.getTag());
|
||||
|
||||
@@ -59,6 +59,10 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
||||
Material.BIRCH_SIGN,
|
||||
Material.BIRCH_WALL_HANGING_SIGN,
|
||||
Material.BIRCH_WALL_SIGN,
|
||||
Material.CHERRY_HANGING_SIGN,
|
||||
Material.CHERRY_SIGN,
|
||||
Material.CHERRY_WALL_HANGING_SIGN,
|
||||
Material.CHERRY_WALL_SIGN,
|
||||
Material.CRIMSON_HANGING_SIGN,
|
||||
Material.CRIMSON_SIGN,
|
||||
Material.CRIMSON_WALL_HANGING_SIGN,
|
||||
@@ -113,7 +117,9 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
||||
Material.SCULK_CATALYST,
|
||||
Material.SCULK_SHRIEKER,
|
||||
Material.SCULK_SENSOR,
|
||||
Material.CHISELED_BOOKSHELF
|
||||
Material.CHISELED_BOOKSHELF,
|
||||
Material.DECORATED_POT,
|
||||
Material.SUSPICIOUS_SAND
|
||||
);
|
||||
|
||||
static {
|
||||
|
||||
@@ -71,6 +71,7 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta {
|
||||
Material.SKELETON_HORSE_SPAWN_EGG,
|
||||
Material.SKELETON_SPAWN_EGG,
|
||||
Material.SLIME_SPAWN_EGG,
|
||||
Material.SNIFFER_SPAWN_EGG,
|
||||
Material.SNOW_GOLEM_SPAWN_EGG,
|
||||
Material.SPIDER_SPAWN_EGG,
|
||||
Material.SQUID_SPAWN_EGG,
|
||||
|
||||
@@ -24,6 +24,6 @@ public class CraftSmithingRecipe extends SmithingRecipe implements CraftRecipe {
|
||||
public void addToCraftingManager() {
|
||||
ItemStack result = this.getResult();
|
||||
|
||||
MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeSmithing(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result)));
|
||||
MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.LegacyUpgradeRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.RecipeChoice;
|
||||
import org.bukkit.inventory.SmithingTransformRecipe;
|
||||
|
||||
public class CraftSmithingTransformRecipe extends SmithingTransformRecipe implements CraftRecipe {
|
||||
public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition) {
|
||||
super(key, result, template, base, addition);
|
||||
}
|
||||
|
||||
public static CraftSmithingTransformRecipe fromBukkitRecipe(SmithingTransformRecipe recipe) {
|
||||
if (recipe instanceof CraftSmithingTransformRecipe) {
|
||||
return (CraftSmithingTransformRecipe) recipe;
|
||||
}
|
||||
CraftSmithingTransformRecipe ret = new CraftSmithingTransformRecipe(recipe.getKey(), recipe.getResult(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToCraftingManager() {
|
||||
ItemStack result = this.getResult();
|
||||
|
||||
MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.SmithingTransformRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.inventory.RecipeChoice;
|
||||
import org.bukkit.inventory.SmithingTrimRecipe;
|
||||
|
||||
public class CraftSmithingTrimRecipe extends SmithingTrimRecipe implements CraftRecipe {
|
||||
|
||||
public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition) {
|
||||
super(key, template, base, addition);
|
||||
}
|
||||
|
||||
public static CraftSmithingTrimRecipe fromBukkitRecipe(SmithingTrimRecipe recipe) {
|
||||
if (recipe instanceof CraftSmithingTrimRecipe) {
|
||||
return (CraftSmithingTrimRecipe) recipe;
|
||||
}
|
||||
CraftSmithingTrimRecipe ret = new CraftSmithingTrimRecipe(recipe.getKey(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToCraftingManager() {
|
||||
MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.SmithingTrimRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true)));
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ public final class CraftInventoryCreator {
|
||||
converterMap.put(InventoryType.CARTOGRAPHY, DEFAULT_CONVERTER);
|
||||
converterMap.put(InventoryType.GRINDSTONE, DEFAULT_CONVERTER);
|
||||
converterMap.put(InventoryType.STONECUTTER, DEFAULT_CONVERTER);
|
||||
converterMap.put(InventoryType.SMITHING_NEW, DEFAULT_CONVERTER);
|
||||
}
|
||||
|
||||
public Inventory createInventory(InventoryHolder holder, InventoryType type) {
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
|
||||
// Util class to create custom DamageSources.
|
||||
public final class CraftDamageSource extends DamageSource {
|
||||
public static DamageSource copyOf(final DamageSource original) {
|
||||
CraftDamageSource newSource = new CraftDamageSource(original.msgId);
|
||||
|
||||
// Check ignoresArmor
|
||||
if (original.isBypassArmor()) {
|
||||
newSource.bypassArmor();
|
||||
}
|
||||
|
||||
// Check magic
|
||||
if (original.isMagic()) {
|
||||
newSource.setMagic();
|
||||
}
|
||||
|
||||
// Check fire
|
||||
if (original.isFire()) {
|
||||
newSource.setIsFire();
|
||||
}
|
||||
|
||||
return newSource;
|
||||
}
|
||||
|
||||
private CraftDamageSource(String identifier) {
|
||||
super(identifier);
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package org.bukkit.craftbukkit.util;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
|
||||
public class CraftIconCache implements CachedServerIcon {
|
||||
public final String value;
|
||||
public final byte[] value;
|
||||
|
||||
public CraftIconCache(final String value) {
|
||||
public CraftIconCache(final byte[] value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,12 +237,12 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
* @return string
|
||||
*/
|
||||
public String getMappingsVersion() {
|
||||
return "1afe2ffe8a9d7fc510442a168b3d4338";
|
||||
return "3009edc0fff87fa34680686663bd59df";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDataVersion() {
|
||||
return SharedConstants.getCurrentVersion().getWorldVersion();
|
||||
return SharedConstants.getCurrentVersion().getDataVersion().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user