Skip to content

Commit 79cb650

Browse files
committed
Change co_block.data type to Int32
Fixes an issue with int underflows when placing/breaking armor stands
1 parent 787f073 commit 79cb650

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
org.gradle.configuration-cache = true
22

33
group = net.earthmc.coreprotect-clickhouse
4-
version = 22.4.3-SNAPSHOT
4+
version = 22.4.4-SNAPSHOT

src/main/java/net/coreprotect/database/Database.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ private static void createTableStructures(String prefix, Statement statement) th
290290

291291
// Block
292292
orderBy = "ORDER BY (wid, y, x, z, time, user, type)";
293-
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "block(rowid UInt64, time UInt32, user UInt32, wid UInt32, x Int32, y Int16, z Int32, type UInt32, data UInt32, meta JSON, blockdata LowCardinality(String), action UInt8, rolled_back UInt8, version UInt8) ENGINE = ReplacingMergeTree(version) " + orderBy + partitionBy);
293+
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "block(rowid UInt64, time UInt32, user UInt32, wid UInt32, x Int32, y Int16, z Int32, type UInt32, data Int32, meta JSON, blockdata LowCardinality(String), action UInt8, rolled_back UInt8, version UInt8) ENGINE = ReplacingMergeTree(version) " + orderBy + partitionBy);
294294

295295
// Chat
296296
orderBy = "ORDER BY (user, time, wid, x, z)";
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package net.coreprotect.patch.script;
2+
3+
import net.coreprotect.CoreProtect;
4+
import net.coreprotect.config.ConfigHandler;
5+
import org.slf4j.Logger;
6+
7+
import java.sql.SQLException;
8+
import java.sql.Statement;
9+
10+
public class __22_4_4 {
11+
protected static boolean patch(Statement statement) {
12+
final Logger logger = CoreProtect.getInstance().getSLF4JLogger();
13+
14+
// The assumption of co_block.data never being negative is wrong due to armor stands using it to store their yaw in it
15+
try {
16+
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "block ALTER COLUMN data TYPE Int32");
17+
return true;
18+
} catch (SQLException e) {
19+
logger.error("An unexpected exception happened while altering data type of the data column in the {}block table to Int32", ConfigHandler.prefix, e);
20+
return false;
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)