Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ bin/
# fabric

run/

.omc/
104 changes: 33 additions & 71 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,94 +1,56 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'maven-publish'
id 'java'
id 'net.neoforged.moddev' version '2.0.142'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
base {
archivesName = project.archives_base_name
}

repositories {
maven {
url "https://maven.shedaniel.me/"
}
maven {
name = 'terraformers maven'
url "https://maven.terraformersmc.com/releases"
}
java {
toolchain.languageVersion = JavaLanguageVersion.of(21)
}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
repositories {
maven { url = 'https://maven.shedaniel.me/' }
}

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
neoForge {
version = project.neoforge_version

modApi("me.shedaniel.cloth:cloth-config-fabric:${project.clothconfig_version}") {
exclude(group: "net.fabricmc.fabric-api")
mods {
inventorytabs {
sourceSet sourceSets.main
}
}

modCompileOnly("com.terraformersmc:modmenu:${project.modmenu_version}") {
transitive = false
}
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
runs {
client {
client()
}
}
}

processResources {
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
}
dependencies {
implementation "me.shedaniel.cloth:cloth-config-neoforge:${project.cloth_config_version}"
}

tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"

// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
options.encoding = 'UTF-8'
options.release = 21
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
processResources {
def props = [version: project.version]
inputs.properties props
filesMatching('META-INF/neoforge.mods.toml') {
expand props
}
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}

loom {
accessWidenerPath = file("src/main/resources/inventorytabs.accesswidener")
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
from('LICENSE')
}
22 changes: 8 additions & 14 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.1
loader_version=0.14.19
# Gradle
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true

# Mod Properties
mod_version = 0.9.1-1.19.4-beta
maven_group = com.kqp
archives_base_name = inventorytabs
mod_version=0.9.1-1.21.1-neoforge
maven_group=com.kqp
archives_base_name=inventorytabs

# Dependencies
fabric_version=0.77.0+1.19.4
clothconfig_version=10.0.96
modmenu_version=6.1.0-rc.4
neoforge_version=21.1.242
cloth_config_version=15.0.140
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
8 changes: 3 additions & 5 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
pluginManagement {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
gradlePluginPortal()
maven { url = 'https://maven.neoforged.net/releases' }
}
}

rootProject.name = 'inventorytabs'
65 changes: 34 additions & 31 deletions src/main/java/com/kqp/inventorytabs/api/TabProviderRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import com.kqp.inventorytabs.init.InventoryTabs;
import com.kqp.inventorytabs.interf.TabManagerContainer;
import com.kqp.inventorytabs.tabs.provider.*;
import net.minecraft.block.*;
import net.minecraft.client.MinecraftClient;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;

import net.minecraft.client.Minecraft;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.piston.MovingPistonBlock;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand All @@ -19,7 +22,7 @@
*/
public class TabProviderRegistry {
private static final Logger LOGGER = LogManager.getLogger("InventoryTabs");
private static final Map<Identifier, TabProvider> TAB_PROVIDERS = new HashMap<>();
private static final Map<ResourceLocation, TabProvider> TAB_PROVIDERS = new HashMap<>();

public static final PlayerInventoryTabProvider PLAYER_INVENTORY_TAB_PROVIDER = (PlayerInventoryTabProvider) register(
InventoryTabs.id("player_inventory_tab_provider"), new PlayerInventoryTabProvider());
Expand Down Expand Up @@ -55,11 +58,11 @@ public static void init(String configMsg) {
blockSet.add(overrideEntry);
}
}
Registries.BLOCK.forEach(block -> {
if (block instanceof BlockEntityProvider) {
BuiltInRegistries.BLOCK.forEach(block -> {
if (block instanceof EntityBlock) {
if (block instanceof AbstractChestBlock) {
registerChest(block);
} else if (!(block instanceof AbstractBannerBlock) && !(block instanceof AbstractSignBlock) && !(block instanceof AbstractSkullBlock) && !(block instanceof BeehiveBlock) && !(block instanceof BedBlock) && !(block instanceof BellBlock) && !(block instanceof CampfireBlock) && !(block instanceof CommandBlock) && !(block instanceof ComparatorBlock) && !(block instanceof ConduitBlock) && !(block instanceof DaylightDetectorBlock) && !(block instanceof EndGatewayBlock) && !(block instanceof EndPortalBlock) && !(block instanceof JigsawBlock) && !(block instanceof JukeboxBlock) && !(block instanceof PistonExtensionBlock) && !(block instanceof SculkSensorBlock) && !(block instanceof SpawnerBlock) && !(block instanceof StructureBlock)) {
} else if (!(block instanceof AbstractBannerBlock) && !(block instanceof SignBlock) && !(block instanceof AbstractSkullBlock) && !(block instanceof BeehiveBlock) && !(block instanceof BedBlock) && !(block instanceof BellBlock) && !(block instanceof CampfireBlock) && !(block instanceof CommandBlock) && !(block instanceof ComparatorBlock) && !(block instanceof ConduitBlock) && !(block instanceof DaylightDetectorBlock) && !(block instanceof EndGatewayBlock) && !(block instanceof EndPortalBlock) && !(block instanceof JigsawBlock) && !(block instanceof JukeboxBlock) && !(block instanceof MovingPistonBlock) && !(block instanceof SculkSensorBlock) && !(block instanceof SpawnerBlock) && !(block instanceof StructureBlock)) {
registerSimpleBlock(block);
}
} else if (block instanceof CraftingTableBlock && !(block instanceof FletchingTableBlock) || block instanceof AnvilBlock || block instanceof CartographyTableBlock || block instanceof GrindstoneBlock || block instanceof LoomBlock || block instanceof StonecutterBlock) {
Expand All @@ -69,23 +72,23 @@ public static void init(String configMsg) {
});
configRemove(blockSet);
configAdd();
registerEntity(new Identifier("minecraft:entity.minecraft.chest_minecart"));
registerEntity(ResourceLocation.parse("minecraft:entity.minecraft.chest_minecart"));

MinecraftClient client = MinecraftClient.getInstance();
Minecraft client = Minecraft.getInstance();
TabManagerContainer tabManagerContainer = (TabManagerContainer) client;
tabManagerContainer.getTabManager().removeTabs();
LOGGER.info(configMsg.equals("save") ? "InventoryTabs: Config saved!" : "InventoryTabs: Config " + configMsg + "ed!");
}

private static void modCompatAdd() {
registerInventoryTab(new Identifier("onastick", "crafting_table_on_a_stick"));
registerInventoryTab(new Identifier("onastick", "smithing_table_on_a_stick"));
registerInventoryTab(new Identifier("onastick", "cartography_table_on_a_stick"));
registerInventoryTab(new Identifier("onastick", "anvil_on_a_stick"));
registerInventoryTab(new Identifier("onastick", "loom_on_a_stick"));
registerInventoryTab(new Identifier("onastick", "grindstone_on_a_stick"));
registerInventoryTab(new Identifier("onastick", "stonecutter_on_a_stick"));
registerInventoryTab(new Identifier("craftingpad", "craftingpad"));
registerInventoryTab(ResourceLocation.fromNamespaceAndPath("onastick", "crafting_table_on_a_stick"));
registerInventoryTab(ResourceLocation.fromNamespaceAndPath("onastick", "smithing_table_on_a_stick"));
registerInventoryTab(ResourceLocation.fromNamespaceAndPath("onastick", "cartography_table_on_a_stick"));
registerInventoryTab(ResourceLocation.fromNamespaceAndPath("onastick", "anvil_on_a_stick"));
registerInventoryTab(ResourceLocation.fromNamespaceAndPath("onastick", "loom_on_a_stick"));
registerInventoryTab(ResourceLocation.fromNamespaceAndPath("onastick", "grindstone_on_a_stick"));
registerInventoryTab(ResourceLocation.fromNamespaceAndPath("onastick", "stonecutter_on_a_stick"));
registerInventoryTab(ResourceLocation.fromNamespaceAndPath("craftingpad", "craftingpad"));
}

public static boolean isValid(String overrideEntry, String[] splitEntry, Set<String> invalidSet) {
Expand All @@ -101,17 +104,17 @@ private static void configRemove(Set<String> blockSet) {
if (InventoryTabs.getConfig().debugEnabled) {
LOGGER.info("Excluding: " + overrideEntry);
}
removeSimpleBlock(new Identifier(overrideEntry));
removeSimpleBlock(ResourceLocation.parse(overrideEntry));
}
}

private static void configRemove(Block block, Set<String> tagSet, Set<String> invalidSet) {
for (String overrideEntry : tagSet) {
String[] splitEntry = overrideEntry.split(":"); // split into two parts: tag id, item name
if (isValid(overrideEntry, splitEntry, invalidSet)) {
List<TagKey<Block>> blockStream = block.getRegistryEntry().streamTags().toList();
List<TagKey<Block>> blockStream = block.builtInRegistryHolder().tags().toList();
for (TagKey<Block> tagKey : blockStream) {
if (block.getRegistryEntry().isIn(TagKey.of(RegistryKeys.BLOCK, new Identifier(splitEntry[0], splitEntry[1])))) {
if (block.builtInRegistryHolder().is(TagKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(splitEntry[0], splitEntry[1])))) {
removeSimpleBlock(block);
if (InventoryTabs.getConfig().debugEnabled) {
LOGGER.info("Excluding: " + block);
Expand All @@ -127,11 +130,11 @@ private static void configAdd() {
if (InventoryTabs.getConfig().debugEnabled) {
LOGGER.info("Including: " + included_tab);
}
registerSimpleBlock(new Identifier(included_tab));
registerSimpleBlock(ResourceLocation.parse(included_tab));
}
}

public static void registerInventoryTab(Identifier itemId) {
public static void registerInventoryTab(ResourceLocation itemId) {
INVENTORY_TAB_PROVIDER.addItem(itemId);
}

Expand All @@ -152,7 +155,7 @@ public static void registerSimpleBlock(Block block) {
*
* @param blockId
*/
public static void registerSimpleBlock(Identifier blockId) {
public static void registerSimpleBlock(ResourceLocation blockId) {
if (InventoryTabs.getConfig().debugEnabled) {
LOGGER.info("Registering: " + blockId);
}
Expand All @@ -163,7 +166,7 @@ public static void removeSimpleBlock(Block block) {
SIMPLE_BLOCK_TAB_PROVIDER.removeBlock(block);
}

public static void removeSimpleBlock(Identifier blockId) {
public static void removeSimpleBlock(ResourceLocation blockId) {
SIMPLE_BLOCK_TAB_PROVIDER.removeBlock(blockId);
}

Expand All @@ -186,7 +189,7 @@ public static void registerUniqueBlock(Block block) {
UNIQUE_TAB_PROVIDER.addUniqueBlock(block);
}

public static void registerEntity(Identifier entityId) {
public static void registerEntity(ResourceLocation entityId) {
if (InventoryTabs.getConfig().debugEnabled) {
LOGGER.info("Registering: " + entityId);
}
Expand All @@ -198,11 +201,11 @@ public static void registerEntity(Identifier entityId) {
*
* @param blockId
*/
public static void registerChest(Identifier blockId) {
public static void registerChest(ResourceLocation blockId) {
CHEST_TAB_PROVIDER.addChestBlock(blockId);
}

public static TabProvider register(Identifier id, TabProvider tabProvider) {
public static TabProvider register(ResourceLocation id, TabProvider tabProvider) {
TAB_PROVIDERS.put(id, tabProvider);

return tabProvider;
Expand All @@ -211,4 +214,4 @@ public static TabProvider register(Identifier id, TabProvider tabProvider) {
public static List<TabProvider> getTabProviders() {
return new ArrayList<>(TAB_PROVIDERS.values());
}
}
}
Loading