Skip to content
Merged
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ jobs:
include:
- mod-loader: 'forge'
mc-version: '1.20.1'
- mod-loader: 'fabric'
mc-version: '1.20.4'
#exclude:
# - mod-loader: 'forge'
# mc-version: '1.17'
Expand Down
4 changes: 2 additions & 2 deletions MinecraftMod/fabric/1.20.4/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.15.7

# Mod Properties
mod_version = 2.3.0
mod_version = 3.1.0
maven_group = com.mosadie.effectmc
archives_base_name = effectmc-fabric-1.20.4

# Dependencies
fabric_version=0.96.11+1.20.4

effectmc_core_version=2.3
effectmc_core_version=3.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.mojang.brigadier.CommandDispatcher;
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.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.ModInitializer;
Expand Down Expand Up @@ -123,7 +127,7 @@ private void registerClientCommand(CommandDispatcher<FabricClientCommandSource>
LOGGER.info("Registering Client Command");
dispatcher.register(ClientCommandManager.literal("effectmc")
.then(ClientCommandManager.literal("trust").executes((context -> {
MinecraftClient.getInstance().send(core::setTrustNextRequest);
MinecraftClient.getInstance().send(core::setTrustFlag);
receiveChatMessage("[EffectMC] Now prompting to trust the next request sent.");
return 0;
})))
Expand Down Expand Up @@ -166,8 +170,36 @@ private void registerClientCommand(CommandDispatcher<FabricClientCommandSource>
showItemToast(tag.toString(), "Exported", MinecraftClient.getInstance().player.getMainHandStack().getName().getString());
receiveChatMessage("[EffectMC] Exported held item data to log file!");
return 0;
}))).executes((context -> {
receiveChatMessage("[EffectMC] Available subcommands: exportbook, exportitem, trust");
}))).then(ClientCommandManager.literal("exporteffect").executes((context -> {
core.setExportFlag();
receiveChatMessage("[EffectMC] Will export the next triggered effect as JSON to the current log file.");
return 0;
}))).then(ClientCommandManager.literal("trigger").then(ClientCommandManager.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;
})));
}
Expand Down Expand Up @@ -201,7 +233,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) {
GameOptions options = MinecraftClient.getInstance().options;

switch (section) {
Expand Down Expand Up @@ -243,7 +275,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) {
GameOptions options = MinecraftClient.getInstance().options;

switch (section) {
Expand Down Expand Up @@ -334,15 +366,15 @@ public boolean showActionMessage(String message) {
}

@Override
public void showTrustPrompt(String device) {
public void showTrustPrompt(Device device) {
MinecraftClient.getInstance().send(() -> {
ConfirmScreen screen = new ConfirmScreen(new EffectMCCore.TrustBooleanConsumer(device, core), Text.of("EffectMC - Trust Prompt"), Text.of("Do you want to trust this device? (" + device + ")"));
ConfirmScreen screen = new ConfirmScreen(new EffectMCCore.TrustBooleanConsumer(device, core), Text.of("EffectMC - Trust Prompt"), Text.of("Do you want to trust this device?\n(Type: " + device.getType() + (device.getType() == DeviceType.OTHER ? " Device Id:" + device.getId() : "") + ")"));
MinecraftClient.getInstance().setScreen(screen);
});
}

@Override
public boolean triggerDisconnect(DisconnectHandler.NEXT_SCREEN nextScreenType, String title, String message) {
public boolean triggerDisconnect(DisconnectEffect.NEXT_SCREEN nextScreenType, String title, String message) {
MinecraftClient.getInstance().send(() -> {
leaveIfNeeded();

Expand Down Expand Up @@ -507,7 +539,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 @@ -552,7 +584,7 @@ public void leaveIfNeeded() {
}

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

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

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

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

@Override
public boolean setChatVisibility(ChatVisibilityHandler.VISIBILITY visibility) {
public boolean setChatVisibility(ChatVisibilityEffect.VISIBILITY visibility) {
ChatVisibility result;
switch (visibility) {
case SHOW:
Expand Down Expand Up @@ -706,6 +738,62 @@ public String getServerIP() {
return null;
}

@Override
public void setVolume(SetVolumeEffect.VOLUME_CATEGORIES category, int volume) {
MinecraftClient.getInstance().execute(() -> {
SoundCategory mcCategory;

switch (category) {
case MASTER:
mcCategory = SoundCategory.MASTER;
break;

case MUSIC:
mcCategory = SoundCategory.MUSIC;
break;

case RECORDS:
mcCategory = SoundCategory.RECORDS;
break;

case WEATHER:
mcCategory = SoundCategory.WEATHER;
break;

case BLOCKS:
mcCategory = SoundCategory.BLOCKS;
break;

case HOSTILE:
mcCategory = SoundCategory.HOSTILE;
break;

case NEUTRAL:
mcCategory = SoundCategory.NEUTRAL;
break;

case PLAYERS:
mcCategory = SoundCategory.PLAYERS;
break;

case AMBIENT:
mcCategory = SoundCategory.AMBIENT;
break;

case VOICE:
mcCategory = SoundCategory.VOICE;
break;

default:
LOGGER.error("Unknown volume category!");
return;
}

MinecraftClient.getInstance().options.getSoundVolumeOption(mcCategory).setValue(volume / 100.0d);
MinecraftClient.getInstance().options.write();
});
}

private void connectIfTrue(boolean connect) {
if (connect) {
joinServer(serverInfo.address);
Expand Down
Loading