Skip to content

Commit

Permalink
*casually ports an entire forge class*
Browse files Browse the repository at this point in the history
  • Loading branch information
RedstoneWizard08 committed Sep 27, 2024
1 parent 203d976 commit 84b942f
Show file tree
Hide file tree
Showing 18 changed files with 635 additions and 58 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"files.autoSave": "off",
"java.jdt.ls.java.home": "/usr/local/sdkman/candidates/java/current",
"java.import.gradle.java.home": "/usr/local/sdkman/candidates/java/current"
"java.import.gradle.java.home": "/usr/local/sdkman/candidates/java/current",
"java.configuration.updateBuildConfiguration": "automatic"
}
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ fun Project.setupRepositories() {
maven("https://maven.terraformersmc.com/releases/")
maven("https://raw.githubusercontent.com/Fuzss/modresources/main/maven/")
maven("https://maven.jamieswhiteshirt.com/libs-release")
maven("https://maven.shedaniel.me/")
}
}

Expand Down
2 changes: 2 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ dependencies {
modCompileOnly("net.fabricmc.fabric-api:fabric-api:${"fabric_api_version"()}")

annotationProcessor(implementation("io.github.llamalad7:mixinextras-common:${"mixin_extras_version"()}")!!)

modApi("dev.architectury:architectury:${"architectury_version"()}")
}

