Skip to content

Commit

Permalink
Merge pull request #59 from MoSadie/neoforge-split
Browse files Browse the repository at this point in the history
Cleaning up some folders
  • Loading branch information
MoSadie authored Dec 24, 2024
2 parents 20092a5 + 7c84e96 commit 056750d
Show file tree
Hide file tree
Showing 97 changed files with 1,760 additions and 139 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ jobs:
matrix:
mod-loader: ['fabric', 'forge']
mc-version: ['1.17.1', '1.18.2', '1.19.4']
include:
- mod-loader: 'forge'
mc-version: '1.20.1'
#exclude:
# - mod-loader: 'forge'
# mc-version: '1.17'
Expand Down Expand Up @@ -155,11 +158,8 @@ jobs:
strategy:
fail-fast: false
matrix:
mod-loader: ['fabric', 'forge']
mod-loader: ['fabric', 'neoforge']
mc-version: ["1.20.6", "1.21", "1.21.3", "1.21.4"]
#exclude:
# - mod-loader: 'forge'
# mc-version: '1.17'

steps:
# Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it
Expand Down
6 changes: 3 additions & 3 deletions MinecraftMod/forge/1.20.1/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle' version '[6.0.18,6.2)'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
}

version = mod_version
group = mod_group_id

base {
archivesName = "effectmc-neoforge-${minecraft_version}"
archivesName = "effectmc-forge-${minecraft_version}"
}

