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;
@Rule(
desc = "Portals won't let a creative player go through instantly",
extra = "Holding obsidian in either hand won't let you through at all",
category = CREATIVE
desc = "Modify the amount of ticks for entering a Nether portal in creative",
options = {"1", "40", "80", "72000"},
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})
public static boolean ctrlQCraftingFix = false;
@@ -1,23 +1,17 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.helpers.PortalHelper;
import net.minecraft.entity.player.PlayerAbilities;
import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(PlayerEntity.class)
public abstract class PlayerEntityMixin
{
@ModifyConstant(method = "getMaxNetherPortalTime",
constant = @Constant(intValue = 1))
private int addFillUpdatesInt(int original) {
if (CarpetSettings.portalCreativeDelay)
if (PortalHelper.player_holds_obsidian((PlayerEntity) (Object)this))
return 72000;
else
return 80;
return original;
public abstract class PlayerEntityMixin {
@Shadow
public PlayerAbilities abilities;
public int getMaxNetherPortalTime() {
return this.abilities.invulnerable ? CarpetSettings.portalCreativeDelay : CarpetSettings.portalSurvivalDelay;
}
}