Incorporate environment into the main plugin
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<artifactId>mc-mesh-master</artifactId>
|
||||
<artifactId>mc-mesh-plugin</artifactId>
|
||||
<groupId>com.aaaaahhhhhhh.bananapuncher714</groupId>
|
||||
<version>1.0.0</version>
|
||||
<version>0.0.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>mc-mesh-plugin</artifactId>
|
||||
<artifactId>mc-mesh-plugin-environment</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<build>
|
||||
<plugins>
|
||||
@@ -29,25 +29,13 @@
|
||||
<release>21</release>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<mainClass>com.aaaaahhhhhhh.bananapuncher714.minietest.MeshingTest6</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.21.10-R0.1-SNAPSHOT</version>
|
||||
<version>1.21.11-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@@ -67,25 +55,17 @@
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>lz4-java</artifactId>
|
||||
<groupId>at.yawk.lz4</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>azure-json</artifactId>
|
||||
<groupId>com.azure</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jcip-annotations</artifactId>
|
||||
<groupId>com.github.stephenc.jcip</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>msal4j</artifactId>
|
||||
<groupId>com.microsoft.azure</groupId>
|
||||
@@ -110,22 +90,6 @@
|
||||
<artifactId>logging</artifactId>
|
||||
<groupId>com.mojang</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>content-type</artifactId>
|
||||
<groupId>com.nimbusds</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>lang-tag</artifactId>
|
||||
<groupId>com.nimbusds</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>nimbus-jose-jwt</artifactId>
|
||||
<groupId>com.nimbusds</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>oauth2-oidc-sdk</artifactId>
|
||||
<groupId>com.nimbusds</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<groupId>commons-io</groupId>
|
||||
@@ -135,7 +99,11 @@
|
||||
<groupId>io.netty</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>netty-codec</artifactId>
|
||||
<artifactId>netty-codec-base</artifactId>
|
||||
<groupId>io.netty</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>netty-codec-compression</artifactId>
|
||||
<groupId>io.netty</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
@@ -162,6 +130,10 @@
|
||||
<artifactId>netty-transport-classes-epoll</artifactId>
|
||||
<groupId>io.netty</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>netty-transport-classes-kqueue</artifactId>
|
||||
<groupId>io.netty</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>netty-transport-native-epoll</artifactId>
|
||||
<groupId>io.netty</groupId>
|
||||
@@ -170,6 +142,14 @@
|
||||
<artifactId>netty-transport-native-epoll</artifactId>
|
||||
<groupId>io.netty</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>netty-transport-native-kqueue</artifactId>
|
||||
<groupId>io.netty</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>netty-transport-native-kqueue</artifactId>
|
||||
<groupId>io.netty</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>netty-transport-native-unix-common</artifactId>
|
||||
<groupId>io.netty</groupId>
|
||||
@@ -186,14 +166,6 @@
|
||||
<artifactId>jna-platform</artifactId>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>accessors-smart</artifactId>
|
||||
<groupId>net.minidev</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>json-smart</artifactId>
|
||||
<groupId>net.minidev</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jopt-simple</artifactId>
|
||||
<groupId>net.sf.jopt-simple</groupId>
|
||||
@@ -215,8 +187,8 @@
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>lz4-java</artifactId>
|
||||
<groupId>org.lz4</groupId>
|
||||
<artifactId>jspecify</artifactId>
|
||||
<groupId>org.jspecify</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.21.10-R0.1-SNAPSHOT</version>
|
||||
<version>1.21.11-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.aaaaahhhhhhh.bananapuncher714.mesh.environment;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
|
||||
import com.aaaaahhhhhhh.bananapuncher714.mesh.environment.objects.ChunkLocation;
|
||||
import com.aaaaahhhhhhh.bananapuncher714.mesh.environment.objects.ChunkMesh;
|
||||
import com.aaaaahhhhhhh.bananapuncher714.mesh.environment.util.ChunkMeshUtil;
|
||||
|
||||
public class ChunkMeshCache {
|
||||
File directory;
|
||||
|
||||
public ChunkMeshCache( File directory ) {
|
||||
this.directory = directory;
|
||||
}
|
||||
|
||||
public ChunkMesh load( ChunkLocation location ) {
|
||||
final File file = new File( directory, location.getWorldName() + "/" + location.getX() + "/" + location.getZ() + ".cmesh" );
|
||||
if ( file.exists() ) {
|
||||
try {
|
||||
final byte[] data = Files.readAllBytes( file.toPath() );
|
||||
final ChunkMesh mesh = ChunkMeshUtil.deserialize( data );
|
||||
|
||||
return mesh;
|
||||
} catch ( IOException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void save( ChunkLocation location, ChunkMesh mesh ) {
|
||||
final File file = new File( directory, location.getWorldName() + "/" + location.getX() + "/" + location.getZ() + ".cmesh" );
|
||||
file.getParentFile().mkdirs();
|
||||
|
||||
final byte[] data = ChunkMeshUtil.serialize( mesh );
|
||||
|
||||
try {
|
||||
Files.write( file.toPath(), data, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE, StandardOpenOption.WRITE );
|
||||
} catch ( IOException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,8 @@ package com.aaaaahhhhhhh.bananapuncher714.mesh.environment.util;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_21_R6.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_21_R6.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_21_R7.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_21_R7.block.data.CraftBlockData;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
name: MC-Mesh-Environment
|
||||
name: Mc-Mesh-Environment
|
||||
main: com.aaaaahhhhhhh.bananapuncher714.mesh.environment.McMeshEnvironmentPlugin
|
||||
version: 0.0.1
|
||||
description: BulletJME and MC-Mesh integration
|
||||
author: BananaPuncher714
|
||||
api-version: 1.13
|
||||
load: STARTUP
|
||||
@@ -14,7 +14,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.21.10-R0.1-SNAPSHOT</version>
|
||||
<version>1.21.11-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -27,19 +27,6 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.aaaaahhhhhhh.bananapuncher714.mesh.physics;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@@ -30,7 +29,7 @@ import com.aaaaahhhhhhh.bananapuncher714.mesh.command.validator.InputValidatorDo
|
||||
import com.aaaaahhhhhhh.bananapuncher714.mesh.command.validator.InputValidatorInt;
|
||||
import com.aaaaahhhhhhh.bananapuncher714.mesh.command.validator.sender.SenderValidatorPlayer;
|
||||
import com.aaaaahhhhhhh.bananapuncher714.mesh.environment.EnvironmentHandler;
|
||||
import com.aaaaahhhhhhh.bananapuncher714.mesh.environment.MeshEnvironment;
|
||||
import com.aaaaahhhhhhh.bananapuncher714.mesh.environment.McMeshEnvironmentPlugin;
|
||||
import com.aaaaahhhhhhh.bananapuncher714.mesh.environment.objects.ChunkLocation;
|
||||
import com.aaaaahhhhhhh.bananapuncher714.mesh.environment.objects.ChunkMesh;
|
||||
import com.aaaaahhhhhhh.bananapuncher714.mesh.environment.util.NmsUtil;
|
||||
@@ -52,15 +51,12 @@ import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
|
||||
public class McMeshPhysicsPlugin extends JavaPlugin {
|
||||
private static final int TIME_STEPS = 5;
|
||||
private static final int TIME_STEPS = 10;
|
||||
private static final float SIMULATION_SPEED = 1f;
|
||||
|
||||
private MeshEnvironment environment;
|
||||
|
||||
private PhysicsSpace space;
|
||||
private boolean paused = false;
|
||||
private boolean teleportOnDeactivate = false;
|
||||
private float tick = 0;
|
||||
private Map< PhysicsCollisionObject, AuxiliaryDisplayStruct > linkedDisplays = new HashMap< PhysicsCollisionObject, AuxiliaryDisplayStruct >();
|
||||
private Set< PhysicsCollisionObject > active = new HashSet< PhysicsCollisionObject >();
|
||||
private Map< ChunkLocation, PhysicsRigidBody > chunks = new HashMap< ChunkLocation, PhysicsRigidBody >();
|
||||
@@ -72,10 +68,13 @@ public class McMeshPhysicsPlugin extends JavaPlugin {
|
||||
space = new PhysicsSpace( BroadphaseType.DBVT );
|
||||
space.setAccuracy( 1f / ( TIME_STEPS * 20f ) );
|
||||
|
||||
environment = new MeshEnvironment( this, new File( getDataFolder(), "environment" ) );
|
||||
environment.setHandler( new EnvironmentHandler() {
|
||||
JavaPlugin.getPlugin( McMeshEnvironmentPlugin.class ).registerHandler( new EnvironmentHandler() {
|
||||
@Override
|
||||
public void onMeshLoad( ChunkLocation location, ChunkMesh mesh ) {
|
||||
if ( !location.getWorld().getName().equalsIgnoreCase( "world" ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Now, create a physics object from the chunk mesh
|
||||
final IndexedMesh nativeMesh = mesh.toIndexedMesh();
|
||||
// Enable quantized AABB compression... hopefully that doesn't mess with the accuracy or anything...
|
||||
@@ -99,12 +98,20 @@ public class McMeshPhysicsPlugin extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onMeshUnload( ChunkLocation location, ChunkMesh mesh ) {
|
||||
space.removeCollisionObject( chunks.get( location ) );
|
||||
if ( !location.getWorld().getName().equalsIgnoreCase( "world" ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
space.removeCollisionObject( chunks.remove( location ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeshUpdate( ChunkLocation location, ChunkMesh mesh ) {
|
||||
// Now, create a physics object from the chunk mesh
|
||||
if ( !location.getWorld().getName().equalsIgnoreCase( "world" ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Now, create a physics object from the chunk mesh
|
||||
final IndexedMesh nativeMesh = mesh.toIndexedMesh();
|
||||
// Enable quantized AABB compression... hopefully that doesn't mess with the accuracy or anything...
|
||||
final MeshCollisionShape meshCollision = new MeshCollisionShape( true, nativeMesh );
|
||||
@@ -132,7 +139,7 @@ public class McMeshPhysicsPlugin extends JavaPlugin {
|
||||
if ( !paused ) {
|
||||
// Update the real world with the physics space objects
|
||||
space.distributeEvents();
|
||||
space.update( tick, TIME_STEPS );
|
||||
space.update( SIMULATION_SPEED / 20f, TIME_STEPS );
|
||||
|
||||
for ( Iterator< Entry< PhysicsCollisionObject, AuxiliaryDisplayStruct > > it = linkedDisplays.entrySet().iterator(); it.hasNext(); ) {
|
||||
Entry< PhysicsCollisionObject, AuxiliaryDisplayStruct > entry = it.next();
|
||||
@@ -187,8 +194,6 @@ public class McMeshPhysicsPlugin extends JavaPlugin {
|
||||
disp.display.setInterpolationDuration( 2 );
|
||||
disp.display.setTransformationMatrix( transMat.mul( transformRot ) );
|
||||
}
|
||||
|
||||
tick += SIMULATION_SPEED / 20f;
|
||||
}
|
||||
}, 0, 1 );
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.v1_21_R6.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_21_R6.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_21_R7.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_21_R7.block.data.CraftBlockData;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -5,6 +5,7 @@ description: BulletJME and MC-Mesh integration
|
||||
author: BananaPuncher714
|
||||
api-version: 1.13
|
||||
depend: [ "Mc-Mesh-Environment" ]
|
||||
load: STARTUP
|
||||
#libraries:
|
||||
#- com.github.stephengold:Minie:7.5.0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user