Skip to content

Commit

Permalink
Preliminary update to 1.17 - known bugs include every entity glowing
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jun 12, 2021
1 parent 2d5e418 commit f2d4c38
Show file tree
Hide file tree
Showing 153 changed files with 25,575 additions and 23 deletions.
9 changes: 8 additions & 1 deletion dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-parent</artifactId>
<version>2.0.27-SNAPSHOT</version>
<version>2.0.28-SNAPSHOT</version>
</parent>
<artifactId>citizens</artifactId>
<packaging>pom</packaging>
Expand Down Expand Up @@ -87,5 +87,12 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>citizens-v1_17_R1</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
4 changes: 2 additions & 2 deletions main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<parent>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-parent</artifactId>
<version>2.0.27-SNAPSHOT</version>
<version>2.0.28-SNAPSHOT</version>
</parent>
<artifactId>citizens-main</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<craftbukkit.version>1.16.5-R0.1-SNAPSHOT</craftbukkit.version>
<craftbukkit.version>1.17-R0.1-SNAPSHOT</craftbukkit.version>
<citizensapi.version>${project.version}</citizensapi.version>
<powermock.version>1.4.12</powermock.version>
<worldguard.version>7.0.4</worldguard.version>
Expand Down
39 changes: 37 additions & 2 deletions main/src/main/java/net/citizensnpcs/util/NMS.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,37 @@ public static MethodHandle getFinalSetter(Class<?> clazz, String field, boolean
return null;
}

public static MethodHandle getFirstMethodHandle(Class<?> clazz, boolean log, Class<?>... params) {
if (clazz == null)
return null;
try {
Method first = null;
for (Method method : clazz.getDeclaredMethods()) {
Class<?>[] paramTypes = method.getParameterTypes();
if (paramTypes.length == params.length) {
first = method;
for (int i = 0; i < paramTypes.length; i++) {
if (paramTypes[i] != params[i]) {
first = null;
}
}
if (first != null) {
break;
}
}
}
if (first == null)
return null;
first.setAccessible(true);
return LOOKUP.unreflect(first);
} catch (Exception e) {
if (log) {
Messaging.logTr(Messages.ERROR_GETTING_METHOD, e.getLocalizedMessage());
}
}
return null;
}

public static GameProfileRepository getGameProfileRepository() {
return BRIDGE.getGameProfileRepository();
}
Expand Down Expand Up @@ -320,7 +351,12 @@ public static void load(CommandManager commands) {
}

