Skip to content

Commit

Permalink
Fixed forge server
Browse files Browse the repository at this point in the history
  • Loading branch information
StewStrong committed Jul 21, 2024
1 parent dcba513 commit 1681692
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"feature.shipyard_entities.MixinEntity",
"feature.shipyard_entities.MixinEntitySection",
"feature.shipyard_entities.MixinEntitySectionStorage",
"feature.shipyard_entities.MixinPersistentEntitySectionManager",
"feature.shipyard_entities.MixinServerLevel",
"feature.shipyard_entities.MixinTransientEntitySectionManager",
"feature.spawn_player_on_ship.MixinServerGamePacketListenerImpl",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.valkyrienskies.mod.mixin.feature.shipyard_entities;
package org.valkyrienskies.mod.fabric.mixin.feature.shipyard_entities;

import java.util.function.LongPredicate;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.entity.EntitySectionStorage;
Expand Down Expand Up @@ -42,8 +43,9 @@ public void setLevel(final Level level) {
value = "INVOKE"
)
)
private java.util.function.LongPredicate processUnloads_catchException(
final java.util.function.LongPredicate par1) {
private LongPredicate processUnloads_catchException(
final LongPredicate par1
) {
return (l) -> {
try {
return par1.test(l);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"compat.create.client.MixinTrackBlockOutline",
"compat.sodium.MixinRenderSectionManager",
"feature.explosions.ClipContextMixin",
"feature.shipyard_entities.MixinPersistentEntitySectionManager",
"world.level.block.FireMixin"
],
"client": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package org.valkyrienskies.mod.forge.mixin.feature.shipyard_entities;

import it.unimi.dsi.fastutil.longs.LongPredicate;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.entity.EntitySectionStorage;
import net.minecraft.world.level.entity.PersistentEntitySectionManager;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.valkyrienskies.mod.mixinducks.world.OfLevel;

@Mixin(PersistentEntitySectionManager.class)
public abstract class MixinPersistentEntitySectionManager implements OfLevel {
@Shadow
@Final
EntitySectionStorage<Entity> sectionStorage;

@Unique
private Level valkyrienskies$level;

@Override
public Level getLevel() {
return valkyrienskies$level;
}

@Override
public void setLevel(final Level level) {
this.valkyrienskies$level = level;
((OfLevel) this.sectionStorage).setLevel(level);
}

/**
* This fixes this function randomly crashing. I'm not sure why but the removeIf() function is buggy
*/
@ModifyArg(
method = "processUnloads",
at = @At(
target = "Lit/unimi/dsi/fastutil/longs/LongSet;removeIf(Lit/unimi/dsi/fastutil/longs/LongPredicate;)Z",
value = "INVOKE"
)
)
private LongPredicate processUnloads_catchException(
final LongPredicate par1
) {
return (l) -> {
try {
return par1.test(l);
} catch (final Exception e) {
e.printStackTrace();
return false;
}
};
}
}
1 change: 1 addition & 0 deletions forge/src/main/resources/valkyrienskies-forge.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"compat.thermalexpansion.MixinTileCoFH",
"compat.tis3d.MixinInfraredPacketEntity",
"feature.forge_interact.MixinIForgePlayer",
"feature.shipyard_entities.MixinPersistentEntitySectionManager",
"world.level.block.FireMixin"
],
"client": [
Expand Down

0 comments on commit 1681692

Please sign in to comment.