Fluid color in cell changes color based on biome's water color + some other fixes and changes

This commit is contained in:
modmuss50 2019-07-28 17:29:01 +01:00
parent 0da3168bbf
commit b89a52e594
2 changed files with 11 additions and 3 deletions

View file

@ -85,7 +85,7 @@ public class DynamicCellBakedModel implements BakedModel, FabricBakedModel {
if(fluid != Fluids.EMPTY){
FluidRenderHandler fluidRenderHandler = FluidRenderHandlerRegistry.INSTANCE.get(fluid);
if(fluidRenderHandler != null){
int color = fluidRenderHandler.getFluidColor(MinecraftClient.getInstance().world, BlockPos.ORIGIN, fluid.getDefaultState());
int color = fluidRenderHandler.getFluidColor(MinecraftClient.getInstance().world, MinecraftClient.getInstance().player.getBlockPos(), fluid.getDefaultState());
//Does maths that works
color = new Color((float)(color >> 16 & 255) / 255.0F, (float)(color >> 8 & 255) / 255.0F,(float)(color & 255) / 255.0F).getRGB();

View file

@ -30,10 +30,13 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.DefaultedList;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import org.apache.commons.lang3.Validate;
import reborncore.common.fluid.FluidUtil;
import reborncore.common.fluid.container.ItemFluidInfo;
import reborncore.common.util.ItemNBTHelper;
import techreborn.TechReborn;
@ -63,8 +66,13 @@ public class ItemDynamicCell extends Item implements ItemFluidInfo {
}
@Override
public String getTranslationKey(ItemStack itemStack_1) {
return super.getTranslationKey(itemStack_1);
public Text getName(ItemStack itemStack) {
Fluid fluid = getFluid(itemStack);
if(fluid != Fluids.EMPTY){
//TODO use translation keys for fluid and the cell https://fabric.asie.pl/wiki/tutorial:lang?s[]=translation might be useful
return new LiteralText(FluidUtil.getFluidName(fluid) + " Cell");
}
return super.getName(itemStack);
}
public static ItemStack getCellWithFluid(Fluid fluid, int stackSize) {