1.21.5
Co-authored-by: Bjarne Koll <git@lynxplay.dev> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: MiniDigger | Martin <admin@minidigger.dev> Co-authored-by: Nassim Jahnke <nassim@njahnke.dev> Co-authored-by: Noah van der Aa <ndvdaa@gmail.com> Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Co-authored-by: Shane Freeder <theboyetronic@gmail.com> Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com> Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com> Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
This commit is contained in:
@@ -5,24 +5,23 @@ import net.minecraft.util.RandomSource;
|
||||
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 net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public final class CapturedBlockState extends CraftBlockState {
|
||||
|
||||
private final boolean treeBlock;
|
||||
|
||||
public CapturedBlockState(Block block, int flag, boolean treeBlock) {
|
||||
super(block, flag);
|
||||
public CapturedBlockState(Block block, int capturedFlags, boolean treeBlock) {
|
||||
super(block, capturedFlags);
|
||||
|
||||
this.treeBlock = treeBlock;
|
||||
}
|
||||
|
||||
protected CapturedBlockState(CapturedBlockState state, Location location) {
|
||||
private CapturedBlockState(CapturedBlockState state, Location location) {
|
||||
super(state, location);
|
||||
this.treeBlock = state.treeBlock;
|
||||
}
|
||||
@@ -31,39 +30,39 @@ public final class CapturedBlockState extends CraftBlockState {
|
||||
public boolean update(boolean force, boolean applyPhysics) {
|
||||
boolean result = super.update(force, applyPhysics);
|
||||
|
||||
// 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.
|
||||
this.addBees();
|
||||
if (result) {
|
||||
this.addBees();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
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
|
||||
this.world.getHandle().setBlock(CraftLocation.toBlockPosition(this.getLocation()), this.getHandle(), this.getFlag());
|
||||
@Override
|
||||
public boolean place(int flags) {
|
||||
boolean result = super.place(flags);
|
||||
|
||||
this.addBees();
|
||||
if (result) {
|
||||
this.addBees();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addBees() {
|
||||
// SPIGOT-5537: Horrible hack to manually add bees given World.captureTreeGeneration does not support tiles
|
||||
// SPIGOT-5537: Horrible hack to manually add bees given Level#captureTreeGeneration does not support block entities
|
||||
if (this.treeBlock && this.getType() == Material.BEE_NEST) {
|
||||
WorldGenLevel generatoraccessseed = this.world.getHandle();
|
||||
BlockPos blockposition1 = this.getPosition();
|
||||
RandomSource random = generatoraccessseed.getRandom();
|
||||
WorldGenLevel worldGenLevel = this.world.getHandle();
|
||||
BlockPos pos = this.getPosition();
|
||||
RandomSource randomSource = worldGenLevel.getRandom();
|
||||
|
||||
// Begin copied block from WorldGenFeatureTreeBeehive
|
||||
BlockEntity tileentity = generatoraccessseed.getBlockEntity(blockposition1);
|
||||
// Begin copied block from BeehiveDecorator
|
||||
worldGenLevel.getBlockEntity(pos, BlockEntityType.BEEHIVE).ifPresent(beehiveBlockEntity -> {
|
||||
int i1 = 2 + randomSource.nextInt(2);
|
||||
|
||||
if (tileentity instanceof BeehiveBlockEntity) {
|
||||
BeehiveBlockEntity tileentitybeehive = (BeehiveBlockEntity) tileentity;
|
||||
int j = 2 + random.nextInt(2);
|
||||
|
||||
for (int k = 0; k < j; ++k) {
|
||||
tileentitybeehive.storeBee(BeehiveBlockEntity.Occupant.create(random.nextInt(599)));
|
||||
for (int i2 = 0; i2 < i1; i2++) {
|
||||
beehiveBlockEntity.storeBee(BeehiveBlockEntity.Occupant.create(randomSource.nextInt(599)));
|
||||
}
|
||||
}
|
||||
});
|
||||
// End copied block
|
||||
}
|
||||
}
|
||||
@@ -78,19 +77,7 @@ public final class CapturedBlockState extends CraftBlockState {
|
||||
return new CapturedBlockState(this, location);
|
||||
}
|
||||
|
||||
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(Level world, BlockPos pos, int flag) {
|
||||
return new CapturedBlockState(world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), flag, true);
|
||||
}
|
||||
|
||||
public static void setBlockState(BlockState blockState) {
|
||||
if (blockState instanceof CapturedBlockState capturedBlockState) {
|
||||
capturedBlockState.updatedTree();
|
||||
} else {
|
||||
blockState.update(true);
|
||||
}
|
||||
return new CapturedBlockState(CraftBlock.at(world, pos), flag, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ public class CraftBanner extends CraftBlockEntityState<BannerBlockEntity> implem
|
||||
private DyeColor base;
|
||||
private List<Pattern> patterns;
|
||||
|
||||
public CraftBanner(World world, BannerBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftBanner(World world, BannerBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftBanner(CraftBanner state, Location location) {
|
||||
@@ -30,21 +30,19 @@ public class CraftBanner extends CraftBlockEntityState<BannerBlockEntity> implem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(BannerBlockEntity banner) {
|
||||
super.load(banner);
|
||||
public void load(BannerBlockEntity blockEntity) {
|
||||
super.load(blockEntity);
|
||||
|
||||
this.base = DyeColor.getByWoolData((byte) ((AbstractBannerBlock) this.data.getBlock()).getColor().getId());
|
||||
this.patterns = new ArrayList<Pattern>();
|
||||
this.patterns = new ArrayList<>();
|
||||
|
||||
if (banner.getPatterns() != null) {
|
||||
for (int i = 0; i < banner.getPatterns().layers().size(); i++) {
|
||||
BannerPatternLayers.Layer p = banner.getPatterns().layers().get(i);
|
||||
// Paper start - fix upstream not handling inlined banner pattern
|
||||
java.util.Optional<org.bukkit.block.banner.PatternType> type = org.bukkit.craftbukkit.CraftRegistry.unwrapAndConvertHolder(RegistryKey.BANNER_PATTERN, p.pattern());
|
||||
if (type.isEmpty()) continue;
|
||||
this.patterns.add(new Pattern(DyeColor.getByWoolData((byte) p.color().getId()), type.get()));
|
||||
// Paper end - fix upstream not handling inlined banner pattern
|
||||
}
|
||||
for (int i = 0; i < blockEntity.getPatterns().layers().size(); i++) {
|
||||
BannerPatternLayers.Layer p = blockEntity.getPatterns().layers().get(i);
|
||||
// Paper start - fix upstream not handling inlined banner pattern
|
||||
java.util.Optional<org.bukkit.block.banner.PatternType> type = org.bukkit.craftbukkit.CraftRegistry.unwrapAndConvertHolder(RegistryKey.BANNER_PATTERN, p.pattern());
|
||||
if (type.isEmpty()) continue;
|
||||
this.patterns.add(new Pattern(DyeColor.getByWoolData((byte) p.color().getId()), type.get()));
|
||||
// Paper end - fix upstream not handling inlined banner pattern
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,17 +93,17 @@ public class CraftBanner extends CraftBlockEntityState<BannerBlockEntity> implem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(BannerBlockEntity banner) {
|
||||
super.applyTo(banner);
|
||||
public void applyTo(BannerBlockEntity blockEntity) {
|
||||
super.applyTo(blockEntity);
|
||||
|
||||
banner.baseColor = net.minecraft.world.item.DyeColor.byId(this.base.getWoolData());
|
||||
blockEntity.baseColor = net.minecraft.world.item.DyeColor.byId(this.base.getWoolData());
|
||||
|
||||
List<BannerPatternLayers.Layer> newPatterns = new ArrayList<>();
|
||||
|
||||
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));
|
||||
blockEntity.setPatterns(new BannerPatternLayers(newPatterns));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,15 +116,14 @@ public class CraftBanner extends CraftBlockEntityState<BannerBlockEntity> implem
|
||||
return new CraftBanner(this, location);
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@Override
|
||||
public net.kyori.adventure.text.Component customName() {
|
||||
return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getSnapshot().getCustomName());
|
||||
return this.getSnapshot().name == null ? null : io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getSnapshot().name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customName(net.kyori.adventure.text.Component customName) {
|
||||
this.getSnapshot().name = io.papermc.paper.adventure.PaperAdventure.asVanilla(customName);
|
||||
this.getSnapshot().name = customName == null ? null : io.papermc.paper.adventure.PaperAdventure.asVanilla(customName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,5 +135,4 @@ public class CraftBanner extends CraftBlockEntityState<BannerBlockEntity> implem
|
||||
public void setCustomName(String name) {
|
||||
this.customName(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserializeOrNull(name));
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftBarrel extends CraftLootable<BarrelBlockEntity> implements Barrel {
|
||||
|
||||
public CraftBarrel(World world, BarrelBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftBarrel(World world, BarrelBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftBarrel(CraftBarrel state, Location location) {
|
||||
@@ -31,37 +31,37 @@ public class CraftBarrel extends CraftLootable<BarrelBlockEntity> implements Bar
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventory(this.getTileEntity());
|
||||
return new CraftInventory(this.getBlockEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
this.requirePlaced();
|
||||
if (!this.getTileEntity().openersCounter.opened) {
|
||||
BlockState blockData = this.getTileEntity().getBlockState();
|
||||
boolean open = blockData.getValue(BarrelBlock.OPEN);
|
||||
if (!this.getBlockEntity().openersCounter.opened) {
|
||||
BlockState state = this.getBlockEntity().getBlockState();
|
||||
boolean open = state.getValue(BarrelBlock.OPEN);
|
||||
|
||||
if (!open) {
|
||||
this.getTileEntity().updateBlockState(blockData, true);
|
||||
this.getBlockEntity().updateBlockState(state, true);
|
||||
if (this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
|
||||
this.getTileEntity().playSound(blockData, SoundEvents.BARREL_OPEN);
|
||||
this.getBlockEntity().playSound(state, SoundEvents.BARREL_OPEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.getTileEntity().openersCounter.opened = true;
|
||||
this.getBlockEntity().openersCounter.opened = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
this.requirePlaced();
|
||||
if (this.getTileEntity().openersCounter.opened) {
|
||||
BlockState blockData = this.getTileEntity().getBlockState();
|
||||
this.getTileEntity().updateBlockState(blockData, false);
|
||||
if (this.getBlockEntity().openersCounter.opened) {
|
||||
BlockState state = this.getBlockEntity().getBlockState();
|
||||
this.getBlockEntity().updateBlockState(state, false);
|
||||
if (this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
|
||||
this.getTileEntity().playSound(blockData, SoundEvents.BARREL_CLOSE);
|
||||
this.getBlockEntity().playSound(state, SoundEvents.BARREL_CLOSE);
|
||||
}
|
||||
}
|
||||
this.getTileEntity().openersCounter.opened = false;
|
||||
this.getBlockEntity().openersCounter.opened = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,7 +77,7 @@ public class CraftBarrel extends CraftLootable<BarrelBlockEntity> implements Bar
|
||||
// Paper start - More Lidded Block API
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return getTileEntity().openersCounter.opened;
|
||||
return getBlockEntity().openersCounter.opened;
|
||||
}
|
||||
// Paper end - More Lidded Block API
|
||||
}
|
||||
|
||||
@@ -4,9 +4,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.advancements.critereon.DataComponentMatchers;
|
||||
import net.minecraft.advancements.critereon.ItemPredicate;
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||
import net.minecraft.core.component.DataComponentPredicate;
|
||||
import net.minecraft.core.component.DataComponentExactPredicate;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.LockCode;
|
||||
@@ -26,8 +27,8 @@ import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class CraftBeacon extends CraftBlockEntityState<BeaconBlockEntity> implements Beacon {
|
||||
|
||||
public CraftBeacon(World world, BeaconBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftBeacon(World world, BeaconBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftBeacon(CraftBeacon state, Location location) {
|
||||
@@ -38,12 +39,12 @@ public class CraftBeacon extends CraftBlockEntityState<BeaconBlockEntity> implem
|
||||
public Collection<LivingEntity> getEntitiesInRange() {
|
||||
this.ensureNoWorldGeneration();
|
||||
|
||||
BlockEntity tileEntity = this.getTileEntityFromWorld();
|
||||
if (tileEntity instanceof BeaconBlockEntity) {
|
||||
BeaconBlockEntity beacon = (BeaconBlockEntity) tileEntity;
|
||||
BlockEntity blockEntity = this.getBlockEntityFromWorld();
|
||||
if (blockEntity instanceof BeaconBlockEntity) {
|
||||
BeaconBlockEntity beacon = (BeaconBlockEntity) blockEntity;
|
||||
|
||||
Collection<Player> nms = BeaconBlockEntity.getHumansInRange(beacon.getLevel(), beacon.getBlockPos(), beacon.levels, beacon); // Paper - Custom beacon ranges
|
||||
Collection<LivingEntity> bukkit = new ArrayList<LivingEntity>(nms.size());
|
||||
Collection<LivingEntity> bukkit = new ArrayList<>(nms.size());
|
||||
|
||||
for (Player human : nms) {
|
||||
bukkit.add(human.getBukkitEntity());
|
||||
@@ -53,7 +54,7 @@ public class CraftBeacon extends CraftBlockEntityState<BeaconBlockEntity> implem
|
||||
}
|
||||
|
||||
// block is no longer a beacon
|
||||
return new ArrayList<LivingEntity>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,18 +82,16 @@ public class CraftBeacon extends CraftBlockEntityState<BeaconBlockEntity> implem
|
||||
this.getSnapshot().secondaryPower = (effect != null) ? CraftPotionEffectType.bukkitToMinecraftHolder(effect) : null;
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@Override
|
||||
public net.kyori.adventure.text.Component customName() {
|
||||
final BeaconBlockEntity be = this.getSnapshot();
|
||||
return be.name != null ? io.papermc.paper.adventure.PaperAdventure.asAdventure(be.name) : null;
|
||||
final BeaconBlockEntity beacon = this.getSnapshot();
|
||||
return beacon.name != null ? io.papermc.paper.adventure.PaperAdventure.asAdventure(beacon.name) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customName(final net.kyori.adventure.text.Component customName) {
|
||||
this.getSnapshot().setCustomName(customName != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(customName) : null);
|
||||
}
|
||||
// Paper end
|
||||
|
||||
@Override
|
||||
public String getCustomName() {
|
||||
@@ -112,7 +111,7 @@ public class CraftBeacon extends CraftBlockEntityState<BeaconBlockEntity> implem
|
||||
|
||||
@Override
|
||||
public String getLock() {
|
||||
Optional<? extends Component> customName = this.getSnapshot().lockKey.predicate().components().asPatch().get(DataComponents.CUSTOM_NAME);
|
||||
Optional<? extends Component> customName = this.getSnapshot().lockKey.predicate().components().exact().asPatch().get(DataComponents.CUSTOM_NAME);
|
||||
|
||||
return (customName != null) ? customName.map(CraftChatMessage::fromComponent).orElse("") : "";
|
||||
}
|
||||
@@ -122,8 +121,8 @@ public class CraftBeacon extends CraftBlockEntityState<BeaconBlockEntity> implem
|
||||
if (key == null) {
|
||||
this.getSnapshot().lockKey = LockCode.NO_LOCK;
|
||||
} else {
|
||||
DataComponentPredicate predicate = DataComponentPredicate.builder().expect(DataComponents.CUSTOM_NAME, CraftChatMessage.fromStringOrNull(key)).build();
|
||||
this.getSnapshot().lockKey = new LockCode(new ItemPredicate(Optional.empty(), MinMaxBounds.Ints.ANY, predicate, Collections.emptyMap()));
|
||||
DataComponentExactPredicate predicate = DataComponentExactPredicate.builder().expect(DataComponents.CUSTOM_NAME, CraftChatMessage.fromStringOrNull(key)).build();
|
||||
this.getSnapshot().lockKey = new LockCode(new ItemPredicate(Optional.empty(), MinMaxBounds.Ints.ANY, new DataComponentMatchers(predicate, Collections.emptyMap())));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ import org.bukkit.block.Bed;
|
||||
|
||||
public class CraftBed extends CraftBlockEntityState<BedBlockEntity> implements Bed {
|
||||
|
||||
public CraftBed(World world, BedBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftBed(World world, BedBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftBed(CraftBed state, Location location) {
|
||||
@@ -18,42 +18,25 @@ public class CraftBed extends CraftBlockEntityState<BedBlockEntity> implements B
|
||||
|
||||
@Override
|
||||
public DyeColor getColor() {
|
||||
switch (this.getType()) {
|
||||
case BLACK_BED:
|
||||
return DyeColor.BLACK;
|
||||
case BLUE_BED:
|
||||
return DyeColor.BLUE;
|
||||
case BROWN_BED:
|
||||
return DyeColor.BROWN;
|
||||
case CYAN_BED:
|
||||
return DyeColor.CYAN;
|
||||
case GRAY_BED:
|
||||
return DyeColor.GRAY;
|
||||
case GREEN_BED:
|
||||
return DyeColor.GREEN;
|
||||
case LIGHT_BLUE_BED:
|
||||
return DyeColor.LIGHT_BLUE;
|
||||
case LIGHT_GRAY_BED:
|
||||
return DyeColor.LIGHT_GRAY;
|
||||
case LIME_BED:
|
||||
return DyeColor.LIME;
|
||||
case MAGENTA_BED:
|
||||
return DyeColor.MAGENTA;
|
||||
case ORANGE_BED:
|
||||
return DyeColor.ORANGE;
|
||||
case PINK_BED:
|
||||
return DyeColor.PINK;
|
||||
case PURPLE_BED:
|
||||
return DyeColor.PURPLE;
|
||||
case RED_BED:
|
||||
return DyeColor.RED;
|
||||
case WHITE_BED:
|
||||
return DyeColor.WHITE;
|
||||
case YELLOW_BED:
|
||||
return DyeColor.YELLOW;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown DyeColor for " + this.getType());
|
||||
}
|
||||
return switch (this.getType()) {
|
||||
case BLACK_BED -> DyeColor.BLACK;
|
||||
case BLUE_BED -> DyeColor.BLUE;
|
||||
case BROWN_BED -> DyeColor.BROWN;
|
||||
case CYAN_BED -> DyeColor.CYAN;
|
||||
case GRAY_BED -> DyeColor.GRAY;
|
||||
case GREEN_BED -> DyeColor.GREEN;
|
||||
case LIGHT_BLUE_BED -> DyeColor.LIGHT_BLUE;
|
||||
case LIGHT_GRAY_BED -> DyeColor.LIGHT_GRAY;
|
||||
case LIME_BED -> DyeColor.LIME;
|
||||
case MAGENTA_BED -> DyeColor.MAGENTA;
|
||||
case ORANGE_BED -> DyeColor.ORANGE;
|
||||
case PINK_BED -> DyeColor.PINK;
|
||||
case PURPLE_BED -> DyeColor.PURPLE;
|
||||
case RED_BED -> DyeColor.RED;
|
||||
case WHITE_BED -> DyeColor.WHITE;
|
||||
case YELLOW_BED -> DyeColor.YELLOW;
|
||||
default -> throw new IllegalArgumentException("Unknown DyeColor for " + this.getType());
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,8 +16,8 @@ import org.bukkit.entity.Bee;
|
||||
|
||||
public class CraftBeehive extends CraftBlockEntityState<BeehiveBlockEntity> implements Beehive {
|
||||
|
||||
public CraftBeehive(World world, BeehiveBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftBeehive(World world, BeehiveBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftBeehive(CraftBeehive state, Location location) {
|
||||
@@ -43,7 +43,7 @@ public class CraftBeehive extends CraftBlockEntityState<BeehiveBlockEntity> impl
|
||||
|
||||
@Override
|
||||
public boolean isSedated() {
|
||||
return this.isPlaced() && this.getTileEntity().isSedated();
|
||||
return this.isPlaced() && this.getBlockEntity().isSedated();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,7 +70,7 @@ public class CraftBeehive extends CraftBlockEntityState<BeehiveBlockEntity> impl
|
||||
List<Bee> bees = new ArrayList<>();
|
||||
|
||||
if (this.isPlaced()) {
|
||||
BeehiveBlockEntity beehive = ((BeehiveBlockEntity) this.getTileEntityFromWorld());
|
||||
BeehiveBlockEntity beehive = ((BeehiveBlockEntity) this.getBlockEntityFromWorld());
|
||||
for (Entity bee : beehive.releaseBees(this.getHandle(), BeeReleaseStatus.BEE_RELEASED, true)) {
|
||||
bees.add((Bee) bee.getBukkitEntity());
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
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.BellBlockEntity;
|
||||
@@ -15,8 +14,8 @@ import org.bukkit.entity.Entity;
|
||||
|
||||
public class CraftBell extends CraftBlockEntityState<BellBlockEntity> implements Bell {
|
||||
|
||||
public CraftBell(World world, BellBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftBell(World world, BellBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftBell(CraftBell state, Location location) {
|
||||
@@ -27,30 +26,13 @@ public class CraftBell extends CraftBlockEntityState<BellBlockEntity> implements
|
||||
public boolean ring(Entity entity, BlockFace direction) {
|
||||
Preconditions.checkArgument(direction == null || direction.isCartesian(), "direction must be cartesian, given %s", direction);
|
||||
|
||||
BlockEntity tileEntity = this.getTileEntityFromWorld();
|
||||
if (tileEntity == null) {
|
||||
BlockEntity blockEntity = this.getBlockEntityFromWorld();
|
||||
if (blockEntity == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
net.minecraft.world.entity.Entity nmsEntity = (entity != null) ? ((CraftEntity) entity).getHandle() : null;
|
||||
Direction enumDirection = CraftBlock.blockFaceToNotch(direction);
|
||||
|
||||
return ((BellBlock) Blocks.BELL).attemptToRing(nmsEntity, this.world.getHandle(), this.getPosition(), enumDirection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ring(Entity entity) {
|
||||
return this.ring(entity, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ring(BlockFace direction) {
|
||||
return this.ring(null, direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ring() {
|
||||
return this.ring(null, null);
|
||||
return ((BellBlock) Blocks.BELL).attemptToRing(nmsEntity, this.world.getHandle(), this.getPosition(), CraftBlock.blockFaceToNotch(direction));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import java.util.Locale;
|
||||
import io.papermc.paper.util.OldEnumHolderable;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.craftbukkit.CraftRegistry;
|
||||
import org.bukkit.craftbukkit.util.Handleable;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CraftBiome implements Biome, Handleable<net.minecraft.world.level.biome.Biome> {
|
||||
@NullMarked
|
||||
public class CraftBiome extends OldEnumHolderable<Biome, net.minecraft.world.level.biome.Biome> implements Biome {
|
||||
|
||||
private static int count = 0;
|
||||
|
||||
@@ -18,10 +22,10 @@ public class CraftBiome implements Biome, Handleable<net.minecraft.world.level.b
|
||||
}
|
||||
|
||||
public static Biome minecraftHolderToBukkit(Holder<net.minecraft.world.level.biome.Biome> minecraft) {
|
||||
return CraftBiome.minecraftToBukkit(minecraft.value());
|
||||
return CraftRegistry.minecraftHolderToBukkit(minecraft, Registries.BIOME);
|
||||
}
|
||||
|
||||
public static net.minecraft.world.level.biome.Biome bukkitToMinecraft(Biome bukkit) {
|
||||
public static net.minecraft.world.level.biome.@Nullable Biome bukkitToMinecraft(Biome bukkit) {
|
||||
if (bukkit == Biome.CUSTOM) {
|
||||
return null;
|
||||
}
|
||||
@@ -29,89 +33,68 @@ public class CraftBiome implements Biome, Handleable<net.minecraft.world.level.b
|
||||
return CraftRegistry.bukkitToMinecraft(bukkit);
|
||||
}
|
||||
|
||||
public static Holder<net.minecraft.world.level.biome.Biome> bukkitToMinecraftHolder(Biome bukkit) {
|
||||
public static @Nullable Holder<net.minecraft.world.level.biome.Biome> bukkitToMinecraftHolder(Biome bukkit) {
|
||||
if (bukkit == Biome.CUSTOM) {
|
||||
return null;
|
||||
}
|
||||
return CraftRegistry.bukkitToMinecraftHolder(bukkit, Registries.BIOME);
|
||||
}
|
||||
|
||||
net.minecraft.core.Registry<net.minecraft.world.level.biome.Biome> registry = CraftRegistry.getMinecraftRegistry(Registries.BIOME);
|
||||
public CraftBiome(final Holder<net.minecraft.world.level.biome.Biome> holder) {
|
||||
super(holder, count++);
|
||||
}
|
||||
|
||||
if (registry.wrapAsHolder(CraftBiome.bukkitToMinecraft(bukkit)) instanceof Holder.Reference<net.minecraft.world.level.biome.Biome> holder) {
|
||||
return holder;
|
||||
/**
|
||||
* Implementation for the deprecated, API only, CUSTOM biome.
|
||||
* As per {@link #bukkitToMinecraft(Biome)} and {@link #bukkitToMinecraftHolder(Biome)} it cannot be
|
||||
* converted into an internal biome and only serves backwards compatibility reasons.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.5")
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "1.22")
|
||||
public static class LegacyCustomBiomeImpl implements Biome {
|
||||
|
||||
private static final NamespacedKey LEGACY_CUSTOM_KEY = new NamespacedKey("minecraft", "custom");
|
||||
private final int ordinal;
|
||||
|
||||
public LegacyCustomBiomeImpl() {
|
||||
this.ordinal = count++;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("No Reference holder found for " + bukkit
|
||||
+ ", this can happen if a plugin creates its own biome base with out properly registering it.");
|
||||
}
|
||||
|
||||
private final NamespacedKey key;
|
||||
private final net.minecraft.world.level.biome.Biome biomeBase;
|
||||
private final String name;
|
||||
private final int ordinal;
|
||||
|
||||
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,
|
||||
// in case plugins use for example the name as key in a config file to receive biome specific values.
|
||||
// Custom biomes will return the key with namespace. For a plugin this should look than like a new biome
|
||||
// (which can always be added in new minecraft versions and the plugin should therefore handle it accordingly).
|
||||
if (NamespacedKey.MINECRAFT.equals(key.getNamespace())) {
|
||||
this.name = key.getKey().toUpperCase(Locale.ROOT);
|
||||
} else {
|
||||
this.name = key.toString();
|
||||
}
|
||||
this.ordinal = CraftBiome.count++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.level.biome.Biome getHandle() {
|
||||
return this.biomeBase;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull Biome biome) {
|
||||
return this.ordinal - biome.ordinal();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String name() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int ordinal() {
|
||||
return this.ordinal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// For backwards compatibility
|
||||
return this.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
@Override
|
||||
public @NotNull NamespacedKey getKey() {
|
||||
return LEGACY_CUSTOM_KEY;
|
||||
}
|
||||
|
||||
if (!(other instanceof CraftBiome otherBiome)) {
|
||||
return false;
|
||||
@Override
|
||||
public int compareTo(@NotNull final Biome other) {
|
||||
return this.ordinal - other.ordinal();
|
||||
}
|
||||
|
||||
return this.getKey().equals(otherBiome.getKey());
|
||||
}
|
||||
@Override
|
||||
public @NotNull String name() {
|
||||
return "CUSTOM";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.getKey().hashCode();
|
||||
@Override
|
||||
public int ordinal() {
|
||||
return this.ordinal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object) {
|
||||
if (object == null || getClass() != object.getClass()) return false;
|
||||
final LegacyCustomBiomeImpl that = (LegacyCustomBiomeImpl) object;
|
||||
return ordinal == that.ordinal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(ordinal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CUSTOM";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import org.bukkit.block.BlastFurnace;
|
||||
|
||||
public class CraftBlastFurnace extends CraftFurnace<BlastFurnaceBlockEntity> implements BlastFurnace {
|
||||
|
||||
public CraftBlastFurnace(World world, BlastFurnaceBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftBlastFurnace(World world, BlastFurnaceBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftBlastFurnace(CraftBlastFurnace state, Location location) {
|
||||
|
||||
@@ -78,11 +78,9 @@ public class CraftBlock implements Block {
|
||||
return this.world.getBlockState(this.position);
|
||||
}
|
||||
|
||||
// Paper start
|
||||
public net.minecraft.world.level.material.FluidState getNMSFluid() {
|
||||
return this.world.getFluidState(this.position);
|
||||
}
|
||||
// Paper end
|
||||
|
||||
public BlockPos getPosition() {
|
||||
return this.position;
|
||||
@@ -145,25 +143,25 @@ public class CraftBlock implements Block {
|
||||
}
|
||||
|
||||
public void setData(final byte data) {
|
||||
this.setData(data, 3);
|
||||
this.setData(data, net.minecraft.world.level.block.Block.UPDATE_ALL);
|
||||
}
|
||||
|
||||
public void setData(final byte data, boolean applyPhysics) {
|
||||
if (applyPhysics) {
|
||||
this.setData(data, 3);
|
||||
this.setData(data, net.minecraft.world.level.block.Block.UPDATE_ALL);
|
||||
} else {
|
||||
this.setData(data, 2);
|
||||
this.setData(data, net.minecraft.world.level.block.Block.UPDATE_CLIENTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void setData(final byte data, int flag) {
|
||||
this.world.setBlock(this.position, CraftMagicNumbers.getBlock(this.getType(), data), flag);
|
||||
private void setData(final byte data, int flags) {
|
||||
this.world.setBlock(this.position, CraftMagicNumbers.getBlock(this.getType(), data), flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getData() {
|
||||
net.minecraft.world.level.block.state.BlockState blockData = this.world.getBlockState(this.position);
|
||||
return CraftMagicNumbers.toLegacyData(blockData);
|
||||
net.minecraft.world.level.block.state.BlockState state = this.world.getBlockState(this.position);
|
||||
return CraftMagicNumbers.toLegacyData(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -190,34 +188,37 @@ public class CraftBlock implements Block {
|
||||
@Override
|
||||
public void setBlockData(BlockData data, boolean applyPhysics) {
|
||||
Preconditions.checkArgument(data != null, "BlockData cannot be null");
|
||||
this.setTypeAndData(((CraftBlockData) data).getState(), applyPhysics);
|
||||
this.setBlockState(((CraftBlockData) data).getState(), 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);
|
||||
boolean setBlockState(final net.minecraft.world.level.block.state.BlockState state, final boolean applyPhysics) {
|
||||
return CraftBlock.setBlockState(this.world, this.position, this.getNMS(), state, 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
|
||||
public static boolean setBlockState(LevelAccessor world, BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState, boolean applyPhysics) {
|
||||
// SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in block entity cleanup
|
||||
if (oldState.hasBlockEntity() && newState.getBlock() != oldState.getBlock()) { // SPIGOT-3725 remove old block entity if block changes
|
||||
// SPIGOT-4612: faster - just clear tile
|
||||
if (world instanceof net.minecraft.world.level.Level) {
|
||||
((net.minecraft.world.level.Level) world).removeBlockEntity(position);
|
||||
((net.minecraft.world.level.Level) world).removeBlockEntity(pos);
|
||||
} else {
|
||||
world.setBlock(position, Blocks.AIR.defaultBlockState(), 0);
|
||||
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (applyPhysics) {
|
||||
return world.setBlock(position, blockData, 3);
|
||||
return world.setBlock(pos, newState, net.minecraft.world.level.block.Block.UPDATE_ALL);
|
||||
} else {
|
||||
boolean success = world.setBlock(position, blockData, 2 | 16 | 1024); // NOTIFY | NO_OBSERVER | NO_PLACE (custom)
|
||||
boolean success = world.setBlock(pos, newState,
|
||||
net.minecraft.world.level.block.Block.UPDATE_CLIENTS |
|
||||
net.minecraft.world.level.block.Block.UPDATE_KNOWN_SHAPE |
|
||||
net.minecraft.world.level.block.Block.UPDATE_SKIP_ON_PLACE);
|
||||
if (success && world instanceof net.minecraft.world.level.Level) {
|
||||
world.getMinecraftWorld().sendBlockUpdated(
|
||||
position,
|
||||
old,
|
||||
blockData,
|
||||
3
|
||||
pos,
|
||||
oldState,
|
||||
newState,
|
||||
net.minecraft.world.level.block.Block.UPDATE_ALL
|
||||
);
|
||||
}
|
||||
return success;
|
||||
@@ -282,7 +283,7 @@ public class CraftBlock implements Block {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftBlock{pos=" + this.position + ",type=" + this.getType() + ",data=" + this.getNMS() + ",fluid=" + this.world.getFluidState(this.position) + '}';
|
||||
return "CraftBlock{pos=" + this.position + ",type=" + this.getType() + ",data=" + this.getNMS() + ",fluid=" + this.getNMSFluid() + '}';
|
||||
}
|
||||
|
||||
public static BlockFace notchToBlockFace(Direction notch) {
|
||||
@@ -406,7 +407,7 @@ public class CraftBlock implements Block {
|
||||
|
||||
Block relative = this.getRelative(face);
|
||||
if (relative.getType() == Material.REDSTONE_WIRE) {
|
||||
return Math.max(power, relative.getData()) > 0;
|
||||
return Math.max(power, relative.getData()) > 0; // todo remove legacy usage
|
||||
}
|
||||
|
||||
return power > 0;
|
||||
@@ -428,13 +429,11 @@ public class CraftBlock implements Block {
|
||||
return power > 0 ? power : (face == BlockFace.SELF ? this.isBlockIndirectlyPowered() : this.isBlockFaceIndirectlyPowered(face)) ? 15 : 0;
|
||||
}
|
||||
|
||||
private static int getPower(int i, net.minecraft.world.level.block.state.BlockState iblockdata) {
|
||||
if (!iblockdata.is(Blocks.REDSTONE_WIRE)) {
|
||||
return i;
|
||||
private static int getPower(int power, net.minecraft.world.level.block.state.BlockState state) {
|
||||
if (!state.is(Blocks.REDSTONE_WIRE)) {
|
||||
return power;
|
||||
} else {
|
||||
int j = iblockdata.getValue(RedStoneWireBlock.POWER);
|
||||
|
||||
return j > i ? j : i;
|
||||
return Math.max(state.getValue(RedStoneWireBlock.POWER), power);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,39 +501,39 @@ public class CraftBlock implements Block {
|
||||
public boolean breakNaturally(ItemStack item, boolean triggerEffect, boolean dropExperience) {
|
||||
// Paper end
|
||||
// Order matters here, need to drop before setting to air so skulls can get their data
|
||||
net.minecraft.world.level.block.state.BlockState iblockdata = this.getNMS();
|
||||
net.minecraft.world.level.block.Block block = iblockdata.getBlock();
|
||||
net.minecraft.world.level.block.state.BlockState state = this.getNMS();
|
||||
net.minecraft.world.level.block.Block block = state.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, this.world.getMinecraftWorld(), this.position, this.world.getBlockEntity(this.position), null, nmsItem, false); // Paper - Properly handle xp dropping
|
||||
// Paper start - improve Block#breanNaturally
|
||||
// Modelled off Player#hasCorrectToolForDrops
|
||||
if (block != Blocks.AIR && (item == null || !state.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(state))) {
|
||||
net.minecraft.world.level.block.Block.dropResources(state, this.world.getMinecraftWorld(), this.position, this.world.getBlockEntity(this.position), null, nmsItem, false); // Paper - Properly handle xp dropping
|
||||
// Paper start - improve Block#breakNaturally
|
||||
if (triggerEffect) {
|
||||
if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.BaseFireBlock) {
|
||||
if (state.getBlock() instanceof net.minecraft.world.level.block.BaseFireBlock) {
|
||||
this.world.levelEvent(net.minecraft.world.level.block.LevelEvent.SOUND_EXTINGUISH_FIRE, this.position, 0);
|
||||
} else {
|
||||
this.world.levelEvent(net.minecraft.world.level.block.LevelEvent.PARTICLES_DESTROY_BLOCK, this.position, net.minecraft.world.level.block.Block.getId(iblockdata));
|
||||
this.world.levelEvent(net.minecraft.world.level.block.LevelEvent.PARTICLES_DESTROY_BLOCK, this.position, net.minecraft.world.level.block.Block.getId(state));
|
||||
}
|
||||
}
|
||||
if (dropExperience) block.popExperience(this.world.getMinecraftWorld(), this.position, block.getExpDrop(iblockdata, this.world.getMinecraftWorld(), this.position, nmsItem, true));
|
||||
if (dropExperience) block.popExperience(this.world.getMinecraftWorld(), this.position, block.getExpDrop(state, this.world.getMinecraftWorld(), this.position, nmsItem, true));
|
||||
// Paper end
|
||||
result = true;
|
||||
}
|
||||
|
||||
// SPIGOT-6778: Directly call setBlock instead of setTypeAndData, so that the tile entiy is not removed and custom remove logic is run.
|
||||
// SPIGOT-6778: Directly call setBlock instead of setBlockState, so that the block entity is not removed and custom remove logic is run.
|
||||
// Paper start - improve breakNaturally
|
||||
boolean destroyed = this.world.removeBlock(this.position, false);
|
||||
if (destroyed) {
|
||||
block.destroy(this.world, this.position, iblockdata);
|
||||
block.destroy(this.world, this.position, state);
|
||||
}
|
||||
if (result) {
|
||||
// special cases
|
||||
if (block instanceof net.minecraft.world.level.block.IceBlock iceBlock) {
|
||||
iceBlock.afterDestroy(this.world.getMinecraftWorld(), this.position, nmsItem);
|
||||
} else if (block instanceof net.minecraft.world.level.block.TurtleEggBlock turtleEggBlock) {
|
||||
turtleEggBlock.decreaseEggs(this.world.getMinecraftWorld(), this.position, iblockdata);
|
||||
turtleEggBlock.decreaseEggs(this.world.getMinecraftWorld(), this.position, state);
|
||||
}
|
||||
}
|
||||
return destroyed && result;
|
||||
@@ -553,26 +552,27 @@ public class CraftBlock implements Block {
|
||||
InteractionResult result = BoneMealItem.applyBonemeal(context);
|
||||
world.captureTreeGeneration = false;
|
||||
|
||||
if (world.capturedBlockStates.size() > 0) {
|
||||
if (!world.capturedBlockStates.isEmpty()) {
|
||||
TreeType treeType = SaplingBlock.treeType;
|
||||
SaplingBlock.treeType = null;
|
||||
List<BlockState> blocks = new ArrayList<>(world.capturedBlockStates.values());
|
||||
List<BlockState> states = new ArrayList<>(world.capturedBlockStates.values());
|
||||
world.capturedBlockStates.clear();
|
||||
StructureGrowEvent structureEvent = null;
|
||||
|
||||
if (treeType != null) {
|
||||
structureEvent = new StructureGrowEvent(this.getLocation(), treeType, true, null, blocks);
|
||||
structureEvent = new StructureGrowEvent(this.getLocation(), treeType, true, null, states);
|
||||
Bukkit.getPluginManager().callEvent(structureEvent);
|
||||
}
|
||||
|
||||
event = new BlockFertilizeEvent(CraftBlock.at(world, this.getPosition()), null, blocks);
|
||||
event = new BlockFertilizeEvent(CraftBlock.at(world, this.getPosition()), null, states);
|
||||
event.setCancelled(structureEvent != null && structureEvent.isCancelled());
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
for (BlockState blockstate : blocks) {
|
||||
blockstate.update(true);
|
||||
world.checkCapturedTreeStateForObserverNotify(this.position, (org.bukkit.craftbukkit.block.CraftBlockState) blockstate); // Paper - notify observers even if grow failed
|
||||
for (BlockState state : states) {
|
||||
CraftBlockState craftBlockState = (CraftBlockState) state;
|
||||
craftBlockState.place(craftBlockState.getFlags());
|
||||
world.checkCapturedTreeStateForObserverNotify(this.position, craftBlockState); // Paper - notify observers even if grow failed
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -592,12 +592,12 @@ public class CraftBlock implements Block {
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getDrops(ItemStack item, Entity entity) {
|
||||
net.minecraft.world.level.block.state.BlockState iblockdata = this.getNMS();
|
||||
net.minecraft.world.level.block.state.BlockState state = 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, (ServerLevel) this.world.getMinecraftWorld(), this.position, this.world.getBlockEntity(this.position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms)
|
||||
// Modelled off Player#hasCorrectToolForDrops
|
||||
if (item == null || CraftBlockData.isPreferredTool(state, nms)) {
|
||||
return net.minecraft.world.level.block.Block.getDrops(state, 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();
|
||||
@@ -606,9 +606,9 @@ public class CraftBlock implements Block {
|
||||
|
||||
@Override
|
||||
public boolean isPreferredTool(ItemStack item) {
|
||||
net.minecraft.world.level.block.state.BlockState iblockdata = this.getNMS();
|
||||
net.minecraft.world.level.block.state.BlockState state = this.getNMS();
|
||||
net.minecraft.world.item.ItemStack nms = CraftItemStack.asNMSCopy(item);
|
||||
return CraftBlockData.isPreferredTool(iblockdata, nms);
|
||||
return CraftBlockData.isPreferredTool(state, nms);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -658,11 +658,11 @@ public class CraftBlock implements Block {
|
||||
}
|
||||
|
||||
Vector dir = direction.clone().normalize().multiply(maxDistance);
|
||||
Vec3 startPos = CraftLocation.toVec3D(start);
|
||||
Vec3 startPos = CraftLocation.toVec3(start);
|
||||
Vec3 endPos = startPos.add(dir.getX(), dir.getY(), dir.getZ());
|
||||
|
||||
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);
|
||||
HitResult hitResult = this.world.clip(new ClipContext(startPos, endPos, ClipContext.Block.OUTLINE, CraftFluidCollisionMode.toFluid(fluidCollisionMode), CollisionContext.empty()), this.position);
|
||||
return CraftRayTraceResult.convertFromInternal(this.world, hitResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,12 +9,12 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
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;
|
||||
import org.bukkit.craftbukkit.CraftRegistry;
|
||||
import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -22,25 +22,25 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class CraftBlockEntityState<T extends BlockEntity> extends CraftBlockState implements TileState { // Paper - revert upstream's revert of the block state changes
|
||||
|
||||
private final T tileEntity;
|
||||
private final T blockEntity;
|
||||
private final T snapshot;
|
||||
public boolean snapshotDisabled; // Paper
|
||||
public static boolean DISABLE_SNAPSHOT = false; // Paper
|
||||
|
||||
public CraftBlockEntityState(World world, T tileEntity) {
|
||||
super(world, tileEntity.getBlockPos(), tileEntity.getBlockState());
|
||||
public CraftBlockEntityState(World world, T blockEntity) {
|
||||
super(world, blockEntity.getBlockPos(), blockEntity.getBlockState());
|
||||
|
||||
this.tileEntity = tileEntity;
|
||||
this.blockEntity = blockEntity;
|
||||
|
||||
try { // Paper - Show blockstate location if we failed to read it
|
||||
// Paper start
|
||||
this.snapshotDisabled = DISABLE_SNAPSHOT;
|
||||
if (DISABLE_SNAPSHOT) {
|
||||
this.snapshot = this.tileEntity;
|
||||
this.snapshot = this.blockEntity;
|
||||
} else {
|
||||
this.snapshot = this.createSnapshot(tileEntity);
|
||||
this.snapshot = this.createSnapshot(blockEntity);
|
||||
}
|
||||
// copy tile entity data:
|
||||
// copy block entity data:
|
||||
if (this.snapshot != null) {
|
||||
this.load(this.snapshot);
|
||||
}
|
||||
@@ -62,29 +62,27 @@ public abstract class CraftBlockEntityState<T extends BlockEntity> extends Craft
|
||||
|
||||
protected CraftBlockEntityState(CraftBlockEntityState<T> state, Location location) {
|
||||
super(state, location);
|
||||
this.tileEntity = this.createSnapshot(state.snapshot);
|
||||
this.snapshot = this.tileEntity;
|
||||
this.blockEntity = this.createSnapshot(state.snapshot);
|
||||
this.snapshot = this.blockEntity;
|
||||
this.loadData(state.getSnapshotNBT());
|
||||
}
|
||||
|
||||
public void refreshSnapshot() {
|
||||
this.load(this.tileEntity);
|
||||
this.load(this.blockEntity);
|
||||
}
|
||||
|
||||
private RegistryAccess getRegistryAccess() {
|
||||
LevelAccessor worldHandle = this.getWorldHandle();
|
||||
return (worldHandle != null) ? worldHandle.registryAccess() : MinecraftServer.getDefaultRegistryAccess();
|
||||
return (worldHandle != null) ? worldHandle.registryAccess() : CraftRegistry.getMinecraftRegistry();
|
||||
}
|
||||
|
||||
private T createSnapshot(T tileEntity) {
|
||||
if (tileEntity == null) {
|
||||
private T createSnapshot(T from) {
|
||||
if (from == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CompoundTag nbtTagCompound = tileEntity.saveWithFullMetadata(this.getRegistryAccess());
|
||||
T snapshot = (T) BlockEntity.loadStatic(this.getPosition(), this.getHandle(), nbtTagCompound, this.getRegistryAccess());
|
||||
|
||||
return snapshot;
|
||||
CompoundTag tag = from.saveWithFullMetadata(this.getRegistryAccess());
|
||||
return (T) BlockEntity.loadStatic(this.getPosition(), this.getHandle(), tag, this.getRegistryAccess());
|
||||
}
|
||||
|
||||
public Set<DataComponentType<?>> applyComponents(DataComponentMap datacomponentmap, DataComponentPatch datacomponentpatch) {
|
||||
@@ -97,36 +95,36 @@ public abstract class CraftBlockEntityState<T extends BlockEntity> extends Craft
|
||||
return this.snapshot.collectComponents();
|
||||
}
|
||||
|
||||
// Loads the specified data into the snapshot TileEntity.
|
||||
public void loadData(CompoundTag nbtTagCompound) {
|
||||
this.snapshot.loadWithComponents(nbtTagCompound, this.getRegistryAccess());
|
||||
// Loads the specified data into the snapshot BlockEntity.
|
||||
public void loadData(CompoundTag tag) {
|
||||
this.snapshot.loadWithComponents(tag, this.getRegistryAccess());
|
||||
this.load(this.snapshot);
|
||||
}
|
||||
|
||||
// copies the TileEntity-specific data, retains the position
|
||||
// copies the BlockEntity-specific data, retains the position
|
||||
private void copyData(T from, T to) {
|
||||
CompoundTag nbtTagCompound = from.saveWithFullMetadata(this.getRegistryAccess());
|
||||
to.loadWithComponents(nbtTagCompound, this.getRegistryAccess());
|
||||
CompoundTag tag = from.saveWithFullMetadata(this.getRegistryAccess());
|
||||
to.loadWithComponents(tag, this.getRegistryAccess());
|
||||
}
|
||||
|
||||
// gets the wrapped TileEntity
|
||||
public T getTileEntity() {
|
||||
return this.tileEntity;
|
||||
// gets the wrapped BlockEntity
|
||||
public T getBlockEntity() {
|
||||
return this.blockEntity;
|
||||
}
|
||||
|
||||
// gets the cloned TileEntity which is used to store the captured data
|
||||
// gets the cloned BlockEntity which is used to store the captured data
|
||||
protected T getSnapshot() {
|
||||
return this.snapshot;
|
||||
}
|
||||
|
||||
// gets the current TileEntity from the world at this position
|
||||
protected BlockEntity getTileEntityFromWorld() {
|
||||
// gets the current BlockEntity from the world at this position
|
||||
protected BlockEntity getBlockEntityFromWorld() {
|
||||
this.requirePlaced();
|
||||
|
||||
return this.getWorldHandle().getBlockEntity(this.getPosition());
|
||||
}
|
||||
|
||||
// gets the NBT data of the TileEntity represented by this block state
|
||||
// gets the NBT data of the BlockEntity represented by this block state
|
||||
public CompoundTag getSnapshotNBT() {
|
||||
// update snapshot
|
||||
this.applyTo(this.snapshot);
|
||||
@@ -134,21 +132,7 @@ public abstract class CraftBlockEntityState<T extends BlockEntity> extends Craft
|
||||
return this.snapshot.saveWithFullMetadata(this.getRegistryAccess());
|
||||
}
|
||||
|
||||
public CompoundTag getItemNBT() {
|
||||
// update snapshot
|
||||
this.applyTo(this.snapshot);
|
||||
|
||||
// See TileEntity#saveToItem
|
||||
CompoundTag nbt = this.snapshot.saveCustomOnly(this.getRegistryAccess());
|
||||
this.snapshot.removeComponentsFromTag(nbt);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public void addEntityType(CompoundTag nbt) {
|
||||
BlockEntity.addEntityType(nbt, this.snapshot.getType());
|
||||
}
|
||||
|
||||
// gets the packet data of the TileEntity represented by this block state
|
||||
// gets the packet data of the BlockEntity represented by this block state
|
||||
public CompoundTag getUpdateNBT() {
|
||||
// update snapshot
|
||||
this.applyTo(this.snapshot);
|
||||
@@ -169,40 +153,47 @@ public abstract class CraftBlockEntityState<T extends BlockEntity> extends Craft
|
||||
}
|
||||
// Paper end
|
||||
|
||||
// copies the data of the given tile entity to this block state
|
||||
protected void load(T tileEntity) {
|
||||
if (tileEntity != null && tileEntity != this.snapshot) {
|
||||
this.copyData(tileEntity, this.snapshot);
|
||||
// copies the data of the given block entity to this block state
|
||||
protected void load(T blockEntity) {
|
||||
if (blockEntity != null && blockEntity != this.snapshot) {
|
||||
this.copyData(blockEntity, this.snapshot);
|
||||
}
|
||||
}
|
||||
|
||||
// applies the TileEntity data of this block state to the given TileEntity
|
||||
protected void applyTo(T tileEntity) {
|
||||
if (tileEntity != null && tileEntity != this.snapshot) {
|
||||
this.copyData(this.snapshot, tileEntity);
|
||||
// applies the BlockEntity data of this block state to the given BlockEntity
|
||||
protected void applyTo(T blockEntity) {
|
||||
if (blockEntity != null && blockEntity != this.snapshot) {
|
||||
this.copyData(this.snapshot, blockEntity);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isApplicable(BlockEntity tileEntity) {
|
||||
return tileEntity != null && this.tileEntity.getClass() == tileEntity.getClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(boolean force, boolean applyPhysics) {
|
||||
boolean result = super.update(force, applyPhysics);
|
||||
|
||||
if (result && this.isPlaced()) {
|
||||
BlockEntity tile = this.getTileEntityFromWorld();
|
||||
|
||||
if (this.isApplicable(tile)) {
|
||||
this.applyTo((T) tile);
|
||||
tile.setChanged();
|
||||
}
|
||||
this.getWorldHandle().getBlockEntity(this.getPosition(), this.blockEntity.getType()).ifPresent(blockEntity -> {
|
||||
this.applyTo((T) blockEntity);
|
||||
blockEntity.setChanged();
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean place(int flags) {
|
||||
if (super.place(flags)) {
|
||||
this.getWorldHandle().getBlockEntity(this.getPosition(), this.blockEntity.getType()).ifPresent(blockEntity -> {
|
||||
this.applyTo((T) blockEntity);
|
||||
blockEntity.setChanged();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersistentDataContainer getPersistentDataContainer() {
|
||||
return this.getSnapshot().persistentDataContainer;
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.block;
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
@@ -27,26 +28,27 @@ public class CraftBlockState implements BlockState {
|
||||
protected final CraftWorld world;
|
||||
private final BlockPos position;
|
||||
protected net.minecraft.world.level.block.state.BlockState data;
|
||||
protected int flag;
|
||||
protected int capturedFlags; // todo move out of this class
|
||||
private WeakReference<LevelAccessor> weakWorld;
|
||||
|
||||
protected CraftBlockState(final Block block) {
|
||||
this(block.getWorld(), ((CraftBlock) block).getPosition(), ((CraftBlock) block).getNMS());
|
||||
this.flag = 3;
|
||||
this.capturedFlags = net.minecraft.world.level.block.Block.UPDATE_ALL;
|
||||
|
||||
this.setWorldHandle(((CraftBlock) block).getHandle());
|
||||
}
|
||||
|
||||
protected CraftBlockState(final Block block, int flag) {
|
||||
@Deprecated
|
||||
protected CraftBlockState(final Block block, int capturedFlags) {
|
||||
this(block);
|
||||
this.flag = flag;
|
||||
this.capturedFlags = capturedFlags;
|
||||
}
|
||||
|
||||
// world can be null for non-placed BlockStates.
|
||||
protected CraftBlockState(@Nullable World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData) {
|
||||
protected CraftBlockState(@Nullable World world, BlockPos pos, net.minecraft.world.level.block.state.BlockState data) {
|
||||
this.world = (CraftWorld) world;
|
||||
this.position = blockPosition;
|
||||
this.data = blockData;
|
||||
this.position = pos;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
// Creates an unplaced copy of the given CraftBlockState at the given location
|
||||
@@ -59,7 +61,7 @@ public class CraftBlockState implements BlockState {
|
||||
this.position = CraftLocation.toBlockPosition(location);
|
||||
}
|
||||
this.data = state.data;
|
||||
this.flag = state.flag;
|
||||
this.capturedFlags = state.capturedFlags;
|
||||
this.setWorldHandle(state.getWorldHandle());
|
||||
}
|
||||
|
||||
@@ -178,12 +180,12 @@ public class CraftBlockState implements BlockState {
|
||||
return this.data.getBukkitMaterial(); // Paper - optimise getType calls
|
||||
}
|
||||
|
||||
public void setFlag(int flag) {
|
||||
this.flag = flag;
|
||||
public void setFlags(int flags) {
|
||||
this.capturedFlags = flags;
|
||||
}
|
||||
|
||||
public int getFlag() {
|
||||
return this.flag;
|
||||
public int getFlags() {
|
||||
return this.capturedFlags;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -222,13 +224,13 @@ public class CraftBlockState implements BlockState {
|
||||
}
|
||||
|
||||
net.minecraft.world.level.block.state.BlockState newBlock = this.data;
|
||||
block.setTypeAndData(newBlock, applyPhysics);
|
||||
block.setBlockState(newBlock, applyPhysics);
|
||||
if (access instanceof net.minecraft.world.level.Level) {
|
||||
this.world.getHandle().sendBlockUpdated(
|
||||
this.position,
|
||||
block.getNMS(),
|
||||
newBlock,
|
||||
3
|
||||
this.position,
|
||||
block.getNMS(),
|
||||
newBlock,
|
||||
net.minecraft.world.level.block.Block.UPDATE_ALL
|
||||
);
|
||||
}
|
||||
|
||||
@@ -240,6 +242,26 @@ public class CraftBlockState implements BlockState {
|
||||
return true;
|
||||
}
|
||||
|
||||
// used when the flags matter for non API usage
|
||||
public boolean place(int flags) {
|
||||
if (!this.isPlaced()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.getWorldHandle().setBlock(this.position, this.data, flags);
|
||||
}
|
||||
|
||||
// used to revert a block placement due to an event being cancelled for example
|
||||
public boolean revertPlace() {
|
||||
return this.place(
|
||||
net.minecraft.world.level.block.Block.UPDATE_CLIENTS |
|
||||
net.minecraft.world.level.block.Block.UPDATE_KNOWN_SHAPE |
|
||||
net.minecraft.world.level.block.Block.UPDATE_SUPPRESS_DROPS |
|
||||
net.minecraft.world.level.block.Block.UPDATE_SKIP_ON_PLACE |
|
||||
net.minecraft.world.level.block.Block.UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getRawData() {
|
||||
return CraftMagicNumbers.toLegacyData(this.data);
|
||||
@@ -278,16 +300,9 @@ public class CraftBlockState implements BlockState {
|
||||
return false;
|
||||
}
|
||||
final CraftBlockState other = (CraftBlockState) obj;
|
||||
if (this.world != other.world && (this.world == null || !this.world.equals(other.world))) {
|
||||
return false;
|
||||
}
|
||||
if (this.position != other.position && (this.position == null || !this.position.equals(other.position))) {
|
||||
return false;
|
||||
}
|
||||
if (this.data != other.data && (this.data == null || !this.data.equals(other.data))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return Objects.equals(this.world, other.world) &&
|
||||
Objects.equals(this.position, other.position) &&
|
||||
Objects.equals(this.data, other.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -353,13 +368,13 @@ public class CraftBlockState implements BlockState {
|
||||
this.requirePlaced();
|
||||
net.minecraft.world.item.ItemStack nms = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(item);
|
||||
|
||||
// Modelled off EntityHuman#hasBlock
|
||||
if (item == null || !data.requiresCorrectToolForDrops() || nms.isCorrectToolForDrops(data)) {
|
||||
// Modelled off Player#hasCorrectToolForDrops
|
||||
if (item == null || !data.requiresCorrectToolForDrops() || nms.isCorrectToolForDrops(this.data)) {
|
||||
return net.minecraft.world.level.block.Block.getDrops(
|
||||
data,
|
||||
world.getHandle(),
|
||||
position,
|
||||
world.getHandle().getBlockEntity(position), entity == null ? null :
|
||||
this.data,
|
||||
this.world.getHandle(),
|
||||
this.position,
|
||||
this.world.getHandle().getBlockEntity(this.position), entity == null ? null :
|
||||
((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandle(), nms
|
||||
).stream().map(org.bukkit.craftbukkit.inventory.CraftItemStack::asBukkitCopy).toList();
|
||||
} else {
|
||||
|
||||
@@ -1,70 +1,22 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiFunction;
|
||||
import javax.annotation.Nullable;
|
||||
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.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.BlockEntityType; // Paper
|
||||
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.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.PistonMovingBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.craftbukkit.CraftRegistry;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
|
||||
public final class CraftBlockStates {
|
||||
@@ -78,108 +30,110 @@ public final class CraftBlockStates {
|
||||
}
|
||||
|
||||
// The given world can be null for unplaced BlockStates.
|
||||
// If the world is not null and the given block data is a tile entity, the given tile entity is expected to not be null.
|
||||
// Otherwise, the given tile entity may or may not be null.
|
||||
// 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, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity);
|
||||
// If the world is not null and the given block data is a block entity, the given block entity is expected to not be null.
|
||||
// Otherwise, the given block entity may or may not be null.
|
||||
// If the given block 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 block entity's world may be null, even if the given world is not null.
|
||||
// If the block entity's world is not null, it is expected to match the given world.
|
||||
public abstract B createBlockState(World world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, BlockEntity blockEntity);
|
||||
}
|
||||
|
||||
private static class BlockEntityStateFactory<T extends BlockEntity, B extends CraftBlockEntityState<T>> extends BlockStateFactory<B> {
|
||||
|
||||
private final BiFunction<World, T, B> blockStateConstructor;
|
||||
private final BlockEntityType<? extends T> tileEntityConstructor; // Paper
|
||||
private final BlockEntityType<? extends T> blockEntityType;
|
||||
|
||||
protected BlockEntityStateFactory(Class<B> blockStateType, BiFunction<World, T, B> blockStateConstructor, BlockEntityType<? extends T> tileEntityConstructor) { // Paper
|
||||
protected BlockEntityStateFactory(Class<B> blockStateType, BiFunction<World, T, B> blockStateConstructor, BlockEntityType<? extends T> blockEntityType) {
|
||||
super(blockStateType);
|
||||
this.blockStateConstructor = blockStateConstructor;
|
||||
this.tileEntityConstructor = tileEntityConstructor;
|
||||
this.blockEntityType = blockEntityType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final B createBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
|
||||
public final B createBlockState(World world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, BlockEntity blockEntity) {
|
||||
if (world != null) {
|
||||
Preconditions.checkState(tileEntity != null, "Tile is null, asynchronous access? %s", CraftBlock.at(((CraftWorld) world).getHandle(), blockPosition));
|
||||
} else if (tileEntity == null) {
|
||||
tileEntity = this.createTileEntity(blockPosition, blockData);
|
||||
Preconditions.checkState(blockEntity != null, "Block entity is null, asynchronous access? %s", CraftBlock.at(((CraftWorld) world).getHandle(), pos));
|
||||
} else if (blockEntity == null) {
|
||||
blockEntity = this.createBlockEntity(pos, state);
|
||||
}
|
||||
return this.createBlockState(world, (T) tileEntity);
|
||||
return this.createBlockState(world, (T) blockEntity);
|
||||
}
|
||||
|
||||
private T createTileEntity(BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData) {
|
||||
return this.tileEntityConstructor.create(blockPosition, blockData); // Paper
|
||||
private T createBlockEntity(BlockPos pos, net.minecraft.world.level.block.state.BlockState state) {
|
||||
return this.blockEntityType.create(pos, state);
|
||||
}
|
||||
|
||||
private B createBlockState(World world, T tileEntity) {
|
||||
return this.blockStateConstructor.apply(world, tileEntity);
|
||||
private B createBlockState(World world, T blockEntity) {
|
||||
return this.blockStateConstructor.apply(world, blockEntity);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<Material, BlockStateFactory<?>> FACTORIES = new HashMap<>();
|
||||
private static final BlockStateFactory<?> DEFAULT_FACTORY = new BlockStateFactory<CraftBlockState>(CraftBlockState.class) {
|
||||
private static final BlockStateFactory<?> DEFAULT_FACTORY = new BlockStateFactory<>(CraftBlockState.class) {
|
||||
@Override
|
||||
public CraftBlockState createBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
|
||||
public CraftBlockState createBlockState(World world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, BlockEntity blockEntity) {
|
||||
// Paper - revert upstream's revert of the block state changes. Block entities that have already had the block type set to AIR are still valid, upstream decided to ignore them
|
||||
Preconditions.checkState(tileEntity == null, "Unexpected BlockState for %s", CraftBlockType.minecraftToBukkit(blockData.getBlock()));
|
||||
return new CraftBlockState(world, blockPosition, blockData);
|
||||
Preconditions.checkState(blockEntity == null, "Unexpected BlockState for %s", CraftBlockType.minecraftToBukkit(state.getBlock()));
|
||||
return new CraftBlockState(world, pos, state);
|
||||
}
|
||||
};
|
||||
// Paper start
|
||||
|
||||
private static final Map<BlockEntityType<?>, BlockStateFactory<?>> FACTORIES_BY_BLOCK_ENTITY_TYPE = new HashMap<>();
|
||||
private static void register(BlockEntityType<?> type, BlockStateFactory<?> factory) {
|
||||
FACTORIES_BY_BLOCK_ENTITY_TYPE.put(type, factory);
|
||||
}
|
||||
// Paper end
|
||||
|
||||
static {
|
||||
// Paper start - simplify
|
||||
register(BlockEntityType.SIGN, CraftSign.class, CraftSign::new);
|
||||
register(BlockEntityType.HANGING_SIGN, CraftHangingSign.class, CraftHangingSign::new);
|
||||
register(BlockEntityType.SKULL, CraftSkull.class, CraftSkull::new);
|
||||
register(BlockEntityType.COMMAND_BLOCK, CraftCommandBlock.class, CraftCommandBlock::new);
|
||||
// Start generate - CraftBlockEntityStates
|
||||
// @GeneratedFrom 1.21.5
|
||||
register(BlockEntityType.BANNER, CraftBanner.class, CraftBanner::new);
|
||||
register(BlockEntityType.SHULKER_BOX, CraftShulkerBox.class, CraftShulkerBox::new);
|
||||
register(BlockEntityType.BED, CraftBed.class, CraftBed::new);
|
||||
register(BlockEntityType.BEEHIVE, CraftBeehive.class, CraftBeehive::new);
|
||||
register(BlockEntityType.CAMPFIRE, CraftCampfire.class, CraftCampfire::new);
|
||||
register(BlockEntityType.BARREL, CraftBarrel.class, CraftBarrel::new);
|
||||
register(BlockEntityType.BEACON, CraftBeacon.class, CraftBeacon::new);
|
||||
register(BlockEntityType.BED, CraftBed.class, CraftBed::new);
|
||||
register(BlockEntityType.BEEHIVE, CraftBeehive.class, CraftBeehive::new);
|
||||
register(BlockEntityType.BELL, CraftBell.class, CraftBell::new);
|
||||
register(BlockEntityType.BLAST_FURNACE, CraftBlastFurnace.class, CraftBlastFurnace::new);
|
||||
register(BlockEntityType.BREWING_STAND, CraftBrewingStand.class, CraftBrewingStand::new);
|
||||
register(BlockEntityType.BRUSHABLE_BLOCK, CraftBrushableBlock.class, CraftBrushableBlock::new);
|
||||
register(BlockEntityType.CALIBRATED_SCULK_SENSOR, CraftCalibratedSculkSensor.class, CraftCalibratedSculkSensor::new);
|
||||
register(BlockEntityType.CAMPFIRE, CraftCampfire.class, CraftCampfire::new);
|
||||
register(BlockEntityType.CHEST, CraftChest.class, CraftChest::new);
|
||||
register(BlockEntityType.CHISELED_BOOKSHELF, CraftChiseledBookshelf.class, CraftChiseledBookshelf::new);
|
||||
register(BlockEntityType.COMMAND_BLOCK, CraftCommandBlock.class, CraftCommandBlock::new);
|
||||
register(BlockEntityType.COMPARATOR, CraftComparator.class, CraftComparator::new);
|
||||
register(BlockEntityType.CONDUIT, CraftConduit.class, CraftConduit::new);
|
||||
register(BlockEntityType.CRAFTER, CraftCrafter.class, CraftCrafter::new);
|
||||
register(BlockEntityType.CREAKING_HEART, CraftCreakingHeart.class, CraftCreakingHeart::new);
|
||||
register(BlockEntityType.DAYLIGHT_DETECTOR, CraftDaylightDetector.class, CraftDaylightDetector::new);
|
||||
register(BlockEntityType.DECORATED_POT, CraftDecoratedPot.class, CraftDecoratedPot::new);
|
||||
register(BlockEntityType.DISPENSER, CraftDispenser.class, CraftDispenser::new);
|
||||
register(BlockEntityType.DROPPER, CraftDropper.class, CraftDropper::new);
|
||||
register(BlockEntityType.ENCHANTING_TABLE, CraftEnchantingTable.class, CraftEnchantingTable::new);
|
||||
register(BlockEntityType.ENDER_CHEST, CraftEnderChest.class, CraftEnderChest::new);
|
||||
register(BlockEntityType.END_GATEWAY, CraftEndGateway.class, CraftEndGateway::new);
|
||||
register(BlockEntityType.END_PORTAL, CraftEndPortal.class, CraftEndPortal::new);
|
||||
register(BlockEntityType.ENDER_CHEST, CraftEnderChest.class, CraftEnderChest::new);
|
||||
register(BlockEntityType.FURNACE, CraftFurnaceFurnace.class, CraftFurnaceFurnace::new);
|
||||
register(BlockEntityType.HANGING_SIGN, CraftHangingSign.class, CraftHangingSign::new);
|
||||
register(BlockEntityType.HOPPER, CraftHopper.class, CraftHopper::new);
|
||||
register(BlockEntityType.JIGSAW, CraftJigsaw.class, CraftJigsaw::new);
|
||||
register(BlockEntityType.JUKEBOX, CraftJukebox.class, CraftJukebox::new);
|
||||
register(BlockEntityType.LECTERN, CraftLectern.class, CraftLectern::new);
|
||||
register(BlockEntityType.MOB_SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new);
|
||||
register(BlockEntityType.PISTON, CraftMovingPiston.class, CraftMovingPiston::new);
|
||||
register(BlockEntityType.SCULK_CATALYST, CraftSculkCatalyst.class, CraftSculkCatalyst::new);
|
||||
register(BlockEntityType.SCULK_SENSOR, CraftSculkSensor.class, CraftSculkSensor::new);
|
||||
register(BlockEntityType.SCULK_SHRIEKER, CraftSculkShrieker.class, CraftSculkShrieker::new);
|
||||
register(BlockEntityType.CALIBRATED_SCULK_SENSOR, CraftCalibratedSculkSensor.class, CraftCalibratedSculkSensor::new);
|
||||
register(BlockEntityType.SHULKER_BOX, CraftShulkerBox.class, CraftShulkerBox::new);
|
||||
register(BlockEntityType.SIGN, CraftSign.class, CraftSign::new);
|
||||
register(BlockEntityType.SKULL, CraftSkull.class, CraftSkull::new);
|
||||
register(BlockEntityType.SMOKER, CraftSmoker.class, CraftSmoker::new);
|
||||
register(BlockEntityType.MOB_SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new);
|
||||
register(BlockEntityType.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new);
|
||||
register(BlockEntityType.BRUSHABLE_BLOCK, CraftBrushableBlock.class, CraftBrushableBlock::new); // note: spigot still uses CraftSuspiciousSand impl for that block type
|
||||
register(BlockEntityType.TEST_BLOCK, CraftTestBlock.class, CraftTestBlock::new);
|
||||
register(BlockEntityType.TEST_INSTANCE_BLOCK, CraftTestInstanceBlock.class, CraftTestInstanceBlock::new);
|
||||
register(BlockEntityType.TRAPPED_CHEST, CraftChest.class, CraftChest::new);
|
||||
register(BlockEntityType.CRAFTER, CraftCrafter.class, CraftCrafter::new);
|
||||
register(BlockEntityType.TRIAL_SPAWNER, CraftTrialSpawner.class, CraftTrialSpawner::new);
|
||||
register(BlockEntityType.VAULT, CraftVault.class, CraftVault::new);
|
||||
// Paper end
|
||||
// End generate - CraftBlockEntityStates
|
||||
}
|
||||
|
||||
private static void register(Material blockType, BlockStateFactory<?> factory) {
|
||||
@@ -187,24 +141,21 @@ public final class CraftBlockStates {
|
||||
}
|
||||
|
||||
private static <T extends BlockEntity, B extends CraftBlockEntityState<T>> void register(
|
||||
net.minecraft.world.level.block.entity.BlockEntityType<? extends T> blockEntityType, // Paper
|
||||
net.minecraft.world.level.block.entity.BlockEntityType<? extends T> blockEntityType,
|
||||
Class<B> blockStateType,
|
||||
BiFunction<World, T, B> blockStateConstructor // Paper
|
||||
BiFunction<World, T, B> blockStateConstructor
|
||||
) {
|
||||
// Paper start
|
||||
BlockStateFactory<B> factory = new BlockEntityStateFactory<>(blockStateType, blockStateConstructor, blockEntityType); // Paper
|
||||
BlockStateFactory<B> factory = new BlockEntityStateFactory<>(blockStateType, blockStateConstructor, blockEntityType);
|
||||
for (net.minecraft.world.level.block.Block block : blockEntityType.validBlocks) {
|
||||
CraftBlockStates.register(CraftBlockType.minecraftToBukkit(block), factory);
|
||||
}
|
||||
CraftBlockStates.register(blockEntityType, factory);
|
||||
// Paper end
|
||||
}
|
||||
|
||||
private static BlockStateFactory<?> getFactory(Material material) {
|
||||
return CraftBlockStates.FACTORIES.getOrDefault(material, CraftBlockStates.DEFAULT_FACTORY);
|
||||
}
|
||||
|
||||
// Paper start
|
||||
private static BlockStateFactory<?> getFactory(Material material, BlockEntityType<?> type) {
|
||||
if (type != null) {
|
||||
return CraftBlockStates.FACTORIES_BY_BLOCK_ENTITY_TYPE.getOrDefault(type, getFactory(material));
|
||||
@@ -212,123 +163,108 @@ public final class CraftBlockStates {
|
||||
return getFactory(material);
|
||||
}
|
||||
}
|
||||
// Paper end
|
||||
|
||||
public static Class<? extends CraftBlockState> getBlockStateType(Material material) {
|
||||
Preconditions.checkNotNull(material, "material is null");
|
||||
return CraftBlockStates.getFactory(material).blockStateType;
|
||||
}
|
||||
|
||||
public static BlockEntity createNewTileEntity(Material material) {
|
||||
public static BlockEntity createNewBlockEntity(Material material) {
|
||||
BlockStateFactory<?> factory = CraftBlockStates.getFactory(material);
|
||||
|
||||
if (factory instanceof BlockEntityStateFactory) {
|
||||
return ((BlockEntityStateFactory<?, ?>) factory).createTileEntity(BlockPos.ZERO, CraftBlockType.bukkitToMinecraft(material).defaultBlockState());
|
||||
return ((BlockEntityStateFactory<?, ?>) factory).createBlockEntity(BlockPos.ZERO, CraftBlockType.bukkitToMinecraft(material).defaultBlockState());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Paper start
|
||||
public static Class<? extends CraftBlockState> getBlockStateType(BlockEntityType<?> blockEntityType) {
|
||||
Preconditions.checkNotNull(blockEntityType, "blockEntityType is null");
|
||||
return CraftBlockStates.getFactory(null, blockEntityType).blockStateType;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
public static BlockState getBlockState(Block block) {
|
||||
// Paper start
|
||||
return CraftBlockStates.getBlockState(block, true);
|
||||
}
|
||||
|
||||
public static BlockState getBlockState(Block block, boolean useSnapshot) {
|
||||
// Paper end
|
||||
Preconditions.checkNotNull(block, "block is null");
|
||||
CraftBlock craftBlock = (CraftBlock) block;
|
||||
CraftWorld world = (CraftWorld) block.getWorld();
|
||||
BlockPos blockPosition = craftBlock.getPosition();
|
||||
net.minecraft.world.level.block.state.BlockState blockData = craftBlock.getNMS();
|
||||
BlockEntity tileEntity = craftBlock.getHandle().getBlockEntity(blockPosition);
|
||||
// Paper start - block state snapshots
|
||||
BlockPos pos = craftBlock.getPosition();
|
||||
net.minecraft.world.level.block.state.BlockState state = craftBlock.getNMS();
|
||||
BlockEntity blockEntity = craftBlock.getHandle().getBlockEntity(pos);
|
||||
boolean prev = CraftBlockEntityState.DISABLE_SNAPSHOT;
|
||||
CraftBlockEntityState.DISABLE_SNAPSHOT = !useSnapshot;
|
||||
try {
|
||||
// Paper end
|
||||
CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockPosition, blockData, tileEntity);
|
||||
blockState.setWorldHandle(craftBlock.getHandle()); // Inject the block's generator access
|
||||
return blockState;
|
||||
// Paper start
|
||||
CraftBlockState blockState = CraftBlockStates.getBlockState(world, pos, state, blockEntity);
|
||||
blockState.setWorldHandle(craftBlock.getHandle()); // Inject the block's generator access
|
||||
return blockState;
|
||||
} finally {
|
||||
CraftBlockEntityState.DISABLE_SNAPSHOT = prev;
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static BlockState getBlockState(BlockPos blockPosition, Material material, @Nullable CompoundTag blockEntityTag) {
|
||||
return CraftBlockStates.getBlockState(MinecraftServer.getDefaultRegistryAccess(), blockPosition, material, blockEntityTag);
|
||||
public static BlockState getBlockState(BlockPos pos, Material material, @Nullable CompoundTag blockEntityTag) {
|
||||
return CraftBlockStates.getBlockState(CraftRegistry.getMinecraftRegistry(), pos, 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(LevelReader world, BlockPos pos, Material material, @Nullable CompoundTag blockEntityTag) {
|
||||
return CraftBlockStates.getBlockState(world.registryAccess(), pos, material, blockEntityTag);
|
||||
}
|
||||
|
||||
public static BlockState getBlockState(RegistryAccess registry, BlockPos blockPosition, Material material, @Nullable CompoundTag blockEntityTag) {
|
||||
public static BlockState getBlockState(RegistryAccess registry, BlockPos pos, Material material, @Nullable CompoundTag blockEntityTag) {
|
||||
Preconditions.checkNotNull(material, "material is null");
|
||||
net.minecraft.world.level.block.state.BlockState blockData = CraftBlockType.bukkitToMinecraft(material).defaultBlockState();
|
||||
return CraftBlockStates.getBlockState(registry, blockPosition, blockData, blockEntityTag);
|
||||
return CraftBlockStates.getBlockState(registry, pos, blockData, blockEntityTag);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
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(net.minecraft.world.level.block.state.BlockState state, @Nullable CompoundTag blockEntityTag) {
|
||||
return CraftBlockStates.getBlockState(CraftRegistry.getMinecraftRegistry(), BlockPos.ZERO, state, 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(LevelReader level, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState state, @Nullable CompoundTag blockEntityTag) {
|
||||
return CraftBlockStates.getBlockState(level.registryAccess(), blockPosition, state, 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");
|
||||
BlockEntity tileEntity = (blockEntityTag == null) ? null : BlockEntity.loadStatic(blockPosition, blockData, blockEntityTag, registry);
|
||||
return CraftBlockStates.getBlockState(null, blockPosition, blockData, tileEntity);
|
||||
public static BlockState getBlockState(RegistryAccess registry, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @Nullable CompoundTag blockEntityTag) {
|
||||
Preconditions.checkNotNull(pos, "pos is null");
|
||||
Preconditions.checkNotNull(state, "state is null");
|
||||
BlockEntity blockEntity = (blockEntityTag == null) ? null : BlockEntity.loadStatic(pos, state, blockEntityTag, registry); // todo create block entity from the state
|
||||
return CraftBlockStates.getBlockState(null, pos, state, blockEntity);
|
||||
}
|
||||
|
||||
// See BlockStateFactory#createBlockState(World, BlockPosition, IBlockData, 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());
|
||||
// See BlockStateFactory#createBlockState(World, BlockPos, BlockState, BlockEntity)
|
||||
public static CraftBlockState getBlockState(World world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, BlockEntity blockEntity) {
|
||||
Material material = CraftBlockType.minecraftToBukkit(state.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 && CraftBlockStates.isTileEntityOptional(material)) {
|
||||
// For some types of BlockEntity blocks (e.g. moving pistons), Minecraft may in some situations (e.g. when using Block#setType or the
|
||||
// setBlock command) not create a corresponding BlockEntity in the world. We return a normal BlockState in this case.
|
||||
if (world != null && blockEntity == null && CraftBlockStates.isBlockEntityOptional(material)) {
|
||||
factory = CraftBlockStates.DEFAULT_FACTORY;
|
||||
} else {
|
||||
factory = CraftBlockStates.getFactory(material, tileEntity != null ? tileEntity.getType() : null); // Paper
|
||||
factory = CraftBlockStates.getFactory(material, blockEntity != null ? blockEntity.getType() : null); // Paper
|
||||
}
|
||||
return factory.createBlockState(world, blockPosition, blockData, tileEntity);
|
||||
return factory.createBlockState(world, pos, state, blockEntity);
|
||||
}
|
||||
|
||||
public static boolean isTileEntityOptional(Material material) {
|
||||
public static boolean isBlockEntityOptional(Material material) {
|
||||
return material == Material.MOVING_PISTON;
|
||||
}
|
||||
|
||||
// This ignores tile entity data.
|
||||
// This ignores block entity data.
|
||||
public static CraftBlockState getBlockState(LevelAccessor world, BlockPos pos) {
|
||||
return new CraftBlockState(CraftBlock.at(world, pos));
|
||||
}
|
||||
|
||||
// This ignores tile entity data.
|
||||
public static CraftBlockState getBlockState(LevelAccessor world, BlockPos pos, int flag) {
|
||||
return new CraftBlockState(CraftBlock.at(world, pos), flag);
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@Nullable
|
||||
public static BlockEntityType<?> getBlockEntityType(final Material material) {
|
||||
final BlockStateFactory<?> factory = org.bukkit.craftbukkit.block.CraftBlockStates.FACTORIES.get(material);
|
||||
return factory instanceof final BlockEntityStateFactory<?,?> blockEntityStateFactory ? blockEntityStateFactory.tileEntityConstructor : null;
|
||||
return factory instanceof final BlockEntityStateFactory<?,?> blockEntityStateFactory ? blockEntityStateFactory.blockEntityType : null;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
private CraftBlockStates() {
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import io.papermc.paper.registry.HolderableBase;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Consumer;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.function.Supplier;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
@@ -21,7 +25,6 @@ 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;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockType;
|
||||
@@ -31,16 +34,14 @@ import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemType;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.util.Handleable;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
public class CraftBlockType<B extends BlockData> implements BlockType.Typed<B>, Handleable<Block>, io.papermc.paper.world.flag.PaperFeatureDependent { // Paper - feature flag API
|
||||
@NullMarked
|
||||
public class CraftBlockType<B extends @NonNull BlockData> extends HolderableBase<Block> implements BlockType.Typed<B>, io.papermc.paper.world.flag.PaperFeatureDependent<Block> { // Paper - feature flag API
|
||||
|
||||
private final NamespacedKey key;
|
||||
private final Block block;
|
||||
private final Class<B> blockDataClass;
|
||||
private final boolean interactable;
|
||||
|
||||
public static Material minecraftToBukkit(Block block) {
|
||||
return CraftMagicNumbers.getMaterial(block);
|
||||
@@ -92,30 +93,26 @@ public class CraftBlockType<B extends BlockData> implements BlockType.Typed<B>,
|
||||
return hasMethod;
|
||||
}
|
||||
|
||||
public CraftBlockType(NamespacedKey key, Block block) {
|
||||
this.key = key;
|
||||
this.block = block;
|
||||
this.blockDataClass = (Class<B>) CraftBlockData.fromData(block.defaultBlockState()).getClass().getInterfaces()[0];
|
||||
this.interactable = CraftBlockType.isInteractable(block);
|
||||
private final Supplier<Class<B>> blockDataClass;
|
||||
private final Supplier<Boolean> interactable;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CraftBlockType(final Holder<Block> holder) {
|
||||
super(holder);
|
||||
this.blockDataClass = Suppliers.memoize(() -> (Class<B>) CraftBlockData.fromData(this.getHandle().defaultBlockState()).getClass().getInterfaces()[0]);
|
||||
this.interactable = Suppliers.memoize(() -> CraftBlockType.isInteractable(this.getHandle()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getHandle() {
|
||||
return this.block;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Typed<BlockData> typed() {
|
||||
return this.typed(BlockData.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <Other extends BlockData> Typed<Other> typed(@NotNull Class<Other> blockDataType) {
|
||||
if (blockDataType.isAssignableFrom(this.blockDataClass)) return (Typed<Other>) this;
|
||||
throw new IllegalArgumentException("Cannot type block type " + this.key.toString() + " to blockdata type " + blockDataType.getSimpleName());
|
||||
public <Other extends BlockData> Typed<Other> typed(final Class<Other> blockDataType) {
|
||||
if (blockDataType.isAssignableFrom(this.blockDataClass.get())) return (Typed<Other>) this;
|
||||
throw new IllegalArgumentException("Cannot type block type " + this + " to blockdata type " + blockDataType.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,24 +121,23 @@ public class CraftBlockType<B extends BlockData> implements BlockType.Typed<B>,
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.block.asItem() != Items.AIR;
|
||||
return this.getHandle().asItem() != Items.AIR;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemType getItemType() {
|
||||
if (this == AIR) {
|
||||
return ItemType.AIR;
|
||||
}
|
||||
|
||||
Item item = this.block.asItem();
|
||||
Item item = this.getHandle().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 this.blockDataClass;
|
||||
return this.blockDataClass.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,17 +146,17 @@ public class CraftBlockType<B extends BlockData> implements BlockType.Typed<B>,
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<B> createBlockDataStates() {
|
||||
final ImmutableList<BlockState> possibleStates = this.block.getStateDefinition().getPossibleStates();
|
||||
public Collection<B> createBlockDataStates() {
|
||||
final ImmutableList<BlockState> possibleStates = this.getHandle().getStateDefinition().getPossibleStates();
|
||||
final ImmutableList.Builder<B> builder = ImmutableList.builderWithExpectedSize(possibleStates.size());
|
||||
for (final BlockState possibleState : possibleStates) {
|
||||
builder.add(this.blockDataClass.cast(possibleState.createCraftBlockData()));
|
||||
builder.add(this.blockDataClass.get().cast(possibleState.createCraftBlockData()));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public B createBlockData(Consumer<? super B> consumer) {
|
||||
public B createBlockData(final @Nullable Consumer<? super B> consumer) {
|
||||
B data = this.createBlockData();
|
||||
|
||||
if (consumer != null) {
|
||||
@@ -170,94 +166,89 @@ public class CraftBlockType<B extends BlockData> implements BlockType.Typed<B>,
|
||||
return data;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public B createBlockData(String data) {
|
||||
public B createBlockData(final @Nullable String data) {
|
||||
return (B) CraftBlockData.newData(this, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolid() {
|
||||
return this.block.defaultBlockState().blocksMotion();
|
||||
return this.getHandle().defaultBlockState().blocksMotion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir() {
|
||||
return this.block.defaultBlockState().isAir();
|
||||
return this.getHandle().defaultBlockState().isAir();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledByFeature(@NotNull World world) {
|
||||
public boolean isEnabledByFeature(final World world) {
|
||||
Preconditions.checkNotNull(world, "World cannot be null");
|
||||
return this.getHandle().isEnabled(((CraftWorld) world).getHandle().enabledFeatures());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlammable() {
|
||||
return this.block.defaultBlockState().ignitedByLava();
|
||||
return this.getHandle().defaultBlockState().ignitedByLava();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBurnable() {
|
||||
return ((FireBlock) Blocks.FIRE).igniteOdds.getOrDefault(this.block, 0) > 0;
|
||||
return ((FireBlock) Blocks.FIRE).igniteOdds.getOrDefault(this.getHandle(), 0) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOccluding() {
|
||||
return this.block.defaultBlockState().isRedstoneConductor(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
|
||||
return this.getHandle().defaultBlockState().isRedstoneConductor(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGravity() {
|
||||
return this.block instanceof Fallable;
|
||||
return this.getHandle() instanceof Fallable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInteractable() {
|
||||
return this.interactable;
|
||||
return this.interactable.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHardness() {
|
||||
return this.block.defaultBlockState().destroySpeed;
|
||||
return this.getHandle().defaultBlockState().destroySpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlastResistance() {
|
||||
return this.block.getExplosionResistance();
|
||||
return this.getHandle().getExplosionResistance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSlipperiness() {
|
||||
return this.block.getFriction();
|
||||
return this.getHandle().getFriction();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getTranslationKey() {
|
||||
return this.block.getDescriptionId();
|
||||
return this.getHandle().getDescriptionId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material asMaterial() {
|
||||
return Registry.MATERIAL.get(this.key);
|
||||
public @Nullable Material asMaterial() {
|
||||
return Registry.MATERIAL.get(this.getKey());
|
||||
}
|
||||
|
||||
// Paper start - add Translatable
|
||||
@Override
|
||||
public String translationKey() {
|
||||
return this.block.getDescriptionId();
|
||||
return this.getHandle().getDescriptionId();
|
||||
}
|
||||
// Paper end - add Translatable
|
||||
|
||||
// Paper start - hasCollision API
|
||||
@Override
|
||||
public boolean hasCollision() {
|
||||
return this.block.hasCollision;
|
||||
return this.getHandle().hasCollision;
|
||||
}
|
||||
// Paper end - hasCollision API
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import org.bukkit.inventory.BrewerInventory;
|
||||
|
||||
public class CraftBrewingStand extends CraftContainer<BrewingStandBlockEntity> implements BrewingStand {
|
||||
|
||||
public CraftBrewingStand(World world, BrewingStandBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftBrewingStand(World world, BrewingStandBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftBrewingStand(CraftBrewingStand state, Location location) {
|
||||
@@ -28,7 +28,7 @@ public class CraftBrewingStand extends CraftContainer<BrewingStandBlockEntity> i
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventoryBrewer(this.getTileEntity());
|
||||
return new CraftInventoryBrewer(this.getBlockEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,8 +11,8 @@ import org.bukkit.loot.LootTable;
|
||||
|
||||
public class CraftBrushableBlock extends CraftBlockEntityState<BrushableBlockEntity> implements BrushableBlock {
|
||||
|
||||
public CraftBrushableBlock(World world, BrushableBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftBrushableBlock(World world, BrushableBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftBrushableBlock(CraftBrushableBlock state, Location location) {
|
||||
@@ -30,11 +30,11 @@ public class CraftBrushableBlock extends CraftBlockEntityState<BrushableBlockEnt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(BrushableBlockEntity lootable) {
|
||||
super.applyTo(lootable);
|
||||
public void applyTo(BrushableBlockEntity blockEntity) {
|
||||
super.applyTo(blockEntity);
|
||||
|
||||
if (this.getSnapshot().lootTable == null) {
|
||||
lootable.setLootTable(null, 0L);
|
||||
blockEntity.setLootTable(null, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ import org.bukkit.block.CalibratedSculkSensor;
|
||||
|
||||
public class CraftCalibratedSculkSensor extends CraftSculkSensor<CalibratedSculkSensorBlockEntity> implements CalibratedSculkSensor {
|
||||
|
||||
public CraftCalibratedSculkSensor(World world, CalibratedSculkSensorBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftCalibratedSculkSensor(World world, CalibratedSculkSensorBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftCalibratedSculkSensor(CraftCalibratedSculkSensor state, Location location) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.world.level.block.entity.CampfireBlockEntity;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@@ -9,8 +10,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CraftCampfire extends CraftBlockEntityState<CampfireBlockEntity> implements Campfire {
|
||||
|
||||
public CraftCampfire(World world, CampfireBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftCampfire(World world, CampfireBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftCampfire(CraftCampfire state, Location location) {
|
||||
@@ -63,39 +64,37 @@ public class CraftCampfire extends CraftBlockEntityState<CampfireBlockEntity> im
|
||||
return new CraftCampfire(this, location);
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@Override
|
||||
public void stopCooking() {
|
||||
for (int i = 0; i < getSnapshot().stopCooking.length; ++i)
|
||||
for (int i = 0; i < this.getSnapshot().stopCooking.length; ++i)
|
||||
this.stopCooking(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startCooking() {
|
||||
for (int i = 0; i < getSnapshot().stopCooking.length; ++i)
|
||||
for (int i = 0; i < this.getSnapshot().stopCooking.length; ++i)
|
||||
this.startCooking(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopCooking(int index) {
|
||||
org.apache.commons.lang.Validate.isTrue(-1 < index && index < 4, "Slot index must be between 0 (incl) to 3 (incl)");
|
||||
Preconditions.checkArgument(-1 < index && index < 4, "Slot index must be between 0 (incl) to 3 (incl)");
|
||||
boolean previous = this.isCookingDisabled(index);
|
||||
getSnapshot().stopCooking[index] = true;
|
||||
this.getSnapshot().stopCooking[index] = true;
|
||||
return previous;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startCooking(int index) {
|
||||
org.apache.commons.lang.Validate.isTrue(-1 < index && index < 4, "Slot index must be between 0 (incl) to 3 (incl)");
|
||||
Preconditions.checkArgument(-1 < index && index < 4, "Slot index must be between 0 (incl) to 3 (incl)");
|
||||
boolean previous = this.isCookingDisabled(index);
|
||||
getSnapshot().stopCooking[index] = false;
|
||||
this.getSnapshot().stopCooking[index] = false;
|
||||
return previous;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCookingDisabled(int index) {
|
||||
org.apache.commons.lang.Validate.isTrue(-1 < index && index < 4, "Slot index must be between 0 (incl) to 3 (incl)");
|
||||
return getSnapshot().stopCooking[index];
|
||||
Preconditions.checkArgument(-1 < index && index < 4, "Slot index must be between 0 (incl) to 3 (incl)");
|
||||
return this.getSnapshot().stopCooking[index];
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftChest extends CraftLootable<ChestBlockEntity> implements Chest {
|
||||
|
||||
public CraftChest(World world, ChestBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftChest(World world, ChestBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftChest(CraftChest state, Location location) {
|
||||
@@ -35,7 +35,7 @@ public class CraftChest extends CraftLootable<ChestBlockEntity> implements Chest
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventory(this.getTileEntity());
|
||||
return new CraftInventory(this.getBlockEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,27 +60,27 @@ public class CraftChest extends CraftLootable<ChestBlockEntity> implements Chest
|
||||
@Override
|
||||
public void open() {
|
||||
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();
|
||||
if (!this.getBlockEntity().openersCounter.opened && this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
|
||||
BlockState block = this.getBlockEntity().getBlockState();
|
||||
int openCount = this.getBlockEntity().openersCounter.getOpenerCount();
|
||||
|
||||
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);
|
||||
this.getBlockEntity().openersCounter.onAPIOpen((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block);
|
||||
this.getBlockEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block, openCount, openCount + 1);
|
||||
}
|
||||
this.getTileEntity().openersCounter.opened = true;
|
||||
this.getBlockEntity().openersCounter.opened = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
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();
|
||||
if (this.getBlockEntity().openersCounter.opened && this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
|
||||
BlockState block = this.getBlockEntity().getBlockState();
|
||||
int openCount = this.getBlockEntity().openersCounter.getOpenerCount();
|
||||
|
||||
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);
|
||||
this.getBlockEntity().openersCounter.onAPIClose((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block);
|
||||
this.getBlockEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block, openCount, 0);
|
||||
}
|
||||
this.getTileEntity().openersCounter.opened = false;
|
||||
this.getBlockEntity().openersCounter.opened = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,7 +96,7 @@ public class CraftChest extends CraftLootable<ChestBlockEntity> implements Chest
|
||||
// Paper start - More Lidded Block API
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return getTileEntity().openersCounter.opened;
|
||||
return getBlockEntity().openersCounter.opened;
|
||||
}
|
||||
// Paper end - More Lidded Block API
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftChiseledBookshelf extends CraftBlockEntityState<ChiseledBookShelfBlockEntity> implements ChiseledBookshelf {
|
||||
|
||||
public CraftChiseledBookshelf(World world, ChiseledBookShelfBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftChiseledBookshelf(World world, ChiseledBookShelfBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftChiseledBookshelf(CraftChiseledBookshelf state, Location location) {
|
||||
@@ -43,7 +43,7 @@ public class CraftChiseledBookshelf extends CraftBlockEntityState<ChiseledBookSh
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventoryChiseledBookshelf(this.getTileEntity());
|
||||
return new CraftInventoryChiseledBookshelf(this.getBlockEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,8 +8,8 @@ import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
|
||||
public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity> implements CommandBlock, io.papermc.paper.commands.PaperCommandBlockHolder {
|
||||
|
||||
public CraftCommandBlock(World world, CommandBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftCommandBlock(World world, CommandBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftCommandBlock(CraftCommandBlock state, Location location) {
|
||||
@@ -46,20 +46,18 @@ public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity>
|
||||
return new CraftCommandBlock(this, location);
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@Override
|
||||
public net.kyori.adventure.text.Component name() {
|
||||
return io.papermc.paper.adventure.PaperAdventure.asAdventure(getSnapshot().getCommandBlock().getName());
|
||||
return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getSnapshot().getCommandBlock().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void name(net.kyori.adventure.text.Component name) {
|
||||
getSnapshot().getCommandBlock().setCustomName(name == null ? net.minecraft.network.chat.Component.literal("@") : io.papermc.paper.adventure.PaperAdventure.asVanilla(name));
|
||||
this.getSnapshot().getCommandBlock().setCustomName(name == null ? net.minecraft.network.chat.Component.literal("@") : io.papermc.paper.adventure.PaperAdventure.asVanilla(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.level.BaseCommandBlock getCommandBlockHandle() {
|
||||
return getSnapshot().getCommandBlock();
|
||||
return this.getSnapshot().getCommandBlock();
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import org.bukkit.block.Comparator;
|
||||
|
||||
public class CraftComparator extends CraftBlockEntityState<ComparatorBlockEntity> implements Comparator {
|
||||
|
||||
public CraftComparator(World world, ComparatorBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftComparator(World world, ComparatorBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftComparator(CraftComparator state, Location location) {
|
||||
|
||||
@@ -15,8 +15,8 @@ import org.bukkit.util.BoundingBox;
|
||||
|
||||
public class CraftConduit extends CraftBlockEntityState<ConduitBlockEntity> implements Conduit {
|
||||
|
||||
public CraftConduit(World world, ConduitBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftConduit(World world, ConduitBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftConduit(CraftConduit state, Location location) {
|
||||
@@ -36,14 +36,14 @@ public class CraftConduit extends CraftBlockEntityState<ConduitBlockEntity> impl
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
this.ensureNoWorldGeneration();
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getBlockEntityFromWorld();
|
||||
return conduit != null && conduit.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHunting() {
|
||||
this.ensureNoWorldGeneration();
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getBlockEntityFromWorld();
|
||||
return conduit != null && conduit.isHunting();
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class CraftConduit extends CraftBlockEntityState<ConduitBlockEntity> impl
|
||||
this.ensureNoWorldGeneration();
|
||||
Collection<Block> blocks = new ArrayList<>();
|
||||
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getBlockEntityFromWorld();
|
||||
if (conduit != null) {
|
||||
for (BlockPos position : conduit.effectBlocks) {
|
||||
blocks.add(CraftBlock.at(this.getWorldHandle(), position));
|
||||
@@ -65,20 +65,20 @@ public class CraftConduit extends CraftBlockEntityState<ConduitBlockEntity> impl
|
||||
@Override
|
||||
public int getFrameBlockCount() {
|
||||
this.ensureNoWorldGeneration();
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getBlockEntityFromWorld();
|
||||
return (conduit != null) ? conduit.effectBlocks.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRange() {
|
||||
this.ensureNoWorldGeneration();
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getBlockEntityFromWorld();
|
||||
return (conduit != null) ? ConduitBlockEntity.getRange(conduit.effectBlocks) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setTarget(LivingEntity target) {
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getBlockEntityFromWorld();
|
||||
if (conduit == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public class CraftConduit extends CraftBlockEntityState<ConduitBlockEntity> impl
|
||||
|
||||
@Override
|
||||
public LivingEntity getTarget() {
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getBlockEntityFromWorld();
|
||||
if (conduit == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public class CraftConduit extends CraftBlockEntityState<ConduitBlockEntity> impl
|
||||
|
||||
@Override
|
||||
public boolean hasTarget() {
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getTileEntityFromWorld();
|
||||
ConduitBlockEntity conduit = (ConduitBlockEntity) this.getBlockEntityFromWorld();
|
||||
return conduit != null && conduit.destroyTarget != null && conduit.destroyTarget.isAlive();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@ package org.bukkit.craftbukkit.block;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.advancements.critereon.DataComponentMatchers;
|
||||
import net.minecraft.advancements.critereon.ItemPredicate;
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||
import net.minecraft.core.component.DataComponentPredicate;
|
||||
import net.minecraft.core.component.DataComponentExactPredicate;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.LockCode;
|
||||
@@ -18,8 +19,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public abstract class CraftContainer<T extends BaseContainerBlockEntity> extends CraftBlockEntityState<T> implements Container {
|
||||
|
||||
public CraftContainer(World world, T tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftContainer(World world, T blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftContainer(CraftContainer<T> state, Location location) {
|
||||
@@ -33,7 +34,7 @@ public abstract class CraftContainer<T extends BaseContainerBlockEntity> extends
|
||||
|
||||
@Override
|
||||
public String getLock() {
|
||||
Optional<? extends Component> customName = this.getSnapshot().lockKey.predicate().components().asPatch().get(DataComponents.CUSTOM_NAME);
|
||||
Optional<? extends Component> customName = this.getSnapshot().lockKey.predicate().components().exact().asPatch().get(DataComponents.CUSTOM_NAME);
|
||||
|
||||
return (customName != null) ? customName.map(CraftChatMessage::fromComponent).orElse("") : "";
|
||||
}
|
||||
@@ -43,8 +44,8 @@ public abstract class CraftContainer<T extends BaseContainerBlockEntity> extends
|
||||
if (key == null) {
|
||||
this.getSnapshot().lockKey = LockCode.NO_LOCK;
|
||||
} else {
|
||||
DataComponentPredicate predicate = DataComponentPredicate.builder().expect(DataComponents.CUSTOM_NAME, CraftChatMessage.fromStringOrNull(key)).build();
|
||||
this.getSnapshot().lockKey = new LockCode(new ItemPredicate(Optional.empty(), MinMaxBounds.Ints.ANY, predicate, Collections.emptyMap()));
|
||||
DataComponentExactPredicate predicate = DataComponentExactPredicate.builder().expect(DataComponents.CUSTOM_NAME, CraftChatMessage.fromStringOrNull(key)).build();
|
||||
this.getSnapshot().lockKey = new LockCode(new ItemPredicate(Optional.empty(), MinMaxBounds.Ints.ANY, new DataComponentMatchers(predicate, Collections.emptyMap())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,18 +58,16 @@ public abstract class CraftContainer<T extends BaseContainerBlockEntity> extends
|
||||
}
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@Override
|
||||
public net.kyori.adventure.text.Component customName() {
|
||||
final T be = this.getSnapshot();
|
||||
return be.hasCustomName() ? io.papermc.paper.adventure.PaperAdventure.asAdventure(be.getCustomName()) : null;
|
||||
final T blockEntity = this.getSnapshot();
|
||||
return blockEntity.hasCustomName() ? io.papermc.paper.adventure.PaperAdventure.asAdventure(blockEntity.getCustomName()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customName(final net.kyori.adventure.text.Component customName) {
|
||||
this.getSnapshot().name = (customName != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(customName) : null);
|
||||
this.getSnapshot().name = customName != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(customName) : null;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
@Override
|
||||
public String getCustomName() {
|
||||
@@ -82,11 +81,11 @@ public abstract class CraftContainer<T extends BaseContainerBlockEntity> extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(T container) {
|
||||
super.applyTo(container);
|
||||
public void applyTo(T blockEntity) {
|
||||
super.applyTo(blockEntity);
|
||||
|
||||
if (this.getSnapshot().name == null) {
|
||||
container.name = null;
|
||||
blockEntity.name = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftCrafter extends CraftLootable<CrafterBlockEntity> implements Crafter {
|
||||
|
||||
public CraftCrafter(World world, CrafterBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftCrafter(World world, CrafterBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftCrafter(CraftCrafter state, Location location) {
|
||||
@@ -29,7 +29,7 @@ public class CraftCrafter extends CraftLootable<CrafterBlockEntity> implements C
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventory(this.getTileEntity());
|
||||
return new CraftInventory(this.getBlockEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,8 +7,8 @@ import org.bukkit.block.CreakingHeart;
|
||||
|
||||
public class CraftCreakingHeart extends CraftBlockEntityState<CreakingHeartBlockEntity> implements CreakingHeart {
|
||||
|
||||
public CraftCreakingHeart(World world, CreakingHeartBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftCreakingHeart(World world, CreakingHeartBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftCreakingHeart(CraftCreakingHeart state, Location location) {
|
||||
|
||||
@@ -11,8 +11,8 @@ import java.util.stream.Collectors;
|
||||
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.Wrapper;
|
||||
import net.minecraft.util.random.Weighted;
|
||||
import net.minecraft.util.random.WeightedList;
|
||||
import net.minecraft.world.entity.EquipmentTable;
|
||||
import net.minecraft.world.level.BaseSpawner;
|
||||
import net.minecraft.world.level.SpawnData;
|
||||
@@ -31,8 +31,8 @@ import org.bukkit.entity.EntityType;
|
||||
|
||||
public class CraftCreatureSpawner extends CraftBlockEntityState<SpawnerBlockEntity> implements CreatureSpawner, org.bukkit.craftbukkit.spawner.PaperSharedSpawnerLogic { // Paper - more spawner API
|
||||
|
||||
public CraftCreatureSpawner(World world, SpawnerBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftCreatureSpawner(World world, SpawnerBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftCreatureSpawner(CraftCreatureSpawner state, Location location) {
|
||||
@@ -53,7 +53,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<SpawnerBlockEnti
|
||||
@Override
|
||||
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().spawnPotentials = WeightedList.of(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later
|
||||
this.getSnapshot().getSpawner().nextSpawnData = new SpawnData();
|
||||
return;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<SpawnerBlockEnti
|
||||
}
|
||||
|
||||
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
|
||||
spawner.spawnPotentials = WeightedList.of(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later
|
||||
|
||||
if (snapshot == null) {
|
||||
spawner.nextSpawnData = new SpawnData();
|
||||
@@ -107,8 +107,8 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<SpawnerBlockEnti
|
||||
|
||||
CompoundTag compoundTag = ((CraftEntitySnapshot) snapshot).getData();
|
||||
|
||||
SimpleWeightedRandomList.Builder<SpawnData> builder = SimpleWeightedRandomList.builder(); // PAIL rename Builder
|
||||
spawner.spawnPotentials.unwrap().forEach(entry -> builder.add(entry.data(), entry.getWeight().asInt()));
|
||||
WeightedList.Builder<SpawnData> builder = WeightedList.builder();
|
||||
spawner.spawnPotentials.unwrap().forEach(entry -> builder.add(entry.value(), entry.weight()));
|
||||
builder.add(new SpawnData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnRule)), CraftCreatureSpawner.getEquipment(equipment)), weight);
|
||||
spawner.spawnPotentials = builder.build();
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<SpawnerBlockEnti
|
||||
public static void setPotentialSpawns(BaseSpawner spawner, Collection<SpawnerEntry> entries) {
|
||||
Preconditions.checkArgument(entries != null, "Entries cannot be null");
|
||||
|
||||
SimpleWeightedRandomList.Builder<SpawnData> builder = SimpleWeightedRandomList.builder();
|
||||
WeightedList.Builder<SpawnData> builder = WeightedList.builder();
|
||||
for (SpawnerEntry spawnerEntry : entries) {
|
||||
CompoundTag compoundTag = ((CraftEntitySnapshot) spawnerEntry.getSnapshot()).getData();
|
||||
builder.add(new SpawnData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnerEntry.getSpawnRule())), CraftCreatureSpawner.getEquipment(spawnerEntry.getEquipment())), spawnerEntry.getSpawnWeight());
|
||||
@@ -144,18 +144,18 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<SpawnerBlockEnti
|
||||
public static List<SpawnerEntry> getPotentialSpawns(BaseSpawner spawner) {
|
||||
List<SpawnerEntry> entries = new ArrayList<>();
|
||||
|
||||
for (Wrapper<SpawnData> entry : spawner.spawnPotentials.unwrap()) { // PAIL rename Wrapper
|
||||
CraftEntitySnapshot snapshot = CraftEntitySnapshot.create(entry.data().getEntityToSpawn());
|
||||
for (Weighted<SpawnData> entry : spawner.spawnPotentials.unwrap()) {
|
||||
CraftEntitySnapshot snapshot = CraftEntitySnapshot.create(entry.value().getEntityToSpawn());
|
||||
|
||||
if (snapshot != null) {
|
||||
SpawnRule rule = entry.data().customSpawnRules().map(CraftCreatureSpawner::fromMinecraftRule).orElse(null);
|
||||
entries.add(new SpawnerEntry(snapshot, entry.getWeight().asInt(), rule, CraftCreatureSpawner.getEquipment(entry.data().equipment())));
|
||||
SpawnRule rule = entry.value().customSpawnRules().map(CraftCreatureSpawner::fromMinecraftRule).orElse(null);
|
||||
entries.add(new SpawnerEntry(snapshot, entry.weight(), rule, CraftCreatureSpawner.getEquipment(entry.value().equipment())));
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
public static SpawnData.CustomSpawnRules toMinecraftRule(SpawnRule rule) { // PAIL rename CustomSpawnRules
|
||||
public static SpawnData.CustomSpawnRules toMinecraftRule(SpawnRule rule) {
|
||||
if (rule == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -292,7 +292,6 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<SpawnerBlockEnti
|
||||
)).orElse(null);
|
||||
}
|
||||
|
||||
// Paper start - more spawner API
|
||||
@Override
|
||||
public boolean isActivated() {
|
||||
requirePlaced();
|
||||
@@ -324,5 +323,4 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<SpawnerBlockEnti
|
||||
public net.minecraft.world.level.Level getInternalWorld() {
|
||||
return this.world.getHandle();
|
||||
}
|
||||
// Paper end - more spawner API
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import org.bukkit.block.DaylightDetector;
|
||||
|
||||
public class CraftDaylightDetector extends CraftBlockEntityState<DaylightDetectorBlockEntity> implements DaylightDetector {
|
||||
|
||||
public CraftDaylightDetector(World world, DaylightDetectorBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftDaylightDetector(World world, DaylightDetectorBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftDaylightDetector(CraftDaylightDetector state, Location location) {
|
||||
|
||||
@@ -21,8 +21,8 @@ import org.bukkit.inventory.DecoratedPotInventory;
|
||||
|
||||
public class CraftDecoratedPot extends CraftBlockEntityState<DecoratedPotBlockEntity> implements DecoratedPot {
|
||||
|
||||
public CraftDecoratedPot(World world, DecoratedPotBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftDecoratedPot(World world, DecoratedPotBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftDecoratedPot(CraftDecoratedPot state, Location location) {
|
||||
@@ -40,7 +40,7 @@ public class CraftDecoratedPot extends CraftBlockEntityState<DecoratedPotBlockEn
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventoryDecoratedPot(this.getTileEntity());
|
||||
return new CraftInventoryDecoratedPot(this.getBlockEntity());
|
||||
}
|
||||
|
||||
// Paper start - expose loot table
|
||||
|
||||
@@ -16,8 +16,8 @@ import org.bukkit.projectiles.BlockProjectileSource;
|
||||
|
||||
public class CraftDispenser extends CraftLootable<DispenserBlockEntity> implements Dispenser {
|
||||
|
||||
public CraftDispenser(World world, DispenserBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftDispenser(World world, DispenserBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftDispenser(CraftDispenser state, Location location) {
|
||||
@@ -35,7 +35,7 @@ public class CraftDispenser extends CraftLootable<DispenserBlockEntity> implemen
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventory(this.getTileEntity());
|
||||
return new CraftInventory(this.getBlockEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,7 +46,7 @@ public class CraftDispenser extends CraftLootable<DispenserBlockEntity> implemen
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CraftBlockProjectileSource((DispenserBlockEntity) this.getTileEntityFromWorld());
|
||||
return new CraftBlockProjectileSource((DispenserBlockEntity) this.getBlockEntityFromWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,8 +14,8 @@ import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftDropper extends CraftLootable<DropperBlockEntity> implements Dropper {
|
||||
|
||||
public CraftDropper(World world, DropperBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftDropper(World world, DropperBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftDropper(CraftDropper state, Location location) {
|
||||
@@ -33,7 +33,7 @@ public class CraftDropper extends CraftLootable<DropperBlockEntity> implements D
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventory(this.getTileEntity());
|
||||
return new CraftInventory(this.getBlockEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,26 +8,24 @@ import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
|
||||
public class CraftEnchantingTable extends CraftBlockEntityState<EnchantingTableBlockEntity> implements EnchantingTable {
|
||||
|
||||
public CraftEnchantingTable(World world, EnchantingTableBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftEnchantingTable(World world, EnchantingTableBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftEnchantingTable(CraftEnchantingTable state, Location location) {
|
||||
super(state, location);
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@Override
|
||||
public net.kyori.adventure.text.Component customName() {
|
||||
final EnchantingTableBlockEntity be = this.getSnapshot();
|
||||
return be.hasCustomName() ? io.papermc.paper.adventure.PaperAdventure.asAdventure(be.getCustomName()) : null;
|
||||
final EnchantingTableBlockEntity enchantingTable = this.getSnapshot();
|
||||
return enchantingTable.hasCustomName() ? io.papermc.paper.adventure.PaperAdventure.asAdventure(enchantingTable.getCustomName()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customName(final net.kyori.adventure.text.Component customName) {
|
||||
this.getSnapshot().setCustomName(customName != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(customName) : null);
|
||||
}
|
||||
// Paper end
|
||||
|
||||
@Override
|
||||
public String getCustomName() {
|
||||
@@ -41,11 +39,11 @@ public class CraftEnchantingTable extends CraftBlockEntityState<EnchantingTableB
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(EnchantingTableBlockEntity enchantingTable) {
|
||||
super.applyTo(enchantingTable);
|
||||
public void applyTo(EnchantingTableBlockEntity blockEntity) {
|
||||
super.applyTo(blockEntity);
|
||||
|
||||
if (!this.getSnapshot().hasCustomName()) {
|
||||
enchantingTable.setCustomName(null);
|
||||
blockEntity.setCustomName(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
|
||||
public class CraftEndGateway extends CraftBlockEntityState<TheEndGatewayBlockEntity> implements EndGateway {
|
||||
|
||||
public CraftEndGateway(World world, TheEndGatewayBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftEndGateway(World world, TheEndGatewayBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftEndGateway(CraftEndGateway state, Location location) {
|
||||
@@ -56,11 +56,11 @@ public class CraftEndGateway extends CraftBlockEntityState<TheEndGatewayBlockEnt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(TheEndGatewayBlockEntity endGateway) {
|
||||
super.applyTo(endGateway);
|
||||
public void applyTo(TheEndGatewayBlockEntity blockEntity) {
|
||||
super.applyTo(blockEntity);
|
||||
|
||||
if (this.getSnapshot().exitPortal == null) {
|
||||
endGateway.exitPortal = null;
|
||||
blockEntity.exitPortal = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import org.bukkit.World;
|
||||
|
||||
public class CraftEndPortal extends CraftBlockEntityState<TheEndPortalBlockEntity> {
|
||||
|
||||
public CraftEndPortal(World world, TheEndPortalBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftEndPortal(World world, TheEndPortalBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftEndPortal(CraftEndPortal state, Location location) {
|
||||
|
||||
@@ -8,8 +8,8 @@ import org.bukkit.block.EnderChest;
|
||||
|
||||
public class CraftEnderChest extends CraftBlockEntityState<EnderChestBlockEntity> implements EnderChest {
|
||||
|
||||
public CraftEnderChest(World world, EnderChestBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftEnderChest(World world, EnderChestBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftEnderChest(CraftEnderChest state, Location location) {
|
||||
@@ -19,27 +19,27 @@ public class CraftEnderChest extends CraftBlockEntityState<EnderChestBlockEntity
|
||||
@Override
|
||||
public void open() {
|
||||
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();
|
||||
if (!this.getBlockEntity().openersCounter.opened && this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
|
||||
BlockState block = this.getBlockEntity().getBlockState();
|
||||
int openCount = this.getBlockEntity().openersCounter.getOpenerCount();
|
||||
|
||||
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);
|
||||
this.getBlockEntity().openersCounter.onAPIOpen((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block);
|
||||
this.getBlockEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block, openCount, openCount + 1);
|
||||
}
|
||||
this.getTileEntity().openersCounter.opened = true;
|
||||
this.getBlockEntity().openersCounter.opened = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
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();
|
||||
if (this.getBlockEntity().openersCounter.opened && this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
|
||||
BlockState block = this.getBlockEntity().getBlockState();
|
||||
int openCount = this.getBlockEntity().openersCounter.getOpenerCount();
|
||||
|
||||
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);
|
||||
this.getBlockEntity().openersCounter.onAPIClose((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block);
|
||||
this.getBlockEntity().openersCounter.openerAPICountChanged((net.minecraft.world.level.Level) this.getWorldHandle(), this.getPosition(), block, openCount, 0);
|
||||
}
|
||||
this.getTileEntity().openersCounter.opened = false;
|
||||
this.getBlockEntity().openersCounter.opened = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +55,7 @@ public class CraftEnderChest extends CraftBlockEntityState<EnderChestBlockEntity
|
||||
// Paper start - More Lidded Block API
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return getTileEntity().openersCounter.opened;
|
||||
return getBlockEntity().openersCounter.opened;
|
||||
}
|
||||
// Paper end - More Lidded Block API
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ import org.bukkit.inventory.Recipe;
|
||||
|
||||
public abstract class CraftFurnace<T extends AbstractFurnaceBlockEntity> extends CraftContainer<T> implements Furnace {
|
||||
|
||||
public CraftFurnace(World world, T tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftFurnace(World world, T blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftFurnace(CraftFurnace<T> state, Location location) {
|
||||
@@ -35,7 +35,7 @@ public abstract class CraftFurnace<T extends AbstractFurnaceBlockEntity> extends
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventoryFurnace(this.getTileEntity());
|
||||
return new CraftInventoryFurnace(this.getBlockEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,8 +6,8 @@ import org.bukkit.World;
|
||||
|
||||
public class CraftFurnaceFurnace extends CraftFurnace<FurnaceBlockEntity> {
|
||||
|
||||
public CraftFurnaceFurnace(World world, FurnaceBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftFurnaceFurnace(World world, FurnaceBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftFurnaceFurnace(CraftFurnaceFurnace state, Location location) {
|
||||
|
||||
@@ -7,8 +7,8 @@ import org.bukkit.block.HangingSign;
|
||||
|
||||
public class CraftHangingSign extends CraftSign<HangingSignBlockEntity> implements HangingSign {
|
||||
|
||||
public CraftHangingSign(World world, HangingSignBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftHangingSign(World world, HangingSignBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftHangingSign(CraftHangingSign state, Location location) {
|
||||
|
||||
@@ -9,8 +9,8 @@ import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftHopper extends CraftLootable<HopperBlockEntity> implements Hopper {
|
||||
|
||||
public CraftHopper(World world, HopperBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftHopper(World world, HopperBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftHopper(CraftHopper state, Location location) {
|
||||
@@ -28,7 +28,7 @@ public class CraftHopper extends CraftLootable<HopperBlockEntity> implements Hop
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventory(this.getTileEntity());
|
||||
return new CraftInventory(this.getBlockEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,8 +7,8 @@ import org.bukkit.block.Jigsaw;
|
||||
|
||||
public class CraftJigsaw extends CraftBlockEntityState<JigsawBlockEntity> implements Jigsaw {
|
||||
|
||||
public CraftJigsaw(World world, JigsawBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftJigsaw(World world, JigsawBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftJigsaw(CraftJigsaw state, Location location) {
|
||||
|
||||
@@ -15,8 +15,8 @@ import org.bukkit.inventory.JukeboxInventory;
|
||||
|
||||
public class CraftJukebox extends CraftBlockEntityState<JukeboxBlockEntity> implements Jukebox {
|
||||
|
||||
public CraftJukebox(World world, JukeboxBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftJukebox(World world, JukeboxBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftJukebox(CraftJukebox state, Location location) {
|
||||
@@ -34,7 +34,7 @@ public class CraftJukebox extends CraftBlockEntityState<JukeboxBlockEntity> impl
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventoryJukebox(this.getTileEntity());
|
||||
return new CraftInventoryJukebox(this.getBlockEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,8 +44,8 @@ public class CraftJukebox extends CraftBlockEntityState<JukeboxBlockEntity> impl
|
||||
if (result && this.isPlaced() && this.getType() == Material.JUKEBOX) {
|
||||
this.getWorldHandle().setBlock(this.getPosition(), this.data, 3);
|
||||
|
||||
BlockEntity tileEntity = this.getTileEntityFromWorld();
|
||||
if (tileEntity instanceof JukeboxBlockEntity jukebox) {
|
||||
BlockEntity blockEntity = this.getBlockEntityFromWorld();
|
||||
if (blockEntity instanceof JukeboxBlockEntity jukebox) {
|
||||
jukebox.setTheItem(jukebox.getTheItem());
|
||||
}
|
||||
}
|
||||
@@ -92,16 +92,16 @@ public class CraftJukebox extends CraftBlockEntityState<JukeboxBlockEntity> impl
|
||||
public boolean isPlaying() {
|
||||
this.requirePlaced();
|
||||
|
||||
BlockEntity tileEntity = this.getTileEntityFromWorld();
|
||||
return tileEntity instanceof JukeboxBlockEntity jukebox && jukebox.getSongPlayer().isPlaying();
|
||||
BlockEntity blockEntity = this.getBlockEntityFromWorld();
|
||||
return blockEntity instanceof JukeboxBlockEntity jukebox && jukebox.getSongPlayer().isPlaying();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startPlaying() {
|
||||
this.requirePlaced();
|
||||
|
||||
BlockEntity tileEntity = this.getTileEntityFromWorld();
|
||||
if (!(tileEntity instanceof JukeboxBlockEntity jukebox)) {
|
||||
BlockEntity blockEntity = this.getBlockEntityFromWorld();
|
||||
if (!(blockEntity instanceof JukeboxBlockEntity jukebox)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -118,22 +118,22 @@ public class CraftJukebox extends CraftBlockEntityState<JukeboxBlockEntity> impl
|
||||
public void stopPlaying() {
|
||||
this.requirePlaced();
|
||||
|
||||
BlockEntity tileEntity = this.getTileEntityFromWorld();
|
||||
if (!(tileEntity instanceof JukeboxBlockEntity jukebox)) {
|
||||
BlockEntity blockEntity = this.getBlockEntityFromWorld();
|
||||
if (!(blockEntity instanceof JukeboxBlockEntity jukebox)) {
|
||||
return;
|
||||
}
|
||||
|
||||
jukebox.getSongPlayer().stop(tileEntity.getLevel(), tileEntity.getBlockState());
|
||||
jukebox.getSongPlayer().stop(blockEntity.getLevel(), blockEntity.getBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eject() {
|
||||
this.ensureNoWorldGeneration();
|
||||
|
||||
BlockEntity tileEntity = this.getTileEntityFromWorld();
|
||||
if (!(tileEntity instanceof JukeboxBlockEntity)) return false;
|
||||
BlockEntity blockEntity = this.getBlockEntityFromWorld();
|
||||
if (!(blockEntity instanceof JukeboxBlockEntity)) return false;
|
||||
|
||||
JukeboxBlockEntity jukebox = (JukeboxBlockEntity) tileEntity;
|
||||
JukeboxBlockEntity jukebox = (JukeboxBlockEntity) blockEntity;
|
||||
boolean result = !jukebox.getTheItem().isEmpty();
|
||||
jukebox.popOutTheItem();
|
||||
return result;
|
||||
|
||||
@@ -11,8 +11,8 @@ import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftLectern extends CraftBlockEntityState<LecternBlockEntity> implements Lectern {
|
||||
|
||||
public CraftLectern(World world, LecternBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftLectern(World world, LecternBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftLectern(CraftLectern state, Location location) {
|
||||
@@ -40,7 +40,7 @@ public class CraftLectern extends CraftBlockEntityState<LecternBlockEntity> impl
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventoryLectern(this.getTileEntity().bookAccess);
|
||||
return new CraftInventoryLectern(this.getBlockEntity().bookAccess);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,8 +10,8 @@ import org.bukkit.loot.Lootable;
|
||||
|
||||
public abstract class CraftLootable<T extends RandomizableContainerBlockEntity> extends CraftContainer<T> implements Nameable, Lootable, com.destroystokyo.paper.loottable.PaperLootableBlockInventory { // Paper
|
||||
|
||||
public CraftLootable(World world, T tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftLootable(World world, T blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftLootable(CraftLootable<T> state, Location location) {
|
||||
@@ -19,11 +19,11 @@ public abstract class CraftLootable<T extends RandomizableContainerBlockEntity>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(T lootable) {
|
||||
super.applyTo(lootable);
|
||||
public void applyTo(T blockEntity) {
|
||||
super.applyTo(blockEntity);
|
||||
|
||||
if (this.getSnapshot().lootTable == null) {
|
||||
lootable.setLootTable(null, 0L);
|
||||
blockEntity.setLootTable(null, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import org.bukkit.World;
|
||||
|
||||
public class CraftMovingPiston extends CraftBlockEntityState<PistonMovingBlockEntity> implements io.papermc.paper.block.MovingPiston { // Paper - Add Moving Piston API
|
||||
|
||||
public CraftMovingPiston(World world, PistonMovingBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftMovingPiston(World world, PistonMovingBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftMovingPiston(CraftMovingPiston state, Location location) {
|
||||
@@ -27,22 +27,22 @@ public class CraftMovingPiston extends CraftBlockEntityState<PistonMovingBlockEn
|
||||
// Paper start - Add Moving Piston API
|
||||
@Override
|
||||
public org.bukkit.block.data.BlockData getMovingBlock() {
|
||||
return org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(this.getTileEntity().getMovedState());
|
||||
return org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(this.getBlockEntity().getMovedState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.BlockFace getDirection() {
|
||||
return org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(this.getTileEntity().getDirection());
|
||||
return org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(this.getBlockEntity().getDirection());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExtending() {
|
||||
return this.getTileEntity().isExtending();
|
||||
return this.getBlockEntity().isExtending();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPistonHead() {
|
||||
return this.getTileEntity().isSourcePiston();
|
||||
return this.getBlockEntity().isSourcePiston();
|
||||
}
|
||||
// Paper end - Add Moving Piston API
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import org.bukkit.block.SculkCatalyst;
|
||||
|
||||
public class CraftSculkCatalyst extends CraftBlockEntityState<SculkCatalystBlockEntity> implements SculkCatalyst {
|
||||
|
||||
public CraftSculkCatalyst(World world, SculkCatalystBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftSculkCatalyst(World world, SculkCatalystBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftSculkCatalyst(CraftSculkCatalyst state, Location location) {
|
||||
@@ -25,8 +25,8 @@ public class CraftSculkCatalyst extends CraftBlockEntityState<SculkCatalystBlock
|
||||
this.requirePlaced();
|
||||
|
||||
// bloom() is for visual blooming effect, cursors are what changes the blocks.
|
||||
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);
|
||||
this.getBlockEntity().getListener().bloom(this.world.getHandle(), this.getPosition(), this.getHandle(), this.world.getHandle().getRandom());
|
||||
this.getBlockEntity().getListener().getSculkSpreader().addCursors(new BlockPos(block.getX(), block.getY(), block.getZ()), charge);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,13 +45,13 @@ public class CraftSculkCatalyst extends CraftBlockEntityState<SculkCatalystBlock
|
||||
com.google.common.base.Preconditions.checkNotNull(position);
|
||||
requirePlaced();
|
||||
|
||||
getTileEntity().getListener().bloom(
|
||||
getBlockEntity().getListener().bloom(
|
||||
world.getHandle(),
|
||||
getTileEntity().getBlockPos(),
|
||||
getTileEntity().getBlockState(),
|
||||
getBlockEntity().getBlockPos(),
|
||||
getBlockEntity().getBlockState(),
|
||||
world.getHandle().getRandom()
|
||||
);
|
||||
getTileEntity().getListener().getSculkSpreader().addCursors(io.papermc.paper.util.MCUtil.toBlockPos(position), charge);
|
||||
getBlockEntity().getListener().getSculkSpreader().addCursors(io.papermc.paper.util.MCUtil.toBlockPos(position), charge);
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import org.bukkit.block.SculkSensor;
|
||||
|
||||
public class CraftSculkSensor<T extends SculkSensorBlockEntity> extends CraftBlockEntityState<T> implements SculkSensor {
|
||||
|
||||
public CraftSculkSensor(World world, T tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftSculkSensor(World world, T blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftSculkSensor(CraftSculkSensor<T> state, Location location) {
|
||||
|
||||
@@ -10,8 +10,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class CraftSculkShrieker extends CraftBlockEntityState<SculkShriekerBlockEntity> implements SculkShrieker {
|
||||
|
||||
public CraftSculkShrieker(World world, SculkShriekerBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftSculkShrieker(World world, SculkShriekerBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftSculkShrieker(CraftSculkShrieker state, Location location) {
|
||||
@@ -32,8 +32,8 @@ public class CraftSculkShrieker extends CraftBlockEntityState<SculkShriekerBlock
|
||||
public void tryShriek(Player player) {
|
||||
this.requirePlaced();
|
||||
|
||||
ServerPlayer entityPlayer = (player == null) ? null : ((CraftPlayer) player).getHandle();
|
||||
this.getTileEntity().tryShriek(this.world.getHandle(), entityPlayer);
|
||||
ServerPlayer serverPlayer = player == null ? null : ((CraftPlayer) player).getHandle();
|
||||
this.getBlockEntity().tryShriek(this.world.getHandle(), serverPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,8 +13,8 @@ import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftShulkerBox extends CraftLootable<ShulkerBoxBlockEntity> implements ShulkerBox {
|
||||
|
||||
public CraftShulkerBox(World world, ShulkerBoxBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftShulkerBox(World world, ShulkerBoxBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftShulkerBox(CraftShulkerBox state, Location location) {
|
||||
@@ -32,7 +32,7 @@ public class CraftShulkerBox extends CraftLootable<ShulkerBoxBlockEntity> implem
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventory(this.getTileEntity());
|
||||
return new CraftInventory(this.getBlockEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,23 +45,23 @@ public class CraftShulkerBox extends CraftLootable<ShulkerBoxBlockEntity> implem
|
||||
@Override
|
||||
public void open() {
|
||||
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);
|
||||
if (!this.getBlockEntity().opened && this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
|
||||
net.minecraft.world.level.Level world = this.getBlockEntity().getLevel();
|
||||
world.blockEvent(this.getPosition(), this.getBlockEntity().getBlockState().getBlock(), 1, 1);
|
||||
world.playSound(null, this.getPosition(), SoundEvents.SHULKER_BOX_OPEN, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
|
||||
}
|
||||
this.getTileEntity().opened = true;
|
||||
this.getBlockEntity().opened = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
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);
|
||||
if (this.getBlockEntity().opened && this.getWorldHandle() instanceof net.minecraft.world.level.Level) {
|
||||
net.minecraft.world.level.Level world = this.getBlockEntity().getLevel();
|
||||
world.blockEvent(this.getPosition(), this.getBlockEntity().getBlockState().getBlock(), 1, 0);
|
||||
world.playSound(null, this.getPosition(), SoundEvents.SHULKER_BOX_CLOSE, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); // Paper - More Lidded Block API (Wrong sound)
|
||||
}
|
||||
this.getTileEntity().opened = false;
|
||||
this.getBlockEntity().opened = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,7 +77,7 @@ public class CraftShulkerBox extends CraftLootable<ShulkerBoxBlockEntity> implem
|
||||
// Paper start - More Lidded Block API
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return getTileEntity().opened;
|
||||
return getBlockEntity().opened;
|
||||
}
|
||||
// Paper end - More Lidded Block API
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ public class CraftSign<T extends SignBlockEntity> extends CraftBlockEntityState<
|
||||
private final CraftSignSide front;
|
||||
private final CraftSignSide back;
|
||||
|
||||
public CraftSign(World world, T tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftSign(World world, T blockEntity) {
|
||||
super(world, blockEntity);
|
||||
this.front = new CraftSignSide(this.getSnapshot().getFrontText());
|
||||
this.back = new CraftSignSide(this.getSnapshot().getBackText());
|
||||
}
|
||||
@@ -129,8 +129,8 @@ public class CraftSign<T extends SignBlockEntity> extends CraftBlockEntityState<
|
||||
public Player getAllowedEditor() {
|
||||
this.ensureNoWorldGeneration();
|
||||
|
||||
// getPlayerWhoMayEdit is always null for the snapshot, so we use the wrapped TileEntity
|
||||
UUID id = this.getTileEntity().getPlayerWhoMayEdit();
|
||||
// getPlayerWhoMayEdit is always null for the snapshot, so we use the wrapped BlockEntity
|
||||
UUID id = this.getBlockEntity().getPlayerWhoMayEdit();
|
||||
return (id == null) ? null : Bukkit.getPlayer(id);
|
||||
}
|
||||
|
||||
@@ -145,11 +145,11 @@ public class CraftSign<T extends SignBlockEntity> extends CraftBlockEntityState<
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(T sign) {
|
||||
public void applyTo(T blockEntity) {
|
||||
this.getSnapshot().setText(this.front.applyLegacyStringToSignSide(), true);
|
||||
this.getSnapshot().setText(this.back.applyLegacyStringToSignSide(), false);
|
||||
|
||||
super.applyTo(sign);
|
||||
super.applyTo(blockEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -178,10 +178,10 @@ public class CraftSign<T extends SignBlockEntity> extends CraftBlockEntityState<
|
||||
}
|
||||
} // Paper - Add PlayerOpenSignEvent
|
||||
|
||||
SignBlockEntity handle = ((CraftSign<?>) sign).getTileEntity();
|
||||
handle.setAllowedPlayerEditor(player.getUniqueId());
|
||||
SignBlockEntity blockEntity = ((CraftSign<?>) sign).getBlockEntity();
|
||||
blockEntity.setAllowedPlayerEditor(player.getUniqueId());
|
||||
|
||||
((CraftPlayer) player).getHandle().openTextEdit(handle, Side.FRONT == side);
|
||||
((CraftPlayer) player).getHandle().openTextEdit(blockEntity, Side.FRONT == side);
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@@ -202,13 +202,13 @@ public class CraftSign<T extends SignBlockEntity> extends CraftBlockEntityState<
|
||||
@Override
|
||||
public java.util.UUID getAllowedEditorUniqueId() {
|
||||
this.ensureNoWorldGeneration();
|
||||
return this.getTileEntity().getPlayerWhoMayEdit();
|
||||
return this.getBlockEntity().getPlayerWhoMayEdit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAllowedEditorUniqueId(java.util.UUID uuid) {
|
||||
this.ensureNoWorldGeneration();
|
||||
this.getTileEntity().setAllowedPlayerEditor(uuid);
|
||||
this.getBlockEntity().setAllowedPlayerEditor(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,8 +31,8 @@ public class CraftSkull extends CraftBlockEntityState<SkullBlockEntity> implemen
|
||||
private static final int MAX_OWNER_LENGTH = 16;
|
||||
private ResolvableProfile profile;
|
||||
|
||||
public CraftSkull(World world, SkullBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftSkull(World world, SkullBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftSkull(CraftSkull state, Location location) {
|
||||
@@ -40,10 +40,10 @@ public class CraftSkull extends CraftBlockEntityState<SkullBlockEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(SkullBlockEntity skull) {
|
||||
super.load(skull);
|
||||
public void load(SkullBlockEntity blockEntity) {
|
||||
super.load(blockEntity);
|
||||
|
||||
ResolvableProfile owner = skull.getOwnerProfile();
|
||||
ResolvableProfile owner = blockEntity.getOwnerProfile();
|
||||
if (owner != null) {
|
||||
this.profile = owner;
|
||||
}
|
||||
@@ -201,11 +201,11 @@ public class CraftSkull extends CraftBlockEntityState<SkullBlockEntity> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(SkullBlockEntity skull) {
|
||||
super.applyTo(skull);
|
||||
public void applyTo(SkullBlockEntity blockEntity) {
|
||||
super.applyTo(blockEntity);
|
||||
|
||||
if (this.getSkullType() == SkullType.PLAYER) {
|
||||
skull.setOwner(this.hasOwner() ? this.profile : null);
|
||||
blockEntity.setOwner(this.hasOwner() ? this.profile : null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ import org.bukkit.block.Smoker;
|
||||
|
||||
public class CraftSmoker extends CraftFurnace<SmokerBlockEntity> implements Smoker {
|
||||
|
||||
public CraftSmoker(World world, SmokerBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftSmoker(World world, SmokerBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftSmoker(CraftSmoker state, Location location) {
|
||||
|
||||
@@ -19,8 +19,8 @@ public class CraftStructureBlock extends CraftBlockEntityState<StructureBlockEnt
|
||||
|
||||
private static final int MAX_SIZE = 48;
|
||||
|
||||
public CraftStructureBlock(World world, StructureBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftStructureBlock(World world, StructureBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftStructureBlock(CraftStructureBlock state, Location location) {
|
||||
@@ -180,19 +180,19 @@ public class CraftStructureBlock extends CraftBlockEntityState<StructureBlockEnt
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTo(StructureBlockEntity tileEntity) {
|
||||
super.applyTo(tileEntity);
|
||||
protected void applyTo(StructureBlockEntity blockEntity) {
|
||||
super.applyTo(blockEntity);
|
||||
net.minecraft.world.level.LevelAccessor access = this.getWorldHandle();
|
||||
|
||||
// Ensure block type is correct
|
||||
if (access instanceof net.minecraft.world.level.Level) {
|
||||
tileEntity.setMode(tileEntity.getMode());
|
||||
blockEntity.setMode(blockEntity.getMode());
|
||||
} else if (access != null) {
|
||||
// Custom handle during world generation
|
||||
// From TileEntityStructure#setUsageMode(BlockPropertyStructureMode)
|
||||
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.StructureBlock.MODE, tileEntity.getMode()), 2);
|
||||
// From StructureBlockEntity#setMode(BlockPropertyStructureMode)
|
||||
net.minecraft.world.level.block.state.BlockState state = access.getBlockState(this.getPosition());
|
||||
if (state.is(net.minecraft.world.level.block.Blocks.STRUCTURE_BLOCK)) {
|
||||
access.setBlock(this.getPosition(), state.setValue(net.minecraft.world.level.block.StructureBlock.MODE, blockEntity.getMode()), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.world.level.block.entity.BrushableBlockEntity;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.SuspiciousSand;
|
||||
|
||||
public class CraftSuspiciousSand extends CraftBrushableBlock implements SuspiciousSand {
|
||||
|
||||
public CraftSuspiciousSand(World world, BrushableBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
}
|
||||
|
||||
protected CraftSuspiciousSand(CraftSuspiciousSand state, Location location) {
|
||||
super(state, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftSuspiciousSand copy() {
|
||||
return new CraftSuspiciousSand(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftSuspiciousSand copy(Location location) {
|
||||
return new CraftSuspiciousSand(this, location);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.world.level.block.entity.TestBlockEntity;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.TestBlock;
|
||||
|
||||
public class CraftTestBlock extends CraftBlockEntityState<TestBlockEntity> implements TestBlock {
|
||||
|
||||
public CraftTestBlock(World world, TestBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftTestBlock(CraftTestBlock state, Location location) {
|
||||
super(state, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftTestBlock copy() {
|
||||
return new CraftTestBlock(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftTestBlock copy(Location location) {
|
||||
return new CraftTestBlock(this, location);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.world.level.block.entity.TestInstanceBlockEntity;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.TestInstanceBlock;
|
||||
|
||||
public class CraftTestInstanceBlock extends CraftBlockEntityState<TestInstanceBlockEntity> implements TestInstanceBlock {
|
||||
|
||||
public CraftTestInstanceBlock(World world, TestInstanceBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftTestInstanceBlock(CraftTestInstanceBlock state, Location location) {
|
||||
super(state, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftTestInstanceBlock copy() {
|
||||
return new CraftTestInstanceBlock(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftTestInstanceBlock copy(Location location) {
|
||||
return new CraftTestInstanceBlock(this, location);
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,10 @@ public class CraftTrialSpawner extends CraftBlockEntityState<TrialSpawnerBlockEn
|
||||
private final CraftTrialSpawnerConfiguration normalConfig;
|
||||
private final CraftTrialSpawnerConfiguration ominousConfig;
|
||||
|
||||
public CraftTrialSpawner(World world, TrialSpawnerBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
this.normalConfig = new CraftTrialSpawnerConfiguration(tileEntity.getTrialSpawner().getNormalConfig(), this.getSnapshot());
|
||||
this.ominousConfig = new CraftTrialSpawnerConfiguration(tileEntity.getTrialSpawner().getOminousConfig(), this.getSnapshot());
|
||||
public CraftTrialSpawner(World world, TrialSpawnerBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
this.normalConfig = new CraftTrialSpawnerConfiguration(blockEntity.getTrialSpawner().getNormalConfig(), this.getSnapshot());
|
||||
this.ominousConfig = new CraftTrialSpawnerConfiguration(blockEntity.getTrialSpawner().getOminousConfig(), this.getSnapshot());
|
||||
}
|
||||
|
||||
protected CraftTrialSpawner(CraftTrialSpawner state, Location location) {
|
||||
@@ -169,11 +169,11 @@ public class CraftTrialSpawner extends CraftBlockEntityState<TrialSpawnerBlockEn
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTo(TrialSpawnerBlockEntity tileEntity) {
|
||||
super.applyTo(tileEntity);
|
||||
protected void applyTo(TrialSpawnerBlockEntity blockEntity) {
|
||||
super.applyTo(blockEntity);
|
||||
|
||||
tileEntity.trialSpawner.normalConfig = Holder.direct(this.normalConfig.toMinecraft());
|
||||
tileEntity.trialSpawner.ominousConfig = Holder.direct(this.ominousConfig.toMinecraft());
|
||||
blockEntity.trialSpawner.normalConfig = Holder.direct(this.normalConfig.toMinecraft());
|
||||
blockEntity.trialSpawner.ominousConfig = Holder.direct(this.ominousConfig.toMinecraft());
|
||||
}
|
||||
|
||||
private TrialSpawnerData getTrialData() {
|
||||
|
||||
@@ -10,8 +10,9 @@ import java.util.Optional;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.util.random.SimpleWeightedRandomList;
|
||||
import net.minecraft.util.random.WeightedEntry.Wrapper;
|
||||
import net.minecraft.util.random.Weighted;
|
||||
import net.minecraft.util.random.WeightedList;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.SpawnData;
|
||||
import net.minecraft.world.level.block.entity.TrialSpawnerBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerConfig;
|
||||
@@ -35,8 +36,8 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
|
||||
private float totalMobsAddedPerPlayer;
|
||||
private float simultaneousMobsAddedPerPlayer;
|
||||
private int ticksBetweenSpawn;
|
||||
private SimpleWeightedRandomList<SpawnData> spawnPotentialsDefinition;
|
||||
private SimpleWeightedRandomList<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> lootTablesToEject;
|
||||
private WeightedList<SpawnData> spawnPotentialsDefinition;
|
||||
private WeightedList<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> lootTablesToEject;
|
||||
private ResourceKey<net.minecraft.world.level.storage.loot.LootTable> itemsToDropWhenOminous;
|
||||
|
||||
public CraftTrialSpawnerConfiguration(TrialSpawnerConfig minecraft, TrialSpawnerBlockEntity snapshot) {
|
||||
@@ -59,7 +60,7 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
|
||||
return null;
|
||||
}
|
||||
|
||||
Optional<net.minecraft.world.entity.EntityType<?>> type = net.minecraft.world.entity.EntityType.by(this.spawnPotentialsDefinition.unwrap().get(0).data().getEntityToSpawn());
|
||||
Optional<net.minecraft.world.entity.EntityType<?>> type = net.minecraft.world.entity.EntityType.by(this.spawnPotentialsDefinition.unwrap().get(0).value().getEntityToSpawn());
|
||||
return type.map(CraftEntityType::minecraftToBukkit).orElse(null);
|
||||
}
|
||||
|
||||
@@ -67,15 +68,15 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
|
||||
public void setSpawnedType(EntityType entityType) {
|
||||
if (entityType == null) {
|
||||
this.getTrialData().nextSpawnData = Optional.empty();
|
||||
this.spawnPotentialsDefinition = SimpleWeightedRandomList.empty(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later
|
||||
this.spawnPotentialsDefinition = WeightedList.of(); // 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);
|
||||
|
||||
SpawnData data = new SpawnData();
|
||||
data.getEntityToSpawn().putString("id", BuiltInRegistries.ENTITY_TYPE.getKey(CraftEntityType.bukkitToMinecraft(entityType)).toString());
|
||||
data.getEntityToSpawn().putString(Entity.ID_TAG, BuiltInRegistries.ENTITY_TYPE.getKey(CraftEntityType.bukkitToMinecraft(entityType)).toString());
|
||||
this.getTrialData().nextSpawnData = Optional.of(data);
|
||||
this.spawnPotentialsDefinition = SimpleWeightedRandomList.single(data);
|
||||
this.spawnPotentialsDefinition = WeightedList.of(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,12 +143,12 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
|
||||
|
||||
@Override
|
||||
public EntitySnapshot getSpawnedEntity() {
|
||||
SimpleWeightedRandomList<SpawnData> potentials = this.spawnPotentialsDefinition;
|
||||
WeightedList<SpawnData> potentials = this.spawnPotentialsDefinition;
|
||||
if (potentials.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return CraftEntitySnapshot.create(potentials.unwrap().get(0).data().getEntityToSpawn());
|
||||
return CraftEntitySnapshot.create(potentials.unwrap().get(0).value().getEntityToSpawn());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -165,7 +166,7 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
|
||||
private void setSpawnedEntity(EntitySnapshot snapshot, SpawnRule spawnRule, SpawnerEntry.Equipment equipment) {
|
||||
if (snapshot == null) {
|
||||
this.getTrialData().nextSpawnData = Optional.empty();
|
||||
this.spawnPotentialsDefinition = SimpleWeightedRandomList.empty(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later
|
||||
this.spawnPotentialsDefinition = WeightedList.of(); // need clear the spawnPotentials to avoid nextSpawnData being replaced later
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -173,7 +174,7 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
|
||||
SpawnData data = new SpawnData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnRule)), CraftCreatureSpawner.getEquipment(equipment));
|
||||
|
||||
this.getTrialData().nextSpawnData = Optional.of(data);
|
||||
this.spawnPotentialsDefinition = SimpleWeightedRandomList.single(data);
|
||||
this.spawnPotentialsDefinition = WeightedList.of(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -186,8 +187,8 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
|
||||
|
||||
CompoundTag compoundTag = ((CraftEntitySnapshot) snapshot).getData();
|
||||
|
||||
SimpleWeightedRandomList.Builder<SpawnData> builder = SimpleWeightedRandomList.builder(); // PAIL rename Builder
|
||||
this.spawnPotentialsDefinition.unwrap().forEach(entry -> builder.add(entry.data(), entry.getWeight().asInt()));
|
||||
WeightedList.Builder<SpawnData> builder = WeightedList.builder();
|
||||
this.spawnPotentialsDefinition.unwrap().forEach(entry -> builder.add(entry.value(), entry.weight()));
|
||||
builder.add(new SpawnData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnRule)), CraftCreatureSpawner.getEquipment(equipment)), weight);
|
||||
this.spawnPotentialsDefinition = builder.build();
|
||||
}
|
||||
@@ -203,7 +204,7 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
|
||||
public void setPotentialSpawns(Collection<SpawnerEntry> entries) {
|
||||
Preconditions.checkArgument(entries != null, "Entries cannot be null");
|
||||
|
||||
SimpleWeightedRandomList.Builder<SpawnData> builder = SimpleWeightedRandomList.builder();
|
||||
WeightedList.Builder<SpawnData> builder = WeightedList.builder();
|
||||
for (SpawnerEntry spawnerEntry : entries) {
|
||||
CompoundTag compoundTag = ((CraftEntitySnapshot) spawnerEntry.getSnapshot()).getData();
|
||||
builder.add(new SpawnData(compoundTag, Optional.ofNullable(CraftCreatureSpawner.toMinecraftRule(spawnerEntry.getSpawnRule())), CraftCreatureSpawner.getEquipment(spawnerEntry.getEquipment())), spawnerEntry.getSpawnWeight());
|
||||
@@ -215,12 +216,12 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
|
||||
public List<SpawnerEntry> getPotentialSpawns() {
|
||||
List<SpawnerEntry> entries = new ArrayList<>();
|
||||
|
||||
for (Wrapper<SpawnData> entry : this.spawnPotentialsDefinition.unwrap()) { // PAIL rename Wrapper
|
||||
CraftEntitySnapshot snapshot = CraftEntitySnapshot.create(entry.data().getEntityToSpawn());
|
||||
for (Weighted<SpawnData> entry : this.spawnPotentialsDefinition.unwrap()) {
|
||||
CraftEntitySnapshot snapshot = CraftEntitySnapshot.create(entry.value().getEntityToSpawn());
|
||||
|
||||
if (snapshot != null) {
|
||||
SpawnRule rule = entry.data().customSpawnRules().map(CraftCreatureSpawner::fromMinecraftRule).orElse(null);
|
||||
entries.add(new SpawnerEntry(snapshot, entry.getWeight().asInt(), rule));
|
||||
SpawnRule rule = entry.value().customSpawnRules().map(CraftCreatureSpawner::fromMinecraftRule).orElse(null);
|
||||
entries.add(new SpawnerEntry(snapshot, entry.weight(), rule));
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
@@ -230,10 +231,10 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
|
||||
public Map<LootTable, Integer> getPossibleRewards() {
|
||||
Map<LootTable, Integer> tables = new HashMap<>();
|
||||
|
||||
for (Wrapper<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> entry : this.lootTablesToEject.unwrap()) {
|
||||
LootTable table = CraftLootTable.minecraftToBukkit(entry.data());
|
||||
for (Weighted<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> entry : this.lootTablesToEject.unwrap()) {
|
||||
LootTable table = CraftLootTable.minecraftToBukkit(entry.value());
|
||||
if (table != null) {
|
||||
tables.put(table, entry.getWeight().asInt());
|
||||
tables.put(table, entry.weight());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,8 +246,8 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
|
||||
Preconditions.checkArgument(table != null, "Table cannot be null");
|
||||
Preconditions.checkArgument(weight >= 1, "Weight must be at least 1");
|
||||
|
||||
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()));
|
||||
WeightedList.Builder<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> builder = WeightedList.builder();
|
||||
this.lootTablesToEject.unwrap().forEach(entry -> builder.add(entry.value(), entry.weight()));
|
||||
builder.add(CraftLootTable.bukkitToMinecraft(table), weight);
|
||||
this.lootTablesToEject = builder.build();
|
||||
}
|
||||
@@ -256,11 +257,11 @@ 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.Builder<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> builder = SimpleWeightedRandomList.builder();
|
||||
WeightedList.Builder<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> builder = WeightedList.builder();
|
||||
|
||||
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());
|
||||
for (Weighted<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> entry : this.lootTablesToEject.unwrap()) {
|
||||
if (!entry.value().equals(minecraftKey)) {
|
||||
builder.add(entry.value(), entry.weight());
|
||||
}
|
||||
}
|
||||
this.lootTablesToEject = builder.build();
|
||||
@@ -269,11 +270,11 @@ public class CraftTrialSpawnerConfiguration implements TrialSpawnerConfiguration
|
||||
@Override
|
||||
public void setPossibleRewards(Map<LootTable, Integer> rewards) {
|
||||
if (rewards == null || rewards.isEmpty()) {
|
||||
this.lootTablesToEject = SimpleWeightedRandomList.empty();
|
||||
this.lootTablesToEject = WeightedList.of();
|
||||
return;
|
||||
}
|
||||
|
||||
SimpleWeightedRandomList.Builder<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> builder = SimpleWeightedRandomList.builder();
|
||||
WeightedList.Builder<ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> builder = WeightedList.builder();
|
||||
rewards.forEach((table, weight) -> {
|
||||
Preconditions.checkArgument(table != null, "Table cannot be null");
|
||||
Preconditions.checkArgument(weight >= 1, "Weight must be at least 1");
|
||||
|
||||
@@ -23,8 +23,8 @@ import java.util.UUID;
|
||||
@NullMarked
|
||||
public class CraftVault extends CraftBlockEntityState<VaultBlockEntity> implements Vault {
|
||||
|
||||
public CraftVault(World world, VaultBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
public CraftVault(World world, VaultBlockEntity blockEntity) {
|
||||
super(world, blockEntity);
|
||||
}
|
||||
|
||||
protected CraftVault(CraftVault state, @Nullable Location location) {
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Ageable;
|
||||
|
||||
public abstract class CraftAgeable extends CraftBlockData implements Ageable {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.IntegerProperty AGE = getInteger("age");
|
||||
|
||||
@Override
|
||||
public int getAge() {
|
||||
return this.get(CraftAgeable.AGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAge(int age) {
|
||||
this.set(CraftAgeable.AGE, age);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumAge() {
|
||||
return getMax(CraftAgeable.AGE);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.AnaloguePowerable;
|
||||
|
||||
public abstract class CraftAnaloguePowerable extends CraftBlockData implements AnaloguePowerable {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.IntegerProperty POWER = getInteger("power");
|
||||
|
||||
@Override
|
||||
public int getPower() {
|
||||
return this.get(CraftAnaloguePowerable.POWER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(int power) {
|
||||
this.set(CraftAnaloguePowerable.POWER, power);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumPower() {
|
||||
return getMax(CraftAnaloguePowerable.POWER);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Attachable;
|
||||
|
||||
public abstract class CraftAttachable extends CraftBlockData implements Attachable {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BooleanProperty ATTACHED = getBoolean("attached");
|
||||
|
||||
@Override
|
||||
public boolean isAttached() {
|
||||
return this.get(CraftAttachable.ATTACHED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttached(boolean attached) {
|
||||
this.set(CraftAttachable.ATTACHED, attached);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Bisected;
|
||||
|
||||
public class CraftBisected extends CraftBlockData implements Bisected {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> HALF = getEnum("half");
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.data.Bisected.Half getHalf() {
|
||||
return this.get(CraftBisected.HALF, org.bukkit.block.data.Bisected.Half.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHalf(org.bukkit.block.data.Bisected.Half half) {
|
||||
this.set(CraftBisected.HALF, half);
|
||||
}
|
||||
}
|
||||
@@ -340,15 +340,12 @@ public class CraftBlockData implements BlockData {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the minimum value allowed by the BlockStateInteger.
|
||||
*
|
||||
* @param state the state to check
|
||||
* @return the minimum value allowed
|
||||
*/
|
||||
protected static int getMin(IntegerProperty state) {
|
||||
return state.min;
|
||||
}
|
||||
public static final BlockFace[] ROTATION_CYCLE = {
|
||||
BlockFace.SOUTH, BlockFace.SOUTH_SOUTH_WEST, BlockFace.SOUTH_WEST, BlockFace.WEST_SOUTH_WEST,
|
||||
BlockFace.WEST, BlockFace.WEST_NORTH_WEST, BlockFace.NORTH_WEST, BlockFace.NORTH_NORTH_WEST,
|
||||
BlockFace.NORTH, BlockFace.NORTH_NORTH_EAST, BlockFace.NORTH_EAST, BlockFace.EAST_NORTH_EAST,
|
||||
BlockFace.EAST, BlockFace.EAST_SOUTH_EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH_SOUTH_EAST
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the maximum value allowed by the BlockStateInteger.
|
||||
@@ -360,177 +357,176 @@ public class CraftBlockData implements BlockData {
|
||||
return state.max;
|
||||
}
|
||||
|
||||
//
|
||||
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">
|
||||
// Start generate - CraftBlockData#MAP
|
||||
// @GeneratedFrom 1.21.5
|
||||
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.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.AttachedStemBlock.class, org.bukkit.craftbukkit.block.impl.CraftAttachedStem::new);
|
||||
register(net.minecraft.world.level.block.BambooStalkBlock.class, org.bukkit.craftbukkit.block.impl.CraftBambooStalk::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.BaseCoralFanBlock.class, org.bukkit.craftbukkit.block.impl.CraftBaseCoralFan::new);
|
||||
register(net.minecraft.world.level.block.BaseCoralPlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftBaseCoralPlant::new);
|
||||
register(net.minecraft.world.level.block.BaseCoralWallFanBlock.class, org.bukkit.craftbukkit.block.impl.CraftBaseCoralWallFan::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.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.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.BrushableBlock.class, org.bukkit.craftbukkit.block.impl.CraftBrushable::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.ButtonBlock.class, org.bukkit.craftbukkit.block.impl.CraftButton::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.CampfireBlock.class, org.bukkit.craftbukkit.block.impl.CraftCampfire::new);
|
||||
register(net.minecraft.world.level.block.CandleBlock.class, org.bukkit.craftbukkit.block.impl.CraftCandle::new);
|
||||
register(net.minecraft.world.level.block.CandleCakeBlock.class, org.bukkit.craftbukkit.block.impl.CraftCandleCake::new);
|
||||
register(net.minecraft.world.level.block.CarrotBlock.class, org.bukkit.craftbukkit.block.impl.CraftCarrot::new);
|
||||
register(net.minecraft.world.level.block.CarvedPumpkinBlock.class, org.bukkit.craftbukkit.block.impl.CraftCarvedPumpkin::new);
|
||||
register(net.minecraft.world.level.block.CaveVinesBlock.class, org.bukkit.craftbukkit.block.impl.CraftCaveVines::new);
|
||||
register(net.minecraft.world.level.block.CaveVinesPlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftCaveVinesPlant::new);
|
||||
register(net.minecraft.world.level.block.CeilingHangingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftCeilingHangingSign::new);
|
||||
register(net.minecraft.world.level.block.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.ChiseledBookShelfBlock.class, org.bukkit.craftbukkit.block.impl.CraftChiseledBookShelf::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.CraftChorusPlant::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.CraftCommandBlock::new);
|
||||
register(net.minecraft.world.level.block.ComparatorBlock.class, org.bukkit.craftbukkit.block.impl.CraftComparator::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.CopperBulbBlock.class, org.bukkit.craftbukkit.block.impl.CraftCopperBulb::new);
|
||||
register(net.minecraft.world.level.block.CoralFanBlock.class, org.bukkit.craftbukkit.block.impl.CraftCoralFan::new);
|
||||
register(net.minecraft.world.level.block.CoralPlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftCoralPlant::new);
|
||||
register(net.minecraft.world.level.block.CoralWallFanBlock.class, org.bukkit.craftbukkit.block.impl.CraftCoralWallFan::new);
|
||||
register(net.minecraft.world.level.block.CrafterBlock.class, org.bukkit.craftbukkit.block.impl.CraftCrafter::new);
|
||||
register(net.minecraft.world.level.block.CreakingHeartBlock.class, org.bukkit.craftbukkit.block.impl.CraftCreakingHeart::new);
|
||||
register(net.minecraft.world.level.block.CropBlock.class, org.bukkit.craftbukkit.block.impl.CraftCrop::new);
|
||||
register(net.minecraft.world.level.block.DaylightDetectorBlock.class, org.bukkit.craftbukkit.block.impl.CraftDaylightDetector::new);
|
||||
register(net.minecraft.world.level.block.DecoratedPotBlock.class, org.bukkit.craftbukkit.block.impl.CraftDecoratedPot::new);
|
||||
register(net.minecraft.world.level.block.DetectorRailBlock.class, org.bukkit.craftbukkit.block.impl.CraftDetectorRail::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.DoublePlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftDoublePlant::new);
|
||||
register(net.minecraft.world.level.block.DropperBlock.class, org.bukkit.craftbukkit.block.impl.CraftDropper::new);
|
||||
register(net.minecraft.world.level.block.EndPortalFrameBlock.class, org.bukkit.craftbukkit.block.impl.CraftEndPortalFrame::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.FarmBlock.class, org.bukkit.craftbukkit.block.impl.CraftFarm::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.FlowerBedBlock.class, org.bukkit.craftbukkit.block.impl.CraftFlowerBed::new);
|
||||
register(net.minecraft.world.level.block.FrostedIceBlock.class, org.bukkit.craftbukkit.block.impl.CraftFrostedIce::new);
|
||||
register(net.minecraft.world.level.block.FurnaceBlock.class, org.bukkit.craftbukkit.block.impl.CraftFurnace::new);
|
||||
register(net.minecraft.world.level.block.GlazedTerracottaBlock.class, org.bukkit.craftbukkit.block.impl.CraftGlazedTerracotta::new);
|
||||
register(net.minecraft.world.level.block.GlowLichenBlock.class, org.bukkit.craftbukkit.block.impl.CraftGlowLichen::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.HangingMossBlock.class, org.bukkit.craftbukkit.block.impl.CraftHangingMoss::new);
|
||||
register(net.minecraft.world.level.block.HangingRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftHangingRoots::new);
|
||||
register(net.minecraft.world.level.block.HayBlock.class, org.bukkit.craftbukkit.block.impl.CraftHay::new);
|
||||
register(net.minecraft.world.level.block.HeavyCoreBlock.class, org.bukkit.craftbukkit.block.impl.CraftHeavyCore::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.InfestedRotatedPillarBlock.class, org.bukkit.craftbukkit.block.impl.CraftInfestedRotatedPillar::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.LayeredCauldronBlock.class, org.bukkit.craftbukkit.block.impl.CraftLayeredCauldron::new);
|
||||
register(net.minecraft.world.level.block.LeafLitterBlock.class, org.bukkit.craftbukkit.block.impl.CraftLeafLitter::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.LightBlock.class, org.bukkit.craftbukkit.block.impl.CraftLight::new);
|
||||
register(net.minecraft.world.level.block.LightningRodBlock.class, org.bukkit.craftbukkit.block.impl.CraftLightningRod::new);
|
||||
register(net.minecraft.world.level.block.LiquidBlock.class, org.bukkit.craftbukkit.block.impl.CraftLiquid::new);
|
||||
register(net.minecraft.world.level.block.LoomBlock.class, org.bukkit.craftbukkit.block.impl.CraftLoom::new);
|
||||
register(net.minecraft.world.level.block.MangroveLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangroveLeaves::new);
|
||||
register(net.minecraft.world.level.block.MangrovePropaguleBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangrovePropagule::new);
|
||||
register(net.minecraft.world.level.block.MangroveRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangroveRoots::new);
|
||||
register(net.minecraft.world.level.block.MossyCarpetBlock.class, org.bukkit.craftbukkit.block.impl.CraftMossyCarpet::new);
|
||||
register(net.minecraft.world.level.block.MultifaceBlock.class, org.bukkit.craftbukkit.block.impl.CraftMultiface::new);
|
||||
register(net.minecraft.world.level.block.ParticleLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftParticleLeaves::new);
|
||||
register(net.minecraft.world.level.block.MyceliumBlock.class, org.bukkit.craftbukkit.block.impl.CraftMycelium::new);
|
||||
register(net.minecraft.world.level.block.NetherPortalBlock.class, org.bukkit.craftbukkit.block.impl.CraftNetherPortal::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.CraftNoteBlock::new);
|
||||
register(net.minecraft.world.level.block.ObserverBlock.class, org.bukkit.craftbukkit.block.impl.CraftObserver::new);
|
||||
register(net.minecraft.world.level.block.PiglinWallSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftPiglinWallSkull::new);
|
||||
register(net.minecraft.world.level.block.PinkPetalsBlock.class, org.bukkit.craftbukkit.block.impl.CraftPinkPetals::new);
|
||||
register(net.minecraft.world.level.block.PitcherCropBlock.class, org.bukkit.craftbukkit.block.impl.CraftPitcherCrop::new);
|
||||
register(net.minecraft.world.level.block.PlayerHeadBlock.class, org.bukkit.craftbukkit.block.impl.CraftPlayerHead::new);
|
||||
register(net.minecraft.world.level.block.PlayerWallHeadBlock.class, org.bukkit.craftbukkit.block.impl.CraftPlayerWallHead::new);
|
||||
register(net.minecraft.world.level.block.PointedDripstoneBlock.class, org.bukkit.craftbukkit.block.impl.CraftPointedDripstone::new);
|
||||
register(net.minecraft.world.level.block.PotatoBlock.class, org.bukkit.craftbukkit.block.impl.CraftPotato::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.CraftPressurePlate::new);
|
||||
register(net.minecraft.world.level.block.RailBlock.class, org.bukkit.craftbukkit.block.impl.CraftRail::new);
|
||||
register(net.minecraft.world.level.block.RedStoneOreBlock.class, org.bukkit.craftbukkit.block.impl.CraftRedStoneOre::new);
|
||||
register(net.minecraft.world.level.block.RedStoneWireBlock.class, org.bukkit.craftbukkit.block.impl.CraftRedStoneWire::new);
|
||||
register(net.minecraft.world.level.block.RedstoneLampBlock.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneLamp::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.CraftRedstoneWallTorch::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.CraftRotatedPillar::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.SculkCatalystBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkCatalyst::new);
|
||||
register(net.minecraft.world.level.block.SculkSensorBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkSensor::new);
|
||||
register(net.minecraft.world.level.block.SculkShriekerBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkShrieker::new);
|
||||
register(net.minecraft.world.level.block.SculkVeinBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkVein::new);
|
||||
register(net.minecraft.world.level.block.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.SlabBlock.class, org.bukkit.craftbukkit.block.impl.CraftSlab::new);
|
||||
register(net.minecraft.world.level.block.SmallDripleafBlock.class, org.bukkit.craftbukkit.block.impl.CraftSmallDripleaf::new);
|
||||
register(net.minecraft.world.level.block.SmokerBlock.class, org.bukkit.craftbukkit.block.impl.CraftSmoker::new);
|
||||
register(net.minecraft.world.level.block.SnifferEggBlock.class, org.bukkit.craftbukkit.block.impl.CraftSnifferEgg::new);
|
||||
register(net.minecraft.world.level.block.SnowLayerBlock.class, org.bukkit.craftbukkit.block.impl.CraftSnowLayer::new);
|
||||
register(net.minecraft.world.level.block.SnowyDirtBlock.class, org.bukkit.craftbukkit.block.impl.CraftSnowyDirt::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.CraftStair::new);
|
||||
register(net.minecraft.world.level.block.StandingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftStandingSign::new);
|
||||
register(net.minecraft.world.level.block.StemBlock.class, org.bukkit.craftbukkit.block.impl.CraftStem::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.CraftStructureBlock::new);
|
||||
register(net.minecraft.world.level.block.SugarCaneBlock.class, org.bukkit.craftbukkit.block.impl.CraftSugarCane::new);
|
||||
register(net.minecraft.world.level.block.SweetBerryBushBlock.class, org.bukkit.craftbukkit.block.impl.CraftSweetBerryBush::new);
|
||||
register(net.minecraft.world.level.block.TallFlowerBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallFlower::new);
|
||||
register(net.minecraft.world.level.block.TallSeagrassBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallSeagrass::new);
|
||||
register(net.minecraft.world.level.block.TargetBlock.class, org.bukkit.craftbukkit.block.impl.CraftTarget::new);
|
||||
register(net.minecraft.world.level.block.TestBlock.class, org.bukkit.craftbukkit.block.impl.CraftTestBlock::new);
|
||||
register(net.minecraft.world.level.block.TintedParticleLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftTintedParticleLeaves::new);
|
||||
register(net.minecraft.world.level.block.TntBlock.class, org.bukkit.craftbukkit.block.impl.CraftTnt::new);
|
||||
register(net.minecraft.world.level.block.TorchflowerCropBlock.class, org.bukkit.craftbukkit.block.impl.CraftTorchflowerCrop::new);
|
||||
register(net.minecraft.world.level.block.TrapDoorBlock.class, org.bukkit.craftbukkit.block.impl.CraftTrapDoor::new);
|
||||
register(net.minecraft.world.level.block.TrappedChestBlock.class, org.bukkit.craftbukkit.block.impl.CraftTrappedChest::new);
|
||||
register(net.minecraft.world.level.block.TrialSpawnerBlock.class, org.bukkit.craftbukkit.block.impl.CraftTrialSpawner::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.UntintedParticleLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftUntintedParticleLeaves::new);
|
||||
register(net.minecraft.world.level.block.VaultBlock.class, org.bukkit.craftbukkit.block.impl.CraftVault::new);
|
||||
register(net.minecraft.world.level.block.VineBlock.class, org.bukkit.craftbukkit.block.impl.CraftVine::new);
|
||||
register(net.minecraft.world.level.block.WallBannerBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallBanner::new);
|
||||
register(net.minecraft.world.level.block.WallBlock.class, org.bukkit.craftbukkit.block.impl.CraftWall::new);
|
||||
register(net.minecraft.world.level.block.WallHangingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallHangingSign::new);
|
||||
register(net.minecraft.world.level.block.WallSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallSign::new);
|
||||
register(net.minecraft.world.level.block.WallSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallSkull::new);
|
||||
register(net.minecraft.world.level.block.WallTorchBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallTorch::new);
|
||||
register(net.minecraft.world.level.block.WaterloggedTransparentBlock.class, org.bukkit.craftbukkit.block.impl.CraftWaterloggedTransparent::new);
|
||||
register(net.minecraft.world.level.block.WeatheringCopperBulbBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperBulb::new);
|
||||
register(net.minecraft.world.level.block.WeatheringCopperDoorBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperDoor::new);
|
||||
@@ -538,9 +534,14 @@ 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.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);
|
||||
register(net.minecraft.world.level.block.WeepingVinesBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeepingVines::new);
|
||||
register(net.minecraft.world.level.block.WeightedPressurePlateBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeightedPressurePlate::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.CraftWitherWallSkull::new);
|
||||
register(net.minecraft.world.level.block.piston.MovingPistonBlock.class, org.bukkit.craftbukkit.block.impl.CraftMovingPiston::new);
|
||||
register(net.minecraft.world.level.block.piston.PistonBaseBlock.class, org.bukkit.craftbukkit.block.impl.CraftPistonBase::new);
|
||||
register(net.minecraft.world.level.block.piston.PistonHeadBlock.class, org.bukkit.craftbukkit.block.impl.CraftPistonHead::new);
|
||||
// End generate - CraftBlockData#MAP
|
||||
//</editor-fold>
|
||||
}
|
||||
|
||||
@@ -612,7 +613,7 @@ public class CraftBlockData implements BlockData {
|
||||
|
||||
// Paper start - optimize creating BlockData to not need a map lookup
|
||||
static {
|
||||
// Initialize cached data for all IBlockData instances after registration
|
||||
// Initialize cached data for all BlockState instances after registration
|
||||
Block.BLOCK_STATE_REGISTRY.iterator().forEachRemaining(net.minecraft.world.level.block.state.BlockState::createCraftBlockData);
|
||||
}
|
||||
public static CraftBlockData fromData(net.minecraft.world.level.block.state.BlockState data) {
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Brushable;
|
||||
|
||||
public abstract class CraftBrushable extends CraftBlockData implements Brushable {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.IntegerProperty DUSTED = getInteger("dusted");
|
||||
|
||||
@Override
|
||||
public int getDusted() {
|
||||
return this.get(CraftBrushable.DUSTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDusted(int dusted) {
|
||||
this.set(CraftBrushable.DUSTED, dusted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumDusted() {
|
||||
return getMax(CraftBrushable.DUSTED);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Directional;
|
||||
|
||||
public abstract class CraftDirectional extends CraftBlockData implements Directional {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> FACING = getEnum("facing");
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.BlockFace getFacing() {
|
||||
return this.get(CraftDirectional.FACING, org.bukkit.block.BlockFace.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(org.bukkit.block.BlockFace facing) {
|
||||
this.set(CraftDirectional.FACING, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
|
||||
return this.getValues(CraftDirectional.FACING, org.bukkit.block.BlockFace.class);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.FaceAttachable;
|
||||
|
||||
public abstract class CraftFaceAttachable extends CraftBlockData implements FaceAttachable {
|
||||
|
||||
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 this.get(CraftFaceAttachable.ATTACH_FACE, org.bukkit.block.data.FaceAttachable.AttachedFace.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttachedFace(org.bukkit.block.data.FaceAttachable.AttachedFace face) {
|
||||
this.set(CraftFaceAttachable.ATTACH_FACE, face);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Hangable;
|
||||
|
||||
public abstract class CraftHangable extends CraftBlockData implements Hangable {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BooleanProperty HANGING = getBoolean("hanging");
|
||||
|
||||
@Override
|
||||
public boolean isHanging() {
|
||||
return this.get(CraftHangable.HANGING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHanging(boolean hanging) {
|
||||
this.set(CraftHangable.HANGING, hanging);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Hatchable;
|
||||
|
||||
public abstract class CraftHatchable extends CraftBlockData implements Hatchable {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.IntegerProperty HATCH = getInteger("hatch");
|
||||
|
||||
@Override
|
||||
public int getHatch() {
|
||||
return this.get(CraftHatchable.HATCH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHatch(int hatch) {
|
||||
this.set(CraftHatchable.HATCH, hatch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumHatch() {
|
||||
return getMax(CraftHatchable.HATCH);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Levelled;
|
||||
|
||||
public abstract class CraftLevelled extends CraftBlockData implements Levelled {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.IntegerProperty LEVEL = getInteger("level");
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return this.get(CraftLevelled.LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLevel(int level) {
|
||||
this.set(CraftLevelled.LEVEL, level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumLevel() {
|
||||
return getMax(CraftLevelled.LEVEL);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Lightable;
|
||||
|
||||
public abstract class CraftLightable extends CraftBlockData implements Lightable {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BooleanProperty LIT = getBoolean("lit");
|
||||
|
||||
@Override
|
||||
public boolean isLit() {
|
||||
return this.get(CraftLightable.LIT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLit(boolean lit) {
|
||||
this.set(CraftLightable.LIT, lit);
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.MultipleFacing;
|
||||
|
||||
public abstract class CraftMultipleFacing extends CraftBlockData implements MultipleFacing {
|
||||
|
||||
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.BooleanProperty state = CraftMultipleFacing.FACES[face.ordinal()];
|
||||
if (state == null) {
|
||||
throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces.");
|
||||
}
|
||||
return this.get(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFace(org.bukkit.block.BlockFace face, boolean has) {
|
||||
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.");
|
||||
}
|
||||
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 < CraftMultipleFacing.FACES.length; i++) {
|
||||
if (CraftMultipleFacing.FACES[i] != null && this.get(CraftMultipleFacing.FACES[i])) {
|
||||
faces.add(org.bukkit.block.BlockFace.values()[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return faces.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
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 < CraftMultipleFacing.FACES.length; i++) {
|
||||
if (CraftMultipleFacing.FACES[i] != null) {
|
||||
faces.add(org.bukkit.block.BlockFace.values()[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return faces.build();
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Openable;
|
||||
|
||||
public abstract class CraftOpenable extends CraftBlockData implements Openable {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BooleanProperty OPEN = getBoolean("open");
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return this.get(CraftOpenable.OPEN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOpen(boolean open) {
|
||||
this.set(CraftOpenable.OPEN, open);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Orientable;
|
||||
|
||||
public class CraftOrientable extends CraftBlockData implements Orientable {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> AXIS = getEnum("axis");
|
||||
|
||||
@Override
|
||||
public org.bukkit.Axis getAxis() {
|
||||
return this.get(CraftOrientable.AXIS, org.bukkit.Axis.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAxis(org.bukkit.Axis axis) {
|
||||
this.set(CraftOrientable.AXIS, axis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.Set<org.bukkit.Axis> getAxes() {
|
||||
return this.getValues(CraftOrientable.AXIS, org.bukkit.Axis.class);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Powerable;
|
||||
|
||||
public abstract class CraftPowerable extends CraftBlockData implements Powerable {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BooleanProperty POWERED = getBoolean("powered");
|
||||
|
||||
@Override
|
||||
public boolean isPowered() {
|
||||
return this.get(CraftPowerable.POWERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPowered(boolean powered) {
|
||||
this.set(CraftPowerable.POWERED, powered);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Rail;
|
||||
|
||||
public abstract class CraftRail extends CraftBlockData implements Rail {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.EnumProperty<?> SHAPE = getEnum("shape");
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.data.Rail.Shape getShape() {
|
||||
return this.get(CraftRail.SHAPE, org.bukkit.block.data.Rail.Shape.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShape(org.bukkit.block.data.Rail.Shape shape) {
|
||||
this.set(CraftRail.SHAPE, shape);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.Set<org.bukkit.block.data.Rail.Shape> getShapes() {
|
||||
return this.getValues(CraftRail.SHAPE, org.bukkit.block.data.Rail.Shape.class);
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Rotatable;
|
||||
|
||||
public abstract class CraftRotatable extends CraftBlockData implements Rotatable {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.IntegerProperty ROTATION = getInteger("rotation");
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.BlockFace getRotation() {
|
||||
int data = this.get(CraftRotatable.ROTATION);
|
||||
switch (data) {
|
||||
case 0x0:
|
||||
return org.bukkit.block.BlockFace.SOUTH;
|
||||
case 0x1:
|
||||
return org.bukkit.block.BlockFace.SOUTH_SOUTH_WEST;
|
||||
case 0x2:
|
||||
return org.bukkit.block.BlockFace.SOUTH_WEST;
|
||||
case 0x3:
|
||||
return org.bukkit.block.BlockFace.WEST_SOUTH_WEST;
|
||||
case 0x4:
|
||||
return org.bukkit.block.BlockFace.WEST;
|
||||
case 0x5:
|
||||
return org.bukkit.block.BlockFace.WEST_NORTH_WEST;
|
||||
case 0x6:
|
||||
return org.bukkit.block.BlockFace.NORTH_WEST;
|
||||
case 0x7:
|
||||
return org.bukkit.block.BlockFace.NORTH_NORTH_WEST;
|
||||
case 0x8:
|
||||
return org.bukkit.block.BlockFace.NORTH;
|
||||
case 0x9:
|
||||
return org.bukkit.block.BlockFace.NORTH_NORTH_EAST;
|
||||
case 0xA:
|
||||
return org.bukkit.block.BlockFace.NORTH_EAST;
|
||||
case 0xB:
|
||||
return org.bukkit.block.BlockFace.EAST_NORTH_EAST;
|
||||
case 0xC:
|
||||
return org.bukkit.block.BlockFace.EAST;
|
||||
case 0xD:
|
||||
return org.bukkit.block.BlockFace.EAST_SOUTH_EAST;
|
||||
case 0xE:
|
||||
return org.bukkit.block.BlockFace.SOUTH_EAST;
|
||||
case 0xF:
|
||||
return org.bukkit.block.BlockFace.SOUTH_SOUTH_EAST;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown rotation " + data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotation(org.bukkit.block.BlockFace rotation) {
|
||||
int val;
|
||||
switch (rotation) {
|
||||
case SOUTH:
|
||||
val = 0x0;
|
||||
break;
|
||||
case SOUTH_SOUTH_WEST:
|
||||
val = 0x1;
|
||||
break;
|
||||
case SOUTH_WEST:
|
||||
val = 0x2;
|
||||
break;
|
||||
case WEST_SOUTH_WEST:
|
||||
val = 0x3;
|
||||
break;
|
||||
case WEST:
|
||||
val = 0x4;
|
||||
break;
|
||||
case WEST_NORTH_WEST:
|
||||
val = 0x5;
|
||||
break;
|
||||
case NORTH_WEST:
|
||||
val = 0x6;
|
||||
break;
|
||||
case NORTH_NORTH_WEST:
|
||||
val = 0x7;
|
||||
break;
|
||||
case NORTH:
|
||||
val = 0x8;
|
||||
break;
|
||||
case NORTH_NORTH_EAST:
|
||||
val = 0x9;
|
||||
break;
|
||||
case NORTH_EAST:
|
||||
val = 0xA;
|
||||
break;
|
||||
case EAST_NORTH_EAST:
|
||||
val = 0xB;
|
||||
break;
|
||||
case EAST:
|
||||
val = 0xC;
|
||||
break;
|
||||
case EAST_SOUTH_EAST:
|
||||
val = 0xD;
|
||||
break;
|
||||
case SOUTH_EAST:
|
||||
val = 0xE;
|
||||
break;
|
||||
case SOUTH_SOUTH_EAST:
|
||||
val = 0xF;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Illegal rotation " + rotation);
|
||||
}
|
||||
this.set(CraftRotatable.ROTATION, val);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Snowable;
|
||||
|
||||
public abstract class CraftSnowable extends CraftBlockData implements Snowable {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BooleanProperty SNOWY = getBoolean("snowy");
|
||||
|
||||
@Override
|
||||
public boolean isSnowy() {
|
||||
return this.get(CraftSnowable.SNOWY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSnowy(boolean snowy) {
|
||||
this.set(CraftSnowable.SNOWY, snowy);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
|
||||
public abstract class CraftWaterlogged extends CraftBlockData implements Waterlogged {
|
||||
|
||||
private static final net.minecraft.world.level.block.state.properties.BooleanProperty WATERLOGGED = getBoolean("waterlogged");
|
||||
|
||||
@Override
|
||||
public boolean isWaterlogged() {
|
||||
return this.get(CraftWaterlogged.WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWaterlogged(boolean waterlogged) {
|
||||
this.set(CraftWaterlogged.WATERLOGGED, waterlogged);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Bamboo;
|
||||
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.EnumProperty<?> LEAVES = getEnum("leaves");
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.data.type.Bamboo.Leaves getLeaves() {
|
||||
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) {
|
||||
this.set(CraftBamboo.LEAVES, leaves);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Bed;
|
||||
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.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 this.get(CraftBed.PART, org.bukkit.block.data.type.Bed.Part.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPart(org.bukkit.block.data.type.Bed.Part part) {
|
||||
this.set(CraftBed.PART, part);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOccupied() {
|
||||
return this.get(CraftBed.OCCUPIED);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Beehive;
|
||||
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.IntegerProperty HONEY_LEVEL = getInteger("honey_level");
|
||||
|
||||
@Override
|
||||
public int getHoneyLevel() {
|
||||
return this.get(CraftBeehive.HONEY_LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHoneyLevel(int honeyLevel) {
|
||||
this.set(CraftBeehive.HONEY_LEVEL, honeyLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumHoneyLevel() {
|
||||
return getMax(CraftBeehive.HONEY_LEVEL);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Bell;
|
||||
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.EnumProperty<?> ATTACHMENT = getEnum("attachment");
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.data.type.Bell.Attachment getAttachment() {
|
||||
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) {
|
||||
this.set(CraftBell.ATTACHMENT, leaves);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.BigDripleaf;
|
||||
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.EnumProperty<?> TILT = getEnum("tilt");
|
||||
|
||||
@Override
|
||||
public Tilt getTilt() {
|
||||
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) {
|
||||
this.set(CraftBigDripleaf.TILT, tilt);
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.BrewingStand;
|
||||
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.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 this.get(CraftBrewingStand.HAS_BOTTLE[bottle]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBottle(int bottle, boolean 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 < this.getMaximumBottles(); index++) {
|
||||
if (this.hasBottle(index)) {
|
||||
bottles.add(index);
|
||||
}
|
||||
}
|
||||
|
||||
return bottles.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumBottles() {
|
||||
return CraftBrewingStand.HAS_BOTTLE.length;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.Brushable;
|
||||
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.IntegerProperty DUSTED = getInteger("dusted");
|
||||
|
||||
@Override
|
||||
public int getDusted() {
|
||||
return this.get(CraftBrushable.DUSTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDusted(int dusted) {
|
||||
this.set(CraftBrushable.DUSTED, dusted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumDusted() {
|
||||
return getMax(CraftBrushable.DUSTED);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.BubbleColumn;
|
||||
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.BooleanProperty DRAG = getBoolean("drag");
|
||||
|
||||
@Override
|
||||
public boolean isDrag() {
|
||||
return this.get(CraftBubbleColumn.DRAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDrag(boolean drag) {
|
||||
this.set(CraftBubbleColumn.DRAG, drag);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Cake;
|
||||
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.IntegerProperty BITES = getInteger("bites");
|
||||
|
||||
@Override
|
||||
public int getBites() {
|
||||
return this.get(CraftCake.BITES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBites(int bites) {
|
||||
this.set(CraftCake.BITES, bites);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumBites() {
|
||||
return getMax(CraftCake.BITES);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Campfire;
|
||||
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.BooleanProperty SIGNAL_FIRE = getBoolean("signal_fire");
|
||||
|
||||
@Override
|
||||
public boolean isSignalFire() {
|
||||
return this.get(CraftCampfire.SIGNAL_FIRE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSignalFire(boolean signalFire) {
|
||||
this.set(CraftCampfire.SIGNAL_FIRE, signalFire);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Candle;
|
||||
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.IntegerProperty CANDLES = getInteger("candles");
|
||||
|
||||
@Override
|
||||
public int getCandles() {
|
||||
return this.get(CraftCandle.CANDLES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCandles(int candles) {
|
||||
this.set(CraftCandle.CANDLES, candles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumCandles() {
|
||||
return getMax(CraftCandle.CANDLES);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.CaveVinesPlant;
|
||||
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.BooleanProperty BERRIES = getBoolean("berries");
|
||||
|
||||
@Override
|
||||
public boolean isBerries() {
|
||||
return this.get(CraftCaveVinesPlant.BERRIES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBerries(boolean berries) {
|
||||
this.set(CraftCaveVinesPlant.BERRIES, berries);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Chest;
|
||||
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.EnumProperty<?> TYPE = getEnum("type");
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.data.type.Chest.Type getType() {
|
||||
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) {
|
||||
this.set(CraftChest.TYPE, type);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.ChiseledBookshelf;
|
||||
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.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 this.get(CraftChiseledBookshelf.SLOT_OCCUPIED[slot]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlotOccupied(int slot, boolean 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 < this.getMaximumOccupiedSlots(); index++) {
|
||||
if (this.isSlotOccupied(index)) {
|
||||
slots.add(index);
|
||||
}
|
||||
}
|
||||
|
||||
return slots.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumOccupiedSlots() {
|
||||
return CraftChiseledBookshelf.SLOT_OCCUPIED.length;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.CommandBlock;
|
||||
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.BooleanProperty CONDITIONAL = getBoolean("conditional");
|
||||
|
||||
@Override
|
||||
public boolean isConditional() {
|
||||
return this.get(CraftCommandBlock.CONDITIONAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConditional(boolean conditional) {
|
||||
this.set(CraftCommandBlock.CONDITIONAL, conditional);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Comparator;
|
||||
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.EnumProperty<?> MODE = getEnum("mode");
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.data.type.Comparator.Mode getMode() {
|
||||
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) {
|
||||
this.set(CraftComparator.MODE, mode);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Crafter;
|
||||
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.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 this.get(CraftCrafter.CRAFTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCrafting(boolean crafting) {
|
||||
this.set(CraftCrafter.CRAFTING, crafting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTriggered() {
|
||||
return this.get(CraftCrafter.TRIGGERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTriggered(boolean triggered) {
|
||||
this.set(CraftCrafter.TRIGGERED, triggered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.data.type.Crafter.Orientation getOrientation() {
|
||||
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) {
|
||||
this.set(CraftCrafter.ORIENTATION, orientation);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.CreakingHeart;
|
||||
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.BooleanProperty ACTIVE = getBoolean("active");
|
||||
private static final net.minecraft.world.level.block.state.properties.BooleanProperty NATURAL = getBoolean("natural");
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return this.get(CraftCreakingHeart.ACTIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active) {
|
||||
this.set(CraftCreakingHeart.ACTIVE, active);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNatural() {
|
||||
return this.get(CraftCreakingHeart.NATURAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNatural(boolean natural) {
|
||||
this.set(CraftCreakingHeart.NATURAL, natural);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.DaylightDetector;
|
||||
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.BooleanProperty INVERTED = getBoolean("inverted");
|
||||
|
||||
@Override
|
||||
public boolean isInverted() {
|
||||
return this.get(CraftDaylightDetector.INVERTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInverted(boolean inverted) {
|
||||
this.set(CraftDaylightDetector.INVERTED, inverted);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Dispenser;
|
||||
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.BooleanProperty TRIGGERED = getBoolean("triggered");
|
||||
|
||||
@Override
|
||||
public boolean isTriggered() {
|
||||
return this.get(CraftDispenser.TRIGGERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTriggered(boolean triggered) {
|
||||
this.set(CraftDispenser.TRIGGERED, triggered);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Door;
|
||||
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.EnumProperty<?> HINGE = getEnum("hinge");
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.data.type.Door.Hinge getHinge() {
|
||||
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) {
|
||||
this.set(CraftDoor.HINGE, hinge);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.EndPortalFrame;
|
||||
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.BooleanProperty EYE = getBoolean("eye");
|
||||
|
||||
@Override
|
||||
public boolean hasEye() {
|
||||
return this.get(CraftEndPortalFrame.EYE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEye(boolean eye) {
|
||||
this.set(CraftEndPortalFrame.EYE, eye);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user