Skip to content

Commit

Permalink
Merge branch 'next/4.4.0' into compactmods/1.18.x
Browse files Browse the repository at this point in the history
  • Loading branch information
robotgryphon committed Jul 16, 2022
2 parents ba271ca + a38525f commit a5784dc
Show file tree
Hide file tree
Showing 58 changed files with 1,334 additions and 104 deletions.
13 changes: 12 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://maven.parchmentmc.org' }
maven { url = 'https://repo.spongepowered.org/repository/maven-public' }
mavenCentral()
mavenLocal()
}

dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:5.1.+"
classpath 'org.parchmentmc:librarian:1.+'
classpath "org.spongepowered:mixingradle:${mixingradle_version}"
}
}
Expand All @@ -19,6 +21,7 @@ plugins {
}

apply plugin: "net.minecraftforge.gradle"
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'org.spongepowered.mixin'

def semver = { ->
Expand Down Expand Up @@ -113,7 +116,7 @@ sourceSets {

println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
mappings channel: 'official', version: minecraft_version
mappings channel: 'parchment', version: parchment_version
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
Expand Down Expand Up @@ -307,6 +310,14 @@ dependencies {
// Mekanism + Mek Generators - Tunnel testing
runtimeOnly(fg.deobf("curse.maven:mekanism-268560:3743835"))
runtimeOnly(fg.deobf("curse.maven:mekanismgenerators-268566:3743837"))

// Soul Shards (FTB)
runtimeOnly(fg.deobf("curse.maven:polylib-576589:3751528"))
runtimeOnly(fg.deobf("curse.maven:soulshards-551523:3757202"))

// Everlasting Abilities
runtimeOnly(fg.deobf("curse.maven:cyclopscore-232758:3809427"))
runtimeOnly(fg.deobf("curse.maven:everlastabilities-248353:3768481"))
}
}

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ org.gradle.daemon=false

minecraft_version=1.18.2
forge_version=40.1.0
parchment_version=2022.07.03-1.18.2

mod_id=compactmachines

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class CMCommands {
public static final ResourceLocation LEVEL_REGISTERED = new ResourceLocation(MOD_ID, "level_registered");
public static final ResourceLocation LEVEL_NOT_FOUND = new ResourceLocation(MOD_ID, "level_not_found");

public static final ResourceLocation ROOM_NOT_FOUND = new ResourceLocation(MOD_ID, "room_not_found");

/**
* Used for displaying the number of registered machines via summary commands.
*/
Expand All @@ -32,4 +34,5 @@ public class CMCommands {
public static final ResourceLocation CANNOT_GIVE_MACHINE = new ResourceLocation(MOD_ID, "cannot_give_machine_item");
public static final ResourceLocation MACHINE_GIVEN = new ResourceLocation(MOD_ID, "machine_given_successfully");
public static final ResourceLocation NO_REBIND_TUNNEL_PRESENT = new ResourceLocation(MOD_ID, "cannot_rebind_tunnel_present");
public static final ResourceLocation SPAWN_CHANGED_SUCCESSFULLY = new ResourceLocation(MOD_ID, "spawn_changed_successfully");
}
11 changes: 11 additions & 0 deletions src/api/java/dev/compactmods/machines/api/core/CMTags.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dev.compactmods.machines.api.core;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;

public class CMTags {

public static final TagKey<Item> ROOM_UPGRADE_ITEM = ItemTags.create(new ResourceLocation(Constants.MOD_ID, "room_upgrade"));
}
16 changes: 16 additions & 0 deletions src/api/java/dev/compactmods/machines/api/core/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,20 @@ public abstract class Messages {
* Used to show information about a room, accessed via a bound machine.
*/
public static final ResourceLocation MACHINE_ROOM_INFO = new ResourceLocation(Constants.MOD_ID, "machine_room_info");

/**
* Shown when a non-owner tries to rename a room. Takes the owner's display name.
*/
public static final ResourceLocation CANNOT_RENAME_NOT_OWNER = new ResourceLocation(Constants.MOD_ID, "cannot_rename_not_owner");

/**
* Shown to players when they try to interact with a room they do not own. Provides the owner's display name.
*/
public static final ResourceLocation NOT_ROOM_OWNER = new ResourceLocation(Constants.MOD_ID, "not_the_room_owner");
public static final ResourceLocation UPGRADE_APPLIED = new ResourceLocation(Constants.MOD_ID, "upgrade_applied");
public static final ResourceLocation UPGRADE_ADD_FAILED = new ResourceLocation(Constants.MOD_ID, "upgrade_add_failed");
public static final ResourceLocation UPGRADE_REMOVED = new ResourceLocation(Constants.MOD_ID, "upgrade_removed");
public static final ResourceLocation UPGRADE_REM_FAILED = new ResourceLocation(Constants.MOD_ID, "upgrade_remove_failed");
public static final ResourceLocation ALREADY_HAS_UPGRADE = new ResourceLocation(Constants.MOD_ID, "upgrade_already_present");
public static final ResourceLocation UPGRADE_NOT_PRESENT = new ResourceLocation(Constants.MOD_ID, "upgrade_not_present");
}
2 changes: 2 additions & 0 deletions src/api/java/dev/compactmods/machines/api/core/Tooltips.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public abstract class Tooltips {
public static final ResourceLocation TUNNEL_TYPE = new ResourceLocation(Constants.MOD_ID, "tunnel_type");
public static final ResourceLocation UNKNOWN_TUNNEL_TYPE = new ResourceLocation(Constants.MOD_ID, "unknown_tunnel_type");
public static final ResourceLocation ROOM_NAME = new ResourceLocation(Constants.MOD_ID, "room_name");
public static final ResourceLocation ROOM_UPGRADE_TYPE = new ResourceLocation(Constants.MOD_ID, "room_upgrade_type");
public static final ResourceLocation TUTORIAL_APPLY_ROOM_UPGRADE = new ResourceLocation(Constants.MOD_ID, "tutorial_apply_room_upgrade");

public static abstract class Machines {
public static final ResourceLocation ID = new ResourceLocation(Constants.MOD_ID, "machine.id");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package dev.compactmods.machines.api.room.upgrade;

import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.ChunkPos;

public interface ILevelLoadedUpgradeListener extends RoomUpgrade {

/**
* Called when a level is loaded, typically when the server first boots up.
*/
default void onLevelLoaded(ServerLevel level, ChunkPos room) {}

/**
* Called when a level is unloaded.
*/
default void onLevelUnloaded(ServerLevel level, ChunkPos room) {}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package dev.compactmods.machines.api.room.upgrade;

import com.mojang.serialization.Codec;
import dev.compactmods.machines.api.core.Constants;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ChunkPos;
import net.minecraftforge.registries.IForgeRegistryEntry;

import static dev.compactmods.machines.api.core.Constants.MOD_ID;

public interface RoomUpgrade extends IForgeRegistryEntry<RoomUpgrade> {

ResourceKey<Registry<RoomUpgrade>> REG_KEY = ResourceKey.createRegistryKey(new ResourceLocation(MOD_ID, "room_upgrade"));

String UNNAMED_TRANS_KEY = "item." + MOD_ID + ".upgrades.unnamed";

default String getTranslationKey() {
final var rid = this.getRegistryName();
return "item." + rid.getNamespace() + ".upgrades." + rid.getPath().replace('/', '.');
}

default String getTranslationKey(ItemStack stack) {
final var rid = this.getRegistryName();
return "item." + rid.getNamespace() + ".upgrades." + rid.getPath().replace('/', '.');
}

/**
* Called when an upgrade is first applied to a room.
*/
default void onAdded(ServerLevel level, ChunkPos room) {}

/**
* Called when an update is removed from a room.
*/
default void onRemoved(ServerLevel level, ChunkPos room) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package dev.compactmods.machines.api.room.upgrade;

import net.minecraft.world.level.ChunkPos;

public record RoomUpgradeInstance<T extends RoomUpgrade>(T upgrade, ChunkPos room) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package dev.compactmods.machines.api.upgrade;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;

import java.util.Optional;

public abstract class RoomUpgradeHelper {

public static final String NBT_UPGRADE_NODE = "upgrade_info";
public static final String NBT_UPDATE_ID = "key";

public static Optional<ResourceLocation> getTypeFrom(@NotNull ItemStack stack) {
if(!stack.hasTag()) return Optional.empty();
final var tag = stack.getTag();
if(!tag.contains(NBT_UPGRADE_NODE)) return Optional.empty();

final var upg = tag.getCompound(NBT_UPGRADE_NODE);
if(!upg.contains(NBT_UPDATE_ID)) return Optional.empty();

final var upg2 = new ResourceLocation(upg.getString(NBT_UPDATE_ID));
return Optional.of(upg2);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package dev.compactmods.machines.datagen;

import dev.compactmods.machines.CompactMachines;
import dev.compactmods.machines.datagen.lang.BaseLangGenerator;
import dev.compactmods.machines.datagen.lang.EnglishLangGenerator;
import dev.compactmods.machines.datagen.lang.RussianLangGenerator;
import dev.compactmods.machines.datagen.tags.BlockTagGenerator;
import dev.compactmods.machines.datagen.tags.ItemTagGenerator;
import net.minecraft.data.DataGenerator;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.eventbus.api.SubscribeEvent;
Expand All @@ -28,10 +29,10 @@ private static void registerServerProviders(DataGenerator generator, GatherDataE
generator.addProvider(new BlockLootGenerator(generator));
generator.addProvider(new RecipeGenerator(generator));
generator.addProvider(new AdvancementGenerator(generator));
generator.addProvider(new TagGenerator(generator, helper));

generator.addProvider(new EnglishLangGenerator(generator));
generator.addProvider(new RussianLangGenerator(generator));
final var blocks = new BlockTagGenerator(generator, helper);
generator.addProvider(blocks);
generator.addProvider(new ItemTagGenerator(generator, blocks, helper));
}

private static void registerClientProviders(DataGenerator generator, GatherDataEvent event) {
Expand All @@ -40,5 +41,7 @@ private static void registerClientProviders(DataGenerator generator, GatherDataE
generator.addProvider(new TunnelWallStateGenerator(generator, helper));
generator.addProvider(new ItemModelGenerator(generator, helper));

generator.addProvider(new EnglishLangGenerator(generator));
generator.addProvider(new RussianLangGenerator(generator));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import dev.compactmods.machines.CompactMachines;
import dev.compactmods.machines.room.RoomSize;
import dev.compactmods.machines.upgrade.MachineRoomUpgrades;
import net.minecraft.data.DataGenerator;
import net.minecraftforge.client.model.generators.ItemModelProvider;
import net.minecraftforge.common.data.ExistingFileHelper;
Expand All @@ -25,6 +26,9 @@ protected void registerModels() {

withExistingParent("tunnel", mcLoc("item/generated"))
.texture("layer0", modLoc("item/tunnel"));

withExistingParent(MachineRoomUpgrades.CHUNKLOADER.getId().toString(), mcLoc("item/generated"))
.texture("layer0", modLoc("upgrades/chunkloader"));
}

private void machine(String size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dev.compactmods.machines.api.core.CMCommands;
import dev.compactmods.machines.api.core.Messages;
import dev.compactmods.machines.api.core.Tooltips;
import dev.compactmods.machines.api.room.upgrade.RoomUpgrade;
import dev.compactmods.machines.api.tunnels.TunnelDefinition;
import dev.compactmods.machines.core.Registration;
import dev.compactmods.machines.core.Tunnels;
Expand All @@ -15,7 +16,11 @@
import net.minecraft.core.Direction;
import net.minecraft.data.DataGenerator;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraftforge.common.data.LanguageProvider;
import net.minecraftforge.registries.RegistryObject;

import java.util.function.Supplier;

import static org.apache.commons.lang3.StringUtils.capitalize;

Expand Down Expand Up @@ -56,8 +61,14 @@ protected void addTooltip(ResourceLocation id, String translation) {
add(TranslationUtil.tooltipId(id), translation);
}

protected void addTunnel(TunnelDefinition tunnel, String name) {
add(TranslationUtil.tunnelId(tunnel.getRegistryName()), name);
protected void addTunnel(Supplier<TunnelDefinition> tunnel, String name) {
add(TranslationUtil.tunnelId(tunnel.get().getRegistryName()), name);
}

void addUpgradeItem(Supplier<RoomUpgrade> upgrade, String translation) {
final var u = upgrade.get();
if(u != null)
add(u.getTranslationKey(), translation);
}

protected void addAdvancementTranslations() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
import dev.compactmods.machines.api.core.CMCommands;
import dev.compactmods.machines.api.core.Messages;
import dev.compactmods.machines.api.core.Tooltips;
import dev.compactmods.machines.api.room.upgrade.RoomUpgrade;
import dev.compactmods.machines.core.Registration;
import dev.compactmods.machines.core.Tunnels;
import dev.compactmods.machines.room.RoomSize;
import dev.compactmods.machines.upgrade.MachineRoomUpgrades;
import net.minecraft.data.DataGenerator;
import net.minecraft.world.item.Item;
import net.minecraftforge.registries.RegistryObject;

import static org.apache.commons.lang3.StringUtils.capitalize;

Expand All @@ -28,10 +32,14 @@ protected void addTranslations() {
addMessage(Messages.TELEPORT_OUT_OF_BOUNDS, "An otherworldly force prevents your teleportation.");
addMessage(Messages.NO_TUNNEL_SIDE, "There are no available sides for this tunnel type.");

addMessage(Messages.NOT_ROOM_OWNER, "You are not the room owner; only %s may make changes.");

// 1 = Display Name, 2 = Chunk, 3 = Size
addMessage(Messages.PLAYER_ROOM_INFO, "Player '%1$s' is inside a %3$s room at %2$s.");
addMessage(Messages.MACHINE_ROOM_INFO, "Machine at %1$s is bound to a %2$s size room at %3$s");

addMessage(Messages.CANNOT_RENAME_NOT_OWNER, "Only %s may rename this room.");

addCommand(CMCommands.NOT_IN_COMPACT_DIMENSION, "Cannot use that command outside of a machine room.");
addCommand(CMCommands.FAILED_CMD_FILE_ERROR, "Failed to execute command; there was a file error. Check logs.");
addCommand(CMCommands.MACHINE_NOT_BOUND, "Machine at %s is not bound to a room.");
Expand All @@ -40,21 +48,25 @@ protected void addTranslations() {
addCommand(CMCommands.MACHINE_REG_TOTAL, "Total: %s");
addCommand(CMCommands.LEVEL_REGISTERED, "Compact Machine dimension found.");
addCommand(CMCommands.LEVEL_NOT_FOUND, "Compact Machine dimension could not be found.");
addCommand(CMCommands.ROOM_NOT_FOUND, "Room [%s] could not be found.");
addCommand(CMCommands.SPAWN_CHANGED_SUCCESSFULLY, "Spawnpoint for room [%s] was changed successfully.");

addAdvancementTranslations();

add(Registration.BLOCK_BREAKABLE_WALL.get(), "Compact Machine Wall");
add(Registration.BLOCK_SOLID_WALL.get(), "Solid Compact Machine Wall");
add(Tunnels.BLOCK_TUNNEL_WALL.get(), "Solid Compact Machine Wall (with Tunnel)");
addBlock(Registration.BLOCK_BREAKABLE_WALL, "Compact Machine Wall");
addBlock(Registration.BLOCK_SOLID_WALL, "Solid Compact Machine Wall");
addBlock(Tunnels.BLOCK_TUNNEL_WALL, "Solid Compact Machine Wall (with Tunnel)");

add(Registration.PERSONAL_SHRINKING_DEVICE.get(), "Personal Shrinking Device");

add(CompactMachines.MOD_ID + ".direction.side", "Side: %s");
add(CompactMachines.MOD_ID + ".connected_block", "Connected: %s");

addTunnel(Tunnels.ITEM_TUNNEL_DEF.get(), "Item Tunnel");
addTunnel(Tunnels.FLUID_TUNNEL_DEF.get(), "Fluid Tunnel");
addTunnel(Tunnels.FORGE_ENERGY.get(), "Energy Tunnel");
add(RoomUpgrade.UNNAMED_TRANS_KEY, "Unnamed Room Upgrade");

addTunnel(Tunnels.ITEM_TUNNEL_DEF, "Item Tunnel");
addTunnel(Tunnels.FLUID_TUNNEL_DEF, "Fluid Tunnel");
addTunnel(Tunnels.FORGE_ENERGY, "Energy Tunnel");
// addTunnel(Tunnels.REDSTONE_IN_DEF.get(), "Redstone Tunnel (In)");
// addTunnel(Tunnels.REDSTONE_OUT_DEF.get(), "Redstone Tunnel (Out)");

Expand All @@ -73,6 +85,23 @@ protected void addTranslations() {
addTooltip(Tooltips.UNKNOWN_TUNNEL_TYPE, "Unknown Tunnel Type (%s)");

addTooltip(Tooltips.ROOM_NAME, "Bound to room: %s");

//region Upgrades
addUpgradeItem(MachineRoomUpgrades.CHUNKLOAD, "Chunkloader Upgrade");

addMessage(Messages.ALREADY_HAS_UPGRADE, "Upgrade has already been applied to room.");
addMessage(Messages.UPGRADE_NOT_PRESENT, "Upgrade is not applied to the room.");

addMessage(Messages.UPGRADE_APPLIED, "Upgrade applied to room.");
addMessage(Messages.UPGRADE_ADD_FAILED, "Upgrade failed to apply to room.");

addMessage(Messages.UPGRADE_REMOVED, "Upgrade removed from room.");
addMessage(Messages.UPGRADE_REM_FAILED, "Upgrade removal failed to apply to room.");

addTooltip(Tooltips.ROOM_UPGRADE_TYPE, "Type: %s");
addTooltip(Tooltips.TUTORIAL_APPLY_ROOM_UPGRADE, "Use on a bound machine block to apply upgrade.");
//endregion

addCommand(CMCommands.CANNOT_GIVE_MACHINE, "Failed to give a new machine to player.");
addCommand(CMCommands.MACHINE_GIVEN, "Created a new machine item and gave it to %s.");

Expand Down
Loading

0 comments on commit a5784dc

Please sign in to comment.