Skip to content

Commit

Permalink
Fix status effect ui, fix vaults not showing polymer items
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Dec 16, 2024
1 parent 02a7720 commit 06374e5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fabric_version=0.111.0+1.21.4

maven_group = eu.pb4

mod_version = 0.11.2
mod_version = 0.11.3

minecraft_version_supported = ">=1.21.4-"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
import eu.pb4.polymer.core.impl.TransformingComponent;
import eu.pb4.polymer.core.impl.compat.polymc.PolyMcUtils;
import eu.pb4.polymer.core.impl.interfaces.BlockStateExtra;
import eu.pb4.polymer.core.impl.other.PolymerTooltipType;
import eu.pb4.polymer.core.mixin.block.BlockEntityUpdateS2CPacketAccessor;
import eu.pb4.polymer.rsm.api.RegistrySyncUtils;
import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.block.entity.VaultBlockEntity;
import net.minecraft.component.ComponentMap;
import net.minecraft.component.ComponentType;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -179,6 +181,28 @@ public static NbtCompound transformBlockEntityNbt(PacketContext context, BlockEn

var lookup = context.getRegistryWrapperLookup() != null ? context.getRegistryWrapperLookup() : PolymerImplUtils.FALLBACK_LOOKUP;

if (original.contains("shared_data", NbtElement.COMPOUND_TYPE)) {
var shared = original.getCompound("shared_data");
if (shared.contains("display_item")) {
var itemNbt = shared.getCompound("display_item");
var stack = ItemStack.fromNbtOrEmpty(lookup, itemNbt);
if (PolymerItemUtils.isPolymerServerItem(stack, context)) {
//noinspection ConstantValue
if (override == null) {
override = original.copy();
}

try {
override.getCompound("shared_data").put("display_item",
PolymerItemUtils.getPolymerItemStack(stack, context).toNbtAllowEmpty(lookup));
} catch (Throwable e) {
e.printStackTrace();
}
}
}
}


if (original.contains("Items", NbtElement.LIST_TYPE)) {
var list = original.getList("Items", NbtElement.COMPOUND_TYPE);
for (int i = 0; i < list.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ private void drawUi() {
}
icon.set(DataComponentTypes.HIDE_ADDITIONAL_TOOLTIP, Unit.INSTANCE);
icon.set(DataComponentTypes.RARITY, Rarity.COMMON);
icon.set(DataComponentTypes.ITEM_NAME, Text.empty()
icon.set(DataComponentTypes.CUSTOM_NAME, Text.empty()
.append(effectInstance.getEffectType().value().getName())
.append(Text.literal(" (")
.append(StatusEffectUtil.getDurationText(effectInstance, 1.0F, this.player.getServer().getTickManager().getTickRate()))
.append(")")
.formatted(Formatting.GRAY))
.setStyle(Style.EMPTY.withItalic(false))
);

//icon.getNbt().putInt("HideFlags", 255);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.command.argument.BlockStateArgumentType;
import net.minecraft.command.argument.ItemStackArgumentType;
import net.minecraft.command.argument.RegistryEntryArgumentType;
import net.minecraft.command.argument.RegistryEntryReferenceArgumentType;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -16,7 +17,8 @@
public abstract class CommandManagerMixin {
@Inject(method = "argument", at = @At("TAIL"))
private static void polymer$handleSuggestions(String name, ArgumentType<?> type, CallbackInfoReturnable<RequiredArgumentBuilder<ServerCommandSource, ?>> cir) {
if (type instanceof ItemStackArgumentType || type instanceof BlockStateArgumentType || type instanceof RegistryEntryArgumentType<?>) {
if (type instanceof ItemStackArgumentType || type instanceof BlockStateArgumentType
|| type instanceof RegistryEntryArgumentType<?> || type instanceof RegistryEntryReferenceArgumentType<?>) {
cir.getReturnValue().suggests(type::listSuggestions);
}
}
Expand Down

0 comments on commit 06374e5

Please sign in to comment.