-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
152 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
.../eu/jacobsjo/worldgendevtools/client/coloredjigsawblock/impl/JigsawBlockItemRenderer.java
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
...nt/java/eu/jacobsjo/worldgendevtools/client/coloredjigsawblock/impl/JigsawTintSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package eu.jacobsjo.worldgendevtools.client.coloredjigsawblock.impl; | ||
|
||
import com.mojang.serialization.DataResult; | ||
import com.mojang.serialization.MapCodec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.color.item.ItemTintSource; | ||
import net.minecraft.core.component.DataComponents; | ||
import net.minecraft.core.component.TypedDataComponent; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.ExtraCodecs; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.component.CustomData; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
@Environment(EnvType.CLIENT) | ||
public record JigsawTintSource(int defaultColor) implements ItemTintSource { | ||
private static final ResourceLocation EMPTY_RESOURCE_LOCATION = ResourceLocation.withDefaultNamespace("empty"); | ||
|
||
public static final MapCodec<JigsawTintSource> MAP_CODEC = RecordCodecBuilder.mapCodec( | ||
instance -> instance.group(ExtraCodecs.RGB_COLOR_CODEC.fieldOf("default").forGetter(JigsawTintSource::defaultColor)).apply(instance, JigsawTintSource::new) | ||
); | ||
|
||
@Override | ||
public int calculate(ItemStack stack) { | ||
TypedDataComponent<CustomData> blockEntityData = stack.getComponents().getTyped(DataComponents.BLOCK_ENTITY_DATA); | ||
if (blockEntityData == null) | ||
return this.defaultColor; | ||
|
||
DataResult<JigsawBlockData> dataResult = blockEntityData.value().read(JigsawBlockData.CODEC); | ||
if (dataResult.isError() || dataResult.result().isEmpty()) | ||
return this.defaultColor; | ||
|
||
JigsawBlockData data = dataResult.result().get(); | ||
|
||
ResourceLocation location = data.name().equals(EMPTY_RESOURCE_LOCATION) ? data.target() : data.name(); | ||
|
||
if (location.equals(EMPTY_RESOURCE_LOCATION)) { | ||
return this.defaultColor; | ||
} | ||
|
||
int hash = location.toString().hashCode(); | ||
int r = hash & 0xFF; | ||
int g = hash >> 8 & 0xFF; | ||
int b = hash >> 16 & 0xFF; | ||
|
||
return 0xFF000000 | r << 16 | g << 8 | b; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public MapCodec<JigsawTintSource> type() { | ||
return MAP_CODEC; | ||
} | ||
} | ||
|
35 changes: 0 additions & 35 deletions
35
.../java/eu/jacobsjo/worldgendevtools/client/coloredjigsawblock/mixin/ItemRendererMixin.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"model": { | ||
"type": "minecraft:composite", | ||
"models": [ | ||
{ | ||
"type": "minecraft:model", | ||
"model": "minecraft:block/jigsaw" | ||
}, | ||
{ | ||
"type": "minecraft:model", | ||
"model": "worldgendevtools:item/jigsaw_overlay", | ||
"tints": [ | ||
{ | ||
"type": "worldgendevtools:jigsaw", | ||
"default": 14134487 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
File renamed without changes
File renamed without changes
File renamed without changes
53 changes: 53 additions & 0 deletions
53
src/client/resources/assets/worldgendevtools/models/item/jigsaw_overlay.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"parent": "minecraft:block/block", | ||
"textures": { | ||
"side": "worldgendevtools:block/jigsaw_side_overlay", | ||
"top": "worldgendevtools:block/jigsaw_top_overlay", | ||
"lock": "worldgendevtools:block/jigsaw_lock_overlay" | ||
}, | ||
"elements": [ | ||
{ | ||
"from": [ 0, 0, 0 ], | ||
"to": [ 16, 16, 16 ], | ||
"faces": { | ||
"down": { "texture": "#side", "cullface": "down", "rotation": 180, "tintindex": 0 }, | ||
"up": { "texture": "#lock", "cullface": "up", "tintindex": 0 }, | ||
"north": { "texture": "#top", "cullface": "north", "tintindex": 0 }, | ||
"west": { "texture": "#side", "cullface": "west", "rotation": 270, "tintindex": 0 }, | ||
"east": { "texture": "#side", "cullface": "east", "rotation": 90, "tintindex": 0 } | ||
} | ||
} | ||
], | ||
"display": { | ||
"gui": { | ||
"rotation": [ 30, 225, 0 ], | ||
"translation": [ 0, 0, 0], | ||
"scale":[ 0.626, 0.626, 0.626 ] | ||
}, | ||
"ground": { | ||
"rotation": [ 0, 0, 0 ], | ||
"translation": [ 0, 3, 0], | ||
"scale":[ 0.251, 0.251, 0.251 ] | ||
}, | ||
"fixed": { | ||
"rotation": [ 0, 0, 0 ], | ||
"translation": [ 0, 0, 0], | ||
"scale":[ 0.501, 0.501, 0.501 ] | ||
}, | ||
"thirdperson_righthand": { | ||
"rotation": [ 75, 45, 0 ], | ||
"translation": [ 0, 2.5, 0], | ||
"scale": [ 0.376, 0.376, 0.376 ] | ||
}, | ||
"firstperson_righthand": { | ||
"rotation": [ 0, 45, 0 ], | ||
"translation": [ 0, 0, 0 ], | ||
"scale": [ 0.401, 0.401, 0.401 ] | ||
}, | ||
"firstperson_lefthand": { | ||
"rotation": [ 0, 225, 0 ], | ||
"translation": [ 0, 0, 0 ], | ||
"scale": [ 0.401, 0.401, 0.401 ] | ||
} | ||
} | ||
} |
Binary file added
BIN
+4.36 KB
...client/resources/assets/worldgendevtools/textures/block/jigsaw_lock_overlay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.51 KB
...client/resources/assets/worldgendevtools/textures/block/jigsaw_side_overlay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.57 KB
src/client/resources/assets/worldgendevtools/textures/block/jigsaw_top_overlay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters