Skip to content

Commit

Permalink
Merge pull request #170 from Hojosa/cork
Browse files Browse the repository at this point in the history
fix wine bottle texture tinting & add lang entries
  • Loading branch information
Alatyami authored Dec 26, 2024
2 parents 2429f77 + 9a577fe commit a03fdf6
Show file tree
Hide file tree
Showing 5 changed files with 451 additions and 340 deletions.
22 changes: 14 additions & 8 deletions src/main/java/growthcraft/cellar/item/CellarPotionItem.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package growthcraft.cellar.item;

import java.util.List;

import javax.annotation.Nullable;

import org.jetbrains.annotations.NotNull;

import growthcraft.lib.item.GrowthcraftItem;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -12,15 +18,14 @@
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.*;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ItemUtils;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.UseAnim;
import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.gameevent.GameEvent;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nullable;
import java.awt.*;
import java.util.List;

public class CellarPotionItem extends GrowthcraftItem {

Expand Down Expand Up @@ -102,7 +107,8 @@ public boolean isFoil(ItemStack stack) {
}

@Override
public int getColor(int layer) {
return layer == 0 ? new Color(0xCFA26F).getRGB() : 0xFFFFFF;
public int getColor(ItemStack itemStack, int layer) {
CompoundTag tag = itemStack.getTag();
return layer == 0 ? tag != null ? itemStack.getTag().getInt("color") : 0xFFFFFF : 0xFFFFF;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package growthcraft.cellar.recipe;

import java.awt.Color;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

import growthcraft.cellar.GrowthcraftCellar;
import growthcraft.cellar.shared.Reference;
import growthcraft.lib.utils.CraftingUtils;
import growthcraft.lib.utils.EffectUtils;
import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -23,10 +30,6 @@
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.registries.ForgeRegistries;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.awt.*;

public class FermentationBarrelRecipe implements Recipe<SimpleContainer> {

Expand All @@ -48,12 +51,14 @@ public FermentationBarrelRecipe(ResourceLocation recipeId, FluidStack inputFluid
this.potionItemStack = bottle;
this.color = color;

CompoundTag tag = potionItemStack.getOrCreateTag();
tag.putInt("color", this.color.getRGB());

this.potionItemStack.setHoverName(
this.potionItemStack.getDisplayName().copy()
.append(" ")
.append(Component.translatable(this.outputFluidStack.getTranslationKey()))
);

).setTag(tag);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package growthcraft.lib.client;

import growthcraft.cellar.item.CellarPotionItem;
import growthcraft.lib.item.GrowthcraftItem;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.world.item.ItemStack;
Expand All @@ -10,10 +9,7 @@ public class GrowthcraftItemColor implements ItemColor {
public int getColor(ItemStack itemStack, int layer) {

if (itemStack.getItem() instanceof GrowthcraftItem growthcraftItem) {
return growthcraftItem.getColor(layer);
}
if (itemStack.getItem() instanceof CellarPotionItem cellarPotionItem) {
return cellarPotionItem.getColor(layer);
return growthcraftItem.getColor(itemStack, layer);
}
return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/growthcraft_cellar/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"block.growthcraft_cellar.cork_wood_log": "Cork Log",
"block.growthcraft_cellar.cork_wood_log_stripped": "Stripped Cork Log",
"block.growthcraft_cellar.cork_wood_stripped": "Stripped Cork Wood",
"block.growthcraft_cellar.cork_coaster": "Cork Coaster",
"container.growthcraft_cellar.brew_kettle": "Brew Kettle",
"container.growthcraft_cellar.culture_jar": "Culture Jar",
"container.growthcraft_cellar.fermentation_barrel": "Fermentation Barrel",
Expand Down Expand Up @@ -121,6 +122,7 @@
"item.growthcraft_cellar.yeast_ethereal": "Ethereal Yeast",
"item.growthcraft_cellar.yeast_lager": "Lager Yeast",
"item.growthcraft_cellar.yeast_lager_ethereal": "Lager Yeast (Ethereal)",
"item.growthcraft_cellar.cork_bark": "Cork Bark",
"growthcraft_cellar.tooltip.roaster.progress": "Roast Level %s (%d%%)",
"growthcraft_cellar.tooltip.fermentation.progress": "Fermenting %s%%",
"growthcraft_cellar.tooltip.fermentation.yeast_warning": "Insufficient yeast.",
Expand Down
Loading

0 comments on commit a03fdf6

Please sign in to comment.