Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed Sep 13, 2024
2 parents 09e4af8 + 1dea1f1 commit ffc9fe0
Show file tree
Hide file tree
Showing 47 changed files with 424 additions and 975 deletions.
1 change: 0 additions & 1 deletion .architectury-transformer/debug.log

This file was deleted.

17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ Your best friend when developing a Modpack. With an ever growing list of feature

## Features so far

- Reimplementation of the pause menu with a fully featured API for modders to properly add more buttons and features to the pause menu. This is a work in progress and will be expanded upon in the future.
- Structure Processor to resolve issues with WaterLogging blocks that should not be water logged
- Command to help you generate loot tables in game!
- Removal of toasts that are annoying
- Custom spawners behaviour
- Punish the player on break
- Prevent breaking of spawners
- Break torches / light sources near a spawner
- Modify the difficulty of the spawners mobs via a custom attribute
- A new `RandomNameLootFunction` that lets you set a list of names for an item and have the function select one at random
- A relatively simple re-implementation of (https://github.com/MCTeamPotato/SparseStructuresReforged/) for 1.21.1 to bridge the gap until they port. This is allowed per their MIT license.

## Using the features

Expand All @@ -26,14 +33,6 @@ It should look like this
}
```

### `create_loot_table` command

This one is super helpful, it'll allow you to create a loot table based on in-game items with their current data.

```java
// TODO, show how this works
```

### RandomNameLootFunction

The `RandomNameLootFunction` it a `LootItemFunction` that allows you to set an item's name based on a list of names. This requires a list of `Component`'s in `JSON` format to be placed in the `data/ftbpc/sources/random-name-loot-source.json` folder. You can use a `datapack` or `KubeJS` to modify this file as by default, it simply contains an example.
Expand Down
12 changes: 7 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
id "me.modmuss50.mod-publish-plugin" version "0.5.1"
}

Expand Down Expand Up @@ -34,7 +34,7 @@ allprojects {

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 17
options.release = 21
}

java {
Expand All @@ -45,6 +45,8 @@ allprojects {
subprojects {
apply plugin: "dev.architectury.loom"
apply plugin: 'maven-publish'

apply from: rootProject.file("extra-build.gradle")
apply from: 'https://raw.githubusercontent.com/FTBTeam/mods-meta/main/gradle/publishing.gradle'

loom {
Expand Down Expand Up @@ -126,9 +128,9 @@ publishMods {
curseforge("curseforgeFabric") {
from(curseForgeOptions, createOptions("fabric"))
projectId = curseforge_id
requires {slug = "fabric-api" }
requires {slug = "architectury-api" }
requires {slug = 'ftb-library-fabric' }
requires { slug = "fabric-api" }
requires { slug = "architectury-api" }
requires { slug = 'ftb-library-fabric' }
}

curseforge("curseforgeNeoForge") {
Expand Down
14 changes: 6 additions & 8 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,17 @@ dependencies {
// Do NOT use other classes from fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
// Remove the next line if you don't want to depend on the API
modApi "dev.architectury:architectury:${rootProject.architectury_version}"
modApi "dev.architectury:architectury:${rootProject.architectury_api_version}"

modImplementation ("dev.ftb.mods:ftb-library:${rootProject.ftb_library_version}") { transitive false }
modCompileOnly("net.darkhax.tips:Tips-Forge-${minecraft_version}:${tips_version}")
// modCompileOnly("net.darkhax.tips:Tips-Forge-${minecraft_version}:${tips_version}")

modCompileOnly("curse.maven:creeperhost-minetogether-267172:5300688")
modCompileOnly "net.creeperhost:polylib-fabric:2004.0.3-build.140"

modCompileOnlyApi("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")
modCompileOnlyApi("mezz.jei:jei-${minecraft_version}-gui:${jei_version}")
if (isEnabled(jei_enabled)) {
modCompileOnlyApi("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")
modCompileOnlyApi("mezz.jei:jei-${minecraft_version}-gui:${jei_version}")
}
}

def ENV = System.getenv()

publishing {
publications {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

public class CommandRegistry {
private static final Set<CommandEntry> COMMANDS = Set.of(
// new LootTableGeneratorCommand()
new SpawnerManagerClearCommand()
);

Expand Down
6 changes: 6 additions & 0 deletions common/src/main/java/dev/ftb/packcompanion/PackCompanion.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dev.architectury.registry.ReloadListenerRegistry;
import dev.architectury.utils.Env;
import dev.architectury.utils.EnvExecutor;
import dev.ftb.packcompanion.api.PackCompanionAPI;
import dev.ftb.packcompanion.config.PCCommonConfig;
import dev.ftb.packcompanion.config.PCServerConfig;
import dev.ftb.packcompanion.features.CommonFeature;
Expand All @@ -14,6 +15,7 @@
import dev.ftb.packcompanion.registry.LootTableRegistries;
import dev.ftb.packcompanion.registry.ReloadResourceManager;
import dev.ftb.packcompanion.registry.StructureProcessorRegistry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.packs.PackType;

Expand Down Expand Up @@ -53,4 +55,8 @@ private static void serverBeforeStart(MinecraftServer server) {
private static void serverStarted(MinecraftServer server) {
Features.INSTANCE.getServerFeatures().forEach(e -> e.setup(server));
}

public static ResourceLocation id(String path) {
return ResourceLocation.fromNamespaceAndPath(PackCompanionAPI.MOD_ID, path);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.ftb.packcompanion.client.screen.pause;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.realmsclient.RealmsMainScreen;
import dev.architectury.platform.Platform;
import dev.ftb.packcompanion.PackCompanionExpectPlatform;
Expand All @@ -11,91 +10,87 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.layouts.FrameLayout;
import net.minecraft.client.gui.layouts.GridLayout;
import net.minecraft.client.gui.screens.*;
import net.minecraft.client.gui.screens.achievement.StatsScreen;
import net.minecraft.client.gui.screens.advancements.AdvancementsScreen;
import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen;
import net.minecraft.client.gui.screens.options.OptionsScreen;
import net.minecraft.client.gui.screens.social.SocialInteractionsScreen;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.Nullable;

import java.util.function.Supplier;

public class CustomPauseScreen extends Screen {
public static boolean DISABLE_CUSTOM_PAUSE = false;

// Stolen from MC
private static final Component RETURN_TO_GAME = Component.translatable("menu.returnToGame");
private static final Component ADVANCEMENTS = Component.translatable("gui.advancements");
private static final Component STATS = Component.translatable("gui.stats");
private static final Component OPTIONS = Component.translatable("menu.options");
private static final Component SHARE_TO_LAN = Component.translatable("menu.shareToLan");
private static final Component PLAYER_REPORTING = Component.translatable("menu.playerReporting");
private static final Component RETURN_TO_MENU = Component.translatable("menu.returnToMenu");
private static final Component GAME = Component.translatable("menu.game");
private static final Component SAVING_LEVEL = Component.translatable("menu.savingLevel");

Minecraft minecraft = Minecraft.getInstance();
ScreenHolder holder = ScreenHolder.of(this);

@Nullable
private Button disconnectButton;

public CustomPauseScreen() {
super(Component.translatable("menu.game"));
super(GAME);
}

@Override
protected void init() {
this.addRenderableWidget(Button.builder(Component.translatable("menu.returnToGame"), (buttonx) -> {
GridLayout gridLayout = new GridLayout();
gridLayout.defaultCellSetting().padding(4, 4, 4, 0);
GridLayout.RowHelper rowHelper = gridLayout.createRowHelper(2);
rowHelper.addChild(Button.builder(RETURN_TO_GAME, button -> {
this.minecraft.setScreen(null);
this.minecraft.mouseHandler.grabMouse();
}).bounds(this.width / 2 - 102, this.height / 4 + 24 + -16, 204, 20).build());
}).width(204).build(), 2, gridLayout.newCellSettings().paddingTop(50));

var noAdvancements = PCClientConfig.REMOVE_ADVANCEMENTS_FROM_PAUSE.get();
if (!noAdvancements) {
this.addRenderableWidget(Button.builder( Component.translatable("gui.advancements"), (buttonx) -> {
this.minecraft.setScreen(new AdvancementsScreen(this.minecraft.player.connection.getAdvancements()));
}).bounds(this.width / 2 - 102, this.height / 4 + 48 + -16, 100, 20).build());
rowHelper.addChild(this.openScreenButton(ADVANCEMENTS, () -> new AdvancementsScreen(this.minecraft.player.connection.getAdvancements(), this)));
}

this.addRenderableWidget(Button.builder(Component.translatable("gui.stats"), (buttonx) -> {
this.minecraft.setScreen(new StatsScreen(this, this.minecraft.player.getStats()));
}).bounds(noAdvancements ? this.width / 2 - 102 : (this.width / 2 + 2), this.height / 4 + 48 + -16, noAdvancements ? 204 : 100, 20).build());
rowHelper.addChild(this.openScreenButton(STATS, () -> new StatsScreen(this, this.minecraft.player.getStats())));

if (PackCompanionExpectPlatform.hasModlistScreen()) {
this.addRenderableWidget(Button.builder(Component.translatable("ftbpackcompanion.pause.mods", Platform.getMods().size()), (buttonx) -> {
this.minecraft.setScreen(PackCompanionExpectPlatform.getModListScreen().apply(this));
}).bounds(this.width / 2 - 102, this.height / 4 + 56, 204, 20).build());
rowHelper.addChild(this.openScreenButton(Component.translatable("ftbpackcompanion.pause.mods", Platform.getMods().size()), () -> PackCompanionExpectPlatform.getModListScreen().apply(this), noAdvancements ? 98 : 204), noAdvancements ? 1 : 2);
}

this.addRenderableWidget(Button.builder(Component.translatable("menu.options"), (buttonx) -> {
this.minecraft.setScreen(new OptionsScreen(this, this.minecraft.options));
}).bounds(this.width / 2 - 102, this.height / 4 + 96 + -16, 100, 20).build());


rowHelper.addChild(this.openScreenButton(OPTIONS, () -> new OptionsScreen(this, this.minecraft.options)));
if (this.minecraft.hasSingleplayerServer() && !this.minecraft.getSingleplayerServer().isPublished()) {
this.addRenderableWidget(Button.builder(Component.translatable("menu.shareToLan"), (arg) -> {
this.minecraft.setScreen(new ShareToLanScreen(this));
}).bounds(this.width / 2 + 2, this.height / 4 + 96 + -16, 100, 20).build());
rowHelper.addChild(this.openScreenButton(SHARE_TO_LAN, () -> new ShareToLanScreen(this)));
} else {
this.addRenderableWidget(Button.builder(Component.translatable("menu.playerReporting"), (arg) -> {
this.minecraft.setScreen(new SocialInteractionsScreen());
}).bounds(this.width / 2 + 2, this.height / 4 + 96 + -16, 100, 20).build());
rowHelper.addChild(this.openScreenButton(PLAYER_REPORTING, () -> new SocialInteractionsScreen(this)));
}

Component component = this.minecraft.isLocalServer() ? Component.translatable("menu.returnToMenu") : Component.translatable("menu.disconnect");
this.addRenderableWidget(Button.builder(component, (buttonx) -> {
this.minecraft.getReportingContext().draftReportHandled(this.minecraft, this, () -> {
boolean bl = this.minecraft.isLocalServer();
ServerData serverData = this.minecraft.getCurrentServer();
this.minecraft.level.disconnect();
if (bl) {
this.minecraft.disconnect(new GenericDirtMessageScreen(Component.translatable("menu.savingLevel")));
} else {
this.minecraft.disconnect();
}

TitleScreen titleScreen = new TitleScreen();
if (bl) {
this.minecraft.setScreen(titleScreen);
} else if (serverData != null && serverData.isRealm()) {
this.minecraft.setScreen(new RealmsMainScreen(titleScreen));
} else {
this.minecraft.setScreen(new JoinMultiplayerScreen(titleScreen));
}
}, true);
}).bounds(this.width / 2 - 102, this.height / 4 + 120 + -16, 204, 20).build());
Component component = this.minecraft.isLocalServer() ? RETURN_TO_MENU : CommonComponents.GUI_DISCONNECT;
this.disconnectButton = rowHelper.addChild(Button.builder(component, button -> {
button.active = false;
this.minecraft.getReportingContext().draftReportHandled(this.minecraft, this, this::onDisconnect, true);
}).width(204).build(), 2);
gridLayout.arrangeElements();
FrameLayout.alignInRectangle(gridLayout, 0, 0, this.width, this.height, 0.5F, 0.25F);
gridLayout.visitWidgets(this::addRenderableWidget);

// NOTE: Only needed for testing
// this.addRenderableWidget(new Button(0, 0, 80, 20, Component.literal("Original main menu"), (buttonx) -> {
// this.addRenderableWidget(Button.builder(Component.literal("Original main menu"), (buttonx) -> {
// DISABLE_CUSTOM_PAUSE = true;
// this.minecraft.setScreen(new PauseScreen(true));
// }));
// }).bounds(0, 0, 80, 20).build());

initAdditionalPauseProviders();
}
Expand All @@ -112,6 +107,34 @@ private void initAdditionalPauseProviders() {
});
}

private Button openScreenButton(Component component, Supplier<Screen> supplier) {
return openScreenButton(component, supplier, 98);
}

private Button openScreenButton(Component component, Supplier<Screen> supplier, int width) {
return Button.builder(component, button -> this.minecraft.setScreen(supplier.get())).width(width).build();
}

private void onDisconnect() {
boolean bl = this.minecraft.isLocalServer();
ServerData serverData = this.minecraft.getCurrentServer();
this.minecraft.level.disconnect();
if (bl) {
this.minecraft.disconnect(new GenericMessageScreen(SAVING_LEVEL));
} else {
this.minecraft.disconnect();
}

TitleScreen titleScreen = new TitleScreen();
if (bl) {
this.minecraft.setScreen(titleScreen);
} else if (serverData != null && serverData.isRealm()) {
this.minecraft.setScreen(new RealmsMainScreen(titleScreen));
} else {
this.minecraft.setScreen(new JoinMultiplayerScreen(titleScreen));
}
}

@Override
public boolean keyPressed(int i, int j, int k) {
return super.keyPressed(i, j, k);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.ftb.packcompanion.client.screen.pause.providers;

import dev.ftb.packcompanion.PackCompanion;
import dev.ftb.packcompanion.api.client.pause.AdditionalPauseProvider;
import dev.ftb.packcompanion.api.client.pause.AdditionalPauseTarget;
import dev.ftb.packcompanion.api.client.pause.ScreenHolder;
Expand All @@ -14,8 +15,8 @@
import org.jetbrains.annotations.Nullable;

public class SupportPauseProvider implements AdditionalPauseProvider {
private static final ResourceLocation DISCORD_ICON = new ResourceLocation("ftbpc:textures/gui/discord.png");
private static final ResourceLocation GITHUB_ICON = new ResourceLocation("ftbpc:textures/gui/github.png");
private static final ResourceLocation DISCORD_ICON = PackCompanion.id("textures/gui/discord.png");
private static final ResourceLocation GITHUB_ICON = PackCompanion.id("textures/gui/github.png");

@Override
public @Nullable ScreenWidgetCollection init(AdditionalPauseTarget target, ScreenHolder screen, int x, int y) {
Expand Down

This file was deleted.

Loading

0 comments on commit ffc9fe0

Please sign in to comment.