Skip to content

Commit

Permalink
*lots* of work on rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
JustAHuman-xD committed Nov 18, 2024
1 parent bb23715 commit f57f41d
Show file tree
Hide file tree
Showing 61 changed files with 391 additions and 15,315 deletions.
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
Slimefun Essentials is a minecraft mod dedicated to add support for Slimefun4 items and mechanics to other client sided mods.

### What does it do:
- Adds Support for Slimefun Recipes to EMI, REI, JEI
- Adds Support for Custom Textures for Placed Slimefun Blocks (Requires More Block Predicates on the Client and Requires Slimefun Server Essentials on the Server)
- Adds Support for Jade Tooltips for Placed Slimefun Blocks (Requires Jade on the Client and Requires Slimefun Server Essentials on the Server)
- More Coming Soon™
- TODO: rewrite this

### Downloads
- [Github](https://github.com/JustAHuman-xD/SlimefunEssentials/releases)
Expand All @@ -15,24 +12,15 @@ Slimefun Essentials is a minecraft mod dedicated to add support for Slimefun4 it
### Dependencies
- Mod Menu (Optional)
- Cloth Config API (Optional)
- More Block Predicates (Optional)
- Jade (Optional)
- One of the following: (Optional)
- EMI
- JEI
- REI

### Configuration:
- "block_features"
- Should Slimefun Essentials enabled support for Custom Textures & Jade Integration
- Requires More Block Predicates (For Custom Textures)
- Requires Jade (For Well Jade Integration)
- Requires Slimefun Server Essentials on the Server (For Any Features)
- "recipe_features"
- Should Slimefun Essentials add support for Slimefun Recipes
- Requires EMI, JEI, or REI
- "auto_toggle_addons"
- Should Slimefun Essentials attempt to automatically toggle on or off Addons when Joining a Server with Slimefun Server Essentials installed
- "addons"
- A list of addons to support
- Items **for all features** will only be supported if the addon they come from is in this list
- Requires SlimefunServerEssentials on the server
- TODO: fill out the rest of this
15 changes: 0 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
}

version = project.mod_version
Expand Down Expand Up @@ -30,13 +29,6 @@ repositories {
includeGroup "curse.maven"
}
}
maven {
name = "MoreBlockPredicates, Patchouli"
url = "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
mavenCentral()
}

Expand All @@ -46,8 +38,6 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation "maven.modrinth:patchouli:${project.patchouli_version}"

modImplementation "curse.maven:jade-324717:${project.jade_version}"

modImplementation ("dev.emi:emi-fabric:${project.emi_version}") {
Expand Down Expand Up @@ -107,9 +97,4 @@ jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
}
}

// configure the maven publication
publishing {
// TODO
}
35 changes: 10 additions & 25 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,44 +1,29 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.9

# Mod Properties
mod_version=0.4.1
maven_group=me.justahuman
archives_base_name=Slimefun Essentials

# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.108.0+1.21.1

# https://modrinth.com/mod/patchouli/versions?l=fabric
patchouli_version=1.21-87-fabric

# https://github.com/emilyploszaj/emi/releases
emi_version=1.1.18+1.21.1

# https://www.curseforge.com/minecraft/mc-mods/jei/files?page=1&pageSize=20&gameVersionTypeId=4&showAlphaFiles=show
jei_version=1.21.1-fabric:19.21.0.247

# https://linkie.shedaniel.dev/dependencies?loader=fabric
rei_version=16.0.788

# https://www.curseforge.com/minecraft/mc-mods/jade/files?page=1&pageSize=20&gameVersionTypeId=4
jade_version=5884237

# https://maven.terraformersmc.com/releases/com/terraformersmc/modmenu/
mod_menu_version=10.0.0

# https://modrinth.com/mod/cloth-config/versions
cloth_config_version=15.0.140

# https://github.com/shedaniel/cloth-basic-math
cloth_math_version=0.6.1
lombok_version=1.18.34

# https://projectlombok.org/setup/gradle
lombok_version=1.18.34
# https://modmuss50.me/fabric.html
# https://github.com/emilyploszaj/emi/releases
# https://www.curseforge.com/minecraft/mc-mods/jei/files?page=1&pageSize=20&gameVersionTypeId=4&showAlphaFiles=show
# https://linkie.shedaniel.dev/dependencies?loader=fabric
# https://www.curseforge.com/minecraft/mc-mods/jade/files?page=1&pageSize=20&gameVersionTypeId=4
# https://maven.terraformersmc.com/releases/com/terraformersmc/modmenu/
# https://modrinth.com/mod/cloth-config/versions
# https://github.com/shedaniel/cloth-basic-math
# https://projectlombok.org/setup/gradle
Original file line number Diff line number Diff line change
@@ -1,129 +1,68 @@
package me.justahuman.slimefun_essentials;

