overwrite getMaxNetherPortalTime

This commit is contained in:
ImUrX committed 2020-02-08 16:18:56 -03:00
1 parent 9a875c64e2
commit fe56ab8d3e
2 files changed
+31 -18

No files matched your search

+23 -4
View File
@@ -50,11 +50,30 @@ public class CarpetSettings
public static boolean superSecretSetting = false; public static boolean superSecretSetting = false;
@Rule( @Rule(
desc = "Portals won't let a creative player go through instantly", desc = "Modify the amount of ticks for entering a Nether portal in creative",
extra = "Holding obsidian in either hand won't let you through at all", options = {"1", "40", "80", "72000"},
category = CREATIVE category = CREATIVE,
strict = false,
validate = NetherPortalDelayLimit.class
) )
public static boolean portalCreativeDelay = false; public static int portalCreativeDelay = 1;
@Rule(
desc = "Modify the amount of ticks for entering a Nether portal in survival",
options = {"1", "40", "80", "72000"},
category = SURVIVAL,
strict = false,
validate = NetherPortalDelayLimit.class
)
public static int portalSurvivalDelay = 80;
private static class NetherPortalDelayLimit extends Validator<Integer> {
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
return (newValue > 0 && newValue <= 72000) ? newValue : null;
}
@Override
public String description() { return "You must choose a value from 1 to 72000";}
}
@Rule(desc = "Dropping entire stacks works also from on the crafting UI result slot", category = {BUGFIX, SURVIVAL}) @Rule(desc = "Dropping entire stacks works also from on the crafting UI result slot", category = {BUGFIX, SURVIVAL})
public static boolean ctrlQCraftingFix = false; public static boolean ctrlQCraftingFix = false;
@@ -1,23 +1,17 @@
package carpet.mixins; package carpet.mixins;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import carpet.helpers.PortalHelper; import net.minecraft.entity.player.PlayerAbilities;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(PlayerEntity.class) @Mixin(PlayerEntity.class)
public abstract class PlayerEntityMixin public abstract class PlayerEntityMixin {
{ @Shadow
@ModifyConstant(method = "getMaxNetherPortalTime", public PlayerAbilities abilities;
constant = @Constant(intValue = 1))
private int addFillUpdatesInt(int original) { public int getMaxNetherPortalTime() {
if (CarpetSettings.portalCreativeDelay) return this.abilities.invulnerable ? CarpetSettings.portalCreativeDelay : CarpetSettings.portalSurvivalDelay;
if (PortalHelper.player_holds_obsidian((PlayerEntity) (Object)this))
return 72000;
else
return 80;
return original;
} }
} }