colorful tooltips and 16384k cell

This commit is contained in:
GlodBlock committed 2023-01-23 20:52:19 +08:00
1 parent 8d072f0c89
commit 4440ea5a1c
13 files changed
+139 -82

No files matched your search

@@ -41,6 +41,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
@@ -94,6 +95,10 @@ public class ItemBasicFluidStorageCell extends AEBaseItem
this.idleDrain = 3.5;
this.perType = 8;
break;
case Cell16384kPart:
this.idleDrain = 4.0;
this.perType = 8;
break;
default:
this.idleDrain = 0.0;
this.perType = 8;
@@ -106,7 +111,10 @@ public class ItemBasicFluidStorageCell extends AEBaseItem
@Override
public String getItemStackDisplayName(ItemStack stack) {
return StatCollector.translateToLocalFormatted("item.fluid_storage." + this.totalBytes / 1024 + ".name");
return StatCollector.translateToLocalFormatted(
"item.fluid_storage." + this.totalBytes / 1024 + ".name",
CellType.getTypeColor(this.component),
EnumChatFormatting.RESET);
}
@Override
@@ -136,11 +144,14 @@ public class ItemBasicFluidStorageCell extends AEBaseItem
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
lines.add(cellInventory.getUsedBytes() + " " + GuiText.Of.getLocal() + ' '
+ cellInventory.getTotalBytes() + ' ' + GuiText.BytesUsed.getLocal());
lines.add(cellInventory.getStoredFluidTypes() + " " + GuiText.Of.getLocal() + ' '
+ cellInventory.getTotalFluidTypes() + ' ' + GuiText.Types.getLocal());
lines.add(EnumChatFormatting.WHITE + String.valueOf(cellInventory.getUsedBytes())
+ EnumChatFormatting.GRAY + " " + GuiText.Of.getLocal() + " "
+ EnumChatFormatting.DARK_GREEN + cellInventory.getTotalBytes() + " "
+ EnumChatFormatting.GRAY + GuiText.BytesUsed.getLocal());
lines.add(EnumChatFormatting.WHITE + String.valueOf(cellInventory.getStoredFluidTypes())
+ EnumChatFormatting.GRAY + " " + GuiText.Of.getLocal() + " "
+ EnumChatFormatting.DARK_GREEN + cellInventory.getTotalFluidTypes() + " "
+ EnumChatFormatting.GRAY + GuiText.Types.getLocal());
if (GuiScreen.isCtrlKeyDown()) {
if (cellInventory.getStoredFluidTypes() > 0) {
@@ -148,7 +159,7 @@ public class ItemBasicFluidStorageCell extends AEBaseItem
for (IAEFluidStack fluid : cellInventory.getContents()) {
if (fluid != null) {
lines.add(String.format(
" %s x%smB",
" %s x%s mB",
fluid.getFluidStack().getLocalizedName(),
format.toWideReadableForm(fluid.getStackSize())));
}
@@ -2,6 +2,7 @@ package com.glodblock.github.common.item;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.storage.CellType;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
@@ -13,12 +14,13 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
public class ItemBasicFluidStoragePart extends FCBaseItem {
public static final int types = 7;
public static final int types = 8;
private static final HashMap<Integer, IIcon> icon = new HashMap<>();
public ItemBasicFluidStoragePart() {
@@ -39,7 +41,8 @@ public class ItemBasicFluidStoragePart extends FCBaseItem {
@Override
public String getItemStackDisplayName(ItemStack stack) {
int meta = stack.getItemDamage();
return StatCollector.translateToLocalFormatted("item.fluid_part." + meta + ".name");
return StatCollector.translateToLocalFormatted(
"item.fluid_part." + meta + ".name", CellType.getTypeColor(meta), EnumChatFormatting.RESET);
}
@Override
@@ -4,6 +4,7 @@ import appeng.core.features.AEFeature;
import java.util.EnumSet;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
public enum CellType {
Cell1kPart(0, AEFeature.StorageCells),
@@ -12,7 +13,8 @@ public enum CellType {
Cell64kPart(3, AEFeature.StorageCells),
Cell256kPart(4, AEFeature.StorageCells),
Cell1024kPart(5, AEFeature.StorageCells),
Cell4096kPart(6, AEFeature.StorageCells);
Cell4096kPart(6, AEFeature.StorageCells),
Cell16384kPart(7, AEFeature.StorageCells);
private final EnumSet<AEFeature> features;
private int damageValue;
@@ -46,4 +48,30 @@ public enum CellType {
public void setItemInstance(final Item itemInstance) {
this.itemInstance = itemInstance;
}
public static EnumChatFormatting getTypeColor(int type) {
return getTypeColor(CellType.values()[type % CellType.values().length]);
}
public static EnumChatFormatting getTypeColor(CellType type) {
switch (type) {
case Cell1kPart:
return EnumChatFormatting.GOLD;
case Cell4kPart:
return EnumChatFormatting.YELLOW;
case Cell16kPart:
return EnumChatFormatting.GREEN;
case Cell64kPart:
return EnumChatFormatting.AQUA;
case Cell256kPart:
return EnumChatFormatting.BLUE;
case Cell1024kPart:
return EnumChatFormatting.LIGHT_PURPLE;
case Cell4096kPart:
return EnumChatFormatting.RED;
case Cell16384kPart:
return EnumChatFormatting.DARK_PURPLE;
}
return EnumChatFormatting.WHITE;
}
}
@@ -20,6 +20,7 @@ public class FluidCellHandler implements ICellHandler {
}
@Override
@SuppressWarnings("rawtypes")
public IMEInventoryHandler getCellInventory(
final ItemStack is, final ISaveProvider container, final StorageChannel channel) {
if (channel == StorageChannel.FLUIDS) {
@@ -39,6 +39,22 @@ public class FluidCellInventory implements IFluidCellInventory {
public static final int singleByteAmount = 256 * 8;
public FluidCellInventory(final ItemStack o, final ISaveProvider container) throws AppEngException {
if (o == null) {
throw new AppEngException("ItemStack was used as a cell, but was not a cell!");
}
this.cellType = null;
this.cellItem = o;
final Item type = this.cellItem.getItem();
if (type instanceof IStorageFluidCell) {
this.cellType = (IStorageFluidCell) this.cellItem.getItem();
}
if (this.cellType == null) {
throw new AppEngException("ItemStack was used as a cell, but was not a cell!");
}
if (!this.cellType.isStorageCell(this.cellItem)) {
throw new AppEngException("ItemStack was used as a cell, but was not a cell!");
}
if (fluidSlots == null) {
fluidSlots = new String[MAX_TYPE];
fluidSlotCount = new String[MAX_TYPE];
@@ -49,27 +65,6 @@ public class FluidCellInventory implements IFluidCellInventory {
}
}
if (o == null) {
throw new AppEngException("ItemStack was used as a cell, but was not a cell!");
}
this.cellType = null;
this.cellItem = o;
final Item type = this.cellItem.getItem();
if (type instanceof IStorageFluidCell) {
this.cellType = (IStorageFluidCell) this.cellItem.getItem();
}
if (this.cellType == null) {
throw new AppEngException("ItemStack was used as a cell, but was not a cell!");
}
if (!this.cellType.isStorageCell(this.cellItem)) {
throw new AppEngException("ItemStack was used as a cell, but was not a cell!");
}
this.container = container;
this.tagCompound = Platform.openNbtData(o);
this.storedFluids = this.tagCompound.getShort(FLUID_TYPE_TAG);
@@ -40,6 +40,8 @@ public class ItemAndBlockHolder {
new ItemBasicFluidStorageCell(CellType.Cell1024kPart, 1024).register();
public static ItemBasicFluidStorageCell CELL4096K =
new ItemBasicFluidStorageCell(CellType.Cell4096kPart, 4096).register();
public static ItemBasicFluidStorageCell CELL16384K =
new ItemBasicFluidStorageCell(CellType.Cell16384kPart, 16384).register();
public static ItemBasicFluidStoragePart CELL_PART = new ItemBasicFluidStoragePart().register();
public static void loadSetting() {
@@ -51,5 +53,6 @@ public class ItemAndBlockHolder {
CellType.Cell256kPart.setItemInstance(CELL_PART);
CellType.Cell1024kPart.setItemInstance(CELL_PART);
CellType.Cell4096kPart.setItemInstance(CELL_PART);
CellType.Cell16384kPart.setItemInstance(CELL_PART);
}
}
@@ -177,7 +177,7 @@ public class RecipeLoader implements Runnable {
"CEC",
"DCD",
'D',
"dyeBlue",
"dyeRed",
'C',
"anyCertusCrystal",
'E',
@@ -188,7 +188,7 @@ public class RecipeLoader implements Runnable {
"CGC",
"DCD",
'D',
"dyeBlue",
"dyeRed",
'C',
CellType.Cell1kPart.stack(1),
'P',
@@ -201,7 +201,7 @@ public class RecipeLoader implements Runnable {
"CGC",
"DCD",
'D',
"dyeBlue",
"dyeRed",
'C',
CellType.Cell4kPart.stack(1),
'P',
@@ -214,7 +214,7 @@ public class RecipeLoader implements Runnable {
"CGC",
"DCD",
'D',
"dyeBlue",
"dyeRed",
'C',
CellType.Cell16kPart.stack(1),
'P',
@@ -227,7 +227,7 @@ public class RecipeLoader implements Runnable {
"CGC",
"DCD",
'D',
"dyeBlue",
"dyeRed",
'C',
CellType.Cell64kPart.stack(1),
'P',
@@ -240,7 +240,7 @@ public class RecipeLoader implements Runnable {
"CGC",
"DCD",
'D',
"dyeBlue",
"dyeRed",
'C',
CellType.Cell256kPart.stack(1),
'P',
@@ -253,16 +253,30 @@ public class RecipeLoader implements Runnable {
"CGC",
"DCD",
'D',
"dyeBlue",
"dyeRed",
'C',
CellType.Cell1024kPart.stack(1),
'P',
AE2_PROCESS_CAL,
'G',
AE2_LAMP_GLASS));
GameRegistry.addRecipe(new ShapedOreRecipe(
CellType.Cell16384kPart.stack(1),
"DPD",
"CGC",
"DCD",
'D',
"dyeRed",
'C',
CellType.Cell4096kPart.stack(1),
'P',
AE2_PROCESS_ENG,
'G',
AE2_LAMP_GLASS));
ItemBasicFluidStorageCell[] cells =
new ItemBasicFluidStorageCell[] {CELL1K, CELL4K, CELL16K, CELL64K, CELL256K, CELL1024K, CELL4096K};
ItemBasicFluidStorageCell[] cells = new ItemBasicFluidStorageCell[] {
CELL1K, CELL4K, CELL16K, CELL64K, CELL256K, CELL1024K, CELL4096K, CELL16384K
};
for (ItemBasicFluidStorageCell cell : cells) {
GameRegistry.addRecipe(new ShapedOreRecipe(