Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.20.1' into 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
robotgryphon committed Nov 27, 2024
2 parents bd16396 + e25308e commit f0cf2c5
Show file tree
Hide file tree
Showing 9 changed files with 298 additions and 11 deletions.
20 changes: 14 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,21 @@ dependencies {
compileOnly fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")
runtimeOnly fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")

// The One Probe
implementation(fg.deobf("curse.maven:theoneprobe-245211:4629624"))
// Visual Data Mod
compileOnly fg.deobf("curse.maven:theoneprobe-245211:4629624")
compileOnly fg.deobf("curse.maven:jade-324717:5776962")

if (!System.getenv().containsKey("CI") && include_test_mods.equals("true")) {
// Nicephore - Screenshots and Stuff
//runtimeOnly(fg.deobf("curse.maven:nicephore-401014:3879841"))

// Visual Data Mods
if (visual_info_mod.equals("theoneprobe")) {
implementation(fg.deobf("curse.maven:theoneprobe-245211:4629624"))
} else if (visual_info_mod.equals("jade")) {
implementation(fg.deobf("curse.maven:jade-324717:5776962"))
}

// Testing Mods - Trash Cans, Pipez, Create, Refined Pipes, Pretty Pipes, Refined Storage
runtimeOnly(fg.deobf("curse.maven:SuperMartijn642Core-454372:5668859"))
runtimeOnly(fg.deobf("curse.maven:SuperMartijn642Config-438332:4715408"))
Expand All @@ -278,10 +286,10 @@ dependencies {
// runtimeOnly(fg.deobf("curse.maven:immersiveeng-231951:3587149"))

// FTB Chunks
// runtimeOnly(fg.deobf("curse.maven:architectury-forge-419699:3781711"))
// runtimeOnly(fg.deobf("curse.maven:ftb-teams-404468:3725501"))
// runtimeOnly(fg.deobf("curse.maven:ftblib-404465:3725485"))
// runtimeOnly(fg.deobf("curse.maven:ftbchunks-314906:3780113"))
// runtimeOnly(fg.deobf("curse.maven:architectury-forge-419699:5137938"))
// runtimeOnly(fg.deobf("curse.maven:ftb-teams-404468:5267190"))
// runtimeOnly(fg.deobf("curse.maven:ftblib-404465:5567591"))
// runtimeOnly(fg.deobf("curse.maven:ftbchunks-314906:5856503"))

// Mekanism + Mek Generators - Tunnel testing
runtimeOnly(fg.deobf("curse.maven:mekanism-268560:5662583"))
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ jei_version=15.18.0.79
mixin_version = 0.8.5
mixingradle_version = 0.7-SNAPSHOT

include_test_mods = true
include_test_mods = true
# theoneprobe or jade or none
visual_info_mod = jade
12 changes: 12 additions & 0 deletions src/api/java/dev/compactmods/machines/api/core/JadeInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package dev.compactmods.machines.api.core;

import net.minecraft.resources.ResourceLocation;

public class JadeInfo {
public static final String JADE_CONFIG = "config.jade.plugin_compactmachines";

public static final String MACHINE = JADE_CONFIG.concat(".machine");
public static final String MACHINE_TUNNELS = JADE_CONFIG.concat(".machine_tunnels");
public static final String TUNNEL = JADE_CONFIG.concat(".tunnel");
public static final String TUNNEL_CONNECTION = JADE_CONFIG.concat(".tunnel_connection");
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package dev.compactmods.machines.datagen.lang;

import dev.compactmods.machines.api.core.CMCommands;
import dev.compactmods.machines.api.core.Constants;
import dev.compactmods.machines.api.core.Messages;
import dev.compactmods.machines.api.core.Tooltips;
import dev.compactmods.machines.api.core.*;
import dev.compactmods.machines.api.room.RoomSize;
import dev.compactmods.machines.api.room.upgrade.RoomUpgrade;
import dev.compactmods.machines.client.CreativeTabs;
Expand Down Expand Up @@ -109,6 +106,13 @@ protected void addTranslations() {

addMessage(Messages.UNKNOWN_ROOM_CHUNK, "Unknown room at %s; please verify it exists.");

// Jade Plugin Specific Translations
add(JadeInfo.MACHINE, "Compact Machine Block Information");
add(JadeInfo.MACHINE_TUNNELS, "Compact Machine Tunnel Presence");
add(JadeInfo.TUNNEL, "Tunnel Information");
add(JadeInfo.TUNNEL_CONNECTION, "Tunnel Connection");


add("biome." + Constants.MOD_ID + ".machine", "Compact Machine");

add("compactmachines.psd.pages.machines.title", "Compact Machines");
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/dev/compactmods/machines/compat/jade/JadePlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package dev.compactmods.machines.compat.jade;

import dev.compactmods.machines.compat.jade.providers.client.CompactMachineProvider;
import dev.compactmods.machines.compat.jade.providers.client.TunnelProvider;
import dev.compactmods.machines.compat.jade.providers.server.CompactMachineComponentProvider;
import dev.compactmods.machines.compat.jade.providers.server.TunnelComponentProvider;
import dev.compactmods.machines.machine.CompactMachineBlock;
import dev.compactmods.machines.machine.CompactMachineBlockEntity;
import dev.compactmods.machines.tunnel.TunnelWallBlock;
import dev.compactmods.machines.tunnel.TunnelWallEntity;
import snownee.jade.api.IWailaClientRegistration;
import snownee.jade.api.IWailaCommonRegistration;
import snownee.jade.api.IWailaPlugin;
import snownee.jade.api.WailaPlugin;

@WailaPlugin
public class JadePlugin implements IWailaPlugin {
@Override
public void register(IWailaCommonRegistration registration) {
registration.registerBlockDataProvider(CompactMachineComponentProvider.INSTANCE, CompactMachineBlockEntity.class);
registration.registerBlockDataProvider(TunnelComponentProvider.INSTANCE, TunnelWallEntity.class);
}

@Override
public void registerClient(IWailaClientRegistration registration) {
registration.registerBlockComponent(CompactMachineProvider.INSTANCE, CompactMachineBlock.class);
registration.registerBlockComponent(TunnelProvider.INSTANCE, TunnelWallBlock.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package dev.compactmods.machines.compat.jade.providers.client;

import dev.compactmods.machines.api.core.Constants;
import dev.compactmods.machines.api.core.Tooltips;
import dev.compactmods.machines.i18n.TranslationUtil;
import dev.compactmods.machines.machine.CompactMachineBlockEntity;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.Vec2;
import snownee.jade.api.BlockAccessor;
import snownee.jade.api.IBlockComponentProvider;
import snownee.jade.api.ITooltip;
import snownee.jade.api.config.IPluginConfig;
import snownee.jade.api.ui.IElement;
import snownee.jade.api.ui.IElementHelper;

public class CompactMachineProvider implements IBlockComponentProvider {
public static final CompactMachineProvider INSTANCE = new CompactMachineProvider();

@Override
public void appendTooltip(
ITooltip tooltip,
BlockAccessor accessor,
IPluginConfig config
) {
final CompactMachineBlockEntity machine = (CompactMachineBlockEntity) accessor.getBlockEntity();
machine.getConnectedRoom().ifPresentOrElse(room -> {
tooltip.add(TranslationUtil.tooltip(Tooltips.Machines.BOUND_TO, room));
}, () -> {
MutableComponent newMachine = TranslationUtil
.message(new ResourceLocation(Constants.MOD_ID, "new_machine"))
.withStyle(ChatFormatting.GREEN);
tooltip.add(newMachine);
});

machine.getOwnerUUID().ifPresent(ownerID -> {
// Owner Name
Player owner = accessor.getLevel().getPlayerByUUID(ownerID);
if (owner != null) {
MutableComponent ownerName = TranslationUtil
.tooltip(Tooltips.Machines.OWNER, owner.getDisplayName())
.withStyle(ChatFormatting.GRAY);
tooltip.add(ownerName);
}
});

if (accessor.getServerData().contains("attached_tunnels")) {
ListTag tag = (ListTag) accessor.getServerData().get("attached_tunnels");
tooltip.add(Component.literal("")); // New Line
tag.forEach(t -> {
CompoundTag compound = (CompoundTag) t;
ItemStack itemStack = ItemStack.of(compound);
IElementHelper helper = tooltip.getElementHelper();
IElement icon = helper
.item(itemStack)
.size(new Vec2(15, 15))
.translate(new Vec2(-4, -3));
tooltip.append(icon);
});
}
}

@Override
public ResourceLocation getUid() {
return new ResourceLocation(Constants.MOD_ID, "machine");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package dev.compactmods.machines.compat.jade.providers.client;

import dev.compactmods.machines.api.core.Constants;
import dev.compactmods.machines.tunnel.TunnelWallBlock;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.phys.Vec2;
import snownee.jade.api.BlockAccessor;
import snownee.jade.api.IBlockComponentProvider;
import snownee.jade.api.ITooltip;
import snownee.jade.api.config.IPluginConfig;
import snownee.jade.api.ui.IElement;
import snownee.jade.api.ui.IElementHelper;

public class TunnelProvider implements IBlockComponentProvider {
public static final TunnelProvider INSTANCE = new TunnelProvider();

@Override
public void appendTooltip(ITooltip iTooltip, BlockAccessor blockAccessor, IPluginConfig iPluginConfig) {
Direction outSide = blockAccessor.getBlockState().getValue(TunnelWallBlock.CONNECTED_SIDE);

IElementHelper helper = iTooltip.getElementHelper();
IElement compassIcon = helper
.item(new ItemStack(Items.COMPASS), 1)
.size(new Vec2(15, 15)).translate(new Vec2(0, -1));
iTooltip.add(compassIcon);

String sideTranslated = Constants.MOD_ID + ".direction." + outSide.getName();
IElement directionText = helper
.text(Component.translatable(sideTranslated))
.translate(new Vec2(5, 3));
iTooltip.append(directionText);

if (blockAccessor.getServerData().contains("connected_block")) {
ItemStack connectedBlockItemStack =
ItemStack.of((CompoundTag) blockAccessor.getServerData().get("connected_block"));
IElement itemIcon = helper
.item(connectedBlockItemStack, 1)
.size(new Vec2(15, 15)).translate(new Vec2(0, -1));
iTooltip.add(itemIcon);
IElement itemName = helper
.text(connectedBlockItemStack.getHoverName())
.translate(new Vec2(5, 3));
iTooltip.append(itemName);
}
}

@Override
public ResourceLocation getUid() {
return new ResourceLocation(Constants.MOD_ID, "tunnel");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package dev.compactmods.machines.compat.jade.providers.server;

import dev.compactmods.machines.api.core.Constants;
import dev.compactmods.machines.api.dimension.CompactDimension;
import dev.compactmods.machines.machine.CompactMachineBlockEntity;
import dev.compactmods.machines.tunnel.TunnelItem;
import dev.compactmods.machines.tunnel.graph.TunnelConnectionGraph;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import snownee.jade.api.BlockAccessor;
import snownee.jade.api.IBlockComponentProvider;
import snownee.jade.api.IServerDataProvider;
import snownee.jade.api.ITooltip;
import snownee.jade.api.config.IPluginConfig;

public class CompactMachineComponentProvider implements IBlockComponentProvider, IServerDataProvider<BlockAccessor> {
public static final CompactMachineComponentProvider INSTANCE = new CompactMachineComponentProvider();

@Override
public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfig config) {
}

@Override
public void appendServerData(CompoundTag data, BlockAccessor accessor) {
final CompactMachineBlockEntity machine = (CompactMachineBlockEntity) accessor.getBlockEntity();
machine.getConnectedRoom().ifPresent(room -> {
final var compactDim = accessor.getLevel().getServer().getLevel(CompactDimension.LEVEL_KEY);
final var graph = TunnelConnectionGraph.forRoom(compactDim, room);
final var attachedTunnelsStream = graph.getTypesForSide(machine.getLevelPosition(), accessor.getSide());

ItemStack[] itemStackArray = attachedTunnelsStream
.map(TunnelItem::createStack)
.toArray(ItemStack[]::new);

ListTag attachedTunnels = new ListTag();
for (ItemStack itemStack : itemStackArray) {
CompoundTag tag = itemStack.save(new CompoundTag());
attachedTunnels.add(tag);
}

data.put("attached_tunnels", attachedTunnels);
});
}

@Override
public ResourceLocation getUid() {
return new ResourceLocation(Constants.MOD_ID, "machine_tunnels");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package dev.compactmods.machines.compat.jade.providers.server;

import dev.compactmods.machines.api.core.Constants;
import dev.compactmods.machines.api.location.IDimensionalBlockPosition;
import dev.compactmods.machines.api.location.IDimensionalPosition;
import dev.compactmods.machines.tunnel.TunnelWallEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import snownee.jade.api.BlockAccessor;
import snownee.jade.api.IBlockComponentProvider;
import snownee.jade.api.IServerDataProvider;
import snownee.jade.api.ITooltip;
import snownee.jade.api.config.IPluginConfig;

public class TunnelComponentProvider implements IBlockComponentProvider, IServerDataProvider<BlockAccessor> {
public static final TunnelComponentProvider INSTANCE = new TunnelComponentProvider();

@Override
public void appendTooltip(ITooltip iTooltip, BlockAccessor blockAccessor, IPluginConfig iPluginConfig) {
}

@Override
public void appendServerData(CompoundTag data, BlockAccessor accessor) {
final ServerLevel compactLevel = (ServerLevel) accessor.getLevel();

final TunnelWallEntity tunnelWallEntity = (TunnelWallEntity) accessor.getBlockEntity();
final IDimensionalBlockPosition machinePosition = tunnelWallEntity.getConnectedPosition();
final IDimensionalPosition connectedWorldPosition = machinePosition.relative(tunnelWallEntity.getConnectedSide());

final BlockState connectedBlockState = connectedWorldPosition
.level(compactLevel.getServer())
.getBlockState(connectedWorldPosition.getBlockPosition());

final BlockEntity connectedBlockEntity = connectedWorldPosition
.level(compactLevel.getServer())
.getBlockEntity(connectedWorldPosition.getBlockPosition());

if (!connectedBlockState.isAir()) {
ItemStack connectedBlockItemStack = connectedBlockState.getBlock().asItem().getDefaultInstance();
data.put("connected_block", connectedBlockItemStack.save(new CompoundTag()));
}
}

@Override
public ResourceLocation getUid() {
return new ResourceLocation(Constants.MOD_ID, "tunnel_connection");
}
}

0 comments on commit f0cf2c5

Please sign in to comment.