Skip to content

Commit

Permalink
Update compat code
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Dec 22, 2024
1 parent 016ec80 commit 999272a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 37 deletions.
6 changes: 3 additions & 3 deletions polymer-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ dependencies {
}


modCompileOnly /*modLocalRuntime*/("maven.modrinth:jade:14.1.0+fabric")
modCompileOnly /*modLocalRuntime*/("mcp.mobius.waila:wthit:fabric-11.2.0")
modCompileOnly /*modLocalRuntime*/("maven.modrinth:jade:17.1.2+fabric")
modCompileOnly /*modLocalRuntime*/("mcp.mobius.waila:wthit:fabric-14.0.1")

modCompileOnly /*modLocalRuntime*/ ("me.shedaniel:RoughlyEnoughItems-fabric:17.0.789")
modCompileOnly /*modLocalRuntime*/ ("me.shedaniel:RoughlyEnoughItems-fabric:18.0.796")
modCompileOnly /*modLocalRuntime*/("dev.emi:emi-fabric:1.1.6+1.20.6")

//modCompileOnlyApi modLocalRuntime("mezz.jei:jei-1.19-common:11.0.0.206")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.Entity;
import net.minecraft.item.PlayerHeadItem;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
Expand Down Expand Up @@ -77,15 +76,15 @@ public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfi

