mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-04 13:54:35 +01:00
Fix apparently a long standing issue where getNewEntityId wasn't working in 1.14+ as per #786
This commit is contained in:
parent
6278d3a993
commit
ebf66ce1b0
@ -92,7 +92,8 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
if (increment) {
|
if (increment) {
|
||||||
return atomicInteger.incrementAndGet();
|
return atomicInteger.incrementAndGet();
|
||||||
} else {
|
} else {
|
||||||
return atomicInteger.get();
|
// Add 1 as we didn't increment the counter and thus this is currently pointing to the last entity id used
|
||||||
|
return atomicInteger.get() + 1;
|
||||||
}
|
}
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -92,7 +92,8 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
if (increment) {
|
if (increment) {
|
||||||
return atomicInteger.incrementAndGet();
|
return atomicInteger.incrementAndGet();
|
||||||
} else {
|
} else {
|
||||||
return atomicInteger.get();
|
// Add 1 as we didn't increment the counter and thus this is currently pointing to the last entity id used
|
||||||
|
return atomicInteger.get() + 1;
|
||||||
}
|
}
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -94,7 +94,8 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
if (increment) {
|
if (increment) {
|
||||||
return atomicInteger.incrementAndGet();
|
return atomicInteger.incrementAndGet();
|
||||||
} else {
|
} else {
|
||||||
return atomicInteger.get();
|
// Add 1 as we didn't increment the counter and thus this is currently pointing to the last entity id used
|
||||||
|
return atomicInteger.get() + 1;
|
||||||
}
|
}
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -93,7 +93,8 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
if (increment) {
|
if (increment) {
|
||||||
return atomicInteger.incrementAndGet();
|
return atomicInteger.incrementAndGet();
|
||||||
} else {
|
} else {
|
||||||
return atomicInteger.get();
|
// Add 1 as we didn't increment the counter and thus this is currently pointing to the last entity id used
|
||||||
|
return atomicInteger.get() + 1;
|
||||||
}
|
}
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -108,7 +108,8 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
if (increment) {
|
if (increment) {
|
||||||
return atomicInteger.incrementAndGet();
|
return atomicInteger.incrementAndGet();
|
||||||
} else {
|
} else {
|
||||||
return atomicInteger.get();
|
// Add 1 as we didn't increment the counter and thus this is currently pointing to the last entity id used
|
||||||
|
return atomicInteger.get() + 1;
|
||||||
}
|
}
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -107,7 +107,8 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
if (increment) {
|
if (increment) {
|
||||||
return atomicInteger.incrementAndGet();
|
return atomicInteger.incrementAndGet();
|
||||||
} else {
|
} else {
|
||||||
return atomicInteger.get();
|
// Add 1 as we didn't increment the counter and thus this is currently pointing to the last entity id used
|
||||||
|
return atomicInteger.get() + 1;
|
||||||
}
|
}
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -107,7 +107,8 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
if (increment) {
|
if (increment) {
|
||||||
return atomicInteger.incrementAndGet();
|
return atomicInteger.incrementAndGet();
|
||||||
} else {
|
} else {
|
||||||
return atomicInteger.get();
|
// Add 1 as we didn't increment the counter and thus this is currently pointing to the last entity id used
|
||||||
|
return atomicInteger.get() + 1;
|
||||||
}
|
}
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -130,7 +130,8 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
if (increment) {
|
if (increment) {
|
||||||
return entityCounter.incrementAndGet();
|
return entityCounter.incrementAndGet();
|
||||||
} else {
|
} else {
|
||||||
return entityCounter.get();
|
// Add 1 as we didn't increment the counter and thus this is currently pointing to the last entity id used
|
||||||
|
return entityCounter.get() + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,8 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
if (increment) {
|
if (increment) {
|
||||||
return entityCounter.incrementAndGet();
|
return entityCounter.incrementAndGet();
|
||||||
} else {
|
} else {
|
||||||
return entityCounter.get();
|
// Add 1 as we didn't increment the counter and thus this is currently pointing to the last entity id used
|
||||||
|
return entityCounter.get() + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,8 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
if (increment) {
|
if (increment) {
|
||||||
return entityCounter.incrementAndGet();
|
return entityCounter.incrementAndGet();
|
||||||
} else {
|
} else {
|
||||||
return entityCounter.get();
|
// Add 1 as we didn't increment the counter and thus this is currently pointing to the last entity id used
|
||||||
|
return entityCounter.get() + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,8 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
if (increment) {
|
if (increment) {
|
||||||
return entityCounter.incrementAndGet();
|
return entityCounter.incrementAndGet();
|
||||||
} else {
|
} else {
|
||||||
return entityCounter.get();
|
// Add 1 as we didn't increment the counter and thus this is currently pointing to the last entity id used
|
||||||
|
return entityCounter.get() + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,8 @@ public class ReflectionManager implements ReflectionManagerAbstract {
|
|||||||
if (increment) {
|
if (increment) {
|
||||||
return entityCounter.incrementAndGet();
|
return entityCounter.incrementAndGet();
|
||||||
} else {
|
} else {
|
||||||
return entityCounter.get();
|
// Add 1 as we didn't increment the counter and thus this is currently pointing to the last entity id used
|
||||||
|
return entityCounter.get() + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,6 +269,7 @@ public class DisguiseAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int id = ReflectionManager.getNewEntityId(false);
|
int id = ReflectionManager.getNewEntityId(false);
|
||||||
|
|
||||||
DisguiseUtilities.addFutureDisguise(id, (TargetedDisguise) disguise);
|
DisguiseUtilities.addFutureDisguise(id, (TargetedDisguise) disguise);
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
|
@ -604,6 +604,10 @@ public class ReflectionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getNewEntityId(boolean increment) {
|
public static int getNewEntityId(boolean increment) {
|
||||||
|
// From earlier versions up to 1.13, entityId = entityCounter++
|
||||||
|
// From 1.14 and onwards, entityId = entityCounter.incrementAndGet()
|
||||||
|
// Obviously, they are very different.
|
||||||
|
|
||||||
if (nmsReflection != null) {
|
if (nmsReflection != null) {
|
||||||
return nmsReflection.getNewEntityId(increment);
|
return nmsReflection.getNewEntityId(increment);
|
||||||
}
|
}
|
||||||
@ -623,6 +627,10 @@ public class ReflectionManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NmsVersion.v1_14.isSupported()) {
|
||||||
|
return entityCount.intValue() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
return entityCount.intValue();
|
return entityCount.intValue();
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Loading…
Reference in New Issue
Block a user