Skip to content

Commit

Permalink
feat: 1.16.5 backport
Browse files Browse the repository at this point in the history
  • Loading branch information
RubixDev committed Aug 20, 2023
1 parent d395643 commit ed54862
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 77 deletions.
22 changes: 1 addition & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ An extension for [gnembon's Carpet Mod](https://github.com/gnembon/fabric-carpet
- [`WORLD_UPDATES`](markdown/WORLD_UPDATES_Category.md)

## Index
Count: 35
Count: 33
- [announceAdvancements](#announceadvancements)
- [commandBlockOutput](#commandblockoutput)
- [disableElytraMovementCheck](#disableelytramovementcheck)
Expand All @@ -51,14 +51,12 @@ Count: 35
- [fallDamage](#falldamage)
- [fireDamage](#firedamage)
- [forgiveDeadPlayers](#forgivedeadplayers)
- [freezeDamage](#freezedamage)
- [keepInventory](#keepinventory)
- [logAdminCommands](#logadmincommands)
- [maxCommandChainLength](#maxcommandchainlength)
- [maxEntityCramming](#maxentitycramming)
- [mobGriefing](#mobgriefing)
- [naturalRegeneration](#naturalregeneration)
- [playersSleepingPercentage](#playerssleepingpercentage)
- [randomTickSpeed](#randomtickspeed)
- [reducedDebugInfo](#reduceddebuginfo)
- [sendCommandFeedback](#sendcommandfeedback)
Expand Down Expand Up @@ -249,15 +247,6 @@ Angered neutral mobs stop being angry when the targeted player dies nearby
- Required options: `true`, `false`
- Categories: `GAMERULE`, `MOBS`

### freezeDamage
Deal freeze damage

Whether the player should take damage when inside powder snow
- Type: `boolean`
- Default value: `true`
- Required options: `true`, `false`
- Categories: `GAMERULE`, `PLAYER`

### keepInventory
Keep inventory after death

Expand Down Expand Up @@ -316,15 +305,6 @@ Doesn't affect external healing, such as golden apples, the Regeneration effect,
- Required options: `true`, `false`
- Categories: `GAMERULE`, `PLAYER`

### playersSleepingPercentage
Sleep percentage

The percentage of players who must be sleeping to skip the night
- Type: `int`
- Default value: `100`
- Suggested options: `0`, `25`, `50`, `75`, `100`
- Categories: `GAMERULE`, `PLAYER`

### randomTickSpeed
Random tick speed rate

Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tasks.withType(JavaCompile).configureEach {
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"

it.options.release = 17
it.options.release = 16
}

java {
Expand All @@ -49,8 +49,8 @@ java {
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16
}

jar {
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ org.gradle.jvmargs=-Xmx2G

# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.4
minecraft_version=1.16.5
yarn_mappings=1.16.5+build.10
loader_version=0.14.22
# check available versions on maven for the given minecraft version you are using: https://masa.dy.fi/maven/carpet/fabric-carpet/
carpet_core_version=1.18.2-1.4.69+v220331
carpet_core_version=1.16.5-1.4.44+v210714

# Mod Properties
mod_version = 2.0.0
Expand All @@ -16,13 +16,13 @@ archives_base_name = carpetgamerules

# Release Action properties
mod_name = CarpetGamerules
minecraft_minimum_version = 1.18.2
minecraft_minimum_version = 1.16.5
curse_project_id = 504123
modrinth_project_id = BZjbriEM

release_curse_versions = Minecraft 1.18:1.18.2
release_modrinth_versions = 1.18.2
release_display_version = 1.18.2
release_curse_versions = Minecraft 1.16:1.16.5
release_modrinth_versions = 1.16.5
release_display_version = 1.16.5

release_extra_branch = false
release_extra_branch_name = 1.19
Expand Down
22 changes: 1 addition & 21 deletions markdown/PLAYER_Category.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

For a list of all implemented Rules go [here](../README.md)
## Index
Count: 12
Count: 10
- [disableElytraMovementCheck](#disableelytramovementcheck)
- [doImmediateRespawn](#doimmediaterespawn)
- [doLimitedCrafting](#dolimitedcrafting)
- [drowningDamage](#drowningdamage)
- [fallDamage](#falldamage)
- [fireDamage](#firedamage)
- [freezeDamage](#freezedamage)
- [keepInventory](#keepinventory)
- [naturalRegeneration](#naturalregeneration)
- [playersSleepingPercentage](#playerssleepingpercentage)
- [spawnRadius](#spawnradius)
- [spectatorsGenerateChunks](#spectatorsgeneratechunks)

Expand Down Expand Up @@ -72,15 +70,6 @@ Whether the player should take damage in fire, lava, campfires, or on magma bloc
- Required options: `true`, `false`
- Categories: `GAMERULE`, `PLAYER`

### freezeDamage
Deal freeze damage

Whether the player should take damage when inside powder snow
- Type: `boolean`
- Default value: `true`
- Required options: `true`, `false`
- Categories: `GAMERULE`, `PLAYER`

### keepInventory
Keep inventory after death

Expand All @@ -100,15 +89,6 @@ Doesn't affect external healing, such as golden apples, the Regeneration effect,
- Required options: `true`, `false`
- Categories: `GAMERULE`, `PLAYER`

### playersSleepingPercentage
Sleep percentage

The percentage of players who must be sleeping to skip the night
- Type: `int`
- Default value: `100`
- Suggested options: `0`, `25`, `50`, `75`, `100`
- Categories: `GAMERULE`, `PLAYER`

### spawnRadius
Respawn location radius

Expand Down
4 changes: 1 addition & 3 deletions markdown/curseforge.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Extension Mod for [gnembon's Carpet Mod](https://www.curseforge.com/minecraft/mc
**Visit the [GitHub page](https://github.com/RubixDev/CarpetGamerules) for a more detailed explanation.**

## List of Gamerules
Count: 35
Count: 33
- announceAdvancements
- commandBlockOutput
- disableElytraMovementCheck
Expand All @@ -26,14 +26,12 @@ Count: 35
- fallDamage
- fireDamage
- forgiveDeadPlayers
- freezeDamage
- keepInventory
- logAdminCommands
- maxCommandChainLength
- maxEntityCramming
- mobGriefing
- naturalRegeneration
- playersSleepingPercentage
- randomTickSpeed
- reducedDebugInfo
- sendCommandFeedback
Expand Down
4 changes: 1 addition & 3 deletions markdown/modrinth.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Extension for [gnembon's Carpet Mod](https://github.com/gnembon/fabric-carpet) t
**Visit the [GitHub page](https://github.com/RubixDev/CarpetGamerules) for a more detailed explanation.**

## List of Gamerules
Count: 35
Count: 33
- announceAdvancements
- commandBlockOutput
- disableElytraMovementCheck
Expand All @@ -26,14 +26,12 @@ Count: 35
- fallDamage
- fireDamage
- forgiveDeadPlayers
- freezeDamage
- keepInventory
- logAdminCommands
- maxCommandChainLength
- maxEntityCramming
- mobGriefing
- naturalRegeneration
- playersSleepingPercentage
- randomTickSpeed
- reducedDebugInfo
- sendCommandFeedback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import carpet.settings.ParsedRule;
import carpet.settings.Rule;
import carpet.settings.SettingsManager;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.context.ParsedArgument;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -14,6 +16,7 @@
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.metadata.ModMetadata;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.world.GameRules;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -123,7 +126,19 @@ private void updateGameruleValue(ParsedRule<?> carpetRule, GameRules.Key<?> key,
} else {
GameRules.IntRule gamerule =
(GameRules.IntRule) server.getGameRules().get(key);
gamerule.set((Integer) carpetRule.get(), server);
// the only public `set` method takes a command context, so we spoof one with just the relevant information
CommandContext<ServerCommandSource> context = new CommandContext<>(
server.getCommandSource(),
"",
Map.of("value", new ParsedArgument<>(0, 0, (Integer) carpetRule.get())),
null,
null,
null,
null,
null,
null,
false);
gamerule.set(context, "value");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,6 @@ public class CarpetGamerulesSettings {
category = {GAMERULE, MOBS})
public static boolean forgiveDeadPlayers = true;

@Rule(
desc = "Deal freeze damage",
extra = "Whether the player should take damage when inside powder snow",
category = {GAMERULE, PLAYER})
public static boolean freezeDamage = true;

@Rule(
desc = "Keep inventory after death",
extra = "Whether the player should keep items and experience in their inventory after death",
Expand Down Expand Up @@ -190,14 +184,6 @@ public class CarpetGamerulesSettings {
category = {GAMERULE, PLAYER})
public static boolean naturalRegeneration = true;

@Rule(
desc = "Sleep percentage",
extra = "The percentage of players who must be sleeping to skip the night",
category = {GAMERULE, PLAYER},
strict = false,
options = {"0", "25", "50", "75", "100"})
public static int playersSleepingPercentage = 100;

@Rule(
desc = "Random tick speed rate",
extra = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ private static <T extends GameRules.Rule<T>> void updateCarpetSetting(
.getRule(key.getName())
.set(
context.getSource(),
context.getSource().getServer().getGameRules().get(key).toString());
context.getSource()
.getMinecraftServer()
.getGameRules()
.get(key)
.toString());
}
}
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

"depends": {
"fabricloader": ">=0.14.22",
"carpet": ">=1.4.69",
"java": ">=17",
"minecraft": ">=1.18"
"carpet": ">=1.4.44",
"java": ">=16",
"minecraft": ">=1.16"
},
"suggests": {
},
Expand Down

0 comments on commit ed54862

Please sign in to comment.