Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reimplement anvil feature #2404

Draft
wants to merge 4 commits into
base: v3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,16 @@ public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
return CraftItemStack.asCraftMirror(stack);
}

@Override
public char[] getIbdToStateOrdinal() {
return new char[0];
}

@Override
public int[] getOrdinalToIbdID() {
return new int[0];
}

@Override
public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) {
final ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,16 @@ public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
return CraftItemStack.asCraftMirror(stack);
}

@Override
public char[] getIbdToStateOrdinal() {
return new char[0];
}

@Override
public int[] getOrdinalToIbdID() {
return new int[0];
}

@Override
public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) {
final ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,16 @@ public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
return CraftItemStack.asCraftMirror(stack);
}

@Override
public char[] getIbdToStateOrdinal() {
return new char[0];
}

@Override
public int[] getOrdinalToIbdID() {
return new int[0];
}

@Override
public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) {
var registryAccess = DedicatedServer.getServer().registryAccess();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,16 @@ public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
return CraftItemStack.asCraftMirror(stack);
}

@Override
public char[] getIbdToStateOrdinal() {
return new char[0];
}

@Override
public int[] getOrdinalToIbdID() {
return new int[0];
}

@Override
public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) {
var registryAccess = DedicatedServer.getServer().registryAccess();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.bukkit.plugin.PluginManager;

import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -312,6 +313,16 @@ public FAWEPlatformAdapterImpl getPlatformAdapter() {
return platformAdapter;
}

@Override
public Path getWorldsFolder() {
return Bukkit.getWorldContainer().toPath();
}

@Override
public boolean isWorldLoaded(String world) {
return Bukkit.getWorld(world) != null;
}

private void setupPlotSquared() {
Plugin plotSquared = this.plugin.getServer().getPluginManager().getPlugin("PlotSquared");
if (plotSquared == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,4 @@ public BlockState adapt(BlockData blockData) {
}
}

protected abstract char[] getIbdToStateOrdinal();

protected abstract int[] getOrdinalToIbdID();

}
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,14 @@ default List<org.bukkit.entity.Entity> getEntities(org.bukkit.World world) {
return TaskManager.taskManager().sync(world::getEntities);
}

/**
* Get a char array of minecraft internal IDs against FAWE char IDs
*/
char[] getIbdToStateOrdinal();

/**
* Get an int array of FAWE char IDs against minecraft internal IDs
*/
int[] getOrdinalToIbdID();

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ private boolean init() {
}

@Override
protected char[] getIbdToStateOrdinal() {
public char[] getIbdToStateOrdinal() {
return new char[Character.MAX_VALUE + 1];
}

@Override
protected int[] getOrdinalToIbdID() {
public int[] getOrdinalToIbdID() {
return new int[Character.MAX_VALUE + 1];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,4 +495,20 @@ public static ItemStack adapt(BaseItemStack item) {
return getAdapter().adapt(item);
//FAWE end
}

//FAWE start
/**
* Get a char array of minecraft internal IDs against FAWE char IDs
*/
public static char[] getIbdToStateOrdinal() {
return getAdapter().getIbdToStateOrdinal();
}

/**
* Get an int array of FAWE char IDs against minecraft internal IDs
*/
public static int[] getOrdinalToIbdID() {
return getAdapter().getOrdinalToIbdID();
}
//FAWE end
}
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,17 @@ public IBatchProcessor getPlatformPostProcessor(boolean fastMode) {
}
return this.plugin.getBukkitImplAdapter().getTickingPostProcessor();
}

@Nullable
@Override
public char[] getIbdToStateOrdinal() {
return BukkitAdapter.getIbdToStateOrdinal();
}

@Nullable
@Override
public int[] getOrdinalToIbdID() {
return BukkitAdapter.getOrdinalToIbdID();
}
//FAWE end
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.sk89q.worldedit.entity.Player;

import java.io.File;
import java.nio.file.Path;
import java.util.Collection;
import java.util.UUID;

Expand Down Expand Up @@ -49,4 +50,8 @@ default boolean isChunksStretched() {

FAWEPlatformAdapterImpl getPlatformAdapter();

Path getWorldsFolder();

boolean isWorldLoaded(String world);

}
Loading
Loading