forked from CaffeineMC/lithium-fabric
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix running in dev * Port entity fluid optimization to Forge * Improve efficiency of Forge isInFluidType() extension * Do not bother making the hashed reference list for tiny pools * Reduce overhead of Forge spawning event * Disable some known-problematic mixin packages by default * Port POI mixin to Forge * Update mixin config file
- Loading branch information
Showing
13 changed files
with
171 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/java/me/jellysquid/mods/lithium/common/world/PotentialSpawnsExtended.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package me.jellysquid.mods.lithium.common.world; | ||
|
||
public interface PotentialSpawnsExtended { | ||
boolean radium$wasListModified(); | ||
} |
24 changes: 0 additions & 24 deletions
24
...va/me/jellysquid/mods/lithium/common/world/interests/types/PointOfInterestTypeHelper.java
This file was deleted.
Oops, something went wrong.
23 changes: 8 additions & 15 deletions
23
src/main/java/me/jellysquid/mods/lithium/mixin/ai/poi/PointOfInterestTypesMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,19 @@ | ||
package me.jellysquid.mods.lithium.mixin.ai.poi; | ||
|
||
import me.jellysquid.mods.lithium.common.world.interests.types.PointOfInterestTypeHelper; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.world.poi.PointOfInterestTypes; | ||
import org.spongepowered.asm.mixin.Final; | ||
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyArg; | ||
|
||
import java.util.Set; | ||
import java.util.Map; | ||
|
||
/** | ||
* Replaces the backing map type with a faster collection type which uses reference equality. | ||
*/ | ||
@Mixin(PointOfInterestTypes.class) | ||
@Mixin(targets = { "net/minecraftforge/registries/GameData$PointOfInterestTypeCallbacks" }) | ||
public class PointOfInterestTypesMixin { | ||
@Shadow | ||
@Final | ||
protected static Set<BlockState> f_218067_; | ||
|
||
static { | ||
// POI_STATES_TO_TYPE = new Reference2ReferenceOpenHashMap<>(POI_STATES_TO_TYPE); TODO why it broke? | ||
|
||
PointOfInterestTypeHelper.init(f_218067_); | ||
@ModifyArg(method = "onCreate", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/registries/IForgeRegistryInternal;setSlaveMap(Lnet/minecraft/util/Identifier;Ljava/lang/Object;)V"), index = 1) | ||
private Object changeMapType(Object obj) { | ||
return new Reference2ReferenceOpenHashMap<>((Map<?, ?>)obj); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ava/me/jellysquid/mods/lithium/mixin/collections/mob_spawning/ForgeEventFactoryMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package me.jellysquid.mods.lithium.mixin.collections.mob_spawning; | ||
|
||
import me.jellysquid.mods.lithium.common.world.PotentialSpawnsExtended; | ||
import net.minecraft.entity.SpawnGroup; | ||
import net.minecraft.util.collection.Pool; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.WorldAccess; | ||
import net.minecraft.world.biome.SpawnSettings; | ||
import net.minecraftforge.event.ForgeEventFactory; | ||
import net.minecraftforge.event.level.LevelEvent; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
@Mixin(ForgeEventFactory.class) | ||
public class ForgeEventFactoryMixin { | ||
/** | ||
* @author embeddedt | ||
* @reason Avoid the overhead of re-creating a pool in the event that the spawn list was not changed. | ||
*/ | ||
@Inject(method = "getPotentialSpawns", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/util/collection/Pool;of(Ljava/util/List;)Lnet/minecraft/util/collection/Pool;"), | ||
locals = LocalCapture.CAPTURE_FAILHARD, | ||
cancellable = true | ||
) | ||
private static void reusePoolIfPossible(WorldAccess level, SpawnGroup category, BlockPos pos, Pool<SpawnSettings.SpawnEntry> oldList, CallbackInfoReturnable<Pool<SpawnSettings.SpawnEntry>> cir, LevelEvent.PotentialSpawns event) { | ||
if(!((PotentialSpawnsExtended)event).radium$wasListModified()) { | ||
cir.setReturnValue(oldList); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
.../me/jellysquid/mods/lithium/mixin/collections/mob_spawning/PotentialSpawnsEventMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package me.jellysquid.mods.lithium.mixin.collections.mob_spawning; | ||
|
||
import me.jellysquid.mods.lithium.common.world.PotentialSpawnsExtended; | ||
import net.minecraftforge.event.level.LevelEvent; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(LevelEvent.PotentialSpawns.class) | ||
public class PotentialSpawnsEventMixin implements PotentialSpawnsExtended { | ||
private boolean radium$listModified; | ||
|
||
@Inject(method = "addSpawnerData", at = @At("RETURN")) | ||
private void onAdd(CallbackInfo ci) { | ||
radium$listModified = true; | ||
} | ||
|
||
@Inject(method = "removeSpawnerData", at = @At("RETURN")) | ||
private void onRemove(CallbackInfoReturnable<Boolean> ci) { | ||
radium$listModified = true; | ||
} | ||
|
||
@Override | ||
public boolean radium$wasListModified() { | ||
return radium$listModified; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...va/me/jellysquid/mods/lithium/mixin/world/block_entity_ticking/sleeping/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
@MixinConfigOption(description = "Allows BlockEntities to sleep, meaning they are no longer ticked until woken up, e.g. by updates to their inventory or block state") | ||
@MixinConfigOption(description = "Allows BlockEntities to sleep, meaning they are no longer ticked until woken up, e.g. by updates to their inventory or block state", enabled = false) | ||
package me.jellysquid.mods.lithium.mixin.world.block_entity_ticking.sleeping; | ||
|
||
import net.caffeinemc.gradle.MixinConfigOption; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters