Skip to content

Commit

Permalink
update to 24w46a
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsjo committed Nov 14, 2024
1 parent fc96cbf commit 5f4d8bc
Show file tree
Hide file tree
Showing 21 changed files with 152 additions and 87 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.21.3
loader_version=0.16.7
minecraft_version=24w46a
loader_version=0.16.9

# Mod Properties
mod_version = 1.2.0
Expand All @@ -14,5 +14,5 @@ archives_base_name = worldgenDevtools

# Dependencies
# check this on https://fabricmc.net/develop/
fabric_version=0.106.1+1.21.3
fabric_version=0.108.1+1.21.4

Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@ public JigsawBlockEntityRenderer(@SuppressWarnings("unused") BlockEntityRenderer
@Override
public void render(JigsawBlockEntity blockEntity, float partialTick, PoseStack poseStack, MultiBufferSource buffer, int packedLight, int packedOverlay) {

JigsawBlockEntityRenderer.render(blockEntity.getName(), blockEntity.getTarget(), blockEntity.getBlockState().getValue(JigsawBlock.ORIENTATION), poseStack, buffer, packedOverlay, false);
JigsawBlockEntityRenderer.render(blockEntity.getName(), blockEntity.getTarget(), blockEntity.getBlockState().getValue(JigsawBlock.ORIENTATION), poseStack, buffer, packedOverlay);
}

public static void render(ResourceLocation name, ResourceLocation target, FrontAndTop orientation, PoseStack poseStack, MultiBufferSource buffer, int packedOverlay, boolean renderEmpty) {
public static void render(ResourceLocation name, ResourceLocation target, FrontAndTop orientation, PoseStack poseStack, MultiBufferSource buffer, int packedOverlay) {
ResourceLocation location = name.equals(EMPTY_RESOURCE_LOCATION) ? target : name;

if (location.equals(EMPTY_RESOURCE_LOCATION)) {
if (renderEmpty){
render( 0xFFD7ACD7, orientation, poseStack, buffer, packedOverlay);
}
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.rendering.v1.BuiltinItemRendererRegistry;
import net.minecraft.client.color.item.ItemTintSources;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.world.item.Items;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.entity.BlockEntityType;
@Environment(EnvType.CLIENT)
public class JigsawBlockEntityRenderingClientInit implements ClientModInitializer {
@Override
public void onInitializeClient() {
BlockEntityRenderers.register(BlockEntityType.JIGSAW, JigsawBlockEntityRenderer::new);
BuiltinItemRendererRegistry.INSTANCE.register(Items.JIGSAW, new JigsawBlockItemRenderer());
ItemTintSources.ID_MAPPER.put(ResourceLocation.fromNamespaceAndPath("worldgendevtools", "jigsaw"), JigsawTintSource.MAP_CODEC );
}
}

This file was deleted.

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;
}
}

This file was deleted.

21 changes: 21 additions & 0 deletions src/client/resources/assets/minecraft/items/jigsaw.json
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
}
]
}
]
}
}
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 ]
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"mixins": [
],
"client": [
"GameMasterBlockItemMixin",
"ItemRendererMixin"
"GameMasterBlockItemMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.SectionPos;
import net.minecraft.resources.ResourceKey;
import net.minecraft.util.RandomSource;
import net.minecraft.util.profiling.Profiler;
import net.minecraft.util.profiling.Zone;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.StructureManager;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkAccess;
Expand Down Expand Up @@ -47,10 +49,10 @@ private boolean profilePlaceWithBiomeCheck(PlacedFeature placedFeature, WorldGen
@WrapMethod(
method = "tryGenerateStructure"
)
private boolean tryGenerateStructure(StructureSet.StructureSelectionEntry structureSelectionEntry, StructureManager structureManager, RegistryAccess registryAccess, RandomState random, StructureTemplateManager structureTemplateManager, long seed, ChunkAccess chunk, ChunkPos chunkPos, SectionPos sectionPos, Operation<Boolean> original){
private boolean tryGenerateStructure(StructureSet.StructureSelectionEntry structureSelectionEntry, StructureManager structureManager, RegistryAccess registryAccess, RandomState random, StructureTemplateManager structureTemplateManager, long seed, ChunkAccess chunk, ChunkPos chunkPos, SectionPos sectionPos, ResourceKey<Level> resourceKey, Operation<Boolean> original){
try (Zone zone = Profiler.get().zone("structure")) {
zone.addText(structureSelectionEntry.structure().getRegisteredName());
boolean result = original.call(structureSelectionEntry, structureManager, registryAccess, random, structureTemplateManager, seed, chunk, chunkPos, sectionPos);
boolean result = original.call(structureSelectionEntry, structureManager, registryAccess, random, structureTemplateManager, seed, chunk, chunkPos, sectionPos, resourceKey);
if (!result) {
zone.addText("(not placed)");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@Mixin(JfrProfiler.class)
public class JfrProfilerMixin {
@ModifyExpressionValue(method = "<clinit>", at = @At(value = "INVOKE", target = "Ljava/util/List;of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;"))
@ModifyExpressionValue(method = "<clinit>", at = @At(value = "INVOKE", target = "Ljava/util/List;of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;"))
private static List<Class<? extends Event>> addEvent(List<Class<? extends Event>> original){
return Stream.concat(original.stream(), Stream.of(FeatureGenerationEvent.class)).toList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelHeightAccessor;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSource;
Expand All @@ -29,7 +31,7 @@ public abstract class StructureMixin {
*/
@SuppressWarnings("DataFlowIssue")
@Inject(method = "generate", at = @At("RETURN"), cancellable = true)
public void generate(RegistryAccess registryAccess, ChunkGenerator chunkGenerator, BiomeSource biomeSource, RandomState randomState, StructureTemplateManager structureTemplateManager, long l, ChunkPos chunkPos, int i, LevelHeightAccessor levelHeightAccessor, Predicate<Holder<Biome>> predicate, CallbackInfoReturnable<StructureStart> cir) {
public void generate(Holder<Structure> holder, ResourceKey<Level> resourceKey, RegistryAccess registryAccess, ChunkGenerator chunkGenerator, BiomeSource biomeSource, RandomState randomState, StructureTemplateManager structureTemplateManager, long l, ChunkPos chunkPos, int i, LevelHeightAccessor levelHeightAccessor, Predicate<Holder<Biome>> predicate, CallbackInfoReturnable<StructureStart> cir) {
try {
Registry<Structure> registry = registryAccess.lookupOrThrow(Registries.STRUCTURE);
((HolderStructureStart) (Object) cir.getReturnValue()).worldgenDevtools$setHolder(registry.get(registry.getResourceKey((Structure) (Object) this).orElseThrow()).orElseThrow());
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"depends": {
"fabricloader": "*",
"fabric-api": "*",
"minecraft": ">=1.21.2- <1.21.4-",
"minecraft": ">=1.21.4- <1.21.5-",
"java": ">=21"
}
}
4 changes: 3 additions & 1 deletion src/main/resources/worldgendevtools.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ accessible field net/minecraft/world/level/Level dimensionTypeRegistration Lnet/
mutable field net/minecraft/world/level/Level dimensionTypeRegistration Lnet/minecraft/core/Holder;

accessible field net/minecraft/world/level/validation/DirectoryValidator symlinkTargetAllowList Ljava/nio/file/PathMatcher;
mutable field net/minecraft/world/level/validation/DirectoryValidator symlinkTargetAllowList Ljava/nio/file/PathMatcher;
mutable field net/minecraft/world/level/validation/DirectoryValidator symlinkTargetAllowList Ljava/nio/file/PathMatcher;

accessible field net/minecraft/client/color/item/ItemTintSources ID_MAPPER Lnet/minecraft/util/ExtraCodecs$LateBoundIdMapper;

0 comments on commit 5f4d8bc

Please sign in to comment.