Merge pull request #142 from ImUrX/betterNetherDelays
make the nether portal delays better, fixes #139
This commit is contained in:
commit
13a8fbb6f2
2 files changed
+40
-18
No files matched your search
@@ -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,26 @@
|
|||||||
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;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
|
||||||
@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) {
|
@Inject(
|
||||||
if (CarpetSettings.portalCreativeDelay)
|
method = "getMaxNetherPortalTime()I",
|
||||||
if (PortalHelper.player_holds_obsidian((PlayerEntity) (Object)this))
|
at = @At("HEAD"),
|
||||||
return 72000;
|
cancellable = true
|
||||||
else
|
)
|
||||||
return 80;
|
public void onMaxNetherPortalTime(CallbackInfoReturnable<Integer> cir) {
|
||||||
return original;
|
if(CarpetSettings.portalCreativeDelay != 1 && this.abilities.invulnerable) cir.setReturnValue(CarpetSettings.portalCreativeDelay);
|
||||||
|
else if(CarpetSettings.portalSurvivalDelay != 80 && !this.abilities.invulnerable) cir.setReturnValue(CarpetSettings.portalSurvivalDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user