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>
<artifactId>tamablefoxes-parent</artifactId>
<groupId>net.seanomik</groupId>
<version>2.2.1-SNAPSHOT</version>
<version>2.2.2-SNAPSHOT</version>
</parent>
<artifactId>tamablefoxes_v1_14_R1</artifactId>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@
<parent>
<groupId>net.seanomik</groupId>
<artifactId>tamablefoxes-parent</artifactId>
<version>2.2.1-SNAPSHOT</version>
<version>2.2.2-SNAPSHOT</version>
</parent>
<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 {
Method method = Fox.class.getDeclaredMethod("fL"); // isDefending
method.setAccessible(true);
boolean defending = (boolean) method.invoke((Fox) this);
method.setAccessible(false);
return defending;
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
EntityDataAccessor<Byte> dataFlagsId = getDataFlagsId();
return ((Byte)super.entityData.get(dataFlagsId) & i) != 0;
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
return false;
}
public void setDefending(boolean defending) {
protected void setFlag(int i, boolean flag) {
try {
Method method = Fox.class.getDeclaredMethod("A", boolean.class); // setDefending
method.setAccessible(true);
method.invoke((Fox) this, defending);
method.setAccessible(false);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
EntityDataAccessor<Byte> dataFlagsId = getDataFlagsId();
if (flag) {
this.entityData.set(dataFlagsId, (byte)((Byte)this.entityData.get(dataFlagsId) | i));
} else {
this.entityData.set(dataFlagsId, (byte)((Byte)this.entityData.get(dataFlagsId) & ~i));
}
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
}
public boolean isDefending() {
return getFlag(128);
}
public void setDefending(boolean defending) {
setFlag(128, defending);
}
@Override
protected void defineSynchedData() {
super.defineSynchedData();

View File

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

View File

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

View File

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

View File

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