// Enable Jar in Jar
Expand Down Expand Up @@ -118,7 +118,7 @@ dependencies {
// The "userdev" classifier will be requested and setup by ForgeGradle.
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
minecraft "net.neoforged:forge:${minecraft_version}-${forge_version}"
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"

implementation "com.mosadie.effectmc:core:${effectmc_core_version}"
jarJar("com.mosadie.effectmc:core:${effectmc_core_version_range}")
Expand Down
8 changes: 4 additions & 4 deletions MinecraftMod/forge/1.20.1/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ org.gradle.daemon=false

# EffectMC Properties

effectmc_core_version=2.3
effectmc_core_version_range=[2.2,3.0)
mod_version=2.3.0
effectmc_core_version=3.1.0
effectmc_core_version_range=[3.1.0,4.0.0)
mod_version=3.1.0

mod_id=effectmc
mod_name=EffectMC
Expand All @@ -27,7 +27,7 @@ minecraft_version=1.20.1
minecraft_version_range=[1.20.1,1.21)

# The Forge version must agree with the Minecraft version to get a valid artifact
forge_version=47.1.81
forge_version=47.0.50

# The Forge version range can use any version of Forge as bounds or match the loader version range
forge_version_range=[47,)
Expand Down
2 changes: 1 addition & 1 deletion MinecraftMod/forge/1.20.1/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pluginManagement {
repositories {
gradlePluginPortal()
maven {
url = uri("https://maven.neoforged.net/releases")
url = uri("https://maven.minecraftforge.net/")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.text2speech.Narrator;
import com.mosadie.effectmc.core.EffectExecutor;
import com.mosadie.effectmc.core.EffectMCCore;
import com.mosadie.effectmc.core.WorldState;
import com.mosadie.effectmc.core.effect.*;
import com.mosadie.effectmc.core.effect.internal.Effect;
import com.mosadie.effectmc.core.effect.internal.EffectRequest;
import com.mosadie.effectmc.core.handler.*;
import net.minecraft.client.CameraType;
import net.minecraft.client.Minecraft;
Expand All @@ -28,6 +32,7 @@
import net.minecraft.nbt.NbtUtils;
import net.minecraft.nbt.TagParser;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.contents.TranslatableContents;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.WorldStem;
import net.minecraft.server.packs.repository.PackRepository;
Expand All @@ -40,6 +45,7 @@
import net.minecraft.world.item.WrittenBookItem;
import net.minecraft.world.level.storage.LevelStorageSource;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.RegisterClientCommandsEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
Expand Down Expand Up @@ -107,6 +113,7 @@ public EffectMC() throws IOException {
LOGGER.info("Server start result: " + result);

MinecraftForge.EVENT_BUS.addListener(this::registerClientCommand);
MinecraftForge.EVENT_BUS.addListener(this::listenForTranslation);

Header authHeader = new BasicHeader("Authorization", "Bearer " + Minecraft.getInstance().getUser().getAccessToken());
List<Header> headers = new ArrayList<>();
Expand All @@ -118,7 +125,7 @@ public void registerClientCommand(RegisterClientCommandsEvent event) {
LOGGER.info("Registering effectmc command.");
event.getDispatcher().register(Commands.literal("effectmc")
.then(Commands.literal("trust").executes((context -> {
Minecraft.getInstance().execute(core::setTrustNextRequest);
Minecraft.getInstance().execute(core::setTrustFlag);
receiveChatMessage("[EffectMC] Now prompting to trust the next request sent.");
return 0;
})))
Expand Down Expand Up @@ -161,13 +168,72 @@ public void registerClientCommand(RegisterClientCommandsEvent event) {
showItemToast(NbtUtils.prettyPrint(tag), "Exported", Minecraft.getInstance().player.getMainHandItem().getDisplayName().getString());
receiveChatMessage("[EffectMC] Exported held item data to log file!");
return 0;
}))).executes((context -> {
receiveChatMessage("[EffectMC] Available subcommands: exportbook, exportitem, trust");
}))).then(Commands.literal("exporteffect").executes((context -> {
core.setExportFlag();
receiveChatMessage("[EffectMC] Will export the next triggered effect as JSON to the current log file.");
return 0;
}))).then(Commands.literal("trigger").then(Commands.argument("json", StringArgumentType.greedyString()).executes((context -> {
String json = StringArgumentType.getString(context, "json");
EffectRequest request = core.requestFromJson(json);

if (request == null) {
receiveChatMessage("[EffectMC] Invalid JSON for effect request!");
return 0;
}

String worldId = getWorldState() == WorldState.SINGLEPLAYER ? getSPWorldName() : getServerIP();

Device device = new Device(worldId, getWorldState() == WorldState.SINGLEPLAYER ? DeviceType.WORLD : DeviceType.SERVER);

Effect.EffectResult result = core.triggerEffect(device, request);
switch (result.result) {
case SUCCESS -> receiveChatMessage("[EffectMC] Effect \"" + request.getEffectId() + "\" triggered successfully: " + result.message);
case ERROR -> receiveChatMessage("[EffectMC] Error triggering effect: " + result.message);
case UNAUTHORIZED -> receiveChatMessage("[EffectMC] World/Server not trusted. Use /effectmc trust to trust the current world/server.");
case UNKNOWN -> receiveChatMessage("[EffectMC] Unknown effect.");
case SKIPPED -> receiveChatMessage("[EffectMC] Effect skipped: " + result.message);
case UNSUPPORTED -> receiveChatMessage("[EffectMC] Effect unsupported: " + result.message);
}

return 0;
})))).executes((context -> {
receiveChatMessage("[EffectMC] Available subcommands: exportbook, exportitem, exporteffect, trigger, trust");
return 0;
})));
LOGGER.info("Registered effectmc command.");
}

public void listenForTranslation(ClientChatReceivedEvent event) {
Component component = event.getMessage();

if (component.getContents() instanceof TranslatableContents translationTextComponent) {

if (translationTextComponent.getKey().equals(EffectMCCore.TRANSLATION_TRIGGER_KEY)) {
event.setCanceled(true);

if (translationTextComponent.getArgs().length != 1) {
log("Invalid length of args for translation trigger!");
return;
}

String data = String.valueOf(translationTextComponent.getArgs()[0]);

EffectRequest request = core.requestFromJson(data);

if (request == null) {
log("Invalid request json for translation trigger!");
return;
}

String worldId = getWorldState() == WorldState.SINGLEPLAYER ? getSPWorldName() : getServerIP();

Device device = new Device(worldId, getWorldState() == WorldState.SINGLEPLAYER ? DeviceType.WORLD : DeviceType.SERVER);

core.triggerEffect(device, request);
}
}
}

@Override
public void log(String message) {
LOGGER.info(message);
Expand Down Expand Up @@ -206,7 +272,7 @@ public boolean joinServer(String serverIp) {
}

@Override
public boolean setSkinLayer(SkinLayerHandler.SKIN_SECTION section, boolean visibility) {
public boolean setSkinLayer(SkinLayerEffect.SKIN_SECTION section, boolean visibility) {
Options options = Minecraft.getInstance().options;

switch (section) {
Expand Down Expand Up @@ -249,7 +315,7 @@ public boolean setSkinLayer(SkinLayerHandler.SKIN_SECTION section, boolean visib
}

@Override
public boolean toggleSkinLayer(SkinLayerHandler.SKIN_SECTION section) {
public boolean toggleSkinLayer(SkinLayerEffect.SKIN_SECTION section) {
Options options = Minecraft.getInstance().options;
switch (section) {

Expand Down Expand Up @@ -338,7 +404,7 @@ public boolean showActionMessage(String message) {
}

@Override
public boolean triggerDisconnect(DisconnectHandler.NEXT_SCREEN nextScreenType, String title, String message) {
public boolean triggerDisconnect(DisconnectEffect.NEXT_SCREEN nextScreenType, String title, String message) {
Minecraft.getInstance().execute(() -> {
if (Minecraft.getInstance().level != null) {
LOGGER.info("Disconnecting from world...");
Expand Down Expand Up @@ -407,9 +473,9 @@ public boolean playSound(String soundID, String categoryName, float volume, floa
}

@Override
public void showTrustPrompt(String device) {
public void showTrustPrompt(Device device) {
Minecraft.getInstance().execute(() -> {
ConfirmScreen screen = new ConfirmScreen(new EffectMCCore.TrustBooleanConsumer(device, core), Component.literal("EffectMC - Trust Prompt"), Component.literal("Do you want to trust this device? (" + device + ")"));
ConfirmScreen screen = new ConfirmScreen(new EffectMCCore.TrustBooleanConsumer(device, core), Component.literal("EffectMC - Trust Prompt"), Component.literal("Do you want to trust this device?\n(Type: " + device.getType() + (device.getType() == DeviceType.OTHER ? " Device Id:" + device.getId() : "") + ")"));
Minecraft.getInstance().setScreen(screen);
});
}
Expand Down Expand Up @@ -512,7 +578,7 @@ public boolean loadWorld(String worldName) {
}

@Override
public boolean setSkin(URL skinUrl, SetSkinHandler.SKIN_TYPE skinType) {
public boolean setSkin(URL skinUrl, SetSkinEffect.SKIN_TYPE skinType) {
if (skinUrl == null) {
LOGGER.warn("Skin URL is null!");
return false;
Expand Down Expand Up @@ -557,7 +623,7 @@ public void leaveIfNeeded() {
}

@Override
public boolean openScreen(OpenScreenHandler.SCREEN screen) {
public boolean openScreen(OpenScreenEffect.SCREEN screen) {
Minecraft.getInstance().execute(() -> {
leaveIfNeeded();

Expand Down Expand Up @@ -591,7 +657,7 @@ public boolean setFOV(int fov) {
}

@Override
public boolean setPOV(SetPovHandler.POV pov) {
public boolean setPOV(SetPovEffect.POV pov) {
CameraType mcPov;

switch (pov) {
Expand Down Expand Up @@ -637,7 +703,7 @@ public boolean setGamma(double gamma) {
}

@Override
public boolean setChatVisibility(ChatVisibilityHandler.VISIBILITY visibility) {
public boolean setChatVisibility(ChatVisibilityEffect.VISIBILITY visibility) {
ChatVisiblity result;
switch (visibility) {
case SHOW:
Expand Down Expand Up @@ -697,6 +763,53 @@ public String getSPWorldName() {
return null;
}

@Override
public void setVolume(SetVolumeEffect.VOLUME_CATEGORIES category, int volume) {
Minecraft.getInstance().execute(() -> {

SoundSource mcSoundSource;

switch (category) {
case MASTER:
mcSoundSource = SoundSource.MASTER;
break;
case MUSIC:
mcSoundSource = SoundSource.MUSIC;
break;
case RECORDS:
mcSoundSource = SoundSource.RECORDS;
break;
case WEATHER:
mcSoundSource = SoundSource.WEATHER;
break;
case BLOCKS:
mcSoundSource = SoundSource.BLOCKS;
break;
case HOSTILE:
mcSoundSource = SoundSource.HOSTILE;
break;
case NEUTRAL:
mcSoundSource = SoundSource.NEUTRAL;
break;
case PLAYERS:
mcSoundSource = SoundSource.PLAYERS;
break;
case AMBIENT:
mcSoundSource = SoundSource.AMBIENT;
break;
case VOICE:
mcSoundSource = SoundSource.VOICE;
break;
default:
LOGGER.error("Unknown volume category!");
return;
}

Minecraft.getInstance().options.getSoundSourceOptionInstance(mcSoundSource).set(volume / 100.0d);
Minecraft.getInstance().options.save();
});
}

@Override
public String getServerIP() {
if (getWorldState() != WorldState.MULTIPLAYER) {
Expand Down
46 changes: 3 additions & 43 deletions MinecraftMod/forge/update.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
{
"homepage": "https://github.com/MoSadie/EffectMC",
"1.21.4": {
"3.1.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v3.1.0"
},
"1.21.3": {
"3.1.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v3.1.0",
"3.0.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v3.0.0"
},
"1.21.1": {
"3.1.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v3.1.0",
"3.0.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v3.0.0"
},
"1.21": {
"3.1.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v3.1.0",
"3.0.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v3.0.0",
"2.3.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v2.3.0"
},
"1.20.6": {
"3.1.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v3.1.0",
"3.0.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v3.0.0",
"2.3.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v2.3.0"
},
"1.20.4": {
"2.3.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v2.3.0"
},
"1.20.2": {
"2.3.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v2.3.0"
},
"1.20.1": {
"3.1.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v3.1.0",
"2.3.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v2.3.0",
"2.2.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v2.2.0"
},
Expand Down Expand Up @@ -98,22 +72,8 @@
"1.0.0": "See https://github.com/MoSadie/EffectMC/releases/tag/v1.0.0"
},
"promos": {
"1.21.4-latest": "3.1.0",
"1.21.4-recommended": "3.1.0",
"1.21.3-latest": "3.1.0",
"1.21.3-recommended": "3.1.0",
"1.21.1-latest": "3.1.0",
"1.21.1-recommended": "3.1.0",
"1.21-latest": "3.1.0",
"1.21-recommended": "3.1.0",
"1.20.6-latest": "3.1.0",
"1.20.6-recommended": "3.1.0",
"1.20.4-latest": "2.3.0",
"1.20.4-recommended": "2.3.0",
"1.20.2-latest": "2.3.0",
"1.20.2-recommended": "2.3.0",
"1.20.1-latest": "2.3.0",
"1.20.1-recommended": "2.3.0",
"1.20.1-latest": "3.1.0",
"1.20.1-recommended": "3.1.0",
"1.19.4-latest": "3.1.0",
"1.19.4-recommended": "3.1.0",
"1.19.3-latest": "2.3.0",
Expand Down
File renamed without changes.
Loading

0 comments on commit 056750d

Please sign in to comment.