Merge branch 'master' into 1.16
This commit is contained in:
commit
8a09fb55b2
8 files changed
+89
-543
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 = "Amount of delay ticks to use a nether portal in creative",
|
||||
options = {"1", "40", "80", "72000"},
|
||||
category = CREATIVE,
|
||||
strict = false,
|
||||
validate = OneHourMaxDelayLimit.class
|
||||
)
|
||||
public static boolean portalCreativeDelay = false;
|
||||
public static int portalCreativeDelay = 1;
|
||||
|
||||
@Rule(
|
||||
desc = "Amount of delay ticks to use a nether portal in survival",
|
||||
options = {"1", "40", "80", "72000"},
|
||||
category = SURVIVAL,
|
||||
strict = false,
|
||||
validate = OneHourMaxDelayLimit.class
|
||||
)
|
||||
public static int portalSurvivalDelay = 80;
|
||||
|
||||
private static class OneHourMaxDelayLimit 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;
|
||||
|
||||
@@ -53,7 +53,9 @@ public class PlayerCommand
|
||||
.then(makeActionCommand("jump", EntityPlayerActionPack.ActionType.JUMP))
|
||||
.then(makeActionCommand("attack", EntityPlayerActionPack.ActionType.ATTACK))
|
||||
.then(makeActionCommand("drop", EntityPlayerActionPack.ActionType.DROP_ITEM))
|
||||
.then(makeDropCommand("drop", false))
|
||||
.then(makeActionCommand("dropStack", EntityPlayerActionPack.ActionType.DROP_STACK))
|
||||
.then(makeDropCommand("dropStack", true))
|
||||
.then(makeActionCommand("swapHands", EntityPlayerActionPack.ActionType.SWAP_HANDS))
|
||||
.then(literal("kill").executes(PlayerCommand::kill))
|
||||
.then(literal("shadow"). executes(PlayerCommand::shadow))
|
||||
@@ -105,6 +107,19 @@ public class PlayerCommand
|
||||
.executes(c -> action(c, type, EntityPlayerActionPack.Action.interval(IntegerArgumentType.getInteger(c, "ticks"))))));
|
||||
}
|
||||
|
||||
private static LiteralArgumentBuilder<ServerCommandSource> makeDropCommand(String actionName, boolean dropAll)
|
||||
{
|
||||
return literal(actionName)
|
||||
.then(literal("all").executes(c ->manipulate(c, ap -> ap.drop(-2,dropAll))))
|
||||
.then(literal("mainhand").executes(c ->manipulate(c, ap -> ap.drop(-1,dropAll))))
|
||||
.then(literal("offhand").executes(c ->manipulate(c, ap -> ap.drop(40,dropAll))))
|
||||
.then(argument("slot", IntegerArgumentType.integer(0, 40)).
|
||||
executes(c ->manipulate(c, ap -> ap.drop(
|
||||
IntegerArgumentType.getInteger(c,"slot"),
|
||||
dropAll
|
||||
))));
|
||||
}
|
||||
|
||||
private static Collection<String> getPlayers(ServerCommandSource source)
|
||||
{
|
||||
Set<String> players = Sets.newLinkedHashSet(Arrays.asList("Steve", "Alex"));
|
||||
|
||||
@@ -4,6 +4,7 @@ import carpet.fakes.ServerPlayerEntityInterface;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.passive.HorseBaseEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.vehicle.BoatEntity;
|
||||
import net.minecraft.entity.vehicle.MinecartEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -222,6 +223,31 @@ public class EntityPlayerActionPack
|
||||
return Tracer.rayTrace(player, 1, reach, false);
|
||||
}
|
||||
|
||||
private void dropItemFromSlot(int slot, boolean dropAll)
|
||||
{
|
||||
PlayerInventory inv = player.inventory;
|
||||
if (!inv.getInvStack(slot).isEmpty())
|
||||
player.dropItem(inv.takeInvStack(slot,
|
||||
dropAll ? inv.getInvStack(slot).getCount() : 1
|
||||
), false, true); // scatter, keep owner
|
||||
}
|
||||
|
||||
public void drop(int selectedSlot, boolean dropAll)
|
||||
{
|
||||
PlayerInventory inv = player.inventory;
|
||||
if (selectedSlot == -2) // all
|
||||
{
|
||||
for (int i = inv.getInvSize(); i >= 0; i--)
|
||||
dropItemFromSlot(i, dropAll);
|
||||
}
|
||||
else // one slot
|
||||
{
|
||||
if (selectedSlot == -1)
|
||||
selectedSlot = inv.selectedSlot;
|
||||
dropItemFromSlot(selectedSlot, dropAll);
|
||||
}
|
||||
}
|
||||
|
||||
public enum ActionType
|
||||
{
|
||||
USE(true)
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package carpet.helpers;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.BlockItem;
|
||||
|
||||
public class PortalHelper
|
||||
{
|
||||
public static boolean player_holds_obsidian(PlayerEntity playerIn)
|
||||
{
|
||||
return (!playerIn.getMainHandStack().isEmpty()
|
||||
&& playerIn.getMainHandStack().getItem() instanceof BlockItem &&
|
||||
((BlockItem) (playerIn.getMainHandStack().getItem())).getBlock() == Blocks.OBSIDIAN);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.helpers.PortalHelper;
|
||||
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;
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.entity.player.PlayerAbilities;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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_portalDelayMixin
|
||||
{
|
||||
@Final @Shadow public PlayerAbilities abilities;
|
||||
|
||||
@Inject(method = "getMaxNetherPortalTime()I", at = @At("HEAD"), cancellable = true)
|
||||
private 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);
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@
|
||||
"EndCityFeatureMixin",
|
||||
|
||||
"InfestedBlockMixin",
|
||||
"PlayerEntityMixin",
|
||||
"PlayerEntityMixin_portalDelayMixin",
|
||||
|
||||
"PistonBlock_qcMixin",
|
||||
"DispenserBlock_qcMixin",
|
||||
|
||||
Reference in new issue
Block a user