Skip to content

Instantly share code, notes, and snippets.

@Commoble
Commoble / DynamicDimensionHelper.java
Last active April 6, 2024 12:16
Dynamic Dimensions and How to Go to Dimensions in Minecraft Forge 1.16.4
package commoble.hyperbox;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.function.BiFunction;
import java.util.function.Function;
import com.google.common.collect.ImmutableList;
import com.mojang.serialization.Lifecycle;
@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 / 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 / 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 / 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 / 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 / build.gradle
Last active January 15, 2024 06:05
How2ShadowJar in a minecraft forge mod's buildscript
// thanks to gigaherz for pointing me in the right directions on the buildscript
// The shadow gradle plugin assists with repackaging a 3rd-party library jar within your own jar
// In addition to ensuring that your end-users have the library available when they use your own thing,
// it also helps avoid collisions with other things that are also using the same library.
// As always, make sure the license of the library allows redistribution and is compatible with
// your own thing's license before redistributing it in this manner
buildscript {
@Commoble
Commoble / VoxelShapeGetters.java
Last active December 10, 2023 22:31
What's the difference between the different VoxelShape getters in forge for minecraft 1.16.4?
/**
AbstractBlock::getShape(BlockState, IBlockReader, BlockPos, ISelectionContext)
The primary shape for "selection" raytraces, like clicking a block.
Defaults to a full cube. Delegated to by AbstractBlockState::getShape(IBlockReader, BlockPos, ISelectionContext)
Most of the other shape getters either default to this or default to empty,
so just overriding this shape getter is sufficient if finer variations aren't needed.
AbstractBlock::getCollisionShape(BlockState, IBlockReader, BlockPos, ISelectionContext)
The primary shape for collision raytraces.
Delegated to by AbstractBlockState::getCollisionShape(IBlockReader, BlockPos, ISelectionContext)
@Commoble
Commoble / ThisIsHowYouMakeDimensionsInForgeForMinecraft14.java
Last active February 25, 2022 21:42
Custom Dimensions and How You Go In Them in Minecraft Forge 1.14 and 1.15
/**
WHAT ARE WE WORKING WITH
--Dimension, DimensionType, ServerWorld
-- There exists a 1:1:1 relationship between each of these, e.g. there will be one DimensionType instance
and one Dimension instance for a given ServerWorld, and those DimensionType and Dimension instances will only be
used on that worldserver
--ServerWorld
-- The server-specific version of the World, which holds all the block and chunk data, entities, tile entities, etc.\
for a given dimension. You won't be making these yourself or extending the class, but you'll need to find and use the
ServerWorld for your Dimension to teleport the player there.
@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"