Skip to content

Commit

Permalink
1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
emortaldev committed Apr 21, 2024
1 parent e43047e commit 36565b6
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies {
implementation("com.badlogicgames.gdx:gdx-bullet:1.12.0")
implementation("com.badlogicgames.gdx:gdx-bullet-platform:1.12.0:natives-desktop")

implementation("dev.hollowcube:minestom-ce:30699ec3fd")
implementation("net.minestom:minestom-snapshots:e8e22a2b15")
}

tasks {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Oct 01 21:33:41 BST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
15 changes: 9 additions & 6 deletions src/main/java/dev/emortal/BlockRigidBody.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,17 @@ private void spawnEntity(Instance instance, Block block) {
// Uses an ITEM_DISPLAY instead of a BLOCK_DISPLAY as it is centered around the middle instead of the corner
entity = new NoTickingEntity(EntityType.ITEM_DISPLAY);
meta = (ItemDisplayMeta) entity.getEntityMeta();
entity.setInstance(instance, Pos.ZERO);

meta.setWidth(2);
meta.setHeight(2);

meta.setNotifyAboutChanges(false);
meta.setItemStack(ItemStack.of(block.registry().material()));
Matrix4 transform = rigidBody.getWorldTransform();

Vector3 translation = new Vector3();
transform.getTranslation(translation);
meta.setTranslation(toVec(translation));
entity.setInstance(instance, toVec(translation));

Vector3 scale = new Vector3();
transform.getScale(scale);
Expand All @@ -88,16 +90,17 @@ private void spawnEntity(Instance instance, Block block) {
public void updateEntity() {
if (meta == null) return;

rigidBody.activate(); // Rigid bodies have to be constantly active in order to be pushed by the player
// rigidBody.activate(); // Rigid bodies have to be constantly active in order to be pushed by the player

meta.setNotifyAboutChanges(false);
meta.setInterpolationDuration(1);
meta.setInterpolationStartDelta(0);
meta.setTransformationInterpolationDuration(1);
meta.setPosRotInterpolationDuration(1);
meta.setTransformationInterpolationStartDelta(0);
Matrix4 transform = rigidBody.getWorldTransform();

Vector3 translation = new Vector3();
transform.getTranslation(translation);
meta.setTranslation(toVec(translation));
entity.teleport(Pos.fromPoint(toVec(translation)));

// size not updated as it doesn't change

Expand Down
33 changes: 17 additions & 16 deletions src/main/java/dev/emortal/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.kyori.adventure.bossbar.BossBar;
import net.kyori.adventure.text.Component;
import net.minestom.server.MinecraftServer;
import net.minestom.server.ServerFlag;
import net.minestom.server.coordinate.Point;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.coordinate.Vec;
Expand All @@ -13,12 +14,12 @@
import net.minestom.server.entity.GameMode;
import net.minestom.server.entity.metadata.other.PrimedTntMeta;
import net.minestom.server.event.GlobalEventHandler;
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
import net.minestom.server.event.player.PlayerBlockPlaceEvent;
import net.minestom.server.event.player.PlayerLoginEvent;
import net.minestom.server.event.player.PlayerSpawnEvent;
import net.minestom.server.event.player.PlayerStartSneakingEvent;
import net.minestom.server.event.server.ServerTickMonitorEvent;
import net.minestom.server.instance.Instance;
import net.minestom.server.instance.InstanceManager;
import net.minestom.server.instance.InstanceContainer;
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
import net.minestom.server.instance.block.Block;
import net.minestom.server.item.ItemStack;
Expand All @@ -27,8 +28,8 @@
import net.minestom.server.timer.TaskSchedule;
import net.minestom.server.utils.NamespaceID;
import net.minestom.server.world.DimensionType;
import net.minestom.server.world.DimensionTypeManager;

import java.io.IOException;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
Expand All @@ -44,13 +45,10 @@ public static void main(String[] args) {
Bullet.init();
MinecraftServer server = MinecraftServer.init();

DimensionType fullbright = DimensionType.builder(NamespaceID.from("fullbright")).ambientLight(1f).build();
MinecraftServer.getDimensionTypeManager().addDimension(fullbright);

DimensionTypeManager dm = MinecraftServer.getDimensionTypeManager();
DimensionType dimension = DimensionType.builder(NamespaceID.from("fb")).ambientLight(1f).build();
dm.addDimension(dimension);

InstanceManager im = MinecraftServer.getInstanceManager();
Instance instance = im.createInstanceContainer(dimension);
InstanceContainer instance = MinecraftServer.getInstanceManager().createInstanceContainer(fullbright);

for (int x = -20; x < 20; x++) {
for (int z = -20; z < 20; z++) {
Expand All @@ -66,11 +64,9 @@ public static void main(String[] args) {

GlobalEventHandler global = MinecraftServer.getGlobalEventHandler();

global.addListener(PlayerLoginEvent.class, e -> {
global.addListener(PlayerSpawnEvent.class, e -> {
e.getPlayer().showBossBar(bossBar);
e.setSpawningInstance(instance);
e.getPlayer().setGameMode(GameMode.CREATIVE);
e.getPlayer().setRespawnPoint(new Pos(0, 5, 0));

e.getPlayer().sendMessage(Component.text("Welcome, crouch to spawn blocks"));
e.getPlayer().sendMessage(Component.text("You can interact with the cubes by moving into them"));
Expand All @@ -92,8 +88,13 @@ public static void main(String[] args) {
}).repeat(TaskSchedule.tick(1)).schedule();
});

global.addListener(AsyncPlayerConfigurationEvent.class, e -> {
e.setSpawningInstance(instance);
e.getPlayer().setRespawnPoint(new Pos(0, 20, 0));
});

instance.scheduler().buildTask(() -> {
physicsHandler.update(1f / (float)MinecraftServer.TICK_PER_SECOND);
physicsHandler.update(1f / (float) ServerFlag.SERVER_TICKS_PER_SECOND);
}).repeat(TaskSchedule.tick(1)).schedule();


Expand Down Expand Up @@ -155,14 +156,14 @@ public static void main(String[] args) {
batch.setBlock(nearbyBlock.position(), Block.AIR);
}
batch.apply(instance, null);
}).delay(TaskSchedule.tick(3 * MinecraftServer.TICK_PER_SECOND)).schedule();
}).delay(TaskSchedule.tick(3 * ServerFlag.SERVER_TICKS_PER_SECOND)).schedule();
}
});

global.addListener(PlayerStartSneakingEvent.class, e -> {
for (int x = -5; x < 5; x++) {
for (int z = -5; z < 5; z++) {
physicsHandler.addCube(new BlockRigidBody(instance, new Vector3(x, 15, z), new Vector3(0.5f, 0.5f, 0.5f), 1, true, Block.DIAMOND_BLOCK));
physicsHandler.addCube(new BlockRigidBody(instance, new Vector3(x, 20, z), new Vector3(0.5f, 0.5f, 0.5f), 1, true, Block.DIAMOND_BLOCK));
}
}
});
Expand Down

0 comments on commit 36565b6

Please sign in to comment.