initial commit
I accidentally did git rm -fr . and it removed all the code with no backups
This commit is contained in:
commit
c803feef96
12 changed files with 341 additions and 0 deletions
40
.classpath
Normal file
40
.classpath
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
/target/
|
||||
/bin/
|
||||
/.settings/
|
23
.project
Normal file
23
.project
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>soccer</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
24
pom.xml
Normal file
24
pom.xml
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?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/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>net.pivipi</groupId>
|
||||
<artifactId>soccer</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.minestom</groupId>
|
||||
<artifactId>minestom-snapshots</artifactId>
|
||||
<version>90fb708739</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,19 @@
|
|||
package net.minestom.server.collision;
|
||||
|
||||
public class VisibleSweepResult {
|
||||
public final double res;
|
||||
public final double normalX, normalY, normalZ;
|
||||
public final double collidedPositionX, collidedPositionY, collidedPositionZ;
|
||||
public final Shape collidedShape;
|
||||
|
||||
public VisibleSweepResult(SweepResult sweepResult) {
|
||||
this.res = sweepResult.res;
|
||||
this.normalX = sweepResult.normalX;
|
||||
this.normalY = sweepResult.normalY;
|
||||
this.normalZ = sweepResult.normalZ;
|
||||
this.collidedPositionX = sweepResult.collidedPositionX;
|
||||
this.collidedPositionY = sweepResult.collidedPositionY;
|
||||
this.collidedPositionZ = sweepResult.collidedPositionZ;
|
||||
this.collidedShape = sweepResult.collidedShape;
|
||||
}
|
||||
}
|
49
src/main/java/net/pivipi/LoginHandler.java
Normal file
49
src/main/java/net/pivipi/LoginHandler.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
package net.pivipi;
|
||||
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.GameMode;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.GlobalEventHandler;
|
||||
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
|
||||
import net.minestom.server.event.player.PlayerSpawnEvent;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.pivipi.ball.Ball;
|
||||
|
||||
public class LoginHandler {
|
||||
private final Instance spawningInstance;
|
||||
|
||||
public LoginHandler(Instance spawningInstance) {
|
||||
this.spawningInstance = spawningInstance;
|
||||
}
|
||||
|
||||
public void setup(GlobalEventHandler globalEventHandler) {
|
||||
globalEventHandler.addListener(
|
||||
AsyncPlayerConfigurationEvent.class,
|
||||
event -> onLogin(event)
|
||||
);
|
||||
|
||||
globalEventHandler.addListener(
|
||||
PlayerSpawnEvent.class,
|
||||
event -> onSpawn(event)
|
||||
);
|
||||
}
|
||||
|
||||
private void onLogin(AsyncPlayerConfigurationEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
event.setSpawningInstance(spawningInstance);
|
||||
event.setHardcore(true);
|
||||
|
||||
player.setRespawnPoint(new Pos(0, 5, 0));
|
||||
}
|
||||
|
||||
private void onSpawn(PlayerSpawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
|
||||
Ball ball = new Ball();
|
||||
ball.setInstance(event.getInstance());
|
||||
ball.teleport(new Pos(0.5, 10, 0.5));
|
||||
}
|
||||
}
|
42
src/main/java/net/pivipi/Main.java
Normal file
42
src/main/java/net/pivipi/Main.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package net.pivipi;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.event.GlobalEventHandler;
|
||||
import net.minestom.server.instance.InstanceContainer;
|
||||
import net.minestom.server.instance.InstanceManager;
|
||||
import net.minestom.server.instance.LightingChunk;
|
||||
import net.pivipi.world.SoccerGenerator;
|
||||
import net.pivipi.world.WorldConstraints;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("minestom.tps", "60");
|
||||
|
||||
MinecraftServer minecraftServer = MinecraftServer.init();
|
||||
|
||||
InstanceManager instanceManager = MinecraftServer.getInstanceManager();
|
||||
GlobalEventHandler globalEventHandler = MinecraftServer.getGlobalEventHandler();
|
||||
|
||||
InstanceContainer instanceContainer = instanceManager.createInstanceContainer();
|
||||
|
||||
SoccerGenerator generator = new SoccerGenerator();
|
||||
instanceContainer.setGenerator(generator);
|
||||
instanceContainer.setChunkSupplier(LightingChunk::new);
|
||||
|
||||
LoginHandler loginHandler = new LoginHandler(instanceContainer);
|
||||
loginHandler.setup(globalEventHandler);
|
||||
|
||||
WorldConstraints worldConstraints = new WorldConstraints();
|
||||
worldConstraints.setup(globalEventHandler);
|
||||
|
||||
|
||||
/* done */
|
||||
|
||||
MinecraftServer.setCompressionThreshold(0);
|
||||
MinecraftServer.setBrandName("PiViPi");
|
||||
|
||||
minecraftServer.start("0.0.0.0", 25565);
|
||||
System.out.println("started");
|
||||
|
||||
}
|
||||
}
|
42
src/main/java/net/pivipi/ball/Ball.java
Normal file
42
src/main/java/net/pivipi/ball/Ball.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package net.pivipi.ball;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.entity.metadata.other.FallingBlockMeta;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.pivipi.physics.Physics;
|
||||
|
||||
public class Ball extends Entity {
|
||||
private long lastTick;
|
||||
private final Physics physics = new Physics(this);
|
||||
|
||||
public Ball(Block block) {
|
||||
super(EntityType.FALLING_BLOCK); // not block display because its movement lags for some reason
|
||||
|
||||
this.setBoundingBox(0.625, 0.625, 0.625);
|
||||
this.setNoGravity(true);
|
||||
this.setGlowing(true);
|
||||
|
||||
this.editEntityMeta(FallingBlockMeta.class, meta -> {
|
||||
meta.setBlock(block);
|
||||
});
|
||||
}
|
||||
|
||||
public Ball() {
|
||||
this(Block.WHITE_WOOL);
|
||||
}
|
||||
|
||||
|
||||
public void tick(long time) { // I don't know if change that to update
|
||||
if (this.lastTick == 0) {
|
||||
this.lastTick = time;
|
||||
}
|
||||
|
||||
long delay = time - this.lastTick;
|
||||
|
||||
physics.applyPhysics();
|
||||
|
||||
this.lastTick = time;
|
||||
}
|
||||
|
||||
}
|
31
src/main/java/net/pivipi/physics/Collision.java
Normal file
31
src/main/java/net/pivipi/physics/Collision.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
package net.pivipi.physics;
|
||||
|
||||
import javax.swing.text.html.parser.Entity;
|
||||
|
||||
import net.kyori.adventure.text.BlockNBTComponent.Pos;
|
||||
import net.minestom.server.collision.VisibleSweepResult;
|
||||
import net.minestom.server.entity.Player;
|
||||
|
||||
public class Collision {
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
* @param moving the moving entity
|
||||
* @param velocity the applied velocity
|
||||
* @return null if no collision
|
||||
*/
|
||||
public static VisibleSweepResult willCollideWithPlayer(Player player, Entity moving, Pos velocity) {
|
||||
return null; // TODO
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param groundY ground Y
|
||||
* @param moving the moving entity
|
||||
* @param velocity the applied velocity
|
||||
* @return null if no collision
|
||||
*/
|
||||
public static VisibleSweepResult willCollideWithGround(double groundY, Entity moving, Pos velocity) {
|
||||
return null; // TODO
|
||||
}
|
||||
}
|
17
src/main/java/net/pivipi/physics/Physics.java
Normal file
17
src/main/java/net/pivipi/physics/Physics.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package net.pivipi.physics;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
|
||||
public class Physics {
|
||||
private final double gravity = 9.8;
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public Physics(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public void applyPhysics() {
|
||||
|
||||
}
|
||||
}
|
19
src/main/java/net/pivipi/world/SoccerGenerator.java
Normal file
19
src/main/java/net/pivipi/world/SoccerGenerator.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package net.pivipi.world;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.generator.GenerationUnit;
|
||||
import net.minestom.server.instance.generator.Generator;
|
||||
import net.minestom.server.instance.generator.UnitModifier;
|
||||
|
||||
public class SoccerGenerator implements Generator {
|
||||
|
||||
@Override
|
||||
public void generate(@NotNull GenerationUnit unit) {
|
||||
UnitModifier modifier = unit.modifier();
|
||||
|
||||
modifier.fillHeight(1, 2, Block.GRASS_BLOCK);
|
||||
}
|
||||
|
||||
}
|
32
src/main/java/net/pivipi/world/WorldConstraints.java
Normal file
32
src/main/java/net/pivipi/world/WorldConstraints.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package net.pivipi.world;
|
||||
|
||||
import net.minestom.server.event.GlobalEventHandler;
|
||||
import net.minestom.server.event.player.PlayerBlockBreakEvent;
|
||||
import net.minestom.server.event.player.PlayerBlockPlaceEvent;
|
||||
|
||||
public class WorldConstraints {
|
||||
public WorldConstraints() {
|
||||
|
||||
}
|
||||
|
||||
private void onBreak(PlayerBlockBreakEvent event) {
|
||||
//if (event.getBlock() == Block.GRASS_BLOCK)
|
||||
// event.setCancelled(true);
|
||||
}
|
||||
|
||||
private void onPlace(PlayerBlockPlaceEvent event) {
|
||||
|
||||
}
|
||||
|
||||
public void setup(GlobalEventHandler globalEventHandler) {
|
||||
globalEventHandler.addListener(
|
||||
PlayerBlockBreakEvent.class,
|
||||
event -> onBreak(event)
|
||||
);
|
||||
|
||||
globalEventHandler.addListener(
|
||||
PlayerBlockPlaceEvent.class,
|
||||
event -> onPlace(event)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue