v1.4.3: Release #15
7 changed files with 135 additions and 72 deletions
6
pom.xml
6
pom.xml
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ This file is part of MapReflectionAPI.
|
||||
~ Copyright (c) 2022 inventivetalent / SBDevelopment - All Rights Reserved
|
||||
~ Copyright (c) 2022-2023 inventivetalent / SBDevelopment - All Rights Reserved
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
|
@ -24,7 +24,7 @@
|
|||
|
||||
<groupId>tech.sbdevelopment</groupId>
|
||||
<artifactId>MapReflectionAPI</artifactId>
|
||||
<version>1.4.2</version>
|
||||
<version>1.4.3</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>MapReflectionAPI</name>
|
||||
|
@ -161,7 +161,7 @@
|
|||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.19.3-R0.1-SNAPSHOT</version>
|
||||
<version>1.19.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -3,4 +3,6 @@
|
|||
These classes are from [BKCommonLib](https://github.com/bergerhealer/BKCommonLib). Only the required classes and methods
|
||||
are extracted.
|
||||
|
||||
Current version: master#25ad90b702cabbbf632c40f6ed209241aee38a41 (1.19.1-v1 release)
|
||||
**Current version:** master#3fc97d5981742f43348cac1f752404f95daa6c07
|
||||
|
||||
_Last update: 16-03-2023_
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of MapReflectionAPI.
|
||||
* Copyright (c) 2022 inventivetalent / SBDevelopment - All Rights Reserved
|
||||
* Copyright (c) 2022-2023 inventivetalent / SBDevelopment - All Rights Reserved
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -26,6 +26,7 @@ import java.io.InputStream;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.IntPredicate;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
/**
|
||||
|
@ -99,7 +100,7 @@ public class MCSDBubbleFormat extends MapColorSpaceData {
|
|||
private void initColors() {
|
||||
// Set initial cell colors
|
||||
this.clearRGBData();
|
||||
for (Bubble cell : bubbles) {
|
||||
for (MCSDBubbleFormat.Bubble cell : bubbles) {
|
||||
for (int z = cell.z_min; z <= cell.z_max; z++) {
|
||||
this.set(cell.x, cell.y, z, cell.color);
|
||||
}
|
||||
|
@ -108,62 +109,119 @@ public class MCSDBubbleFormat extends MapColorSpaceData {
|
|||
}
|
||||
|
||||
private void spreadColors() {
|
||||
final boolean[] all_strands = new boolean[1 << 24];
|
||||
// As we'll be processing pretty much every element, allocate the full space (60MB)
|
||||
// The range of the buffer we process shrinks as we spread
|
||||
StrandBuffer buf;
|
||||
{
|
||||
final int[] buffer = new int[1 << 24];
|
||||
int count = -1;
|
||||
for (int z = 0; z < 256; z++) {
|
||||
System.arraycopy(this.strands[z], 0, all_strands, z << 16, 1 << 16);
|
||||
boolean[] layerStrands = this.strands[z];
|
||||
int indexOffset = z << 16;
|
||||
for (int i = 0; i < (1 << 16); i++) {
|
||||
if (!layerStrands[i]) {
|
||||
buffer[++count] = indexOffset + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
count++;
|
||||
buf = new StrandBuffer(buffer, count);
|
||||
}
|
||||
|
||||
boolean mode = false;
|
||||
boolean hasChanges;
|
||||
do {
|
||||
hasChanges = false;
|
||||
|
||||
// Alternate the direction in which we process every step
|
||||
// This prevents really slow filling when the direction is 'wrong'
|
||||
// The below logic is partially based on the light fixing algorithm in Light Cleaner
|
||||
final int index_end, index_delta;
|
||||
int index;
|
||||
// Process all until no more changes remain
|
||||
buf.process(index -> {
|
||||
byte color;
|
||||
if (mode = !mode) {
|
||||
index_delta = 1;
|
||||
index = 0;
|
||||
index_end = (1 << 24);
|
||||
} else {
|
||||
index_delta = -1;
|
||||
index = (1 << 24) - 1;
|
||||
index_end = 0;
|
||||
}
|
||||
do {
|
||||
if (!all_strands[index]) {
|
||||
all_strands[index] = true;
|
||||
|
||||
if ((index & 0xFF) < 0xFF) {
|
||||
if ((color = this.get(index + 1)) != 0) {
|
||||
this.set(index, color);
|
||||
hasChanges = true;
|
||||
} else if ((color = this.get(index)) != 0) {
|
||||
boolean col = ((index & 0xFF) < 0xFF);
|
||||
boolean row = ((index & 0xFF00) < 0xFF00);
|
||||
|
||||
if (col && row) {
|
||||
if ((color = this.get(index)) != 0) {
|
||||
this.set(index + 1, color);
|
||||
hasChanges = true;
|
||||
} else {
|
||||
all_strands[index] = false; // retry
|
||||
this.set(index + 256, color);
|
||||
return true;
|
||||
} else if ((color = this.get(index + 1)) != 0) {
|
||||
this.set(index, color);
|
||||
this.set(index + 256, color);
|
||||
return true;
|
||||
} else if ((color = this.get(index + 256)) != 0) {
|
||||
this.set(index, color);
|
||||
this.set(index + 1, color);
|
||||
return true;
|
||||
}
|
||||
} else if (col) {
|
||||
if ((color = this.get(index)) != 0) {
|
||||
this.set(index + 1, color);
|
||||
return true;
|
||||
} else if ((color = this.get(index + 1)) != 0) {
|
||||
this.set(index, color);
|
||||
return true;
|
||||
}
|
||||
} else if (row) {
|
||||
if ((color = this.get(index)) != 0) {
|
||||
this.set(index + 256, color);
|
||||
return true;
|
||||
} else if ((color = this.get(index + 256)) != 0) {
|
||||
this.set(index, color);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((index & 0xFF00) < 0xFF00) {
|
||||
if ((color = this.get(index + 256)) != 0) {
|
||||
this.set(index, color);
|
||||
hasChanges = true;
|
||||
} else if ((color = this.get(index)) != 0) {
|
||||
this.set(index + 256, color);
|
||||
hasChanges = true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
private static class StrandBuffer {
|
||||
private final int[] buf;
|
||||
private int start, end;
|
||||
|
||||
public StrandBuffer(int[] buffer, int count) {
|
||||
this.buf = buffer;
|
||||
this.start = 0;
|
||||
this.end = count - 1;
|
||||
}
|
||||
|
||||
public void process(IntPredicate strandIndexProc) {
|
||||
while (forward(strandIndexProc) && reverse(strandIndexProc)) {
|
||||
// Process alternating over and over until there are no more changes
|
||||
}
|
||||
}
|
||||
|
||||
public boolean forward(IntPredicate strandIndexProc) {
|
||||
int[] buf = this.buf;
|
||||
int writeIdx = start - 1;
|
||||
int endIdx = end;
|
||||
boolean changed = false;
|
||||
for (int i = start; i <= endIdx; ++i) {
|
||||
int strandIndex = buf[i];
|
||||
if (strandIndexProc.test(strandIndex)) {
|
||||
changed = true;
|
||||
} else {
|
||||
all_strands[index] = false; // retry
|
||||
buf[++writeIdx] = strandIndex;
|
||||
}
|
||||
}
|
||||
this.end = writeIdx;
|
||||
return changed;
|
||||
}
|
||||
} while ((index += index_delta) != index_end);
|
||||
} while (hasChanges);
|
||||
|
||||
public boolean reverse(IntPredicate strandIndexProc) {
|
||||
int[] buf = this.buf;
|
||||
int writeIdx = end + 1;
|
||||
int startIdx = start;
|
||||
boolean changed = false;
|
||||
for (int i = end; i >= startIdx; --i) {
|
||||
int strandIndex = buf[i];
|
||||
if (strandIndexProc.test(strandIndex)) {
|
||||
changed = true;
|
||||
} else {
|
||||
buf[--writeIdx] = strandIndex;
|
||||
}
|
||||
}
|
||||
this.start = writeIdx;
|
||||
return changed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of MapReflectionAPI.
|
||||
* Copyright (c) 2022 inventivetalent / SBDevelopment - All Rights Reserved
|
||||
* Copyright (c) 2022-2023 inventivetalent / SBDevelopment - All Rights Reserved
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -64,11 +64,11 @@ public class MapReflectionAPI extends JavaPlugin {
|
|||
instance = this;
|
||||
|
||||
getLogger().info("----------------");
|
||||
getLogger().info("MapReflectionAPI v" + getDescription().getVersion() + "");
|
||||
getLogger().info("Made by © Copyright SBDevelopment 2022");
|
||||
getLogger().info("MapReflectionAPI v" + getDescription().getVersion());
|
||||
getLogger().info("Made by © Copyright SBDevelopment 2023");
|
||||
|
||||
if (!ReflectionUtil.supports(12)) {
|
||||
getLogger().severe("MapReflectionAPI only supports Minecraft 1.12.x - 1.19.x!");
|
||||
getLogger().severe("MapReflectionAPI only supports Minecraft 1.12 - 1.19.4!");
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of MapReflectionAPI.
|
||||
* Copyright (c) 2022 inventivetalent / SBDevelopment - All Rights Reserved
|
||||
* Copyright (c) 2022-2023 inventivetalent / SBDevelopment - All Rights Reserved
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -168,7 +168,7 @@ public class MapWrapper extends AbstractMapWrapper {
|
|||
|
||||
String inventoryMenuName;
|
||||
if (ReflectionUtil.supports(19)) { //1.19
|
||||
inventoryMenuName = "bT";
|
||||
inventoryMenuName = ReflectionUtil.VER_MINOR == 3 ? "bO" : "bT"; //1.19.4 = bO, >= 1.19.3 = bT
|
||||
} else if (ReflectionUtil.supports(18)) { //1.18
|
||||
inventoryMenuName = ReflectionUtil.VER_MINOR == 1 ? "bV" : "bU"; //1.18.1 = ap, 1.18(.2) = ao
|
||||
} else if (ReflectionUtil.supports(17)) { //1.17, same as 1.18(.2)
|
||||
|
@ -322,8 +322,8 @@ public class MapWrapper extends AbstractMapWrapper {
|
|||
Object nmsStack = createCraftItemStack(stack, mapId);
|
||||
|
||||
String dataWatcherObjectName;
|
||||
if (ReflectionUtil.supports(19)) { //1.19, same as 1.17 and 1.18(.2)
|
||||
dataWatcherObjectName = "ao";
|
||||
if (ReflectionUtil.supports(19)) { //1.19
|
||||
dataWatcherObjectName = ReflectionUtil.VER_MINOR == 3 ? "g" : "ao"; //1.19.4 = g, >= 1.19.3 = ao
|
||||
} else if (ReflectionUtil.supports(18)) { //1.18
|
||||
dataWatcherObjectName = ReflectionUtil.VER_MINOR == 1 ? "ap" : "ao"; //1.18.1 = ap, 1.18(.2) = ao
|
||||
} else if (ReflectionUtil.supports(17)) { //1.17
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of MapReflectionAPI.
|
||||
* Copyright (c) 2022 inventivetalent / SBDevelopment - All Rights Reserved
|
||||
* Copyright (c) 2022-2023 inventivetalent / SBDevelopment - All Rights Reserved
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -115,7 +115,7 @@ public class PacketListener implements Listener {
|
|||
} else if (packet.getClass().isAssignableFrom(packetPlayInSetCreativeSlotClass)) {
|
||||
Object packetPlayInSetCreativeSlot = packetPlayInSetCreativeSlotClass.cast(packet);
|
||||
|
||||
int slot = (int) ReflectionUtil.callDeclaredMethod(packetPlayInSetCreativeSlot, ReflectionUtil.supports(13) ? "b" : "a"); //1.13 = b, 1.12 = a
|
||||
int slot = (int) ReflectionUtil.callDeclaredMethod(packetPlayInSetCreativeSlot, ReflectionUtil.supports(19, 3) ? "a" : ReflectionUtil.supports(13) ? "b" : "a"); //1.19.4 = a, 1.19.3 - 1.13 = b, 1.12 = a
|
||||
Object nmsStack = ReflectionUtil.callDeclaredMethod(packetPlayInSetCreativeSlot, ReflectionUtil.supports(18) ? "c" : "getItemStack"); //1.18 = c, 1.17 = getItemStack
|
||||
ItemStack craftStack = (ItemStack) ReflectionUtil.callMethod(craftStackClass, "asBukkitCopy", nmsStack);
|
||||
|
||||
|
@ -143,8 +143,8 @@ public class PacketListener implements Listener {
|
|||
private Channel getChannel(Player player) {
|
||||
Object playerHandle = getHandle(player);
|
||||
Object playerConnection = getDeclaredField(playerHandle, ReflectionUtil.supports(17) ? "b" : "playerConnection"); //1.17 = b, 1.16 = playerConnection
|
||||
Object networkManager = getDeclaredField(playerConnection, ReflectionUtil.supports(19) ? "b" : ReflectionUtil.supports(17) ? "a" : "networkManager"); //1.19 = b, 1.18 = a, 1.16 = networkManager
|
||||
return (Channel) getDeclaredField(networkManager, ReflectionUtil.supports(18) ? "m" : ReflectionUtil.supports(17) ? "k" : "channel"); //1.18 = m, 1.17 = k, 1.16 = channel
|
||||
Object networkManager = getDeclaredField(playerConnection, ReflectionUtil.supports(19, 3) ? "h" : ReflectionUtil.supports(19) ? "b" : ReflectionUtil.supports(17) ? "a" : "networkManager"); //1.19.4 = h, >= 1.19.3 = b, 1.18 = a, 1.16 = networkManager
|
||||
return (Channel) getDeclaredField(networkManager, ReflectionUtil.supports(18) ? "m" : ReflectionUtil.supports(17) ? "k" : "channel"); //1.19 & 1.18 = m, 1.17 = k, 1.16 = channel
|
||||
}
|
||||
|
||||
private Vector vec3DToVector(Object vec3d) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of MapReflectionAPI.
|
||||
* Copyright (c) 2022 inventivetalent / SBDevelopment - All Rights Reserved
|
||||
* Copyright (c) 2022-2023 inventivetalent / SBDevelopment - All Rights Reserved
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -187,6 +187,9 @@ public class ReflectionUtil {
|
|||
|
||||
/**
|
||||
* Checks whether the server version is equal or greater than the given version.
|
||||
* <p>
|
||||
* PAY ATTENTION! The minor version is based on the NMS version.
|
||||
* This means that v1_19_R3 has major version 19 and minor version 3.
|
||||
*
|
||||
* @param major the major version to compare the server version with.
|
||||
* @param minor the minor version to compare the server version with.
|
||||
|
|
Loading…
Add table
Reference in a new issue