mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-01 00:10:40 +01:00
Add NMS support for 1.21.3
This commit is contained in:
parent
c5b1a9037f
commit
3288d22334
@ -616,7 +616,6 @@ public class User implements MetaDataAble {
|
||||
* @param message The message to send, containing inline commands in square brackets.
|
||||
*/
|
||||
public void sendRawMessage(String message) {
|
||||
BentoBox.getInstance().logDebug(message);
|
||||
// Create a base TextComponent for the message
|
||||
TextComponent baseComponent = new TextComponent();
|
||||
|
||||
|
@ -0,0 +1,52 @@
|
||||
package world.bentobox.bentobox.nms.v1_21_3_R0_1_SNAPSHOT;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_21_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_21_R2.block.data.CraftBlockData;
|
||||
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.nms.PasteHandler;
|
||||
import world.bentobox.bentobox.util.DefaultPasteUtil;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
public class PasteHandlerImpl implements PasteHandler {
|
||||
|
||||
protected static final IBlockData AIR = ((CraftBlockData) AIR_BLOCKDATA).getState();
|
||||
|
||||
/**
|
||||
* Set the block to the location
|
||||
*
|
||||
* @param island - island
|
||||
* @param location - location
|
||||
* @param bpBlock - blueprint block
|
||||
*/
|
||||
@Override
|
||||
public CompletableFuture<Void> setBlock(Island island, Location location, BlueprintBlock bpBlock) {
|
||||
return Util.getChunkAtAsync(location).thenRun(() -> {
|
||||
Block block = location.getBlock();
|
||||
// Set the block data - default is AIR
|
||||
BlockData bd = DefaultPasteUtil.createBlockData(bpBlock);
|
||||
CraftBlockData craft = (CraftBlockData) bd;
|
||||
net.minecraft.world.level.World nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
|
||||
Chunk nmsChunk = nmsWorld.d(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
BlockPosition bp = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
// Setting the block to air before setting to another state prevents some console errors
|
||||
nmsChunk.a(bp, AIR, false);
|
||||
nmsChunk.a(bp, craft.getState(), false);
|
||||
block.setBlockData(bd, false);
|
||||
DefaultPasteUtil.setBlockState(island, block, bpBlock);
|
||||
// Set biome
|
||||
if (bpBlock.getBiome() != null) {
|
||||
block.setBiome(bpBlock.getBiome());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package world.bentobox.bentobox.nms.v1_21_3_R0_1_SNAPSHOT;
|
||||
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_21_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_21_R2.block.data.CraftBlockData;
|
||||
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import world.bentobox.bentobox.nms.CopyWorldRegenerator;
|
||||
|
||||
public class WorldRegeneratorImpl extends CopyWorldRegenerator {
|
||||
|
||||
@Override
|
||||
public void setBlockInNativeChunk(org.bukkit.Chunk chunk, int x, int y, int z, BlockData blockData,
|
||||
boolean applyPhysics) {
|
||||
CraftBlockData craft = (CraftBlockData) blockData;
|
||||
World nmsWorld = ((CraftWorld) chunk.getWorld()).getHandle();
|
||||
Chunk nmsChunk = nmsWorld.d(chunk.getX(), chunk.getZ());
|
||||
BlockPosition bp = new BlockPosition((chunk.getX() << 4) + x, y, (chunk.getZ() << 4) + z);
|
||||
// Setting the block to air before setting to another state prevents some console errors
|
||||
nmsChunk.a(bp, PasteHandlerImpl.AIR, applyPhysics);
|
||||
nmsChunk.a(bp, craft.getState(), applyPhysics);
|
||||
}
|
||||
|
||||
}
|
@ -743,6 +743,7 @@ public class Util {
|
||||
throw new IllegalStateException("Class " + clazz.getName() + " does not implement WorldRegenerator");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
plugin.logWarning("No Regenerator found for " + bukkitVersion + ", falling back to Bukkit API.");
|
||||
handler = new world.bentobox.bentobox.nms.fallback.WorldRegeneratorImpl();
|
||||
}
|
||||
@ -772,6 +773,7 @@ public class Util {
|
||||
throw new IllegalStateException("Class " + clazz.getName() + " does not implement PasteHandler");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
plugin.logWarning("No PasteHandler found for " + bukkitVersion + ", falling back to Bukkit API.");
|
||||
handler = new world.bentobox.bentobox.nms.fallback.PasteHandlerImpl();
|
||||
}
|
||||
|
@ -249,7 +249,12 @@ public class ServerCompatibility {
|
||||
/**
|
||||
* @since 2.5.0
|
||||
*/
|
||||
V1_21_1(Compatibility.COMPATIBLE);
|
||||
V1_21_1(Compatibility.COMPATIBLE),
|
||||
|
||||
/**
|
||||
* @since 2.7.0
|
||||
*/
|
||||
V1_21_2(Compatibility.INCOMPATIBLE), V1_21_3(Compatibility.COMPATIBLE);
|
||||
|
||||
private final Compatibility compatibility;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user