Skip to content

Commit

Permalink
fixed iterator bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanobass committed Jun 10, 2024
1 parent a7c9ce6 commit 4196cf5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mod Properties
id = flux-entities
version = 1.2.1
version = 1.2.2
description = Flux Entities

group = dev.crmodders
Expand Down
24 changes: 14 additions & 10 deletions src/main/java/dev/crmodders/flux/entities/mixins/ChunkMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,25 @@ public abstract class ChunkMixin implements ITickable, IRenderable {
@Override
public void onTick(float tps) {
if(blockEntities != null)
blockEntities.forEach(entity -> {
if(entity instanceof ITickable tickable) {
tickable.onTick(tps);
}
});
synchronized (blockEntities) {
blockEntities.forEach(entity -> {
if(entity instanceof ITickable tickable) {
tickable.onTick(tps);
}
});
}
}

@Override
public void onRender(Camera camera, float dt) {
if(blockEntities != null)
blockEntities.forEach(entity -> {
if(entity instanceof IRenderable renderable) {
renderable.onRender(camera, dt);
}
});
synchronized (blockEntities) {
blockEntities.forEach(entity -> {
if(entity instanceof IRenderable renderable) {
renderable.onRender(camera, dt);
}
});
}
}

@Inject(method = "setBlockEntity", at= @At(value = "INVOKE", target = "Lfinalforeach/cosmicreach/blockentities/BlockEntity;onRemove()V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD)
Expand Down
24 changes: 14 additions & 10 deletions src/main/java/dev/crmodders/flux/entities/mixins/ZoneMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,23 @@ public class ZoneMixin implements IRenderable {

@Inject(method = "runScheduledTriggers", at = @At("HEAD"))
private void zoneUpdate(CallbackInfo ci) {
chunks.forEach(chunk -> {
if(chunk instanceof ITickable tickable) {
tickable.onTick(1f / 20f); // TODO get tps here
}
});
synchronized (chunks) {
chunks.forEach(chunk -> {
if (chunk instanceof ITickable tickable) {
tickable.onTick(1f / 20f); // TODO get tps here
}
});
}
}

@Override
public void onRender(Camera camera, float dt) {
chunks.forEach(chunk -> {
if(chunk instanceof IRenderable renderable) {
renderable.onRender(camera, dt);
}
});
synchronized (chunks) {
chunks.forEach(chunk -> {
if(chunk instanceof IRenderable renderable) {
renderable.onRender(camera, dt);
}
});
}
}
}

0 comments on commit 4196cf5

Please sign in to comment.