Skip to content
This repository was archived by the owner on Dec 24, 2023. It is now read-only.

Commit fce3752

Browse files
Fixed a testmod bug in forge
1 parent e7cec2b commit fce3752

File tree

12 files changed

+24
-46
lines changed

12 files changed

+24
-46
lines changed

common/src/main/java/dev/lazurite/rayon/impl/event/ServerEventHandler.java

+7
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
import dev.lazurite.toolbox.api.math.VectorHelper;
2121
import dev.lazurite.toolbox.api.network.PacketRegistry;
2222
import dev.lazurite.toolbox.api.util.PlayerUtil;
23+
import net.minecraft.core.BlockPos;
2324
import net.minecraft.server.MinecraftServer;
2425
import net.minecraft.server.level.ServerLevel;
2526
import net.minecraft.server.level.ServerPlayer;
2627
import net.minecraft.world.entity.Entity;
2728
import net.minecraft.world.level.Level;
29+
import net.minecraft.world.level.block.state.BlockState;
2830

2931
public final class ServerEventHandler {
3032
private static PhysicsThread thread;
@@ -48,13 +50,18 @@ public static void register() {
4850
ServerEvents.Lifecycle.LOAD_LEVEL.register(ServerEventHandler::onLevelLoad);
4951
ServerEvents.Tick.START_LEVEL_TICK.register(ServerEventHandler::onStartLevelTick);
5052
ServerEvents.Tick.START_LEVEL_TICK.register(ServerEventHandler::onEntityStartLevelTick);
53+
ServerEvents.Block.BLOCK_UPDATE.register(ServerEventHandler::onBlockUpdate);
5154

5255
// Entity Events
5356
ServerEvents.Entity.LOAD.register(ServerEventHandler::onEntityLoad);
5457
ServerEvents.Entity.START_TRACKING.register(ServerEventHandler::onStartTrackingEntity);
5558
ServerEvents.Entity.STOP_TRACKING.register(ServerEventHandler::onStopTrackingEntity);
5659
}
5760

61+
public static void onBlockUpdate(Level level, BlockState blockState, BlockPos blockPos) {
62+
MinecraftSpace.getOptional(level).ifPresent(space -> space.doBlockUpdate(blockPos));
63+
}
64+
5865
public static void onServerStart(MinecraftServer server) {
5966
thread = new PhysicsThread(server, Thread.currentThread(), new ServerLevelSupplier(server), "Server Physics Thread");
6067
}

common/src/main/java/dev/lazurite/rayon/impl/mixin/common/BlockStateBaseMixin.java

-23
This file was deleted.

common/src/main/java/dev/lazurite/rayon/impl/mixin/common/LevelMixin.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
*/
1313
@Mixin(Level.class)
1414
public class LevelMixin implements SpaceStorage {
15-
@Unique
16-
private MinecraftSpace space;
15+
@Unique private MinecraftSpace space;
1716

1817
@Override
1918
public void setSpace(MinecraftSpace space) {

common/src/main/java/dev/lazurite/rayon/impl/mixin/common/ExplosionMixin.java renamed to common/src/main/java/dev/lazurite/rayon/impl/mixin/common/entity/ExplosionMixin.java

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package dev.lazurite.rayon.impl.mixin.common;
1+
package dev.lazurite.rayon.impl.mixin.common.entity;
22

3+
import dev.lazurite.rayon.api.EntityPhysicsElement;
34
import dev.lazurite.rayon.api.PhysicsElement;
4-
import dev.lazurite.rayon.impl.bullet.collision.space.MinecraftSpace;
55
import dev.lazurite.rayon.impl.bullet.math.Convert;
66
import net.minecraft.world.entity.Entity;
77
import net.minecraft.world.level.Explosion;
@@ -22,7 +22,8 @@
2222
*/
2323
@Mixin(Explosion.class)
2424
public class ExplosionMixin {
25-
@Unique private Entity entity;
25+
@Unique
26+
private Entity entity;
2627

2728
@Inject(
2829
method = "explode",
@@ -44,14 +45,10 @@ public void collectBlocksAndDamageEntities(CallbackInfo info, Set set, int q, fl
4445
)
4546
)
4647
public Vec3 setVelocity(Vec3 velocity) {
47-
if (entity instanceof PhysicsElement) {
48-
var rigidBody = ((PhysicsElement) entity).getRigidBody();
49-
50-
MinecraftSpace.get(entity.level).getWorkerThread().execute(() ->
51-
rigidBody.applyCentralImpulse(Convert.toBullet(velocity).multLocal(rigidBody.getMass()).multLocal(100))
52-
);
48+
if (entity instanceof EntityPhysicsElement element) {
49+
element.getRigidBody().applyCentralImpulse(Convert.toBullet(velocity).multLocal(element.getRigidBody().getMass() * 100f));
5350
}
5451

5552
return velocity;
5653
}
57-
}
54+
}

common/src/main/resources/assets/dev/lang/en_us.json

-4
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"debug.rayon.on": "Rigid Body Hitboxes: shown",
3-
"debug.rayon.off": "Rigid Body Hitboxes: hidden"
3+
"debug.rayon.off": "Rigid Body Hitboxes: hidden",
4+
5+
"item.rayon.wand_item" : "Wand Item",
6+
"entity.rayon.stone_block_entity" : "Stone Block"
47
}

common/src/main/resources/rayon.mixins.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
"package": "dev.lazurite.rayon.impl.mixin",
55
"compatibilityLevel": "JAVA_17",
66
"mixins": [
7-
"common.BlockStateBaseMixin",
8-
"common.ExplosionMixin",
97
"common.LevelMixin",
108
"common.entity.EntityMixin",
11-
"common.entity.EntityTrackerEntryMixin"
9+
"common.entity.EntityTrackerEntryMixin",
10+
"common.entity.ExplosionMixin"
1211
],
1312
"client": [
1413
"client.EntityRenderDispatcherMixin",

forge/src/main/java/dev/lazurite/rayon/impl/forge/dev/RayonDevForge.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ public static void init() {
3434
}
3535

3636
@SubscribeEvent
37-
public void onInitialize(FMLCommonSetupEvent event) {
37+
public static void onInitialize(FMLCommonSetupEvent event) {
3838
RayonDev.WAND_ITEM = (WandItem) WAND_ITEM.get();
3939
RayonDev.STONE_BLOCK_ENTITY = (EntityType<StoneBlockEntity>) STONE_BLOCK_ENTITY.get();
4040
}
4141

4242
@SubscribeEvent
43-
public void onRegisterAttributes(EntityAttributeCreationEvent event) {
43+
public static void onRegisterAttributes(EntityAttributeCreationEvent event) {
4444
event.put(STONE_BLOCK_ENTITY.get(), LivingEntity.createLivingAttributes().build());
4545
}
4646
}

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ forge_version = 41.0.100
1616
# Dependencies
1717
libbulletjme_version = 15.2.1
1818
transporter_version = 1.3.12
19-
toolbox_version = 1.3.22
19+
toolbox_version = 1.3.23
2020

2121
# Gradle
2222
shadow_version = 7.0.0

0 commit comments

Comments
 (0)