-
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.
- Loading branch information
1 parent
b36e8f9
commit 9208c87
Showing
5 changed files
with
45 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
34 changes: 34 additions & 0 deletions
34
src/main/java/org/blocovermelho/bvextension/mixin/BotsDontSleep.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,34 @@ | ||
package org.blocovermelho.bvextension.mixin; | ||
|
||
import carpet.CarpetServer; | ||
import carpet.patches.EntityPlayerMPFake; | ||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import net.minecraft.server.world.SleepManager; | ||
import org.blocovermelho.bvextension.Settings; | ||
import org.objectweb.asm.Opcodes; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(SleepManager.class) | ||
public class BotsDontSleep { | ||
@ModifyExpressionValue( | ||
method = "getNightSkippingRequirement", | ||
at = @At( | ||
value = "FIELD", | ||
opcode = Opcodes.GETFIELD, | ||
target = "Lnet/minecraft/server/world/SleepManager;total:I" | ||
)) | ||
public int bvext$botsDontSleep(int original) { | ||
if (!Settings.botsDontSleep) { | ||
return original; | ||
} | ||
|
||
var players = CarpetServer.minecraft_server.getPlayerManager().getPlayerList(); | ||
|
||
var bots = (int) players.stream().filter(p -> { | ||
return p instanceof EntityPlayerMPFake; | ||
}).count(); | ||
|
||
return original - bots; | ||
} | ||
} |
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,3 +1,4 @@ | ||
{ | ||
"carpet.rule.carefulBreak.desc": "Places the mined block in the player inventory when sneaking" | ||
"carpet.rule.carefulBreak.desc": "Places the mined block in the player inventory when sneaking", | ||
"carpet.rule.botsDontSleep.desc" : "Makes carpet bots don't count towards playersSleepingPercentage" | ||
} |
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,3 +1,4 @@ | ||
{ | ||
"carpet.rule.carefulBreak.desc": "Coloca o bloco minerado direto no inventário quando o jogador está agachado" | ||
"carpet.rule.carefulBreak.desc": "Coloca o bloco minerado direto no inventário quando o jogador está agachado", | ||
"carpet.rule.botsDontSleep.desc" : "Faz com que bots do carpet não contem para a gamerule playersSleepingPercentage" | ||
} |
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