Skip to content

Commit

Permalink
Old Item color is kil
Browse files Browse the repository at this point in the history
  • Loading branch information
Vazkii committed Nov 8, 2023
1 parent 6b0f890 commit 0b41740
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 64 deletions.
30 changes: 15 additions & 15 deletions src/main/java/vazkii/quark/addons/oddities/item/BackpackItem.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package vazkii.quark.addons.oddities.item;

import java.util.Map;
import java.util.function.BooleanSupplier;
import java.util.function.Consumer;

import javax.annotation.Nonnull;

import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.client.color.item.ItemColor;

import net.minecraft.client.model.HumanoidModel;
import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -18,7 +24,12 @@
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.*;
import net.minecraft.world.item.ArmorMaterials;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.DyeableArmorItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
Expand All @@ -31,7 +42,6 @@
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import vazkii.zeta.util.ItemNBTHelper;
import vazkii.quark.addons.oddities.inventory.BackpackMenu;
import vazkii.quark.addons.oddities.module.BackpackModule;
import vazkii.quark.base.Quark;
Expand All @@ -40,14 +50,9 @@
import vazkii.quark.base.handler.ProxiedItemStackHandler;
import vazkii.zeta.item.IZetaItem;
import vazkii.zeta.module.ZetaModule;
import vazkii.zeta.registry.IZetaItemColorProvider_OLD;

import javax.annotation.Nonnull;
import java.util.Map;
import java.util.function.BooleanSupplier;
import java.util.function.Consumer;
import vazkii.zeta.util.ItemNBTHelper;

