From fe56ab8d3e6f6519c7cbf9e0ddd793106bd67148 Mon Sep 17 00:00:00 2001 From: ImUrX Date: Sat, 8 Feb 2020 16:18:56 -0300 Subject: [PATCH 1/9] overwrite getMaxNetherPortalTime --- src/main/java/carpet/CarpetSettings.java | 27 ++++++++++++++++--- .../java/carpet/mixins/PlayerEntityMixin.java | 22 ++++++--------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index b07f7195..26cc4c47 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -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 { + @Override public Integer validate(ServerCommandSource source, ParsedRule 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; diff --git a/src/main/java/carpet/mixins/PlayerEntityMixin.java b/src/main/java/carpet/mixins/PlayerEntityMixin.java index d72cddb8..e8a3292d 100644 --- a/src/main/java/carpet/mixins/PlayerEntityMixin.java +++ b/src/main/java/carpet/mixins/PlayerEntityMixin.java @@ -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; } } From a83088e685d03da0b6b456cacbeedd91f7c62ee5 Mon Sep 17 00:00:00 2001 From: ImUrX Date: Sat, 8 Feb 2020 16:49:39 -0300 Subject: [PATCH 2/9] use injections --- src/main/java/carpet/mixins/PlayerEntityMixin.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/carpet/mixins/PlayerEntityMixin.java b/src/main/java/carpet/mixins/PlayerEntityMixin.java index e8a3292d..698ffd5c 100644 --- a/src/main/java/carpet/mixins/PlayerEntityMixin.java +++ b/src/main/java/carpet/mixins/PlayerEntityMixin.java @@ -5,13 +5,22 @@ import net.minecraft.entity.player.PlayerAbilities; import net.minecraft.entity.player.PlayerEntity; 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 { @Shadow public PlayerAbilities abilities; - public int getMaxNetherPortalTime() { - return this.abilities.invulnerable ? CarpetSettings.portalCreativeDelay : CarpetSettings.portalSurvivalDelay; + @Inject( + method = "getMaxNetherPortalTime()I", + at = @At("HEAD"), + cancellable = true + ) + public void onMaxNetherPortalTime(CallbackInfoReturnable cir) { + if(CarpetSettings.portalCreativeDelay != 1) cir.setReturnValue(CarpetSettings.portalCreativeDelay); + else if(CarpetSettings.portalSurvivalDelay != 80) cir.setReturnValue(CarpetSettings.portalSurvivalDelay); } } From d13ae34b1ebd798b25cf087812c93ce42c4a5c7c Mon Sep 17 00:00:00 2001 From: ImUrX Date: Sat, 8 Feb 2020 16:50:55 -0300 Subject: [PATCH 3/9] forgot about invulnerable --- src/main/java/carpet/mixins/PlayerEntityMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/mixins/PlayerEntityMixin.java b/src/main/java/carpet/mixins/PlayerEntityMixin.java index 698ffd5c..a994d710 100644 --- a/src/main/java/carpet/mixins/PlayerEntityMixin.java +++ b/src/main/java/carpet/mixins/PlayerEntityMixin.java @@ -20,7 +20,7 @@ public abstract class PlayerEntityMixin { cancellable = true ) public void onMaxNetherPortalTime(CallbackInfoReturnable cir) { - if(CarpetSettings.portalCreativeDelay != 1) cir.setReturnValue(CarpetSettings.portalCreativeDelay); + if(CarpetSettings.portalCreativeDelay != 1 && this.abilities.invulnerable) cir.setReturnValue(CarpetSettings.portalCreativeDelay); else if(CarpetSettings.portalSurvivalDelay != 80) cir.setReturnValue(CarpetSettings.portalSurvivalDelay); } } From a44b4439bc1478261120d9a76399be41aca05070 Mon Sep 17 00:00:00 2001 From: ImUrX Date: Sat, 8 Feb 2020 16:51:56 -0300 Subject: [PATCH 4/9] in both sides... --- src/main/java/carpet/mixins/PlayerEntityMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/mixins/PlayerEntityMixin.java b/src/main/java/carpet/mixins/PlayerEntityMixin.java index a994d710..39c7ab56 100644 --- a/src/main/java/carpet/mixins/PlayerEntityMixin.java +++ b/src/main/java/carpet/mixins/PlayerEntityMixin.java @@ -21,6 +21,6 @@ public abstract class PlayerEntityMixin { ) public void onMaxNetherPortalTime(CallbackInfoReturnable cir) { if(CarpetSettings.portalCreativeDelay != 1 && this.abilities.invulnerable) cir.setReturnValue(CarpetSettings.portalCreativeDelay); - else if(CarpetSettings.portalSurvivalDelay != 80) cir.setReturnValue(CarpetSettings.portalSurvivalDelay); + else if(CarpetSettings.portalSurvivalDelay != 80 && !this.abilities.invulnerable) cir.setReturnValue(CarpetSettings.portalSurvivalDelay); } } From e63dd154336cfb21b3d5d144ca9d108127b62a3a Mon Sep 17 00:00:00 2001 From: gnembon Date: Sat, 8 Feb 2020 18:17:55 -0400 Subject: [PATCH 5/9] raneming --- src/main/java/carpet/CarpetSettings.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 26cc4c47..0110289c 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -50,24 +50,24 @@ public class CarpetSettings public static boolean superSecretSetting = false; @Rule( - desc = "Modify the amount of ticks for entering a Nether portal in creative", + desc = "Amount of delay ticks to use a nether portal in creative", options = {"1", "40", "80", "72000"}, category = CREATIVE, strict = false, - validate = NetherPortalDelayLimit.class + validate = OneHourMaxDelayLimit.class ) public static int portalCreativeDelay = 1; @Rule( - desc = "Modify the amount of ticks for entering a Nether portal in survival", + desc = "Amount of delay ticks to use a nether portal in survival", options = {"1", "40", "80", "72000"}, category = SURVIVAL, strict = false, - validate = NetherPortalDelayLimit.class + validate = OneHourMaxDelayLimit.class ) public static int portalSurvivalDelay = 80; - private static class NetherPortalDelayLimit extends Validator { + private static class OneHourMaxDelayLimit extends Validator { @Override public Integer validate(ServerCommandSource source, ParsedRule currentRule, Integer newValue, String string) { return (newValue > 0 && newValue <= 72000) ? newValue : null; } From dffaec7355a80daf90886a06193f15b6247fcc28 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sat, 8 Feb 2020 18:21:18 -0400 Subject: [PATCH 6/9] raneming --- ...va => PlayerEntityMixin_portalDelayMixin.java} | 15 ++++++--------- src/main/resources/carpet.mixins.json | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) rename src/main/java/carpet/mixins/{PlayerEntityMixin.java => PlayerEntityMixin_portalDelayMixin.java} (69%) diff --git a/src/main/java/carpet/mixins/PlayerEntityMixin.java b/src/main/java/carpet/mixins/PlayerEntityMixin_portalDelayMixin.java similarity index 69% rename from src/main/java/carpet/mixins/PlayerEntityMixin.java rename to src/main/java/carpet/mixins/PlayerEntityMixin_portalDelayMixin.java index 39c7ab56..b0102cb6 100644 --- a/src/main/java/carpet/mixins/PlayerEntityMixin.java +++ b/src/main/java/carpet/mixins/PlayerEntityMixin_portalDelayMixin.java @@ -3,6 +3,7 @@ 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; @@ -10,16 +11,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.At; @Mixin(PlayerEntity.class) -public abstract class PlayerEntityMixin { - @Shadow - public PlayerAbilities abilities; +public abstract class PlayerEntityMixin_portalDelayMixin +{ + @Final @Shadow public PlayerAbilities abilities; - @Inject( - method = "getMaxNetherPortalTime()I", - at = @At("HEAD"), - cancellable = true - ) - public void onMaxNetherPortalTime(CallbackInfoReturnable cir) { + @Inject(method = "getMaxNetherPortalTime()I", at = @At("HEAD"), cancellable = true) + private void onMaxNetherPortalTime(CallbackInfoReturnable cir) { if(CarpetSettings.portalCreativeDelay != 1 && this.abilities.invulnerable) cir.setReturnValue(CarpetSettings.portalCreativeDelay); else if(CarpetSettings.portalSurvivalDelay != 80 && !this.abilities.invulnerable) cir.setReturnValue(CarpetSettings.portalSurvivalDelay); } diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index 26935e54..5f60c74c 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -109,7 +109,7 @@ "EndCityFeatureMixin", "InfestedBlockMixin", - "PlayerEntityMixin", + "PlayerEntityMixin_portalDelayMixin", "PistonBlock_qcMixin", "DispenserBlock_qcMixin", From 8ed56c1d8149146c1cd669220328f52df7b88957 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sat, 8 Feb 2020 18:27:34 -0400 Subject: [PATCH 7/9] raneming --- src/main/java/carpet/helpers/PortalHelper.java | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 src/main/java/carpet/helpers/PortalHelper.java diff --git a/src/main/java/carpet/helpers/PortalHelper.java b/src/main/java/carpet/helpers/PortalHelper.java deleted file mode 100644 index baae0f66..00000000 --- a/src/main/java/carpet/helpers/PortalHelper.java +++ /dev/null @@ -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); - } -} From 80c6e0a13c7173bb4fd415e9b9d9f95c08e4a0ce Mon Sep 17 00:00:00 2001 From: gnembon <41132274+gnembon@users.noreply.github.com> Date: Sat, 8 Feb 2020 18:44:45 -0400 Subject: [PATCH 8/9] moved list of settings to the wiki --- README.md | 501 +----------------------------------------------------- 1 file changed, 1 insertion(+), 500 deletions(-) diff --git a/README.md b/README.md index cac52516..53a1d66d 100644 --- a/README.md +++ b/README.md @@ -8,503 +8,4 @@ Follow instructions for all other fabric mods in https://fabricmc.net/use/ and d with other compatible mods. # Carpet Mod Settings -## antiCheatDisabled -Prevents players from rubberbanding when moving too fast -... or being kicked out for 'flying' -Puts more trust in clients positioning -Increases player allowed mining distance to 32 blocks -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `CREATIVE`, `SURVIVAL` - -## carpets -Placing carpets may issue carpet commands for non-op players -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `SURVIVAL` - -## combineXPOrbs -XP orbs combine with other into bigger orbs -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `FEATURE` - -## commandCameramode -Enables /c and /s commands to quickly switch between camera and survival modes -/c and /s commands are available to all players regardless of their permission levels -* Type: `String` -* Default value: `true` -* Suggested options: `true`, `false` -* Categories: `COMMAND` -* Additional notes: - * It has an accompanying command - * Can be limited to 'ops' only, or a custom permission level - -## commandDistance -Enables /distance command to measure in game distance between points -Also enables brown carpet placement action if 'carpets' rule is turned on as well -* Type: `String` -* Default value: `true` -* Suggested options: `true`, `false` -* Categories: `COMMAND` -* Additional notes: - * It has an accompanying command - * Can be limited to 'ops' only, or a custom permission level - -## commandDraw -Enables /draw commands -... allows for drawing simple shapes -* Type: `String` -* Default value: `true` -* Suggested options: `true`, `false` -* Categories: `COMMAND` -* Additional notes: - * It has an accompanying command - * Can be limited to 'ops' only, or a custom permission level - -## commandInfo -Enables /info command for blocks -Also enables gray carpet placement action -if 'carpets' rule is turned on as well -* Type: `String` -* Default value: `true` -* Suggested options: `true`, `false` -* Categories: `COMMAND` -* Additional notes: - * It has an accompanying command - * Can be limited to 'ops' only, or a custom permission level - -## commandLog -Enables /log command to monitor events via chat and overlays -* Type: `String` -* Default value: `true` -* Suggested options: `true`, `false` -* Categories: `COMMAND` -* Additional notes: - * It has an accompanying command - * Can be limited to 'ops' only, or a custom permission level - -## commandPerimeterInfo -Enables /perimeterinfo command -... that scans the area around the block for potential spawnable spots -* Type: `String` -* Default value: `true` -* Suggested options: `true`, `false` -* Categories: `COMMAND` -* Additional notes: - * It has an accompanying command - * Can be limited to 'ops' only, or a custom permission level - -## commandPlayer -Enables /player command to control/spawn players -* Type: `String` -* Default value: `true` -* Suggested options: `true`, `false` -* Categories: `COMMAND` -* Additional notes: - * It has an accompanying command - * Can be limited to 'ops' only, or a custom permission level - -## commandScript -Enables /script command -An in-game scripting API for Scarpet programming language -* Type: `boolean` -* Default value: `true` -* Required options: `true`, `false` -* Categories: `COMMAND` -* Additional notes: - * It has an accompanying command - -## commandSpawn -Enables /spawn command for spawn tracking -* Type: `String` -* Default value: `true` -* Suggested options: `true`, `false` -* Categories: `COMMAND` -* Additional notes: - * It has an accompanying command - * Can be limited to 'ops' only, or a custom permission level - -## commandTick -Enables /tick command to control game clocks -* Type: `String` -* Default value: `true` -* Suggested options: `true`, `false` -* Categories: `COMMAND` -* Additional notes: - * It has an accompanying command - * Can be limited to 'ops' only, or a custom permission level - -## commandTrackAI -Allows to track mobs AI via /track command -* Type: `String` -* Default value: `true` -* Suggested options: `true`, `false` -* Categories: `COMMAND` -* Additional notes: - * It has an accompanying command - * Can be limited to 'ops' only, or a custom permission level - -## ctrlQCraftingFix -Dropping entire stacks works also from on the crafting UI result slot -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `BUGFIX`, `SURVIVAL` - -## customMOTD -Sets a different motd message on client trying to connect to the server -use '_' to use the startup setting from server.properties -* Type: `String` -* Default value: `_` -* Suggested options: `_` -* Categories: `CREATIVE` - -## defaultLoggers -sets these loggers in their default configurations for all new players -use csv, like 'tps,mobcaps' for multiple loggers, none for nothing -* Type: `String` -* Default value: `none` -* Suggested options: `none`, `tps`, `mobcaps,tps` -* Categories: `CREATIVE`, `SURVIVAL` - -## desertShrubs -Saplings turn into dead shrubs in hot climates and no water access -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `FEATURE` - -## disableSpawnChunks -Allows spawn chunks to unload -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `CREATIVE` - -## explosionNoBlockDamage -Explosions won't destroy blocks -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `CREATIVE`, `TNT` - -## extremeBehaviours -Edge cases are as frequent as common cases, for testing only!! -Dispensers and Droppers will use extreme random velocity values -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `CREATIVE` - -## fastRedstoneDust -Lag optimizations for redstone dust -by Theosib -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `EXPERIMENTAL`, `OPTIMIZATION` - -## fillLimit -Customizable fill/clone volume limit -* Type: `int` -* Default value: `32768` -* Suggested options: `32768`, `250000`, `1000000` -* Categories: `CREATIVE` -* Additional notes: - * You must choose a value from 1 to 20M - -## fillUpdates -fill/clone/setblock and structure blocks cause block updates -* Type: `boolean` -* Default value: `true` -* Required options: `true`, `false` -* Categories: `CREATIVE` - -## flatWorldStructureSpawning -Allows structure mobs to spawn in flat worlds -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `EXPERIMENTAL`, `CREATIVE` - -## flippinCactus -Players can flip and rotate blocks when holding cactus -Doesn't cause block updates when rotated/flipped -Applies to pistons, observers, droppers, repeaters, stairs, glazed terracotta etc... -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `CREATIVE`, `SURVIVAL`, `FEATURE` - -## hardcodeTNTangle -Sets the horizontal random angle on TNT for debugging of TNT contraptions -Set to -1 for default behavior -* Type: `double` -* Default value: `0.0` -* Suggested options: `-1` -* Categories: `TNT` -* Additional notes: - * Must be between 0 and 2pi, or -1 - -## hopperCounters -hoppers pointing to wool will count items passing through them -Enables /counter command, and actions while placing red and green carpets on wool blocks -Use /counter reset to reset the counter, and /counter to query -In survival, place green carpet on same color wool to query, red to reset the counters -Counters are global and shared between players, 16 channels available -Items counted are destroyed, count up to one stack per tick per hopper -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `COMMAND`, `CREATIVE`, `FEATURE` -* Additional notes: - * It has an accompanying command - -## huskSpawningInTemples -Only husks spawn in desert temples -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `FEATURE` - -## lagFreeSpawning -Spawning requires much less CPU and Memory -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `OPTIMIZATION` - -## leadFix -Fixes leads breaking/becoming invisible in unloaded chunks -You may still get visibly broken leash links on the client side, but server side the link is still there. -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `BUGFIX` - -## maxEntityCollisions -Customizable maximal entity collision limits, 0 for no limits -* Type: `int` -* Default value: `0` -* Suggested options: `0`, `1`, `20` -* Categories: `OPTIMIZATION` -* Additional notes: - * Must be a positive number - -## mergeTNT -Merges stationary primed TNT entities -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `TNT` - -## missingTools -Pistons, Glass and Sponge can be broken faster with their appropriate tools -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `SURVIVAL` - -## movableBlockEntities -Pistons can push block entities, like hoppers, chests etc. -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `EXPERIMENTAL`, `FEATURE` - -## onePlayerSleeping -One player is required on the server to cause night to pass -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `SURVIVAL` - -## optimizedTNT -TNT causes less lag when exploding in the same spot and in liquids -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `TNT` - -## persistentParrots -Parrots don't get of your shoulders until you receive proper damage -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `SURVIVAL`, `FEATURE` - -## placementRotationFix -fixes block placement rotation issue when player rotates quickly while placing blocks -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `BUGFIX` - -## portalCreativeDelay -Portals won't let a creative player go through instantly -Holding obsidian in either hand won't let you through at all -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `CREATIVE` - -## portalSuffocationFix -Nether portals correctly place entities going through -Entities shouldn't suffocate in obsidian -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `BUGFIX` - -## pushLimit -Customizable piston push limit -* Type: `int` -* Default value: `12` -* Suggested options: `10`, `12`, `14`, `100` -* Categories: `CREATIVE` -* Additional notes: - * You must choose a value from 1 to 1024 - -## quasiConnectivity -Pistons, droppers and dispensers react if block above them is powered -* Type: `boolean` -* Default value: `true` -* Required options: `true`, `false` -* Categories: `CREATIVE` - -## railPowerLimit -Customizable powered rail power range -* Type: `int` -* Default value: `9` -* Suggested options: `9`, `15`, `30` -* Categories: `CREATIVE` -* Additional notes: - * You must choose a value from 1 to 1024 - -## renewableCoral -Coral structures will grow with bonemeal from coral plants -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `FEATURE` - -## renewableSponges -Guardians turn into Elder Guardian when struck by lightning -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `FEATURE` - -## rotatorBlock -Cactus in dispensers rotates blocks. -Rotates block anti-clockwise if possible -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `FEATURE`, `DISPENSER` - -## scriptsAutoload -Scarpet script from world files will autoload on server/world start -if /script is enabled -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `CREATIVE` - -## shulkerSpawningInEndCities -Shulkers will respawn in end cities -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `FEATURE` - -## silverFishDropGravel -Silverfish drop a gravel item when breaking out of a block -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `FEATURE` - -## smoothClientAnimations -smooth client animations with low tps settings -works only in SP, and will slow down players -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `CREATIVE` - -## stackableShulkerBoxes -Empty shulker boxes can stack to 64 when dropped on the ground -To move them around between inventories, use shift click to move entire stacks -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `SURVIVAL`, `FEATURE` - -## summonNaturalLightning -summoning a lightning bolt has all the side effects of natural lightning -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `CREATIVE` - -## superSecretSetting -Gbhs sgnf sadsgras fhskdpri! -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `EXPERIMENTAL` - -## tntDoNotUpdate -TNT doesn't update when placed against a power source -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `CREATIVE`, `TNT` - -## tntPrimerMomentumRemoved -Removes random TNT momentum when primed -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `CREATIVE`, `TNT` - -## tntRandomRange -Sets the tnt random explosion range to a fixed value -Set to -1 for default behavior -* Type: `double` -* Default value: `-1.0` -* Suggested options: `-1` -* Categories: `TNT` -* Additional notes: - * optimizedTNT must be enabled - * Cannot be negative, except for -1 - -## unloadedEntityFix -Entities pushed or moved into unloaded chunks no longer disappear -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `EXPERIMENTAL`, `BUGFIX` - -## viewDistance -Changes the view distance of the server. -Set to 0 to not override the value in server settings. -* Type: `int` -* Default value: `0` -* Suggested options: `0`, `12`, `16`, `32` -* Categories: `CREATIVE` -* Additional notes: - * You must choose a value from 0 (use server settings) to 32 - -## xpNoCooldown -Players absorb XP instantly, without delay -* Type: `boolean` -* Default value: `false` -* Required options: `true`, `false` -* Categories: `CREATIVE` - +See [List of all currently available settings](https://github.com/gnembon/fabric-carpet/wiki/Current-Available-Settings) on the wiki From 161b5d491db44808f9aaa089d42ebbd4496651fd Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 9 Feb 2020 01:56:30 -0400 Subject: [PATCH 9/9] added options for drop command --- .../java/carpet/commands/PlayerCommand.java | 15 +++++++++++ .../helpers/EntityPlayerActionPack.java | 26 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/main/java/carpet/commands/PlayerCommand.java b/src/main/java/carpet/commands/PlayerCommand.java index 47c63e59..4440efb4 100644 --- a/src/main/java/carpet/commands/PlayerCommand.java +++ b/src/main/java/carpet/commands/PlayerCommand.java @@ -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 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 getPlayers(ServerCommandSource source) { Set players = Sets.newLinkedHashSet(Arrays.asList("Steve", "Alex")); diff --git a/src/main/java/carpet/helpers/EntityPlayerActionPack.java b/src/main/java/carpet/helpers/EntityPlayerActionPack.java index 0b0d2d1f..6d6b4670 100644 --- a/src/main/java/carpet/helpers/EntityPlayerActionPack.java +++ b/src/main/java/carpet/helpers/EntityPlayerActionPack.java @@ -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)