public static void loadBridge(String rev) throws Exception {
Class<?> entity = Class.forName("net.minecraft.server.v" + rev + ".Entity");
Class<?> entity = null;
try {
entity = Class.forName("net.minecraft.server.v" + rev + ".Entity");
} catch (ClassNotFoundException ex) {
entity = Class.forName("net.minecraft.world.entity.Entity");
}
giveReflectiveAccess(entity, NMS.class);
BRIDGE = (NMSBridge) Class.forName("net.citizensnpcs.nms.v" + rev + ".util.NMSImpl").getConstructor()
.newInstance();
Expand Down Expand Up @@ -518,7 +554,6 @@ public static void updatePathfindingRange(NPC npc, float pathfindingRange) {
private static Object UNSAFE;
private static MethodHandle UNSAFE_FIELD_OFFSET;
private static MethodHandle UNSAFE_PUT_OBJECT;

private static MethodHandle UNSAFE_STATIC_FIELD_OFFSET;

static {
Expand Down
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<packaging>pom</packaging>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-parent</artifactId>
<version>2.0.27-SNAPSHOT</version>
<version>2.0.28-SNAPSHOT</version>
<properties>
<BUILD_NUMBER>Unknown</BUILD_NUMBER>
<CITIZENS_VERSION>2.0.27</CITIZENS_VERSION>
<CITIZENS_VERSION>2.0.28</CITIZENS_VERSION>
</properties>
<build>
<defaultGoal>clean package install</defaultGoal>
Expand All @@ -25,6 +25,7 @@
<module>v1_14_R1</module>
<module>v1_15_R1</module>
<module>v1_16_R3</module>
<module>v1_17_R1</module>
<module>dist</module>
</modules>
</project>
2 changes: 1 addition & 1 deletion v1_10_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-parent</artifactId>
<version>2.0.27-SNAPSHOT</version>
<version>2.0.28-SNAPSHOT</version>
</parent>
<artifactId>citizens-v1_10_R1</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion v1_11_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-parent</artifactId>
<version>2.0.27-SNAPSHOT</version>
<version>2.0.28-SNAPSHOT</version>
</parent>
<artifactId>citizens-v1_11_R1</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion v1_12_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-parent</artifactId>
<version>2.0.27-SNAPSHOT</version>
<version>2.0.28-SNAPSHOT</version>
</parent>
<artifactId>citizens-v1_12_R1</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion v1_13_R2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-parent</artifactId>
<version>2.0.27-SNAPSHOT</version>
<version>2.0.28-SNAPSHOT</version>
</parent>
<artifactId>citizens-v1_13_R2</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion v1_14_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-parent</artifactId>
<version>2.0.27-SNAPSHOT</version>
<version>2.0.28-SNAPSHOT</version>
</parent>
<artifactId>citizens-v1_14_R1</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion v1_15_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-parent</artifactId>
<version>2.0.27-SNAPSHOT</version>
<version>2.0.28-SNAPSHOT</version>
</parent>
<artifactId>citizens-v1_15_R1</artifactId>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public boolean d(NBTTagCompound save) {

@Override
public boolean doAITick() {
return false;
return npc == null ? super.doAITick() : false;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion v1_16_R3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-parent</artifactId>
<version>2.0.27-SNAPSHOT</version>
<version>2.0.28-SNAPSHOT</version>
</parent>
<artifactId>citizens-v1_16_R3</artifactId>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public boolean d(NBTTagCompound save) {

@Override
public boolean doAITick() {
return false;
return npc == null ? super.doAITick() : false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ public void mobTick() {
super.mobTick();
}
try {
if (bF != null) {
bF.invoke(this, 10); // DespawnDelay
if (bw != null) {
bw.invoke(this, 10); // DespawnDelay
}
} catch (Throwable e) {
}
Expand All @@ -223,7 +223,7 @@ protected boolean n(Entity entity) {
return super.n(entity);
}

private static final MethodHandle bF = NMS.getSetter(EntityLlamaTrader.class, "bF");
private static final MethodHandle bw = NMS.getSetter(EntityLlamaTrader.class, "bw");
}

public static class TraderLlamaNPC extends CraftTraderLlama implements ForwardingNPCHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void tick() {
((EntityHuman) getShooter()).inventory.items.set(((EntityHuman) getShooter()).inventory.itemInHandIndex,
new ItemStack(Items.FISHING_ROD, 1));
try {
D.invoke(this, 0);
G.invoke(this, 0);
} catch (Throwable e) {
e.printStackTrace();
}
Expand All @@ -120,7 +120,7 @@ public void tick() {
}
}

private static MethodHandle D = NMS.getSetter(EntityFishingHook.class, "d");
private static MethodHandle G = NMS.getSetter(EntityFishingHook.class, "g");
}

public static class FishingHookNPC extends CraftFishHook implements ForwardingNPCHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private net.minecraft.server.v1_16_R3.ItemStack getCurrentItem() {
}

private float getStrength(IBlockData block) {
float base = block.getBlock().a(block, null, new BlockPosition(0, 0, 0));
float base = block.h(null, new BlockPosition(0, 0, 0));
return base < 0.0F ? 0.0F : (!isDestroyable(block) ? 1.0F / base / 100.0F : strengthMod(block) / base / 30.0F);
}

Expand Down
119 changes: 119 additions & 0 deletions v1_17_R1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<!-- Citizens build file -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-parent</artifactId>
<version>2.0.28-SNAPSHOT</version>
</parent>
<artifactId>citizens-v1_17_R1</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<craftbukkit.version>1.17-R0.1-SNAPSHOT</craftbukkit.version>
</properties>

<repositories>
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>citizens-main</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${craftbukkit.version}</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<defaultGoal>clean package install</defaultGoal>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<compilerId>eclipse</compilerId>
<source>1.8</source>
<target>1.8</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.8.6</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.17-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.17-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.17-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.17-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit f2d4c38

Please sign in to comment.