Skip to content

Commit

Permalink
Move some of the loose classes into better places
Browse files Browse the repository at this point in the history
  • Loading branch information
Vazkii committed Jan 7, 2024
1 parent 66c3cb9 commit 71346c7
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 57 deletions.
55 changes: 0 additions & 55 deletions src/main/java/org/violetmoon/quark/QuarkRemapHandler.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.violetmoon.quark;
package org.violetmoon.quark.base.capability;

import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.violetmoon.quark.base.handler;

import net.minecraft.core.DefaultedRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.MissingMappingsEvent;
import org.violetmoon.quark.base.Quark;

import java.util.HashMap;
import java.util.Map;

@Mod.EventBusSubscriber
public class QuarkRemapHandler {
//datafixers could have also been used here but good luck figuring them out

private static final Map<String, String> REMAP = new HashMap<>();

static {
REMAP.put("quark:crafter", "minecraft:crafter");
REMAP.put("quark:polished_tuff", "minecraft:polished_tuff");
REMAP.put("quark:bamboo_planks_slab", "minecraft:bamboo_planks_slab");
REMAP.put("quark:bamboo_planks_stairs", "minecraft:bamboo_planks_stairs");
REMAP.put("quark:bamboo_fence", "minecraft:bamboo_fence");
REMAP.put("quark:bamboo_fence_gate", "minecraft:bamboo_fence_gate");
REMAP.put("quark:bamboo_door", "minecraft:bamboo_door");
REMAP.put("quark:bamboo_trapdoor", "minecraft:bamboo_trapdoor");
REMAP.put("quark:bamboo_button", "minecraft:bamboo_button");
REMAP.put("quark:bamboo_pressure_plate", "minecraft:bamboo_pressure_plate");
REMAP.put("quark:bamboo_bookshelf", "minecraft:bamboo_bookshelf");
REMAP.put("quark:bamboo_sign", "minecraft:bamboo_sign");
REMAP.put("quark:bamboo_mosaic", "minecraft:bamboo_mosaic");
REMAP.put("quark:bamboo_block", "minecraft:bamboo_block");
REMAP.put("quark:stripped_bamboo_block", "minecraft:stripped_bamboo_block");
}

@SubscribeEvent
public static void onRemapBlocks(MissingMappingsEvent event) {
remapAll(event, BuiltInRegistries.BLOCK);
remapAll(event, BuiltInRegistries.ITEM);
}


private static <T> void remapAll(MissingMappingsEvent event, DefaultedRegistry<T> block) {
for (var v : event.getMappings(block.key(), Quark.MOD_ID)) {
String rem = REMAP.get(v.getKey().toString());
if (rem != null) {
var b = block.getOptional(new ResourceLocation(rem));
b.ifPresent(v::remap);
} else v.ignore();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

import org.jetbrains.annotations.Nullable;
import org.violetmoon.quark.QuarkForgeCapabilities;
import org.violetmoon.quark.api.*;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.capability.CapabilityHandler;
import org.violetmoon.quark.base.capability.QuarkForgeCapabilities;
import org.violetmoon.quark.base.config.QuarkGeneralConfig;
import org.violetmoon.quark.base.handler.*;
import org.violetmoon.quark.base.network.QuarkNetwork;
Expand Down

0 comments on commit 71346c7

Please sign in to comment.