import me.justahuman.slimefun_essentials.client.ResourceLoader;
import me.justahuman.slimefun_essentials.client.payloads.DisabledItemPayload;
import me.justahuman.slimefun_essentials.client.payloads.SlimefunAddonPayload;
import me.justahuman.slimefun_essentials.client.payloads.SlimefunBlockPayload;
import me.justahuman.slimefun_essentials.client.SlimefunRegistry;
import me.justahuman.slimefun_essentials.client.payloads.ItemGroupsPayload;
import me.justahuman.slimefun_essentials.client.payloads.ItemsPayload;
import me.justahuman.slimefun_essentials.client.payloads.RecipeCategoryPayload;
import me.justahuman.slimefun_essentials.client.payloads.RecipeDisplayPayload;
import me.justahuman.slimefun_essentials.compat.cloth_config.ConfigScreen;
import me.justahuman.slimefun_essentials.config.ModConfig;
import me.justahuman.slimefun_essentials.utils.Payloads;
import me.justahuman.slimefun_essentials.utils.CompatUtils;
import me.justahuman.slimefun_essentials.utils.Utils;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.ChunkPos;
import org.lwjgl.glfw.GLFW;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

public class SlimefunEssentials implements ClientModInitializer {
public static final String MOD_ID = "slimefun_essentials";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

@Override
public void onInitializeClient() {
PayloadTypeRegistry.playS2C().register(Payloads.ADDON_CHANNEL, SlimefunAddonPayload.CODEC);
PayloadTypeRegistry.playS2C().register(Payloads.BLOCK_CHANNEL, SlimefunBlockPayload.CODEC);
PayloadTypeRegistry.playS2C().register(Payloads.ITEM_CHANNEL, DisabledItemPayload.CODEC);
PayloadTypeRegistry.playS2C().register(Payloads.ITEM_CHANNEL, ItemsPayload.CODEC);
PayloadTypeRegistry.playS2C().register(Payloads.ITEM_GROUPS_CHANNEL, ItemGroupsPayload.CODEC);
PayloadTypeRegistry.playS2C().register(Payloads.RECIPE_CATEGORY_CHANNEL, RecipeCategoryPayload.CODEC);
PayloadTypeRegistry.playS2C().register(Payloads.RECIPE_DISPLAY_CHANNEL, RecipeDisplayPayload.CODEC);
ModConfig.loadConfig();

/*if (CompatUtils.isPatchouliLoaded()) {
PatchouliIntegration.init();
}*/

if (CompatUtils.isClothConfigLoaded()) {
final KeyBinding keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding("slimefun_essentials.key_bind.open_config", GLFW.GLFW_KEY_F6, "slimefun_essentials.title"));
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (keyBinding.isPressed()) {
client.setScreen(ConfigScreen.buildScreen(client.currentScreen));
}
});
}

ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(new SimpleSynchronousResourceReloadListener() {
@Override
public Identifier getFabricId() {
return Utils.id("reload_listener");
}

@Override
public void reload(ResourceManager manager) {
if (MinecraftClient.getInstance().world == null) {
return;
}
ResourceLoader.clear();
ResourceLoader.loadResources(manager);
ClientPlayNetworking.registerGlobalReceiver(Payloads.ITEM_CHANNEL, (payload, context) -> {
if (ModConfig.recipeFeatures() && payload != ItemsPayload.EMPTY) {
payload.load();
SlimefunRegistry.loadItemModels();
}
});

if (ModConfig.blockFeatures()) {
ClientChunkEvents.CHUNK_LOAD.register(((world, chunk) -> {
final PacketByteBuf packetByteBuf = PacketByteBufs.create();
final ChunkPos chunkPos = chunk.getPos();
packetByteBuf.writeInt(chunkPos.x);
packetByteBuf.writeInt(chunkPos.z);

}));

ClientChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> ResourceLoader.removePlacedChunk(chunk.getPos()));

ClientPlayNetworking.registerGlobalReceiver(Payloads.BLOCK_CHANNEL, (payload, context) -> {
// If the id is a space that means it's no longer a slimefun block
if (payload.id().equals(" ")) {
ResourceLoader.removePlacedBlock(payload.pos());
return;
}

ResourceLoader.addPlacedBlock(payload.pos(), payload.id().toLowerCase());
});

ClientPlayConnectionEvents.DISCONNECT.register((handler, minecraftClient) -> ResourceLoader.clearPlacedBlocks());
}
ClientPlayNetworking.registerGlobalReceiver(Payloads.ITEM_CHANNEL, (payload, context) -> {
if (ModConfig.recipeFeatures() && payload != ItemsPayload.EMPTY) {
payload.load();
}
});

if (ModConfig.autoToggleAddons()) {
final List<String> normalAddons = new ArrayList<>();
ClientPlayNetworking.registerGlobalReceiver(Payloads.ADDON_CHANNEL, (payload, context) -> {
if (payload.addon().equals("clear")) {
normalAddons.addAll(ModConfig.getAddons());
ModConfig.getAddons().clear();
return;
}
ClientPlayNetworking.registerGlobalReceiver(Payloads.ITEM_CHANNEL, (payload, context) -> {
if (ModConfig.recipeFeatures() && payload != ItemsPayload.EMPTY) {
payload.load();
}
});

ModConfig.getAddons().add(payload.addon());
});
ClientPlayNetworking.registerGlobalReceiver(Payloads.ITEM_CHANNEL, (payload, context) -> {
if (ModConfig.recipeFeatures() && payload != ItemsPayload.EMPTY) {
payload.load();
}
});

ClientPlayConnectionEvents.DISCONNECT.register(((handler, client) -> {
if (!normalAddons.isEmpty()) {
ModConfig.getAddons().clear();
ModConfig.getAddons().addAll(normalAddons);
normalAddons.clear();
if (CompatUtils.isClothConfigLoaded()) {
final KeyBinding keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding("slimefun_essentials.key_bind.open_config", GLFW.GLFW_KEY_F6, "slimefun_essentials.title"));
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (keyBinding.isPressed()) {
client.setScreen(ConfigScreen.buildScreen(client.currentScreen));
}
}));
}

if (ModConfig.autoManageItems()) {
ClientPlayNetworking.registerGlobalReceiver(Payloads.ITEM_CHANNEL, (payload, context) -> {
ResourceLoader.blacklistItem(payload.id());
});

ClientPlayConnectionEvents.DISCONNECT.register(((handler, client) -> ResourceLoader.clearItemBlacklist()));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.justahuman.slimefun_essentials.api;

import me.justahuman.slimefun_essentials.SlimefunEssentials;
import me.justahuman.slimefun_essentials.client.ResourceLoader;
import me.justahuman.slimefun_essentials.client.SlimefunRegistry;
import me.justahuman.slimefun_essentials.client.SlimefunRecipeComponent;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
import net.minecraft.entity.EntityType;
Expand All @@ -17,7 +17,7 @@ default T interpretId(@NotNull SlimefunRecipeComponent component, @NotNull Strin
if (id.isEmpty() || id.isBlank()) {
return def;
}

if (!id.contains(":")) {
SlimefunEssentials.LOGGER.error("Invalid Ingredient Id: {}", id);
return def;
Expand All @@ -38,7 +38,7 @@ default T interpretId(@NotNull SlimefunRecipeComponent component, @NotNull Strin
id = id.substring(0, id.indexOf('%'));
} catch (Exception ignored) {}
}

final String type = id.substring(0, id.indexOf(':'));
final String count = id.substring(id.indexOf(':') + 1);
int amount = 1;
Expand All @@ -47,8 +47,8 @@ default T interpretId(@NotNull SlimefunRecipeComponent component, @NotNull Strin
} catch (Exception ignored) {}

// Slimefun Item
if (ResourceLoader.getSlimefunItems().containsKey(type)) {
final ItemStack itemStack = ResourceLoader.getSlimefunItems().get(type).copy().itemStack();
if (SlimefunRegistry.getSlimefunItems().containsKey(type)) {
final ItemStack itemStack = SlimefunRegistry.getSlimefunItems().get(type).copy().itemStack();
if (damage > 0) {
itemStack.setDamage(damage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
import net.minecraft.util.Identifier;

public enum DrawMode {
LIGHT, DARK, BOOK;
LIGHT, DARK;

public Identifier defaultIdentifier() {
return switch (this) {
case LIGHT -> TextureUtils.WIDGETS;
case DARK -> TextureUtils.WIDGETS_DARK;
case BOOK -> TextureUtils.WIDGETS_BOOK;
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package me.justahuman.slimefun_essentials.client;

import com.google.gson.JsonObject;

public class RecipeDisplay {
public static void deserialize(String type, JsonObject displayObject) {

}
}
Loading

0 comments on commit f57f41d

Please sign in to comment.