Skip to content

Instantly share code, notes, and snippets.

@Commoble
Commoble / AnimationCodecs.java
Created July 3, 2022 22:05
Animation Codecs
package commoble.databuddy.codec;
import java.util.Map;
import com.google.common.collect.Lists;
import com.mojang.math.Vector3f;
import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
import com.mojang.serialization.codecs.RecordCodecBuilder;
@Commoble
Commoble / FeatureExampleMod.java
Created May 1, 2022 23:45
Registering and using configured/placed features in Forge for Minecraft 1.18.2
package commoble.featureexamplemod;
import java.util.List;
import net.minecraft.core.Registry;
import net.minecraft.data.worldgen.placement.PlacementUtils;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
@Commoble
Commoble / BiomeCheeserDatagen.java
Created April 17, 2022 18:59
Datagenerating worldgen registry jsons in forge for minecraft 1.18.2
package biomecheeser;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.gson.Gson;
@Commoble
Commoble / (configured)red_wool.json
Created February 20, 2022 17:18
Adding JSON placedfeatures to vanilla biomes from the BiomeLoadingEvent in Forge for Minecraft 1.18.1
data/sandbox/worldgen/configured_feature/red_wool.json
{
"config":
{
"state":
{
"Name": "minecraft:red_wool"
}
},
"type": "sandbox:single_block"
@Commoble
Commoble / RecipeDataProviders.java
Last active March 14, 2024 19:27
Recipe Data Providers Without Advancements
package commoble.tomeofrocks.datagen;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import com.google.gson.JsonObject;
import net.minecraft.data.CookingRecipeBuilder;
import net.minecraft.data.DataGenerator;
@Commoble
Commoble / BiomeAccessor.java
Last active May 1, 2021 01:25
Experimental DynamicRegistriesLoaded hook for minecraft forge
package commoble.dynamicregistrycheeser.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeGenerationSettings;
@Mixin(Biome.class)
public interface BiomeAccessor
@Commoble
Commoble / CookingRecipeDefinition.java
Created April 3, 2021 15:45
Cooking recipe codec for generating cooking recipe jsons for minecraft forge
/*
The MIT License (MIT)
Copyright (c) 2021 Joseph Bettendorff aka "Commoble"
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@Commoble
Commoble / RegistryDispatcher.java
Last active March 18, 2021 20:30
Using Dispatch Codecs with Forge Registries (with automatic registry factory)
package commoble.sandbox;
import java.util.function.Consumer;
import java.util.function.Supplier;
import com.mojang.serialization.Codec;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.IEventBus;
@Commoble
Commoble / StatePredicateSerializer.java
Last active March 17, 2021 02:01
Using Dispatch Codecs with Forge Registries
package commoble.sandbox;
import java.util.function.Predicate;
import java.util.function.Supplier;
import com.mojang.serialization.Codec;
import commoble.sandbox.StatePredicateSerializer.StatePredicate;
import net.minecraft.block.BlockState;
import net.minecraft.util.ResourceLocation;
@Commoble
Commoble / recordCodecBuilderBuilder.py
Last active August 4, 2021 21:24
RecordCodecBuilderBuilder
#usage:
#install python 3ish
#open cmd
#run `python.recordCodecBuilderBuilder.py`
#enter name of class, e.g. Thing
#enter fields one line at a time in the format
#FieldType field_name FieldType.CODEC
#java class is output to rcbb_Thing.txt
classTemplate = '''