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;
|
||||
|
||||
@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,26 @@
|
||||
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;
|
||||
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)
|
||||
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;
|
||||
|
||||
@Inject(
|
||||
method = "getMaxNetherPortalTime()I",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
public void onMaxNetherPortalTime(CallbackInfoReturnable<Integer> cir) {
|
||||
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