public class BackpackItem extends DyeableArmorItem implements IZetaItem, MenuProvider, IZetaItemColorProvider_OLD {
public class BackpackItem extends DyeableArmorItem implements IZetaItem, MenuProvider {

private static final String WORN_TEXTURE = Quark.MOD_ID + ":textures/misc/backpack_worn.png";
private static final String WORN_OVERLAY_TEXTURE = Quark.MOD_ID + ":textures/misc/backpack_worn_overlay.png";
Expand Down Expand Up @@ -270,11 +275,6 @@ public void fillItemCategory(@Nonnull CreativeModeTab group, @Nonnull NonNullLis
super.fillItemCategory(group, items);
}

@Override
public ItemColor getItemColor() {
return (stack, i) -> i > 0 ? -1 : ((DyeableArmorItem) stack.getItem()).getColor(stack);
}

@Override
public AbstractContainerMenu createMenu(int id, @Nonnull Inventory inv, @Nonnull Player player) {
return new BackpackMenu(id, player);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package vazkii.quark.addons.oddities.module;

import net.minecraft.client.Minecraft;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
Expand All @@ -17,7 +18,12 @@
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.*;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.DyeableArmorItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material;
Expand All @@ -31,6 +37,7 @@
import vazkii.quark.base.module.config.Config;
import vazkii.quark.base.network.QuarkNetwork;
import vazkii.quark.base.network.message.oddities.HandleBackpackMessage;
import vazkii.zeta.client.event.ZAddItemColorHandlers;
import vazkii.zeta.client.event.ZClientSetup;
import vazkii.zeta.client.event.ZScreen;
import vazkii.zeta.client.event.ZStartClientTick;
Expand Down Expand Up @@ -167,6 +174,13 @@ public void clientTick(ZStartClientTick event) {
backpackRequested = false;
}
}


@LoadEvent
public void registerItemColors(ZAddItemColorHandlers event) {
ItemColor color = (stack, i) -> i > 0 ? -1 : ((DyeableArmorItem) stack.getItem()).getColor(stack);
event.register(color, backpack);
}

private static boolean isInventoryGUI(Screen gui) {
return gui != null && gui.getClass() == InventoryScreen.class;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
package vazkii.quark.content.tools.item;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.annotation.Nullable;

import net.minecraft.ChatFormatting;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.core.*;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.GlobalPos;
import net.minecraft.core.Holder;
import net.minecraft.core.NonNullList;
import net.minecraft.core.QuartPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -16,7 +29,11 @@
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.*;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.MapItem;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSource;
Expand All @@ -28,24 +45,15 @@
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.quark.base.Quark;
import vazkii.quark.base.QuarkClient;
import vazkii.zeta.util.ItemNBTHelper;
import vazkii.quark.base.item.QuarkItem;
import vazkii.zeta.module.ZetaModule;
import vazkii.quark.content.mobs.module.StonelingsModule;
import vazkii.quark.content.tools.module.PathfinderMapsModule;
import vazkii.quark.content.tools.module.PathfinderMapsModule.TradeInfo;
import vazkii.quark.content.world.module.GlimmeringWealdModule;
import vazkii.zeta.registry.IZetaItemColorProvider_OLD;

import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import vazkii.zeta.module.ZetaModule;
import vazkii.zeta.util.ItemNBTHelper;

public class PathfindersQuillItem extends QuarkItem implements IZetaItemColorProvider_OLD {
public class PathfindersQuillItem extends QuarkItem {

private static final Direction[] DIRECTIONS = new Direction[]{Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH};

Expand Down Expand Up @@ -403,13 +411,6 @@ public void appendHoverText(ItemStack stack, Level level, List<Component> comps,
} else comps.add(Component.translatable("quark.misc.quill_blank").withStyle(ChatFormatting.GRAY));
}

@Override
@OnlyIn(Dist.CLIENT)
public ItemColor getItemColor() {
return (stack, id) -> id == 0 ? 0xFFFFFF : getOverlayColor(stack);
}


//new concurrent search stuff. Experimental
private record Key(GlobalPos pos, ResourceLocation structure) {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
package vazkii.quark.content.tools.module;

import java.util.LinkedList;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import javax.annotation.Nonnull;

import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.vertex.PoseStack;

import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.client.Minecraft;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
Expand All @@ -30,6 +39,8 @@
import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType;
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.event.village.WandererTradesEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import vazkii.quark.base.Quark;
Expand All @@ -40,22 +51,21 @@
import vazkii.quark.base.module.config.type.IConfigType;
import vazkii.quark.content.tools.item.PathfindersQuillItem;
import vazkii.quark.content.tools.loot.InBiomeCondition;
import vazkii.zeta.client.event.ZAddItemColorHandlers;
import vazkii.zeta.client.event.ZClientSetup;
import vazkii.zeta.client.event.ZRenderGuiOverlay;
import vazkii.zeta.event.*;
import vazkii.zeta.event.ZConfigChanged;
import vazkii.zeta.event.ZLivingTick;
import vazkii.zeta.event.ZPlayerTick;
import vazkii.zeta.event.ZRegister;
import vazkii.zeta.event.ZVillagerTrades;
import vazkii.zeta.event.bus.LoadEvent;
import vazkii.zeta.event.bus.PlayEvent;
import vazkii.zeta.module.ZetaLoadModule;
import vazkii.zeta.module.ZetaModule;
import vazkii.zeta.util.Hint;
import vazkii.zeta.util.ItemNBTHelper;

import javax.annotation.Nonnull;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;

@ZetaLoadModule(category = "tools")
public class PathfinderMapsModule extends ZetaModule {

Expand Down Expand Up @@ -385,5 +395,12 @@ public void drawHUD(ZRenderGuiOverlay.Hotbar.Post event) {
}
}
}

@LoadEvent
public void registerItemColors(ZAddItemColorHandlers event) {
ItemColor color = (stack, id) -> id == 0 ? 0xFFFFFF : PathfindersQuillItem.getOverlayColor(stack);
event.register(color, pathfinders_quill);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
import net.minecraft.world.entity.player.Player;

//fixme Move this into a lifelong home & make other interfaces use this more
public interface PlayerGetter {
public interface PlayerGetter { // TODO rename to getPlayer to prevent overload with LivingGetter
Player getEntity();
}
18 changes: 0 additions & 18 deletions src/main/java/vazkii/zeta/registry/IZetaItemColorProvider_OLD.java

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/java/vazkii/zeta/util/RegistryUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import net.minecraft.resources.ResourceLocation;

public class RegistryUtil {

public static <T> List<T> massRegistryGet(Collection<String> coll, Registry<T> reg) {
return coll.stream().map(ResourceLocation::new).map(reg::get).filter(Objects::nonNull).toList();
}

}

0 comments on commit 0b41740

Please sign in to comment.