-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize Secondary POI and remove spotless fr
- Loading branch information
Showing
6 changed files
with
88 additions
and
3 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
11 changes: 11 additions & 0 deletions
11
src/main/java/net/gensokyoreimagined/nitori/common/util/ArrayConstants.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,11 @@ | ||
package net.gensokyoreimagined.nitori.common.util; | ||
|
||
/** | ||
* Pre-initialized constants to avoid unnecessary allocations. | ||
*/ | ||
public final class ArrayConstants { | ||
private ArrayConstants() {} | ||
|
||
public static final int[] EMPTY = new int[0]; | ||
public static final int[] ZERO = new int[]{0}; | ||
} |
26 changes: 26 additions & 0 deletions
26
...reimagined/nitori/mixin/ai/sensor/secondary_poi/SecondaryPointsOfInterestSensorMixin.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,26 @@ | ||
package net.gensokyoreimagined.nitori.mixin.ai.sensor.secondary_poi; | ||
|
||
import net.minecraft.world.entity.ai.memory.MemoryModuleType; | ||
import net.minecraft.world.entity.ai.sensing.SecondaryPoiSensor; | ||
import net.minecraft.world.entity.npc.Villager; | ||
import net.minecraft.server.level.ServerLevel; | ||
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; | ||
|
||
@Mixin(SecondaryPoiSensor.class) | ||
public class SecondaryPointsOfInterestSensorMixin { | ||
|
||
@Inject( | ||
method = "doTick(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/npc/Villager;)V", | ||
at = @At("HEAD"), | ||
cancellable = true | ||
) | ||
private void skipUselessSense(ServerLevel serverWorld, Villager villagerEntity, CallbackInfo ci) { | ||
if (villagerEntity.getVillagerData().getProfession().secondaryPoi().isEmpty()) { | ||
villagerEntity.getBrain().eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE); | ||
ci.cancel(); | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/net/gensokyoreimagined/nitori/mixin/alloc/composter/ComposterMixin.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,48 @@ | ||
package net.gensokyoreimagined.nitori.mixin.alloc.composter; | ||
|
||
//import net.gensokyoreimagined.nitori.common.util.ArrayConstants; | ||
//import net.minecraft.world.WorldlyContainer; | ||
//import net.minecraft.core.Direction; | ||
//import org.spongepowered.asm.mixin.Mixin; | ||
//import org.spongepowered.asm.mixin.Overwrite; | ||
// | ||
//public class ComposterMixin { | ||
// | ||
// @Mixin(targets = "net.minecraft.block.ComposterBlock$ComposterInventory") | ||
// static abstract class ComposterBlockComposterInventoryMixin implements WorldlyContainer { | ||
// /** | ||
// * @author 2No2Name | ||
// * @reason avoid allocation | ||
// */ | ||
// @Overwrite | ||
// public int[] getSlotsForFace(Direction side) { | ||
// return side == Direction.UP ? ArrayConstants.ZERO : ArrayConstants.EMPTY; | ||
// } | ||
// } | ||
// | ||
// @Mixin(targets = "net.minecraft.block.ComposterBlock$DummyInventory") | ||
// static abstract class ComposterBlockDummyInventoryMixin implements WorldlyContainer { | ||
// /** | ||
// * @author 2No2Name | ||
// * @reason avoid allocation | ||
// */ | ||
// @Overwrite | ||
// public int[] getSlotsForFace(Direction side) { | ||
// return ArrayConstants.EMPTY; | ||
// } | ||
// } | ||
// | ||
// @Mixin(targets = "net.minecraft.block.ComposterBlock$FullComposterInventory") | ||
// static abstract class ComposterBlockFullComposterInventoryMixin implements WorldlyContainer { | ||
// /** | ||
// * @author 2No2Name | ||
// * @reason avoid allocation | ||
// */ | ||
// @Overwrite | ||
// public int[] getSlotsForFace(Direction side) { | ||
// return side == Direction.DOWN ? ArrayConstants.ZERO : ArrayConstants.EMPTY; | ||
// } | ||
// } | ||
//} | ||
|
||
//TODO: Mixins are not getting dettected for some reason even if they are in the mixins.core??? |
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