Skip to content

Commit 3e15ab5

Browse files
committed
Release: 1.3.1 for Minecraft 1.20.6
- Fix block id compatibility. - Fix cherry leaves settings not being added to config file in Minecraft 1.19.4. - Block and item color now returns neon pink when tint is missing. - Add the ability to get specific version of mod by index (E.g. "1.2.3+4.5.6", index 0: 1.2.3, index 1: 4.5.6). - Improve mod patching. - Add the ability to apply snow layer logic to manually added blocks from config file (May work, depends on the mod).
1 parent 9e1c8b2 commit 3e15ab5

File tree

20 files changed

+213
-154
lines changed

20 files changed

+213
-154
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ In Bedrock Edition, there is an exclusive feature that turns some of the leaves
77
- Jungle leaves now have cocoa pods ([Podded Jungle Leaves](https://github.com/ishikyoo/podded-jungle-leaves)).
88
- Fully customisable, snow coverage, leaves colors and more can be tweaked.
99

10-
This branch support `Minecraft` versions from `1.21` and `1.21.1`.
10+
This branch support `Minecraft` versions from `1.19.4` to `1.20.6`.
1111

1212
## Installation
1313
You can install `Leavesly` by downloading it from the following:
@@ -16,7 +16,7 @@ You can install `Leavesly` by downloading it from the following:
1616
[![Modrinth Downloads](https://img.shields.io/modrinth/dt/leavesly?style=for-the-badge&logo=modrinth&color=00AD5B)](https://modrinth.com/mod/leavesly)
1717
[![CurseForge Downloads](https://img.shields.io/curseforge/dt/1109585?style=for-the-badge&logo=curseforge&color=F16436&)](https://www.curseforge.com/minecraft/mc-mods/leavesly)
1818

19-
Simply place the mod file `leavesly-1.3.0+1.21.1.jar` in your `.minecraft\mods` folder, and load Minecraft using [Fabric](https://fabricmc.net/use/installer) or [Quilt](https://quiltmc.org/en/install).
19+
Simply place the mod file `leavesly-1.3.1+1.20.6.jar` in your `.minecraft\mods` folder, and load Minecraft using [Fabric](https://fabricmc.net/use/installer) or [Quilt](https://quiltmc.org/en/install).
2020
You will need Fabric API or Quilted Fabric API.
2121

2222
You can also install it using [Prism Launcher](https://prismlauncher.org), or any other mod manager you like.

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ processResources {
3838
}
3939

4040
tasks.withType(JavaCompile).configureEach {
41-
it.options.release = 21
41+
it.options.release = 17
4242
}
4343

4444
java {
4545
withSourcesJar()
4646

47-
sourceCompatibility = JavaVersion.VERSION_21
48-
targetCompatibility = JavaVersion.VERSION_21
47+
sourceCompatibility = JavaVersion.VERSION_17
48+
targetCompatibility = JavaVersion.VERSION_17
4949
}
5050

5151
jar {

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ org.gradle.parallel=true
44

55
# Fabric Properties
66
# check these on https://fabricmc.net/develop
7-
minecraft_version=1.21.1
8-
yarn_mappings=1.21.1+build.3
7+
minecraft_version=1.20.6
8+
yarn_mappings=1.20.6+build.3
99
loader_version=0.16.10
1010

1111
# Mod Properties
12-
mod_version=1.3.0+1.21.1
12+
mod_version=1.3.1+1.20.6
1313
maven_group=com.ishikyoo.leavesly
1414
archives_base_name=leavesly
1515

1616
# Dependencies
17-
fabric_version=0.115.3+1.21.1
17+
fabric_version=0.100.8+1.20.6

src/main/java/com/ishikyoo/leavesly/LeaveslyColorProvider.java

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import com.ishikyoo.leavesly.block.Blocks;
44
import com.ishikyoo.leavesly.settings.*;
55
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
6-
import net.fabricmc.loader.api.FabricLoader;
7-
import net.fabricmc.loader.api.ModContainer;
86
import net.minecraft.block.Block;
97
import net.minecraft.block.BlockState;
108
import net.minecraft.client.MinecraftClient;
@@ -31,46 +29,55 @@ public class LeaveslyColorProvider {
3129
private static final HashMap<Identifier, Tint> modPatchBlockTintHashMap = new HashMap<>();
3230

3331
public static void initialize() {
34-
HashMap<Identifier, BlockData> blocks = LeaveslySettings.getSettings().getBlocks();
35-
for(Map.Entry<Identifier, BlockData> entry : blocks.entrySet()) {
36-
Identifier id = entry.getKey();
37-
register(id);
38-
}
32+
registerBlockAndItemsColors();
3933
applyModPatch();
4034
}
4135

4236
public static void register(Identifier id) {
43-
if (Blocks.isRegisteredBlockId(id)) {
37+
if (Blocks.isSupportedBlockId(id)) {
4438
BlockData blockData = LeaveslySettings.getSettings().getBlock(id);
4539
Tint tint = blockData.getTint();
4640
if (!registeredBlockIds.contains(id)) {
4741
Block block = Blocks.getBlock(id);
4842
ColorProviderRegistry.BLOCK.register(LeaveslyColorProvider::getColorProviderBlockColor, block);
4943
ColorProviderRegistry.ITEM.register(LeaveslyColorProvider::getColorProviderItemColor, block);
50-
LOG.info("Registered block and item color (Id: {}, Tint: {}).", id, tint.getColorType().toString().toLowerCase());
44+
LOG.info("Registered block and item colors (Id: {}, Tint: {}).", id, tint.getColorType().toString().toLowerCase());
5145
registeredBlockIds.add(id);
5246
} else {
53-
LOG.error("Trying to register a already registered block color (Id: {}, Tint: {}).", id, tint.getColorType().toString().toLowerCase());
47+
LOG.error("Trying to register a already registered block and item colors (Id: {}, Tint: {}).", id, tint.getColorType().toString().toLowerCase());
5448
}
5549
} else {
56-
LOG.error("Trying to register a block and item color for a unregistered block (Id: {}).", id);
50+
LOG.error("Trying to register a block and item colors for a unregistered block (Id: {}).", id);
51+
}
52+
}
53+
54+
private static void registerBlockAndItemsColors() {
55+
HashMap<Identifier, BlockData> blocks = LeaveslySettings.getSettings().getBlocks();
56+
for(Map.Entry<Identifier, BlockData> entry : blocks.entrySet()) {
57+
Identifier id = entry.getKey();
58+
register(id);
5759
}
5860
}
5961

6062
private static void applyModPatch() {
61-
LOG.info("Applying mod patch...");
63+
LOG.info("Registering mod patches...");
6264
//Clutter
63-
Optional<ModContainer> cutterMc = FabricLoader.getInstance().getModContainer("clutter");
64-
if (cutterMc.isPresent()) {
65-
modPatchBlockTintHashMap.put(Identifier.of("clutter:redwood_leaves"), Tint.FOLIAGE);
66-
modPatchBlockTintHashMap.put(Identifier.of("clutter:giant_fern"), Tint.GRASS);
67-
LOG.info("Applied mod patch for (modid: clutter).");
65+
String clutterId = "clutter";
66+
registerModBlockPatch(Identifier.of(clutterId, "redwood_leaves"), Tint.FOLIAGE);
67+
registerModBlockPatch(Identifier.of(clutterId, "giant_fern"), Tint.GRASS);
68+
}
69+
70+
private static void registerModBlockPatch(Identifier blockId, Tint tint) {
71+
LeaveslySettingsData settings = LeaveslySettings.getSettings();
72+
if (!settings.isRegisteredBlockId(blockId) && Blocks.isRegisteredBlockId(blockId)) {
73+
modPatchBlockTintHashMap.put(blockId, tint);
74+
LOG.info("Registered block and item colors mod patch (Id: {}, Tint: {}).", blockId, tint.getColorType().toString().toLowerCase());
6875
}
6976
}
7077

7178
private static int getColorProviderBlockColor(BlockState state, BlockRenderView world, BlockPos position, int index) {
7279
Block block = state.getBlock();
73-
if (Blocks.isRegisteredBlock(block)) {
80+
if (Blocks.isSupportedBlock(block)) {
7481
int snowLayer = state.get(SNOW_LAYER);
7582
int blockColor = getBlockColor(state, world, position);
7683
LeaveslySettingsData settings = LeaveslySettings.getSettings();
@@ -88,18 +95,18 @@ private static int getColorProviderBlockColor(BlockState state, BlockRenderView
8895
} else {
8996
if (isModPatchBlock(block))
9097
return getModPatchBlockColor(block, world, position);
91-
return 0;
98+
return Tint.NEON_PINK.getColorValue();
9299
}
93100
}
94101

95102
private static int getColorProviderItemColor(ItemStack stack, int index) {
96103
Block block = Block.getBlockFromItem(stack.getItem());
97-
if (Blocks.isRegisteredBlock(block)) {
104+
if (Blocks.isSupportedBlock(block)) {
98105
return getItemColor(block);
99106
} else {
100107
if (isModPatchBlock(block))
101108
return getModPatchItemColor(block);
102-
return 0;
109+
return Tint.NEON_PINK.getColorValue();
103110
}
104111
}
105112

@@ -108,24 +115,24 @@ private static int getBlockColor(BlockState state, BlockRenderView world, BlockP
108115
BlockData blockData = LeaveslySettings.getSettings().getBlock(Blocks.getBlockId(block));
109116
Tint tint = blockData.getTint();
110117
switch (tint.getColorType()) {
111-
case ColorType.STATIC:
118+
case STATIC:
112119
return tint.getColorValue();
113-
case ColorType.FOLIAGE:
120+
case FOLIAGE:
114121
switch (tint.getColorBlend()) {
115-
case ColorBlend.MULTIPLY:
122+
case MULTIPLY:
116123
return getMultiplyColor(BiomeColors.getFoliageColor(world, position), tint.getColorValue());
117-
case ColorBlend.SCREEN:
124+
case SCREEN:
118125
return getScreenColor(BiomeColors.getFoliageColor(world, position), tint.getColorValue());
119126
}
120-
case ColorType.GRASS:
127+
case GRASS:
121128
switch (tint.getColorBlend()) {
122-
case ColorBlend.MULTIPLY:
129+
case MULTIPLY:
123130
return getMultiplyColor(BiomeColors.getGrassColor(world, position), tint.getColorValue());
124-
case ColorBlend.SCREEN:
131+
case SCREEN:
125132
return getScreenColor(BiomeColors.getGrassColor(world, position), tint.getColorValue());
126133
}
127134
default:
128-
return 0;
135+
return Tint.NEON_PINK.getColorValue();
129136
}
130137
}
131138

@@ -150,7 +157,7 @@ private static int getItemColor(Block block) {
150157
return getScreenColor(Tint.DEFAULT_GRASS.getColorValue(), tint.getColorValue());
151158
}
152159
default:
153-
return 0;
160+
return Tint.NEON_PINK.getColorValue();
154161
}
155162
}
156163

@@ -174,7 +181,7 @@ private static int getModPatchBlockColor(Block block, BlockRenderView world, Blo
174181
return getScreenColor(BiomeColors.getGrassColor(world, position), tint.getColorValue());
175182
}
176183
default:
177-
return 0;
184+
return Tint.NEON_PINK.getColorValue();
178185
}
179186
}
180187

src/main/java/com/ishikyoo/leavesly/LeaveslyPreLaunch.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package com.ishikyoo.leavesly;
22

3+
import com.ishikyoo.leavesly.block.Blocks;
34
import com.ishikyoo.leavesly.settings.LeaveslySettings;
45
import com.ishikyoo.leavesly.support.Deobfuscator;
56
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
67

78
public class LeaveslyPreLaunch implements PreLaunchEntrypoint {
89
@Override
910
public void onPreLaunch() {
11+
Blocks.preInitialize();
1012
Deobfuscator.initialize();
1113
LeaveslySettings.preInitialize();
1214
}

src/main/java/com/ishikyoo/leavesly/SnowLayerLogic.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,11 @@ public static void randomTick(BlockState state, ServerWorld world, BlockPos pos,
118118
}
119119

120120
public static void setDefaultState(Block block, StateManager<Block, BlockState> stateManager) {
121-
if (Blocks.isSupportedVanillaBlockClassName(block.getClass().getName()))
122-
stateManager.getDefaultState().with(SNOW_LAYER, 0);
121+
stateManager.getDefaultState().with(SNOW_LAYER, 0);
123122
}
124123

125124
public static void appendProperties(Block block, StateManager.Builder<Block, BlockState> builder) {
126-
if (Blocks.isSupportedVanillaBlockClassName(block.getClass().getName()))
127-
builder.add(SNOW_LAYER);
125+
builder.add(SNOW_LAYER);
128126
}
129127

130128
private static double getNeighboursInfluence(ServerWorld world, BlockPos pos, int range) {
@@ -200,7 +198,7 @@ else if (Math.abs(z) > currentValue)
200198
}
201199

202200
private static boolean isSnowLayerBlock(BlockState state) {
203-
return Blocks.isRegisteredBlock(state.getBlock());
201+
return Blocks.isSupportedBlock(state.getBlock());
204202
}
205203

206204
private static void setBlockState(ServerWorld world, BlockPos pos, BlockState state, int value) {

0 commit comments

Comments
 (0)