Fixed broken entity rollbacks

This commit is contained in:
Intelli 2025-03-10 17:15:59 -06:00
parent afb13e6677
commit 3038e96c6e
4 changed files with 8 additions and 36 deletions

View file

@ -46,7 +46,7 @@ public class RollbackEntityHandler {
* The username associated with this entity change
* @return The number of entities affected (1 if successful, 0 otherwise)
*/
public static int processEntity(Object[] row, int rollbackType, String finalUserString, int rowTypeRaw, int rowData, int rowAction, int rowRolledBack, int rowX, int rowY, int rowZ, int rowWorldId, int rowUserId, String rowUser) {
public static int processEntity(Object[] row, int rollbackType, String finalUserString, int oldTypeRaw, int rowTypeRaw, int rowData, int rowAction, int rowRolledBack, int rowX, int rowY, int rowZ, int rowWorldId, int rowUserId, String rowUser) {
try {
// Entity kill
if (rowAction == 3) {
@ -76,12 +76,11 @@ public class RollbackEntityHandler {
}
}
else if (rowTypeRaw <= 0) {
int oldTypeRaw = rowTypeRaw;
// Attempt to remove entity
if (rowRolledBack == 1) {
boolean removed = false;
int entityId = -1;
String entityName = EntityUtils.getEntityType(Math.abs(oldTypeRaw)).name();
String entityName = EntityUtils.getEntityType(oldTypeRaw).name();
String token = "" + rowX + "." + rowY + "." + rowZ + "." + rowWorldId + "." + entityName + "";
Object[] cachedEntity = CacheHandler.entityCache.get(token);
@ -107,7 +106,7 @@ public class RollbackEntityHandler {
}
}
else {
if (entity.getType().equals(EntityUtils.getEntityType(Math.abs(oldTypeRaw)))) {
if (entity.getType().equals(EntityUtils.getEntityType(oldTypeRaw))) {
Location entityLocation = entity.getLocation();
int entityx = entityLocation.getBlockX();
int entityY = entityLocation.getBlockY();

View file

@ -169,7 +169,7 @@ public class RollbackProcessor {
}
}
else if (rowAction == 3) { // entity kill
entityCount += RollbackEntityHandler.processEntity(row, rollbackType, finalUserString, rowTypeRaw, rowData, rowAction, MaterialUtils.rolledBack((Integer) row[9], false), rowX, rowY, rowZ, rowWorldId, (Integer) row[2], rowUser);
entityCount += RollbackEntityHandler.processEntity(row, rollbackType, finalUserString, oldTypeRaw, rowTypeRaw, rowData, rowAction, MaterialUtils.rolledBack((Integer) row[9], false), rowX, rowY, rowZ, rowWorldId, (Integer) row[2], rowUser);
}
else {
String world = WorldUtils.getWorldName(rowWorldId);

View file

@ -533,16 +533,7 @@ public class RollbackUtil extends Lookup {
* Additional data for the entity
*/
public static void queueEntitySpawn(String user, BlockState block, EntityType type, int data) {
if (Queue.class.getDeclaredMethods() != null) {
try {
java.lang.reflect.Method method = Queue.class.getDeclaredMethod("queueEntitySpawn", String.class, BlockState.class, EntityType.class, int.class);
method.setAccessible(true);
method.invoke(null, user, block, type, data);
}
catch (Exception e) {
e.printStackTrace();
}
}
Queue.queueEntitySpawn(user, block, type, data);
}
/**
@ -556,16 +547,7 @@ public class RollbackUtil extends Lookup {
* The row ID for the skull data
*/
public static void queueSkullUpdate(String user, BlockState block, int rowId) {
if (Queue.class.getDeclaredMethods() != null) {
try {
java.lang.reflect.Method method = Queue.class.getDeclaredMethod("queueSkullUpdate", String.class, BlockState.class, int.class);
method.setAccessible(true);
method.invoke(null, user, block, rowId);
}
catch (Exception e) {
e.printStackTrace();
}
}
Queue.queueSkullUpdate(user, block, rowId);
}
/**
@ -581,15 +563,6 @@ public class RollbackUtil extends Lookup {
* The time of the update
*/
public static void queueSignUpdate(String user, BlockState block, int action, int time) {
if (Queue.class.getDeclaredMethods() != null) {
try {
java.lang.reflect.Method method = Queue.class.getDeclaredMethod("queueSignUpdate", String.class, BlockState.class, int.class, int.class);
method.setAccessible(true);
method.invoke(null, user, block, action, time);
}
catch (Exception e) {
e.printStackTrace();
}
}
Queue.queueSignUpdate(user, block, action, time);
}
}

View file

@ -131,4 +131,4 @@ public class EntityUtils extends Queue {
return result;
}
}
}