Fix 1.18.1 for Paper

This commit is contained in:
SeanOMik 2021-12-12 12:14:22 -05:00
parent f7cdaa820d
commit ee8df0c2b3
13 changed files with 43 additions and 25 deletions

View File

@ -7,7 +7,7 @@
<parent> <parent>
<artifactId>tamablefoxes-parent</artifactId> <artifactId>tamablefoxes-parent</artifactId>
<groupId>net.seanomik</groupId> <groupId>net.seanomik</groupId>
<version>2.2.1-SNAPSHOT</version> <version>2.2.2-SNAPSHOT</version>
</parent> </parent>
<artifactId>tamablefoxes_v1_14_R1</artifactId> <artifactId>tamablefoxes_v1_14_R1</artifactId>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<artifactId>tamablefoxes-parent</artifactId> <artifactId>tamablefoxes-parent</artifactId>
<groupId>net.seanomik</groupId> <groupId>net.seanomik</groupId>
<version>2.2.1-SNAPSHOT</version> <version>2.2.2-SNAPSHOT</version>
</parent> </parent>
<artifactId>tamablefoxes_v1_15_R1</artifactId> <artifactId>tamablefoxes_v1_15_R1</artifactId>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<artifactId>tamablefoxes-parent</artifactId> <artifactId>tamablefoxes-parent</artifactId>
<groupId>net.seanomik</groupId> <groupId>net.seanomik</groupId>
<version>2.2.1-SNAPSHOT</version> <version>2.2.2-SNAPSHOT</version>
</parent> </parent>
<artifactId>tamablefoxes_v1_16_R1</artifactId> <artifactId>tamablefoxes_v1_16_R1</artifactId>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<artifactId>tamablefoxes-parent</artifactId> <artifactId>tamablefoxes-parent</artifactId>
<groupId>net.seanomik</groupId> <groupId>net.seanomik</groupId>
<version>2.2.1-SNAPSHOT</version> <version>2.2.2-SNAPSHOT</version>
</parent> </parent>
<artifactId>tamablefoxes_v1_16_R2</artifactId> <artifactId>tamablefoxes_v1_16_R2</artifactId>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.seanomik</groupId> <groupId>net.seanomik</groupId>
<artifactId>tamablefoxes-parent</artifactId> <artifactId>tamablefoxes-parent</artifactId>
<version>2.2.1-SNAPSHOT</version> <version>2.2.2-SNAPSHOT</version>
</parent> </parent>
<artifactId>tamablefoxes_v1_16_R3</artifactId> <artifactId>tamablefoxes_v1_16_R3</artifactId>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.seanomik</groupId> <groupId>net.seanomik</groupId>
<artifactId>tamablefoxes-parent</artifactId> <artifactId>tamablefoxes-parent</artifactId>
<version>2.2.1-SNAPSHOT</version> <version>2.2.2-SNAPSHOT</version>
</parent> </parent>
<build> <build>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.seanomik</groupId> <groupId>net.seanomik</groupId>
<artifactId>tamablefoxes-parent</artifactId> <artifactId>tamablefoxes-parent</artifactId>
<version>2.2.1-SNAPSHOT</version> <version>2.2.2-SNAPSHOT</version>
</parent> </parent>
<build> <build>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.seanomik</groupId> <groupId>net.seanomik</groupId>
<artifactId>tamablefoxes-parent</artifactId> <artifactId>tamablefoxes-parent</artifactId>
<version>2.2.1-SNAPSHOT</version> <version>2.2.2-SNAPSHOT</version>
</parent> </parent>
<build> <build>

View File

@ -170,31 +170,49 @@ public class EntityTamableFox extends Fox {
} }
} }
public boolean isDefending() { protected EntityDataAccessor<Byte> getDataFlagsId() throws NoSuchFieldException, IllegalAccessException {
Field dataFlagsField = Fox.class.getDeclaredField("cb"); // DATA_FLAGS_ID
dataFlagsField.setAccessible(true);
EntityDataAccessor<Byte> dataFlagsId = (EntityDataAccessor<Byte>) dataFlagsField.get(null);
dataFlagsField.setAccessible(false);
return dataFlagsId;
}
protected boolean getFlag(int i) {
try { try {
Method method = Fox.class.getDeclaredMethod("fL"); // isDefending EntityDataAccessor<Byte> dataFlagsId = getDataFlagsId();
method.setAccessible(true);
boolean defending = (boolean) method.invoke((Fox) this); return ((Byte)super.entityData.get(dataFlagsId) & i) != 0;
method.setAccessible(false); } catch (IllegalAccessException | NoSuchFieldException e) {
return defending;
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
} }
return false; return false;
} }
public void setDefending(boolean defending) { protected void setFlag(int i, boolean flag) {
try { try {
Method method = Fox.class.getDeclaredMethod("A", boolean.class); // setDefending EntityDataAccessor<Byte> dataFlagsId = getDataFlagsId();
method.setAccessible(true);
method.invoke((Fox) this, defending); if (flag) {
method.setAccessible(false); this.entityData.set(dataFlagsId, (byte)((Byte)this.entityData.get(dataFlagsId) | i));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { } else {
this.entityData.set(dataFlagsId, (byte)((Byte)this.entityData.get(dataFlagsId) & ~i));
}
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public boolean isDefending() {
return getFlag(128);
}
public void setDefending(boolean defending) {
setFlag(128, defending);
}
@Override @Override
protected void defineSynchedData() { protected void defineSynchedData() {
super.defineSynchedData(); super.defineSynchedData();

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.seanomik</groupId> <groupId>net.seanomik</groupId>
<artifactId>tamablefoxes-parent</artifactId> <artifactId>tamablefoxes-parent</artifactId>
<version>2.2.1-SNAPSHOT</version> <version>2.2.2-SNAPSHOT</version>
</parent> </parent>
<build> <build>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.seanomik</groupId> <groupId>net.seanomik</groupId>
<artifactId>tamablefoxes-parent</artifactId> <artifactId>tamablefoxes-parent</artifactId>
<version>2.2.1-SNAPSHOT</version> <version>2.2.2-SNAPSHOT</version>
</parent> </parent>
<artifactId>tamablefoxes</artifactId> <artifactId>tamablefoxes</artifactId>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.seanomik</groupId> <groupId>net.seanomik</groupId>
<artifactId>tamablefoxes-parent</artifactId> <artifactId>tamablefoxes-parent</artifactId>
<version>2.2.1-SNAPSHOT</version> <version>2.2.2-SNAPSHOT</version>
</parent> </parent>
<artifactId>tamablefoxes-util</artifactId> <artifactId>tamablefoxes-util</artifactId>

View File

@ -6,7 +6,7 @@
<groupId>net.seanomik</groupId> <groupId>net.seanomik</groupId>
<artifactId>tamablefoxes-parent</artifactId> <artifactId>tamablefoxes-parent</artifactId>
<version>2.2.1-SNAPSHOT</version> <version>2.2.2-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>