var block = InternalClientRegistry.getBlockAt(accessor.getPosition());
if (block != ClientPolymerBlock.NONE_STATE) {
var formatting = IWailaConfig.get().getFormatting();
var formatting = IWailaConfig.get().formatting();
tooltip.clear();
try {
tooltip.add(IThemeHelper.get().title(block.block().name().getString()), Identifiers.CORE_OBJECT_NAME);
tooltip.add(IThemeHelper.get().title(block.block().name().getString()), JadeIds.CORE_OBJECT_NAME);
} catch (Throwable e) {
}
try {

RegistryNameProvider.Mode mode = config.getEnum(Identifiers.DEBUG_REGISTRY_NAME);
RegistryNameProvider.Mode mode = config.getEnum(JadeIds.DEBUG_REGISTRY_NAME);

if (mode != RegistryNameProvider.Mode.OFF) {
if (mode != RegistryNameProvider.Mode.ADVANCED_TOOLTIPS || MinecraftClient.getInstance().options.advancedItemTooltips) {
Expand All @@ -97,7 +96,7 @@ public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfi

try {

if (config.get(Identifiers.DEBUG_BLOCK_STATES)) {
if (config.get(JadeIds.DEBUG_BLOCK_STATES)) {
IElementHelper helper = IElementHelper.get();
ITooltip box = helper.tooltip();
block.states().entrySet().forEach((p) -> {
Expand All @@ -114,13 +113,13 @@ public void appendTooltip(ITooltip tooltip, BlockAccessor accessor, IPluginConfi
}
try {

if (config.get(Identifiers.CORE_MOD_NAME)) {
if (config.get(JadeIds.CORE_MOD_NAME)) {
String modName = ModIdentification.getModName(block.block().identifier());

if (modName == null || modName.isEmpty() || modName.equals("Minecraft")) {
modName = "Server";
}
tooltip.add(IThemeHelper.get().modName(modName), Identifiers.CORE_MOD_NAME);
tooltip.add(IThemeHelper.get().modName(modName), JadeIds.CORE_MOD_NAME);
}
} catch (Throwable e) {
}
Expand Down Expand Up @@ -165,13 +164,13 @@ public void appendTooltip(ITooltip tooltip, EntityAccessor accessor, IPluginConf
if (type != null) {
try {

tooltip.add(IThemeHelper.get().title(entity.getDisplayName().getString()), Identifiers.CORE_OBJECT_NAME);
tooltip.add(IThemeHelper.get().title(entity.getDisplayName().getString()), JadeIds.CORE_OBJECT_NAME);
} catch (Throwable e) {
}

var formatting = IWailaConfig.get().getFormatting();
var formatting = IWailaConfig.get().formatting();

RegistryNameProvider.Mode mode = config.getEnum(Identifiers.DEBUG_REGISTRY_NAME);
RegistryNameProvider.Mode mode = config.getEnum(JadeIds.DEBUG_REGISTRY_NAME);
try {

if (mode != RegistryNameProvider.Mode.OFF) {
Expand All @@ -182,13 +181,13 @@ public void appendTooltip(ITooltip tooltip, EntityAccessor accessor, IPluginConf
} catch (Throwable e) {
}
try {
if (config.get(Identifiers.CORE_MOD_NAME)) {
if (config.get(JadeIds.CORE_MOD_NAME)) {
String modName = ModIdentification.getModName(type.identifier());

if (modName == null || modName.isEmpty() || modName.equals("Minecraft")) {
modName = "Server";
}
tooltip.add(IThemeHelper.get().modName(modName), Identifiers.CORE_MOD_NAME);
tooltip.add(IThemeHelper.get().modName(modName), JadeIds.CORE_MOD_NAME);
}
} catch (Throwable e) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public class JeiCompatibility implements IModPlugin {
@Override
public void registerRecipes(IRecipeRegistration registration) {
if (PolymerImpl.IS_CLIENT) {
//update(registration.getIngredientManager());
update(registration.getIngredientManager());
}
}

private static void update(IIngredientManager manager) {
synchronized (manager) {
try {
var list = manager.getAllIngredients(VanillaTypes.ITEM_STACK).stream().filter(PolymerImplUtils::isPolymerControlled).toList();
if (list.size() > 0) {
if (!list.isEmpty()) {
manager.removeIngredientsAtRuntime(VanillaTypes.ITEM_STACK, list);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package eu.pb4.polymer.core.impl.client.compat;

import eu.pb4.polymer.common.impl.entity.InternalEntityHelpers;
import eu.pb4.polymer.core.api.client.ClientPolymerBlock;
import eu.pb4.polymer.core.api.client.PolymerClientUtils;
import eu.pb4.polymer.core.api.item.PolymerItemUtils;
import eu.pb4.polymer.core.impl.client.InternalClientRegistry;
import eu.pb4.polymer.common.impl.entity.InternalEntityHelpers;
import mcp.mobius.waila.api.*;
import mcp.mobius.waila.api.component.EmptyComponent;
import mcp.mobius.waila.api.component.ItemComponent;
import mcp.mobius.waila.api.component.PairComponent;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.PlayerHeadItem;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
Expand All @@ -24,24 +23,24 @@
import org.jetbrains.annotations.Nullable;

@ApiStatus.Internal
public class WthitCompatibility implements IWailaPlugin {
public class WthitCompatibility implements IWailaClientPlugin {
private static final Identifier BLOCK_STATES = Identifier.tryParse("attribute.block_state");

@Override
public void register(IRegistrar registrar) {
registrar.addRedirect(BlockOverride.INSTANCE, Block.class, 400);
registrar.addComponent(BlockOverride.INSTANCE, TooltipPosition.HEAD, Block.class, 100000);
registrar.addComponent(BlockOverride.INSTANCE, TooltipPosition.BODY, Block.class, 100000);
registrar.addComponent(BlockOverride.INSTANCE, TooltipPosition.TAIL, Block.class, 100000);
registrar.addIcon(BlockOverride.INSTANCE, Block.class, 500);
public void register(IClientRegistrar registrar) {
registrar.redirect(BlockOverride.INSTANCE, Block.class, 400);
registrar.head(BlockOverride.INSTANCE, Block.class, 100000);
registrar.body(BlockOverride.INSTANCE, Block.class, 100000);
registrar.tail(BlockOverride.INSTANCE, Block.class, 100000);
registrar.icon(BlockOverride.INSTANCE, Block.class, 500);

registrar.addComponent(ItemEntityOverride.INSTANCE, TooltipPosition.HEAD, ItemEntity.class, 100000);
registrar.addComponent(ItemEntityOverride.INSTANCE, TooltipPosition.TAIL, ItemEntity.class, 100000);
registrar.head(ItemEntityOverride.INSTANCE, ItemEntity.class, 100000);
registrar.tail(ItemEntityOverride.INSTANCE, ItemEntity.class, 100000);

registrar.addComponent(EntityOverride.INSTANCE, TooltipPosition.HEAD, Entity.class, 100000);
registrar.addComponent(EntityOverride.INSTANCE, TooltipPosition.TAIL, Entity.class, 100000);
registrar.head(EntityOverride.INSTANCE, Entity.class, 100000);
registrar.tail(EntityOverride.INSTANCE, Entity.class, 100000);

registrar.addEventListener(OtherOverrides.INSTANCE);
registrar.eventListener(OtherOverrides.INSTANCE);
}

private static class OtherOverrides implements IEventListener {
Expand All @@ -58,7 +57,8 @@ private static class BlockOverride implements IBlockComponentProvider {

@Override
public @Nullable ITargetRedirector.Result redirect(ITargetRedirector redirect, IBlockAccessor accessor, IPluginConfig config) {
if (InternalClientRegistry.getBlockAt(accessor.getPosition()) != ClientPolymerBlock.NONE_STATE) return redirect.toSelf();
if (InternalClientRegistry.getBlockAt(accessor.getPosition()) != ClientPolymerBlock.NONE_STATE)
return redirect.toSelf();
return null;
}

Expand Down Expand Up @@ -154,7 +154,7 @@ public void appendTail(ITooltip tooltip, IEntityAccessor accessor, IPluginConfig
if (id != null) {
String modName = null;
var regBlock = Registries.ITEM.get(id);
if (regBlock != null) {
if (regBlock != null && regBlock != Items.AIR) {
modName = IModInfo.get(regBlock).getName();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
@Pseudo
@Environment(EnvType.CLIENT)
@Mixin(StackHelper.class)
public class jei_StackHelperMixin {/*
public class jei_StackHelperMixin {
@Inject(method = "getRegistryNameForStack", at = @At("HEAD"), cancellable = true, remap = false, require = 0)
private static void polymer$changeId(ItemStack stack, CallbackInfoReturnable<String> cir) {
var id = PolymerItemUtils.getServerIdentifier(stack);
if (id != null) {
cir.setReturnValue(id.toString());
}
}*/
}
}
4 changes: 3 additions & 1 deletion polymer-core/src/main/resources/waila_plugins.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"polymer:core": {
"initializer": "eu.pb4.polymer.core.impl.client.compat.WthitCompatibility",
"entrypoints": {
"client": "eu.pb4.polymer.core.impl.client.compat.WthitCompatibility"
},
"side": "client"
}
}

0 comments on commit 999272a

Please sign in to comment.