diff --git a/README.md b/README.md index 89256be..410eba1 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Extension Mod for [gnembon's fabric-carpet](https://github.com/gnembon/fabric-ca ## Lists of Categories - [`BUGFIX`](markdown/BUGFIX_Category.md) - [`CLIENT`](markdown/CLIENT_Category.md) +- [`COMMAND`](markdown/COMMAND_Category.md) - [`CRAFTING`](markdown/CRAFTING_Category.md) - [`CREATIVE`](markdown/CREATIVE_Category.md) - [`EXPERIMENTAL`](markdown/EXPERIMENTAL_Category.md) @@ -20,12 +21,13 @@ Extension Mod for [gnembon's fabric-carpet](https://github.com/gnembon/fabric-ca - [`SURVIVAL`](markdown/SURVIVAL_Category.md) ## Index -Count: 64 +Count: 67 - [anvilledBlueIce](#anvilledblueice) - [anvilledIce](#anvilledice) - [anvilledPackedIce](#anvilledpackedice) - [cactusFurnaceXp](#cactusfurnacexp) - [campSleeping](#campsleeping) +- [commandSlimeChunk](#commandslimechunk) - [concreteConvertOnCauldron](#concreteconvertoncauldron) - [craftableCobwebs](#craftablecobwebs) - [craftableHorseArmor](#craftablehorsearmor) @@ -56,6 +58,7 @@ Count: 64 - [kelpBlockHardness](#kelpblockhardness) - [lilyPadsOnCauldron](#lilypadsoncauldron) - [longerRepeaters](#longerrepeaters) +- [maxBannerLayers](#maxbannerlayers) - [moreBarkCrafting](#morebarkcrafting) - [moreFortressSpawningBlocks](#morefortressspawningblocks) - [newShulkerBehavior](#newshulkerbehavior) @@ -77,6 +80,7 @@ Count: 64 - [snowballWaterDrag](#snowballwaterdrag) - [stonecutterDamage](#stonecutterdamage) - [strictShulkerShells](#strictshulkershells) +- [tallPlantNoUpdate](#tallplantnoupdate) - [universalDyeing](#universaldyeing) - [unpackableIce](#unpackableice) - [unpackableNetherWart](#unpackablenetherwart) @@ -135,6 +139,14 @@ Allows players to sleep in a Bed without setting their spawn point by entering w - Required options: `true`, `false` - Categories: `EXPERIMENTAL`, `FEATURE`, `RUG`, `SURVIVAL` +### commandSlimeChunk +A command that shows if the current chunk is a slime chunk based on the set slimeChunkPercentage +Players do not need extra permissions to use this command +- Type: `boolean` +- Default value: `false` +- Required options: `true`, `false` +- Categories: `COMMAND`, `RUG` + ### concreteConvertOnCauldron Concrete powder converts to concrete blocks when on top of a filled cauldron - Type: `boolean` @@ -175,7 +187,7 @@ Expect a lag spike when changing the value - Categories: `CRAFTING`, `RUG`, `SURVIVAL` ### dragonDrops -Ender Dragon drops an Elytra when killed +Ender Dragon drops selected item(s) when killed - Type: `String` - Default value: `none` - Required options: `none`, `dragon_egg`, `elytra`, `both` @@ -195,7 +207,7 @@ Amount of XP dropped by later Dragons. The first Dragon always drops 12000 - Type: `int` - Default value: `500` - Suggested options: `500`, `1200`, `12000` -- Categories: `CLIENT`, `EXPERIMENTAL`, `RUG` +- Categories: `EXPERIMENTAL`, `RUG`, `SURVIVAL` - Additional notes: - You must choose a value from 0 to 12000 - [Idea from Neubulae](https://github.com/gnembon/carpet-extra/issues/171) @@ -380,12 +392,23 @@ Lily Pads can be placed on Cauldrons - Categories: `FEATURE`, `RUG` ### longerRepeaters -Repeaters on top of Redstone BLocks multiply their delay by set amount +Repeaters on top of Redstone Blocks multiply their delay by set amount - Type: `int` - Default value: `1` - Required options: `1`, `2`, `3`, `4` - Categories: `EXPERIMENTAL`, `FEATURE`, `RUG` +### maxBannerLayers +Maximum number of layers, that can be applied to a banner +This only works for clients with this mod installed and the Banner tooltips never show more than 6 layers +- Type: `int` +- Default value: `6` +- Suggested options: `3`, `6`, `10`, `12` +- Categories: `CLIENT`, `CRAFTING`, `EXPERIMENTAL`, `RUG`, `SURVIVAL` +- Additional notes: + - You must choose a value from 3 to 16 + - [Idea from SouthernPixel](https://github.com/gnembon/carpet-extra/issues/111) + ### moreBarkCrafting Crafting Logs to Wood gives 4 instead of 3 Expect a lag spike when changing the value @@ -396,7 +419,7 @@ Expect a lag spike when changing the value ### moreFortressSpawningBlocks What blocks Fortress mobs can spawn on inside the bigger Bounding Box -o +off: nether bricks only / more: (red) nether bricks, netherrack, soul sand/soil, packed/blue ice, gravel, magma blocks / all: all - Type: `String` - Default value: `off` - Required options: `off`, `more`, `all` @@ -566,6 +589,14 @@ Shulkers always drop a given amount of shulker shells when killed - You must choose a value from 0 to 4 - Idea from [VanillaTweaks](https://vanillatweaks.net/picker/datapacks/) +### tallPlantNoUpdate +Tall Plants do not update blocks around the top part if the bottom half got broken +Old Bug: MC-31038 +- Type: `boolean` +- Default value: `false` +- Required options: `true`, `false` +- Categories: `EXPERIMENTAL`, `RUG` + ### universalDyeing Allows to dye already dyed things and clean Glass, Glass Panes and Terracotta with a Water Bucket in the Crafting Table Expect a lag spike when changing the value diff --git a/gradle.properties b/gradle.properties index 9f09807..71553a0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ org.gradle.jvmargs=-Xmx2G carpet_core_version=1.4.23+v210115 # Mod Properties - mod_version = 1.1.2 + mod_version = 1.1.3 maven_group = com.rubixdev.rug archives_base_name = fabric-rug diff --git a/markdown/CLIENT_Category.md b/markdown/CLIENT_Category.md index d248088..6af0361 100644 --- a/markdown/CLIENT_Category.md +++ b/markdown/CLIENT_Category.md @@ -3,7 +3,6 @@ For a list of all implemented Rules go [here](../README.md) ## Index Count: 11 -- [dragonXpDrop](#dragonxpdrop) - [edibleGoldIngots](#ediblegoldingots) - [edibleMagmaCream](#ediblemagmacream) - [edibleNetheriteScraps](#ediblenetheritescraps) @@ -12,21 +11,12 @@ Count: 11 - [enderPearlWaterDrag](#enderpearlwaterdrag) - [honeyCombStickiness](#honeycombstickiness) - [kelpBlockHardness](#kelpblockhardness) +- [maxBannerLayers](#maxbannerlayers) - [reachDistance](#reachdistance) - [snowballWaterDrag](#snowballwaterdrag) ## Rules in CLIENT Category -### dragonXpDrop -Amount of XP dropped by later Dragons. The first Dragon always drops 12000 -- Type: `int` -- Default value: `500` -- Suggested options: `500`, `1200`, `12000` -- Categories: `CLIENT`, `EXPERIMENTAL`, `RUG` -- Additional notes: - - You must choose a value from 0 to 12000 - - [Idea from Neubulae](https://github.com/gnembon/carpet-extra/issues/171) - ### edibleGoldIngots Butter is finally edible. Keep in mind 250g of pure butter are not that healthy Works server side only, but eating animation is only rendered if the mod is on the client too @@ -99,6 +89,17 @@ Any value other than 0 will behave like 0.5 for clients without this mod - Additional notes: - You must choose a value from 0 to 0.5 +### maxBannerLayers +Maximum number of layers, that can be applied to a banner +This only works for clients with this mod installed and the Banner tooltips never show more than 6 layers +- Type: `int` +- Default value: `6` +- Suggested options: `3`, `6`, `10`, `12` +- Categories: `CLIENT`, `CRAFTING`, `EXPERIMENTAL`, `RUG`, `SURVIVAL` +- Additional notes: + - You must choose a value from 3 to 16 + - [Idea from SouthernPixel](https://github.com/gnembon/carpet-extra/issues/111) + ### reachDistance Reach in which you can place and break blocks. Value will be 0.5 higher in creative Mod needed on server and client for this feature to work diff --git a/markdown/COMMAND_Category.md b/markdown/COMMAND_Category.md new file mode 100644 index 0000000..670efd5 --- /dev/null +++ b/markdown/COMMAND_Category.md @@ -0,0 +1,16 @@ +# List of Rules in the COMMAND Category + +For a list of all implemented Rules go [here](../README.md) +## Index +Count: 1 +- [commandSlimeChunk](#commandslimechunk) + +## Rules in COMMAND Category + +### commandSlimeChunk +A command that shows if the current chunk is a slime chunk based on the set slimeChunkPercentage +Players do not need extra permissions to use this command +- Type: `boolean` +- Default value: `false` +- Required options: `true`, `false` +- Categories: `COMMAND`, `RUG` diff --git a/markdown/CRAFTING_Category.md b/markdown/CRAFTING_Category.md index 6555472..9b32085 100644 --- a/markdown/CRAFTING_Category.md +++ b/markdown/CRAFTING_Category.md @@ -2,7 +2,7 @@ For a list of all implemented Rules go [here](../README.md) ## Index -Count: 21 +Count: 22 - [craftableCobwebs](#craftablecobwebs) - [craftableHorseArmor](#craftablehorsearmor) - [craftableNameTags](#craftablenametags) @@ -15,6 +15,7 @@ Count: 21 - [easyRepeaterCrafting](#easyrepeatercrafting) - [easyStickCrafting](#easystickcrafting) - [easyTrappedChestCrafting](#easytrappedchestcrafting) +- [maxBannerLayers](#maxbannerlayers) - [moreBarkCrafting](#morebarkcrafting) - [powderToGlassSmelting](#powdertoglasssmelting) - [shapelessCrafting](#shapelesscrafting) @@ -125,6 +126,17 @@ Expect a lag spike when changing the value - Required options: `true`, `false` - Categories: `CRAFTING`, `RUG`, `SURVIVAL` +### maxBannerLayers +Maximum number of layers, that can be applied to a banner +This only works for clients with this mod installed and the Banner tooltips never show more than 6 layers +- Type: `int` +- Default value: `6` +- Suggested options: `3`, `6`, `10`, `12` +- Categories: `CLIENT`, `CRAFTING`, `EXPERIMENTAL`, `RUG`, `SURVIVAL` +- Additional notes: + - You must choose a value from 3 to 16 + - [Idea from SouthernPixel](https://github.com/gnembon/carpet-extra/issues/111) + ### moreBarkCrafting Crafting Logs to Wood gives 4 instead of 3 Expect a lag spike when changing the value diff --git a/markdown/EXPERIMENTAL_Category.md b/markdown/EXPERIMENTAL_Category.md index 4060b68..4f26d50 100644 --- a/markdown/EXPERIMENTAL_Category.md +++ b/markdown/EXPERIMENTAL_Category.md @@ -2,7 +2,7 @@ For a list of all implemented Rules go [here](../README.md) ## Index -Count: 28 +Count: 30 - [anvilledBlueIce](#anvilledblueice) - [anvilledIce](#anvilledice) - [anvilledPackedIce](#anvilledpackedice) @@ -21,6 +21,7 @@ Count: 28 - [infinityNeedsArrow](#infinityneedsarrow) - [kelpBlockHardness](#kelpblockhardness) - [longerRepeaters](#longerrepeaters) +- [maxBannerLayers](#maxbannerlayers) - [moreFortressSpawningBlocks](#morefortressspawningblocks) - [newShulkerBehavior](#newshulkerbehavior) - [peacefulHunger](#peacefulhunger) @@ -30,6 +31,7 @@ Count: 28 - [silkTouchSpawners](#silktouchspawners) - [slimeChunkPercentage](#slimechunkpercentage) - [snowballWaterDrag](#snowballwaterdrag) +- [tallPlantNoUpdate](#tallplantnoupdate) - [zeroTickPlants](#zerotickplants) ## Rules in EXPERIMENTAL Category @@ -83,7 +85,7 @@ Amount of XP dropped by later Dragons. The first Dragon always drops 12000 - Type: `int` - Default value: `500` - Suggested options: `500`, `1200`, `12000` -- Categories: `CLIENT`, `EXPERIMENTAL`, `RUG` +- Categories: `EXPERIMENTAL`, `RUG`, `SURVIVAL` - Additional notes: - You must choose a value from 0 to 12000 - [Idea from Neubulae](https://github.com/gnembon/carpet-extra/issues/171) @@ -186,15 +188,26 @@ Any value other than 0 will behave like 0.5 for clients without this mod - You must choose a value from 0 to 0.5 ### longerRepeaters -Repeaters on top of Redstone BLocks multiply their delay by set amount +Repeaters on top of Redstone Blocks multiply their delay by set amount - Type: `int` - Default value: `1` - Required options: `1`, `2`, `3`, `4` - Categories: `EXPERIMENTAL`, `FEATURE`, `RUG` +### maxBannerLayers +Maximum number of layers, that can be applied to a banner +This only works for clients with this mod installed and the Banner tooltips never show more than 6 layers +- Type: `int` +- Default value: `6` +- Suggested options: `3`, `6`, `10`, `12` +- Categories: `CLIENT`, `CRAFTING`, `EXPERIMENTAL`, `RUG`, `SURVIVAL` +- Additional notes: + - You must choose a value from 3 to 16 + - [Idea from SouthernPixel](https://github.com/gnembon/carpet-extra/issues/111) + ### moreFortressSpawningBlocks What blocks Fortress mobs can spawn on inside the bigger Bounding Box -o +off: nether bricks only / more: (red) nether bricks, netherrack, soul sand/soil, packed/blue ice, gravel, magma blocks / all: all - Type: `String` - Default value: `off` - Required options: `off`, `more`, `all` @@ -270,6 +283,14 @@ Thrown Snowball will stutter on client when mod is only on server - Additional notes: - You must choose a value from 0.5 to 0.99 +### tallPlantNoUpdate +Tall Plants do not update blocks around the top part if the bottom half got broken +Old Bug: MC-31038 +- Type: `boolean` +- Default value: `false` +- Required options: `true`, `false` +- Categories: `EXPERIMENTAL`, `RUG` + ### zeroTickPlants Brings back the ability to force grow certain plants using 0-ticks - Type: `boolean` diff --git a/markdown/FEATURE_Category.md b/markdown/FEATURE_Category.md index 725edcf..73f1b5d 100644 --- a/markdown/FEATURE_Category.md +++ b/markdown/FEATURE_Category.md @@ -77,7 +77,7 @@ Concrete powder converts to concrete blocks when on top of a filled cauldron - Categories: `FEATURE`, `RUG` ### dragonDrops -Ender Dragon drops an Elytra when killed +Ender Dragon drops selected item(s) when killed - Type: `String` - Default value: `none` - Required options: `none`, `dragon_egg`, `elytra`, `both` @@ -169,7 +169,7 @@ Lily Pads can be placed on Cauldrons - Categories: `FEATURE`, `RUG` ### longerRepeaters -Repeaters on top of Redstone BLocks multiply their delay by set amount +Repeaters on top of Redstone Blocks multiply their delay by set amount - Type: `int` - Default value: `1` - Required options: `1`, `2`, `3`, `4` @@ -177,7 +177,7 @@ Repeaters on top of Redstone BLocks multiply their delay by set amount ### moreFortressSpawningBlocks What blocks Fortress mobs can spawn on inside the bigger Bounding Box -o +off: nether bricks only / more: (red) nether bricks, netherrack, soul sand/soil, packed/blue ice, gravel, magma blocks / all: all - Type: `String` - Default value: `off` - Required options: `off`, `more`, `all` diff --git a/markdown/SURVIVAL_Category.md b/markdown/SURVIVAL_Category.md index 642ff4c..daf498b 100644 --- a/markdown/SURVIVAL_Category.md +++ b/markdown/SURVIVAL_Category.md @@ -2,7 +2,7 @@ For a list of all implemented Rules go [here](../README.md) ## Index -Count: 46 +Count: 48 - [cactusFurnaceXp](#cactusfurnacexp) - [campSleeping](#campsleeping) - [craftableCobwebs](#craftablecobwebs) @@ -10,6 +10,7 @@ Count: 46 - [craftableNameTags](#craftablenametags) - [craftableNotchApple](#craftablenotchapple) - [dragonDrops](#dragondrops) +- [dragonXpDrop](#dragonxpdrop) - [easyBlueIceCrafting](#easyblueicecrafting) - [easyBoneBlockCrafting](#easyboneblockcrafting) - [easyChestCrafting](#easychestcrafting) @@ -27,6 +28,7 @@ Count: 46 - [foodInstantHeal](#foodinstantheal) - [infinityNeedsArrow](#infinityneedsarrow) - [kelpBlockHardness](#kelpblockhardness) +- [maxBannerLayers](#maxbannerlayers) - [moreBarkCrafting](#morebarkcrafting) - [noCreeperGriefing](#nocreepergriefing) - [noEndermanGriefing](#noendermangriefing) @@ -102,7 +104,7 @@ Expect a lag spike when changing the value - Categories: `CRAFTING`, `RUG`, `SURVIVAL` ### dragonDrops -Ender Dragon drops an Elytra when killed +Ender Dragon drops selected item(s) when killed - Type: `String` - Default value: `none` - Required options: `none`, `dragon_egg`, `elytra`, `both` @@ -110,6 +112,16 @@ Ender Dragon drops an Elytra when killed - Additional notes: - Idea from [VanillaTweaks](https://vanillatweaks.net/picker/datapacks/) +### dragonXpDrop +Amount of XP dropped by later Dragons. The first Dragon always drops 12000 +- Type: `int` +- Default value: `500` +- Suggested options: `500`, `1200`, `12000` +- Categories: `EXPERIMENTAL`, `RUG`, `SURVIVAL` +- Additional notes: + - You must choose a value from 0 to 12000 + - [Idea from Neubulae](https://github.com/gnembon/carpet-extra/issues/171) + ### easyBlueIceCrafting Blue Ice can be crafted from Ice and Blue Dye Expect a lag spike when changing the value @@ -252,6 +264,17 @@ Any value other than 0 will behave like 0.5 for clients without this mod - Additional notes: - You must choose a value from 0 to 0.5 +### maxBannerLayers +Maximum number of layers, that can be applied to a banner +This only works for clients with this mod installed and the Banner tooltips never show more than 6 layers +- Type: `int` +- Default value: `6` +- Suggested options: `3`, `6`, `10`, `12` +- Categories: `CLIENT`, `CRAFTING`, `EXPERIMENTAL`, `RUG`, `SURVIVAL` +- Additional notes: + - You must choose a value from 3 to 16 + - [Idea from SouthernPixel](https://github.com/gnembon/carpet-extra/issues/111) + ### moreBarkCrafting Crafting Logs to Wood gives 4 instead of 3 Expect a lag spike when changing the value diff --git a/src/main/java/com/rubixdev/rug/RugServer.java b/src/main/java/com/rubixdev/rug/RugServer.java index 65af20a..9edcf20 100644 --- a/src/main/java/com/rubixdev/rug/RugServer.java +++ b/src/main/java/com/rubixdev/rug/RugServer.java @@ -7,6 +7,8 @@ import com.google.common.base.CaseFormat; import com.google.common.collect.Lists; import com.google.gson.*; +import com.mojang.brigadier.CommandDispatcher; +import com.rubixdev.rug.commands.SlimeChunkCommand; import net.fabricmc.fabric.api.event.player.UseBlockCallback; import net.minecraft.block.*; import net.minecraft.item.BlockItem; @@ -16,6 +18,7 @@ import net.minecraft.resource.ResourcePackManager; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ReloadCommand; +import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.world.ServerWorld; import net.minecraft.state.property.IntProperty; import net.minecraft.util.ActionResult; @@ -49,6 +52,11 @@ public void onGameStarted() { CarpetServer.settingsManager.parseSettingsClass(RugSettings.class); } + @Override + public void registerCommands(CommandDispatcher dispatcher) { + SlimeChunkCommand.register(dispatcher); + } + @Override public void onServerLoaded(MinecraftServer server) { UseBlockCallback.EVENT.register(((player, world, hand, hitResult) -> { diff --git a/src/main/java/com/rubixdev/rug/RugSettings.java b/src/main/java/com/rubixdev/rug/RugSettings.java index ebdfcf5..52692ca 100644 --- a/src/main/java/com/rubixdev/rug/RugSettings.java +++ b/src/main/java/com/rubixdev/rug/RugSettings.java @@ -927,6 +927,45 @@ public String description() { ) public static int slimeChunkPercentage = 10; // slimeChunkPercentageAdditional: [Idea from Philipp766](https://github.com/gnembon/carpet-extra/issues/161) + + public static class validatorMaxBannerLayers extends Validator { + + @Override + public Integer validate(ServerCommandSource source, ParsedRule currentRule, Integer newValue, String string) { + return newValue >= 3 && newValue <= 16 ? newValue : null; + } + + @Override + public String description() { + return "You must choose a value from 3 to 16"; + } + } + + @Rule( + desc = "Maximum number of layers, that can be applied to a banner", + extra = "This only works for clients with this mod installed and the Banner tooltips never show more than 6 layers", + options = {"3", "6", "10", "12"}, + strict = false, + validate = validatorMaxBannerLayers.class, + category = {EXPERIMENTAL, SURVIVAL, CLIENT, CRAFTING, RUG} + ) + public static int maxBannerLayers = 6; + // maxBannerLayersAdditional: [Idea from SouthernPixel](https://github.com/gnembon/carpet-extra/issues/111) + + @Rule( + desc = "A command that shows if the current chunk is a slime chunk based on the set slimeChunkPercentage", + extra = "Players do not need extra permissions to use this command", + category = {COMMAND, RUG} + ) + public static boolean commandSlimeChunk = false; + + @Rule( + desc = "Tall Plants do not update blocks around the top part if the bottom half got broken", + extra = "Old Bug: MC-31038", + category = {EXPERIMENTAL, RUG} + ) + public static boolean tallPlantNoUpdate = false; + // Additional: [Idea from DragonEggBedrockBreaking](https://github.com/gnembon/carpet-extra/issues/185) } // BUGFIX diff --git a/src/main/java/com/rubixdev/rug/commands/SlimeChunkCommand.java b/src/main/java/com/rubixdev/rug/commands/SlimeChunkCommand.java new file mode 100644 index 0000000..c63c2a6 --- /dev/null +++ b/src/main/java/com/rubixdev/rug/commands/SlimeChunkCommand.java @@ -0,0 +1,29 @@ +package com.rubixdev.rug.commands; + +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.rubixdev.rug.RugSettings; +import net.minecraft.server.command.CommandManager; +import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.text.LiteralText; +import net.minecraft.util.Util; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.StructureWorldAccess; +import net.minecraft.world.gen.ChunkRandom; + +public class SlimeChunkCommand { + public static void register(CommandDispatcher dispatcher) { + LiteralArgumentBuilder command = CommandManager.literal("slimechunk"). + requires((player) -> RugSettings.commandSlimeChunk). + executes(c -> { + ServerPlayerEntity playerEntity = c.getSource().getPlayer(); + ChunkPos chunkPos = new ChunkPos(playerEntity.getBlockPos()); + StructureWorldAccess worldAccess = c.getSource().getWorld(); + boolean isSlimeChunk = ChunkRandom.getSlimeRandom(chunkPos.x, chunkPos.z, worldAccess.getSeed(), 987234911L).nextInt(10) < RugSettings.slimeChunkPercentage / 10; + playerEntity.sendSystemMessage(new LiteralText("You are " + (isSlimeChunk ? "" : "not ") + "in a Slime Chunk"), Util.NIL_UUID); + return 1; + }); + dispatcher.register(command); + } +} diff --git a/src/main/java/com/rubixdev/rug/mixins/AbsractBlockStateMixin.java b/src/main/java/com/rubixdev/rug/mixins/AbsractBlockStateMixin.java index e81aea6..4e02700 100644 --- a/src/main/java/com/rubixdev/rug/mixins/AbsractBlockStateMixin.java +++ b/src/main/java/com/rubixdev/rug/mixins/AbsractBlockStateMixin.java @@ -11,7 +11,7 @@ @Mixin(targets = {"net/minecraft/block/AbstractBlock$AbstractBlockState"}) public class AbsractBlockStateMixin { - @Inject(method = "getHardness", at = @At("HEAD"), cancellable = true) + @Inject(method = "getHardness(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)F", at = @At("HEAD"), cancellable = true) private void onGetHardness(BlockView world, BlockPos pos, CallbackInfoReturnable cir) { if (world.getBlockState(pos).getBlock().is(Blocks.DRIED_KELP_BLOCK)) { cir.setReturnValue((float) RugSettings.kelpBlockHardness); diff --git a/src/main/java/com/rubixdev/rug/mixins/FallingBlockMixin.java b/src/main/java/com/rubixdev/rug/mixins/FallingBlockMixin.java new file mode 100644 index 0000000..b76e894 --- /dev/null +++ b/src/main/java/com/rubixdev/rug/mixins/FallingBlockMixin.java @@ -0,0 +1,25 @@ +package com.rubixdev.rug.mixins; + +import com.rubixdev.rug.RugSettings; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.FallingBlock; +import net.minecraft.tag.BlockTags; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(FallingBlock.class) +public class FallingBlockMixin { + @Inject(method = "canFallThrough", at = @At("HEAD"), cancellable = true) + private static void onCanFallThrough(BlockState state, CallbackInfoReturnable cir) { + if (RugSettings.tallPlantNoUpdate && isTallPlant(state)) { + cir.setReturnValue(false); + } + } + + private static boolean isTallPlant(BlockState blockState) { + return blockState.isIn(BlockTags.TALL_FLOWERS) || blockState.isOf(Blocks.TALL_GRASS) || blockState.isOf(Blocks.LARGE_FERN); + } +} diff --git a/src/main/java/com/rubixdev/rug/mixins/HungerManagerMixin.java b/src/main/java/com/rubixdev/rug/mixins/HungerManagerMixin.java index 8a30c67..da6431c 100644 --- a/src/main/java/com/rubixdev/rug/mixins/HungerManagerMixin.java +++ b/src/main/java/com/rubixdev/rug/mixins/HungerManagerMixin.java @@ -1,12 +1,19 @@ package com.rubixdev.rug.mixins; import com.rubixdev.rug.RugSettings; +import com.rubixdev.rug.util.storage; import net.minecraft.entity.player.HungerManager; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.world.GameRules; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Objects; @Mixin(HungerManager.class) public class HungerManagerMixin { @@ -25,4 +32,12 @@ private boolean onUpdate(GameRules gameRules, GameRules.Key entityType, World world) { - super(entityType, world); - } +public class PlayerEntityMixin { @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getDifficulty()Lnet/minecraft/world/Difficulty;")) private Difficulty onTickMovement(World world) { - if (RugSettings.peacefulHunger) { - return Difficulty.PEACEFUL; - } else { - return world.getDifficulty(); - } + return RugSettings.peacefulHunger ? Difficulty.PEACEFUL : world.getDifficulty(); } @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/GameRules;getBoolean(Lnet/minecraft/world/GameRules$Key;)Z")) private boolean onTickMovement(GameRules gameRules, GameRules.Key rule) { - if (RugSettings.foodInstantHeal) { - return false; - } else { - return gameRules.getBoolean(rule); - } + return !RugSettings.foodInstantHeal && gameRules.getBoolean(rule); } - @Redirect(method = "eatFood", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/HungerManager;eat(Lnet/minecraft/item/Item;Lnet/minecraft/item/ItemStack;)V")) - private void onEatFood(HungerManager hungerManager, Item item, ItemStack stack) { - if (RugSettings.foodInstantHeal && item.isFood()) { - this.heal(Objects.requireNonNull(item.getFoodComponent()).getHunger()); - } else { - hungerManager.eat(item, stack); - } + @Inject(method = "eatFood", at = @At("HEAD")) + private void savePlayer(World world, ItemStack stack, CallbackInfoReturnable cir) { + storage.player = (PlayerEntity) (Object) this; } @Inject(method = "isUsingEffectiveTool", at = @At("HEAD"), cancellable = true) @@ -59,4 +40,9 @@ private void onIsUsingEffectiveTool(BlockState block, CallbackInfoReturnable type, WorldAccess world, S worldAccess = world; } - @ModifyVariable(method = "canSpawn", name = "bl", at = @At("STORE")) + @ModifyVariable(method = "canSpawn", at = @At("STORE"), ordinal = 0) private static boolean overwriteChance(boolean original) { ChunkPos chunkPos = new ChunkPos(blockPos); return ChunkRandom.getSlimeRandom(chunkPos.x, chunkPos.z, ((StructureWorldAccess)worldAccess).getSeed(), 987234911L).nextInt(10) < RugSettings.slimeChunkPercentage / 10; diff --git a/src/main/java/com/rubixdev/rug/mixins/WorldMixin.java b/src/main/java/com/rubixdev/rug/mixins/WorldMixin.java new file mode 100644 index 0000000..4ed454d --- /dev/null +++ b/src/main/java/com/rubixdev/rug/mixins/WorldMixin.java @@ -0,0 +1,54 @@ +package com.rubixdev.rug.mixins; + +import com.rubixdev.rug.RugSettings; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.TallPlantBlock; +import net.minecraft.block.enums.DoubleBlockHalf; +import net.minecraft.entity.Entity; +import net.minecraft.tag.BlockTags; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyConstant; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(World.class) +public abstract class WorldMixin { + @Shadow public abstract BlockState getBlockState(BlockPos pos); + + private boolean shouldOverwrite; + private boolean lowerWasFirst; + + @Inject(method = "breakBlock", at = @At("HEAD")) + private void testForBlock(BlockPos pos, boolean drop, Entity breakingEntity, int maxUpdateDepth, CallbackInfoReturnable cir) { + BlockState blockState = this.getBlockState(pos); + + boolean isUpperHalf = isTallPlant(blockState) && blockState.get(TallPlantBlock.HALF) == DoubleBlockHalf.UPPER; + boolean lowerWasFirst = this.lowerWasFirst; + this.lowerWasFirst = false; + + shouldOverwrite = isUpperHalf && lowerWasFirst && RugSettings.tallPlantNoUpdate; + } + + @ModifyConstant(method = "breakBlock", constant = @Constant(intValue = 3)) + private int overwriteFlags(int original) { + return shouldOverwrite ? 18 : original; + } + + @Inject(method = "removeBlock", at = @At("HEAD")) + private void saveIsCalled(BlockPos pos, boolean move, CallbackInfoReturnable cir) { + BlockState blockState = this.getBlockState(pos); + if (isTallPlant(blockState) && blockState.get(TallPlantBlock.HALF) == DoubleBlockHalf.LOWER) { + lowerWasFirst = true; + } + } + + private boolean isTallPlant(BlockState blockState) { + return blockState.isIn(BlockTags.TALL_FLOWERS) || blockState.isOf(Blocks.TALL_GRASS) || blockState.isOf(Blocks.LARGE_FERN); + } +} diff --git a/src/main/java/com/rubixdev/rug/util/storage.java b/src/main/java/com/rubixdev/rug/util/storage.java new file mode 100644 index 0000000..0381eb2 --- /dev/null +++ b/src/main/java/com/rubixdev/rug/util/storage.java @@ -0,0 +1,7 @@ +package com.rubixdev.rug.util; + +import net.minecraft.entity.player.PlayerEntity; + +public class storage { + public static PlayerEntity player; +} diff --git a/src/main/resources/rug.mixins.json b/src/main/resources/rug.mixins.json index 34ba95b..edf06db 100644 --- a/src/main/resources/rug.mixins.json +++ b/src/main/resources/rug.mixins.json @@ -23,6 +23,7 @@ "EndermanEntityMixin", "EnderPearlEntityMixin", "FallingBlockEntityMixin", + "FallingBlockMixin", "FishingBobberEntityMixin", "GhastEntityMixin", "HungerManagerMixin", @@ -30,6 +31,7 @@ "ItemsMixin", "LilyPadBlockMixin", "LivingEntityMixin", + "LoomScreenMixin", "MobSpawnerBlockEntityMixin", "NameTagItemMixin", "NetherPortalBlockMixin", @@ -45,7 +47,8 @@ "SpawnHelperMixin", "StoneCutterBlockMixin", "SugarCaneBlockMixin", - "ThrownEntityMixin" + "ThrownEntityMixin", + "WorldMixin" ], "client": [ ],