Remap CraftBukkit to Mojang+Yarn Mappings

By: Initial Source <noreply+automated@papermc.io>
This commit is contained in:
CraftBukkit/Spigot
2024-12-11 22:26:55 +01:00
parent a265d64138
commit 30e4583dbe
1780 changed files with 44628 additions and 41274 deletions

View File

@@ -1,11 +1,11 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.BlockPos;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.GeneratorAccessSeed;
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.entity.TileEntity;
import net.minecraft.world.level.block.entity.TileEntityBeehive;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.entity.BeehiveBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -33,7 +33,7 @@ public final class CapturedBlockState extends CraftBlockState {
// Probably no longer needed with the extra #updatedTree method,
// but leave if here for now in case a plugin for whatever reason relies on this.
addBees();
this.addBees();
return result;
}
@@ -41,27 +41,27 @@ public final class CapturedBlockState extends CraftBlockState {
private void updatedTree() {
// SPIGOT-7248 - Manual update to avoid physics where appropriate
// SPIGOT-7572 - Move SPIGOT-7248 fix from nms ItemStack to here, to allow bee generation in nests
world.getHandle().setBlock(CraftLocation.toBlockPosition(getLocation()), getHandle(), getFlag());
this.world.getHandle().setBlock(CraftLocation.toBlockPosition(this.getLocation()), this.getHandle(), this.getFlag());
addBees();
this.addBees();
}
private void addBees() {
// SPIGOT-5537: Horrible hack to manually add bees given World.captureTreeGeneration does not support tiles
if (this.treeBlock && getType() == Material.BEE_NEST) {
GeneratorAccessSeed generatoraccessseed = this.world.getHandle();
BlockPosition blockposition1 = this.getPosition();
if (this.treeBlock && this.getType() == Material.BEE_NEST) {
WorldGenLevel generatoraccessseed = this.world.getHandle();
BlockPos blockposition1 = this.getPosition();
RandomSource random = generatoraccessseed.getRandom();
// Begin copied block from WorldGenFeatureTreeBeehive
TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition1);
BlockEntity tileentity = generatoraccessseed.getBlockEntity(blockposition1);
if (tileentity instanceof TileEntityBeehive) {
TileEntityBeehive tileentitybeehive = (TileEntityBeehive) tileentity;
if (tileentity instanceof BeehiveBlockEntity) {
BeehiveBlockEntity tileentitybeehive = (BeehiveBlockEntity) tileentity;
int j = 2 + random.nextInt(2);
for (int k = 0; k < j; ++k) {
tileentitybeehive.storeBee(TileEntityBeehive.c.create(random.nextInt(599)));
tileentitybeehive.storeBee(BeehiveBlockEntity.Occupant.create(random.nextInt(599)));
}
}
// End copied block
@@ -78,11 +78,11 @@ public final class CapturedBlockState extends CraftBlockState {
return new CapturedBlockState(this, location);
}
public static CapturedBlockState getBlockState(World world, BlockPosition pos, int flag) {
public static CapturedBlockState getBlockState(Level world, BlockPos pos, int flag) {
return new CapturedBlockState(world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), flag, false);
}
public static CapturedBlockState getTreeBlockState(World world, BlockPosition pos, int flag) {
public static CapturedBlockState getTreeBlockState(Level world, BlockPos pos, int flag) {
return new CapturedBlockState(world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), flag, true);
}

View File

@@ -3,10 +3,9 @@ package org.bukkit.craftbukkit.block;
import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.world.item.EnumColor;
import net.minecraft.world.level.block.BlockBannerAbstract;
import net.minecraft.world.level.block.AbstractBannerBlock;
import net.minecraft.world.level.block.entity.BannerBlockEntity;
import net.minecraft.world.level.block.entity.BannerPatternLayers;
import net.minecraft.world.level.block.entity.TileEntityBanner;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.World;
@@ -14,12 +13,12 @@ import org.bukkit.block.Banner;
import org.bukkit.block.banner.Pattern;
import org.bukkit.craftbukkit.block.banner.CraftPatternType;
public class CraftBanner extends CraftBlockEntityState<TileEntityBanner> implements Banner {
public class CraftBanner extends CraftBlockEntityState<BannerBlockEntity> implements Banner {
private DyeColor base;
private List<Pattern> patterns;
public CraftBanner(World world, TileEntityBanner tileEntity) {
public CraftBanner(World world, BannerBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -30,16 +29,16 @@ public class CraftBanner extends CraftBlockEntityState<TileEntityBanner> impleme
}
@Override
public void load(TileEntityBanner banner) {
public void load(BannerBlockEntity banner) {
super.load(banner);
base = DyeColor.getByWoolData((byte) ((BlockBannerAbstract) this.data.getBlock()).getColor().getId());
patterns = new ArrayList<Pattern>();
this.base = DyeColor.getByWoolData((byte) ((AbstractBannerBlock) this.data.getBlock()).getColor().getId());
this.patterns = new ArrayList<Pattern>();
if (banner.getPatterns() != null) {
for (int i = 0; i < banner.getPatterns().layers().size(); i++) {
BannerPatternLayers.b p = banner.getPatterns().layers().get(i);
patterns.add(new Pattern(DyeColor.getByWoolData((byte) p.color().getId()), CraftPatternType.minecraftHolderToBukkit(p.pattern())));
BannerPatternLayers.Layer p = banner.getPatterns().layers().get(i);
this.patterns.add(new Pattern(DyeColor.getByWoolData((byte) p.color().getId()), CraftPatternType.minecraftHolderToBukkit(p.pattern())));
}
}
}
@@ -57,7 +56,7 @@ public class CraftBanner extends CraftBlockEntityState<TileEntityBanner> impleme
@Override
public List<Pattern> getPatterns() {
return new ArrayList<Pattern>(patterns);
return new ArrayList<Pattern>(this.patterns);
}
@Override
@@ -87,19 +86,19 @@ public class CraftBanner extends CraftBlockEntityState<TileEntityBanner> impleme
@Override
public int numberOfPatterns() {
return patterns.size();
return this.patterns.size();
}
@Override
public void applyTo(TileEntityBanner banner) {
public void applyTo(BannerBlockEntity banner) {
super.applyTo(banner);
banner.baseColor = EnumColor.byId(base.getWoolData());
banner.baseColor = net.minecraft.world.item.DyeColor.byId(this.base.getWoolData());
List<BannerPatternLayers.b> newPatterns = new ArrayList<>();
List<BannerPatternLayers.Layer> newPatterns = new ArrayList<>();
for (Pattern p : patterns) {
newPatterns.add(new net.minecraft.world.level.block.entity.BannerPatternLayers.b(CraftPatternType.bukkitToMinecraftHolder(p.getPattern()), EnumColor.byId(p.getColor().getWoolData())));
for (Pattern p : this.patterns) {
newPatterns.add(new net.minecraft.world.level.block.entity.BannerPatternLayers.Layer(CraftPatternType.bukkitToMinecraftHolder(p.getPattern()), net.minecraft.world.item.DyeColor.byId(p.getColor().getWoolData())));
}
banner.setPatterns(new BannerPatternLayers(newPatterns));
}

View File

@@ -1,18 +1,18 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.sounds.SoundEffects;
import net.minecraft.world.level.block.BlockBarrel;
import net.minecraft.world.level.block.entity.TileEntityBarrel;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.block.BarrelBlock;
import net.minecraft.world.level.block.entity.BarrelBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Barrel;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.inventory.Inventory;
public class CraftBarrel extends CraftLootable<TileEntityBarrel> implements Barrel {
public class CraftBarrel extends CraftLootable<BarrelBlockEntity> implements Barrel {
public CraftBarrel(World world, TileEntityBarrel tileEntity) {
public CraftBarrel(World world, BarrelBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -36,32 +36,32 @@ public class CraftBarrel extends CraftLootable<TileEntityBarrel> implements Barr
@Override
public void open() {
requirePlaced();
if (!getTileEntity().openersCounter.opened) {
IBlockData blockData = getTileEntity().getBlockState();
boolean open = blockData.getValue(BlockBarrel.OPEN);
this.requirePlaced();
if (!this.getTileEntity().openersCounter.opened) {
BlockState blockData = this.getTileEntity().getBlockState();
boolean open = blockData.getValue(BarrelBlock.OPEN);
if (!open) {
getTileEntity().updateBlockState(blockData, true);
if (getWorldHandle() instanceof net.minecraft.world.level.World) {
getTileEntity().playSound(blockData, SoundEffects.BARREL_OPEN);
this.getTileEntity().updateBlockState(blockData, true);
if (this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
this.getTileEntity().playSound(blockData, SoundEvents.BARREL_OPEN);
}
}
}
getTileEntity().openersCounter.opened = true;
this.getTileEntity().openersCounter.opened = true;
}
@Override
public void close() {
requirePlaced();
if (getTileEntity().openersCounter.opened) {
IBlockData blockData = getTileEntity().getBlockState();
getTileEntity().updateBlockState(blockData, false);
if (getWorldHandle() instanceof net.minecraft.world.level.World) {
getTileEntity().playSound(blockData, SoundEffects.BARREL_CLOSE);
this.requirePlaced();
if (this.getTileEntity().openersCounter.opened) {
BlockState blockData = this.getTileEntity().getBlockState();
this.getTileEntity().updateBlockState(blockData, false);
if (this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
this.getTileEntity().playSound(blockData, SoundEvents.BARREL_CLOSE);
}
}
getTileEntity().openersCounter.opened = false;
this.getTileEntity().openersCounter.opened = false;
}
@Override

View File

@@ -4,15 +4,15 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
import net.minecraft.advancements.critereon.CriterionConditionItem;
import net.minecraft.advancements.critereon.CriterionConditionValue;
import net.minecraft.advancements.critereon.ItemPredicate;
import net.minecraft.advancements.critereon.MinMaxBounds;
import net.minecraft.core.component.DataComponentPredicate;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.world.ChestLock;
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.level.block.entity.TileEntity;
import net.minecraft.world.level.block.entity.TileEntityBeacon;
import net.minecraft.network.chat.Component;
import net.minecraft.world.LockCode;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.entity.BeaconBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Beacon;
@@ -24,9 +24,9 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class CraftBeacon extends CraftBlockEntityState<TileEntityBeacon> implements Beacon {
public class CraftBeacon extends CraftBlockEntityState<BeaconBlockEntity> implements Beacon {
public CraftBeacon(World world, TileEntityBeacon tileEntity) {
public CraftBeacon(World world, BeaconBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -36,16 +36,16 @@ public class CraftBeacon extends CraftBlockEntityState<TileEntityBeacon> impleme
@Override
public Collection<LivingEntity> getEntitiesInRange() {
ensureNoWorldGeneration();
this.ensureNoWorldGeneration();
TileEntity tileEntity = this.getTileEntityFromWorld();
if (tileEntity instanceof TileEntityBeacon) {
TileEntityBeacon beacon = (TileEntityBeacon) tileEntity;
BlockEntity tileEntity = this.getTileEntityFromWorld();
if (tileEntity instanceof BeaconBlockEntity) {
BeaconBlockEntity beacon = (BeaconBlockEntity) tileEntity;
Collection<EntityHuman> nms = TileEntityBeacon.getHumansInRange(beacon.getLevel(), beacon.getBlockPos(), beacon.levels);
Collection<Player> nms = BeaconBlockEntity.getHumansInRange(beacon.getLevel(), beacon.getBlockPos(), beacon.levels);
Collection<LivingEntity> bukkit = new ArrayList<LivingEntity>(nms.size());
for (EntityHuman human : nms) {
for (Player human : nms) {
bukkit.add(human.getBukkitEntity());
}
@@ -83,7 +83,7 @@ public class CraftBeacon extends CraftBlockEntityState<TileEntityBeacon> impleme
@Override
public String getCustomName() {
TileEntityBeacon beacon = this.getSnapshot();
BeaconBlockEntity beacon = this.getSnapshot();
return beacon.name != null ? CraftChatMessage.fromComponent(beacon.name) : null;
}
@@ -94,12 +94,12 @@ public class CraftBeacon extends CraftBlockEntityState<TileEntityBeacon> impleme
@Override
public boolean isLocked() {
return this.getSnapshot().lockKey != ChestLock.NO_LOCK;
return this.getSnapshot().lockKey != LockCode.NO_LOCK;
}
@Override
public String getLock() {
Optional<? extends IChatBaseComponent> customName = this.getSnapshot().lockKey.predicate().components().asPatch().get(DataComponents.CUSTOM_NAME);
Optional<? extends Component> customName = this.getSnapshot().lockKey.predicate().components().asPatch().get(DataComponents.CUSTOM_NAME);
return (customName != null) ? customName.map(CraftChatMessage::fromComponent).orElse("") : "";
}
@@ -107,19 +107,19 @@ public class CraftBeacon extends CraftBlockEntityState<TileEntityBeacon> impleme
@Override
public void setLock(String key) {
if (key == null) {
this.getSnapshot().lockKey = ChestLock.NO_LOCK;
this.getSnapshot().lockKey = LockCode.NO_LOCK;
} else {
DataComponentPredicate predicate = DataComponentPredicate.builder().expect(DataComponents.CUSTOM_NAME, CraftChatMessage.fromStringOrNull(key)).build();
this.getSnapshot().lockKey = new ChestLock(new CriterionConditionItem(Optional.empty(), CriterionConditionValue.IntegerRange.ANY, predicate, Collections.emptyMap()));
this.getSnapshot().lockKey = new LockCode(new ItemPredicate(Optional.empty(), MinMaxBounds.Ints.ANY, predicate, Collections.emptyMap()));
}
}
@Override
public void setLockItem(ItemStack key) {
if (key == null) {
this.getSnapshot().lockKey = ChestLock.NO_LOCK;
this.getSnapshot().lockKey = LockCode.NO_LOCK;
} else {
this.getSnapshot().lockKey = new ChestLock(CraftItemStack.asCriterionConditionItem(key));
this.getSnapshot().lockKey = new LockCode(CraftItemStack.asCriterionConditionItem(key));
}
}

View File

@@ -1,14 +1,14 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.TileEntityBed;
import net.minecraft.world.level.block.entity.BedBlockEntity;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Bed;
public class CraftBed extends CraftBlockEntityState<TileEntityBed> implements Bed {
public class CraftBed extends CraftBlockEntityState<BedBlockEntity> implements Bed {
public CraftBed(World world, TileEntityBed tileEntity) {
public CraftBed(World world, BedBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -18,7 +18,7 @@ public class CraftBed extends CraftBlockEntityState<TileEntityBed> implements Be
@Override
public DyeColor getColor() {
switch (getType()) {
switch (this.getType()) {
case BLACK_BED:
return DyeColor.BLACK;
case BLUE_BED:
@@ -52,7 +52,7 @@ public class CraftBed extends CraftBlockEntityState<TileEntityBed> implements Be
case YELLOW_BED:
return DyeColor.YELLOW;
default:
throw new IllegalArgumentException("Unknown DyeColor for " + getType());
throw new IllegalArgumentException("Unknown DyeColor for " + this.getType());
}
}

View File

@@ -3,10 +3,10 @@ package org.bukkit.craftbukkit.block;
import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.block.entity.TileEntityBeehive;
import net.minecraft.world.level.block.entity.TileEntityBeehive.ReleaseStatus;
import net.minecraft.world.level.block.entity.BeehiveBlockEntity;
import net.minecraft.world.level.block.entity.BeehiveBlockEntity.BeeReleaseStatus;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Beehive;
@@ -14,9 +14,9 @@ import org.bukkit.craftbukkit.entity.CraftBee;
import org.bukkit.craftbukkit.util.CraftLocation;
import org.bukkit.entity.Bee;
public class CraftBeehive extends CraftBlockEntityState<TileEntityBeehive> implements Beehive {
public class CraftBeehive extends CraftBlockEntityState<BeehiveBlockEntity> implements Beehive {
public CraftBeehive(World world, TileEntityBeehive tileEntity) {
public CraftBeehive(World world, BeehiveBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -26,52 +26,52 @@ public class CraftBeehive extends CraftBlockEntityState<TileEntityBeehive> imple
@Override
public Location getFlower() {
BlockPosition flower = getSnapshot().savedFlowerPos;
return (flower == null) ? null : CraftLocation.toBukkit(flower, getWorld());
BlockPos flower = this.getSnapshot().savedFlowerPos;
return (flower == null) ? null : CraftLocation.toBukkit(flower, this.getWorld());
}
@Override
public void setFlower(Location location) {
Preconditions.checkArgument(location == null || this.getWorld().equals(location.getWorld()), "Flower must be in same world");
getSnapshot().savedFlowerPos = (location == null) ? null : CraftLocation.toBlockPosition(location);
this.getSnapshot().savedFlowerPos = (location == null) ? null : CraftLocation.toBlockPosition(location);
}
@Override
public boolean isFull() {
return getSnapshot().isFull();
return this.getSnapshot().isFull();
}
@Override
public boolean isSedated() {
return isPlaced() && getTileEntity().isSedated();
return this.isPlaced() && this.getTileEntity().isSedated();
}
@Override
public int getEntityCount() {
return getSnapshot().getOccupantCount();
return this.getSnapshot().getOccupantCount();
}
@Override
public int getMaxEntities() {
return getSnapshot().maxBees;
return this.getSnapshot().maxBees;
}
@Override
public void setMaxEntities(int max) {
Preconditions.checkArgument(max > 0, "Max bees must be more than 0");
getSnapshot().maxBees = max;
this.getSnapshot().maxBees = max;
}
@Override
public List<Bee> releaseEntities() {
ensureNoWorldGeneration();
this.ensureNoWorldGeneration();
List<Bee> bees = new ArrayList<>();
if (isPlaced()) {
TileEntityBeehive beehive = ((TileEntityBeehive) this.getTileEntityFromWorld());
for (Entity bee : beehive.releaseBees(this.getHandle(), ReleaseStatus.BEE_RELEASED, true)) {
if (this.isPlaced()) {
BeehiveBlockEntity beehive = ((BeehiveBlockEntity) this.getTileEntityFromWorld());
for (Entity bee : beehive.releaseBees(this.getHandle(), BeeReleaseStatus.BEE_RELEASED, true)) {
bees.add((Bee) bee.getBukkitEntity());
}
}
@@ -83,7 +83,7 @@ public class CraftBeehive extends CraftBlockEntityState<TileEntityBeehive> imple
public void addEntity(Bee entity) {
Preconditions.checkArgument(entity != null, "Entity must not be null");
getSnapshot().addOccupant(((CraftBee) entity).getHandle());
this.getSnapshot().addOccupant(((CraftBee) entity).getHandle());
}
@Override

View File

@@ -1,11 +1,11 @@
package org.bukkit.craftbukkit.block;
import com.google.common.base.Preconditions;
import net.minecraft.core.EnumDirection;
import net.minecraft.world.level.block.BlockBell;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.BellBlock;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.TileEntity;
import net.minecraft.world.level.block.entity.TileEntityBell;
import net.minecraft.world.level.block.entity.BellBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Bell;
@@ -13,9 +13,9 @@ import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.entity.Entity;
public class CraftBell extends CraftBlockEntityState<TileEntityBell> implements Bell {
public class CraftBell extends CraftBlockEntityState<BellBlockEntity> implements Bell {
public CraftBell(World world, TileEntityBell tileEntity) {
public CraftBell(World world, BellBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -27,50 +27,50 @@ public class CraftBell extends CraftBlockEntityState<TileEntityBell> implements
public boolean ring(Entity entity, BlockFace direction) {
Preconditions.checkArgument(direction == null || direction.isCartesian(), "direction must be cartesian, given %s", direction);
TileEntity tileEntity = getTileEntityFromWorld();
BlockEntity tileEntity = this.getTileEntityFromWorld();
if (tileEntity == null) {
return false;
}
net.minecraft.world.entity.Entity nmsEntity = (entity != null) ? ((CraftEntity) entity).getHandle() : null;
EnumDirection enumDirection = CraftBlock.blockFaceToNotch(direction);
Direction enumDirection = CraftBlock.blockFaceToNotch(direction);
return ((BlockBell) Blocks.BELL).attemptToRing(nmsEntity, world.getHandle(), getPosition(), enumDirection);
return ((BellBlock) Blocks.BELL).attemptToRing(nmsEntity, this.world.getHandle(), this.getPosition(), enumDirection);
}
@Override
public boolean ring(Entity entity) {
return ring(entity, null);
return this.ring(entity, null);
}
@Override
public boolean ring(BlockFace direction) {
return ring(null, direction);
return this.ring(null, direction);
}
@Override
public boolean ring() {
return ring(null, null);
return this.ring(null, null);
}
@Override
public boolean isShaking() {
return getSnapshot().shaking;
return this.getSnapshot().shaking;
}
@Override
public int getShakingTicks() {
return getSnapshot().ticks;
return this.getSnapshot().ticks;
}
@Override
public boolean isResonating() {
return getSnapshot().resonating;
return this.getSnapshot().resonating;
}
@Override
public int getResonatingTicks() {
return isResonating() ? getSnapshot().ticks : 0;
return this.isResonating() ? this.getSnapshot().ticks : 0;
}
@Override

View File

@@ -2,9 +2,7 @@ package org.bukkit.craftbukkit.block;
import java.util.Locale;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.level.biome.BiomeBase;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.block.Biome;
@@ -12,19 +10,19 @@ import org.bukkit.craftbukkit.CraftRegistry;
import org.bukkit.craftbukkit.util.Handleable;
import org.jetbrains.annotations.NotNull;
public class CraftBiome implements Biome, Handleable<BiomeBase> {
public class CraftBiome implements Biome, Handleable<net.minecraft.world.level.biome.Biome> {
private static int count = 0;
public static Biome minecraftToBukkit(BiomeBase minecraft) {
public static Biome minecraftToBukkit(net.minecraft.world.level.biome.Biome minecraft) {
return CraftRegistry.minecraftToBukkit(minecraft, Registries.BIOME, Registry.BIOME);
}
public static Biome minecraftHolderToBukkit(Holder<BiomeBase> minecraft) {
return minecraftToBukkit(minecraft.value());
public static Biome minecraftHolderToBukkit(Holder<net.minecraft.world.level.biome.Biome> minecraft) {
return CraftBiome.minecraftToBukkit(minecraft.value());
}
public static BiomeBase bukkitToMinecraft(Biome bukkit) {
public static net.minecraft.world.level.biome.Biome bukkitToMinecraft(Biome bukkit) {
if (bukkit == Biome.CUSTOM) {
return null;
}
@@ -32,14 +30,14 @@ public class CraftBiome implements Biome, Handleable<BiomeBase> {
return CraftRegistry.bukkitToMinecraft(bukkit);
}
public static Holder<BiomeBase> bukkitToMinecraftHolder(Biome bukkit) {
public static Holder<net.minecraft.world.level.biome.Biome> bukkitToMinecraftHolder(Biome bukkit) {
if (bukkit == Biome.CUSTOM) {
return null;
}
IRegistry<BiomeBase> registry = CraftRegistry.getMinecraftRegistry(Registries.BIOME);
net.minecraft.core.Registry<net.minecraft.world.level.biome.Biome> registry = CraftRegistry.getMinecraftRegistry(Registries.BIOME);
if (registry.wrapAsHolder(bukkitToMinecraft(bukkit)) instanceof Holder.c<BiomeBase> holder) {
if (registry.wrapAsHolder(CraftBiome.bukkitToMinecraft(bukkit)) instanceof Holder.Reference<net.minecraft.world.level.biome.Biome> holder) {
return holder;
}
@@ -48,11 +46,11 @@ public class CraftBiome implements Biome, Handleable<BiomeBase> {
}
private final NamespacedKey key;
private final BiomeBase biomeBase;
private final net.minecraft.world.level.biome.Biome biomeBase;
private final String name;
private final int ordinal;
public CraftBiome(NamespacedKey key, BiomeBase biomeBase) {
public CraftBiome(NamespacedKey key, net.minecraft.world.level.biome.Biome biomeBase) {
this.key = key;
this.biomeBase = biomeBase;
// For backwards compatibility, minecraft values will stile return the uppercase name without the namespace,
@@ -64,40 +62,40 @@ public class CraftBiome implements Biome, Handleable<BiomeBase> {
} else {
this.name = key.toString();
}
this.ordinal = count++;
this.ordinal = CraftBiome.count++;
}
@Override
public BiomeBase getHandle() {
return biomeBase;
public net.minecraft.world.level.biome.Biome getHandle() {
return this.biomeBase;
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
return this.key;
}
@Override
public int compareTo(@NotNull Biome biome) {
return ordinal - biome.ordinal();
return this.ordinal - biome.ordinal();
}
@NotNull
@Override
public String name() {
return name;
return this.name;
}
@Override
public int ordinal() {
return ordinal;
return this.ordinal;
}
@Override
public String toString() {
// For backwards compatibility
return name();
return this.name();
}
@Override
@@ -110,11 +108,11 @@ public class CraftBiome implements Biome, Handleable<BiomeBase> {
return false;
}
return getKey().equals(otherBiome.getKey());
return this.getKey().equals(otherBiome.getKey());
}
@Override
public int hashCode() {
return getKey().hashCode();
return this.getKey().hashCode();
}
}

View File

@@ -1,13 +1,13 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.TileEntityBlastFurnace;
import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.BlastFurnace;
public class CraftBlastFurnace extends CraftFurnace<TileEntityBlastFurnace> implements BlastFurnace {
public class CraftBlastFurnace extends CraftFurnace<BlastFurnaceBlockEntity> implements BlastFurnace {
public CraftBlastFurnace(World world, TileEntityBlastFurnace tileEntity) {
public CraftBlastFurnace(World world, BlastFurnaceBlockEntity tileEntity) {
super(world, tileEntity);
}

View File

@@ -6,27 +6,26 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.EnumDirection;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.EnumHand;
import net.minecraft.world.EnumInteractionResult;
import net.minecraft.world.item.ItemBoneMeal;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.BoneMealItem;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.context.ItemActionContext;
import net.minecraft.world.level.EnumSkyBlock;
import net.minecraft.world.level.GeneratorAccess;
import net.minecraft.world.level.RayTrace;
import net.minecraft.world.level.block.BlockRedstoneWire;
import net.minecraft.world.level.block.BlockSapling;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.phys.Vec3D;
import net.minecraft.world.level.block.RedStoneWireBlock;
import net.minecraft.world.level.block.SaplingBlock;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.FluidCollisionMode;
@@ -63,51 +62,51 @@ import org.bukkit.util.RayTraceResult;
import org.bukkit.util.Vector;
public class CraftBlock implements Block {
private final net.minecraft.world.level.GeneratorAccess world;
private final BlockPosition position;
private final net.minecraft.world.level.LevelAccessor world;
private final BlockPos position;
public CraftBlock(GeneratorAccess world, BlockPosition position) {
public CraftBlock(LevelAccessor world, BlockPos position) {
this.world = world;
this.position = position.immutable();
}
public static CraftBlock at(GeneratorAccess world, BlockPosition position) {
public static CraftBlock at(LevelAccessor world, BlockPos position) {
return new CraftBlock(world, position);
}
public net.minecraft.world.level.block.state.IBlockData getNMS() {
return world.getBlockState(position);
public net.minecraft.world.level.block.state.BlockState getNMS() {
return this.world.getBlockState(this.position);
}
public BlockPosition getPosition() {
return position;
public BlockPos getPosition() {
return this.position;
}
public GeneratorAccess getHandle() {
return world;
public LevelAccessor getHandle() {
return this.world;
}
@Override
public World getWorld() {
return world.getMinecraftWorld().getWorld();
return this.world.getMinecraftWorld().getWorld();
}
public CraftWorld getCraftWorld() {
return (CraftWorld) getWorld();
return (CraftWorld) this.getWorld();
}
@Override
public Location getLocation() {
return CraftLocation.toBukkit(position, getWorld());
return CraftLocation.toBukkit(this.position, this.getWorld());
}
@Override
public Location getLocation(Location loc) {
if (loc != null) {
loc.setWorld(getWorld());
loc.setX(position.getX());
loc.setY(position.getY());
loc.setZ(position.getZ());
loc.setWorld(this.getWorld());
loc.setX(this.position.getX());
loc.setY(this.position.getY());
loc.setZ(this.position.getZ());
loc.setYaw(0);
loc.setPitch(0);
}
@@ -116,88 +115,88 @@ public class CraftBlock implements Block {
}
public BlockVector getVector() {
return new BlockVector(getX(), getY(), getZ());
return new BlockVector(this.getX(), this.getY(), this.getZ());
}
@Override
public int getX() {
return position.getX();
return this.position.getX();
}
@Override
public int getY() {
return position.getY();
return this.position.getY();
}
@Override
public int getZ() {
return position.getZ();
return this.position.getZ();
}
@Override
public Chunk getChunk() {
return getWorld().getChunkAt(this);
return this.getWorld().getChunkAt(this);
}
public void setData(final byte data) {
setData(data, 3);
this.setData(data, 3);
}
public void setData(final byte data, boolean applyPhysics) {
if (applyPhysics) {
setData(data, 3);
this.setData(data, 3);
} else {
setData(data, 2);
this.setData(data, 2);
}
}
private void setData(final byte data, int flag) {
world.setBlock(position, CraftMagicNumbers.getBlock(getType(), data), flag);
this.world.setBlock(this.position, CraftMagicNumbers.getBlock(this.getType(), data), flag);
}
@Override
public byte getData() {
IBlockData blockData = world.getBlockState(position);
net.minecraft.world.level.block.state.BlockState blockData = this.world.getBlockState(this.position);
return CraftMagicNumbers.toLegacyData(blockData);
}
@Override
public BlockData getBlockData() {
return CraftBlockData.fromData(getNMS());
return CraftBlockData.fromData(this.getNMS());
}
@Override
public void setType(final Material type) {
setType(type, true);
this.setType(type, true);
}
@Override
public void setType(Material type, boolean applyPhysics) {
Preconditions.checkArgument(type != null, "Material cannot be null");
setBlockData(type.createBlockData(), applyPhysics);
this.setBlockData(type.createBlockData(), applyPhysics);
}
@Override
public void setBlockData(BlockData data) {
setBlockData(data, true);
this.setBlockData(data, true);
}
@Override
public void setBlockData(BlockData data, boolean applyPhysics) {
Preconditions.checkArgument(data != null, "BlockData cannot be null");
setTypeAndData(((CraftBlockData) data).getState(), applyPhysics);
this.setTypeAndData(((CraftBlockData) data).getState(), applyPhysics);
}
boolean setTypeAndData(final IBlockData blockData, final boolean applyPhysics) {
return setTypeAndData(world, position, getNMS(), blockData, applyPhysics);
boolean setTypeAndData(final net.minecraft.world.level.block.state.BlockState blockData, final boolean applyPhysics) {
return CraftBlock.setTypeAndData(this.world, this.position, this.getNMS(), blockData, applyPhysics);
}
public static boolean setTypeAndData(GeneratorAccess world, BlockPosition position, IBlockData old, IBlockData blockData, boolean applyPhysics) {
public static boolean setTypeAndData(LevelAccessor world, BlockPos position, net.minecraft.world.level.block.state.BlockState old, net.minecraft.world.level.block.state.BlockState blockData, boolean applyPhysics) {
// SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in tile entity cleanup
if (old.hasBlockEntity() && blockData.getBlock() != old.getBlock()) { // SPIGOT-3725 remove old tile entity if block changes
// SPIGOT-4612: faster - just clear tile
if (world instanceof net.minecraft.world.level.World) {
((net.minecraft.world.level.World) world).removeBlockEntity(position);
if (world instanceof net.minecraft.world.level.Level) {
((net.minecraft.world.level.Level) world).removeBlockEntity(position);
} else {
world.setBlock(position, Blocks.AIR.defaultBlockState(), 0);
}
@@ -207,7 +206,7 @@ public class CraftBlock implements Block {
return world.setBlock(position, blockData, 3);
} else {
boolean success = world.setBlock(position, blockData, 2 | 16 | 1024); // NOTIFY | NO_OBSERVER | NO_PLACE (custom)
if (success && world instanceof net.minecraft.world.level.World) {
if (success && world instanceof net.minecraft.world.level.Level) {
world.getMinecraftWorld().sendBlockUpdated(
position,
old,
@@ -221,45 +220,45 @@ public class CraftBlock implements Block {
@Override
public Material getType() {
return CraftBlockType.minecraftToBukkit(world.getBlockState(position).getBlock());
return CraftBlockType.minecraftToBukkit(this.world.getBlockState(this.position).getBlock());
}
@Override
public byte getLightLevel() {
return (byte) world.getMinecraftWorld().getMaxLocalRawBrightness(position);
return (byte) this.world.getMinecraftWorld().getMaxLocalRawBrightness(this.position);
}
@Override
public byte getLightFromSky() {
return (byte) world.getBrightness(EnumSkyBlock.SKY, position);
return (byte) this.world.getBrightness(LightLayer.SKY, this.position);
}
@Override
public byte getLightFromBlocks() {
return (byte) world.getBrightness(EnumSkyBlock.BLOCK, position);
return (byte) this.world.getBrightness(LightLayer.BLOCK, this.position);
}
public Block getFace(final BlockFace face) {
return getRelative(face, 1);
return this.getRelative(face, 1);
}
public Block getFace(final BlockFace face, final int distance) {
return getRelative(face, distance);
return this.getRelative(face, distance);
}
@Override
public Block getRelative(final int modX, final int modY, final int modZ) {
return getWorld().getBlockAt(getX() + modX, getY() + modY, getZ() + modZ);
return this.getWorld().getBlockAt(this.getX() + modX, this.getY() + modY, this.getZ() + modZ);
}
@Override
public Block getRelative(BlockFace face) {
return getRelative(face, 1);
return this.getRelative(face, 1);
}
@Override
public Block getRelative(BlockFace face, int distance) {
return getRelative(face.getModX() * distance, face.getModY() * distance, face.getModZ() * distance);
return this.getRelative(face.getModX() * distance, face.getModY() * distance, face.getModZ() * distance);
}
@Override
@@ -277,10 +276,10 @@ public class CraftBlock implements Block {
@Override
public String toString() {
return "CraftBlock{pos=" + position + ",type=" + getType() + ",data=" + getNMS() + ",fluid=" + world.getFluidState(position) + '}';
return "CraftBlock{pos=" + this.position + ",type=" + this.getType() + ",data=" + this.getNMS() + ",fluid=" + this.world.getFluidState(this.position) + '}';
}
public static BlockFace notchToBlockFace(EnumDirection notch) {
public static BlockFace notchToBlockFace(Direction notch) {
if (notch == null) {
return BlockFace.SELF;
}
@@ -302,23 +301,23 @@ public class CraftBlock implements Block {
}
}
public static EnumDirection blockFaceToNotch(BlockFace face) {
public static Direction blockFaceToNotch(BlockFace face) {
if (face == null) {
return null;
}
switch (face) {
case DOWN:
return EnumDirection.DOWN;
return Direction.DOWN;
case UP:
return EnumDirection.UP;
return Direction.UP;
case NORTH:
return EnumDirection.NORTH;
return Direction.NORTH;
case SOUTH:
return EnumDirection.SOUTH;
return Direction.SOUTH;
case WEST:
return EnumDirection.WEST;
return Direction.WEST;
case EAST:
return EnumDirection.EAST;
return Direction.EAST;
default:
return null;
}
@@ -331,32 +330,32 @@ public class CraftBlock implements Block {
@Override
public Biome getBiome() {
return getWorld().getBiome(getX(), getY(), getZ());
return this.getWorld().getBiome(this.getX(), this.getY(), this.getZ());
}
@Override
public void setBiome(Biome bio) {
getWorld().setBiome(getX(), getY(), getZ(), bio);
this.getWorld().setBiome(this.getX(), this.getY(), this.getZ(), bio);
}
@Override
public double getTemperature() {
return world.getBiome(position).value().getTemperature(position, world.getSeaLevel());
return this.world.getBiome(this.position).value().getTemperature(this.position, this.world.getSeaLevel());
}
@Override
public double getHumidity() {
return getWorld().getHumidity(getX(), getY(), getZ());
return this.getWorld().getHumidity(this.getX(), this.getY(), this.getZ());
}
@Override
public boolean isBlockPowered() {
return world.getMinecraftWorld().getDirectSignalTo(position) > 0;
return this.world.getMinecraftWorld().getDirectSignalTo(this.position) > 0;
}
@Override
public boolean isBlockIndirectlyPowered() {
return world.getMinecraftWorld().hasNeighborSignal(position);
return this.world.getMinecraftWorld().hasNeighborSignal(this.position);
}
@Override
@@ -378,14 +377,14 @@ public class CraftBlock implements Block {
@Override
public boolean isBlockFacePowered(BlockFace face) {
return world.getMinecraftWorld().hasSignal(position, blockFaceToNotch(face));
return this.world.getMinecraftWorld().hasSignal(this.position, CraftBlock.blockFaceToNotch(face));
}
@Override
public boolean isBlockFaceIndirectlyPowered(BlockFace face) {
int power = world.getMinecraftWorld().getSignal(position, blockFaceToNotch(face));
int power = this.world.getMinecraftWorld().getSignal(this.position, CraftBlock.blockFaceToNotch(face));
Block relative = getRelative(face);
Block relative = this.getRelative(face);
if (relative.getType() == Material.REDSTONE_WIRE) {
return Math.max(power, relative.getData()) > 0;
}
@@ -396,24 +395,24 @@ public class CraftBlock implements Block {
@Override
public int getBlockPower(BlockFace face) {
int power = 0;
net.minecraft.world.level.World world = this.world.getMinecraftWorld();
int x = getX();
int y = getY();
int z = getZ();
if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x, y - 1, z), EnumDirection.DOWN)) power = getPower(power, world.getBlockState(new BlockPosition(x, y - 1, z)));
if ((face == BlockFace.UP || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x, y + 1, z), EnumDirection.UP)) power = getPower(power, world.getBlockState(new BlockPosition(x, y + 1, z)));
if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x + 1, y, z), EnumDirection.EAST)) power = getPower(power, world.getBlockState(new BlockPosition(x + 1, y, z)));
if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x - 1, y, z), EnumDirection.WEST)) power = getPower(power, world.getBlockState(new BlockPosition(x - 1, y, z)));
if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x, y, z - 1), EnumDirection.NORTH)) power = getPower(power, world.getBlockState(new BlockPosition(x, y, z - 1)));
if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x, y, z + 1), EnumDirection.SOUTH)) power = getPower(power, world.getBlockState(new BlockPosition(x, y, z + 1)));
return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0;
net.minecraft.world.level.Level world = this.world.getMinecraftWorld();
int x = this.getX();
int y = this.getY();
int z = this.getZ();
if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.hasSignal(new BlockPos(x, y - 1, z), Direction.DOWN)) power = CraftBlock.getPower(power, world.getBlockState(new BlockPos(x, y - 1, z)));
if ((face == BlockFace.UP || face == BlockFace.SELF) && world.hasSignal(new BlockPos(x, y + 1, z), Direction.UP)) power = CraftBlock.getPower(power, world.getBlockState(new BlockPos(x, y + 1, z)));
if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.hasSignal(new BlockPos(x + 1, y, z), Direction.EAST)) power = CraftBlock.getPower(power, world.getBlockState(new BlockPos(x + 1, y, z)));
if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.hasSignal(new BlockPos(x - 1, y, z), Direction.WEST)) power = CraftBlock.getPower(power, world.getBlockState(new BlockPos(x - 1, y, z)));
if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.hasSignal(new BlockPos(x, y, z - 1), Direction.NORTH)) power = CraftBlock.getPower(power, world.getBlockState(new BlockPos(x, y, z - 1)));
if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.hasSignal(new BlockPos(x, y, z + 1), Direction.SOUTH)) power = CraftBlock.getPower(power, world.getBlockState(new BlockPos(x, y, z + 1)));
return power > 0 ? power : (face == BlockFace.SELF ? this.isBlockIndirectlyPowered() : this.isBlockFaceIndirectlyPowered(face)) ? 15 : 0;
}
private static int getPower(int i, IBlockData iblockdata) {
private static int getPower(int i, net.minecraft.world.level.block.state.BlockState iblockdata) {
if (!iblockdata.is(Blocks.REDSTONE_WIRE)) {
return i;
} else {
int j = iblockdata.getValue(BlockRedstoneWire.POWER);
int j = iblockdata.getValue(RedStoneWireBlock.POWER);
return j > i ? j : i;
}
@@ -421,72 +420,72 @@ public class CraftBlock implements Block {
@Override
public int getBlockPower() {
return getBlockPower(BlockFace.SELF);
return this.getBlockPower(BlockFace.SELF);
}
@Override
public boolean isEmpty() {
return getNMS().isAir();
return this.getNMS().isAir();
}
@Override
public boolean isLiquid() {
return getNMS().liquid();
return this.getNMS().liquid();
}
@Override
public PistonMoveReaction getPistonMoveReaction() {
return PistonMoveReaction.getById(getNMS().getPistonPushReaction().ordinal());
return PistonMoveReaction.getById(this.getNMS().getPistonPushReaction().ordinal());
}
@Override
public boolean breakNaturally() {
return breakNaturally(null);
return this.breakNaturally(null);
}
@Override
public boolean breakNaturally(ItemStack item) {
// Order matters here, need to drop before setting to air so skulls can get their data
net.minecraft.world.level.block.state.IBlockData iblockdata = this.getNMS();
net.minecraft.world.level.block.state.BlockState iblockdata = this.getNMS();
net.minecraft.world.level.block.Block block = iblockdata.getBlock();
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
boolean result = false;
// Modelled off EntityHuman#hasBlock
if (block != Blocks.AIR && (item == null || !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata))) {
net.minecraft.world.level.block.Block.dropResources(iblockdata, world.getMinecraftWorld(), position, world.getBlockEntity(position), null, nmsItem);
net.minecraft.world.level.block.Block.dropResources(iblockdata, this.world.getMinecraftWorld(), this.position, this.world.getBlockEntity(this.position), null, nmsItem);
result = true;
}
// SPIGOT-6778: Directly call setBlock instead of setTypeAndData, so that the tile entiy is not removed and custom remove logic is run.
return world.setBlock(position, Blocks.AIR.defaultBlockState(), 3) && result;
return this.world.setBlock(this.position, Blocks.AIR.defaultBlockState(), 3) && result;
}
@Override
public boolean applyBoneMeal(BlockFace face) {
EnumDirection direction = blockFaceToNotch(face);
Direction direction = CraftBlock.blockFaceToNotch(face);
BlockFertilizeEvent event = null;
WorldServer world = getCraftWorld().getHandle();
ItemActionContext context = new ItemActionContext(world, null, EnumHand.MAIN_HAND, Items.BONE_MEAL.getDefaultInstance(), new MovingObjectPositionBlock(Vec3D.ZERO, direction, getPosition(), false));
ServerLevel world = this.getCraftWorld().getHandle();
UseOnContext context = new UseOnContext(world, null, InteractionHand.MAIN_HAND, Items.BONE_MEAL.getDefaultInstance(), new BlockHitResult(Vec3.ZERO, direction, this.getPosition(), false));
// SPIGOT-6895: Call StructureGrowEvent and BlockFertilizeEvent
world.captureTreeGeneration = true;
EnumInteractionResult result = ItemBoneMeal.applyBonemeal(context);
InteractionResult result = BoneMealItem.applyBonemeal(context);
world.captureTreeGeneration = false;
if (world.capturedBlockStates.size() > 0) {
TreeType treeType = BlockSapling.treeType;
BlockSapling.treeType = null;
TreeType treeType = SaplingBlock.treeType;
SaplingBlock.treeType = null;
List<BlockState> blocks = new ArrayList<>(world.capturedBlockStates.values());
world.capturedBlockStates.clear();
StructureGrowEvent structureEvent = null;
if (treeType != null) {
structureEvent = new StructureGrowEvent(getLocation(), treeType, true, null, blocks);
structureEvent = new StructureGrowEvent(this.getLocation(), treeType, true, null, blocks);
Bukkit.getPluginManager().callEvent(structureEvent);
}
event = new BlockFertilizeEvent(CraftBlock.at(world, getPosition()), null, blocks);
event = new BlockFertilizeEvent(CraftBlock.at(world, this.getPosition()), null, blocks);
event.setCancelled(structureEvent != null && structureEvent.isCancelled());
Bukkit.getPluginManager().callEvent(event);
@@ -497,27 +496,27 @@ public class CraftBlock implements Block {
}
}
return result == EnumInteractionResult.SUCCESS && (event == null || !event.isCancelled());
return result == InteractionResult.SUCCESS && (event == null || !event.isCancelled());
}
@Override
public Collection<ItemStack> getDrops() {
return getDrops(null);
return this.getDrops(null);
}
@Override
public Collection<ItemStack> getDrops(ItemStack item) {
return getDrops(item, null);
return this.getDrops(item, null);
}
@Override
public Collection<ItemStack> getDrops(ItemStack item, Entity entity) {
IBlockData iblockdata = getNMS();
net.minecraft.world.level.block.state.BlockState iblockdata = this.getNMS();
net.minecraft.world.item.ItemStack nms = CraftItemStack.asNMSCopy(item);
// Modelled off EntityHuman#hasBlock
if (item == null || CraftBlockData.isPreferredTool(iblockdata, nms)) {
return net.minecraft.world.level.block.Block.getDrops(iblockdata, (WorldServer) world.getMinecraftWorld(), position, world.getBlockEntity(position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms)
return net.minecraft.world.level.block.Block.getDrops(iblockdata, (ServerLevel) this.world.getMinecraftWorld(), this.position, this.world.getBlockEntity(this.position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms)
.stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList());
} else {
return Collections.emptyList();
@@ -526,7 +525,7 @@ public class CraftBlock implements Block {
@Override
public boolean isPreferredTool(ItemStack item) {
IBlockData iblockdata = getNMS();
net.minecraft.world.level.block.state.BlockState iblockdata = this.getNMS();
net.minecraft.world.item.ItemStack nms = CraftItemStack.asNMSCopy(item);
return CraftBlockData.isPreferredTool(iblockdata, nms);
}
@@ -534,32 +533,32 @@ public class CraftBlock implements Block {
@Override
public float getBreakSpeed(Player player) {
Preconditions.checkArgument(player != null, "player cannot be null");
return getNMS().getDestroyProgress(((CraftPlayer) player).getHandle(), world, position);
return this.getNMS().getDestroyProgress(((CraftPlayer) player).getHandle(), this.world, this.position);
}
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
getCraftWorld().getBlockMetadata().setMetadata(this, metadataKey, newMetadataValue);
this.getCraftWorld().getBlockMetadata().setMetadata(this, metadataKey, newMetadataValue);
}
@Override
public List<MetadataValue> getMetadata(String metadataKey) {
return getCraftWorld().getBlockMetadata().getMetadata(this, metadataKey);
return this.getCraftWorld().getBlockMetadata().getMetadata(this, metadataKey);
}
@Override
public boolean hasMetadata(String metadataKey) {
return getCraftWorld().getBlockMetadata().hasMetadata(this, metadataKey);
return this.getCraftWorld().getBlockMetadata().hasMetadata(this, metadataKey);
}
@Override
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
getCraftWorld().getBlockMetadata().removeMetadata(this, metadataKey, owningPlugin);
this.getCraftWorld().getBlockMetadata().removeMetadata(this, metadataKey, owningPlugin);
}
@Override
public boolean isPassable() {
return this.getNMS().getCollisionShape(world, position).isEmpty();
return this.getNMS().getCollisionShape(this.world, this.position).isEmpty();
}
@Override
@@ -578,42 +577,42 @@ public class CraftBlock implements Block {
}
Vector dir = direction.clone().normalize().multiply(maxDistance);
Vec3D startPos = CraftLocation.toVec3D(start);
Vec3D endPos = startPos.add(dir.getX(), dir.getY(), dir.getZ());
Vec3 startPos = CraftLocation.toVec3D(start);
Vec3 endPos = startPos.add(dir.getX(), dir.getY(), dir.getZ());
MovingObjectPosition nmsHitResult = world.clip(new RayTrace(startPos, endPos, RayTrace.BlockCollisionOption.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), VoxelShapeCollision.empty()), position);
HitResult nmsHitResult = this.world.clip(new ClipContext(startPos, endPos, ClipContext.Block.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), CollisionContext.empty()), this.position);
return CraftRayTraceResult.fromNMS(this.getWorld(), nmsHitResult);
}
@Override
public BoundingBox getBoundingBox() {
VoxelShape shape = getNMS().getShape(world, position);
VoxelShape shape = this.getNMS().getShape(this.world, this.position);
if (shape.isEmpty()) {
return new BoundingBox(); // Return an empty bounding box if the block has no dimension
}
AxisAlignedBB aabb = shape.bounds();
return new BoundingBox(getX() + aabb.minX, getY() + aabb.minY, getZ() + aabb.minZ, getX() + aabb.maxX, getY() + aabb.maxY, getZ() + aabb.maxZ);
AABB aabb = shape.bounds();
return new BoundingBox(this.getX() + aabb.minX, this.getY() + aabb.minY, this.getZ() + aabb.minZ, this.getX() + aabb.maxX, this.getY() + aabb.maxY, this.getZ() + aabb.maxZ);
}
@Override
public org.bukkit.util.VoxelShape getCollisionShape() {
VoxelShape shape = getNMS().getCollisionShape(world, position);
VoxelShape shape = this.getNMS().getCollisionShape(this.world, this.position);
return new CraftVoxelShape(shape);
}
@Override
public boolean canPlace(BlockData data) {
Preconditions.checkArgument(data != null, "BlockData cannot be null");
net.minecraft.world.level.block.state.IBlockData iblockdata = ((CraftBlockData) data).getState();
net.minecraft.world.level.World world = this.world.getMinecraftWorld();
net.minecraft.world.level.block.state.BlockState iblockdata = ((CraftBlockData) data).getState();
net.minecraft.world.level.Level world = this.world.getMinecraftWorld();
return iblockdata.canSurvive(world, this.position);
}
@Override
public String getTranslationKey() {
return getNMS().getBlock().getDescriptionId();
return this.getNMS().getBlock().getDescriptionId();
}
}

View File

@@ -1,17 +1,17 @@
package org.bukkit.craftbukkit.block;
import java.util.Set;
import net.minecraft.core.IRegistryCustom;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.core.component.DataComponentPatch;
import net.minecraft.core.component.DataComponentType;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.PacketListenerPlayOut;
import net.minecraft.network.protocol.game.PacketPlayOutTileEntityData;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.GeneratorAccess;
import net.minecraft.world.level.block.entity.TileEntity;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.TileState;
@@ -20,7 +20,7 @@ import org.bukkit.persistence.PersistentDataContainer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState implements TileState {
public class CraftBlockEntityState<T extends BlockEntity> extends CraftBlockState implements TileState {
private final T tileEntity;
private final T snapshot;
@@ -32,22 +32,22 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
// copy tile entity data:
this.snapshot = this.createSnapshot(tileEntity);
this.load(snapshot);
this.load(this.snapshot);
}
protected CraftBlockEntityState(CraftBlockEntityState<T> state, Location location) {
super(state, location);
this.tileEntity = createSnapshot(state.snapshot);
this.snapshot = tileEntity;
loadData(state.getSnapshotNBT());
this.tileEntity = this.createSnapshot(state.snapshot);
this.snapshot = this.tileEntity;
this.loadData(state.getSnapshotNBT());
}
public void refreshSnapshot() {
this.load(tileEntity);
this.load(this.tileEntity);
}
private IRegistryCustom getRegistryAccess() {
GeneratorAccess worldHandle = getWorldHandle();
private RegistryAccess getRegistryAccess() {
LevelAccessor worldHandle = this.getWorldHandle();
return (worldHandle != null) ? worldHandle.registryAccess() : MinecraftServer.getDefaultRegistryAccess();
}
@@ -56,96 +56,96 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
return null;
}
NBTTagCompound nbtTagCompound = tileEntity.saveWithFullMetadata(getRegistryAccess());
T snapshot = (T) TileEntity.loadStatic(getPosition(), getHandle(), nbtTagCompound, getRegistryAccess());
CompoundTag nbtTagCompound = tileEntity.saveWithFullMetadata(this.getRegistryAccess());
T snapshot = (T) BlockEntity.loadStatic(this.getPosition(), this.getHandle(), nbtTagCompound, this.getRegistryAccess());
return snapshot;
}
public Set<DataComponentType<?>> applyComponents(DataComponentMap datacomponentmap, DataComponentPatch datacomponentpatch) {
Set<DataComponentType<?>> result = snapshot.applyComponentsSet(datacomponentmap, datacomponentpatch);
load(snapshot);
Set<DataComponentType<?>> result = this.snapshot.applyComponentsSet(datacomponentmap, datacomponentpatch);
this.load(this.snapshot);
return result;
}
public DataComponentMap collectComponents() {
return snapshot.collectComponents();
return this.snapshot.collectComponents();
}
// Loads the specified data into the snapshot TileEntity.
public void loadData(NBTTagCompound nbtTagCompound) {
snapshot.loadWithComponents(nbtTagCompound, getRegistryAccess());
load(snapshot);
public void loadData(CompoundTag nbtTagCompound) {
this.snapshot.loadWithComponents(nbtTagCompound, this.getRegistryAccess());
this.load(this.snapshot);
}
// copies the TileEntity-specific data, retains the position
private void copyData(T from, T to) {
NBTTagCompound nbtTagCompound = from.saveWithFullMetadata(getRegistryAccess());
to.loadWithComponents(nbtTagCompound, getRegistryAccess());
CompoundTag nbtTagCompound = from.saveWithFullMetadata(this.getRegistryAccess());
to.loadWithComponents(nbtTagCompound, this.getRegistryAccess());
}
// gets the wrapped TileEntity
protected T getTileEntity() {
return tileEntity;
public T getTileEntity() {
return this.tileEntity;
}
// gets the cloned TileEntity which is used to store the captured data
protected T getSnapshot() {
return snapshot;
return this.snapshot;
}
// gets the current TileEntity from the world at this position
protected TileEntity getTileEntityFromWorld() {
requirePlaced();
protected BlockEntity getTileEntityFromWorld() {
this.requirePlaced();
return getWorldHandle().getBlockEntity(this.getPosition());
return this.getWorldHandle().getBlockEntity(this.getPosition());
}
// gets the NBT data of the TileEntity represented by this block state
public NBTTagCompound getSnapshotNBT() {
public CompoundTag getSnapshotNBT() {
// update snapshot
applyTo(snapshot);
this.applyTo(this.snapshot);
return snapshot.saveWithFullMetadata(getRegistryAccess());
return this.snapshot.saveWithFullMetadata(this.getRegistryAccess());
}
public NBTTagCompound getItemNBT() {
public CompoundTag getItemNBT() {
// update snapshot
applyTo(snapshot);
this.applyTo(this.snapshot);
// See TileEntity#saveToItem
NBTTagCompound nbt = snapshot.saveCustomOnly(getRegistryAccess());
snapshot.removeComponentsFromTag(nbt);
CompoundTag nbt = this.snapshot.saveCustomOnly(this.getRegistryAccess());
this.snapshot.removeComponentsFromTag(nbt);
return nbt;
}
public void addEntityType(NBTTagCompound nbt) {
TileEntity.addEntityType(nbt, snapshot.getType());
public void addEntityType(CompoundTag nbt) {
BlockEntity.addEntityType(nbt, this.snapshot.getType());
}
// gets the packet data of the TileEntity represented by this block state
public NBTTagCompound getUpdateNBT() {
public CompoundTag getUpdateNBT() {
// update snapshot
applyTo(snapshot);
this.applyTo(this.snapshot);
return snapshot.getUpdateTag(getRegistryAccess());
return this.snapshot.getUpdateTag(this.getRegistryAccess());
}
// copies the data of the given tile entity to this block state
protected void load(T tileEntity) {
if (tileEntity != null && tileEntity != snapshot) {
copyData(tileEntity, snapshot);
if (tileEntity != null && tileEntity != this.snapshot) {
this.copyData(tileEntity, this.snapshot);
}
}
// applies the TileEntity data of this block state to the given TileEntity
protected void applyTo(T tileEntity) {
if (tileEntity != null && tileEntity != snapshot) {
copyData(snapshot, tileEntity);
if (tileEntity != null && tileEntity != this.snapshot) {
this.copyData(this.snapshot, tileEntity);
}
}
protected boolean isApplicable(TileEntity tileEntity) {
protected boolean isApplicable(BlockEntity tileEntity) {
return tileEntity != null && this.tileEntity.getClass() == tileEntity.getClass();
}
@@ -154,10 +154,10 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
boolean result = super.update(force, applyPhysics);
if (result && this.isPlaced()) {
TileEntity tile = getTileEntityFromWorld();
BlockEntity tile = this.getTileEntityFromWorld();
if (isApplicable(tile)) {
applyTo((T) tile);
if (this.isApplicable(tile)) {
this.applyTo((T) tile);
tile.setChanged();
}
}
@@ -171,8 +171,8 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
}
@Nullable
public Packet<PacketListenerPlayOut> getUpdatePacket(@NotNull Location location) {
return new PacketPlayOutTileEntityData(CraftLocation.toBlockPosition(location), snapshot.getType(), getUpdateNBT());
public Packet<ClientGamePacketListener> getUpdatePacket(@NotNull Location location) {
return new ClientboundBlockEntityDataPacket(CraftLocation.toBlockPosition(location), this.snapshot.getType(), this.getUpdateNBT());
}
@Override

View File

@@ -4,9 +4,8 @@ import com.google.common.base.Preconditions;
import java.lang.ref.WeakReference;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.core.BlockPosition;
import net.minecraft.world.level.GeneratorAccess;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelAccessor;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -26,16 +25,16 @@ import org.bukkit.plugin.Plugin;
public class CraftBlockState implements BlockState {
protected final CraftWorld world;
private final BlockPosition position;
protected IBlockData data;
private final BlockPos position;
protected net.minecraft.world.level.block.state.BlockState data;
protected int flag;
private WeakReference<GeneratorAccess> weakWorld;
private WeakReference<LevelAccessor> weakWorld;
protected CraftBlockState(final Block block) {
this(block.getWorld(), ((CraftBlock) block).getPosition(), ((CraftBlock) block).getNMS());
this.flag = 3;
setWorldHandle(((CraftBlock) block).getHandle());
this.setWorldHandle(((CraftBlock) block).getHandle());
}
protected CraftBlockState(final Block block, int flag) {
@@ -44,10 +43,10 @@ public class CraftBlockState implements BlockState {
}
// world can be null for non-placed BlockStates.
protected CraftBlockState(@Nullable World world, BlockPosition blockPosition, IBlockData blockData) {
protected CraftBlockState(@Nullable World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData) {
this.world = (CraftWorld) world;
position = blockPosition;
data = blockData;
this.position = blockPosition;
this.data = blockData;
}
// Creates an unplaced copy of the given CraftBlockState at the given location
@@ -61,11 +60,11 @@ public class CraftBlockState implements BlockState {
}
this.data = state.data;
this.flag = state.flag;
setWorldHandle(state.getWorldHandle());
this.setWorldHandle(state.getWorldHandle());
}
public void setWorldHandle(GeneratorAccess generatorAccess) {
if (generatorAccess instanceof net.minecraft.world.level.World) {
public void setWorldHandle(LevelAccessor generatorAccess) {
if (generatorAccess instanceof net.minecraft.world.level.Level) {
this.weakWorld = null;
} else {
this.weakWorld = new WeakReference<>(generatorAccess);
@@ -74,71 +73,71 @@ public class CraftBlockState implements BlockState {
// Returns null if weakWorld is not available and the BlockState is not placed.
// If this returns a World instead of only a GeneratorAccess, this implies that this BlockState is placed.
public GeneratorAccess getWorldHandle() {
if (weakWorld == null) {
return this.isPlaced() ? world.getHandle() : null;
public LevelAccessor getWorldHandle() {
if (this.weakWorld == null) {
return this.isPlaced() ? this.world.getHandle() : null;
}
GeneratorAccess access = weakWorld.get();
LevelAccessor access = this.weakWorld.get();
if (access == null) {
weakWorld = null;
return this.isPlaced() ? world.getHandle() : null;
this.weakWorld = null;
return this.isPlaced() ? this.world.getHandle() : null;
}
return access;
}
protected final boolean isWorldGeneration() {
GeneratorAccess generatorAccess = this.getWorldHandle();
return generatorAccess != null && !(generatorAccess instanceof net.minecraft.world.level.World);
LevelAccessor generatorAccess = this.getWorldHandle();
return generatorAccess != null && !(generatorAccess instanceof net.minecraft.world.level.Level);
}
protected final void ensureNoWorldGeneration() {
Preconditions.checkState(!isWorldGeneration(), "This operation is not supported during world generation!");
Preconditions.checkState(!this.isWorldGeneration(), "This operation is not supported during world generation!");
}
@Override
public World getWorld() {
requirePlaced();
return world;
this.requirePlaced();
return this.world;
}
@Override
public int getX() {
return position.getX();
return this.position.getX();
}
@Override
public int getY() {
return position.getY();
return this.position.getY();
}
@Override
public int getZ() {
return position.getZ();
return this.position.getZ();
}
@Override
public Chunk getChunk() {
requirePlaced();
return world.getChunkAt(getX() >> 4, getZ() >> 4);
this.requirePlaced();
return this.world.getChunkAt(this.getX() >> 4, this.getZ() >> 4);
}
public void setData(IBlockData data) {
public void setData(net.minecraft.world.level.block.state.BlockState data) {
this.data = data;
}
public BlockPosition getPosition() {
public BlockPos getPosition() {
return this.position;
}
public IBlockData getHandle() {
public net.minecraft.world.level.block.state.BlockState getHandle() {
return this.data;
}
@Override
public BlockData getBlockData() {
return CraftBlockData.fromData(data);
return CraftBlockData.fromData(this.data);
}
@Override
@@ -161,7 +160,7 @@ public class CraftBlockState implements BlockState {
@Override
public MaterialData getData() {
return CraftMagicNumbers.getMaterial(data);
return CraftMagicNumbers.getMaterial(this.data);
}
@Override
@@ -176,7 +175,7 @@ public class CraftBlockState implements BlockState {
@Override
public Material getType() {
return CraftBlockType.minecraftToBukkit(data.getBlock());
return CraftBlockType.minecraftToBukkit(this.data.getBlock());
}
public void setFlag(int flag) {
@@ -184,49 +183,49 @@ public class CraftBlockState implements BlockState {
}
public int getFlag() {
return flag;
return this.flag;
}
@Override
public byte getLightLevel() {
return getBlock().getLightLevel();
return this.getBlock().getLightLevel();
}
@Override
public CraftBlock getBlock() {
requirePlaced();
return CraftBlock.at(getWorldHandle(), position);
this.requirePlaced();
return CraftBlock.at(this.getWorldHandle(), this.position);
}
@Override
public boolean update() {
return update(false);
return this.update(false);
}
@Override
public boolean update(boolean force) {
return update(force, true);
return this.update(force, true);
}
@Override
public boolean update(boolean force, boolean applyPhysics) {
if (!isPlaced()) {
if (!this.isPlaced()) {
return true;
}
GeneratorAccess access = getWorldHandle();
CraftBlock block = getBlock();
LevelAccessor access = this.getWorldHandle();
CraftBlock block = this.getBlock();
if (block.getType() != getType()) {
if (block.getType() != this.getType()) {
if (!force) {
return false;
}
}
IBlockData newBlock = this.data;
net.minecraft.world.level.block.state.BlockState newBlock = this.data;
block.setTypeAndData(newBlock, applyPhysics);
if (access instanceof net.minecraft.world.level.World) {
world.getHandle().sendBlockUpdated(
position,
if (access instanceof net.minecraft.world.level.Level) {
this.world.getHandle().sendBlockUpdated(
this.position,
block.getNMS(),
newBlock,
3
@@ -234,8 +233,8 @@ public class CraftBlockState implements BlockState {
}
// Update levers etc
if (false && applyPhysics && getData() instanceof Attachable) { // Call does not map to new API
world.getHandle().updateNeighborsAt(position.relative(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock());
if (false && applyPhysics && this.getData() instanceof Attachable) { // Call does not map to new API
this.world.getHandle().updateNeighborsAt(this.position.relative(CraftBlock.blockFaceToNotch(((Attachable) this.getData()).getAttachedFace())), newBlock.getBlock());
}
return true;
@@ -243,7 +242,7 @@ public class CraftBlockState implements BlockState {
@Override
public byte getRawData() {
return CraftMagicNumbers.toLegacyData(data);
return CraftMagicNumbers.toLegacyData(this.data);
}
@Override
@@ -254,10 +253,10 @@ public class CraftBlockState implements BlockState {
@Override
public Location getLocation(Location loc) {
if (loc != null) {
loc.setWorld(world);
loc.setX(getX());
loc.setY(getY());
loc.setZ(getZ());
loc.setWorld(this.world);
loc.setX(this.getX());
loc.setY(this.getY());
loc.setZ(this.getZ());
loc.setYaw(0);
loc.setPitch(0);
}
@@ -267,7 +266,7 @@ public class CraftBlockState implements BlockState {
@Override
public void setRawData(byte data) {
this.data = CraftMagicNumbers.getBlock(getType(), data);
this.data = CraftMagicNumbers.getBlock(this.getType(), data);
}
@Override
@@ -275,7 +274,7 @@ public class CraftBlockState implements BlockState {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if (this.getClass() != obj.getClass()) {
return false;
}
final CraftBlockState other = (CraftBlockState) obj;
@@ -302,35 +301,35 @@ public class CraftBlockState implements BlockState {
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
requirePlaced();
world.getBlockMetadata().setMetadata(getBlock(), metadataKey, newMetadataValue);
this.requirePlaced();
this.world.getBlockMetadata().setMetadata(this.getBlock(), metadataKey, newMetadataValue);
}
@Override
public List<MetadataValue> getMetadata(String metadataKey) {
requirePlaced();
return world.getBlockMetadata().getMetadata(getBlock(), metadataKey);
this.requirePlaced();
return this.world.getBlockMetadata().getMetadata(this.getBlock(), metadataKey);
}
@Override
public boolean hasMetadata(String metadataKey) {
requirePlaced();
return world.getBlockMetadata().hasMetadata(getBlock(), metadataKey);
this.requirePlaced();
return this.world.getBlockMetadata().hasMetadata(this.getBlock(), metadataKey);
}
@Override
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
requirePlaced();
world.getBlockMetadata().removeMetadata(getBlock(), metadataKey, owningPlugin);
this.requirePlaced();
this.world.getBlockMetadata().removeMetadata(this.getBlock(), metadataKey, owningPlugin);
}
@Override
public boolean isPlaced() {
return world != null;
return this.world != null;
}
protected void requirePlaced() {
Preconditions.checkState(isPlaced(), "The blockState must be placed to call this method");
Preconditions.checkState(this.isPlaced(), "The blockState must be placed to call this method");
}
@Override

View File

@@ -8,59 +8,58 @@ import java.util.List;
import java.util.Map;
import java.util.function.BiFunction;
import javax.annotation.Nullable;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.IRegistryCustom;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.core.BlockPos;
import net.minecraft.core.RegistryAccess;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.GeneratorAccess;
import net.minecraft.world.level.IWorldReader;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.entity.BannerBlockEntity;
import net.minecraft.world.level.block.entity.BarrelBlockEntity;
import net.minecraft.world.level.block.entity.BeaconBlockEntity;
import net.minecraft.world.level.block.entity.BedBlockEntity;
import net.minecraft.world.level.block.entity.BeehiveBlockEntity;
import net.minecraft.world.level.block.entity.BellBlockEntity;
import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BrewingStandBlockEntity;
import net.minecraft.world.level.block.entity.BrushableBlockEntity;
import net.minecraft.world.level.block.entity.CalibratedSculkSensorBlockEntity;
import net.minecraft.world.level.block.entity.CampfireBlockEntity;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity;
import net.minecraft.world.level.block.entity.CommandBlockEntity;
import net.minecraft.world.level.block.entity.ComparatorBlockEntity;
import net.minecraft.world.level.block.entity.ConduitBlockEntity;
import net.minecraft.world.level.block.entity.CrafterBlockEntity;
import net.minecraft.world.level.block.entity.CreakingHeartBlockEntity;
import net.minecraft.world.level.block.entity.DaylightDetectorBlockEntity;
import net.minecraft.world.level.block.entity.DecoratedPotBlockEntity;
import net.minecraft.world.level.block.entity.DispenserBlockEntity;
import net.minecraft.world.level.block.entity.DropperBlockEntity;
import net.minecraft.world.level.block.entity.EnchantingTableBlockEntity;
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
import net.minecraft.world.level.block.entity.FurnaceBlockEntity;
import net.minecraft.world.level.block.entity.HangingSignBlockEntity;
import net.minecraft.world.level.block.entity.HopperBlockEntity;
import net.minecraft.world.level.block.entity.JigsawBlockEntity;
import net.minecraft.world.level.block.entity.JukeboxBlockEntity;
import net.minecraft.world.level.block.entity.LecternBlockEntity;
import net.minecraft.world.level.block.entity.SculkCatalystBlockEntity;
import net.minecraft.world.level.block.entity.SculkSensorBlockEntity;
import net.minecraft.world.level.block.entity.SculkShriekerBlockEntity;
import net.minecraft.world.level.block.entity.TileEntity;
import net.minecraft.world.level.block.entity.TileEntityBanner;
import net.minecraft.world.level.block.entity.TileEntityBarrel;
import net.minecraft.world.level.block.entity.TileEntityBeacon;
import net.minecraft.world.level.block.entity.TileEntityBed;
import net.minecraft.world.level.block.entity.TileEntityBeehive;
import net.minecraft.world.level.block.entity.TileEntityBell;
import net.minecraft.world.level.block.entity.TileEntityBlastFurnace;
import net.minecraft.world.level.block.entity.TileEntityBrewingStand;
import net.minecraft.world.level.block.entity.TileEntityCampfire;
import net.minecraft.world.level.block.entity.TileEntityChest;
import net.minecraft.world.level.block.entity.TileEntityChestTrapped;
import net.minecraft.world.level.block.entity.TileEntityCommand;
import net.minecraft.world.level.block.entity.TileEntityComparator;
import net.minecraft.world.level.block.entity.TileEntityConduit;
import net.minecraft.world.level.block.entity.TileEntityDispenser;
import net.minecraft.world.level.block.entity.TileEntityDropper;
import net.minecraft.world.level.block.entity.TileEntityEnchantTable;
import net.minecraft.world.level.block.entity.TileEntityEndGateway;
import net.minecraft.world.level.block.entity.TileEntityEnderChest;
import net.minecraft.world.level.block.entity.TileEntityEnderPortal;
import net.minecraft.world.level.block.entity.TileEntityFurnaceFurnace;
import net.minecraft.world.level.block.entity.TileEntityHopper;
import net.minecraft.world.level.block.entity.TileEntityJigsaw;
import net.minecraft.world.level.block.entity.TileEntityJukeBox;
import net.minecraft.world.level.block.entity.TileEntityLectern;
import net.minecraft.world.level.block.entity.TileEntityLightDetector;
import net.minecraft.world.level.block.entity.TileEntityMobSpawner;
import net.minecraft.world.level.block.entity.TileEntityShulkerBox;
import net.minecraft.world.level.block.entity.TileEntitySign;
import net.minecraft.world.level.block.entity.TileEntitySkull;
import net.minecraft.world.level.block.entity.TileEntitySmoker;
import net.minecraft.world.level.block.entity.TileEntityStructure;
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
import net.minecraft.world.level.block.entity.SignBlockEntity;
import net.minecraft.world.level.block.entity.SkullBlockEntity;
import net.minecraft.world.level.block.entity.SmokerBlockEntity;
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
import net.minecraft.world.level.block.entity.StructureBlockEntity;
import net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity;
import net.minecraft.world.level.block.entity.TheEndPortalBlockEntity;
import net.minecraft.world.level.block.entity.TrappedChestBlockEntity;
import net.minecraft.world.level.block.entity.TrialSpawnerBlockEntity;
import net.minecraft.world.level.block.entity.vault.VaultBlockEntity;
import net.minecraft.world.level.block.piston.TileEntityPiston;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.block.piston.PistonMovingBlockEntity;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
@@ -83,22 +82,22 @@ public final class CraftBlockStates {
// If the given tile entity is not null, its position and block data are expected to match the given block position and block data.
// In some situations, such as during chunk generation, the tile entity's world may be null, even if the given world is not null.
// If the tile entity's world is not null, it is expected to match the given world.
public abstract B createBlockState(World world, BlockPosition blockPosition, IBlockData blockData, TileEntity tileEntity);
public abstract B createBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity);
}
private static class BlockEntityStateFactory<T extends TileEntity, B extends CraftBlockEntityState<T>> extends BlockStateFactory<B> {
private static class BlockEntityStateFactory<T extends BlockEntity, B extends CraftBlockEntityState<T>> extends BlockStateFactory<B> {
private final BiFunction<World, T, B> blockStateConstructor;
private final BiFunction<BlockPosition, IBlockData, T> tileEntityConstructor;
private final BiFunction<BlockPos, net.minecraft.world.level.block.state.BlockState, T> tileEntityConstructor;
protected BlockEntityStateFactory(Class<B> blockStateType, BiFunction<World, T, B> blockStateConstructor, BiFunction<BlockPosition, IBlockData, T> tileEntityConstructor) {
protected BlockEntityStateFactory(Class<B> blockStateType, BiFunction<World, T, B> blockStateConstructor, BiFunction<BlockPos, net.minecraft.world.level.block.state.BlockState, T> tileEntityConstructor) {
super(blockStateType);
this.blockStateConstructor = blockStateConstructor;
this.tileEntityConstructor = tileEntityConstructor;
}
@Override
public final B createBlockState(World world, BlockPosition blockPosition, IBlockData blockData, TileEntity tileEntity) {
public final B createBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
if (world != null) {
Preconditions.checkState(tileEntity != null, "Tile is null, asynchronous access? %s", CraftBlock.at(((CraftWorld) world).getHandle(), blockPosition));
} else if (tileEntity == null) {
@@ -107,19 +106,19 @@ public final class CraftBlockStates {
return this.createBlockState(world, (T) tileEntity);
}
private T createTileEntity(BlockPosition blockPosition, IBlockData blockData) {
return tileEntityConstructor.apply(blockPosition, blockData);
private T createTileEntity(BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData) {
return this.tileEntityConstructor.apply(blockPosition, blockData);
}
private B createBlockState(World world, T tileEntity) {
return blockStateConstructor.apply(world, tileEntity);
return this.blockStateConstructor.apply(world, tileEntity);
}
}
private static final Map<Material, BlockStateFactory<?>> FACTORIES = new HashMap<>();
private static final BlockStateFactory<?> DEFAULT_FACTORY = new BlockStateFactory<CraftBlockState>(CraftBlockState.class) {
@Override
public CraftBlockState createBlockState(World world, BlockPosition blockPosition, IBlockData blockData, TileEntity tileEntity) {
public CraftBlockState createBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
// SPIGOT-6754, SPIGOT-6817: Restore previous behaviour for tile entities with removed blocks (loot generation post-destroy)
if (tileEntity != null) {
// block with unhandled TileEntity:
@@ -157,7 +156,7 @@ public final class CraftBlockStates {
Material.SPRUCE_WALL_SIGN,
Material.WARPED_SIGN,
Material.WARPED_WALL_SIGN
), CraftSign.class, CraftSign::new, TileEntitySign::new
), CraftSign.class, CraftSign::new, SignBlockEntity::new
);
register(
@@ -205,7 +204,7 @@ public final class CraftBlockStates {
Material.WITHER_SKELETON_WALL_SKULL,
Material.ZOMBIE_HEAD,
Material.ZOMBIE_WALL_HEAD
), CraftSkull.class, CraftSkull::new, TileEntitySkull::new
), CraftSkull.class, CraftSkull::new, SkullBlockEntity::new
);
register(
@@ -213,7 +212,7 @@ public final class CraftBlockStates {
Material.COMMAND_BLOCK,
Material.REPEATING_COMMAND_BLOCK,
Material.CHAIN_COMMAND_BLOCK
), CraftCommandBlock.class, CraftCommandBlock::new, TileEntityCommand::new
), CraftCommandBlock.class, CraftCommandBlock::new, CommandBlockEntity::new
);
register(
@@ -250,7 +249,7 @@ public final class CraftBlockStates {
Material.WHITE_WALL_BANNER,
Material.YELLOW_BANNER,
Material.YELLOW_WALL_BANNER
), CraftBanner.class, CraftBanner::new, TileEntityBanner::new
), CraftBanner.class, CraftBanner::new, BannerBlockEntity::new
);
register(
@@ -272,7 +271,7 @@ public final class CraftBlockStates {
Material.GREEN_SHULKER_BOX,
Material.RED_SHULKER_BOX,
Material.BLACK_SHULKER_BOX
), CraftShulkerBox.class, CraftShulkerBox::new, TileEntityShulkerBox::new
), CraftShulkerBox.class, CraftShulkerBox::new, ShulkerBoxBlockEntity::new
);
register(
@@ -293,101 +292,101 @@ public final class CraftBlockStates {
Material.RED_BED,
Material.WHITE_BED,
Material.YELLOW_BED
), CraftBed.class, CraftBed::new, TileEntityBed::new
), CraftBed.class, CraftBed::new, BedBlockEntity::new
);
register(
Arrays.asList(
Material.BEEHIVE,
Material.BEE_NEST
), CraftBeehive.class, CraftBeehive::new, TileEntityBeehive::new
), CraftBeehive.class, CraftBeehive::new, BeehiveBlockEntity::new
);
register(
Arrays.asList(
Material.CAMPFIRE,
Material.SOUL_CAMPFIRE
), CraftCampfire.class, CraftCampfire::new, TileEntityCampfire::new
), CraftCampfire.class, CraftCampfire::new, CampfireBlockEntity::new
);
register(Material.BARREL, CraftBarrel.class, CraftBarrel::new, TileEntityBarrel::new);
register(Material.BEACON, CraftBeacon.class, CraftBeacon::new, TileEntityBeacon::new);
register(Material.BELL, CraftBell.class, CraftBell::new, TileEntityBell::new);
register(Material.BLAST_FURNACE, CraftBlastFurnace.class, CraftBlastFurnace::new, TileEntityBlastFurnace::new);
register(Material.BREWING_STAND, CraftBrewingStand.class, CraftBrewingStand::new, TileEntityBrewingStand::new);
register(Material.CHEST, CraftChest.class, CraftChest::new, TileEntityChest::new);
register(Material.BARREL, CraftBarrel.class, CraftBarrel::new, BarrelBlockEntity::new);
register(Material.BEACON, CraftBeacon.class, CraftBeacon::new, BeaconBlockEntity::new);
register(Material.BELL, CraftBell.class, CraftBell::new, BellBlockEntity::new);
register(Material.BLAST_FURNACE, CraftBlastFurnace.class, CraftBlastFurnace::new, BlastFurnaceBlockEntity::new);
register(Material.BREWING_STAND, CraftBrewingStand.class, CraftBrewingStand::new, BrewingStandBlockEntity::new);
register(Material.CHEST, CraftChest.class, CraftChest::new, ChestBlockEntity::new);
register(Material.CHISELED_BOOKSHELF, CraftChiseledBookshelf.class, CraftChiseledBookshelf::new, ChiseledBookShelfBlockEntity::new);
register(Material.COMPARATOR, CraftComparator.class, CraftComparator::new, TileEntityComparator::new);
register(Material.CONDUIT, CraftConduit.class, CraftConduit::new, TileEntityConduit::new);
register(Material.COMPARATOR, CraftComparator.class, CraftComparator::new, ComparatorBlockEntity::new);
register(Material.CONDUIT, CraftConduit.class, CraftConduit::new, ConduitBlockEntity::new);
register(Material.CREAKING_HEART, CraftCreakingHeart.class, CraftCreakingHeart::new, CreakingHeartBlockEntity::new);
register(Material.DAYLIGHT_DETECTOR, CraftDaylightDetector.class, CraftDaylightDetector::new, TileEntityLightDetector::new);
register(Material.DAYLIGHT_DETECTOR, CraftDaylightDetector.class, CraftDaylightDetector::new, DaylightDetectorBlockEntity::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);
register(Material.ENDER_CHEST, CraftEnderChest.class, CraftEnderChest::new, TileEntityEnderChest::new);
register(Material.END_GATEWAY, CraftEndGateway.class, CraftEndGateway::new, TileEntityEndGateway::new);
register(Material.END_PORTAL, CraftEndPortal.class, CraftEndPortal::new, TileEntityEnderPortal::new);
register(Material.FURNACE, CraftFurnaceFurnace.class, CraftFurnaceFurnace::new, TileEntityFurnaceFurnace::new);
register(Material.HOPPER, CraftHopper.class, CraftHopper::new, TileEntityHopper::new);
register(Material.JIGSAW, CraftJigsaw.class, CraftJigsaw::new, TileEntityJigsaw::new);
register(Material.JUKEBOX, CraftJukebox.class, CraftJukebox::new, TileEntityJukeBox::new);
register(Material.LECTERN, CraftLectern.class, CraftLectern::new, TileEntityLectern::new);
register(Material.MOVING_PISTON, CraftMovingPiston.class, CraftMovingPiston::new, TileEntityPiston::new);
register(Material.DISPENSER, CraftDispenser.class, CraftDispenser::new, DispenserBlockEntity::new);
register(Material.DROPPER, CraftDropper.class, CraftDropper::new, DropperBlockEntity::new);
register(Material.ENCHANTING_TABLE, CraftEnchantingTable.class, CraftEnchantingTable::new, EnchantingTableBlockEntity::new);
register(Material.ENDER_CHEST, CraftEnderChest.class, CraftEnderChest::new, EnderChestBlockEntity::new);
register(Material.END_GATEWAY, CraftEndGateway.class, CraftEndGateway::new, TheEndGatewayBlockEntity::new);
register(Material.END_PORTAL, CraftEndPortal.class, CraftEndPortal::new, TheEndPortalBlockEntity::new);
register(Material.FURNACE, CraftFurnaceFurnace.class, CraftFurnaceFurnace::new, FurnaceBlockEntity::new);
register(Material.HOPPER, CraftHopper.class, CraftHopper::new, HopperBlockEntity::new);
register(Material.JIGSAW, CraftJigsaw.class, CraftJigsaw::new, JigsawBlockEntity::new);
register(Material.JUKEBOX, CraftJukebox.class, CraftJukebox::new, JukeboxBlockEntity::new);
register(Material.LECTERN, CraftLectern.class, CraftLectern::new, LecternBlockEntity::new);
register(Material.MOVING_PISTON, CraftMovingPiston.class, CraftMovingPiston::new, PistonMovingBlockEntity::new);
register(Material.SCULK_CATALYST, CraftSculkCatalyst.class, CraftSculkCatalyst::new, SculkCatalystBlockEntity::new);
register(Material.CALIBRATED_SCULK_SENSOR, CraftCalibratedSculkSensor.class, CraftCalibratedSculkSensor::new, CalibratedSculkSensorBlockEntity::new);
register(Material.SCULK_SENSOR, CraftSculkSensor.class, CraftSculkSensor::new, SculkSensorBlockEntity::new);
register(Material.SCULK_SHRIEKER, CraftSculkShrieker.class, CraftSculkShrieker::new, SculkShriekerBlockEntity::new);
register(Material.SMOKER, CraftSmoker.class, CraftSmoker::new, TileEntitySmoker::new);
register(Material.SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new, TileEntityMobSpawner::new);
register(Material.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new, TileEntityStructure::new);
register(Material.SMOKER, CraftSmoker.class, CraftSmoker::new, SmokerBlockEntity::new);
register(Material.SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new, SpawnerBlockEntity::new);
register(Material.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new, StructureBlockEntity::new);
register(Material.SUSPICIOUS_SAND, CraftSuspiciousSand.class, CraftSuspiciousSand::new, BrushableBlockEntity::new);
register(Material.SUSPICIOUS_GRAVEL, CraftBrushableBlock.class, CraftBrushableBlock::new, BrushableBlockEntity::new);
register(Material.TRAPPED_CHEST, CraftChest.class, CraftChest::new, TileEntityChestTrapped::new);
register(Material.TRAPPED_CHEST, CraftChest.class, CraftChest::new, TrappedChestBlockEntity::new);
register(Material.CRAFTER, CraftCrafter.class, CraftCrafter::new, CrafterBlockEntity::new);
register(Material.TRIAL_SPAWNER, CraftTrialSpawner.class, CraftTrialSpawner::new, TrialSpawnerBlockEntity::new);
register(Material.VAULT, CraftVault.class, CraftVault::new, VaultBlockEntity::new);
}
private static void register(Material blockType, BlockStateFactory<?> factory) {
FACTORIES.put(blockType, factory);
CraftBlockStates.FACTORIES.put(blockType, factory);
}
private static <T extends TileEntity, B extends CraftBlockEntityState<T>> void register(
private static <T extends BlockEntity, B extends CraftBlockEntityState<T>> void register(
Material blockType,
Class<B> blockStateType,
BiFunction<World, T, B> blockStateConstructor,
BiFunction<BlockPosition, IBlockData, T> tileEntityConstructor
BiFunction<BlockPos, net.minecraft.world.level.block.state.BlockState, T> tileEntityConstructor
) {
register(Collections.singletonList(blockType), blockStateType, blockStateConstructor, tileEntityConstructor);
CraftBlockStates.register(Collections.singletonList(blockType), blockStateType, blockStateConstructor, tileEntityConstructor);
}
private static <T extends TileEntity, B extends CraftBlockEntityState<T>> void register(
private static <T extends BlockEntity, B extends CraftBlockEntityState<T>> void register(
List<Material> blockTypes,
Class<B> blockStateType,
BiFunction<World, T, B> blockStateConstructor,
BiFunction<BlockPosition, IBlockData, T> tileEntityConstructor
BiFunction<BlockPos, net.minecraft.world.level.block.state.BlockState, T> tileEntityConstructor
) {
BlockStateFactory<B> factory = new BlockEntityStateFactory<>(blockStateType, blockStateConstructor, tileEntityConstructor);
for (Material blockType : blockTypes) {
register(blockType, factory);
CraftBlockStates.register(blockType, factory);
}
}
private static BlockStateFactory<?> getFactory(Material material) {
return FACTORIES.getOrDefault(material, DEFAULT_FACTORY);
return CraftBlockStates.FACTORIES.getOrDefault(material, CraftBlockStates.DEFAULT_FACTORY);
}
public static Class<? extends CraftBlockState> getBlockStateType(Material material) {
Preconditions.checkNotNull(material, "material is null");
return getFactory(material).blockStateType;
return CraftBlockStates.getFactory(material).blockStateType;
}
public static TileEntity createNewTileEntity(Material material) {
BlockStateFactory<?> factory = getFactory(material);
public static BlockEntity createNewTileEntity(Material material) {
BlockStateFactory<?> factory = CraftBlockStates.getFactory(material);
if (factory instanceof BlockEntityStateFactory) {
return ((BlockEntityStateFactory<?, ?>) factory).createTileEntity(BlockPosition.ZERO, CraftBlockType.bukkitToMinecraft(material).defaultBlockState());
return ((BlockEntityStateFactory<?, ?>) factory).createTileEntity(BlockPos.ZERO, CraftBlockType.bukkitToMinecraft(material).defaultBlockState());
}
return null;
@@ -397,55 +396,55 @@ public final class CraftBlockStates {
Preconditions.checkNotNull(block, "block is null");
CraftBlock craftBlock = (CraftBlock) block;
CraftWorld world = (CraftWorld) block.getWorld();
BlockPosition blockPosition = craftBlock.getPosition();
IBlockData blockData = craftBlock.getNMS();
TileEntity tileEntity = craftBlock.getHandle().getBlockEntity(blockPosition);
CraftBlockState blockState = getBlockState(world, blockPosition, blockData, tileEntity);
BlockPos blockPosition = craftBlock.getPosition();
net.minecraft.world.level.block.state.BlockState blockData = craftBlock.getNMS();
BlockEntity tileEntity = craftBlock.getHandle().getBlockEntity(blockPosition);
CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockPosition, blockData, tileEntity);
blockState.setWorldHandle(craftBlock.getHandle()); // Inject the block's generator access
return blockState;
}
@Deprecated
public static BlockState getBlockState(BlockPosition blockPosition, Material material, @Nullable NBTTagCompound blockEntityTag) {
return getBlockState(MinecraftServer.getDefaultRegistryAccess(), blockPosition, material, blockEntityTag);
public static BlockState getBlockState(BlockPos blockPosition, Material material, @Nullable CompoundTag blockEntityTag) {
return CraftBlockStates.getBlockState(MinecraftServer.getDefaultRegistryAccess(), blockPosition, material, blockEntityTag);
}
public static BlockState getBlockState(IWorldReader world, BlockPosition blockPosition, Material material, @Nullable NBTTagCompound blockEntityTag) {
return getBlockState(world.registryAccess(), blockPosition, material, blockEntityTag);
public static BlockState getBlockState(LevelReader world, BlockPos blockPosition, Material material, @Nullable CompoundTag blockEntityTag) {
return CraftBlockStates.getBlockState(world.registryAccess(), blockPosition, material, blockEntityTag);
}
public static BlockState getBlockState(IRegistryCustom registry, BlockPosition blockPosition, Material material, @Nullable NBTTagCompound blockEntityTag) {
public static BlockState getBlockState(RegistryAccess registry, BlockPos blockPosition, Material material, @Nullable CompoundTag blockEntityTag) {
Preconditions.checkNotNull(material, "material is null");
IBlockData blockData = CraftBlockType.bukkitToMinecraft(material).defaultBlockState();
return getBlockState(registry, blockPosition, blockData, blockEntityTag);
net.minecraft.world.level.block.state.BlockState blockData = CraftBlockType.bukkitToMinecraft(material).defaultBlockState();
return CraftBlockStates.getBlockState(registry, blockPosition, blockData, blockEntityTag);
}
@Deprecated
public static BlockState getBlockState(IBlockData blockData, @Nullable NBTTagCompound blockEntityTag) {
return getBlockState(MinecraftServer.getDefaultRegistryAccess(), BlockPosition.ZERO, blockData, blockEntityTag);
public static BlockState getBlockState(net.minecraft.world.level.block.state.BlockState blockData, @Nullable CompoundTag blockEntityTag) {
return CraftBlockStates.getBlockState(MinecraftServer.getDefaultRegistryAccess(), BlockPos.ZERO, blockData, blockEntityTag);
}
public static BlockState getBlockState(IWorldReader world, BlockPosition blockPosition, IBlockData blockData, @Nullable NBTTagCompound blockEntityTag) {
return getBlockState(world.registryAccess(), blockPosition, blockData, blockEntityTag);
public static BlockState getBlockState(LevelReader world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, @Nullable CompoundTag blockEntityTag) {
return CraftBlockStates.getBlockState(world.registryAccess(), blockPosition, blockData, blockEntityTag);
}
public static BlockState getBlockState(IRegistryCustom registry, BlockPosition blockPosition, IBlockData blockData, @Nullable NBTTagCompound blockEntityTag) {
public static BlockState getBlockState(RegistryAccess registry, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, @Nullable CompoundTag blockEntityTag) {
Preconditions.checkNotNull(blockPosition, "blockPosition is null");
Preconditions.checkNotNull(blockData, "blockData is null");
TileEntity tileEntity = (blockEntityTag == null) ? null : TileEntity.loadStatic(blockPosition, blockData, blockEntityTag, registry);
return getBlockState(null, blockPosition, blockData, tileEntity);
BlockEntity tileEntity = (blockEntityTag == null) ? null : BlockEntity.loadStatic(blockPosition, blockData, blockEntityTag, registry);
return CraftBlockStates.getBlockState(null, blockPosition, blockData, tileEntity);
}
// See BlockStateFactory#createBlockState(World, BlockPosition, IBlockData, TileEntity)
private static CraftBlockState getBlockState(World world, BlockPosition blockPosition, IBlockData blockData, TileEntity tileEntity) {
public static CraftBlockState getBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
Material material = CraftBlockType.minecraftToBukkit(blockData.getBlock());
BlockStateFactory<?> factory;
// For some types of TileEntity blocks (eg. moving pistons), Minecraft may in some situations (eg. when using Block#setType or the
// setBlock command) not create a corresponding TileEntity in the world. We return a normal BlockState in this case.
if (world != null && tileEntity == null && isTileEntityOptional(material)) {
factory = DEFAULT_FACTORY;
if (world != null && tileEntity == null && CraftBlockStates.isTileEntityOptional(material)) {
factory = CraftBlockStates.DEFAULT_FACTORY;
} else {
factory = getFactory(material);
factory = CraftBlockStates.getFactory(material);
}
return factory.createBlockState(world, blockPosition, blockData, tileEntity);
}
@@ -455,12 +454,12 @@ public final class CraftBlockStates {
}
// This ignores tile entity data.
public static CraftBlockState getBlockState(GeneratorAccess world, BlockPosition pos) {
public static CraftBlockState getBlockState(LevelAccessor world, BlockPos pos) {
return new CraftBlockState(CraftBlock.at(world, pos));
}
// This ignores tile entity data.
public static CraftBlockState getBlockState(GeneratorAccess world, BlockPosition pos, int flag) {
public static CraftBlockState getBlockState(LevelAccessor world, BlockPos pos, int flag) {
return new CraftBlockState(CraftBlock.at(world, pos), flag);
}

View File

@@ -1,6 +1,6 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.EnumBlockSupport;
import net.minecraft.world.level.block.SupportType;
import org.bukkit.block.BlockSupport;
public final class CraftBlockSupport {
@@ -8,7 +8,7 @@ public final class CraftBlockSupport {
private CraftBlockSupport() {
}
public static BlockSupport toBukkit(EnumBlockSupport support) {
public static BlockSupport toBukkit(SupportType support) {
return switch (support) {
case FULL -> BlockSupport.FULL;
case CENTER -> BlockSupport.CENTER;
@@ -17,11 +17,11 @@ public final class CraftBlockSupport {
};
}
public static EnumBlockSupport toNMS(BlockSupport support) {
public static SupportType toNMS(BlockSupport support) {
return switch (support) {
case FULL -> EnumBlockSupport.FULL;
case CENTER -> EnumBlockSupport.CENTER;
case RIGID -> EnumBlockSupport.RIGID;
case FULL -> SupportType.FULL;
case CENTER -> SupportType.CENTER;
case RIGID -> SupportType.RIGID;
default -> throw new IllegalArgumentException("Unsupported BlockSupport type: " + support + ". This is a bug.");
};
}

View File

@@ -4,20 +4,20 @@ import com.google.common.base.Preconditions;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.function.Consumer;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.EnumHand;
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.BlockAccessAir;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.BlockFire;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Fallable;
import net.minecraft.world.level.block.state.BlockBase;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.level.block.FireBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
@@ -70,21 +70,21 @@ public class CraftBlockType<B extends BlockData> implements BlockType.Typed<B>,
}
private static final Class<?>[] USE_WITHOUT_ITEM_ARGS = new Class[]{
IBlockData.class, net.minecraft.world.level.World.class, BlockPosition.class, EntityHuman.class, MovingObjectPositionBlock.class
BlockState.class, net.minecraft.world.level.Level.class, BlockPos.class, Player.class, BlockHitResult.class
};
private static final Class<?>[] USE_ITEM_ON_ARGS = new Class[]{
net.minecraft.world.item.ItemStack.class, IBlockData.class, net.minecraft.world.level.World.class, BlockPosition.class, EntityHuman.class, EnumHand.class, MovingObjectPositionBlock.class
net.minecraft.world.item.ItemStack.class, BlockState.class, net.minecraft.world.level.Level.class, BlockPos.class, Player.class, InteractionHand.class, BlockHitResult.class
};
private static boolean isInteractable(Block block) {
Class<?> clazz = block.getClass();
boolean hasMethod = hasMethod(clazz, USE_WITHOUT_ITEM_ARGS) || hasMethod(clazz, USE_ITEM_ON_ARGS);
boolean hasMethod = CraftBlockType.hasMethod(clazz, CraftBlockType.USE_WITHOUT_ITEM_ARGS) || CraftBlockType.hasMethod(clazz, CraftBlockType.USE_ITEM_ON_ARGS);
if (!hasMethod && clazz.getSuperclass() != BlockBase.class) {
if (!hasMethod && clazz.getSuperclass() != BlockBehaviour.class) {
clazz = clazz.getSuperclass();
hasMethod = hasMethod(clazz, USE_WITHOUT_ITEM_ARGS) || hasMethod(clazz, USE_ITEM_ON_ARGS);
hasMethod = CraftBlockType.hasMethod(clazz, CraftBlockType.USE_WITHOUT_ITEM_ARGS) || CraftBlockType.hasMethod(clazz, CraftBlockType.USE_ITEM_ON_ARGS);
}
return hasMethod;
@@ -94,12 +94,12 @@ public class CraftBlockType<B extends BlockData> implements BlockType.Typed<B>,
this.key = key;
this.block = block;
this.blockDataClass = (Class<B>) CraftBlockData.fromData(block.defaultBlockState()).getClass().getInterfaces()[0];
this.interactable = isInteractable(block);
this.interactable = CraftBlockType.isInteractable(block);
}
@Override
public Block getHandle() {
return block;
return this.block;
}
@NotNull
@@ -122,7 +122,7 @@ public class CraftBlockType<B extends BlockData> implements BlockType.Typed<B>,
return true;
}
return block.asItem() != Items.AIR;
return this.block.asItem() != Items.AIR;
}
@NotNull
@@ -132,24 +132,24 @@ public class CraftBlockType<B extends BlockData> implements BlockType.Typed<B>,
return ItemType.AIR;
}
Item item = block.asItem();
Preconditions.checkArgument(item != Items.AIR, "The block type %s has no corresponding item type", getKey());
Item item = this.block.asItem();
Preconditions.checkArgument(item != Items.AIR, "The block type %s has no corresponding item type", this.getKey());
return CraftItemType.minecraftToBukkitNew(item);
}
@Override
public Class<B> getBlockDataClass() {
return blockDataClass;
return this.blockDataClass;
}
@Override
public B createBlockData() {
return createBlockData((String) null);
return this.createBlockData((String) null);
}
@Override
public B createBlockData(Consumer<? super B> consumer) {
B data = createBlockData();
B data = this.createBlockData();
if (consumer != null) {
consumer.accept(data);
@@ -165,69 +165,69 @@ public class CraftBlockType<B extends BlockData> implements BlockType.Typed<B>,
@Override
public boolean isSolid() {
return block.defaultBlockState().blocksMotion();
return this.block.defaultBlockState().blocksMotion();
}
@Override
public boolean isAir() {
return block.defaultBlockState().isAir();
return this.block.defaultBlockState().isAir();
}
@Override
public boolean isEnabledByFeature(@NotNull World world) {
Preconditions.checkNotNull(world, "World cannot be null");
return getHandle().isEnabled(((CraftWorld) world).getHandle().enabledFeatures());
return this.getHandle().isEnabled(((CraftWorld) world).getHandle().enabledFeatures());
}
@Override
public boolean isFlammable() {
return block.defaultBlockState().ignitedByLava();
return this.block.defaultBlockState().ignitedByLava();
}
@Override
public boolean isBurnable() {
return ((BlockFire) Blocks.FIRE).igniteOdds.getOrDefault(block, 0) > 0;
return ((FireBlock) Blocks.FIRE).igniteOdds.getOrDefault(this.block, 0) > 0;
}
@Override
public boolean isOccluding() {
return block.defaultBlockState().isRedstoneConductor(BlockAccessAir.INSTANCE, BlockPosition.ZERO);
return this.block.defaultBlockState().isRedstoneConductor(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
}
@Override
public boolean hasGravity() {
return block instanceof Fallable;
return this.block instanceof Fallable;
}
@Override
public boolean isInteractable() {
return interactable;
return this.interactable;
}
@Override
public float getHardness() {
return block.defaultBlockState().destroySpeed;
return this.block.defaultBlockState().destroySpeed;
}
@Override
public float getBlastResistance() {
return block.getExplosionResistance();
return this.block.getExplosionResistance();
}
@Override
public float getSlipperiness() {
return block.getFriction();
return this.block.getFriction();
}
@NotNull
@Override
public String getTranslationKey() {
return block.getDescriptionId();
return this.block.getDescriptionId();
}
@Override
public NamespacedKey getKey() {
return key;
return this.key;
}
@Override

View File

@@ -1,15 +1,15 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.TileEntityBrewingStand;
import net.minecraft.world.level.block.entity.BrewingStandBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.BrewingStand;
import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer;
import org.bukkit.inventory.BrewerInventory;
public class CraftBrewingStand extends CraftContainer<TileEntityBrewingStand> implements BrewingStand {
public class CraftBrewingStand extends CraftContainer<BrewingStandBlockEntity> implements BrewingStand {
public CraftBrewingStand(World world, TileEntityBrewingStand tileEntity) {
public CraftBrewingStand(World world, BrewingStandBlockEntity tileEntity) {
super(world, tileEntity);
}

View File

@@ -21,12 +21,12 @@ public class CraftBrushableBlock extends CraftBlockEntityState<BrushableBlockEnt
@Override
public ItemStack getItem() {
return CraftItemStack.asBukkitCopy(getSnapshot().getItem());
return CraftItemStack.asBukkitCopy(this.getSnapshot().getItem());
}
@Override
public void setItem(ItemStack item) {
getSnapshot().item = CraftItemStack.asNMSCopy(item);
this.getSnapshot().item = CraftItemStack.asNMSCopy(item);
}
@Override
@@ -40,26 +40,26 @@ public class CraftBrushableBlock extends CraftBlockEntityState<BrushableBlockEnt
@Override
public LootTable getLootTable() {
return CraftLootTable.minecraftToBukkit(getSnapshot().lootTable);
return CraftLootTable.minecraftToBukkit(this.getSnapshot().lootTable);
}
@Override
public void setLootTable(LootTable table) {
setLootTable(table, getSeed());
this.setLootTable(table, this.getSeed());
}
@Override
public long getSeed() {
return getSnapshot().lootTableSeed;
return this.getSnapshot().lootTableSeed;
}
@Override
public void setSeed(long seed) {
setLootTable(getLootTable(), seed);
this.setLootTable(this.getLootTable(), seed);
}
private void setLootTable(LootTable table, long seed) {
getSnapshot().setLootTable(CraftLootTable.bukkitToMinecraft(table), seed);
this.getSnapshot().setLootTable(CraftLootTable.bukkitToMinecraft(table), seed);
}
@Override

View File

@@ -1,15 +1,15 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.TileEntityCampfire;
import net.minecraft.world.level.block.entity.CampfireBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Campfire;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
public class CraftCampfire extends CraftBlockEntityState<TileEntityCampfire> implements Campfire {
public class CraftCampfire extends CraftBlockEntityState<CampfireBlockEntity> implements Campfire {
public CraftCampfire(World world, TileEntityCampfire tileEntity) {
public CraftCampfire(World world, CampfireBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -19,38 +19,38 @@ public class CraftCampfire extends CraftBlockEntityState<TileEntityCampfire> imp
@Override
public int getSize() {
return getSnapshot().getItems().size();
return this.getSnapshot().getItems().size();
}
@Override
public ItemStack getItem(int index) {
net.minecraft.world.item.ItemStack item = getSnapshot().getItems().get(index);
net.minecraft.world.item.ItemStack item = this.getSnapshot().getItems().get(index);
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
}
@Override
public void setItem(int index, ItemStack item) {
getSnapshot().getItems().set(index, CraftItemStack.asNMSCopy(item));
this.getSnapshot().getItems().set(index, CraftItemStack.asNMSCopy(item));
}
@Override
public int getCookTime(int index) {
return getSnapshot().cookingProgress[index];
return this.getSnapshot().cookingProgress[index];
}
@Override
public void setCookTime(int index, int cookTime) {
getSnapshot().cookingProgress[index] = cookTime;
this.getSnapshot().cookingProgress[index] = cookTime;
}
@Override
public int getCookTimeTotal(int index) {
return getSnapshot().cookingTime[index];
return this.getSnapshot().cookingTime[index];
}
@Override
public void setCookTimeTotal(int index, int cookTimeTotal) {
getSnapshot().cookingTime[index] = cookTimeTotal;
this.getSnapshot().cookingTime[index] = cookTimeTotal;
}
@Override

View File

@@ -1,10 +1,10 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.ITileInventory;
import net.minecraft.world.level.block.BlockChest;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.TileEntityChest;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.block.ChestBlock;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
@@ -14,9 +14,9 @@ import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest;
import org.bukkit.inventory.Inventory;
public class CraftChest extends CraftLootable<TileEntityChest> implements Chest {
public class CraftChest extends CraftLootable<ChestBlockEntity> implements Chest {
public CraftChest(World world, TileEntityChest tileEntity) {
public CraftChest(World world, ChestBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -41,46 +41,46 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest
@Override
public Inventory getInventory() {
CraftInventory inventory = (CraftInventory) this.getBlockInventory();
if (!isPlaced() || isWorldGeneration()) {
if (!this.isPlaced() || this.isWorldGeneration()) {
return inventory;
}
// The logic here is basically identical to the logic in BlockChest.interact
CraftWorld world = (CraftWorld) this.getWorld();
BlockChest blockChest = (BlockChest) (this.getType() == Material.CHEST ? Blocks.CHEST : Blocks.TRAPPED_CHEST);
ITileInventory nms = blockChest.getMenuProvider(data, world.getHandle(), this.getPosition(), true);
ChestBlock blockChest = (ChestBlock) (this.getType() == Material.CHEST ? Blocks.CHEST : Blocks.TRAPPED_CHEST);
MenuProvider nms = blockChest.getMenuProvider(this.data, world.getHandle(), this.getPosition(), true);
if (nms instanceof BlockChest.DoubleInventory) {
inventory = new CraftInventoryDoubleChest((BlockChest.DoubleInventory) nms);
if (nms instanceof ChestBlock.DoubleInventory) {
inventory = new CraftInventoryDoubleChest((ChestBlock.DoubleInventory) nms);
}
return inventory;
}
@Override
public void open() {
requirePlaced();
if (!getTileEntity().openersCounter.opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
IBlockData block = getTileEntity().getBlockState();
int openCount = getTileEntity().openersCounter.getOpenerCount();
this.requirePlaced();
if (!this.getTileEntity().openersCounter.opened && this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
BlockState block = this.getTileEntity().getBlockState();
int openCount = this.getTileEntity().openersCounter.getOpenerCount();
getTileEntity().openersCounter.onAPIOpen((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block);
getTileEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block, openCount, openCount + 1);
this.getTileEntity().openersCounter.onAPIOpen((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block);
this.getTileEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block, openCount, openCount + 1);
}
getTileEntity().openersCounter.opened = true;
this.getTileEntity().openersCounter.opened = true;
}
@Override
public void close() {
requirePlaced();
if (getTileEntity().openersCounter.opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
IBlockData block = getTileEntity().getBlockState();
int openCount = getTileEntity().openersCounter.getOpenerCount();
this.requirePlaced();
if (this.getTileEntity().openersCounter.opened && this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
BlockState block = this.getTileEntity().getBlockState();
int openCount = this.getTileEntity().openersCounter.getOpenerCount();
getTileEntity().openersCounter.onAPIClose((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block);
getTileEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block, openCount, 0);
this.getTileEntity().openersCounter.onAPIClose((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block);
this.getTileEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block, openCount, 0);
}
getTileEntity().openersCounter.opened = false;
this.getTileEntity().openersCounter.opened = false;
}
@Override

View File

@@ -2,7 +2,7 @@ package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.ChiseledBookShelfBlock;
import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity;
import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec2;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
@@ -24,12 +24,12 @@ public class CraftChiseledBookshelf extends CraftBlockEntityState<ChiseledBookSh
@Override
public int getLastInteractedSlot() {
return getSnapshot().getLastInteractedSlot();
return this.getSnapshot().getLastInteractedSlot();
}
@Override
public void setLastInteractedSlot(int lastInteractedSlot) {
getSnapshot().lastInteractedSlot = lastInteractedSlot;
this.getSnapshot().lastInteractedSlot = lastInteractedSlot;
}
@Override
@@ -50,19 +50,19 @@ public class CraftChiseledBookshelf extends CraftBlockEntityState<ChiseledBookSh
public int getSlot(Vector clickVector) {
BlockFace facing = ((Directional) this.getBlockData()).getFacing();
Vec2F faceVector;
Vec2 faceVector;
switch (facing) {
case NORTH:
faceVector = new Vec2F((float) (1.0f - clickVector.getX()), (float) clickVector.getY());
faceVector = new Vec2((float) (1.0f - clickVector.getX()), (float) clickVector.getY());
break;
case SOUTH:
faceVector = new Vec2F((float) clickVector.getX(), (float) clickVector.getY());
faceVector = new Vec2((float) clickVector.getX(), (float) clickVector.getY());
break;
case WEST:
faceVector = new Vec2F((float) clickVector.getZ(), (float) clickVector.getY());
faceVector = new Vec2((float) clickVector.getZ(), (float) clickVector.getY());
break;
case EAST:
faceVector = new Vec2F((float) (1f - clickVector.getZ()), (float) clickVector.getY());
faceVector = new Vec2((float) (1f - clickVector.getZ()), (float) clickVector.getY());
break;
case DOWN:
case UP:
@@ -70,10 +70,10 @@ public class CraftChiseledBookshelf extends CraftBlockEntityState<ChiseledBookSh
return -1;
}
return getHitSlot(faceVector);
return CraftChiseledBookshelf.getHitSlot(faceVector);
}
private static int getHitSlot(Vec2F vec2f) {
private static int getHitSlot(Vec2 vec2f) {
int i = vec2f.y >= 0.5F ? 0 : 1;
int j = ChiseledBookShelfBlock.getSection(vec2f.x);

View File

@@ -1,14 +1,14 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.TileEntityCommand;
import net.minecraft.world.level.block.entity.CommandBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CommandBlock;
import org.bukkit.craftbukkit.util.CraftChatMessage;
public class CraftCommandBlock extends CraftBlockEntityState<TileEntityCommand> implements CommandBlock {
public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity> implements CommandBlock {
public CraftCommandBlock(World world, TileEntityCommand tileEntity) {
public CraftCommandBlock(World world, CommandBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -18,22 +18,22 @@ public class CraftCommandBlock extends CraftBlockEntityState<TileEntityCommand>
@Override
public String getCommand() {
return getSnapshot().getCommandBlock().getCommand();
return this.getSnapshot().getCommandBlock().getCommand();
}
@Override
public void setCommand(String command) {
getSnapshot().getCommandBlock().setCommand(command != null ? command : "");
this.getSnapshot().getCommandBlock().setCommand(command != null ? command : "");
}
@Override
public String getName() {
return CraftChatMessage.fromComponent(getSnapshot().getCommandBlock().getName());
return CraftChatMessage.fromComponent(this.getSnapshot().getCommandBlock().getName());
}
@Override
public void setName(String name) {
getSnapshot().getCommandBlock().setCustomName(CraftChatMessage.fromStringOrNull(name != null ? name : "@"));
this.getSnapshot().getCommandBlock().setCustomName(CraftChatMessage.fromStringOrNull(name != null ? name : "@"));
}
@Override

View File

@@ -1,13 +1,13 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.TileEntityComparator;
import net.minecraft.world.level.block.entity.ComparatorBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Comparator;
public class CraftComparator extends CraftBlockEntityState<TileEntityComparator> implements Comparator {
public class CraftComparator extends CraftBlockEntityState<ComparatorBlockEntity> implements Comparator {
public CraftComparator(World world, TileEntityComparator tileEntity) {
public CraftComparator(World world, ComparatorBlockEntity tileEntity) {
super(world, tileEntity);
}

View File

@@ -2,10 +2,9 @@ package org.bukkit.craftbukkit.block;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.core.BlockPosition;
import net.minecraft.world.entity.EntityLiving;
import net.minecraft.world.level.block.entity.TileEntityConduit;
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.ConduitBlockEntity;
import net.minecraft.world.phys.AABB;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
@@ -14,9 +13,9 @@ import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.BoundingBox;
public class CraftConduit extends CraftBlockEntityState<TileEntityConduit> implements Conduit {
public class CraftConduit extends CraftBlockEntityState<ConduitBlockEntity> implements Conduit {
public CraftConduit(World world, TileEntityConduit tileEntity) {
public CraftConduit(World world, ConduitBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -36,27 +35,27 @@ public class CraftConduit extends CraftBlockEntityState<TileEntityConduit> imple
@Override
public boolean isActive() {
ensureNoWorldGeneration();
TileEntityConduit conduit = (TileEntityConduit) getTileEntityFromWorld();
this.ensureNoWorldGeneration();
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
return conduit != null && conduit.isActive();
}
@Override
public boolean isHunting() {
ensureNoWorldGeneration();
TileEntityConduit conduit = (TileEntityConduit) getTileEntityFromWorld();
this.ensureNoWorldGeneration();
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
return conduit != null && conduit.isHunting();
}
@Override
public Collection<Block> getFrameBlocks() {
ensureNoWorldGeneration();
this.ensureNoWorldGeneration();
Collection<Block> blocks = new ArrayList<>();
TileEntityConduit conduit = (TileEntityConduit) getTileEntityFromWorld();
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
if (conduit != null) {
for (BlockPosition position : conduit.effectBlocks) {
blocks.add(CraftBlock.at(getWorldHandle(), position));
for (BlockPos position : conduit.effectBlocks) {
blocks.add(CraftBlock.at(this.getWorldHandle(), position));
}
}
@@ -65,26 +64,26 @@ public class CraftConduit extends CraftBlockEntityState<TileEntityConduit> imple
@Override
public int getFrameBlockCount() {
ensureNoWorldGeneration();
TileEntityConduit conduit = (TileEntityConduit) getTileEntityFromWorld();
this.ensureNoWorldGeneration();
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
return (conduit != null) ? conduit.effectBlocks.size() : 0;
}
@Override
public int getRange() {
ensureNoWorldGeneration();
TileEntityConduit conduit = (TileEntityConduit) getTileEntityFromWorld();
return (conduit != null) ? TileEntityConduit.getRange(conduit.effectBlocks) : 0;
this.ensureNoWorldGeneration();
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
return (conduit != null) ? ConduitBlockEntity.getRange(conduit.effectBlocks) : 0;
}
@Override
public boolean setTarget(LivingEntity target) {
TileEntityConduit conduit = (TileEntityConduit) getTileEntityFromWorld();
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
if (conduit == null) {
return false;
}
EntityLiving currentTarget = conduit.destroyTarget;
net.minecraft.world.entity.LivingEntity currentTarget = conduit.destroyTarget;
if (target == null) {
if (currentTarget == null) {
@@ -102,30 +101,30 @@ public class CraftConduit extends CraftBlockEntityState<TileEntityConduit> imple
conduit.destroyTargetUUID = target.getUniqueId();
}
TileEntityConduit.updateDestroyTarget(conduit.getLevel(), getPosition(), data, conduit.effectBlocks, conduit, false);
ConduitBlockEntity.updateDestroyTarget(conduit.getLevel(), this.getPosition(), this.data, conduit.effectBlocks, conduit, false);
return true;
}
@Override
public LivingEntity getTarget() {
TileEntityConduit conduit = (TileEntityConduit) getTileEntityFromWorld();
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
if (conduit == null) {
return null;
}
EntityLiving nmsEntity = conduit.destroyTarget;
net.minecraft.world.entity.LivingEntity nmsEntity = conduit.destroyTarget;
return (nmsEntity != null) ? (LivingEntity) nmsEntity.getBukkitEntity() : null;
}
@Override
public boolean hasTarget() {
TileEntityConduit conduit = (TileEntityConduit) getTileEntityFromWorld();
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
return conduit != null && conduit.destroyTarget != null && conduit.destroyTarget.isAlive();
}
@Override
public BoundingBox getHuntingArea() {
AxisAlignedBB bounds = TileEntityConduit.getDestroyRangeAABB(getPosition());
AABB bounds = ConduitBlockEntity.getDestroyRangeAABB(this.getPosition());
return new BoundingBox(bounds.minX, bounds.minY, bounds.minZ, bounds.maxX, bounds.maxY, bounds.maxZ);
}
}

View File

@@ -2,13 +2,13 @@ package org.bukkit.craftbukkit.block;
import java.util.Collections;
import java.util.Optional;
import net.minecraft.advancements.critereon.CriterionConditionItem;
import net.minecraft.advancements.critereon.CriterionConditionValue;
import net.minecraft.advancements.critereon.ItemPredicate;
import net.minecraft.advancements.critereon.MinMaxBounds;
import net.minecraft.core.component.DataComponentPredicate;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.world.ChestLock;
import net.minecraft.world.level.block.entity.TileEntityContainer;
import net.minecraft.network.chat.Component;
import net.minecraft.world.LockCode;
import net.minecraft.world.level.block.entity.BaseContainerBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Container;
@@ -16,7 +16,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.util.CraftChatMessage;
import org.bukkit.inventory.ItemStack;
public abstract class CraftContainer<T extends TileEntityContainer> extends CraftBlockEntityState<T> implements Container {
public abstract class CraftContainer<T extends BaseContainerBlockEntity> extends CraftBlockEntityState<T> implements Container {
public CraftContainer(World world, T tileEntity) {
super(world, tileEntity);
@@ -28,12 +28,12 @@ public abstract class CraftContainer<T extends TileEntityContainer> extends Craf
@Override
public boolean isLocked() {
return this.getSnapshot().lockKey != ChestLock.NO_LOCK;
return this.getSnapshot().lockKey != LockCode.NO_LOCK;
}
@Override
public String getLock() {
Optional<? extends IChatBaseComponent> customName = this.getSnapshot().lockKey.predicate().components().asPatch().get(DataComponents.CUSTOM_NAME);
Optional<? extends Component> customName = this.getSnapshot().lockKey.predicate().components().asPatch().get(DataComponents.CUSTOM_NAME);
return (customName != null) ? customName.map(CraftChatMessage::fromComponent).orElse("") : "";
}
@@ -41,19 +41,19 @@ public abstract class CraftContainer<T extends TileEntityContainer> extends Craf
@Override
public void setLock(String key) {
if (key == null) {
this.getSnapshot().lockKey = ChestLock.NO_LOCK;
this.getSnapshot().lockKey = LockCode.NO_LOCK;
} else {
DataComponentPredicate predicate = DataComponentPredicate.builder().expect(DataComponents.CUSTOM_NAME, CraftChatMessage.fromStringOrNull(key)).build();
this.getSnapshot().lockKey = new ChestLock(new CriterionConditionItem(Optional.empty(), CriterionConditionValue.IntegerRange.ANY, predicate, Collections.emptyMap()));
this.getSnapshot().lockKey = new LockCode(new ItemPredicate(Optional.empty(), MinMaxBounds.Ints.ANY, predicate, Collections.emptyMap()));
}
}
@Override
public void setLockItem(ItemStack key) {
if (key == null) {
this.getSnapshot().lockKey = ChestLock.NO_LOCK;
this.getSnapshot().lockKey = LockCode.NO_LOCK;
} else {
this.getSnapshot().lockKey = new ChestLock(CraftItemStack.asCriterionConditionItem(key));
this.getSnapshot().lockKey = new LockCode(CraftItemStack.asCriterionConditionItem(key));
}
}

View File

@@ -44,35 +44,35 @@ public class CraftCrafter extends CraftLootable<CrafterBlockEntity> implements C
@Override
public int getCraftingTicks() {
return getSnapshot().craftingTicksRemaining;
return this.getSnapshot().craftingTicksRemaining;
}
@Override
public void setCraftingTicks(int ticks) {
getSnapshot().setCraftingTicksRemaining(ticks);
this.getSnapshot().setCraftingTicksRemaining(ticks);
}
@Override
public boolean isSlotDisabled(int slot) {
Preconditions.checkArgument(slot >= 0 && slot < 9, "Invalid slot index %s for Crafter", slot);
return getSnapshot().isSlotDisabled(slot);
return this.getSnapshot().isSlotDisabled(slot);
}
@Override
public void setSlotDisabled(int slot, boolean disabled) {
Preconditions.checkArgument(slot >= 0 && slot < 9, "Invalid slot index %s for Crafter", slot);
getSnapshot().setSlotState(slot, disabled);
this.getSnapshot().setSlotState(slot, disabled);
}
@Override
public boolean isTriggered() {
return getSnapshot().isTriggered();
return this.getSnapshot().isTriggered();
}
@Override
public void setTriggered(boolean triggered) {
getSnapshot().setTriggered(triggered);
this.getSnapshot().setTriggered(triggered);
}
}

View File

@@ -8,16 +8,15 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.InclusiveRange;
import net.minecraft.util.RandomSource;
import net.minecraft.util.random.SimpleWeightedRandomList;
import net.minecraft.util.random.WeightedEntry.b;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.util.random.WeightedEntry.Wrapper;
import net.minecraft.world.entity.EquipmentTable;
import net.minecraft.world.level.MobSpawnerAbstract;
import net.minecraft.world.level.MobSpawnerData;
import net.minecraft.world.level.block.entity.TileEntityMobSpawner;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.SpawnData;
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CreatureSpawner;
@@ -30,9 +29,9 @@ import org.bukkit.craftbukkit.entity.CraftEntityType;
import org.bukkit.entity.EntitySnapshot;
import org.bukkit.entity.EntityType;
public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpawner> implements CreatureSpawner {
public class CraftCreatureSpawner extends CraftBlockEntityState<SpawnerBlockEntity> implements CreatureSpawner {
public CraftCreatureSpawner(World world, TileEntityMobSpawner tileEntity) {
public CraftCreatureSpawner(World world, SpawnerBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -42,12 +41,12 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
@Override
public EntityType getSpawnedType() {
MobSpawnerData spawnData = this.getSnapshot().getSpawner().nextSpawnData;
SpawnData spawnData = this.getSnapshot().getSpawner().nextSpawnData;
if (spawnData == null) {
return null;
}
Optional<EntityTypes<?>> type = EntityTypes.by(spawnData.getEntityToSpawn());
Optional<net.minecraft.world.entity.EntityType<?>> type = net.minecraft.world.entity.EntityType.by(spawnData.getEntityToSpawn());
return type.map(CraftEntityType::minecraftToBukkit).orElse(null);
}
@@ -55,7 +54,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
public void setSpawnedType(EntityType entityType) {
if (entityType == null) {
this.getSnapshot().getSpawner().spawnPotentials = SimpleWeightedRandomList.empty(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later
this.getSnapshot().getSpawner().nextSpawnData = new MobSpawnerData();
this.getSnapshot().getSpawner().nextSpawnData = new SpawnData();
return;
}
Preconditions.checkArgument(entityType != EntityType.UNKNOWN, "Can't spawn EntityType %s from mob spawners!", entityType);
@@ -66,7 +65,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
@Override
public EntitySnapshot getSpawnedEntity() {
MobSpawnerData spawnData = this.getSnapshot().getSpawner().nextSpawnData;
SpawnData spawnData = this.getSnapshot().getSpawner().nextSpawnData;
if (spawnData == null) {
return null;
}
@@ -76,41 +75,41 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
@Override
public void setSpawnedEntity(EntitySnapshot snapshot) {
setSpawnedEntity(this.getSnapshot().getSpawner(), snapshot, null, null);
CraftCreatureSpawner.setSpawnedEntity(this.getSnapshot().getSpawner(), snapshot, null, null);
}
@Override
public void setSpawnedEntity(SpawnerEntry spawnerEntry) {
Preconditions.checkArgument(spawnerEntry != null, "Entry cannot be null");
setSpawnedEntity(this.getSnapshot().getSpawner(), spawnerEntry.getSnapshot(), spawnerEntry.getSpawnRule(), spawnerEntry.getEquipment());
CraftCreatureSpawner.setSpawnedEntity(this.getSnapshot().getSpawner(), spawnerEntry.getSnapshot(), spawnerEntry.getSpawnRule(), spawnerEntry.getEquipment());
}
public static void setSpawnedEntity(MobSpawnerAbstract spawner, EntitySnapshot snapshot, SpawnRule spawnRule, SpawnerEntry.Equipment equipment) {
public static void setSpawnedEntity(BaseSpawner spawner, EntitySnapshot snapshot, SpawnRule spawnRule, SpawnerEntry.Equipment equipment) {
spawner.spawnPotentials = SimpleWeightedRandomList.empty(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later
if (snapshot == null) {
spawner.nextSpawnData = new MobSpawnerData();
spawner.nextSpawnData = new SpawnData();
return;
}
NBTTagCompound compoundTag = ((CraftEntitySnapshot) snapshot).getData();
CompoundTag compoundTag = ((CraftEntitySnapshot) snapshot).getData();
spawner.nextSpawnData = new MobSpawnerData(compoundTag, Optional.ofNullable(toMinecraftRule(spawnRule)), getEquipment(equipment));
spawner.nextSpawnData = new SpawnData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnRule)), CraftCreatureSpawner.getEquipment(equipment));
}
@Override
public void addPotentialSpawn(EntitySnapshot snapshot, int weight, SpawnRule spawnRule) {
addPotentialSpawn(this.getSnapshot().getSpawner(), snapshot, weight, spawnRule, null);
CraftCreatureSpawner.addPotentialSpawn(this.getSnapshot().getSpawner(), snapshot, weight, spawnRule, null);
}
public static void addPotentialSpawn(MobSpawnerAbstract spawner, EntitySnapshot snapshot, int weight, SpawnRule spawnRule, SpawnerEntry.Equipment equipment) {
public static void addPotentialSpawn(BaseSpawner spawner, EntitySnapshot snapshot, int weight, SpawnRule spawnRule, SpawnerEntry.Equipment equipment) {
Preconditions.checkArgument(snapshot != null, "Snapshot cannot be null");
NBTTagCompound compoundTag = ((CraftEntitySnapshot) snapshot).getData();
CompoundTag compoundTag = ((CraftEntitySnapshot) snapshot).getData();
SimpleWeightedRandomList.a<MobSpawnerData> builder = SimpleWeightedRandomList.builder(); // PAIL rename Builder
SimpleWeightedRandomList.Builder<SpawnData> builder = SimpleWeightedRandomList.builder(); // PAIL rename Builder
spawner.spawnPotentials.unwrap().forEach(entry -> builder.add(entry.data(), entry.getWeight().asInt()));
builder.add(new MobSpawnerData(compoundTag, Optional.ofNullable(toMinecraftRule(spawnRule)), getEquipment(equipment)), weight);
builder.add(new SpawnData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnRule)), CraftCreatureSpawner.getEquipment(equipment)), weight);
spawner.spawnPotentials = builder.build();
}
@@ -118,52 +117,52 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
public void addPotentialSpawn(SpawnerEntry spawnerEntry) {
Preconditions.checkArgument(spawnerEntry != null, "Entry cannot be null");
addPotentialSpawn(spawnerEntry.getSnapshot(), spawnerEntry.getSpawnWeight(), spawnerEntry.getSpawnRule());
this.addPotentialSpawn(spawnerEntry.getSnapshot(), spawnerEntry.getSpawnWeight(), spawnerEntry.getSpawnRule());
}
@Override
public void setPotentialSpawns(Collection<SpawnerEntry> entries) {
setPotentialSpawns(this.getSnapshot().getSpawner(), entries);
CraftCreatureSpawner.setPotentialSpawns(this.getSnapshot().getSpawner(), entries);
}
public static void setPotentialSpawns(MobSpawnerAbstract spawner, Collection<SpawnerEntry> entries) {
public static void setPotentialSpawns(BaseSpawner spawner, Collection<SpawnerEntry> entries) {
Preconditions.checkArgument(entries != null, "Entries cannot be null");
SimpleWeightedRandomList.a<MobSpawnerData> builder = SimpleWeightedRandomList.builder();
SimpleWeightedRandomList.Builder<SpawnData> builder = SimpleWeightedRandomList.builder();
for (SpawnerEntry spawnerEntry : entries) {
NBTTagCompound compoundTag = ((CraftEntitySnapshot) spawnerEntry.getSnapshot()).getData();
builder.add(new MobSpawnerData(compoundTag, Optional.ofNullable(toMinecraftRule(spawnerEntry.getSpawnRule())), getEquipment(spawnerEntry.getEquipment())), spawnerEntry.getSpawnWeight());
CompoundTag compoundTag = ((CraftEntitySnapshot) spawnerEntry.getSnapshot()).getData();
builder.add(new SpawnData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnerEntry.getSpawnRule())), CraftCreatureSpawner.getEquipment(spawnerEntry.getEquipment())), spawnerEntry.getSpawnWeight());
}
spawner.spawnPotentials = builder.build();
}
@Override
public List<SpawnerEntry> getPotentialSpawns() {
return getPotentialSpawns(this.getSnapshot().getSpawner());
return CraftCreatureSpawner.getPotentialSpawns(this.getSnapshot().getSpawner());
}
public static List<SpawnerEntry> getPotentialSpawns(MobSpawnerAbstract spawner) {
public static List<SpawnerEntry> getPotentialSpawns(BaseSpawner spawner) {
List<SpawnerEntry> entries = new ArrayList<>();
for (b<MobSpawnerData> entry : spawner.spawnPotentials.unwrap()) { // PAIL rename Wrapper
for (Wrapper<SpawnData> entry : spawner.spawnPotentials.unwrap()) { // PAIL rename Wrapper
CraftEntitySnapshot snapshot = CraftEntitySnapshot.create(entry.data().getEntityToSpawn());
if (snapshot != null) {
SpawnRule rule = entry.data().customSpawnRules().map(CraftCreatureSpawner::fromMinecraftRule).orElse(null);
entries.add(new SpawnerEntry(snapshot, entry.getWeight().asInt(), rule, getEquipment(entry.data().equipment())));
entries.add(new SpawnerEntry(snapshot, entry.getWeight().asInt(), rule, CraftCreatureSpawner.getEquipment(entry.data().equipment())));
}
}
return entries;
}
public static MobSpawnerData.a toMinecraftRule(SpawnRule rule) { // PAIL rename CustomSpawnRules
public static SpawnData.CustomSpawnRules toMinecraftRule(SpawnRule rule) { // PAIL rename CustomSpawnRules
if (rule == null) {
return null;
}
return new MobSpawnerData.a(new InclusiveRange<>(rule.getMinBlockLight(), rule.getMaxBlockLight()), new InclusiveRange<>(rule.getMinSkyLight(), rule.getMaxSkyLight()));
return new SpawnData.CustomSpawnRules(new InclusiveRange<>(rule.getMinBlockLight(), rule.getMaxBlockLight()), new InclusiveRange<>(rule.getMinSkyLight(), rule.getMaxSkyLight()));
}
public static SpawnRule fromMinecraftRule(MobSpawnerData.a rule) {
public static SpawnRule fromMinecraftRule(SpawnData.CustomSpawnRules rule) {
InclusiveRange<Integer> blockLight = rule.blockLightLimit();
InclusiveRange<Integer> skyLight = rule.skyLightLimit();
@@ -172,12 +171,12 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
@Override
public String getCreatureTypeName() {
MobSpawnerData spawnData = this.getSnapshot().getSpawner().nextSpawnData;
SpawnData spawnData = this.getSnapshot().getSpawner().nextSpawnData;
if (spawnData == null) {
return null;
}
Optional<EntityTypes<?>> type = EntityTypes.by(spawnData.getEntityToSpawn());
Optional<net.minecraft.world.entity.EntityType<?>> type = net.minecraft.world.entity.EntityType.by(spawnData.getEntityToSpawn());
return type.map(CraftEntityType::minecraftToBukkit).map(CraftEntityType::bukkitToString).orElse(null);
}
@@ -186,10 +185,10 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
// Verify input
EntityType type = CraftEntityType.stringToBukkit(creatureType);
if (type == null) {
setSpawnedType(null);
this.setSpawnedType(null);
return;
}
setSpawnedType(type);
this.setSpawnedType(type);
}
@Override
@@ -209,7 +208,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
@Override
public void setMinSpawnDelay(int spawnDelay) {
Preconditions.checkArgument(spawnDelay <= getMaxSpawnDelay(), "Minimum Spawn Delay must be less than or equal to Maximum Spawn Delay");
Preconditions.checkArgument(spawnDelay <= this.getMaxSpawnDelay(), "Minimum Spawn Delay must be less than or equal to Maximum Spawn Delay");
this.getSnapshot().getSpawner().minSpawnDelay = spawnDelay;
}
@@ -221,7 +220,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
@Override
public void setMaxSpawnDelay(int spawnDelay) {
Preconditions.checkArgument(spawnDelay > 0, "Maximum Spawn Delay must be greater than 0.");
Preconditions.checkArgument(spawnDelay >= getMinSpawnDelay(), "Maximum Spawn Delay must be greater than or equal to Minimum Spawn Delay");
Preconditions.checkArgument(spawnDelay >= this.getMinSpawnDelay(), "Maximum Spawn Delay must be greater than or equal to Minimum Spawn Delay");
this.getSnapshot().getSpawner().maxSpawnDelay = spawnDelay;
}

View File

@@ -1,13 +1,13 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.TileEntityLightDetector;
import net.minecraft.world.level.block.entity.DaylightDetectorBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.DaylightDetector;
public class CraftDaylightDetector extends CraftBlockEntityState<TileEntityLightDetector> implements DaylightDetector {
public class CraftDaylightDetector extends CraftBlockEntityState<DaylightDetectorBlockEntity> implements DaylightDetector {
public CraftDaylightDetector(World world, TileEntityLightDetector tileEntity) {
public CraftDaylightDetector(World world, DaylightDetectorBlockEntity tileEntity) {
super(world, tileEntity);
}

View File

@@ -49,13 +49,13 @@ public class CraftDecoratedPot extends CraftBlockEntityState<DecoratedPotBlockEn
Preconditions.checkArgument(sherd == null || sherd == Material.BRICK || Tag.ITEMS_DECORATED_POT_SHERDS.isTagged(sherd), "sherd is not a valid sherd material: %s", sherd);
Optional<Item> sherdItem = (sherd != null) ? Optional.of(CraftItemType.bukkitToMinecraft(sherd)) : Optional.of(Items.BRICK);
PotDecorations decorations = getSnapshot().getDecorations();
PotDecorations decorations = this.getSnapshot().getDecorations();
switch (face) {
case BACK -> getSnapshot().decorations = new PotDecorations(sherdItem, decorations.left(), decorations.right(), decorations.front());
case LEFT -> getSnapshot().decorations = new PotDecorations(decorations.back(), sherdItem, decorations.right(), decorations.front());
case RIGHT -> getSnapshot().decorations = new PotDecorations(decorations.back(), decorations.left(), sherdItem, decorations.front());
case FRONT -> getSnapshot().decorations = new PotDecorations(decorations.back(), decorations.left(), decorations.right(), sherdItem);
case BACK -> this.getSnapshot().decorations = new PotDecorations(sherdItem, decorations.left(), decorations.right(), decorations.front());
case LEFT -> this.getSnapshot().decorations = new PotDecorations(decorations.back(), sherdItem, decorations.right(), decorations.front());
case RIGHT -> this.getSnapshot().decorations = new PotDecorations(decorations.back(), decorations.left(), sherdItem, decorations.front());
case FRONT -> this.getSnapshot().decorations = new PotDecorations(decorations.back(), decorations.left(), decorations.right(), sherdItem);
default -> throw new IllegalArgumentException("Unexpected value: " + face);
}
}
@@ -64,7 +64,7 @@ public class CraftDecoratedPot extends CraftBlockEntityState<DecoratedPotBlockEn
public Material getSherd(Side face) {
Preconditions.checkArgument(face != null, "face must not be null");
PotDecorations decorations = getSnapshot().getDecorations();
PotDecorations decorations = this.getSnapshot().getDecorations();
Optional<Item> sherdItem = switch (face) {
case BACK -> decorations.back();
case LEFT -> decorations.left();
@@ -78,7 +78,7 @@ public class CraftDecoratedPot extends CraftBlockEntityState<DecoratedPotBlockEn
@Override
public Map<Side, Material> getSherds() {
PotDecorations decorations = getSnapshot().getDecorations();
PotDecorations decorations = this.getSnapshot().getDecorations();
Map<Side, Material> sherds = new EnumMap<>(Side.class);
sherds.put(Side.BACK, CraftItemType.minecraftToBukkit(decorations.back().orElse(Items.BRICK)));
@@ -90,7 +90,7 @@ public class CraftDecoratedPot extends CraftBlockEntityState<DecoratedPotBlockEn
@Override
public List<Material> getShards() {
return getSnapshot().getDecorations().ordered().stream().map(CraftItemType::minecraftToBukkit).collect(Collectors.toUnmodifiableList());
return this.getSnapshot().getDecorations().ordered().stream().map(CraftItemType::minecraftToBukkit).collect(Collectors.toUnmodifiableList());
}
@Override

View File

@@ -1,8 +1,8 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.BlockDispenser;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.TileEntityDispenser;
import net.minecraft.world.level.block.DispenserBlock;
import net.minecraft.world.level.block.entity.DispenserBlockEntity;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
@@ -14,9 +14,9 @@ import org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource;
import org.bukkit.inventory.Inventory;
import org.bukkit.projectiles.BlockProjectileSource;
public class CraftDispenser extends CraftLootable<TileEntityDispenser> implements Dispenser {
public class CraftDispenser extends CraftLootable<DispenserBlockEntity> implements Dispenser {
public CraftDispenser(World world, TileEntityDispenser tileEntity) {
public CraftDispenser(World world, DispenserBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -40,22 +40,22 @@ public class CraftDispenser extends CraftLootable<TileEntityDispenser> implement
@Override
public BlockProjectileSource getBlockProjectileSource() {
Block block = getBlock();
Block block = this.getBlock();
if (block.getType() != Material.DISPENSER) {
return null;
}
return new CraftBlockProjectileSource((TileEntityDispenser) this.getTileEntityFromWorld());
return new CraftBlockProjectileSource((DispenserBlockEntity) this.getTileEntityFromWorld());
}
@Override
public boolean dispense() {
ensureNoWorldGeneration();
Block block = getBlock();
this.ensureNoWorldGeneration();
Block block = this.getBlock();
if (block.getType() == Material.DISPENSER) {
CraftWorld world = (CraftWorld) this.getWorld();
BlockDispenser dispense = (BlockDispenser) Blocks.DISPENSER;
DispenserBlock dispense = (DispenserBlock) Blocks.DISPENSER;
dispense.dispenseFrom(world.getHandle(), this.getHandle(), this.getPosition());
return true;

View File

@@ -1,8 +1,8 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.BlockDropper;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.TileEntityDropper;
import net.minecraft.world.level.block.DropperBlock;
import net.minecraft.world.level.block.entity.DropperBlockEntity;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
@@ -12,9 +12,9 @@ import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.inventory.Inventory;
public class CraftDropper extends CraftLootable<TileEntityDropper> implements Dropper {
public class CraftDropper extends CraftLootable<DropperBlockEntity> implements Dropper {
public CraftDropper(World world, TileEntityDropper tileEntity) {
public CraftDropper(World world, DropperBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -38,11 +38,11 @@ public class CraftDropper extends CraftLootable<TileEntityDropper> implements Dr
@Override
public void drop() {
ensureNoWorldGeneration();
Block block = getBlock();
this.ensureNoWorldGeneration();
Block block = this.getBlock();
if (block.getType() == Material.DROPPER) {
CraftWorld world = (CraftWorld) this.getWorld();
BlockDropper drop = (BlockDropper) Blocks.DROPPER;
DropperBlock drop = (DropperBlock) Blocks.DROPPER;
drop.dispenseFrom(world.getHandle(), this.getHandle(), this.getPosition());
}

View File

@@ -1,14 +1,14 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.TileEntityEnchantTable;
import net.minecraft.world.level.block.entity.EnchantingTableBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.EnchantingTable;
import org.bukkit.craftbukkit.util.CraftChatMessage;
public class CraftEnchantingTable extends CraftBlockEntityState<TileEntityEnchantTable> implements EnchantingTable {
public class CraftEnchantingTable extends CraftBlockEntityState<EnchantingTableBlockEntity> implements EnchantingTable {
public CraftEnchantingTable(World world, TileEntityEnchantTable tileEntity) {
public CraftEnchantingTable(World world, EnchantingTableBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -18,7 +18,7 @@ public class CraftEnchantingTable extends CraftBlockEntityState<TileEntityEnchan
@Override
public String getCustomName() {
TileEntityEnchantTable enchant = this.getSnapshot();
EnchantingTableBlockEntity enchant = this.getSnapshot();
return enchant.hasCustomName() ? CraftChatMessage.fromComponent(enchant.getCustomName()) : null;
}
@@ -28,7 +28,7 @@ public class CraftEnchantingTable extends CraftBlockEntityState<TileEntityEnchan
}
@Override
public void applyTo(TileEntityEnchantTable enchantingTable) {
public void applyTo(EnchantingTableBlockEntity enchantingTable) {
super.applyTo(enchantingTable);
if (!this.getSnapshot().hasCustomName()) {

View File

@@ -1,16 +1,16 @@
package org.bukkit.craftbukkit.block;
import java.util.Objects;
import net.minecraft.core.BlockPosition;
import net.minecraft.world.level.block.entity.TileEntityEndGateway;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.EndGateway;
import org.bukkit.craftbukkit.util.CraftLocation;
public class CraftEndGateway extends CraftBlockEntityState<TileEntityEndGateway> implements EndGateway {
public class CraftEndGateway extends CraftBlockEntityState<TheEndGatewayBlockEntity> implements EndGateway {
public CraftEndGateway(World world, TileEntityEndGateway tileEntity) {
public CraftEndGateway(World world, TheEndGatewayBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -20,7 +20,7 @@ public class CraftEndGateway extends CraftBlockEntityState<TileEntityEndGateway>
@Override
public Location getExitLocation() {
BlockPosition pos = this.getSnapshot().exitPortal;
BlockPos pos = this.getSnapshot().exitPortal;
return pos == null ? null : CraftLocation.toBukkit(pos, this.isPlaced() ? this.getWorld() : null);
}
@@ -56,7 +56,7 @@ public class CraftEndGateway extends CraftBlockEntityState<TileEntityEndGateway>
}
@Override
public void applyTo(TileEntityEndGateway endGateway) {
public void applyTo(TheEndGatewayBlockEntity endGateway) {
super.applyTo(endGateway);
if (this.getSnapshot().exitPortal == null) {

View File

@@ -1,12 +1,12 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.TileEntityEnderPortal;
import net.minecraft.world.level.block.entity.TheEndPortalBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
public class CraftEndPortal extends CraftBlockEntityState<TileEntityEnderPortal> {
public class CraftEndPortal extends CraftBlockEntityState<TheEndPortalBlockEntity> {
public CraftEndPortal(World world, TileEntityEnderPortal tileEntity) {
public CraftEndPortal(World world, TheEndPortalBlockEntity tileEntity) {
super(world, tileEntity);
}

View File

@@ -1,14 +1,14 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.TileEntityEnderChest;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.EnderChest;
public class CraftEnderChest extends CraftBlockEntityState<TileEntityEnderChest> implements EnderChest {
public class CraftEnderChest extends CraftBlockEntityState<EnderChestBlockEntity> implements EnderChest {
public CraftEnderChest(World world, TileEntityEnderChest tileEntity) {
public CraftEnderChest(World world, EnderChestBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -18,28 +18,28 @@ public class CraftEnderChest extends CraftBlockEntityState<TileEntityEnderChest>
@Override
public void open() {
requirePlaced();
if (!getTileEntity().openersCounter.opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
IBlockData block = getTileEntity().getBlockState();
int openCount = getTileEntity().openersCounter.getOpenerCount();
this.requirePlaced();
if (!this.getTileEntity().openersCounter.opened && this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
BlockState block = this.getTileEntity().getBlockState();
int openCount = this.getTileEntity().openersCounter.getOpenerCount();
getTileEntity().openersCounter.onAPIOpen((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block);
getTileEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block, openCount, openCount + 1);
this.getTileEntity().openersCounter.onAPIOpen((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block);
this.getTileEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block, openCount, openCount + 1);
}
getTileEntity().openersCounter.opened = true;
this.getTileEntity().openersCounter.opened = true;
}
@Override
public void close() {
requirePlaced();
if (getTileEntity().openersCounter.opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
IBlockData block = getTileEntity().getBlockState();
int openCount = getTileEntity().openersCounter.getOpenerCount();
this.requirePlaced();
if (this.getTileEntity().openersCounter.opened && this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
BlockState block = this.getTileEntity().getBlockState();
int openCount = this.getTileEntity().openersCounter.getOpenerCount();
getTileEntity().openersCounter.onAPIClose((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block);
getTileEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.World) getWorldHandle(), getPosition(), block, openCount, 0);
this.getTileEntity().openersCounter.onAPIClose((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block);
this.getTileEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block, openCount, 0);
}
getTileEntity().openersCounter.opened = false;
this.getTileEntity().openersCounter.opened = false;
}
@Override

View File

@@ -2,8 +2,8 @@ package org.bukkit.craftbukkit.block;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import net.minecraft.world.level.block.BlockFurnace;
import net.minecraft.world.level.block.entity.TileEntityFurnace;
import net.minecraft.world.level.block.AbstractFurnaceBlock;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@@ -14,7 +14,7 @@ import org.bukkit.inventory.CookingRecipe;
import org.bukkit.inventory.FurnaceInventory;
import org.bukkit.inventory.Recipe;
public abstract class CraftFurnace<T extends TileEntityFurnace> extends CraftContainer<T> implements Furnace {
public abstract class CraftFurnace<T extends AbstractFurnaceBlockEntity> extends CraftContainer<T> implements Furnace {
public CraftFurnace(World world, T tileEntity) {
super(world, tileEntity);
@@ -47,7 +47,7 @@ public abstract class CraftFurnace<T extends TileEntityFurnace> extends CraftCon
public void setBurnTime(short burnTime) {
this.getSnapshot().litTimeRemaining = burnTime;
// SPIGOT-844: Allow lighting and relighting using this API
this.data = this.data.setValue(BlockFurnace.LIT, burnTime > 0);
this.data = this.data.setValue(AbstractFurnaceBlock.LIT, burnTime > 0);
}
@Override

View File

@@ -1,12 +1,12 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.TileEntityFurnaceFurnace;
import net.minecraft.world.level.block.entity.FurnaceBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
public class CraftFurnaceFurnace extends CraftFurnace<TileEntityFurnaceFurnace> {
public class CraftFurnaceFurnace extends CraftFurnace<FurnaceBlockEntity> {
public CraftFurnaceFurnace(World world, TileEntityFurnaceFurnace tileEntity) {
public CraftFurnaceFurnace(World world, FurnaceBlockEntity tileEntity) {
super(world, tileEntity);
}

View File

@@ -1,15 +1,15 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.TileEntityHopper;
import net.minecraft.world.level.block.entity.HopperBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Hopper;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.inventory.Inventory;
public class CraftHopper extends CraftLootable<TileEntityHopper> implements Hopper {
public class CraftHopper extends CraftLootable<HopperBlockEntity> implements Hopper {
public CraftHopper(World world, TileEntityHopper tileEntity) {
public CraftHopper(World world, HopperBlockEntity tileEntity) {
super(world, tileEntity);
}

View File

@@ -1,13 +1,13 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.TileEntityJigsaw;
import net.minecraft.world.level.block.entity.JigsawBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Jigsaw;
public class CraftJigsaw extends CraftBlockEntityState<TileEntityJigsaw> implements Jigsaw {
public class CraftJigsaw extends CraftBlockEntityState<JigsawBlockEntity> implements Jigsaw {
public CraftJigsaw(World world, TileEntityJigsaw tileEntity) {
public CraftJigsaw(World world, JigsawBlockEntity tileEntity) {
super(world, tileEntity);
}

View File

@@ -1,9 +1,9 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.BlockJukeBox;
import net.minecraft.world.level.block.entity.TileEntity;
import net.minecraft.world.level.block.entity.TileEntityJukeBox;
import net.minecraft.world.level.block.JukeboxBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.JukeboxBlockEntity;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
@@ -13,9 +13,9 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.inventory.CraftItemType;
import org.bukkit.inventory.JukeboxInventory;
public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> implements Jukebox {
public class CraftJukebox extends CraftBlockEntityState<JukeboxBlockEntity> implements Jukebox {
public CraftJukebox(World world, TileEntityJukeBox tileEntity) {
public CraftJukebox(World world, JukeboxBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -42,10 +42,10 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
boolean result = super.update(force, applyPhysics);
if (result && this.isPlaced() && this.getType() == Material.JUKEBOX) {
getWorldHandle().setBlock(this.getPosition(), data, 3);
this.getWorldHandle().setBlock(this.getPosition(), this.data, 3);
TileEntity tileEntity = this.getTileEntityFromWorld();
if (tileEntity instanceof TileEntityJukeBox jukebox) {
BlockEntity tileEntity = this.getTileEntityFromWorld();
if (tileEntity instanceof JukeboxBlockEntity jukebox) {
jukebox.setTheItem(jukebox.getTheItem());
}
}
@@ -55,7 +55,7 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
@Override
public Material getPlaying() {
return getRecord().getType();
return this.getRecord().getType();
}
@Override
@@ -64,12 +64,12 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
record = Material.AIR;
}
setRecord(new org.bukkit.inventory.ItemStack(record));
this.setRecord(new org.bukkit.inventory.ItemStack(record));
}
@Override
public boolean hasRecord() {
return getHandle().getValue(BlockJukeBox.HAS_RECORD) && !getPlaying().isAir();
return this.getHandle().getValue(JukeboxBlock.HAS_RECORD) && !this.getPlaying().isAir();
}
@Override
@@ -82,31 +82,31 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
public void setRecord(org.bukkit.inventory.ItemStack record) {
ItemStack nms = CraftItemStack.asNMSCopy(record);
TileEntityJukeBox snapshot = this.getSnapshot();
JukeboxBlockEntity snapshot = this.getSnapshot();
snapshot.setSongItemWithoutPlaying(nms, snapshot.getSongPlayer().getTicksSinceSongStarted());
this.data = this.data.setValue(BlockJukeBox.HAS_RECORD, !nms.isEmpty());
this.data = this.data.setValue(JukeboxBlock.HAS_RECORD, !nms.isEmpty());
}
@Override
public boolean isPlaying() {
requirePlaced();
this.requirePlaced();
TileEntity tileEntity = this.getTileEntityFromWorld();
return tileEntity instanceof TileEntityJukeBox jukebox && jukebox.getSongPlayer().isPlaying();
BlockEntity tileEntity = this.getTileEntityFromWorld();
return tileEntity instanceof JukeboxBlockEntity jukebox && jukebox.getSongPlayer().isPlaying();
}
@Override
public boolean startPlaying() {
requirePlaced();
this.requirePlaced();
TileEntity tileEntity = this.getTileEntityFromWorld();
if (!(tileEntity instanceof TileEntityJukeBox jukebox)) {
BlockEntity tileEntity = this.getTileEntityFromWorld();
if (!(tileEntity instanceof JukeboxBlockEntity jukebox)) {
return false;
}
ItemStack record = jukebox.getTheItem();
if (record.isEmpty() || isPlaying()) {
if (record.isEmpty() || this.isPlaying()) {
return false;
}
@@ -116,10 +116,10 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
@Override
public void stopPlaying() {
requirePlaced();
this.requirePlaced();
TileEntity tileEntity = this.getTileEntityFromWorld();
if (!(tileEntity instanceof TileEntityJukeBox jukebox)) {
BlockEntity tileEntity = this.getTileEntityFromWorld();
if (!(tileEntity instanceof JukeboxBlockEntity jukebox)) {
return;
}
@@ -128,12 +128,12 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
@Override
public boolean eject() {
ensureNoWorldGeneration();
this.ensureNoWorldGeneration();
TileEntity tileEntity = this.getTileEntityFromWorld();
if (!(tileEntity instanceof TileEntityJukeBox)) return false;
BlockEntity tileEntity = this.getTileEntityFromWorld();
if (!(tileEntity instanceof JukeboxBlockEntity)) return false;
TileEntityJukeBox jukebox = (TileEntityJukeBox) tileEntity;
JukeboxBlockEntity jukebox = (JukeboxBlockEntity) tileEntity;
boolean result = !jukebox.getTheItem().isEmpty();
jukebox.popOutTheItem();
return result;

View File

@@ -1,7 +1,7 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.BlockLectern;
import net.minecraft.world.level.block.entity.TileEntityLectern;
import net.minecraft.world.level.block.LecternBlock;
import net.minecraft.world.level.block.entity.LecternBlockEntity;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
@@ -9,9 +9,9 @@ import org.bukkit.block.Lectern;
import org.bukkit.craftbukkit.inventory.CraftInventoryLectern;
import org.bukkit.inventory.Inventory;
public class CraftLectern extends CraftBlockEntityState<TileEntityLectern> implements Lectern {
public class CraftLectern extends CraftBlockEntityState<LecternBlockEntity> implements Lectern {
public CraftLectern(World world, TileEntityLectern tileEntity) {
public CraftLectern(World world, LecternBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -21,12 +21,12 @@ public class CraftLectern extends CraftBlockEntityState<TileEntityLectern> imple
@Override
public int getPage() {
return getSnapshot().getPage();
return this.getSnapshot().getPage();
}
@Override
public void setPage(int page) {
getSnapshot().setPage(page);
this.getSnapshot().setPage(page);
}
@Override
@@ -47,8 +47,8 @@ public class CraftLectern extends CraftBlockEntityState<TileEntityLectern> imple
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result && this.getType() == Material.LECTERN && getWorldHandle() instanceof net.minecraft.world.level.World) {
BlockLectern.signalPageChange(this.world.getHandle(), this.getPosition(), this.getHandle());
if (result && this.getType() == Material.LECTERN && this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
LecternBlock.signalPageChange(this.world.getHandle(), this.getPosition(), this.getHandle());
}
return result;

View File

@@ -1,6 +1,6 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.TileEntityLootable;
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
import org.bukkit.Location;
import org.bukkit.Nameable;
import org.bukkit.World;
@@ -8,7 +8,7 @@ import org.bukkit.craftbukkit.CraftLootTable;
import org.bukkit.loot.LootTable;
import org.bukkit.loot.Lootable;
public abstract class CraftLootable<T extends TileEntityLootable> extends CraftContainer<T> implements Nameable, Lootable {
public abstract class CraftLootable<T extends RandomizableContainerBlockEntity> extends CraftContainer<T> implements Nameable, Lootable {
public CraftLootable(World world, T tileEntity) {
super(world, tileEntity);
@@ -29,26 +29,26 @@ public abstract class CraftLootable<T extends TileEntityLootable> extends CraftC
@Override
public LootTable getLootTable() {
return CraftLootTable.minecraftToBukkit(getSnapshot().lootTable);
return CraftLootTable.minecraftToBukkit(this.getSnapshot().lootTable);
}
@Override
public void setLootTable(LootTable table) {
setLootTable(table, getSeed());
this.setLootTable(table, this.getSeed());
}
@Override
public long getSeed() {
return getSnapshot().lootTableSeed;
return this.getSnapshot().lootTableSeed;
}
@Override
public void setSeed(long seed) {
setLootTable(getLootTable(), seed);
this.setLootTable(this.getLootTable(), seed);
}
private void setLootTable(LootTable table, long seed) {
getSnapshot().setLootTable(CraftLootTable.bukkitToMinecraft(table), seed);
public void setLootTable(LootTable table, long seed) {
this.getSnapshot().setLootTable(CraftLootTable.bukkitToMinecraft(table), seed);
}
@Override

View File

@@ -1,12 +1,12 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.piston.TileEntityPiston;
import net.minecraft.world.level.block.piston.PistonMovingBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
public class CraftMovingPiston extends CraftBlockEntityState<TileEntityPiston> {
public class CraftMovingPiston extends CraftBlockEntityState<PistonMovingBlockEntity> {
public CraftMovingPiston(World world, TileEntityPiston tileEntity) {
public CraftMovingPiston(World world, PistonMovingBlockEntity tileEntity) {
super(world, tileEntity);
}

View File

@@ -1,7 +1,7 @@
package org.bukkit.craftbukkit.block;
import com.google.common.base.Preconditions;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.SculkCatalystBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
@@ -22,11 +22,11 @@ public class CraftSculkCatalyst extends CraftBlockEntityState<SculkCatalystBlock
public void bloom(Block block, int charge) {
Preconditions.checkArgument(block != null, "block cannot be null");
Preconditions.checkArgument(charge > 0, "charge must be positive");
requirePlaced();
this.requirePlaced();
// bloom() is for visual blooming effect, cursors are what changes the blocks.
getTileEntity().getListener().bloom(world.getHandle(), getPosition(), getHandle(), world.getHandle().getRandom());
getTileEntity().getListener().getSculkSpreader().addCursors(new BlockPosition(block.getX(), block.getY(), block.getZ()), charge);
this.getTileEntity().getListener().bloom(this.world.getHandle(), this.getPosition(), this.getHandle(), this.world.getHandle().getRandom());
this.getTileEntity().getListener().getSculkSpreader().addCursors(new BlockPos(block.getX(), block.getY(), block.getZ()), charge);
}
@Override

View File

@@ -18,13 +18,13 @@ public class CraftSculkSensor<T extends SculkSensorBlockEntity> extends CraftBlo
@Override
public int getLastVibrationFrequency() {
return getSnapshot().getLastVibrationFrequency();
return this.getSnapshot().getLastVibrationFrequency();
}
@Override
public void setLastVibrationFrequency(int lastVibrationFrequency) {
Preconditions.checkArgument(0 <= lastVibrationFrequency && lastVibrationFrequency <= 15, "Vibration frequency must be between 0-15");
getSnapshot().lastVibrationFrequency = lastVibrationFrequency;
this.getSnapshot().lastVibrationFrequency = lastVibrationFrequency;
}
@Override

View File

@@ -1,6 +1,6 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.level.EntityPlayer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.block.entity.SculkShriekerBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
@@ -20,20 +20,20 @@ public class CraftSculkShrieker extends CraftBlockEntityState<SculkShriekerBlock
@Override
public int getWarningLevel() {
return getSnapshot().warningLevel;
return this.getSnapshot().warningLevel;
}
@Override
public void setWarningLevel(int level) {
getSnapshot().warningLevel = level;
this.getSnapshot().warningLevel = level;
}
@Override
public void tryShriek(Player player) {
requirePlaced();
this.requirePlaced();
EntityPlayer entityPlayer = (player == null) ? null : ((CraftPlayer) player).getHandle();
getTileEntity().tryShriek(world.getHandle(), entityPlayer);
ServerPlayer entityPlayer = (player == null) ? null : ((CraftPlayer) player).getHandle();
this.getTileEntity().tryShriek(this.world.getHandle(), entityPlayer);
}
@Override

View File

@@ -1,10 +1,9 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.sounds.SoundCategory;
import net.minecraft.sounds.SoundEffects;
import net.minecraft.world.item.EnumColor;
import net.minecraft.world.level.block.BlockShulkerBox;
import net.minecraft.world.level.block.entity.TileEntityShulkerBox;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.level.block.ShulkerBoxBlock;
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.World;
@@ -12,9 +11,9 @@ import org.bukkit.block.ShulkerBox;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.inventory.Inventory;
public class CraftShulkerBox extends CraftLootable<TileEntityShulkerBox> implements ShulkerBox {
public class CraftShulkerBox extends CraftLootable<ShulkerBoxBlockEntity> implements ShulkerBox {
public CraftShulkerBox(World world, TileEntityShulkerBox tileEntity) {
public CraftShulkerBox(World world, ShulkerBoxBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -38,31 +37,31 @@ public class CraftShulkerBox extends CraftLootable<TileEntityShulkerBox> impleme
@Override
public DyeColor getColor() {
EnumColor color = ((BlockShulkerBox) CraftBlockType.bukkitToMinecraft(this.getType())).color;
net.minecraft.world.item.DyeColor color = ((ShulkerBoxBlock) CraftBlockType.bukkitToMinecraft(this.getType())).color;
return (color == null) ? null : DyeColor.getByWoolData((byte) color.getId());
}
@Override
public void open() {
requirePlaced();
if (!getTileEntity().opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
net.minecraft.world.level.World world = getTileEntity().getLevel();
world.blockEvent(getPosition(), getTileEntity().getBlockState().getBlock(), 1, 1);
world.playSound(null, getPosition(), SoundEffects.SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
this.requirePlaced();
if (!this.getTileEntity().opened && this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
net.minecraft.world.level.Level world = this.getTileEntity().getLevel();
world.blockEvent(this.getPosition(), this.getTileEntity().getBlockState().getBlock(), 1, 1);
world.playSound(null, this.getPosition(), SoundEvents.SHULKER_BOX_OPEN, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
}
getTileEntity().opened = true;
this.getTileEntity().opened = true;
}
@Override
public void close() {
requirePlaced();
if (getTileEntity().opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
net.minecraft.world.level.World world = getTileEntity().getLevel();
world.blockEvent(getPosition(), getTileEntity().getBlockState().getBlock(), 1, 0);
world.playSound(null, getPosition(), SoundEffects.SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
this.requirePlaced();
if (this.getTileEntity().opened && this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
net.minecraft.world.level.Level world = this.getTileEntity().getLevel();
world.blockEvent(this.getPosition(), this.getTileEntity().getBlockState().getBlock(), 1, 0);
world.playSound(null, this.getPosition(), SoundEvents.SHULKER_BOX_OPEN, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
}
getTileEntity().opened = false;
this.getTileEntity().opened = false;
}
@Override

View File

@@ -2,8 +2,8 @@ package org.bukkit.craftbukkit.block;
import com.google.common.base.Preconditions;
import java.util.UUID;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.world.level.block.entity.TileEntitySign;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.block.entity.SignBlockEntity;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
@@ -19,7 +19,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerSignOpenEvent;
import org.jetbrains.annotations.NotNull;
public class CraftSign<T extends TileEntitySign> extends CraftBlockEntityState<T> implements Sign {
public class CraftSign<T extends SignBlockEntity> extends CraftBlockEntityState<T> implements Sign {
private final CraftSignSide front;
private final CraftSignSide back;
@@ -38,22 +38,22 @@ public class CraftSign<T extends TileEntitySign> extends CraftBlockEntityState<T
@Override
public String[] getLines() {
return front.getLines();
return this.front.getLines();
}
@Override
public String getLine(int index) throws IndexOutOfBoundsException {
return front.getLine(index);
return this.front.getLine(index);
}
@Override
public void setLine(int index, String line) throws IndexOutOfBoundsException {
front.setLine(index, line);
this.front.setLine(index, line);
}
@Override
public boolean isEditable() {
return !isWaxed();
return !this.isWaxed();
}
@Override
@@ -63,22 +63,22 @@ public class CraftSign<T extends TileEntitySign> extends CraftBlockEntityState<T
@Override
public boolean isWaxed() {
return getSnapshot().isWaxed();
return this.getSnapshot().isWaxed();
}
@Override
public void setWaxed(boolean waxed) {
getSnapshot().setWaxed(waxed);
this.getSnapshot().setWaxed(waxed);
}
@Override
public boolean isGlowingText() {
return front.isGlowingText();
return this.front.isGlowingText();
}
@Override
public void setGlowingText(boolean glowing) {
front.setGlowingText(glowing);
this.front.setGlowingText(glowing);
}
@NotNull
@@ -88,9 +88,9 @@ public class CraftSign<T extends TileEntitySign> extends CraftBlockEntityState<T
switch (side) {
case FRONT:
return front;
return this.front;
case BACK:
return back;
return this.back;
default:
throw new IllegalArgumentException();
}
@@ -98,39 +98,39 @@ public class CraftSign<T extends TileEntitySign> extends CraftBlockEntityState<T
@Override
public SignSide getTargetSide(Player player) {
ensureNoWorldGeneration();
this.ensureNoWorldGeneration();
Preconditions.checkArgument(player != null, "player cannot be null");
if (getSnapshot().isFacingFrontText(((CraftPlayer) player).getHandle())) {
return front;
if (this.getSnapshot().isFacingFrontText(((CraftPlayer) player).getHandle())) {
return this.front;
}
return back;
return this.back;
}
@Override
public Player getAllowedEditor() {
ensureNoWorldGeneration();
this.ensureNoWorldGeneration();
// getPlayerWhoMayEdit is always null for the snapshot, so we use the wrapped TileEntity
UUID id = getTileEntity().getPlayerWhoMayEdit();
UUID id = this.getTileEntity().getPlayerWhoMayEdit();
return (id == null) ? null : Bukkit.getPlayer(id);
}
@Override
public DyeColor getColor() {
return front.getColor();
return this.front.getColor();
}
@Override
public void setColor(DyeColor color) {
front.setColor(color);
this.front.setColor(color);
}
@Override
public void applyTo(T sign) {
getSnapshot().setText(front.applyLegacyStringToSignSide(), true);
getSnapshot().setText(back.applyLegacyStringToSignSide(), false);
this.getSnapshot().setText(this.front.applyLegacyStringToSignSide(), true);
this.getSnapshot().setText(this.back.applyLegacyStringToSignSide(), false);
super.applyTo(sign);
}
@@ -155,35 +155,35 @@ public class CraftSign<T extends TileEntitySign> extends CraftBlockEntityState<T
return;
}
TileEntitySign handle = ((CraftSign<?>) sign).getTileEntity();
SignBlockEntity handle = ((CraftSign<?>) sign).getTileEntity();
handle.setAllowedPlayerEditor(player.getUniqueId());
((CraftPlayer) player).getHandle().openTextEdit(handle, Side.FRONT == side);
}
public static IChatBaseComponent[] sanitizeLines(String[] lines) {
IChatBaseComponent[] components = new IChatBaseComponent[4];
public static Component[] sanitizeLines(String[] lines) {
Component[] components = new Component[4];
for (int i = 0; i < 4; i++) {
if (i < lines.length && lines[i] != null) {
components[i] = CraftChatMessage.fromString(lines[i])[0];
} else {
components[i] = IChatBaseComponent.empty();
components[i] = Component.empty();
}
}
return components;
}
public static String[] revertComponents(IChatBaseComponent[] components) {
public static String[] revertComponents(Component[] components) {
String[] lines = new String[components.length];
for (int i = 0; i < lines.length; i++) {
lines[i] = revertComponent(components[i]);
lines[i] = CraftSign.revertComponent(components[i]);
}
return lines;
}
private static String revertComponent(IChatBaseComponent component) {
private static String revertComponent(Component component) {
return CraftChatMessage.fromComponent(component);
}
}

View File

@@ -2,11 +2,11 @@ package org.bukkit.craftbukkit.block;
import com.google.common.base.Preconditions;
import com.mojang.authlib.GameProfile;
import net.minecraft.SystemUtils;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.Util;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.item.component.ResolvableProfile;
import net.minecraft.world.level.block.entity.TileEntitySkull;
import net.minecraft.world.level.block.entity.SkullBlockEntity;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
@@ -24,12 +24,12 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.profile.PlayerProfile;
import org.jetbrains.annotations.Nullable;
public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implements Skull {
public class CraftSkull extends CraftBlockEntityState<SkullBlockEntity> implements Skull {
private static final int MAX_OWNER_LENGTH = 16;
private ResolvableProfile profile;
public CraftSkull(World world, TileEntitySkull tileEntity) {
public CraftSkull(World world, SkullBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -38,28 +38,28 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
}
@Override
public void load(TileEntitySkull skull) {
public void load(SkullBlockEntity skull) {
super.load(skull);
ResolvableProfile owner = skull.getOwnerProfile();
if (owner != null) {
profile = owner;
this.profile = owner;
}
}
@Override
public boolean hasOwner() {
return profile != null;
return this.profile != null;
}
@Override
public String getOwner() {
return hasOwner() ? profile.name().orElse(null) : null;
return this.hasOwner() ? this.profile.name().orElse(null) : null;
}
@Override
public boolean setOwner(String name) {
if (name == null || name.length() > MAX_OWNER_LENGTH) {
if (name == null || name.length() > CraftSkull.MAX_OWNER_LENGTH) {
return false;
}
@@ -74,13 +74,13 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
@Override
public OfflinePlayer getOwningPlayer() {
if (hasOwner()) {
if (profile.id().filter(u -> !u.equals(SystemUtils.NIL_UUID)).isPresent()) {
return Bukkit.getOfflinePlayer(profile.id().get());
if (this.hasOwner()) {
if (this.profile.id().filter(u -> !u.equals(Util.NIL_UUID)).isPresent()) {
return Bukkit.getOfflinePlayer(this.profile.id().get());
}
if (profile.name().filter(s -> !s.isEmpty()).isPresent()) {
return Bukkit.getOfflinePlayer(profile.name().get());
if (this.profile.name().filter(s -> !s.isEmpty()).isPresent()) {
return Bukkit.getOfflinePlayer(this.profile.name().get());
}
}
@@ -100,11 +100,11 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
@Override
public PlayerProfile getOwnerProfile() {
if (!hasOwner()) {
if (!this.hasOwner()) {
return null;
}
return new CraftPlayerProfile(profile);
return new CraftPlayerProfile(this.profile);
}
@Override
@@ -118,7 +118,7 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
@Override
public NamespacedKey getNoteBlockSound() {
MinecraftKey key = getSnapshot().getNoteBlockSound();
ResourceLocation key = this.getSnapshot().getNoteBlockSound();
return (key != null) ? CraftNamespacedKey.fromMinecraft(key) : null;
}
@@ -133,24 +133,24 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
@Override
public BlockFace getRotation() {
BlockData blockData = getBlockData();
BlockData blockData = this.getBlockData();
return (blockData instanceof Rotatable rotatable) ? rotatable.getRotation() : ((Directional) blockData).getFacing();
}
@Override
public void setRotation(BlockFace rotation) {
BlockData blockData = getBlockData();
BlockData blockData = this.getBlockData();
if (blockData instanceof Rotatable) {
((Rotatable) blockData).setRotation(rotation);
} else {
((Directional) blockData).setFacing(rotation);
}
setBlockData(blockData);
this.setBlockData(blockData);
}
@Override
public SkullType getSkullType() {
switch (getType()) {
switch (this.getType()) {
case SKELETON_SKULL:
case SKELETON_WALL_SKULL:
return SkullType.SKELETON;
@@ -173,7 +173,7 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
case DRAGON_WALL_HEAD:
return SkullType.DRAGON;
default:
throw new IllegalArgumentException("Unknown SkullType for " + getType());
throw new IllegalArgumentException("Unknown SkullType for " + this.getType());
}
}
@@ -183,11 +183,11 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
}
@Override
public void applyTo(TileEntitySkull skull) {
public void applyTo(SkullBlockEntity skull) {
super.applyTo(skull);
if (getSkullType() == SkullType.PLAYER) {
skull.setOwner(hasOwner() ? profile : null);
if (this.getSkullType() == SkullType.PLAYER) {
skull.setOwner(this.hasOwner() ? this.profile : null);
}
}

View File

@@ -1,13 +1,13 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.TileEntitySmoker;
import net.minecraft.world.level.block.entity.SmokerBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Smoker;
public class CraftSmoker extends CraftFurnace<TileEntitySmoker> implements Smoker {
public class CraftSmoker extends CraftFurnace<SmokerBlockEntity> implements Smoker {
public CraftSmoker(World world, TileEntitySmoker tileEntity) {
public CraftSmoker(World world, SmokerBlockEntity tileEntity) {
super(world, tileEntity);
}

View File

@@ -1,10 +1,9 @@
package org.bukkit.craftbukkit.block;
import com.google.common.base.Preconditions;
import net.minecraft.world.level.block.EnumBlockMirror;
import net.minecraft.world.level.block.EnumBlockRotation;
import net.minecraft.world.level.block.entity.TileEntityStructure;
import net.minecraft.world.level.block.state.properties.BlockPropertyStructureMode;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.entity.StructureBlockEntity;
import net.minecraft.world.level.block.state.properties.StructureMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Structure;
@@ -16,11 +15,11 @@ import org.bukkit.craftbukkit.util.CraftBlockVector;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.BlockVector;
public class CraftStructureBlock extends CraftBlockEntityState<TileEntityStructure> implements Structure {
public class CraftStructureBlock extends CraftBlockEntityState<StructureBlockEntity> implements Structure {
private static final int MAX_SIZE = 48;
public CraftStructureBlock(World world, TileEntityStructure tileEntity) {
public CraftStructureBlock(World world, StructureBlockEntity tileEntity) {
super(world, tileEntity);
}
@@ -30,170 +29,170 @@ public class CraftStructureBlock extends CraftBlockEntityState<TileEntityStructu
@Override
public String getStructureName() {
return getSnapshot().getStructureName();
return this.getSnapshot().getStructureName();
}
@Override
public void setStructureName(String name) {
Preconditions.checkArgument(name != null, "Structure name cannot be null");
getSnapshot().setStructureName(name);
this.getSnapshot().setStructureName(name);
}
@Override
public String getAuthor() {
return getSnapshot().author;
return this.getSnapshot().author;
}
@Override
public void setAuthor(String author) {
Preconditions.checkArgument(author != null, "Author name cannot be null");
Preconditions.checkArgument(!author.isEmpty(), "Author name cannot be empty");
getSnapshot().author = author;
this.getSnapshot().author = author;
}
@Override
public void setAuthor(LivingEntity entity) {
Preconditions.checkArgument(entity != null, "Structure Block author entity cannot be null");
getSnapshot().createdBy(((CraftLivingEntity) entity).getHandle());
this.getSnapshot().createdBy(((CraftLivingEntity) entity).getHandle());
}
@Override
public BlockVector getRelativePosition() {
return CraftBlockVector.toBukkit(getSnapshot().structurePos);
return CraftBlockVector.toBukkit(this.getSnapshot().structurePos);
}
@Override
public void setRelativePosition(BlockVector vector) {
Preconditions.checkArgument(isBetween(vector.getBlockX(), -MAX_SIZE, MAX_SIZE), "Structure Size (X) must be between -%s and %s but got %s", MAX_SIZE, MAX_SIZE, vector.getBlockX());
Preconditions.checkArgument(isBetween(vector.getBlockY(), -MAX_SIZE, MAX_SIZE), "Structure Size (Y) must be between -%s and %s but got %s", MAX_SIZE, MAX_SIZE, vector.getBlockY());
Preconditions.checkArgument(isBetween(vector.getBlockZ(), -MAX_SIZE, MAX_SIZE), "Structure Size (Z) must be between -%s and %s but got %s", MAX_SIZE, MAX_SIZE, vector.getBlockZ());
getSnapshot().structurePos = CraftBlockVector.toBlockPosition(vector);
Preconditions.checkArgument(CraftStructureBlock.isBetween(vector.getBlockX(), -CraftStructureBlock.MAX_SIZE, CraftStructureBlock.MAX_SIZE), "Structure Size (X) must be between -%s and %s but got %s", CraftStructureBlock.MAX_SIZE, CraftStructureBlock.MAX_SIZE, vector.getBlockX());
Preconditions.checkArgument(CraftStructureBlock.isBetween(vector.getBlockY(), -CraftStructureBlock.MAX_SIZE, CraftStructureBlock.MAX_SIZE), "Structure Size (Y) must be between -%s and %s but got %s", CraftStructureBlock.MAX_SIZE, CraftStructureBlock.MAX_SIZE, vector.getBlockY());
Preconditions.checkArgument(CraftStructureBlock.isBetween(vector.getBlockZ(), -CraftStructureBlock.MAX_SIZE, CraftStructureBlock.MAX_SIZE), "Structure Size (Z) must be between -%s and %s but got %s", CraftStructureBlock.MAX_SIZE, CraftStructureBlock.MAX_SIZE, vector.getBlockZ());
this.getSnapshot().structurePos = CraftBlockVector.toBlockPosition(vector);
}
@Override
public BlockVector getStructureSize() {
return CraftBlockVector.toBukkit(getSnapshot().structureSize);
return CraftBlockVector.toBukkit(this.getSnapshot().structureSize);
}
@Override
public void setStructureSize(BlockVector vector) {
Preconditions.checkArgument(isBetween(vector.getBlockX(), 0, MAX_SIZE), "Structure Size (X) must be between %s and %s but got %s", 0, MAX_SIZE, vector.getBlockX());
Preconditions.checkArgument(isBetween(vector.getBlockY(), 0, MAX_SIZE), "Structure Size (Y) must be between %s and %s but got %s", 0, MAX_SIZE, vector.getBlockY());
Preconditions.checkArgument(isBetween(vector.getBlockZ(), 0, MAX_SIZE), "Structure Size (Z) must be between %s and %s but got %s", 0, MAX_SIZE, vector.getBlockZ());
getSnapshot().structureSize = CraftBlockVector.toBlockPosition(vector);
Preconditions.checkArgument(CraftStructureBlock.isBetween(vector.getBlockX(), 0, CraftStructureBlock.MAX_SIZE), "Structure Size (X) must be between %s and %s but got %s", 0, CraftStructureBlock.MAX_SIZE, vector.getBlockX());
Preconditions.checkArgument(CraftStructureBlock.isBetween(vector.getBlockY(), 0, CraftStructureBlock.MAX_SIZE), "Structure Size (Y) must be between %s and %s but got %s", 0, CraftStructureBlock.MAX_SIZE, vector.getBlockY());
Preconditions.checkArgument(CraftStructureBlock.isBetween(vector.getBlockZ(), 0, CraftStructureBlock.MAX_SIZE), "Structure Size (Z) must be between %s and %s but got %s", 0, CraftStructureBlock.MAX_SIZE, vector.getBlockZ());
this.getSnapshot().structureSize = CraftBlockVector.toBlockPosition(vector);
}
@Override
public void setMirror(Mirror mirror) {
Preconditions.checkArgument(mirror != null, "Mirror cannot be null");
getSnapshot().mirror = EnumBlockMirror.valueOf(mirror.name());
this.getSnapshot().mirror = net.minecraft.world.level.block.Mirror.valueOf(mirror.name());
}
@Override
public Mirror getMirror() {
return Mirror.valueOf(getSnapshot().mirror.name());
return Mirror.valueOf(this.getSnapshot().mirror.name());
}
@Override
public void setRotation(StructureRotation rotation) {
Preconditions.checkArgument(rotation != null, "StructureRotation cannot be null");
getSnapshot().rotation = EnumBlockRotation.valueOf(rotation.name());
this.getSnapshot().rotation = Rotation.valueOf(rotation.name());
}
@Override
public StructureRotation getRotation() {
return StructureRotation.valueOf(getSnapshot().rotation.name());
return StructureRotation.valueOf(this.getSnapshot().rotation.name());
}
@Override
public void setUsageMode(UsageMode mode) {
Preconditions.checkArgument(mode != null, "UsageMode cannot be null");
getSnapshot().mode = BlockPropertyStructureMode.valueOf(mode.name());
this.getSnapshot().mode = StructureMode.valueOf(mode.name());
}
@Override
public UsageMode getUsageMode() {
return UsageMode.valueOf(getSnapshot().getMode().name());
return UsageMode.valueOf(this.getSnapshot().getMode().name());
}
@Override
public void setIgnoreEntities(boolean flag) {
getSnapshot().ignoreEntities = flag;
this.getSnapshot().ignoreEntities = flag;
}
@Override
public boolean isIgnoreEntities() {
return getSnapshot().ignoreEntities;
return this.getSnapshot().ignoreEntities;
}
@Override
public void setShowAir(boolean showAir) {
getSnapshot().showAir = showAir;
this.getSnapshot().showAir = showAir;
}
@Override
public boolean isShowAir() {
return getSnapshot().showAir;
return this.getSnapshot().showAir;
}
@Override
public void setBoundingBoxVisible(boolean showBoundingBox) {
getSnapshot().showBoundingBox = showBoundingBox;
this.getSnapshot().showBoundingBox = showBoundingBox;
}
@Override
public boolean isBoundingBoxVisible() {
return getSnapshot().showBoundingBox;
return this.getSnapshot().showBoundingBox;
}
@Override
public void setIntegrity(float integrity) {
Preconditions.checkArgument(isBetween(integrity, 0.0f, 1.0f), "Integrity must be between 0.0f and 1.0f but got %s", integrity);
getSnapshot().integrity = integrity;
Preconditions.checkArgument(CraftStructureBlock.isBetween(integrity, 0.0f, 1.0f), "Integrity must be between 0.0f and 1.0f but got %s", integrity);
this.getSnapshot().integrity = integrity;
}
@Override
public float getIntegrity() {
return getSnapshot().integrity;
return this.getSnapshot().integrity;
}
@Override
public void setSeed(long seed) {
getSnapshot().seed = seed;
this.getSnapshot().seed = seed;
}
@Override
public long getSeed() {
return getSnapshot().seed;
return this.getSnapshot().seed;
}
@Override
public void setMetadata(String metadata) {
Preconditions.checkArgument(metadata != null, "Structure metadata cannot be null");
if (getUsageMode() == UsageMode.DATA) {
getSnapshot().metaData = metadata;
if (this.getUsageMode() == UsageMode.DATA) {
this.getSnapshot().metaData = metadata;
}
}
@Override
public String getMetadata() {
return getSnapshot().metaData;
return this.getSnapshot().metaData;
}
@Override
protected void applyTo(TileEntityStructure tileEntity) {
protected void applyTo(StructureBlockEntity tileEntity) {
super.applyTo(tileEntity);
net.minecraft.world.level.GeneratorAccess access = getWorldHandle();
net.minecraft.world.level.LevelAccessor access = this.getWorldHandle();
// Ensure block type is correct
if (access instanceof net.minecraft.world.level.World) {
if (access instanceof net.minecraft.world.level.Level) {
tileEntity.setMode(tileEntity.getMode());
} else if (access != null) {
// Custom handle during world generation
// From TileEntityStructure#setUsageMode(BlockPropertyStructureMode)
net.minecraft.world.level.block.state.IBlockData data = access.getBlockState(this.getPosition());
net.minecraft.world.level.block.state.BlockState data = access.getBlockState(this.getPosition());
if (data.is(net.minecraft.world.level.block.Blocks.STRUCTURE_BLOCK)) {
access.setBlock(this.getPosition(), data.setValue(net.minecraft.world.level.block.BlockStructure.MODE, tileEntity.getMode()), 2);
access.setBlock(this.getPosition(), data.setValue(net.minecraft.world.level.block.StructureBlock.MODE, tileEntity.getMode()), 2);
}
}
}

View File

@@ -23,8 +23,8 @@ public class CraftTrialSpawner extends CraftBlockEntityState<TrialSpawnerBlockEn
public CraftTrialSpawner(World world, TrialSpawnerBlockEntity tileEntity) {
super(world, tileEntity);
this.normalConfig = new CraftTrialSpawnerConfiguration(tileEntity.getTrialSpawner().getNormalConfig(), getSnapshot());
this.ominousConfig = new CraftTrialSpawnerConfiguration(tileEntity.getTrialSpawner().getOminousConfig(), getSnapshot());
this.normalConfig = new CraftTrialSpawnerConfiguration(tileEntity.getTrialSpawner().getNormalConfig(), this.getSnapshot());
this.ominousConfig = new CraftTrialSpawnerConfiguration(tileEntity.getTrialSpawner().getOminousConfig(), this.getSnapshot());
}
protected CraftTrialSpawner(CraftTrialSpawner state, Location location) {
@@ -35,29 +35,29 @@ public class CraftTrialSpawner extends CraftBlockEntityState<TrialSpawnerBlockEn
@Override
public int getCooldownLength() {
return getSnapshot().trialSpawner.getTargetCooldownLength();
return this.getSnapshot().trialSpawner.getTargetCooldownLength();
}
@Override
public void setCooldownLength(int ticks) {
getSnapshot().trialSpawner.targetCooldownLength = ticks;
this.getSnapshot().trialSpawner.targetCooldownLength = ticks;
}
@Override
public int getRequiredPlayerRange() {
return getSnapshot().trialSpawner.getRequiredPlayerRange();
return this.getSnapshot().trialSpawner.getRequiredPlayerRange();
}
@Override
public void setRequiredPlayerRange(int requiredPlayerRange) {
getSnapshot().trialSpawner.requiredPlayerRange = requiredPlayerRange;
this.getSnapshot().trialSpawner.requiredPlayerRange = requiredPlayerRange;
}
@Override
public Collection<Player> getTrackedPlayers() {
ImmutableSet.Builder<Player> players = ImmutableSet.builder();
for (UUID uuid : getTrialData().detectedPlayers) {
for (UUID uuid : this.getTrialData().detectedPlayers) {
Player player = Bukkit.getPlayer(uuid);
if (player != null) {
players.add(player);
@@ -70,28 +70,28 @@ public class CraftTrialSpawner extends CraftBlockEntityState<TrialSpawnerBlockEn
public boolean isTrackingPlayer(Player player) {
Preconditions.checkArgument(player != null, "Player cannot be null");
return getTrialData().detectedPlayers.contains(player.getUniqueId());
return this.getTrialData().detectedPlayers.contains(player.getUniqueId());
}
@Override
public void startTrackingPlayer(Player player) {
Preconditions.checkArgument(player != null, "Player cannot be null");
getTrialData().detectedPlayers.add(player.getUniqueId());
this.getTrialData().detectedPlayers.add(player.getUniqueId());
}
@Override
public void stopTrackingPlayer(Player player) {
Preconditions.checkArgument(player != null, "Player cannot be null");
getTrialData().detectedPlayers.remove(player.getUniqueId());
this.getTrialData().detectedPlayers.remove(player.getUniqueId());
}
@Override
public Collection<Entity> getTrackedEntities() {
ImmutableSet.Builder<Entity> entities = ImmutableSet.builder();
for (UUID uuid : getTrialData().currentMobs) {
for (UUID uuid : this.getTrialData().currentMobs) {
Entity entity = Bukkit.getEntity(uuid);
if (entity != null) {
entities.add(entity);
@@ -104,60 +104,60 @@ public class CraftTrialSpawner extends CraftBlockEntityState<TrialSpawnerBlockEn
public boolean isTrackingEntity(Entity entity) {
Preconditions.checkArgument(entity != null, "Entity cannot be null");
return getTrialData().currentMobs.contains(entity.getUniqueId());
return this.getTrialData().currentMobs.contains(entity.getUniqueId());
}
@Override
public void startTrackingEntity(Entity entity) {
Preconditions.checkArgument(entity != null, "Entity cannot be null");
getTrialData().currentMobs.add(entity.getUniqueId());
this.getTrialData().currentMobs.add(entity.getUniqueId());
}
@Override
public void stopTrackingEntity(Entity entity) {
Preconditions.checkArgument(entity != null, "Entity cannot be null");
getTrialData().currentMobs.remove(entity.getUniqueId());
this.getTrialData().currentMobs.remove(entity.getUniqueId());
}
@Override
public boolean isOminous() {
return getHandle().getValue(TrialSpawnerBlock.OMINOUS);
return this.getHandle().getValue(TrialSpawnerBlock.OMINOUS);
}
@Override
public void setOminous(boolean ominous) {
getSnapshot().trialSpawner.isOminous = ominous;
this.getSnapshot().trialSpawner.isOminous = ominous;
if (ominous) {
setData(getHandle().setValue(TrialSpawnerBlock.OMINOUS, true));
this.setData(this.getHandle().setValue(TrialSpawnerBlock.OMINOUS, true));
// TODO: Consider calling TrialSpawnerData#resetAfterBecomingOminous in update(...), but note that method also removes entities
return;
}
setData(getHandle().setValue(TrialSpawnerBlock.OMINOUS, false));
this.setData(this.getHandle().setValue(TrialSpawnerBlock.OMINOUS, false));
}
@Override
public TrialSpawnerConfiguration getNormalConfiguration() {
return normalConfig;
return this.normalConfig;
}
@Override
public TrialSpawnerConfiguration getOminousConfiguration() {
return ominousConfig;
return this.ominousConfig;
}
@Override
protected void applyTo(TrialSpawnerBlockEntity tileEntity) {
super.applyTo(tileEntity);
tileEntity.trialSpawner.normalConfig = Holder.direct(normalConfig.toMinecraft());
tileEntity.trialSpawner.ominousConfig = Holder.direct(ominousConfig.toMinecraft());
tileEntity.trialSpawner.normalConfig = Holder.direct(this.normalConfig.toMinecraft());
tileEntity.trialSpawner.ominousConfig = Holder.direct(this.ominousConfig.toMinecraft());
}
private TrialSpawnerData getTrialData() {
return getSnapshot().getTrialSpawner().getData();
return this.getSnapshot().getTrialSpawner().getData();
}
@Override

View File

@@ -8,12 +8,11 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceKey;
import net.minecraft.util.random.SimpleWeightedRandomList;
import net.minecraft.util.random.WeightedEntry.b;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.level.MobSpawnerData;
import net.minecraft.util.random.WeightedEntry.Wrapper;
import net.minecraft.world.level.SpawnData;
import net.minecraft.world.level.block.entity.TrialSpawnerBlockEntity;
import net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerConfig;
import net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerData;
@@ -36,7 +35,7 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
private float totalMobsAddedPerPlayer;
private float simultaneousMobsAddedPerPlayer;
private int ticksBetweenSpawn;
private SimpleWeightedRandomList<MobSpawnerData> spawnPotentialsDefinition;
private SimpleWeightedRandomList<SpawnData> spawnPotentialsDefinition;
private SimpleWeightedRandomList<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> lootTablesToEject;
private ResourceKey<net.minecraft.world.level.storage.loot.LootTable> itemsToDropWhenOminous;
@@ -56,84 +55,84 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
@Override
public EntityType getSpawnedType() {
if (spawnPotentialsDefinition.isEmpty()) {
if (this.spawnPotentialsDefinition.isEmpty()) {
return null;
}
Optional<EntityTypes<?>> type = EntityTypes.by(spawnPotentialsDefinition.unwrap().get(0).data().getEntityToSpawn());
Optional<net.minecraft.world.entity.EntityType<?>> type = net.minecraft.world.entity.EntityType.by(this.spawnPotentialsDefinition.unwrap().get(0).data().getEntityToSpawn());
return type.map(CraftEntityType::minecraftToBukkit).orElse(null);
}
@Override
public void setSpawnedType(EntityType entityType) {
if (entityType == null) {
getTrialData().nextSpawnData = Optional.empty();
spawnPotentialsDefinition = SimpleWeightedRandomList.empty(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later
this.getTrialData().nextSpawnData = Optional.empty();
this.spawnPotentialsDefinition = SimpleWeightedRandomList.empty(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later
return;
}
Preconditions.checkArgument(entityType != EntityType.UNKNOWN, "Can't spawn EntityType %s from mob spawners!", entityType);
MobSpawnerData data = new MobSpawnerData();
SpawnData data = new SpawnData();
data.getEntityToSpawn().putString("id", BuiltInRegistries.ENTITY_TYPE.getKey(CraftEntityType.bukkitToMinecraft(entityType)).toString());
getTrialData().nextSpawnData = Optional.of(data);
spawnPotentialsDefinition = SimpleWeightedRandomList.single(data);
this.getTrialData().nextSpawnData = Optional.of(data);
this.spawnPotentialsDefinition = SimpleWeightedRandomList.single(data);
}
@Override
public float getBaseSpawnsBeforeCooldown() {
return totalMobs;
return this.totalMobs;
}
@Override
public void setBaseSpawnsBeforeCooldown(float amount) {
totalMobs = amount;
this.totalMobs = amount;
}
@Override
public float getBaseSimultaneousEntities() {
return simultaneousMobs;
return this.simultaneousMobs;
}
@Override
public void setBaseSimultaneousEntities(float amount) {
simultaneousMobs = amount;
this.simultaneousMobs = amount;
}
@Override
public float getAdditionalSpawnsBeforeCooldown() {
return totalMobsAddedPerPlayer;
return this.totalMobsAddedPerPlayer;
}
@Override
public void setAdditionalSpawnsBeforeCooldown(float amount) {
totalMobsAddedPerPlayer = amount;
this.totalMobsAddedPerPlayer = amount;
}
@Override
public float getAdditionalSimultaneousEntities() {
return simultaneousMobsAddedPerPlayer;
return this.simultaneousMobsAddedPerPlayer;
}
@Override
public void setAdditionalSimultaneousEntities(float amount) {
simultaneousMobsAddedPerPlayer = amount;
this.simultaneousMobsAddedPerPlayer = amount;
}
@Override
public int getDelay() {
return ticksBetweenSpawn;
return this.ticksBetweenSpawn;
}
@Override
public void setDelay(int delay) {
Preconditions.checkArgument(delay >= 0, "Delay cannot be less than 0");
ticksBetweenSpawn = delay;
this.ticksBetweenSpawn = delay;
}
@Override
public int getSpawnRange() {
return spawnRange;
return this.spawnRange;
}
@Override
@@ -143,7 +142,7 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
@Override
public EntitySnapshot getSpawnedEntity() {
SimpleWeightedRandomList<MobSpawnerData> potentials = spawnPotentialsDefinition;
SimpleWeightedRandomList<SpawnData> potentials = this.spawnPotentialsDefinition;
if (potentials.isEmpty()) {
return null;
}
@@ -153,70 +152,70 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
@Override
public void setSpawnedEntity(EntitySnapshot snapshot) {
setSpawnedEntity(snapshot, null, null);
this.setSpawnedEntity(snapshot, null, null);
}
@Override
public void setSpawnedEntity(SpawnerEntry spawnerEntry) {
Preconditions.checkArgument(spawnerEntry != null, "Entry cannot be null");
setSpawnedEntity(spawnerEntry.getSnapshot(), spawnerEntry.getSpawnRule(), spawnerEntry.getEquipment());
this.setSpawnedEntity(spawnerEntry.getSnapshot(), spawnerEntry.getSpawnRule(), spawnerEntry.getEquipment());
}
private void setSpawnedEntity(EntitySnapshot snapshot, SpawnRule spawnRule, SpawnerEntry.Equipment equipment) {
if (snapshot == null) {
getTrialData().nextSpawnData = Optional.empty();
spawnPotentialsDefinition = SimpleWeightedRandomList.empty(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later
this.getTrialData().nextSpawnData = Optional.empty();
this.spawnPotentialsDefinition = SimpleWeightedRandomList.empty(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later
return;
}
NBTTagCompound compoundTag = ((CraftEntitySnapshot) snapshot).getData();
MobSpawnerData data = new MobSpawnerData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnRule)), CraftCreatureSpawner.getEquipment(equipment));
CompoundTag compoundTag = ((CraftEntitySnapshot) snapshot).getData();
SpawnData data = new SpawnData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnRule)), CraftCreatureSpawner.getEquipment(equipment));
getTrialData().nextSpawnData = Optional.of(data);
spawnPotentialsDefinition = SimpleWeightedRandomList.single(data);
this.getTrialData().nextSpawnData = Optional.of(data);
this.spawnPotentialsDefinition = SimpleWeightedRandomList.single(data);
}
@Override
public void addPotentialSpawn(EntitySnapshot snapshot, int weight, SpawnRule spawnRule) {
addPotentialSpawn(snapshot, weight, spawnRule, null);
this.addPotentialSpawn(snapshot, weight, spawnRule, null);
}
private void addPotentialSpawn(EntitySnapshot snapshot, int weight, SpawnRule spawnRule, SpawnerEntry.Equipment equipment) {
Preconditions.checkArgument(snapshot != null, "Snapshot cannot be null");
NBTTagCompound compoundTag = ((CraftEntitySnapshot) snapshot).getData();
CompoundTag compoundTag = ((CraftEntitySnapshot) snapshot).getData();
SimpleWeightedRandomList.a<MobSpawnerData> builder = SimpleWeightedRandomList.builder(); // PAIL rename Builder
spawnPotentialsDefinition.unwrap().forEach(entry -> builder.add(entry.data(), entry.getWeight().asInt()));
builder.add(new MobSpawnerData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnRule)), CraftCreatureSpawner.getEquipment(equipment)), weight);
spawnPotentialsDefinition = builder.build();
SimpleWeightedRandomList.Builder<SpawnData> builder = SimpleWeightedRandomList.builder(); // PAIL rename Builder
this.spawnPotentialsDefinition.unwrap().forEach(entry -> builder.add(entry.data(), entry.getWeight().asInt()));
builder.add(new SpawnData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnRule)), CraftCreatureSpawner.getEquipment(equipment)), weight);
this.spawnPotentialsDefinition = builder.build();
}
@Override
public void addPotentialSpawn(SpawnerEntry spawnerEntry) {
Preconditions.checkArgument(spawnerEntry != null, "Entry cannot be null");
addPotentialSpawn(spawnerEntry.getSnapshot(), spawnerEntry.getSpawnWeight(), spawnerEntry.getSpawnRule(), spawnerEntry.getEquipment());
this.addPotentialSpawn(spawnerEntry.getSnapshot(), spawnerEntry.getSpawnWeight(), spawnerEntry.getSpawnRule(), spawnerEntry.getEquipment());
}
@Override
public void setPotentialSpawns(Collection<SpawnerEntry> entries) {
Preconditions.checkArgument(entries != null, "Entries cannot be null");
SimpleWeightedRandomList.a<MobSpawnerData> builder = SimpleWeightedRandomList.builder();
SimpleWeightedRandomList.Builder<SpawnData> builder = SimpleWeightedRandomList.builder();
for (SpawnerEntry spawnerEntry : entries) {
NBTTagCompound compoundTag = ((CraftEntitySnapshot) spawnerEntry.getSnapshot()).getData();
builder.add(new MobSpawnerData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnerEntry.getSpawnRule())), CraftCreatureSpawner.getEquipment(spawnerEntry.getEquipment())), spawnerEntry.getSpawnWeight());
CompoundTag compoundTag = ((CraftEntitySnapshot) spawnerEntry.getSnapshot()).getData();
builder.add(new SpawnData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnerEntry.getSpawnRule())), CraftCreatureSpawner.getEquipment(spawnerEntry.getEquipment())), spawnerEntry.getSpawnWeight());
}
spawnPotentialsDefinition = builder.build();
this.spawnPotentialsDefinition = builder.build();
}
@Override
public List<SpawnerEntry> getPotentialSpawns() {
List<SpawnerEntry> entries = new ArrayList<>();
for (b<MobSpawnerData> entry : spawnPotentialsDefinition.unwrap()) { // PAIL rename Wrapper
for (Wrapper<SpawnData> entry : this.spawnPotentialsDefinition.unwrap()) { // PAIL rename Wrapper
CraftEntitySnapshot snapshot = CraftEntitySnapshot.create(entry.data().getEntityToSpawn());
if (snapshot != null) {
@@ -231,7 +230,7 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
public Map<LootTable, Integer> getPossibleRewards() {
Map<LootTable, Integer> tables = new HashMap<>();
for (b<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> entry : lootTablesToEject.unwrap()) {
for (Wrapper<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> entry : this.lootTablesToEject.unwrap()) {
LootTable table = CraftLootTable.minecraftToBukkit(entry.data());
if (table != null) {
tables.put(table, entry.getWeight().asInt());
@@ -246,10 +245,10 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
Preconditions.checkArgument(table != null, "Table cannot be null");
Preconditions.checkArgument(weight >= 1, "Weight must be at least 1");
SimpleWeightedRandomList.a<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> builder = SimpleWeightedRandomList.builder();
lootTablesToEject.unwrap().forEach(entry -> builder.add(entry.data(), entry.getWeight().asInt()));
SimpleWeightedRandomList.Builder<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> builder = SimpleWeightedRandomList.builder();
this.lootTablesToEject.unwrap().forEach(entry -> builder.add(entry.data(), entry.getWeight().asInt()));
builder.add(CraftLootTable.bukkitToMinecraft(table), weight);
lootTablesToEject = builder.build();
this.lootTablesToEject = builder.build();
}
@Override
@@ -257,24 +256,24 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
Preconditions.checkArgument(table != null, "Key cannot be null");
ResourceKey<net.minecraft.world.level.storage.loot.LootTable> minecraftKey = CraftLootTable.bukkitToMinecraft(table);
SimpleWeightedRandomList.a<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> builder = SimpleWeightedRandomList.builder();
SimpleWeightedRandomList.Builder<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> builder = SimpleWeightedRandomList.builder();
for (b<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> entry : lootTablesToEject.unwrap()) {
for (Wrapper<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> entry : this.lootTablesToEject.unwrap()) {
if (!entry.data().equals(minecraftKey)) {
builder.add(entry.data(), entry.getWeight().asInt());
}
}
lootTablesToEject = builder.build();
this.lootTablesToEject = builder.build();
}
@Override
public void setPossibleRewards(Map<LootTable, Integer> rewards) {
if (rewards == null || rewards.isEmpty()) {
lootTablesToEject = SimpleWeightedRandomList.empty();
this.lootTablesToEject = SimpleWeightedRandomList.empty();
return;
}
SimpleWeightedRandomList.a<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> builder = SimpleWeightedRandomList.builder();
SimpleWeightedRandomList.Builder<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> builder = SimpleWeightedRandomList.builder();
rewards.forEach((table, weight) -> {
Preconditions.checkArgument(table != null, "Table cannot be null");
Preconditions.checkArgument(weight >= 1, "Weight must be at least 1");
@@ -282,24 +281,24 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
builder.add(CraftLootTable.bukkitToMinecraft(table), weight);
});
lootTablesToEject = builder.build();
this.lootTablesToEject = builder.build();
}
@Override
public int getRequiredPlayerRange() {
return snapshot.trialSpawner.getRequiredPlayerRange();
return this.snapshot.trialSpawner.getRequiredPlayerRange();
}
@Override
public void setRequiredPlayerRange(int requiredPlayerRange) {
snapshot.trialSpawner.requiredPlayerRange = requiredPlayerRange;
this.snapshot.trialSpawner.requiredPlayerRange = requiredPlayerRange;
}
private TrialSpawnerData getTrialData() {
return snapshot.getTrialSpawner().getData();
return this.snapshot.getTrialSpawner().getData();
}
protected TrialSpawnerConfig toMinecraft() {
return new TrialSpawnerConfig(spawnRange, totalMobs, simultaneousMobs, totalMobsAddedPerPlayer, simultaneousMobsAddedPerPlayer, ticksBetweenSpawn, spawnPotentialsDefinition, lootTablesToEject, itemsToDropWhenOminous);
return new TrialSpawnerConfig(this.spawnRange, this.totalMobs, this.simultaneousMobs, this.totalMobsAddedPerPlayer, this.simultaneousMobsAddedPerPlayer, this.ticksBetweenSpawn, this.spawnPotentialsDefinition, this.lootTablesToEject, this.itemsToDropWhenOminous);
}
}

View File

@@ -3,37 +3,36 @@ package org.bukkit.craftbukkit.block.banner;
import com.google.common.base.Preconditions;
import java.util.Locale;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.level.block.entity.EnumBannerPatternType;
import net.minecraft.world.level.block.entity.BannerPattern;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.block.banner.PatternType;
import org.bukkit.craftbukkit.CraftRegistry;
import org.bukkit.craftbukkit.util.Handleable;
public class CraftPatternType implements PatternType, Handleable<EnumBannerPatternType> {
public class CraftPatternType implements PatternType, Handleable<BannerPattern> {
private static int count = 0;
public static PatternType minecraftToBukkit(EnumBannerPatternType minecraft) {
public static PatternType minecraftToBukkit(BannerPattern minecraft) {
return CraftRegistry.minecraftToBukkit(minecraft, Registries.BANNER_PATTERN, Registry.BANNER_PATTERN);
}
public static PatternType minecraftHolderToBukkit(Holder<EnumBannerPatternType> minecraft) {
return minecraftToBukkit(minecraft.value());
public static PatternType minecraftHolderToBukkit(Holder<BannerPattern> minecraft) {
return CraftPatternType.minecraftToBukkit(minecraft.value());
}
public static EnumBannerPatternType bukkitToMinecraft(PatternType bukkit) {
public static BannerPattern bukkitToMinecraft(PatternType bukkit) {
return CraftRegistry.bukkitToMinecraft(bukkit);
}
public static Holder<EnumBannerPatternType> bukkitToMinecraftHolder(PatternType bukkit) {
public static Holder<BannerPattern> bukkitToMinecraftHolder(PatternType bukkit) {
Preconditions.checkArgument(bukkit != null);
IRegistry<EnumBannerPatternType> registry = CraftRegistry.getMinecraftRegistry(Registries.BANNER_PATTERN);
net.minecraft.core.Registry<BannerPattern> registry = CraftRegistry.getMinecraftRegistry(Registries.BANNER_PATTERN);
if (registry.wrapAsHolder(bukkitToMinecraft(bukkit)) instanceof Holder.c<EnumBannerPatternType> holder) {
if (registry.wrapAsHolder(CraftPatternType.bukkitToMinecraft(bukkit)) instanceof Holder.Reference<BannerPattern> holder) {
return holder;
}
@@ -42,11 +41,11 @@ public class CraftPatternType implements PatternType, Handleable<EnumBannerPatte
}
private final NamespacedKey key;
private final EnumBannerPatternType bannerPatternType;
private final BannerPattern bannerPatternType;
private final String name;
private final int ordinal;
public CraftPatternType(NamespacedKey key, EnumBannerPatternType bannerPatternType) {
public CraftPatternType(NamespacedKey key, BannerPattern bannerPatternType) {
this.key = key;
this.bannerPatternType = bannerPatternType;
// For backwards compatibility, minecraft values will stile return the uppercase name without the namespace,
@@ -58,38 +57,38 @@ public class CraftPatternType implements PatternType, Handleable<EnumBannerPatte
} else {
this.name = key.toString();
}
this.ordinal = count++;
this.ordinal = CraftPatternType.count++;
}
@Override
public EnumBannerPatternType getHandle() {
return bannerPatternType;
public BannerPattern getHandle() {
return this.bannerPatternType;
}
@Override
public NamespacedKey getKey() {
return key;
return this.key;
}
@Override
public int compareTo(PatternType patternType) {
return ordinal - patternType.ordinal();
return this.ordinal - patternType.ordinal();
}
@Override
public String name() {
return name;
return this.name;
}
@Override
public int ordinal() {
return ordinal;
return this.ordinal;
}
@Override
public String toString() {
// For backwards compatibility
return name();
return this.name();
}
@Override
@@ -102,12 +101,12 @@ public class CraftPatternType implements PatternType, Handleable<EnumBannerPatte
return false;
}
return getKey().equals(((PatternType) other).getKey());
return this.getKey().equals(((PatternType) other).getKey());
}
@Override
public int hashCode() {
return getKey().hashCode();
return this.getKey().hashCode();
}
@Override

View File

@@ -4,20 +4,20 @@ import org.bukkit.block.data.Ageable;
public abstract class CraftAgeable extends CraftBlockData implements Ageable {
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger AGE = getInteger("age");
private static final net.minecraft.world.level.block.state.properties.IntegerProperty AGE = getInteger("age");
@Override
public int getAge() {
return get(AGE);
return this.get(CraftAgeable.AGE);
}
@Override
public void setAge(int age) {
set(AGE, age);
this.set(CraftAgeable.AGE, age);
}
@Override
public int getMaximumAge() {
return getMax(AGE);
return getMax(CraftAgeable.AGE);
}
}

View File

@@ -4,20 +4,20 @@ import org.bukkit.block.data.AnaloguePowerable;
public abstract class CraftAnaloguePowerable extends CraftBlockData implements AnaloguePowerable {
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger POWER = getInteger("power");
private static final net.minecraft.world.level.block.state.properties.IntegerProperty POWER = getInteger("power");
@Override
public int getPower() {
return get(POWER);
return this.get(CraftAnaloguePowerable.POWER);
}
@Override
public void setPower(int power) {
set(POWER, power);
this.set(CraftAnaloguePowerable.POWER, power);
}
@Override
public int getMaximumPower() {
return getMax(POWER);
return getMax(CraftAnaloguePowerable.POWER);
}
}

View File

@@ -4,15 +4,15 @@ import org.bukkit.block.data.Attachable;
public abstract class CraftAttachable extends CraftBlockData implements Attachable {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean ATTACHED = getBoolean("attached");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty ATTACHED = getBoolean("attached");
@Override
public boolean isAttached() {
return get(ATTACHED);
return this.get(CraftAttachable.ATTACHED);
}
@Override
public void setAttached(boolean attached) {
set(ATTACHED, attached);
this.set(CraftAttachable.ATTACHED, attached);
}
}

View File

@@ -4,15 +4,15 @@ import org.bukkit.block.data.Bisected;
public class CraftBisected extends CraftBlockData implements Bisected {
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> HALF = getEnum("half");
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> HALF = getEnum("half");
@Override
public org.bukkit.block.data.Bisected.Half getHalf() {
return get(HALF, org.bukkit.block.data.Bisected.Half.class);
return this.get(CraftBisected.HALF, org.bukkit.block.data.Bisected.Half.class);
}
@Override
public void setHalf(org.bukkit.block.data.Bisected.Half half) {
set(HALF, half);
this.set(CraftBisected.HALF, half);
}
}

View File

@@ -9,22 +9,20 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.commands.arguments.blocks.ArgumentBlock;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.EnumDirection;
import net.minecraft.commands.arguments.blocks.BlockStateParser;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.util.INamable;
import net.minecraft.world.level.BlockAccessAir;
import net.minecraft.util.StringRepresentable;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EnumBlockMirror;
import net.minecraft.world.level.block.EnumBlockRotation;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.block.state.IBlockDataHolder;
import net.minecraft.world.level.block.state.properties.BlockStateBoolean;
import net.minecraft.world.level.block.state.properties.BlockStateEnum;
import net.minecraft.world.level.block.state.properties.BlockStateInteger;
import net.minecraft.world.level.block.state.properties.IBlockState;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.StateHolder;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.block.state.properties.Property;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -52,24 +50,24 @@ import org.jetbrains.annotations.NotNull;
public class CraftBlockData implements BlockData {
private IBlockData state;
private Map<IBlockState<?>, Comparable<?>> parsedStates;
private net.minecraft.world.level.block.state.BlockState state;
private Map<Property<?>, Comparable<?>> parsedStates;
protected CraftBlockData() {
throw new AssertionError("Template Constructor");
}
protected CraftBlockData(IBlockData state) {
protected CraftBlockData(net.minecraft.world.level.block.state.BlockState state) {
this.state = state;
}
@Override
public Material getMaterial() {
return CraftBlockType.minecraftToBukkit(state.getBlock());
return CraftBlockType.minecraftToBukkit(this.state.getBlock());
}
public IBlockData getState() {
return state;
public net.minecraft.world.level.block.state.BlockState getState() {
return this.state;
}
/**
@@ -80,8 +78,8 @@ public class CraftBlockData implements BlockData {
* @param <B> the type
* @return the matching Bukkit type
*/
protected <B extends Enum<B>> B get(BlockStateEnum<?> nms, Class<B> bukkit) {
return toBukkit(state.getValue(nms), bukkit);
protected <B extends Enum<B>> B get(EnumProperty<?> nms, Class<B> bukkit) {
return CraftBlockData.toBukkit(this.state.getValue(nms), bukkit);
}
/**
@@ -94,27 +92,27 @@ public class CraftBlockData implements BlockData {
* @return an immutable Set of values in their appropriate Bukkit type
*/
@SuppressWarnings("unchecked")
protected <B extends Enum<B>> Set<B> getValues(BlockStateEnum<?> nms, Class<B> bukkit) {
protected <B extends Enum<B>> Set<B> getValues(EnumProperty<?> nms, Class<B> bukkit) {
ImmutableSet.Builder<B> values = ImmutableSet.builder();
for (Enum<?> e : nms.getPossibleValues()) {
values.add(toBukkit(e, bukkit));
values.add(CraftBlockData.toBukkit(e, bukkit));
}
return values.build();
}
/**
* Set a given {@link BlockStateEnum} with the matching enum from Bukkit.
* Set a given {@link EnumProperty} with the matching enum from Bukkit.
*
* @param nms the NMS BlockStateEnum to set
* @param bukkit the matching Bukkit Enum
* @param <B> the Bukkit type
* @param <N> the NMS type
*/
protected <B extends Enum<B>, N extends Enum<N> & INamable> void set(BlockStateEnum<N> nms, Enum<B> bukkit) {
protected <B extends Enum<B>, N extends Enum<N> & StringRepresentable> void set(EnumProperty<N> nms, Enum<B> bukkit) {
this.parsedStates = null;
this.state = this.state.setValue(nms, toNMS(bukkit, nms.getValueClass()));
this.state = this.state.setValue(nms, CraftBlockData.toNMS(bukkit, nms.getValueClass()));
}
@Override
@@ -126,7 +124,7 @@ public class CraftBlockData implements BlockData {
CraftBlockData clone = (CraftBlockData) this.clone();
clone.parsedStates = null;
for (IBlockState parsed : craft.parsedStates.keySet()) {
for (Property parsed : craft.parsedStates.keySet()) {
clone.state = clone.state.setValue(parsed, craft.state.getValue(parsed));
}
@@ -168,10 +166,10 @@ public class CraftBlockData implements BlockData {
*/
@SuppressWarnings("unchecked")
private static <B extends Enum<B>> B toBukkit(Enum<?> nms, Class<B> bukkit) {
if (nms instanceof EnumDirection) {
return (B) CraftBlock.notchToBlockFace((EnumDirection) nms);
if (nms instanceof Direction) {
return (B) CraftBlock.notchToBlockFace((Direction) nms);
}
return (B) ENUM_VALUES.computeIfAbsent(bukkit, Class::getEnumConstants)[nms.ordinal()];
return (B) CraftBlockData.ENUM_VALUES.computeIfAbsent(bukkit, Class::getEnumConstants)[nms.ordinal()];
}
/**
@@ -183,11 +181,11 @@ public class CraftBlockData implements BlockData {
* @throws IllegalStateException if the Enum could not be converted
*/
@SuppressWarnings("unchecked")
private static <N extends Enum<N> & INamable> N toNMS(Enum<?> bukkit, Class<N> nms) {
public static <N extends Enum<N> & StringRepresentable> N toNMS(Enum<?> bukkit, Class<N> nms) {
if (bukkit instanceof BlockFace) {
return (N) CraftBlock.blockFaceToNotch((BlockFace) bukkit);
}
return (N) ENUM_VALUES.computeIfAbsent(nms, Class::getEnumConstants)[bukkit.ordinal()];
return (N) CraftBlockData.ENUM_VALUES.computeIfAbsent(nms, Class::getEnumConstants)[bukkit.ordinal()];
}
/**
@@ -197,7 +195,7 @@ public class CraftBlockData implements BlockData {
* @param <T> the type
* @return the current value of the given state
*/
protected <T extends Comparable<T>> T get(IBlockState<T> ibs) {
protected <T extends Comparable<T>> T get(Property<T> ibs) {
// Straight integer or boolean getter
return this.state.getValue(ibs);
}
@@ -210,7 +208,7 @@ public class CraftBlockData implements BlockData {
* @param <T> the state's type
* @param <V> the value's type. Must match the state's type.
*/
public <T extends Comparable<T>, V extends T> void set(IBlockState<T> ibs, V v) {
public <T extends Comparable<T>, V extends T> void set(Property<T> ibs, V v) {
// Straight integer or boolean setter
this.parsedStates = null;
this.state = this.state.setValue(ibs, v);
@@ -218,12 +216,12 @@ public class CraftBlockData implements BlockData {
@Override
public String getAsString() {
return toString(state.getValues());
return this.toString(this.state.getValues());
}
@Override
public String getAsString(boolean hideUnspecified) {
return (hideUnspecified && parsedStates != null) ? toString(parsedStates) : getAsString();
return (hideUnspecified && this.parsedStates != null) ? this.toString(this.parsedStates) : this.getAsString();
}
@Override
@@ -237,16 +235,16 @@ public class CraftBlockData implements BlockData {
@Override
public String toString() {
return "CraftBlockData{" + getAsString() + "}";
return "CraftBlockData{" + this.getAsString() + "}";
}
// Mimicked from BlockDataAbstract#toString()
public String toString(Map<IBlockState<?>, Comparable<?>> states) {
StringBuilder stateString = new StringBuilder(BuiltInRegistries.BLOCK.getKey(state.getBlock()).toString());
public String toString(Map<Property<?>, Comparable<?>> states) {
StringBuilder stateString = new StringBuilder(BuiltInRegistries.BLOCK.getKey(this.state.getBlock()).toString());
if (!states.isEmpty()) {
stateString.append('[');
stateString.append(states.entrySet().stream().map(IBlockDataHolder.PROPERTY_ENTRY_TO_STRING_FUNCTION).collect(Collectors.joining(",")));
stateString.append(states.entrySet().stream().map(StateHolder.PROPERTY_ENTRY_TO_STRING_FUNCTION).collect(Collectors.joining(",")));
stateString.append(']');
}
@@ -254,14 +252,14 @@ public class CraftBlockData implements BlockData {
}
public Map<String, String> toStates(boolean hideUnspecified) {
return (hideUnspecified && parsedStates != null) ? toStates(parsedStates) : toStates(state.getValues());
return (hideUnspecified && this.parsedStates != null) ? CraftBlockData.toStates(this.parsedStates) : CraftBlockData.toStates(this.state.getValues());
}
private static Map<String, String> toStates(Map<IBlockState<?>, Comparable<?>> states) {
private static Map<String, String> toStates(Map<Property<?>, Comparable<?>> states) {
Map<String, String> compound = new HashMap<>();
for (Map.Entry<IBlockState<?>, Comparable<?>> entry : states.entrySet()) {
IBlockState iblockstate = (IBlockState) entry.getKey();
for (Map.Entry<Property<?>, Comparable<?>> entry : states.entrySet()) {
Property iblockstate = (Property) entry.getKey();
compound.put(iblockstate.getName(), iblockstate.getName(entry.getValue()));
}
@@ -271,48 +269,48 @@ public class CraftBlockData implements BlockData {
@Override
public boolean equals(Object obj) {
return obj instanceof CraftBlockData && state.equals(((CraftBlockData) obj).state);
return obj instanceof CraftBlockData && this.state.equals(((CraftBlockData) obj).state);
}
@Override
public int hashCode() {
return state.hashCode();
return this.state.hashCode();
}
protected static BlockStateBoolean getBoolean(String name) {
protected static BooleanProperty getBoolean(String name) {
throw new AssertionError("Template Method");
}
protected static BlockStateBoolean getBoolean(String name, boolean optional) {
protected static BooleanProperty getBoolean(String name, boolean optional) {
throw new AssertionError("Template Method");
}
protected static BlockStateEnum<?> getEnum(String name) {
protected static EnumProperty<?> getEnum(String name) {
throw new AssertionError("Template Method");
}
protected static BlockStateInteger getInteger(String name) {
protected static IntegerProperty getInteger(String name) {
throw new AssertionError("Template Method");
}
protected static BlockStateBoolean getBoolean(Class<? extends Block> block, String name) {
return (BlockStateBoolean) getState(block, name, false);
protected static BooleanProperty getBoolean(Class<? extends Block> block, String name) {
return (BooleanProperty) CraftBlockData.getState(block, name, false);
}
protected static BlockStateBoolean getBoolean(Class<? extends Block> block, String name, boolean optional) {
return (BlockStateBoolean) getState(block, name, optional);
protected static BooleanProperty getBoolean(Class<? extends Block> block, String name, boolean optional) {
return (BooleanProperty) CraftBlockData.getState(block, name, optional);
}
protected static BlockStateEnum<?> getEnum(Class<? extends Block> block, String name) {
return (BlockStateEnum<?>) getState(block, name, false);
protected static EnumProperty<?> getEnum(Class<? extends Block> block, String name) {
return (EnumProperty<?>) CraftBlockData.getState(block, name, false);
}
protected static BlockStateInteger getInteger(Class<? extends Block> block, String name) {
return (BlockStateInteger) getState(block, name, false);
protected static IntegerProperty getInteger(Class<? extends Block> block, String name) {
return (IntegerProperty) CraftBlockData.getState(block, name, false);
}
/**
* Get a specified {@link IBlockState} from a given block's class with a
* Get a specified {@link Property} from a given block's class with a
* given name
*
* @param block the class to retrieve the state from
@@ -322,15 +320,15 @@ public class CraftBlockData implements BlockData {
* @throws IllegalStateException if the state is null and {@code optional}
* is false.
*/
private static IBlockState<?> getState(Class<? extends Block> block, String name, boolean optional) {
IBlockState<?> state = null;
private static Property<?> getState(Class<? extends Block> block, String name, boolean optional) {
Property<?> state = null;
for (Block instance : BuiltInRegistries.BLOCK) {
if (instance.getClass() == block) {
if (state == null) {
state = instance.getStateDefinition().getProperty(name);
} else {
IBlockState<?> newState = instance.getStateDefinition().getProperty(name);
Property<?> newState = instance.getStateDefinition().getProperty(name);
Preconditions.checkState(state == newState, "State mistmatch %s,%s", state, newState);
}
@@ -348,7 +346,7 @@ public class CraftBlockData implements BlockData {
* @param state the state to check
* @return the minimum value allowed
*/
protected static int getMin(BlockStateInteger state) {
protected static int getMin(IntegerProperty state) {
return state.min;
}
@@ -358,140 +356,140 @@ public class CraftBlockData implements BlockData {
* @param state the state to check
* @return the maximum value allowed
*/
protected static int getMax(BlockStateInteger state) {
protected static int getMax(IntegerProperty state) {
return state.max;
}
//
private static final Map<Class<? extends Block>, Function<IBlockData, CraftBlockData>> MAP = new HashMap<>();
private static final Map<Class<? extends Block>, Function<net.minecraft.world.level.block.state.BlockState, CraftBlockData>> MAP = new HashMap<>();
static {
//<editor-fold desc="CraftBlockData Registration" defaultstate="collapsed">
register(net.minecraft.world.level.block.AmethystClusterBlock.class, org.bukkit.craftbukkit.block.impl.CraftAmethystCluster::new);
register(net.minecraft.world.level.block.BigDripleafBlock.class, org.bukkit.craftbukkit.block.impl.CraftBigDripleaf::new);
register(net.minecraft.world.level.block.BigDripleafStemBlock.class, org.bukkit.craftbukkit.block.impl.CraftBigDripleafStem::new);
register(net.minecraft.world.level.block.BlockAnvil.class, org.bukkit.craftbukkit.block.impl.CraftAnvil::new);
register(net.minecraft.world.level.block.BlockBamboo.class, org.bukkit.craftbukkit.block.impl.CraftBamboo::new);
register(net.minecraft.world.level.block.BlockBanner.class, org.bukkit.craftbukkit.block.impl.CraftBanner::new);
register(net.minecraft.world.level.block.BlockBannerWall.class, org.bukkit.craftbukkit.block.impl.CraftBannerWall::new);
register(net.minecraft.world.level.block.BlockBarrel.class, org.bukkit.craftbukkit.block.impl.CraftBarrel::new);
register(net.minecraft.world.level.block.BlockBarrier.class, org.bukkit.craftbukkit.block.impl.CraftBarrier::new);
register(net.minecraft.world.level.block.BlockBed.class, org.bukkit.craftbukkit.block.impl.CraftBed::new);
register(net.minecraft.world.level.block.BlockBeehive.class, org.bukkit.craftbukkit.block.impl.CraftBeehive::new);
register(net.minecraft.world.level.block.BlockBeetroot.class, org.bukkit.craftbukkit.block.impl.CraftBeetroot::new);
register(net.minecraft.world.level.block.BlockBell.class, org.bukkit.craftbukkit.block.impl.CraftBell::new);
register(net.minecraft.world.level.block.BlockBlastFurnace.class, org.bukkit.craftbukkit.block.impl.CraftBlastFurnace::new);
register(net.minecraft.world.level.block.BlockBrewingStand.class, org.bukkit.craftbukkit.block.impl.CraftBrewingStand::new);
register(net.minecraft.world.level.block.BlockBubbleColumn.class, org.bukkit.craftbukkit.block.impl.CraftBubbleColumn::new);
register(net.minecraft.world.level.block.BlockButtonAbstract.class, org.bukkit.craftbukkit.block.impl.CraftButtonAbstract::new);
register(net.minecraft.world.level.block.BlockCactus.class, org.bukkit.craftbukkit.block.impl.CraftCactus::new);
register(net.minecraft.world.level.block.BlockCake.class, org.bukkit.craftbukkit.block.impl.CraftCake::new);
register(net.minecraft.world.level.block.BlockCampfire.class, org.bukkit.craftbukkit.block.impl.CraftCampfire::new);
register(net.minecraft.world.level.block.BlockCarrots.class, org.bukkit.craftbukkit.block.impl.CraftCarrots::new);
register(net.minecraft.world.level.block.BlockChain.class, org.bukkit.craftbukkit.block.impl.CraftChain::new);
register(net.minecraft.world.level.block.BlockChest.class, org.bukkit.craftbukkit.block.impl.CraftChest::new);
register(net.minecraft.world.level.block.BlockChestTrapped.class, org.bukkit.craftbukkit.block.impl.CraftChestTrapped::new);
register(net.minecraft.world.level.block.BlockChorusFlower.class, org.bukkit.craftbukkit.block.impl.CraftChorusFlower::new);
register(net.minecraft.world.level.block.BlockChorusFruit.class, org.bukkit.craftbukkit.block.impl.CraftChorusFruit::new);
register(net.minecraft.world.level.block.BlockCobbleWall.class, org.bukkit.craftbukkit.block.impl.CraftCobbleWall::new);
register(net.minecraft.world.level.block.BlockCocoa.class, org.bukkit.craftbukkit.block.impl.CraftCocoa::new);
register(net.minecraft.world.level.block.BlockCommand.class, org.bukkit.craftbukkit.block.impl.CraftCommand::new);
register(net.minecraft.world.level.block.BlockComposter.class, org.bukkit.craftbukkit.block.impl.CraftComposter::new);
register(net.minecraft.world.level.block.BlockConduit.class, org.bukkit.craftbukkit.block.impl.CraftConduit::new);
register(net.minecraft.world.level.block.BlockCoralDead.class, org.bukkit.craftbukkit.block.impl.CraftCoralDead::new);
register(net.minecraft.world.level.block.BlockCoralFan.class, org.bukkit.craftbukkit.block.impl.CraftCoralFan::new);
register(net.minecraft.world.level.block.BlockCoralFanAbstract.class, org.bukkit.craftbukkit.block.impl.CraftCoralFanAbstract::new);
register(net.minecraft.world.level.block.BlockCoralFanWall.class, org.bukkit.craftbukkit.block.impl.CraftCoralFanWall::new);
register(net.minecraft.world.level.block.BlockCoralFanWallAbstract.class, org.bukkit.craftbukkit.block.impl.CraftCoralFanWallAbstract::new);
register(net.minecraft.world.level.block.BlockCoralPlant.class, org.bukkit.craftbukkit.block.impl.CraftCoralPlant::new);
register(net.minecraft.world.level.block.BlockCrops.class, org.bukkit.craftbukkit.block.impl.CraftCrops::new);
register(net.minecraft.world.level.block.BlockDaylightDetector.class, org.bukkit.craftbukkit.block.impl.CraftDaylightDetector::new);
register(net.minecraft.world.level.block.BlockDirtSnow.class, org.bukkit.craftbukkit.block.impl.CraftDirtSnow::new);
register(net.minecraft.world.level.block.BlockDispenser.class, org.bukkit.craftbukkit.block.impl.CraftDispenser::new);
register(net.minecraft.world.level.block.BlockDoor.class, org.bukkit.craftbukkit.block.impl.CraftDoor::new);
register(net.minecraft.world.level.block.BlockDropper.class, org.bukkit.craftbukkit.block.impl.CraftDropper::new);
register(net.minecraft.world.level.block.BlockEndRod.class, org.bukkit.craftbukkit.block.impl.CraftEndRod::new);
register(net.minecraft.world.level.block.BlockEnderChest.class, org.bukkit.craftbukkit.block.impl.CraftEnderChest::new);
register(net.minecraft.world.level.block.BlockEnderPortalFrame.class, org.bukkit.craftbukkit.block.impl.CraftEnderPortalFrame::new);
register(net.minecraft.world.level.block.BlockFence.class, org.bukkit.craftbukkit.block.impl.CraftFence::new);
register(net.minecraft.world.level.block.BlockFenceGate.class, org.bukkit.craftbukkit.block.impl.CraftFenceGate::new);
register(net.minecraft.world.level.block.BlockFire.class, org.bukkit.craftbukkit.block.impl.CraftFire::new);
register(net.minecraft.world.level.block.BlockFloorSign.class, org.bukkit.craftbukkit.block.impl.CraftFloorSign::new);
register(net.minecraft.world.level.block.BlockFluids.class, org.bukkit.craftbukkit.block.impl.CraftFluids::new);
register(net.minecraft.world.level.block.BlockFurnaceFurace.class, org.bukkit.craftbukkit.block.impl.CraftFurnaceFurace::new);
register(net.minecraft.world.level.block.BlockGlazedTerracotta.class, org.bukkit.craftbukkit.block.impl.CraftGlazedTerracotta::new);
register(net.minecraft.world.level.block.BlockGrass.class, org.bukkit.craftbukkit.block.impl.CraftGrass::new);
register(net.minecraft.world.level.block.BlockGrindstone.class, org.bukkit.craftbukkit.block.impl.CraftGrindstone::new);
register(net.minecraft.world.level.block.BlockHay.class, org.bukkit.craftbukkit.block.impl.CraftHay::new);
register(net.minecraft.world.level.block.BlockHopper.class, org.bukkit.craftbukkit.block.impl.CraftHopper::new);
register(net.minecraft.world.level.block.BlockHugeMushroom.class, org.bukkit.craftbukkit.block.impl.CraftHugeMushroom::new);
register(net.minecraft.world.level.block.BlockIceFrost.class, org.bukkit.craftbukkit.block.impl.CraftIceFrost::new);
register(net.minecraft.world.level.block.BlockIronBars.class, org.bukkit.craftbukkit.block.impl.CraftIronBars::new);
register(net.minecraft.world.level.block.BlockJigsaw.class, org.bukkit.craftbukkit.block.impl.CraftJigsaw::new);
register(net.minecraft.world.level.block.BlockJukeBox.class, org.bukkit.craftbukkit.block.impl.CraftJukeBox::new);
register(net.minecraft.world.level.block.BlockKelp.class, org.bukkit.craftbukkit.block.impl.CraftKelp::new);
register(net.minecraft.world.level.block.BlockLadder.class, org.bukkit.craftbukkit.block.impl.CraftLadder::new);
register(net.minecraft.world.level.block.BlockLantern.class, org.bukkit.craftbukkit.block.impl.CraftLantern::new);
register(net.minecraft.world.level.block.BlockLeaves.class, org.bukkit.craftbukkit.block.impl.CraftLeaves::new);
register(net.minecraft.world.level.block.BlockLectern.class, org.bukkit.craftbukkit.block.impl.CraftLectern::new);
register(net.minecraft.world.level.block.BlockLever.class, org.bukkit.craftbukkit.block.impl.CraftLever::new);
register(net.minecraft.world.level.block.BlockLoom.class, org.bukkit.craftbukkit.block.impl.CraftLoom::new);
register(net.minecraft.world.level.block.BlockMinecartDetector.class, org.bukkit.craftbukkit.block.impl.CraftMinecartDetector::new);
register(net.minecraft.world.level.block.BlockMinecartTrack.class, org.bukkit.craftbukkit.block.impl.CraftMinecartTrack::new);
register(net.minecraft.world.level.block.BlockMycel.class, org.bukkit.craftbukkit.block.impl.CraftMycel::new);
register(net.minecraft.world.level.block.BlockNetherWart.class, org.bukkit.craftbukkit.block.impl.CraftNetherWart::new);
register(net.minecraft.world.level.block.BlockNote.class, org.bukkit.craftbukkit.block.impl.CraftNote::new);
register(net.minecraft.world.level.block.BlockObserver.class, org.bukkit.craftbukkit.block.impl.CraftObserver::new);
register(net.minecraft.world.level.block.BlockPortal.class, org.bukkit.craftbukkit.block.impl.CraftPortal::new);
register(net.minecraft.world.level.block.BlockPotatoes.class, org.bukkit.craftbukkit.block.impl.CraftPotatoes::new);
register(net.minecraft.world.level.block.BlockPoweredRail.class, org.bukkit.craftbukkit.block.impl.CraftPoweredRail::new);
register(net.minecraft.world.level.block.BlockPressurePlateBinary.class, org.bukkit.craftbukkit.block.impl.CraftPressurePlateBinary::new);
register(net.minecraft.world.level.block.BlockPressurePlateWeighted.class, org.bukkit.craftbukkit.block.impl.CraftPressurePlateWeighted::new);
register(net.minecraft.world.level.block.BlockPumpkinCarved.class, org.bukkit.craftbukkit.block.impl.CraftPumpkinCarved::new);
register(net.minecraft.world.level.block.BlockRedstoneComparator.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneComparator::new);
register(net.minecraft.world.level.block.BlockRedstoneLamp.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneLamp::new);
register(net.minecraft.world.level.block.BlockRedstoneOre.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneOre::new);
register(net.minecraft.world.level.block.BlockRedstoneTorch.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneTorch::new);
register(net.minecraft.world.level.block.BlockRedstoneTorchWall.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneTorchWall::new);
register(net.minecraft.world.level.block.BlockRedstoneWire.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneWire::new);
register(net.minecraft.world.level.block.BlockReed.class, org.bukkit.craftbukkit.block.impl.CraftReed::new);
register(net.minecraft.world.level.block.BlockRepeater.class, org.bukkit.craftbukkit.block.impl.CraftRepeater::new);
register(net.minecraft.world.level.block.BlockRespawnAnchor.class, org.bukkit.craftbukkit.block.impl.CraftRespawnAnchor::new);
register(net.minecraft.world.level.block.BlockRotatable.class, org.bukkit.craftbukkit.block.impl.CraftRotatable::new);
register(net.minecraft.world.level.block.BlockSapling.class, org.bukkit.craftbukkit.block.impl.CraftSapling::new);
register(net.minecraft.world.level.block.BlockScaffolding.class, org.bukkit.craftbukkit.block.impl.CraftScaffolding::new);
register(net.minecraft.world.level.block.BlockSeaPickle.class, org.bukkit.craftbukkit.block.impl.CraftSeaPickle::new);
register(net.minecraft.world.level.block.BlockShulkerBox.class, org.bukkit.craftbukkit.block.impl.CraftShulkerBox::new);
register(net.minecraft.world.level.block.BlockSkull.class, org.bukkit.craftbukkit.block.impl.CraftSkull::new);
register(net.minecraft.world.level.block.BlockSkullPlayer.class, org.bukkit.craftbukkit.block.impl.CraftSkullPlayer::new);
register(net.minecraft.world.level.block.BlockSkullPlayerWall.class, org.bukkit.craftbukkit.block.impl.CraftSkullPlayerWall::new);
register(net.minecraft.world.level.block.BlockSkullWall.class, org.bukkit.craftbukkit.block.impl.CraftSkullWall::new);
register(net.minecraft.world.level.block.BlockSmoker.class, org.bukkit.craftbukkit.block.impl.CraftSmoker::new);
register(net.minecraft.world.level.block.BlockSnow.class, org.bukkit.craftbukkit.block.impl.CraftSnow::new);
register(net.minecraft.world.level.block.BlockSoil.class, org.bukkit.craftbukkit.block.impl.CraftSoil::new);
register(net.minecraft.world.level.block.BlockStainedGlassPane.class, org.bukkit.craftbukkit.block.impl.CraftStainedGlassPane::new);
register(net.minecraft.world.level.block.BlockStairs.class, org.bukkit.craftbukkit.block.impl.CraftStairs::new);
register(net.minecraft.world.level.block.BlockStem.class, org.bukkit.craftbukkit.block.impl.CraftStem::new);
register(net.minecraft.world.level.block.BlockStemAttached.class, org.bukkit.craftbukkit.block.impl.CraftStemAttached::new);
register(net.minecraft.world.level.block.BlockStepAbstract.class, org.bukkit.craftbukkit.block.impl.CraftStepAbstract::new);
register(net.minecraft.world.level.block.BlockStonecutter.class, org.bukkit.craftbukkit.block.impl.CraftStonecutter::new);
register(net.minecraft.world.level.block.BlockStructure.class, org.bukkit.craftbukkit.block.impl.CraftStructure::new);
register(net.minecraft.world.level.block.BlockSweetBerryBush.class, org.bukkit.craftbukkit.block.impl.CraftSweetBerryBush::new);
register(net.minecraft.world.level.block.BlockTNT.class, org.bukkit.craftbukkit.block.impl.CraftTNT::new);
register(net.minecraft.world.level.block.BlockTallPlant.class, org.bukkit.craftbukkit.block.impl.CraftTallPlant::new);
register(net.minecraft.world.level.block.BlockTallPlantFlower.class, org.bukkit.craftbukkit.block.impl.CraftTallPlantFlower::new);
register(net.minecraft.world.level.block.BlockTarget.class, org.bukkit.craftbukkit.block.impl.CraftTarget::new);
register(net.minecraft.world.level.block.BlockTorchWall.class, org.bukkit.craftbukkit.block.impl.CraftTorchWall::new);
register(net.minecraft.world.level.block.BlockTrapdoor.class, org.bukkit.craftbukkit.block.impl.CraftTrapdoor::new);
register(net.minecraft.world.level.block.BlockTripwire.class, org.bukkit.craftbukkit.block.impl.CraftTripwire::new);
register(net.minecraft.world.level.block.BlockTripwireHook.class, org.bukkit.craftbukkit.block.impl.CraftTripwireHook::new);
register(net.minecraft.world.level.block.BlockTurtleEgg.class, org.bukkit.craftbukkit.block.impl.CraftTurtleEgg::new);
register(net.minecraft.world.level.block.BlockTwistingVines.class, org.bukkit.craftbukkit.block.impl.CraftTwistingVines::new);
register(net.minecraft.world.level.block.BlockVine.class, org.bukkit.craftbukkit.block.impl.CraftVine::new);
register(net.minecraft.world.level.block.BlockWallSign.class, org.bukkit.craftbukkit.block.impl.CraftWallSign::new);
register(net.minecraft.world.level.block.BlockWeepingVines.class, org.bukkit.craftbukkit.block.impl.CraftWeepingVines::new);
register(net.minecraft.world.level.block.BlockWitherSkull.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkull::new);
register(net.minecraft.world.level.block.BlockWitherSkullWall.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkullWall::new);
register(net.minecraft.world.level.block.AnvilBlock.class, org.bukkit.craftbukkit.block.impl.CraftAnvil::new);
register(net.minecraft.world.level.block.BambooStalkBlock.class, org.bukkit.craftbukkit.block.impl.CraftBamboo::new);
register(net.minecraft.world.level.block.BannerBlock.class, org.bukkit.craftbukkit.block.impl.CraftBanner::new);
register(net.minecraft.world.level.block.WallBannerBlock.class, org.bukkit.craftbukkit.block.impl.CraftBannerWall::new);
register(net.minecraft.world.level.block.BarrelBlock.class, org.bukkit.craftbukkit.block.impl.CraftBarrel::new);
register(net.minecraft.world.level.block.BarrierBlock.class, org.bukkit.craftbukkit.block.impl.CraftBarrier::new);
register(net.minecraft.world.level.block.BedBlock.class, org.bukkit.craftbukkit.block.impl.CraftBed::new);
register(net.minecraft.world.level.block.BeehiveBlock.class, org.bukkit.craftbukkit.block.impl.CraftBeehive::new);
register(net.minecraft.world.level.block.BeetrootBlock.class, org.bukkit.craftbukkit.block.impl.CraftBeetroot::new);
register(net.minecraft.world.level.block.BellBlock.class, org.bukkit.craftbukkit.block.impl.CraftBell::new);
register(net.minecraft.world.level.block.BlastFurnaceBlock.class, org.bukkit.craftbukkit.block.impl.CraftBlastFurnace::new);
register(net.minecraft.world.level.block.BrewingStandBlock.class, org.bukkit.craftbukkit.block.impl.CraftBrewingStand::new);
register(net.minecraft.world.level.block.BubbleColumnBlock.class, org.bukkit.craftbukkit.block.impl.CraftBubbleColumn::new);
register(net.minecraft.world.level.block.ButtonBlock.class, org.bukkit.craftbukkit.block.impl.CraftButtonAbstract::new);
register(net.minecraft.world.level.block.CactusBlock.class, org.bukkit.craftbukkit.block.impl.CraftCactus::new);
register(net.minecraft.world.level.block.CakeBlock.class, org.bukkit.craftbukkit.block.impl.CraftCake::new);
register(net.minecraft.world.level.block.CampfireBlock.class, org.bukkit.craftbukkit.block.impl.CraftCampfire::new);
register(net.minecraft.world.level.block.CarrotBlock.class, org.bukkit.craftbukkit.block.impl.CraftCarrots::new);
register(net.minecraft.world.level.block.ChainBlock.class, org.bukkit.craftbukkit.block.impl.CraftChain::new);
register(net.minecraft.world.level.block.ChestBlock.class, org.bukkit.craftbukkit.block.impl.CraftChest::new);
register(net.minecraft.world.level.block.TrappedChestBlock.class, org.bukkit.craftbukkit.block.impl.CraftChestTrapped::new);
register(net.minecraft.world.level.block.ChorusFlowerBlock.class, org.bukkit.craftbukkit.block.impl.CraftChorusFlower::new);
register(net.minecraft.world.level.block.ChorusPlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftChorusFruit::new);
register(net.minecraft.world.level.block.WallBlock.class, org.bukkit.craftbukkit.block.impl.CraftCobbleWall::new);
register(net.minecraft.world.level.block.CocoaBlock.class, org.bukkit.craftbukkit.block.impl.CraftCocoa::new);
register(net.minecraft.world.level.block.CommandBlock.class, org.bukkit.craftbukkit.block.impl.CraftCommand::new);
register(net.minecraft.world.level.block.ComposterBlock.class, org.bukkit.craftbukkit.block.impl.CraftComposter::new);
register(net.minecraft.world.level.block.ConduitBlock.class, org.bukkit.craftbukkit.block.impl.CraftConduit::new);
register(net.minecraft.world.level.block.BaseCoralPlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftCoralDead::new);
register(net.minecraft.world.level.block.CoralFanBlock.class, org.bukkit.craftbukkit.block.impl.CraftCoralFan::new);
register(net.minecraft.world.level.block.BaseCoralFanBlock.class, org.bukkit.craftbukkit.block.impl.CraftCoralFanAbstract::new);
register(net.minecraft.world.level.block.CoralWallFanBlock.class, org.bukkit.craftbukkit.block.impl.CraftCoralFanWall::new);
register(net.minecraft.world.level.block.BaseCoralWallFanBlock.class, org.bukkit.craftbukkit.block.impl.CraftCoralFanWallAbstract::new);
register(net.minecraft.world.level.block.CoralPlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftCoralPlant::new);
register(net.minecraft.world.level.block.CropBlock.class, org.bukkit.craftbukkit.block.impl.CraftCrops::new);
register(net.minecraft.world.level.block.DaylightDetectorBlock.class, org.bukkit.craftbukkit.block.impl.CraftDaylightDetector::new);
register(net.minecraft.world.level.block.SnowyDirtBlock.class, org.bukkit.craftbukkit.block.impl.CraftDirtSnow::new);
register(net.minecraft.world.level.block.DispenserBlock.class, org.bukkit.craftbukkit.block.impl.CraftDispenser::new);
register(net.minecraft.world.level.block.DoorBlock.class, org.bukkit.craftbukkit.block.impl.CraftDoor::new);
register(net.minecraft.world.level.block.DropperBlock.class, org.bukkit.craftbukkit.block.impl.CraftDropper::new);
register(net.minecraft.world.level.block.EndRodBlock.class, org.bukkit.craftbukkit.block.impl.CraftEndRod::new);
register(net.minecraft.world.level.block.EnderChestBlock.class, org.bukkit.craftbukkit.block.impl.CraftEnderChest::new);
register(net.minecraft.world.level.block.EndPortalFrameBlock.class, org.bukkit.craftbukkit.block.impl.CraftEnderPortalFrame::new);
register(net.minecraft.world.level.block.FenceBlock.class, org.bukkit.craftbukkit.block.impl.CraftFence::new);
register(net.minecraft.world.level.block.FenceGateBlock.class, org.bukkit.craftbukkit.block.impl.CraftFenceGate::new);
register(net.minecraft.world.level.block.FireBlock.class, org.bukkit.craftbukkit.block.impl.CraftFire::new);
register(net.minecraft.world.level.block.StandingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftFloorSign::new);
register(net.minecraft.world.level.block.LiquidBlock.class, org.bukkit.craftbukkit.block.impl.CraftFluids::new);
register(net.minecraft.world.level.block.FurnaceBlock.class, org.bukkit.craftbukkit.block.impl.CraftFurnaceFurace::new);
register(net.minecraft.world.level.block.GlazedTerracottaBlock.class, org.bukkit.craftbukkit.block.impl.CraftGlazedTerracotta::new);
register(net.minecraft.world.level.block.GrassBlock.class, org.bukkit.craftbukkit.block.impl.CraftGrass::new);
register(net.minecraft.world.level.block.GrindstoneBlock.class, org.bukkit.craftbukkit.block.impl.CraftGrindstone::new);
register(net.minecraft.world.level.block.HayBlock.class, org.bukkit.craftbukkit.block.impl.CraftHay::new);
register(net.minecraft.world.level.block.HopperBlock.class, org.bukkit.craftbukkit.block.impl.CraftHopper::new);
register(net.minecraft.world.level.block.HugeMushroomBlock.class, org.bukkit.craftbukkit.block.impl.CraftHugeMushroom::new);
register(net.minecraft.world.level.block.FrostedIceBlock.class, org.bukkit.craftbukkit.block.impl.CraftIceFrost::new);
register(net.minecraft.world.level.block.IronBarsBlock.class, org.bukkit.craftbukkit.block.impl.CraftIronBars::new);
register(net.minecraft.world.level.block.JigsawBlock.class, org.bukkit.craftbukkit.block.impl.CraftJigsaw::new);
register(net.minecraft.world.level.block.JukeboxBlock.class, org.bukkit.craftbukkit.block.impl.CraftJukeBox::new);
register(net.minecraft.world.level.block.KelpBlock.class, org.bukkit.craftbukkit.block.impl.CraftKelp::new);
register(net.minecraft.world.level.block.LadderBlock.class, org.bukkit.craftbukkit.block.impl.CraftLadder::new);
register(net.minecraft.world.level.block.LanternBlock.class, org.bukkit.craftbukkit.block.impl.CraftLantern::new);
register(net.minecraft.world.level.block.LeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftLeaves::new);
register(net.minecraft.world.level.block.LecternBlock.class, org.bukkit.craftbukkit.block.impl.CraftLectern::new);
register(net.minecraft.world.level.block.LeverBlock.class, org.bukkit.craftbukkit.block.impl.CraftLever::new);
register(net.minecraft.world.level.block.LoomBlock.class, org.bukkit.craftbukkit.block.impl.CraftLoom::new);
register(net.minecraft.world.level.block.DetectorRailBlock.class, org.bukkit.craftbukkit.block.impl.CraftMinecartDetector::new);
register(net.minecraft.world.level.block.RailBlock.class, org.bukkit.craftbukkit.block.impl.CraftMinecartTrack::new);
register(net.minecraft.world.level.block.MyceliumBlock.class, org.bukkit.craftbukkit.block.impl.CraftMycel::new);
register(net.minecraft.world.level.block.NetherWartBlock.class, org.bukkit.craftbukkit.block.impl.CraftNetherWart::new);
register(net.minecraft.world.level.block.NoteBlock.class, org.bukkit.craftbukkit.block.impl.CraftNote::new);
register(net.minecraft.world.level.block.ObserverBlock.class, org.bukkit.craftbukkit.block.impl.CraftObserver::new);
register(net.minecraft.world.level.block.NetherPortalBlock.class, org.bukkit.craftbukkit.block.impl.CraftPortal::new);
register(net.minecraft.world.level.block.PotatoBlock.class, org.bukkit.craftbukkit.block.impl.CraftPotatoes::new);
register(net.minecraft.world.level.block.PoweredRailBlock.class, org.bukkit.craftbukkit.block.impl.CraftPoweredRail::new);
register(net.minecraft.world.level.block.PressurePlateBlock.class, org.bukkit.craftbukkit.block.impl.CraftPressurePlateBinary::new);
register(net.minecraft.world.level.block.WeightedPressurePlateBlock.class, org.bukkit.craftbukkit.block.impl.CraftPressurePlateWeighted::new);
register(net.minecraft.world.level.block.CarvedPumpkinBlock.class, org.bukkit.craftbukkit.block.impl.CraftPumpkinCarved::new);
register(net.minecraft.world.level.block.ComparatorBlock.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneComparator::new);
register(net.minecraft.world.level.block.RedstoneLampBlock.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneLamp::new);
register(net.minecraft.world.level.block.RedStoneOreBlock.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneOre::new);
register(net.minecraft.world.level.block.RedstoneTorchBlock.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneTorch::new);
register(net.minecraft.world.level.block.RedstoneWallTorchBlock.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneTorchWall::new);
register(net.minecraft.world.level.block.RedStoneWireBlock.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneWire::new);
register(net.minecraft.world.level.block.SugarCaneBlock.class, org.bukkit.craftbukkit.block.impl.CraftReed::new);
register(net.minecraft.world.level.block.RepeaterBlock.class, org.bukkit.craftbukkit.block.impl.CraftRepeater::new);
register(net.minecraft.world.level.block.RespawnAnchorBlock.class, org.bukkit.craftbukkit.block.impl.CraftRespawnAnchor::new);
register(net.minecraft.world.level.block.RotatedPillarBlock.class, org.bukkit.craftbukkit.block.impl.CraftRotatable::new);
register(net.minecraft.world.level.block.SaplingBlock.class, org.bukkit.craftbukkit.block.impl.CraftSapling::new);
register(net.minecraft.world.level.block.ScaffoldingBlock.class, org.bukkit.craftbukkit.block.impl.CraftScaffolding::new);
register(net.minecraft.world.level.block.SeaPickleBlock.class, org.bukkit.craftbukkit.block.impl.CraftSeaPickle::new);
register(net.minecraft.world.level.block.ShulkerBoxBlock.class, org.bukkit.craftbukkit.block.impl.CraftShulkerBox::new);
register(net.minecraft.world.level.block.SkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftSkull::new);
register(net.minecraft.world.level.block.PlayerHeadBlock.class, org.bukkit.craftbukkit.block.impl.CraftSkullPlayer::new);
register(net.minecraft.world.level.block.PlayerWallHeadBlock.class, org.bukkit.craftbukkit.block.impl.CraftSkullPlayerWall::new);
register(net.minecraft.world.level.block.WallSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftSkullWall::new);
register(net.minecraft.world.level.block.SmokerBlock.class, org.bukkit.craftbukkit.block.impl.CraftSmoker::new);
register(net.minecraft.world.level.block.SnowLayerBlock.class, org.bukkit.craftbukkit.block.impl.CraftSnow::new);
register(net.minecraft.world.level.block.FarmBlock.class, org.bukkit.craftbukkit.block.impl.CraftSoil::new);
register(net.minecraft.world.level.block.StainedGlassPaneBlock.class, org.bukkit.craftbukkit.block.impl.CraftStainedGlassPane::new);
register(net.minecraft.world.level.block.StairBlock.class, org.bukkit.craftbukkit.block.impl.CraftStairs::new);
register(net.minecraft.world.level.block.StemBlock.class, org.bukkit.craftbukkit.block.impl.CraftStem::new);
register(net.minecraft.world.level.block.AttachedStemBlock.class, org.bukkit.craftbukkit.block.impl.CraftStemAttached::new);
register(net.minecraft.world.level.block.SlabBlock.class, org.bukkit.craftbukkit.block.impl.CraftStepAbstract::new);
register(net.minecraft.world.level.block.StonecutterBlock.class, org.bukkit.craftbukkit.block.impl.CraftStonecutter::new);
register(net.minecraft.world.level.block.StructureBlock.class, org.bukkit.craftbukkit.block.impl.CraftStructure::new);
register(net.minecraft.world.level.block.SweetBerryBushBlock.class, org.bukkit.craftbukkit.block.impl.CraftSweetBerryBush::new);
register(net.minecraft.world.level.block.TntBlock.class, org.bukkit.craftbukkit.block.impl.CraftTNT::new);
register(net.minecraft.world.level.block.DoublePlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallPlant::new);
register(net.minecraft.world.level.block.TallFlowerBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallPlantFlower::new);
register(net.minecraft.world.level.block.TargetBlock.class, org.bukkit.craftbukkit.block.impl.CraftTarget::new);
register(net.minecraft.world.level.block.WallTorchBlock.class, org.bukkit.craftbukkit.block.impl.CraftTorchWall::new);
register(net.minecraft.world.level.block.TrapDoorBlock.class, org.bukkit.craftbukkit.block.impl.CraftTrapdoor::new);
register(net.minecraft.world.level.block.TripWireBlock.class, org.bukkit.craftbukkit.block.impl.CraftTripwire::new);
register(net.minecraft.world.level.block.TripWireHookBlock.class, org.bukkit.craftbukkit.block.impl.CraftTripwireHook::new);
register(net.minecraft.world.level.block.TurtleEggBlock.class, org.bukkit.craftbukkit.block.impl.CraftTurtleEgg::new);
register(net.minecraft.world.level.block.TwistingVinesBlock.class, org.bukkit.craftbukkit.block.impl.CraftTwistingVines::new);
register(net.minecraft.world.level.block.VineBlock.class, org.bukkit.craftbukkit.block.impl.CraftVine::new);
register(net.minecraft.world.level.block.WallSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallSign::new);
register(net.minecraft.world.level.block.WeepingVinesBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeepingVines::new);
register(net.minecraft.world.level.block.WitherSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkull::new);
register(net.minecraft.world.level.block.WitherWallSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkullWall::new);
register(net.minecraft.world.level.block.BrushableBlock.class, org.bukkit.craftbukkit.block.impl.CraftBrushable::new);
register(net.minecraft.world.level.block.CalibratedSculkSensorBlock.class, org.bukkit.craftbukkit.block.impl.CraftCalibratedSculkSensor::new);
register(net.minecraft.world.level.block.CandleBlock.class, org.bukkit.craftbukkit.block.impl.CraftCandle::new);
@@ -540,20 +538,20 @@ public class CraftBlockData implements BlockData {
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);
register(net.minecraft.world.level.block.WeatheringCopperTrapDoorBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperTrapDoor::new);
register(net.minecraft.world.level.block.piston.BlockPiston.class, org.bukkit.craftbukkit.block.impl.CraftPiston::new);
register(net.minecraft.world.level.block.piston.BlockPistonExtension.class, org.bukkit.craftbukkit.block.impl.CraftPistonExtension::new);
register(net.minecraft.world.level.block.piston.BlockPistonMoving.class, org.bukkit.craftbukkit.block.impl.CraftPistonMoving::new);
register(net.minecraft.world.level.block.piston.PistonBaseBlock.class, org.bukkit.craftbukkit.block.impl.CraftPiston::new);
register(net.minecraft.world.level.block.piston.PistonHeadBlock.class, org.bukkit.craftbukkit.block.impl.CraftPistonExtension::new);
register(net.minecraft.world.level.block.piston.MovingPistonBlock.class, org.bukkit.craftbukkit.block.impl.CraftPistonMoving::new);
//</editor-fold>
}
private static void register(Class<? extends Block> nms, Function<IBlockData, CraftBlockData> bukkit) {
Preconditions.checkState(MAP.put(nms, bukkit) == null, "Duplicate mapping %s->%s", nms, bukkit);
private static void register(Class<? extends Block> nms, Function<net.minecraft.world.level.block.state.BlockState, CraftBlockData> bukkit) {
Preconditions.checkState(CraftBlockData.MAP.put(nms, bukkit) == null, "Duplicate mapping %s->%s", nms, bukkit);
}
public static CraftBlockData newData(BlockType blockType, String data) {
IBlockData blockData;
net.minecraft.world.level.block.state.BlockState blockData;
Block block = blockType == null ? null : ((CraftBlockType<?>) blockType).getHandle();
Map<IBlockState<?>, Comparable<?>> parsed = null;
Map<Property<?>, Comparable<?>> parsed = null;
// Data provided, use it
if (data != null) {
@@ -564,7 +562,7 @@ public class CraftBlockData implements BlockData {
}
StringReader reader = new StringReader(data);
ArgumentBlock.a arg = ArgumentBlock.parseForBlock(CraftRegistry.getMinecraftRegistry(Registries.BLOCK), reader, false);
BlockStateParser.BlockResult arg = BlockStateParser.parseForBlock(CraftRegistry.getMinecraftRegistry(Registries.BLOCK), reader, false);
Preconditions.checkArgument(!reader.canRead(), "Spurious trailing data: " + data);
blockData = arg.blockState();
@@ -576,33 +574,33 @@ public class CraftBlockData implements BlockData {
blockData = block.defaultBlockState();
}
CraftBlockData craft = fromData(blockData);
CraftBlockData craft = CraftBlockData.fromData(blockData);
craft.parsedStates = parsed;
return craft;
}
public static CraftBlockData fromData(IBlockData data) {
return MAP.getOrDefault(data.getBlock().getClass(), CraftBlockData::new).apply(data);
public static CraftBlockData fromData(net.minecraft.world.level.block.state.BlockState data) {
return CraftBlockData.MAP.getOrDefault(data.getBlock().getClass(), CraftBlockData::new).apply(data);
}
@Override
public SoundGroup getSoundGroup() {
return CraftSoundGroup.getSoundGroup(state.getSoundType());
return CraftSoundGroup.getSoundGroup(this.state.getSoundType());
}
@Override
public int getLightEmission() {
return state.getLightEmission();
return this.state.getLightEmission();
}
@Override
public boolean isOccluding() {
return state.canOcclude();
return this.state.canOcclude();
}
@Override
public boolean requiresCorrectToolForDrops() {
return state.requiresCorrectToolForDrops();
return this.state.requiresCorrectToolForDrops();
}
@Override
@@ -610,16 +608,16 @@ public class CraftBlockData implements BlockData {
Preconditions.checkArgument(tool != null, "tool must not be null");
net.minecraft.world.item.ItemStack nms = CraftItemStack.asNMSCopy(tool);
return isPreferredTool(state, nms);
return CraftBlockData.isPreferredTool(this.state, nms);
}
public static boolean isPreferredTool(IBlockData iblockdata, net.minecraft.world.item.ItemStack nmsItem) {
public static boolean isPreferredTool(net.minecraft.world.level.block.state.BlockState iblockdata, net.minecraft.world.item.ItemStack nmsItem) {
return !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata);
}
@Override
public PistonMoveReaction getPistonMoveReaction() {
return PistonMoveReaction.getById(state.getPistonPushReaction().ordinal());
return PistonMoveReaction.getById(this.state.getPistonPushReaction().ordinal());
}
@Override
@@ -627,7 +625,7 @@ public class CraftBlockData implements BlockData {
Preconditions.checkArgument(block != null, "block must not be null");
CraftBlock craftBlock = (CraftBlock) block;
return state.canSurvive(craftBlock.getCraftWorld().getHandle(), craftBlock.getPosition());
return this.state.canSurvive(craftBlock.getCraftWorld().getHandle(), craftBlock.getPosition());
}
@Override
@@ -637,8 +635,8 @@ public class CraftBlockData implements BlockData {
CraftWorld world = (CraftWorld) location.getWorld();
Preconditions.checkArgument(world != null, "location must not have a null world");
BlockPosition position = CraftLocation.toBlockPosition(location);
return state.canSurvive(world.getHandle(), position);
BlockPos position = CraftLocation.toBlockPosition(location);
return this.state.canSurvive(world.getHandle(), position);
}
@Override
@@ -646,43 +644,43 @@ public class CraftBlockData implements BlockData {
Preconditions.checkArgument(face != null, "face must not be null");
Preconditions.checkArgument(support != null, "support must not be null");
return state.isFaceSturdy(BlockAccessAir.INSTANCE, BlockPosition.ZERO, CraftBlock.blockFaceToNotch(face), CraftBlockSupport.toNMS(support));
return this.state.isFaceSturdy(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CraftBlock.blockFaceToNotch(face), CraftBlockSupport.toNMS(support));
}
@Override
public Color getMapColor() {
return Color.fromRGB(state.getMapColor(null, null).col);
return Color.fromRGB(this.state.getMapColor(null, null).col);
}
@Override
public Material getPlacementMaterial() {
return CraftItemType.minecraftToBukkit(state.getBlock().asItem());
return CraftItemType.minecraftToBukkit(this.state.getBlock().asItem());
}
@Override
public void rotate(StructureRotation rotation) {
this.state = state.rotate(EnumBlockRotation.valueOf(rotation.name()));
this.state = this.state.rotate(Rotation.valueOf(rotation.name()));
}
@Override
public void mirror(Mirror mirror) {
this.state = state.mirror(EnumBlockMirror.valueOf(mirror.name()));
this.state = this.state.mirror(net.minecraft.world.level.block.Mirror.valueOf(mirror.name()));
}
@Override
public void copyTo(BlockData blockData) {
CraftBlockData other = (CraftBlockData) blockData;
IBlockData nms = other.state;
for (IBlockState<?> property : state.getBlock().getStateDefinition().getProperties()) {
net.minecraft.world.level.block.state.BlockState nms = other.state;
for (Property<?> property : this.state.getBlock().getStateDefinition().getProperties()) {
if (nms.hasProperty(property)) {
nms = copyProperty(state, nms, property);
nms = this.copyProperty(this.state, nms, property);
}
}
other.state = nms;
}
private <T extends Comparable<T>> IBlockData copyProperty(IBlockData source, IBlockData target, IBlockState<T> property) {
private <T extends Comparable<T>> net.minecraft.world.level.block.state.BlockState copyProperty(net.minecraft.world.level.block.state.BlockState source, net.minecraft.world.level.block.state.BlockState target, Property<T> property) {
return target.setValue(property, source.getValue(property));
}

View File

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

View File

@@ -4,20 +4,20 @@ import org.bukkit.block.data.Directional;
public abstract class CraftDirectional extends CraftBlockData implements Directional {
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> FACING = getEnum("facing");
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> FACING = getEnum("facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
return this.get(CraftDirectional.FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
this.set(CraftDirectional.FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
return this.getValues(CraftDirectional.FACING, org.bukkit.block.BlockFace.class);
}
}

View File

@@ -4,15 +4,15 @@ import org.bukkit.block.data.FaceAttachable;
public abstract class CraftFaceAttachable extends CraftBlockData implements FaceAttachable {
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> ATTACH_FACE = getEnum("face");
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> ATTACH_FACE = getEnum("face");
@Override
public org.bukkit.block.data.FaceAttachable.AttachedFace getAttachedFace() {
return get(ATTACH_FACE, org.bukkit.block.data.FaceAttachable.AttachedFace.class);
return this.get(CraftFaceAttachable.ATTACH_FACE, org.bukkit.block.data.FaceAttachable.AttachedFace.class);
}
@Override
public void setAttachedFace(org.bukkit.block.data.FaceAttachable.AttachedFace face) {
set(ATTACH_FACE, face);
this.set(CraftFaceAttachable.ATTACH_FACE, face);
}
}

View File

@@ -4,15 +4,15 @@ import org.bukkit.block.data.Hangable;
public abstract class CraftHangable extends CraftBlockData implements Hangable {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean HANGING = getBoolean("hanging");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty HANGING = getBoolean("hanging");
@Override
public boolean isHanging() {
return get(HANGING);
return this.get(CraftHangable.HANGING);
}
@Override
public void setHanging(boolean hanging) {
set(HANGING, hanging);
this.set(CraftHangable.HANGING, hanging);
}
}

View File

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

View File

@@ -4,20 +4,20 @@ import org.bukkit.block.data.Levelled;
public abstract class CraftLevelled extends CraftBlockData implements Levelled {
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger LEVEL = getInteger("level");
private static final net.minecraft.world.level.block.state.properties.IntegerProperty LEVEL = getInteger("level");
@Override
public int getLevel() {
return get(LEVEL);
return this.get(CraftLevelled.LEVEL);
}
@Override
public void setLevel(int level) {
set(LEVEL, level);
this.set(CraftLevelled.LEVEL, level);
}
@Override
public int getMaximumLevel() {
return getMax(LEVEL);
return getMax(CraftLevelled.LEVEL);
}
}

View File

@@ -4,15 +4,15 @@ import org.bukkit.block.data.Lightable;
public abstract class CraftLightable extends CraftBlockData implements Lightable {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean LIT = getBoolean("lit");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty LIT = getBoolean("lit");
@Override
public boolean isLit() {
return get(LIT);
return this.get(CraftLightable.LIT);
}
@Override
public void setLit(boolean lit) {
set(LIT, lit);
this.set(CraftLightable.LIT, lit);
}
}

View File

@@ -4,34 +4,34 @@ import org.bukkit.block.data.MultipleFacing;
public abstract class CraftMultipleFacing extends CraftBlockData implements MultipleFacing {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean[] FACES = new net.minecraft.world.level.block.state.properties.BlockStateBoolean[]{
private static final net.minecraft.world.level.block.state.properties.BooleanProperty[] FACES = new net.minecraft.world.level.block.state.properties.BooleanProperty[]{
getBoolean("north", true), getBoolean("east", true), getBoolean("south", true), getBoolean("west", true), getBoolean("up", true), getBoolean("down", true)
};
@Override
public boolean hasFace(org.bukkit.block.BlockFace face) {
net.minecraft.world.level.block.state.properties.BlockStateBoolean state = FACES[face.ordinal()];
net.minecraft.world.level.block.state.properties.BooleanProperty state = CraftMultipleFacing.FACES[face.ordinal()];
if (state == null) {
throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces.");
}
return get(state);
return this.get(state);
}
@Override
public void setFace(org.bukkit.block.BlockFace face, boolean has) {
net.minecraft.world.level.block.state.properties.BlockStateBoolean state = FACES[face.ordinal()];
net.minecraft.world.level.block.state.properties.BooleanProperty state = CraftMultipleFacing.FACES[face.ordinal()];
if (state == null) {
throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces.");
}
set(state, has);
this.set(state, has);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
com.google.common.collect.ImmutableSet.Builder<org.bukkit.block.BlockFace> faces = com.google.common.collect.ImmutableSet.builder();
for (int i = 0; i < FACES.length; i++) {
if (FACES[i] != null && get(FACES[i])) {
for (int i = 0; i < CraftMultipleFacing.FACES.length; i++) {
if (CraftMultipleFacing.FACES[i] != null && this.get(CraftMultipleFacing.FACES[i])) {
faces.add(org.bukkit.block.BlockFace.values()[i]);
}
}
@@ -43,8 +43,8 @@ public abstract class CraftMultipleFacing extends CraftBlockData implements Mult
public java.util.Set<org.bukkit.block.BlockFace> getAllowedFaces() {
com.google.common.collect.ImmutableSet.Builder<org.bukkit.block.BlockFace> faces = com.google.common.collect.ImmutableSet.builder();
for (int i = 0; i < FACES.length; i++) {
if (FACES[i] != null) {
for (int i = 0; i < CraftMultipleFacing.FACES.length; i++) {
if (CraftMultipleFacing.FACES[i] != null) {
faces.add(org.bukkit.block.BlockFace.values()[i]);
}
}

View File

@@ -4,15 +4,15 @@ import org.bukkit.block.data.Openable;
public abstract class CraftOpenable extends CraftBlockData implements Openable {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean OPEN = getBoolean("open");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty OPEN = getBoolean("open");
@Override
public boolean isOpen() {
return get(OPEN);
return this.get(CraftOpenable.OPEN);
}
@Override
public void setOpen(boolean open) {
set(OPEN, open);
this.set(CraftOpenable.OPEN, open);
}
}

View File

@@ -4,20 +4,20 @@ import org.bukkit.block.data.Orientable;
public class CraftOrientable extends CraftBlockData implements Orientable {
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> AXIS = getEnum("axis");
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> AXIS = getEnum("axis");
@Override
public org.bukkit.Axis getAxis() {
return get(AXIS, org.bukkit.Axis.class);
return this.get(CraftOrientable.AXIS, org.bukkit.Axis.class);
}
@Override
public void setAxis(org.bukkit.Axis axis) {
set(AXIS, axis);
this.set(CraftOrientable.AXIS, axis);
}
@Override
public java.util.Set<org.bukkit.Axis> getAxes() {
return getValues(AXIS, org.bukkit.Axis.class);
return this.getValues(CraftOrientable.AXIS, org.bukkit.Axis.class);
}
}

View File

@@ -4,15 +4,15 @@ import org.bukkit.block.data.Powerable;
public abstract class CraftPowerable extends CraftBlockData implements Powerable {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean POWERED = getBoolean("powered");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty POWERED = getBoolean("powered");
@Override
public boolean isPowered() {
return get(POWERED);
return this.get(CraftPowerable.POWERED);
}
@Override
public void setPowered(boolean powered) {
set(POWERED, powered);
this.set(CraftPowerable.POWERED, powered);
}
}

View File

@@ -4,20 +4,20 @@ import org.bukkit.block.data.Rail;
public abstract class CraftRail extends CraftBlockData implements Rail {
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> SHAPE = getEnum("shape");
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> SHAPE = getEnum("shape");
@Override
public org.bukkit.block.data.Rail.Shape getShape() {
return get(SHAPE, org.bukkit.block.data.Rail.Shape.class);
return this.get(CraftRail.SHAPE, org.bukkit.block.data.Rail.Shape.class);
}
@Override
public void setShape(org.bukkit.block.data.Rail.Shape shape) {
set(SHAPE, shape);
this.set(CraftRail.SHAPE, shape);
}
@Override
public java.util.Set<org.bukkit.block.data.Rail.Shape> getShapes() {
return getValues(SHAPE, org.bukkit.block.data.Rail.Shape.class);
return this.getValues(CraftRail.SHAPE, org.bukkit.block.data.Rail.Shape.class);
}
}

View File

@@ -4,11 +4,11 @@ import org.bukkit.block.data.Rotatable;
public abstract class CraftRotatable extends CraftBlockData implements Rotatable {
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger ROTATION = getInteger("rotation");
private static final net.minecraft.world.level.block.state.properties.IntegerProperty ROTATION = getInteger("rotation");
@Override
public org.bukkit.block.BlockFace getRotation() {
int data = get(ROTATION);
int data = this.get(CraftRotatable.ROTATION);
switch (data) {
case 0x0:
return org.bukkit.block.BlockFace.SOUTH;
@@ -102,6 +102,6 @@ public abstract class CraftRotatable extends CraftBlockData implements Rotatable
default:
throw new IllegalArgumentException("Illegal rotation " + rotation);
}
set(ROTATION, val);
this.set(CraftRotatable.ROTATION, val);
}
}

View File

@@ -4,15 +4,15 @@ import org.bukkit.block.data.Snowable;
public abstract class CraftSnowable extends CraftBlockData implements Snowable {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean SNOWY = getBoolean("snowy");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty SNOWY = getBoolean("snowy");
@Override
public boolean isSnowy() {
return get(SNOWY);
return this.get(CraftSnowable.SNOWY);
}
@Override
public void setSnowy(boolean snowy) {
set(SNOWY, snowy);
this.set(CraftSnowable.SNOWY, snowy);
}
}

View File

@@ -4,15 +4,15 @@ import org.bukkit.block.data.Waterlogged;
public abstract class CraftWaterlogged extends CraftBlockData implements Waterlogged {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean("waterlogged");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty WATERLOGGED = getBoolean("waterlogged");
@Override
public boolean isWaterlogged() {
return get(WATERLOGGED);
return this.get(CraftWaterlogged.WATERLOGGED);
}
@Override
public void setWaterlogged(boolean waterlogged) {
set(WATERLOGGED, waterlogged);
this.set(CraftWaterlogged.WATERLOGGED, waterlogged);
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftBamboo extends CraftBlockData implements Bamboo {
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> LEAVES = getEnum("leaves");
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> LEAVES = getEnum("leaves");
@Override
public org.bukkit.block.data.type.Bamboo.Leaves getLeaves() {
return get(LEAVES, org.bukkit.block.data.type.Bamboo.Leaves.class);
return this.get(CraftBamboo.LEAVES, org.bukkit.block.data.type.Bamboo.Leaves.class);
}
@Override
public void setLeaves(org.bukkit.block.data.type.Bamboo.Leaves leaves) {
set(LEAVES, leaves);
this.set(CraftBamboo.LEAVES, leaves);
}
}

View File

@@ -5,21 +5,21 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftBed extends CraftBlockData implements Bed {
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> PART = getEnum("part");
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean OCCUPIED = getBoolean("occupied");
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> PART = getEnum("part");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty OCCUPIED = getBoolean("occupied");
@Override
public org.bukkit.block.data.type.Bed.Part getPart() {
return get(PART, org.bukkit.block.data.type.Bed.Part.class);
return this.get(CraftBed.PART, org.bukkit.block.data.type.Bed.Part.class);
}
@Override
public void setPart(org.bukkit.block.data.type.Bed.Part part) {
set(PART, part);
this.set(CraftBed.PART, part);
}
@Override
public boolean isOccupied() {
return get(OCCUPIED);
return this.get(CraftBed.OCCUPIED);
}
}

View File

@@ -5,20 +5,20 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftBeehive extends CraftBlockData implements Beehive {
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger HONEY_LEVEL = getInteger("honey_level");
private static final net.minecraft.world.level.block.state.properties.IntegerProperty HONEY_LEVEL = getInteger("honey_level");
@Override
public int getHoneyLevel() {
return get(HONEY_LEVEL);
return this.get(CraftBeehive.HONEY_LEVEL);
}
@Override
public void setHoneyLevel(int honeyLevel) {
set(HONEY_LEVEL, honeyLevel);
this.set(CraftBeehive.HONEY_LEVEL, honeyLevel);
}
@Override
public int getMaximumHoneyLevel() {
return getMax(HONEY_LEVEL);
return getMax(CraftBeehive.HONEY_LEVEL);
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftBell extends CraftBlockData implements Bell {
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> ATTACHMENT = getEnum("attachment");
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> ATTACHMENT = getEnum("attachment");
@Override
public org.bukkit.block.data.type.Bell.Attachment getAttachment() {
return get(ATTACHMENT, org.bukkit.block.data.type.Bell.Attachment.class);
return this.get(CraftBell.ATTACHMENT, org.bukkit.block.data.type.Bell.Attachment.class);
}
@Override
public void setAttachment(org.bukkit.block.data.type.Bell.Attachment leaves) {
set(ATTACHMENT, leaves);
this.set(CraftBell.ATTACHMENT, leaves);
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftBigDripleaf extends CraftBlockData implements BigDripleaf {
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> TILT = getEnum("tilt");
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> TILT = getEnum("tilt");
@Override
public Tilt getTilt() {
return get(TILT, org.bukkit.block.data.type.BigDripleaf.Tilt.class);
return this.get(CraftBigDripleaf.TILT, org.bukkit.block.data.type.BigDripleaf.Tilt.class);
}
@Override
public void setTilt(org.bukkit.block.data.type.BigDripleaf.Tilt tilt) {
set(TILT, tilt);
this.set(CraftBigDripleaf.TILT, tilt);
}
}

View File

@@ -5,26 +5,26 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftBrewingStand extends CraftBlockData implements BrewingStand {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean[] HAS_BOTTLE = new net.minecraft.world.level.block.state.properties.BlockStateBoolean[]{
private static final net.minecraft.world.level.block.state.properties.BooleanProperty[] HAS_BOTTLE = new net.minecraft.world.level.block.state.properties.BooleanProperty[]{
getBoolean("has_bottle_0"), getBoolean("has_bottle_1"), getBoolean("has_bottle_2")
};
@Override
public boolean hasBottle(int bottle) {
return get(HAS_BOTTLE[bottle]);
return this.get(CraftBrewingStand.HAS_BOTTLE[bottle]);
}
@Override
public void setBottle(int bottle, boolean has) {
set(HAS_BOTTLE[bottle], has);
this.set(CraftBrewingStand.HAS_BOTTLE[bottle], has);
}
@Override
public java.util.Set<Integer> getBottles() {
com.google.common.collect.ImmutableSet.Builder<Integer> bottles = com.google.common.collect.ImmutableSet.builder();
for (int index = 0; index < getMaximumBottles(); index++) {
if (hasBottle(index)) {
for (int index = 0; index < this.getMaximumBottles(); index++) {
if (this.hasBottle(index)) {
bottles.add(index);
}
}
@@ -34,6 +34,6 @@ public abstract class CraftBrewingStand extends CraftBlockData implements Brewin
@Override
public int getMaximumBottles() {
return HAS_BOTTLE.length;
return CraftBrewingStand.HAS_BOTTLE.length;
}
}

View File

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

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftBubbleColumn extends CraftBlockData implements BubbleColumn {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean DRAG = getBoolean("drag");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty DRAG = getBoolean("drag");
@Override
public boolean isDrag() {
return get(DRAG);
return this.get(CraftBubbleColumn.DRAG);
}
@Override
public void setDrag(boolean drag) {
set(DRAG, drag);
this.set(CraftBubbleColumn.DRAG, drag);
}
}

View File

@@ -5,20 +5,20 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftCake extends CraftBlockData implements Cake {
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger BITES = getInteger("bites");
private static final net.minecraft.world.level.block.state.properties.IntegerProperty BITES = getInteger("bites");
@Override
public int getBites() {
return get(BITES);
return this.get(CraftCake.BITES);
}
@Override
public void setBites(int bites) {
set(BITES, bites);
this.set(CraftCake.BITES, bites);
}
@Override
public int getMaximumBites() {
return getMax(BITES);
return getMax(CraftCake.BITES);
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftCampfire extends CraftBlockData implements Campfire {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean SIGNAL_FIRE = getBoolean("signal_fire");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty SIGNAL_FIRE = getBoolean("signal_fire");
@Override
public boolean isSignalFire() {
return get(SIGNAL_FIRE);
return this.get(CraftCampfire.SIGNAL_FIRE);
}
@Override
public void setSignalFire(boolean signalFire) {
set(SIGNAL_FIRE, signalFire);
this.set(CraftCampfire.SIGNAL_FIRE, signalFire);
}
}

View File

@@ -5,20 +5,20 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftCandle extends CraftBlockData implements Candle {
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger CANDLES = getInteger("candles");
private static final net.minecraft.world.level.block.state.properties.IntegerProperty CANDLES = getInteger("candles");
@Override
public int getCandles() {
return get(CANDLES);
return this.get(CraftCandle.CANDLES);
}
@Override
public void setCandles(int candles) {
set(CANDLES, candles);
this.set(CraftCandle.CANDLES, candles);
}
@Override
public int getMaximumCandles() {
return getMax(CANDLES);
return getMax(CraftCandle.CANDLES);
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftCaveVinesPlant extends CraftBlockData implements CaveVinesPlant {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean BERRIES = getBoolean("berries");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty BERRIES = getBoolean("berries");
@Override
public boolean isBerries() {
return get(BERRIES);
return this.get(CraftCaveVinesPlant.BERRIES);
}
@Override
public void setBerries(boolean berries) {
set(BERRIES, berries);
this.set(CraftCaveVinesPlant.BERRIES, berries);
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftChest extends CraftBlockData implements Chest {
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> TYPE = getEnum("type");
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> TYPE = getEnum("type");
@Override
public org.bukkit.block.data.type.Chest.Type getType() {
return get(TYPE, org.bukkit.block.data.type.Chest.Type.class);
return this.get(CraftChest.TYPE, org.bukkit.block.data.type.Chest.Type.class);
}
@Override
public void setType(org.bukkit.block.data.type.Chest.Type type) {
set(TYPE, type);
this.set(CraftChest.TYPE, type);
}
}

View File

@@ -5,27 +5,27 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftChiseledBookshelf extends CraftBlockData implements ChiseledBookshelf {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean[] SLOT_OCCUPIED = new net.minecraft.world.level.block.state.properties.BlockStateBoolean[]{
private static final net.minecraft.world.level.block.state.properties.BooleanProperty[] SLOT_OCCUPIED = new net.minecraft.world.level.block.state.properties.BooleanProperty[]{
getBoolean("slot_0_occupied"), getBoolean("slot_1_occupied"), getBoolean("slot_2_occupied"),
getBoolean("slot_3_occupied"), getBoolean("slot_4_occupied"), getBoolean("slot_5_occupied")
};
@Override
public boolean isSlotOccupied(int slot) {
return get(SLOT_OCCUPIED[slot]);
return this.get(CraftChiseledBookshelf.SLOT_OCCUPIED[slot]);
}
@Override
public void setSlotOccupied(int slot, boolean has) {
set(SLOT_OCCUPIED[slot], has);
this.set(CraftChiseledBookshelf.SLOT_OCCUPIED[slot], has);
}
@Override
public java.util.Set<Integer> getOccupiedSlots() {
com.google.common.collect.ImmutableSet.Builder<Integer> slots = com.google.common.collect.ImmutableSet.builder();
for (int index = 0; index < getMaximumOccupiedSlots(); index++) {
if (isSlotOccupied(index)) {
for (int index = 0; index < this.getMaximumOccupiedSlots(); index++) {
if (this.isSlotOccupied(index)) {
slots.add(index);
}
}
@@ -35,6 +35,6 @@ public abstract class CraftChiseledBookshelf extends CraftBlockData implements C
@Override
public int getMaximumOccupiedSlots() {
return SLOT_OCCUPIED.length;
return CraftChiseledBookshelf.SLOT_OCCUPIED.length;
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftCommandBlock extends CraftBlockData implements CommandBlock {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean CONDITIONAL = getBoolean("conditional");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty CONDITIONAL = getBoolean("conditional");
@Override
public boolean isConditional() {
return get(CONDITIONAL);
return this.get(CraftCommandBlock.CONDITIONAL);
}
@Override
public void setConditional(boolean conditional) {
set(CONDITIONAL, conditional);
this.set(CraftCommandBlock.CONDITIONAL, conditional);
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftComparator extends CraftBlockData implements Comparator {
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> MODE = getEnum("mode");
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> MODE = getEnum("mode");
@Override
public org.bukkit.block.data.type.Comparator.Mode getMode() {
return get(MODE, org.bukkit.block.data.type.Comparator.Mode.class);
return this.get(CraftComparator.MODE, org.bukkit.block.data.type.Comparator.Mode.class);
}
@Override
public void setMode(org.bukkit.block.data.type.Comparator.Mode mode) {
set(MODE, mode);
this.set(CraftComparator.MODE, mode);
}
}

View File

@@ -5,37 +5,37 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftCrafter extends CraftBlockData implements Crafter {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean CRAFTING = getBoolean("crafting");
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean TRIGGERED = getBoolean("triggered");
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> ORIENTATION = getEnum("orientation");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty CRAFTING = getBoolean("crafting");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty TRIGGERED = getBoolean("triggered");
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> ORIENTATION = getEnum("orientation");
@Override
public boolean isCrafting() {
return get(CRAFTING);
return this.get(CraftCrafter.CRAFTING);
}
@Override
public void setCrafting(boolean crafting) {
set(CRAFTING, crafting);
this.set(CraftCrafter.CRAFTING, crafting);
}
@Override
public boolean isTriggered() {
return get(TRIGGERED);
return this.get(CraftCrafter.TRIGGERED);
}
@Override
public void setTriggered(boolean triggered) {
set(TRIGGERED, triggered);
this.set(CraftCrafter.TRIGGERED, triggered);
}
@Override
public org.bukkit.block.data.type.Crafter.Orientation getOrientation() {
return get(ORIENTATION, org.bukkit.block.data.type.Crafter.Orientation.class);
return this.get(CraftCrafter.ORIENTATION, org.bukkit.block.data.type.Crafter.Orientation.class);
}
@Override
public void setOrientation(org.bukkit.block.data.type.Crafter.Orientation orientation) {
set(ORIENTATION, orientation);
this.set(CraftCrafter.ORIENTATION, orientation);
}
}

View File

@@ -5,26 +5,26 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftCreakingHeart extends CraftBlockData implements CreakingHeart {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean ACTIVE = getBoolean("active");
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean NATURAL = getBoolean("natural");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty ACTIVE = getBoolean("active");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty NATURAL = getBoolean("natural");
@Override
public boolean isActive() {
return get(ACTIVE);
return this.get(CraftCreakingHeart.ACTIVE);
}
@Override
public void setActive(boolean active) {
set(ACTIVE, active);
this.set(CraftCreakingHeart.ACTIVE, active);
}
@Override
public boolean isNatural() {
return get(NATURAL);
return this.get(CraftCreakingHeart.NATURAL);
}
@Override
public void setNatural(boolean natural) {
set(NATURAL, natural);
this.set(CraftCreakingHeart.NATURAL, natural);
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftDaylightDetector extends CraftBlockData implements DaylightDetector {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean INVERTED = getBoolean("inverted");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty INVERTED = getBoolean("inverted");
@Override
public boolean isInverted() {
return get(INVERTED);
return this.get(CraftDaylightDetector.INVERTED);
}
@Override
public void setInverted(boolean inverted) {
set(INVERTED, inverted);
this.set(CraftDaylightDetector.INVERTED, inverted);
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftDispenser extends CraftBlockData implements Dispenser {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean TRIGGERED = getBoolean("triggered");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty TRIGGERED = getBoolean("triggered");
@Override
public boolean isTriggered() {
return get(TRIGGERED);
return this.get(CraftDispenser.TRIGGERED);
}
@Override
public void setTriggered(boolean triggered) {
set(TRIGGERED, triggered);
this.set(CraftDispenser.TRIGGERED, triggered);
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftDoor extends CraftBlockData implements Door {
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> HINGE = getEnum("hinge");
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> HINGE = getEnum("hinge");
@Override
public org.bukkit.block.data.type.Door.Hinge getHinge() {
return get(HINGE, org.bukkit.block.data.type.Door.Hinge.class);
return this.get(CraftDoor.HINGE, org.bukkit.block.data.type.Door.Hinge.class);
}
@Override
public void setHinge(org.bukkit.block.data.type.Door.Hinge hinge) {
set(HINGE, hinge);
this.set(CraftDoor.HINGE, hinge);
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftEndPortalFrame extends CraftBlockData implements EndPortalFrame {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean EYE = getBoolean("eye");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty EYE = getBoolean("eye");
@Override
public boolean hasEye() {
return get(EYE);
return this.get(CraftEndPortalFrame.EYE);
}
@Override
public void setEye(boolean eye) {
set(EYE, eye);
this.set(CraftEndPortalFrame.EYE, eye);
}
}

View File

@@ -5,20 +5,20 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftFarmland extends CraftBlockData implements Farmland {
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger MOISTURE = getInteger("moisture");
private static final net.minecraft.world.level.block.state.properties.IntegerProperty MOISTURE = getInteger("moisture");
@Override
public int getMoisture() {
return get(MOISTURE);
return this.get(CraftFarmland.MOISTURE);
}
@Override
public void setMoisture(int moisture) {
set(MOISTURE, moisture);
this.set(CraftFarmland.MOISTURE, moisture);
}
@Override
public int getMaximumMoisture() {
return getMax(MOISTURE);
return getMax(CraftFarmland.MOISTURE);
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftGate extends CraftBlockData implements Gate {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean IN_WALL = getBoolean("in_wall");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty IN_WALL = getBoolean("in_wall");
@Override
public boolean isInWall() {
return get(IN_WALL);
return this.get(CraftGate.IN_WALL);
}
@Override
public void setInWall(boolean inWall) {
set(IN_WALL, inWall);
this.set(CraftGate.IN_WALL, inWall);
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftHangingMoss extends CraftBlockData implements HangingMoss {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean TIP = getBoolean("tip");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty TIP = getBoolean("tip");
@Override
public boolean isTip() {
return get(TIP);
return this.get(CraftHangingMoss.TIP);
}
@Override
public void setTip(boolean tip) {
set(TIP, tip);
this.set(CraftHangingMoss.TIP, tip);
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftHopper extends CraftBlockData implements Hopper {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean ENABLED = getBoolean("enabled");
private static final net.minecraft.world.level.block.state.properties.BooleanProperty ENABLED = getBoolean("enabled");
@Override
public boolean isEnabled() {
return get(ENABLED);
return this.get(CraftHopper.ENABLED);
}
@Override
public void setEnabled(boolean enabled) {
set(ENABLED, enabled);
this.set(CraftHopper.ENABLED, enabled);
}
}

View File

@@ -5,15 +5,15 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftJigsaw extends CraftBlockData implements Jigsaw {
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> ORIENTATION = getEnum("orientation");
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> ORIENTATION = getEnum("orientation");
@Override
public org.bukkit.block.data.type.Jigsaw.Orientation getOrientation() {
return get(ORIENTATION, org.bukkit.block.data.type.Jigsaw.Orientation.class);
return this.get(CraftJigsaw.ORIENTATION, org.bukkit.block.data.type.Jigsaw.Orientation.class);
}
@Override
public void setOrientation(org.bukkit.block.data.type.Jigsaw.Orientation orientation) {
set(ORIENTATION, orientation);
this.set(CraftJigsaw.ORIENTATION, orientation);
}
}

Some files were not shown because too many files have changed in this diff Show More