tasks.processResources {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package uwu.lopyluna.create_dd.access;

import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;

public interface AccessDyeColor {
default TagKey<Item> getTag() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import com.simibubi.create.content.processing.recipe.ProcessingRecipe;
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder.ProcessingRecipeParams;
import net.minecraft.world.level.Level;
import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.items.wrapper.RecipeWrapper;
import uwu.lopyluna.create_dd.registry.DesiresRecipeTypes;

import javax.annotation.ParametersAreNonnullByDefault;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
package uwu.lopyluna.create_dd.infrastructure.world;

import com.simibubi.create.infrastructure.worldgen.OreFeatureConfigEntry;

import dev.architectury.registry.registries.DeferredRegister;
import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import net.minecraftforge.common.world.BiomeModifier;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

import java.util.Map;

import static uwu.lopyluna.create_dd.Desires.MOD_ID;

public class DesireBuiltinRegistration {
private static final DeferredRegister<ConfiguredFeature<?, ?>> CONFIGURED_FEATURE_REGISTER = DeferredRegister.create(Registry.CONFIGURED_FEATURE_REGISTRY, MOD_ID);
private static final DeferredRegister<PlacedFeature> PLACED_FEATURE_REGISTER = DeferredRegister.create(Registry.PLACED_FEATURE_REGISTRY, MOD_ID);
private static final DeferredRegister<BiomeModifier> BIOME_MODIFIER_REGISTER = DeferredRegister.create(ForgeRegistries.Keys.BIOME_MODIFIERS, MOD_ID);
private static final DeferredRegister<ConfiguredFeature<?, ?>> CONFIGURED_FEATURE_REGISTER = DeferredRegister.create(MOD_ID, Registry.CONFIGURED_FEATURE_REGISTRY);
private static final DeferredRegister<PlacedFeature> PLACED_FEATURE_REGISTER = DeferredRegister.create(MOD_ID, Registry.PLACED_FEATURE_REGISTRY);
// private static final DeferredRegister<BiomeModifier> BIOME_MODIFIER_REGISTER = DeferredRegister.create(Registry.Keys.BIOME_MODIFIERS, MOD_ID);

static {
for (Map.Entry<ResourceLocation, OreFeatureConfigEntry> entry : OreFeatureConfigEntry.ALL.entrySet()) {
Expand All @@ -28,15 +26,15 @@ public class DesireBuiltinRegistration {
if (datagenExt != null) {
CONFIGURED_FEATURE_REGISTER.register(id.getPath(), () -> datagenExt.createConfiguredFeature(BuiltinRegistries.ACCESS));
PLACED_FEATURE_REGISTER.register(id.getPath(), () -> datagenExt.createPlacedFeature(BuiltinRegistries.ACCESS));
BIOME_MODIFIER_REGISTER.register(id.getPath(), () -> datagenExt.createBiomeModifier(BuiltinRegistries.ACCESS));
// BIOME_MODIFIER_REGISTER.register(id.getPath(), () -> datagenExt.createBiomeModifier(BuiltinRegistries.ACCESS)); // TODO
}
}
}
}

public static void register(IEventBus modEventBus) {
CONFIGURED_FEATURE_REGISTER.register(modEventBus);
PLACED_FEATURE_REGISTER.register(modEventBus);
BIOME_MODIFIER_REGISTER.register(modEventBus);
public static void register() {
CONFIGURED_FEATURE_REGISTER.register();
PLACED_FEATURE_REGISTER.register();
// BIOME_MODIFIER_REGISTER.register(modEventBus); // TODO
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

import com.simibubi.create.infrastructure.worldgen.LayeredOreFeature;
import com.simibubi.create.infrastructure.worldgen.StandardOreFeature;

import dev.architectury.registry.registries.DeferredRegister;
import dev.architectury.registry.registries.RegistrySupplier;
import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

import static uwu.lopyluna.create_dd.Desires.MOD_ID;

@SuppressWarnings("unused")
public class DesiresFeatures {
private static final DeferredRegister<Feature<?>> REGISTER = DeferredRegister.create(ForgeRegistries.FEATURES, MOD_ID);
private static final DeferredRegister<Feature<?>> REGISTER = DeferredRegister.create(MOD_ID, Registry.FEATURE_REGISTRY);

public static final RegistryObject<StandardOreFeature> STANDARD_ORE = REGISTER.register("standard_ore", StandardOreFeature::new);
public static final RegistryObject<LayeredOreFeature> LAYERED_ORE = REGISTER.register("layered_ore", LayeredOreFeature::new);
public static final RegistrySupplier<StandardOreFeature> STANDARD_ORE = REGISTER.register("standard_ore", StandardOreFeature::new);
public static final RegistrySupplier<LayeredOreFeature> LAYERED_ORE = REGISTER.register("layered_ore", LayeredOreFeature::new);

public static void register(IEventBus modEventBus) {
REGISTER.register(modEventBus);
public static void register() {
REGISTER.register();
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package uwu.lopyluna.create_dd.infrastructure.world;

import com.simibubi.create.infrastructure.worldgen.ConfigDrivenPlacement;

import dev.architectury.registry.registries.DeferredRegister;
import dev.architectury.registry.registries.RegistrySupplier;
import net.minecraft.core.Registry;
import net.minecraft.world.level.levelgen.placement.PlacementModifierType;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;

import static uwu.lopyluna.create_dd.Desires.MOD_ID;

public class DesiresPlacementModifiers {
private static final DeferredRegister<PlacementModifierType<?>> REGISTER = DeferredRegister.create(Registry.PLACEMENT_MODIFIER_REGISTRY, MOD_ID);
private static final DeferredRegister<PlacementModifierType<?>> REGISTER = DeferredRegister.create(MOD_ID, Registry.PLACEMENT_MODIFIER_REGISTRY);

public static final RegistryObject<PlacementModifierType<? extends ConfigDrivenPlacement>> CONFIG_DRIVEN = REGISTER.register("config_driven", () -> () -> CDrivenPlacement.CODEC);
public static final RegistrySupplier<PlacementModifierType<? extends ConfigDrivenPlacement>> CONFIG_DRIVEN = REGISTER.register("config_driven", () -> () -> CDrivenPlacement.CODEC);

public static void register(IEventBus modEventBus) {
REGISTER.register(modEventBus);
public static void register() {
REGISTER.register();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package uwu.lopyluna.create_dd.mixins;

import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.material.MaterialColor;
import uwu.lopyluna.create_dd.access.AccessDyeColor;

@Mixin(DyeColor.class)
public class MixinDyeColor implements AccessDyeColor {
@Shadow
@Final
private String name;
@Unique
private TagKey<Item> tag;

@Inject(method = "<init>", at = @At("TAIL"))
public void addTag(String woolId, int id, int color, String mapColor, int fireworkColor, MaterialColor signColor, int j, int k, CallbackInfo ci) {
tag = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation("c", name + "_dyes"));
}

@Override
public TagKey<Item> getTag() {
return tag;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import net.minecraft.world.level.material.MaterialColor;
import net.minecraftforge.client.model.generators.ConfiguredModel;
import net.minecraftforge.client.model.generators.ModelFile;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.util.ForgeSoundType;
import uwu.lopyluna.create_dd.Desires;
import uwu.lopyluna.create_dd.DesireUtil;
import uwu.lopyluna.create_dd.content.blocks.contraptions.bore_block.BoreBlock;
Expand Down Expand Up @@ -70,6 +68,7 @@
import uwu.lopyluna.create_dd.content.blocks.logistics.item_stockpile.ItemStockpileBlock;
import uwu.lopyluna.create_dd.content.blocks.logistics.item_stockpile.ItemStockpileCTBehaviour;
import uwu.lopyluna.create_dd.content.blocks.logistics.item_stockpile.ItemStockpileItem;
import uwu.lopyluna.create_dd.infrastructure.utility.ForgeTags;

import java.util.function.Consumer;

Expand Down Expand Up @@ -202,9 +201,9 @@ public class DesiresBlocks {
public static final BlockEntry<BoreBlock> BORE_BLOCK = REGISTRATE.block("bore_block", BoreBlock::new)
.initialProperties(SharedProperties::stone)
.properties(p -> p.color(MaterialColor.STONE))
.properties(p -> p.sound(new ForgeSoundType(0.9f, 1.25f, () -> SoundEvents.NETHERITE_BLOCK_BREAK,
() -> SoundEvents.NETHERITE_BLOCK_STEP, () -> SoundEvents.NETHERITE_BLOCK_PLACE,
() -> SoundEvents.NETHERITE_BLOCK_HIT, () -> SoundEvents.NETHERITE_BLOCK_FALL)))
.properties(p -> p.sound(new SoundType(0.9f, 1.25f, SoundEvents.NETHERITE_BLOCK_BREAK,
SoundEvents.NETHERITE_BLOCK_STEP, SoundEvents.NETHERITE_BLOCK_PLACE,
SoundEvents.NETHERITE_BLOCK_HIT, SoundEvents.NETHERITE_BLOCK_FALL)))
.onRegister(movementBehaviour(new BoreBlockMovementBehaviour()))
.transform(pickaxeOnly())
.recipe((c, p) -> {
Expand Down Expand Up @@ -504,9 +503,9 @@ public class DesiresBlocks {

ShapedRecipeBuilder.shaped(c.get(), 1)
.define('B', AllTags.forgeItemTag("plates/iron"))
.define('C', Tags.Items.BARRELS_WOODEN)
.define('C', ForgeTags.Items.BARRELS_WOODEN)
.pattern("BCB")
.unlockedBy("has_" + getItemName(Items.BARREL.asItem()), has(Tags.Items.BARRELS_WOODEN))
.unlockedBy("has_" + getItemName(Items.BARREL.asItem()), has(ForgeTags.Items.BARRELS_WOODEN))
.save(p, DesireUtil.asResource("crafting/kinetics/" + c.getName()));
})
.tab(() -> DesiresCreativeModeTabs.BASE_CREATIVE_TAB)
Expand All @@ -528,9 +527,9 @@ public class DesiresBlocks {

ShapedRecipeBuilder.shaped(c.get(), 1)
.define('B', AllTags.forgeItemTag("plates/copper"))
.define('C', Tags.Items.BARRELS_WOODEN)
.define('C', ForgeTags.Items.BARRELS_WOODEN)
.pattern("BCB")
.unlockedBy("has_" + getItemName(Items.BARREL.asItem()), has(Tags.Items.BARRELS_WOODEN))
.unlockedBy("has_" + getItemName(Items.BARREL.asItem()), has(ForgeTags.Items.BARRELS_WOODEN))
.save(p, DesireUtil.asResource("crafting/kinetics/" + c.getName()));
})
.tab(() -> DesiresCreativeModeTabs.BASE_CREATIVE_TAB)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
package uwu.lopyluna.create_dd.registry;

import net.minecraft.network.syncher.EntityDataSerializer;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import uwu.lopyluna.create_dd.Desires;


public class DesiresEntityDataSerializers {
private static final DeferredRegister<EntityDataSerializer<?>> REGISTER = DeferredRegister.create(ForgeRegistries.Keys.ENTITY_DATA_SERIALIZERS, Desires.MOD_ID);
// TODO - also, is this even used?
// private static final DeferredRegister<EntityDataSerializer<?>> REGISTER = DeferredRegister.create(Desires.MOD_ID, Registry.Keys.ENTITY_DATA_SERIALIZERS);

public static void register(IEventBus modEventBus) {
REGISTER.register(modEventBus);
}
// public static void register(IEventBus modEventBus) {
// REGISTER.register(modEventBus);
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
import net.minecraftforge.common.ForgeMod;
import net.minecraftforge.fluids.FluidInteractionRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidType;
import net.minecraftforge.fluids.ForgeFlowingFluid;
import org.jetbrains.annotations.NotNull;
import uwu.lopyluna.create_dd.infrastructure.config.DesiresConfigs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.ItemLike;
import net.minecraftforge.registries.ForgeRegistries;
import uwu.lopyluna.create_dd.Desires;
import uwu.lopyluna.create_dd.DesireUtil;
import uwu.lopyluna.create_dd.content.blocks.kinetics.modular_drill.ModularDrillHeadItem;
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/create_dd-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"MixinBlockFluidResBlock",
"MixinClutchBlock",
"MixinClutchBlockEntity",
"MixinDyeColor",
"MixinFluidPipeBlock",
"MixinFluidPropagator",
"MixinForgeHooks",
Expand Down
2 changes: 2 additions & 0 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ dependencies {
modLocalRuntime("maven.modrinth:lazydfu:${"lazydfu_version"()}")
modLocalRuntime("com.terraformersmc:modmenu:${"modmenu_version"()}")
modLocalRuntime("dev.emi:emi-fabric:${"emi_version"()}")

modApi("dev.architectury:architectury-fabric:${"architectury_version"()}")
}

operator fun String.invoke(): String {
Expand Down
2 changes: 2 additions & 0 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ dependencies {

compileOnly("io.github.llamalad7:mixinextras-common:${"mixin_extras_version"()}")
annotationProcessor(implementation(include("io.github.llamalad7:mixinextras-forge:${"mixin_extras_version"()}")!!)!!)

modApi("dev.architectury:architectury-forge:${"architectury_version"()}") { isTransitive = false }
}

operator fun String.invoke(): String {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ parchment_version = 2022.11.27

# Common
mixin_extras_version = 0.3.5
architectury_version = 6.6.92

# Dev QoL
fabric_recipe_viewer = emi
Expand Down

0 comments on commit 84b942f

Please sign in to comment.